comparison libtomcrypt/src/modes/ctr/ctr_test.c @ 1471:6dba84798cd5

Update to libtomcrypt 1.18.1, merged with Dropbear changes
author Matt Johnston <matt@ucc.asn.au>
date Fri, 09 Feb 2018 21:44:05 +0800
parents f849a5ca2efc
children
comparison
equal deleted inserted replaced
1470:8bba51a55704 1471:6dba84798cd5
3 * LibTomCrypt is a library that provides various cryptographic 3 * LibTomCrypt is a library that provides various cryptographic
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 *
9 * Tom St Denis, [email protected], http://libtom.org
10 */ 8 */
11 #include "tomcrypt.h" 9 #include "tomcrypt.h"
12 10
13 /** 11 /**
14 @file ctr_test.c 12 @file ctr_test.c
50 }; 48 };
51 int idx, err, x; 49 int idx, err, x;
52 unsigned char buf[64]; 50 unsigned char buf[64];
53 symmetric_CTR ctr; 51 symmetric_CTR ctr;
54 52
55 /* AES can be under rijndael or aes... try to find it */ 53 /* AES can be under rijndael or aes... try to find it */
56 if ((idx = find_cipher("aes")) == -1) { 54 if ((idx = find_cipher("aes")) == -1) {
57 if ((idx = find_cipher("rijndael")) == -1) { 55 if ((idx = find_cipher("rijndael")) == -1) {
58 return CRYPT_NOP; 56 return CRYPT_NOP;
59 } 57 }
60 } 58 }
65 } 63 }
66 if ((err = ctr_encrypt(tests[x].pt, buf, tests[x].msglen, &ctr)) != CRYPT_OK) { 64 if ((err = ctr_encrypt(tests[x].pt, buf, tests[x].msglen, &ctr)) != CRYPT_OK) {
67 return err; 65 return err;
68 } 66 }
69 ctr_done(&ctr); 67 ctr_done(&ctr);
70 if (XMEMCMP(buf, tests[x].ct, tests[x].msglen)) { 68 if (compare_testvector(buf, tests[x].msglen, tests[x].ct, tests[x].msglen, "CTR", x)) {
71 return CRYPT_FAIL_TESTVECTOR; 69 return CRYPT_FAIL_TESTVECTOR;
72 } 70 }
73 } 71 }
74 return CRYPT_OK; 72 return CRYPT_OK;
75 #endif 73 #endif
76 } 74 }
77 75
78 #endif 76 #endif
79 77
80 /* $Source$ */ 78 /* ref: $Format:%D$ */
81 /* $Revision$ */ 79 /* git commit: $Format:%H$ */
82 /* $Date$ */ 80 /* commit time: $Format:%ai$ */
83 81
84 82
85 83