Mercurial > dropbear
comparison dss.c @ 118:5312ca05ed48 private-rez
propagate of 717950f4061f1123659ee87c7c168805af920ab7 and 839f98f136788cc1466e4641bf796f96040a085d from branch 'matt.dbclient.authpam' to 'matt.dbclient.rez'
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 12 Sep 2004 04:56:50 +0000 |
parents | 29a5c7c62350 |
children | 82fcf3185616 |
comparison
equal
deleted
inserted
replaced
57:3b2a5a1c4347 | 118:5312ca05ed48 |
---|---|
162 unsigned int len) { | 162 unsigned int len) { |
163 | 163 |
164 unsigned char msghash[SHA1_HASH_SIZE]; | 164 unsigned char msghash[SHA1_HASH_SIZE]; |
165 hash_state hs; | 165 hash_state hs; |
166 int ret = DROPBEAR_FAILURE; | 166 int ret = DROPBEAR_FAILURE; |
167 mp_int val1, val2, val3, val4; | 167 DEF_MP_INT(val1); |
168 DEF_MP_INT(val2); | |
169 DEF_MP_INT(val3); | |
170 DEF_MP_INT(val4); | |
168 char * string = NULL; | 171 char * string = NULL; |
169 int stringlen; | 172 int stringlen; |
170 | 173 |
171 TRACE(("enter buf_dss_verify")); | 174 TRACE(("enter buf_dss_verify")); |
172 assert(key != NULL); | 175 assert(key != NULL); |
176 | |
177 m_mp_init_multi(&val1, &val2, &val3, &val4, NULL); | |
173 | 178 |
174 /* get blob, check length */ | 179 /* get blob, check length */ |
175 string = buf_getstring(buf, &stringlen); | 180 string = buf_getstring(buf, &stringlen); |
176 if (stringlen != 2*SHA1_HASH_SIZE) { | 181 if (stringlen != 2*SHA1_HASH_SIZE) { |
177 goto out; | 182 goto out; |
179 | 184 |
180 /* hash the data */ | 185 /* hash the data */ |
181 sha1_init(&hs); | 186 sha1_init(&hs); |
182 sha1_process(&hs, data, len); | 187 sha1_process(&hs, data, len); |
183 sha1_done(&hs, msghash); | 188 sha1_done(&hs, msghash); |
184 | |
185 m_mp_init_multi(&val1, &val2, &val3, &val4, NULL); | |
186 | 189 |
187 /* create the signature - s' and r' are the received signatures in buf */ | 190 /* create the signature - s' and r' are the received signatures in buf */ |
188 /* w = (s')-1 mod q */ | 191 /* w = (s')-1 mod q */ |
189 /* let val1 = s' */ | 192 /* let val1 = s' */ |
190 if (mp_read_unsigned_bin(&val1, &string[SHA1_HASH_SIZE], SHA1_HASH_SIZE) | 193 if (mp_read_unsigned_bin(&val1, &string[SHA1_HASH_SIZE], SHA1_HASH_SIZE) |
279 unsigned int i; | 282 unsigned int i; |
280 #ifdef DSS_PROTOK | 283 #ifdef DSS_PROTOK |
281 unsigned char privkeyhash[SHA512_HASH_SIZE]; | 284 unsigned char privkeyhash[SHA512_HASH_SIZE]; |
282 unsigned char *privkeytmp; | 285 unsigned char *privkeytmp; |
283 unsigned char proto_k[SHA512_HASH_SIZE]; | 286 unsigned char proto_k[SHA512_HASH_SIZE]; |
284 mp_int dss_protok; | 287 DEF_MP_INT(dss_protok); |
285 #else | 288 #else |
286 unsigned char kbuf[SHA1_HASH_SIZE]; | 289 unsigned char kbuf[SHA1_HASH_SIZE]; |
287 #endif | 290 #endif |
288 mp_int dss_k, dss_m; | 291 DEF_MP_INT(dss_k); |
289 mp_int dss_temp1, dss_temp2; | 292 DEF_MP_INT(dss_m); |
290 mp_int dss_r, dss_s; | 293 DEF_MP_INT(dss_temp1); |
294 DEF_MP_INT(dss_temp2); | |
295 DEF_MP_INT(dss_r); | |
296 DEF_MP_INT(dss_s); | |
291 hash_state hs; | 297 hash_state hs; |
292 | 298 |
293 TRACE(("enter buf_put_dss_sign")); | 299 TRACE(("enter buf_put_dss_sign")); |
294 assert(key != NULL); | 300 assert(key != NULL); |
295 | 301 |