comparison libtomcrypt/src/pk/dsa/dsa_make_key.c @ 1439:8d24733026c5 coverity

merge
author Matt Johnston <matt@ucc.asn.au>
date Sat, 24 Jun 2017 23:33:16 +0800
parents f849a5ca2efc
children 6dba84798cd5
comparison
equal deleted inserted replaced
1400:238a439670f5 1439:8d24733026c5
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 * 8 *
9 * Tom St Denis, [email protected], http://libtomcrypt.com 9 * Tom St Denis, [email protected], http://libtom.org
10 */ 10 */
11 #include "tomcrypt.h" 11 #include "tomcrypt.h"
12 12
13 /** 13 /**
14 @file dsa_make_key.c 14 @file dsa_make_key.c
15 DSA implementation, generate a DSA key, Tom St Denis 15 DSA implementation, generate a DSA key, Tom St Denis
16 */ 16 */
17 17
18 #ifdef MDSA 18 #ifdef LTC_MDSA
19 19
20 /** 20 /**
21 Create a DSA key 21 Create a DSA key
22 @param prng An active PRNG state 22 @param prng An active PRNG state
23 @param wprng The index of the PRNG desired 23 @param wprng The index of the PRNG desired
39 if ((err = prng_is_valid(wprng)) != CRYPT_OK) { 39 if ((err = prng_is_valid(wprng)) != CRYPT_OK) {
40 return err; 40 return err;
41 } 41 }
42 42
43 /* check size */ 43 /* check size */
44 if (group_size >= MDSA_MAX_GROUP || group_size <= 15 || 44 if (group_size >= LTC_MDSA_MAX_GROUP || group_size <= 15 ||
45 group_size >= modulus_size || (modulus_size - group_size) >= MDSA_DELTA) { 45 group_size >= modulus_size || (modulus_size - group_size) >= LTC_MDSA_DELTA) {
46 return CRYPT_INVALID_ARG; 46 return CRYPT_INVALID_ARG;
47 } 47 }
48 48
49 /* allocate ram */ 49 /* allocate ram */
50 buf = XMALLOC(MDSA_DELTA); 50 buf = XMALLOC(LTC_MDSA_DELTA);
51 if (buf == NULL) { 51 if (buf == NULL) {
52 return CRYPT_MEM; 52 return CRYPT_MEM;
53 } 53 }
54 54
55 /* init mp_ints */ 55 /* init mp_ints */
115 115
116 key->type = PK_PRIVATE; 116 key->type = PK_PRIVATE;
117 key->qord = group_size; 117 key->qord = group_size;
118 118
119 #ifdef LTC_CLEAN_STACK 119 #ifdef LTC_CLEAN_STACK
120 zeromem(buf, MDSA_DELTA); 120 zeromem(buf, LTC_MDSA_DELTA);
121 #endif 121 #endif
122 122
123 err = CRYPT_OK; 123 err = CRYPT_OK;
124 goto done; 124 goto done;
125 error: 125 error:
130 return err; 130 return err;
131 } 131 }
132 132
133 #endif 133 #endif
134 134
135 /* $Source: /cvs/libtom/libtomcrypt/src/pk/dsa/dsa_make_key.c,v $ */ 135 /* $Source$ */
136 /* $Revision: 1.10 $ */ 136 /* $Revision$ */
137 /* $Date: 2006/12/04 03:18:43 $ */ 137 /* $Date$ */