Mercurial > dropbear
comparison libtomcrypt/src/modes/lrw/lrw_test.c @ 1511:5916af64acd4 fuzz
merge from main
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 17 Feb 2018 19:29:51 +0800 |
parents | 6dba84798cd5 |
children |
comparison
equal
deleted
inserted
replaced
1457:32f990cc96b1 | 1511:5916af64acd4 |
---|---|
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 lrw_test.c | 12 @file lrw_test.c |
86 if ((err = lrw_start(idx, tests[x].IV, tests[x].key, 16, tests[x].tweak, 0, &lrw)) != CRYPT_OK) { | 84 if ((err = lrw_start(idx, tests[x].IV, tests[x].key, 16, tests[x].tweak, 0, &lrw)) != CRYPT_OK) { |
87 return err; | 85 return err; |
88 } | 86 } |
89 | 87 |
90 /* check pad against expected tweak */ | 88 /* check pad against expected tweak */ |
91 if (XMEMCMP(tests[x].expected_tweak, lrw.pad, 16)) { | 89 if (compare_testvector(tests[x].expected_tweak, 16, lrw.pad, 16, "LRW Tweak", x)) { |
92 lrw_done(&lrw); | 90 lrw_done(&lrw); |
93 return CRYPT_FAIL_TESTVECTOR; | 91 return CRYPT_FAIL_TESTVECTOR; |
94 } | 92 } |
95 | 93 |
96 /* process block */ | 94 /* process block */ |
97 if ((err = lrw_encrypt(tests[x].P, buf[0], 16, &lrw)) != CRYPT_OK) { | 95 if ((err = lrw_encrypt(tests[x].P, buf[0], 16, &lrw)) != CRYPT_OK) { |
98 lrw_done(&lrw); | 96 lrw_done(&lrw); |
99 return err; | 97 return err; |
100 } | 98 } |
101 | 99 |
102 if (XMEMCMP(buf[0], tests[x].C, 16)) { | 100 if (compare_testvector(buf[0], 16, tests[x].C, 16, "LRW Encrypt", x)) { |
103 lrw_done(&lrw); | 101 lrw_done(&lrw); |
104 return CRYPT_FAIL_TESTVECTOR; | 102 return CRYPT_FAIL_TESTVECTOR; |
105 } | 103 } |
106 | 104 |
107 /* process block */ | 105 /* process block */ |
108 if ((err = lrw_setiv(tests[x].IV, 16, &lrw)) != CRYPT_OK) { | 106 if ((err = lrw_setiv(tests[x].IV, 16, &lrw)) != CRYPT_OK) { |
109 lrw_done(&lrw); | 107 lrw_done(&lrw); |
110 return err; | 108 return err; |
111 } | 109 } |
112 | 110 |
113 if ((err = lrw_decrypt(buf[0], buf[1], 16, &lrw)) != CRYPT_OK) { | 111 if ((err = lrw_decrypt(buf[0], buf[1], 16, &lrw)) != CRYPT_OK) { |
114 lrw_done(&lrw); | 112 lrw_done(&lrw); |
115 return err; | 113 return err; |
116 } | 114 } |
117 | 115 |
118 if (XMEMCMP(buf[1], tests[x].P, 16)) { | 116 if (compare_testvector(buf[1], 16, tests[x].P, 16, "LRW Decrypt", x)) { |
119 lrw_done(&lrw); | 117 lrw_done(&lrw); |
120 return CRYPT_FAIL_TESTVECTOR; | 118 return CRYPT_FAIL_TESTVECTOR; |
121 } | 119 } |
122 if ((err = lrw_done(&lrw)) != CRYPT_OK) { | 120 if ((err = lrw_done(&lrw)) != CRYPT_OK) { |
123 return err; | 121 return err; |
124 } | 122 } |
125 } | 123 } |
126 return CRYPT_OK; | 124 return CRYPT_OK; |
127 #endif | 125 #endif |
128 } | 126 } |
129 | 127 |
130 #endif | 128 #endif |
131 | 129 |
132 | 130 |
133 | 131 |
134 /* $Source$ */ | 132 /* ref: $Format:%D$ */ |
135 /* $Revision$ */ | 133 /* git commit: $Format:%H$ */ |
136 /* $Date$ */ | 134 /* commit time: $Format:%ai$ */ |