1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner.
6 * The library is free for all purposes without any express
15 Binary export a DH key to a buffer
16 @param out [out] The destination for the key
17 @param outlen [in/out] The max size and resulting size of the DH key
18 @param type Which type of key (PK_PRIVATE or PK_PUBLIC)
19 @param key The key you wish to export
20 @return CRYPT_OK if successful
22 int dh_export_key(void *out, unsigned long *outlen, int type, dh_key *key)
27 LTC_ARGCHK(out != NULL);
28 LTC_ARGCHK(outlen != NULL);
29 LTC_ARGCHK(key != NULL);
31 k = (type == PK_PRIVATE) ? key->x : key->y;
32 len = mp_unsigned_bin_size(k);
36 return CRYPT_BUFFER_OVERFLOW;
40 return mp_to_unsigned_bin(k, out);
45 /* ref: $Format:%D$ */
46 /* git commit: $Format:%H$ */
47 /* commit time: $Format:%ai$ */