]>
git.saurik.com Git - apple/security.git/blob - sec/Security/vmdh.h
5 * Created by Michael Brouwer on 11/7/06.
6 * Copyright (c) 2006-2007 Apple Inc. All Rights Reserved.
12 The functions provided in vmdh.h implement the crypto exchange required
13 for a Diffie-Hellman voicemail exchange.
16 #ifndef _SECURITY_VMDH_H_
17 #define _SECURITY_VMDH_H_
21 #include <sys/types.h>
27 typedef struct vmdh
*vmdh_t
;
29 /* Return a newly allocated vmdh object given g, p and the recip of p recip.
30 The recip and recip_len parameters are constant for a given p. They are
31 optional although providing them improves performance.
32 The caller should call vmdh_destroy once the returned handle is no longer
34 vmdh_t
vmdh_create(uint32_t g
, const uint8_t *p
, size_t p_len
,
35 const uint8_t *recip
, size_t recip_len
);
37 /* Generate a dh private/public keypair and return the public key in pub_key.
38 on input *pub_key_len is the number of bytes available in pub_key, on output
39 pub_key_len is the number of bytes actually in pub_key. Returns true on
40 success and false on failure. */
41 bool vmdh_generate_key(vmdh_t vmdh
, uint8_t *pub_key
, size_t *pub_key_len
);
43 /* Given the length of a password return the size of the encrypted password. */
44 #define vmdh_encpw_len(PWLEN) (((PWLEN) & ~0xf) + 16)
46 /* Given a vmdh handle and the other parties public key pub_key (of
47 pub_key_len bytes long), encrypt the password given by pw of pw_len bytes
48 long and return it in encpw. On input *enc_pw contains the number of bytes
49 available in encpw, on output *encpw will contain the actual length of
51 bool vmdh_encrypt_password(vmdh_t vmdh
,
52 const uint8_t *pub_key
, size_t pub_key_len
,
53 const uint8_t *pw
, size_t pw_len
, uint8_t *encpw
, size_t *encpw_len
);
55 /* Destroy a vmdh object created with vmdh_create(). */
56 void vmdh_destroy(vmdh_t vmdh
);
62 #endif /* _SECURITY_VMDH_H_ */