Mercurial > dropbear
comparison hmac_test.c @ 143:5d99163f7e32 libtomcrypt-orig
import of libtomcrypt 0.99
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 19 Dec 2004 11:34:45 +0000 |
parents | 7faae8f46238 |
children |
comparison
equal
deleted
inserted
replaced
15:6362d3854bb4 | 143:5d99163f7e32 |
---|---|
283 if (hash == -1) continue; | 283 if (hash == -1) continue; |
284 ++tested; | 284 ++tested; |
285 outlen = sizeof(digest); | 285 outlen = sizeof(digest); |
286 if((err = hmac_memory(hash, cases[i].key, cases[i].keylen, cases[i].data, cases[i].datalen, digest, &outlen)) != CRYPT_OK) { | 286 if((err = hmac_memory(hash, cases[i].key, cases[i].keylen, cases[i].data, cases[i].datalen, digest, &outlen)) != CRYPT_OK) { |
287 #if 0 | 287 #if 0 |
288 printf("HMAC-%s test #%d\n", cases[i].algo, cases[i].num); | 288 printf("HMAC-%s test #%d, %s\n", cases[i].algo, cases[i].num, error_to_string(err)); |
289 #endif | 289 #endif |
290 return err; | 290 return err; |
291 } | 291 } |
292 | 292 |
293 if(memcmp(digest, cases[i].digest, (size_t)hash_descriptor[hash].hashsize) != 0) { | 293 if(memcmp(digest, cases[i].digest, (size_t)hash_descriptor[hash].hashsize) != 0) { |
294 failed++; | |
294 #if 0 | 295 #if 0 |
295 unsigned int j; | 296 unsigned int j; |
296 printf("\nHMAC-%s test #%d:\n", cases[i].algo, cases[i].num); | 297 printf("\nHMAC-%s test #%d:\n", cases[i].algo, cases[i].num); |
297 printf( "Result: 0x"); | 298 printf( "Result: 0x"); |
298 for(j=0; j < hash_descriptor[hash].hashsize; j++) { | 299 for(j=0; j < hash_descriptor[hash].hashsize; j++) { |
301 printf("\nCorrect: 0x"); | 302 printf("\nCorrect: 0x"); |
302 for(j=0; j < hash_descriptor[hash].hashsize; j++) { | 303 for(j=0; j < hash_descriptor[hash].hashsize; j++) { |
303 printf("%2x ", cases[i].digest[j]); | 304 printf("%2x ", cases[i].digest[j]); |
304 } | 305 } |
305 printf("\n"); | 306 printf("\n"); |
307 return CRYPT_ERROR; | |
306 #endif | 308 #endif |
307 failed++; | |
308 //return CRYPT_ERROR; | |
309 } else { | 309 } else { |
310 /* printf("HMAC-%s test #%d: Passed\n", cases[i].algo, cases[i].num); */ | 310 /* printf("HMAC-%s test #%d: Passed\n", cases[i].algo, cases[i].num); */ |
311 } | 311 } |
312 } | 312 } |
313 | 313 |