comparison libtomcrypt/src/encauth/ocb/ocb_test.c @ 382:0cbe8f6dbf9e

propagate from branch 'au.asn.ucc.matt.ltc.dropbear' (head 2af22fb4e878750b88f80f90d439b316d229796f) to branch 'au.asn.ucc.matt.dropbear' (head 02c413252c90e9de8e03d91e9939dde3029f5c0a)
author Matt Johnston <matt@ucc.asn.au>
date Thu, 11 Jan 2007 02:41:05 +0000
parents 1b9e69c058d2
children f849a5ca2efc
comparison
equal deleted inserted replaced
379:b66a00272a90 382:0cbe8f6dbf9e
4 * algorithms in a highly modular and flexible manner. 4 * algorithms in a highly modular and flexible manner.
5 * 5 *
6 * The library is free for all purposes without any express 6 * The library is free for all purposes without any express
7 * guarantee it works. 7 * guarantee it works.
8 * 8 *
9 * Tom St Denis, [email protected], http://libtomcrypt.org 9 * Tom St Denis, [email protected], http://libtomcrypt.com
10 */ 10 */
11 11
12 /** 12 /**
13 @file ocb_test.c 13 @file ocb_test.c
14 OCB implementation, self-test by Tom St Denis 14 OCB implementation, self-test by Tom St Denis
180 if ((err = ocb_encrypt_authenticate_memory(idx, tests[x].key, 16, 180 if ((err = ocb_encrypt_authenticate_memory(idx, tests[x].key, 16,
181 tests[x].nonce, tests[x].pt, tests[x].ptlen, outct, outtag, &len)) != CRYPT_OK) { 181 tests[x].nonce, tests[x].pt, tests[x].ptlen, outct, outtag, &len)) != CRYPT_OK) {
182 return err; 182 return err;
183 } 183 }
184 184
185 if (memcmp(outtag, tests[x].tag, len) || memcmp(outct, tests[x].ct, tests[x].ptlen)) { 185 if (XMEMCMP(outtag, tests[x].tag, len) || XMEMCMP(outct, tests[x].ct, tests[x].ptlen)) {
186 #if 0 186 #if 0
187 unsigned long y; 187 unsigned long y;
188 printf("\n\nFailure: \nCT:\n"); 188 printf("\n\nFailure: \nCT:\n");
189 for (y = 0; y < (unsigned long)tests[x].ptlen; ) { 189 for (y = 0; y < (unsigned long)tests[x].ptlen; ) {
190 printf("0x%02x", outct[y]); 190 printf("0x%02x", outct[y]);
203 203
204 if ((err = ocb_decrypt_verify_memory(idx, tests[x].key, 16, tests[x].nonce, outct, tests[x].ptlen, 204 if ((err = ocb_decrypt_verify_memory(idx, tests[x].key, 16, tests[x].nonce, outct, tests[x].ptlen,
205 outct, tests[x].tag, len, &res)) != CRYPT_OK) { 205 outct, tests[x].tag, len, &res)) != CRYPT_OK) {
206 return err; 206 return err;
207 } 207 }
208 if ((res != 1) || memcmp(tests[x].pt, outct, tests[x].ptlen)) { 208 if ((res != 1) || XMEMCMP(tests[x].pt, outct, tests[x].ptlen)) {
209 #if 0 209 #if 0
210 unsigned long y; 210 unsigned long y;
211 printf("\n\nFailure-decrypt: \nPT:\n"); 211 printf("\n\nFailure-decrypt: \nPT:\n");
212 for (y = 0; y < (unsigned long)tests[x].ptlen; ) { 212 for (y = 0; y < (unsigned long)tests[x].ptlen; ) {
213 printf("0x%02x", outct[y]); 213 printf("0x%02x", outct[y]);
231 -- hard to stream [you can't emit ciphertext until full block] 231 -- hard to stream [you can't emit ciphertext until full block]
232 -- The setup is somewhat complicated... 232 -- The setup is somewhat complicated...
233 */ 233 */
234 234
235 /* $Source: /cvs/libtom/libtomcrypt/src/encauth/ocb/ocb_test.c,v $ */ 235 /* $Source: /cvs/libtom/libtomcrypt/src/encauth/ocb/ocb_test.c,v $ */
236 /* $Revision: 1.3 $ */ 236 /* $Revision: 1.5 $ */
237 /* $Date: 2005/05/05 14:35:58 $ */ 237 /* $Date: 2006/11/01 09:28:17 $ */