Mercurial > dropbear
comparison libtomcrypt/src/pk/dsa/dsa_shared_secret.c @ 1471:6dba84798cd5
Update to libtomcrypt 1.18.1, merged with Dropbear changes
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 09 Feb 2018 21:44:05 +0800 |
parents | f849a5ca2efc |
children |
comparison
equal
deleted
inserted
replaced
1470:8bba51a55704 | 1471:6dba84798cd5 |
---|---|
3 * LibTomCrypt is a library that provides various cryptographic | 3 * LibTomCrypt is a library that provides various cryptographic |
4 * algorithms in a highly modular and flexible manner. | 4 * algorithms in a highly modular and flexible manner. |
5 * | 5 * |
6 * The library is free for all purposes without any express | 6 * The library is free for all purposes without any express |
7 * guarantee it works. | 7 * guarantee it works. |
8 * | |
9 * Tom St Denis, [email protected], http://libtom.org | |
10 */ | 8 */ |
11 #include "tomcrypt.h" | 9 #include "tomcrypt.h" |
12 | 10 |
13 /** | 11 /** |
14 @file dsa_shared_secret.c | 12 @file dsa_shared_secret.c |
15 DSA Crypto, Tom St Denis | 13 DSA Crypto, Tom St Denis |
16 */ | 14 */ |
17 | 15 |
18 #ifdef LTC_MDSA | 16 #ifdef LTC_MDSA |
19 | 17 |
20 /** | 18 /** |
21 Create a DSA shared secret between two keys | 19 Create a DSA shared secret between two keys |
22 @param private_key The private DSA key (the exponent) | 20 @param private_key The private DSA key (the exponent) |
23 @param base The base of the exponentiation (allows this to be used for both encrypt and decrypt) | 21 @param base The base of the exponentiation (allows this to be used for both encrypt and decrypt) |
24 @param public_key The public key | 22 @param public_key The public key |
25 @param out [out] Destination of the shared secret | 23 @param out [out] Destination of the shared secret |
26 @param outlen [in/out] The max size and resulting size of the shared secret | 24 @param outlen [in/out] The max size and resulting size of the shared secret |
27 @return CRYPT_OK if successful | 25 @return CRYPT_OK if successful |
28 */ | 26 */ |
46 | 44 |
47 if ((err = mp_exptmod(base, private_key, public_key->p, res)) != CRYPT_OK) { | 45 if ((err = mp_exptmod(base, private_key, public_key->p, res)) != CRYPT_OK) { |
48 mp_clear(res); | 46 mp_clear(res); |
49 return err; | 47 return err; |
50 } | 48 } |
51 | 49 |
52 x = (unsigned long)mp_unsigned_bin_size(res); | 50 x = (unsigned long)mp_unsigned_bin_size(res); |
53 if (*outlen < x) { | 51 if (*outlen < x) { |
54 *outlen = x; | 52 *outlen = x; |
55 err = CRYPT_BUFFER_OVERFLOW; | 53 err = CRYPT_BUFFER_OVERFLOW; |
56 goto done; | 54 goto done; |
64 mp_clear(res); | 62 mp_clear(res); |
65 return err; | 63 return err; |
66 } | 64 } |
67 | 65 |
68 #endif | 66 #endif |
69 /* $Source$ */ | 67 /* ref: $Format:%D$ */ |
70 /* $Revision$ */ | 68 /* git commit: $Format:%H$ */ |
71 /* $Date$ */ | 69 /* commit time: $Format:%ai$ */ |
72 | 70 |