Skip to content

Commit 444d9f3

Browse files
committed
do dsa_int_validate_* in dsa_import
1 parent fd94e95 commit 444d9f3

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

src/pk/dsa/dsa_import.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key)
2626
{
27-
int err;
27+
int err, stat;
2828
unsigned long zero = 0;
2929
unsigned char* tmpbuf = NULL;
3030
unsigned char flags[1];
@@ -116,10 +116,21 @@ int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key)
116116
}
117117

118118
LBL_OK:
119-
key->qord = mp_unsigned_bin_size(key->q);
119+
key->qord = mp_unsigned_bin_size(key->q);
120120

121-
if (key->qord >= LTC_MDSA_MAX_GROUP || key->qord <= 15 ||
122-
(unsigned long)key->qord >= mp_unsigned_bin_size(key->p) || (mp_unsigned_bin_size(key->p) - key->qord) >= LTC_MDSA_DELTA) {
121+
/* quick p, q, g validation, without primality testing */
122+
if ((err = dsa_int_validate_pqg(key, &stat)) != CRYPT_OK) {
123+
goto LBL_ERR;
124+
}
125+
if (stat == 0) {
126+
err = CRYPT_INVALID_PACKET;
127+
goto LBL_ERR;
128+
}
129+
/* validate x, y */
130+
if ((err = dsa_int_validate_xy(key, &stat)) != CRYPT_OK) {
131+
goto LBL_ERR;
132+
}
133+
if (stat == 0) {
123134
err = CRYPT_INVALID_PACKET;
124135
goto LBL_ERR;
125136
}

0 commit comments

Comments
 (0)