X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/80e2389990082500d76eb566d4946be3e786c3ef..d8f41ccd20de16f8ebe2ccc84d47bf1cb2b26bbb:/sec/Security/vmdh.c?ds=sidebyside diff --git a/sec/Security/vmdh.c b/sec/Security/vmdh.c deleted file mode 100644 index 65763233..00000000 --- a/sec/Security/vmdh.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * vmdh.c - * Security - * - * Created by Michael Brouwer on 11/7/06. - * Copyright (c) 2006-2007 Apple Inc. All Rights Reserved. - * - */ - -/*! - @header vmdh - The functions provided in vmdh.h implement the crypto exchange required - for a Diffie-Hellman voicemail exchange. -*/ - - -#include "vmdh.h" -#include -#include -#include -#include -#include - -vmdh_t vmdh_create(uint32_t g, const uint8_t *p, size_t p_len, - const uint8_t *recip, size_t recip_len) { - SecDHContext dh; - if (SecDHCreate(g, p, p_len, 0/*l*/, recip, recip_len, &dh)) - return NULL; - return (vmdh_t)dh; -} - -bool vmdh_generate_key(vmdh_t vmdh, uint8_t *pub_key, size_t *pub_key_len) { - return !SecDHGenerateKeypair((SecDHContext)vmdh, pub_key, pub_key_len); -} - -bool vmdh_encrypt_password(vmdh_t vmdh, - const uint8_t *pub_key, size_t pub_key_len, - const uint8_t *pw, size_t pw_len, uint8_t *encpw, size_t *encpw_len) { - uint8_t aes_key[kCCKeySizeAES128]; - size_t aes_key_len = kCCKeySizeAES128; - - if (SecDHComputeKey((SecDHContext)vmdh, pub_key, pub_key_len, - aes_key, &aes_key_len)) { - return false; - } - - /* Use the first 16 bytes in aes_key as an AES key. */ - if (CCCrypt(kCCEncrypt, kCCAlgorithmAES128, - kCCOptionPKCS7Padding, aes_key, kCCKeySizeAES128, NULL, - pw, pw_len, encpw, *encpw_len, encpw_len)) { - return false; - } - - /* Zero out key material. */ - bzero(aes_key, kCCKeySizeAES128); - - return true; -} - -void vmdh_destroy(vmdh_t vmdh) { - return SecDHDestroy((SecDHContext)vmdh); -}