Mercurial > dropbear
comparison dss.c @ 1410:771e4a7051e0
improve value range validation
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 14 Jun 2017 23:31:15 +0800 |
parents | c721e8c42d2a |
children | a54b22f4058d 79582b52a791 |
comparison
equal
deleted
inserted
replaced
1409:c721e8c42d2a | 1410:771e4a7051e0 |
---|---|
179 | 179 |
180 if (mp_cmp(&val1, key->q) != MP_LT) { | 180 if (mp_cmp(&val1, key->q) != MP_LT) { |
181 TRACE(("verify failed, s' >= q")) | 181 TRACE(("verify failed, s' >= q")) |
182 goto out; | 182 goto out; |
183 } | 183 } |
184 if (mp_cmp_d(&val1, 0) != MP_GT) { | |
185 TRACE(("verify failed, s' <= 0")) | |
186 goto out; | |
187 } | |
184 /* let val2 = w = (s')^-1 mod q*/ | 188 /* let val2 = w = (s')^-1 mod q*/ |
185 if (mp_invmod(&val1, key->q, &val2) != MP_OKAY) { | 189 if (mp_invmod(&val1, key->q, &val2) != MP_OKAY) { |
186 goto out; | 190 goto out; |
187 } | 191 } |
188 | 192 |
198 /* u2 = ((r')w) mod q */ | 202 /* u2 = ((r')w) mod q */ |
199 /* let val1 = r' */ | 203 /* let val1 = r' */ |
200 bytes_to_mp(&val1, (const unsigned char*) &string[0], SHA1_HASH_SIZE); | 204 bytes_to_mp(&val1, (const unsigned char*) &string[0], SHA1_HASH_SIZE); |
201 if (mp_cmp(&val1, key->q) != MP_LT) { | 205 if (mp_cmp(&val1, key->q) != MP_LT) { |
202 TRACE(("verify failed, r' >= q")) | 206 TRACE(("verify failed, r' >= q")) |
207 goto out; | |
208 } | |
209 if (mp_cmp_d(&val1, 0) != MP_GT) { | |
210 TRACE(("verify failed, r' <= 0")) | |
203 goto out; | 211 goto out; |
204 } | 212 } |
205 /* let val4 = u2 = ((r')w) mod q */ | 213 /* let val4 = u2 = ((r')w) mod q */ |
206 if (mp_mulmod(&val1, &val2, key->q, &val4) != MP_OKAY) { | 214 if (mp_mulmod(&val1, &val2, key->q, &val4) != MP_OKAY) { |
207 goto out; | 215 goto out; |