comparison src/encauth/ocb/ocb_test.c @ 380:d5faf4814ddb libtomcrypt-orig libtomcrypt-1.16

Update to LibTomCrypt 1.16
author Matt Johnston <matt@ucc.asn.au>
date Thu, 11 Jan 2007 02:22:00 +0000
parents 59400faa4b44
children
comparison
equal deleted inserted replaced
280:59400faa4b44 380:d5faf4814ddb
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 $ */