comparison dss.c @ 1415:2d937dc44851 fuzz

verify debug printing
author Matt Johnston <matt@ucc.asn.au>
date Tue, 20 Jun 2017 20:07:25 +0800
parents 79582b52a791
children 4f17d75d027b
comparison
equal deleted inserted replaced
1414:9236e7120c3e 1415:2d937dc44851
172 string = buf_getstring(buf, &stringlen); 172 string = buf_getstring(buf, &stringlen);
173 if (stringlen != 2*SHA1_HASH_SIZE) { 173 if (stringlen != 2*SHA1_HASH_SIZE) {
174 goto out; 174 goto out;
175 } 175 }
176 176
177 #if DEBUG_DSS_VERIFY
178 printmpint("dss verify p", key->p);
179 printmpint("dss verify q", key->q);
180 printmpint("dss verify g", key->g);
181 printmpint("dss verify x", key->x);
182 #endif
183
177 /* hash the data */ 184 /* hash the data */
178 sha1_init(&hs); 185 sha1_init(&hs);
179 sha1_process(&hs, data_buf->data, data_buf->len); 186 sha1_process(&hs, data_buf->data, data_buf->len);
180 sha1_done(&hs, msghash); 187 sha1_done(&hs, msghash);
181 188
182 /* create the signature - s' and r' are the received signatures in buf */ 189 /* create the signature - s' and r' are the received signatures in buf */
183 /* w = (s')-1 mod q */ 190 /* w = (s')-1 mod q */
184 /* let val1 = s' */ 191 /* let val1 = s' */
185 bytes_to_mp(&val1, (const unsigned char*) &string[SHA1_HASH_SIZE], SHA1_HASH_SIZE); 192 bytes_to_mp(&val1, (const unsigned char*) &string[SHA1_HASH_SIZE], SHA1_HASH_SIZE);
193 #if DEBUG_DSS_VERIFY
194 printmpint("dss verify s'", &val1);
195 #endif
186 196
187 if (mp_cmp(&val1, key->q) != MP_LT) { 197 if (mp_cmp(&val1, key->q) != MP_LT) {
188 TRACE(("verify failed, s' >= q")) 198 TRACE(("verify failed, s' >= q"))
189 goto out; 199 goto out;
190 } 200 }
198 } 208 }
199 209
200 /* u1 = ((SHA(M')w) mod q */ 210 /* u1 = ((SHA(M')w) mod q */
201 /* let val1 = SHA(M') = msghash */ 211 /* let val1 = SHA(M') = msghash */
202 bytes_to_mp(&val1, msghash, SHA1_HASH_SIZE); 212 bytes_to_mp(&val1, msghash, SHA1_HASH_SIZE);
213 #if DEBUG_DSS_VERIFY
214 printmpint("dss verify r'", &val1);
215 #endif
203 216
204 /* let val3 = u1 = ((SHA(M')w) mod q */ 217 /* let val3 = u1 = ((SHA(M')w) mod q */
205 if (mp_mulmod(&val1, &val2, key->q, &val3) != MP_OKAY) { 218 if (mp_mulmod(&val1, &val2, key->q, &val3) != MP_OKAY) {
206 goto out; 219 goto out;
207 } 220 }