aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/tcrypt.h
diff options
context:
space:
mode:
authorAdrian-Ken Rueegsegger <rueegsegger@swiss-it.ch>2008-05-07 10:16:36 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2008-07-10 08:35:10 -0400
commitfd4adf1a0b1923f6126835e1097b2997eb0d27e2 (patch)
treef670130dc1fbd42d197c4d49061a4bcb993fe68e /crypto/tcrypt.h
parentc6580eb8b17d64f0d6ad25c86a034adbda5ab4e1 (diff)
[CRYPTO] tcrypt: Add test vectors for RIPEMD-128 and RIPEMD-160
This patch adds test vectors for RIPEMD-128 and RIPEMD-160 hash algorithms and digests (HMAC). The test vectors are taken from ISO:IEC 10118-3 (2004) and RFC2286. Signed-off-by: Adrian-Ken Rueegsegger <rueegsegger@swiss-it.ch> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/tcrypt.h')
-rw-r--r--crypto/tcrypt.h292
1 files changed, 292 insertions, 0 deletions
diff --git a/crypto/tcrypt.h b/crypto/tcrypt.h
index 47bc0ecb8978..89068233acfd 100644
--- a/crypto/tcrypt.h
+++ b/crypto/tcrypt.h
@@ -13,6 +13,7 @@
13 * Software Foundation; either version 2 of the License, or (at your option) 13 * Software Foundation; either version 2 of the License, or (at your option)
14 * any later version. 14 * any later version.
15 * 15 *
16 * 2008-04-27 Added RIPEMD tests
16 * 2007-11-13 Added GCM tests 17 * 2007-11-13 Added GCM tests
17 * 2007-11-13 Added AEAD support 18 * 2007-11-13 Added AEAD support
18 * 2006-12-07 Added SHA384 HMAC and SHA512 HMAC tests 19 * 2006-12-07 Added SHA384 HMAC and SHA512 HMAC tests
@@ -168,6 +169,135 @@ static struct hash_testvec md5_tv_template[] = {
168 .digest = "\x57\xed\xf4\xa2\x2b\xe3\xc9\x55" 169 .digest = "\x57\xed\xf4\xa2\x2b\xe3\xc9\x55"
169 "\xac\x49\xda\x2e\x21\x07\xb6\x7a", 170 "\xac\x49\xda\x2e\x21\x07\xb6\x7a",
170 } 171 }
172
173};
174
175/*
176 * RIPEMD-128 test vectors from ISO/IEC 10118-3:2004(E)
177 */
178#define RMD128_TEST_VECTORS 10
179
180static struct hash_testvec rmd128_tv_template[] = {
181 {
182 .digest = "\xcd\xf2\x62\x13\xa1\x50\xdc\x3e"
183 "\xcb\x61\x0f\x18\xf6\xb3\x8b\x46",
184 }, {
185 .plaintext = "a",
186 .psize = 1,
187 .digest = "\x86\xbe\x7a\xfa\x33\x9d\x0f\xc7"
188 "\xcf\xc7\x85\xe7\x2f\x57\x8d\x33",
189 }, {
190 .plaintext = "abc",
191 .psize = 3,
192 .digest = "\xc1\x4a\x12\x19\x9c\x66\xe4\xba"
193 "\x84\x63\x6b\x0f\x69\x14\x4c\x77",
194 }, {
195 .plaintext = "message digest",
196 .psize = 14,
197 .digest = "\x9e\x32\x7b\x3d\x6e\x52\x30\x62"
198 "\xaf\xc1\x13\x2d\x7d\xf9\xd1\xb8",
199 }, {
200 .plaintext = "abcdefghijklmnopqrstuvwxyz",
201 .psize = 26,
202 .digest = "\xfd\x2a\xa6\x07\xf7\x1d\xc8\xf5"
203 "\x10\x71\x49\x22\xb3\x71\x83\x4e",
204 }, {
205 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"
206 "fghijklmnopqrstuvwxyz0123456789",
207 .psize = 62,
208 .digest = "\xd1\xe9\x59\xeb\x17\x9c\x91\x1f"
209 "\xae\xa4\x62\x4c\x60\xc5\xc7\x02",
210 }, {
211 .plaintext = "1234567890123456789012345678901234567890"
212 "1234567890123456789012345678901234567890",
213 .psize = 80,
214 .digest = "\x3f\x45\xef\x19\x47\x32\xc2\xdb"
215 "\xb2\xc4\xa2\xc7\x69\x79\x5f\xa3",
216 }, {
217 .plaintext = "abcdbcdecdefdefgefghfghighij"
218 "hijkijkljklmklmnlmnomnopnopq",
219 .psize = 56,
220 .digest = "\xa1\xaa\x06\x89\xd0\xfa\xfa\x2d"
221 "\xdc\x22\xe8\x8b\x49\x13\x3a\x06",
222 .np = 2,
223 .tap = { 28, 28 },
224 }, {
225 .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghi"
226 "jklmghijklmnhijklmnoijklmnopjklmnopqklmnopqr"
227 "lmnopqrsmnopqrstnopqrstu",
228 .psize = 112,
229 .digest = "\xd4\xec\xc9\x13\xe1\xdf\x77\x6b"
230 "\xf4\x8d\xe9\xd5\x5b\x1f\x25\x46",
231 }, {
232 .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
233 .psize = 32,
234 .digest = "\x13\xfc\x13\xe8\xef\xff\x34\x7d"
235 "\xe1\x93\xff\x46\xdb\xac\xcf\xd4",
236 }
237};
238
239/*
240 * RIPEMD-160 test vectors from ISO/IEC 10118-3:2004(E)
241 */
242#define RMD160_TEST_VECTORS 10
243
244static struct hash_testvec rmd160_tv_template[] = {
245 {
246 .digest = "\x9c\x11\x85\xa5\xc5\xe9\xfc\x54\x61\x28"
247 "\x08\x97\x7e\xe8\xf5\x48\xb2\x25\x8d\x31",
248 }, {
249 .plaintext = "a",
250 .psize = 1,
251 .digest = "\x0b\xdc\x9d\x2d\x25\x6b\x3e\xe9\xda\xae"
252 "\x34\x7b\xe6\xf4\xdc\x83\x5a\x46\x7f\xfe",
253 }, {
254 .plaintext = "abc",
255 .psize = 3,
256 .digest = "\x8e\xb2\x08\xf7\xe0\x5d\x98\x7a\x9b\x04"
257 "\x4a\x8e\x98\xc6\xb0\x87\xf1\x5a\x0b\xfc",
258 }, {
259 .plaintext = "message digest",
260 .psize = 14,
261 .digest = "\x5d\x06\x89\xef\x49\xd2\xfa\xe5\x72\xb8"
262 "\x81\xb1\x23\xa8\x5f\xfa\x21\x59\x5f\x36",
263 }, {
264 .plaintext = "abcdefghijklmnopqrstuvwxyz",
265 .psize = 26,
266 .digest = "\xf7\x1c\x27\x10\x9c\x69\x2c\x1b\x56\xbb"
267 "\xdc\xeb\x5b\x9d\x28\x65\xb3\x70\x8d\xbc",
268 }, {
269 .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"
270 "fghijklmnopqrstuvwxyz0123456789",
271 .psize = 62,
272 .digest = "\xb0\xe2\x0b\x6e\x31\x16\x64\x02\x86\xed"
273 "\x3a\x87\xa5\x71\x30\x79\xb2\x1f\x51\x89",
274 }, {
275 .plaintext = "1234567890123456789012345678901234567890"
276 "1234567890123456789012345678901234567890",
277 .psize = 80,
278 .digest = "\x9b\x75\x2e\x45\x57\x3d\x4b\x39\xf4\xdb"
279 "\xd3\x32\x3c\xab\x82\xbf\x63\x32\x6b\xfb",
280 }, {
281 .plaintext = "abcdbcdecdefdefgefghfghighij"
282 "hijkijkljklmklmnlmnomnopnopq",
283 .psize = 56,
284 .digest = "\x12\xa0\x53\x38\x4a\x9c\x0c\x88\xe4\x05"
285 "\xa0\x6c\x27\xdc\xf4\x9a\xda\x62\xeb\x2b",
286 .np = 2,
287 .tap = { 28, 28 },
288 }, {
289 .plaintext = "abcdefghbcdefghicdefghijdefghijkefghijklfghi"
290 "jklmghijklmnhijklmnoijklmnopjklmnopqklmnopqr"
291 "lmnopqrsmnopqrstnopqrstu",
292 .psize = 112,
293 .digest = "\x6f\x3f\xa3\x9b\x6b\x50\x3c\x38\x4f\x91"
294 "\x9a\x49\xa7\xaa\x5c\x2c\x08\xbd\xfb\x45",
295 }, {
296 .plaintext = "abcdbcdecdefdefgefghfghighijhijk",
297 .psize = 32,
298 .digest = "\x94\xc2\x64\x11\x54\x04\xe6\x33\x79\x0d"
299 "\xfc\xc8\x7b\x58\x7d\x36\x77\x06\x7d\x9f",
300 }
171}; 301};
172 302
173/* 303/*
@@ -817,6 +947,168 @@ static struct hash_testvec hmac_md5_tv_template[] =
817}; 947};
818 948
819/* 949/*
950 * HMAC-RIPEMD128 test vectors from RFC2286
951 */
952#define HMAC_RMD128_TEST_VECTORS 7
953
954static struct hash_testvec hmac_rmd128_tv_template[] = {
955 {
956 .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
957 .ksize = 16,
958 .plaintext = "Hi There",
959 .psize = 8,
960 .digest = "\xfb\xf6\x1f\x94\x92\xaa\x4b\xbf"
961 "\x81\xc1\x72\xe8\x4e\x07\x34\xdb",
962 }, {
963 .key = "Jefe",
964 .ksize = 4,
965 .plaintext = "what do ya want for nothing?",
966 .psize = 28,
967 .digest = "\x87\x5f\x82\x88\x62\xb6\xb3\x34"
968 "\xb4\x27\xc5\x5f\x9f\x7f\xf0\x9b",
969 .np = 2,
970 .tap = { 14, 14 },
971 }, {
972 .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
973 .ksize = 16,
974 .plaintext = "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
975 "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
976 "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
977 "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
978 .psize = 50,
979 .digest = "\x09\xf0\xb2\x84\x6d\x2f\x54\x3d"
980 "\xa3\x63\xcb\xec\x8d\x62\xa3\x8d",
981 }, {
982 .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
983 "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
984 "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
985 .ksize = 25,
986 .plaintext = "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
987 "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
988 "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
989 "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
990 .psize = 50,
991 .digest = "\xbd\xbb\xd7\xcf\x03\xe4\x4b\x5a"
992 "\xa6\x0a\xf8\x15\xbe\x4d\x22\x94",
993 }, {
994 .key = "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
995 .ksize = 16,
996 .plaintext = "Test With Truncation",
997 .psize = 20,
998 .digest = "\xe7\x98\x08\xf2\x4b\x25\xfd\x03"
999 "\x1c\x15\x5f\x0d\x55\x1d\x9a\x3a",
1000 }, {
1001 .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1002 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1003 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1004 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1005 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1006 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1007 "\xaa\xaa",
1008 .ksize = 80,
1009 .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
1010 .psize = 54,
1011 .digest = "\xdc\x73\x29\x28\xde\x98\x10\x4a"
1012 "\x1f\x59\xd3\x73\xc1\x50\xac\xbb",
1013 }, {
1014 .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1015 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1016 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1017 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1018 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1019 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1020 "\xaa\xaa",
1021 .ksize = 80,
1022 .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
1023 "Block-Size Data",
1024 .psize = 73,
1025 .digest = "\x5c\x6b\xec\x96\x79\x3e\x16\xd4"
1026 "\x06\x90\xc2\x37\x63\x5f\x30\xc5",
1027 },
1028};
1029
1030/*
1031 * HMAC-RIPEMD160 test vectors from RFC2286
1032 */
1033#define HMAC_RMD160_TEST_VECTORS 7
1034
1035static struct hash_testvec hmac_rmd160_tv_template[] = {
1036 {
1037 .key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
1038 .ksize = 20,
1039 .plaintext = "Hi There",
1040 .psize = 8,
1041 .digest = "\x24\xcb\x4b\xd6\x7d\x20\xfc\x1a\x5d\x2e"
1042 "\xd7\x73\x2d\xcc\x39\x37\x7f\x0a\x56\x68",
1043 }, {
1044 .key = "Jefe",
1045 .ksize = 4,
1046 .plaintext = "what do ya want for nothing?",
1047 .psize = 28,
1048 .digest = "\xdd\xa6\xc0\x21\x3a\x48\x5a\x9e\x24\xf4"
1049 "\x74\x20\x64\xa7\xf0\x33\xb4\x3c\x40\x69",
1050 .np = 2,
1051 .tap = { 14, 14 },
1052 }, {
1053 .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
1054 .ksize = 20,
1055 .plaintext = "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
1056 "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
1057 "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd"
1058 "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
1059 .psize = 50,
1060 .digest = "\xb0\xb1\x05\x36\x0d\xe7\x59\x96\x0a\xb4"
1061 "\xf3\x52\x98\xe1\x16\xe2\x95\xd8\xe7\xc1",
1062 }, {
1063 .key = "\x01\x02\x03\x04\x05\x06\x07\x08"
1064 "\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"
1065 "\x11\x12\x13\x14\x15\x16\x17\x18\x19",
1066 .ksize = 25,
1067 .plaintext = "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
1068 "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
1069 "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd"
1070 "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
1071 .psize = 50,
1072 .digest = "\xd5\xca\x86\x2f\x4d\x21\xd5\xe6\x10\xe1"
1073 "\x8b\x4c\xf1\xbe\xb9\x7a\x43\x65\xec\xf4",
1074 }, {
1075 .key = "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c",
1076 .ksize = 20,
1077 .plaintext = "Test With Truncation",
1078 .psize = 20,
1079 .digest = "\x76\x19\x69\x39\x78\xf9\x1d\x90\x53\x9a"
1080 "\xe7\x86\x50\x0f\xf3\xd8\xe0\x51\x8e\x39",
1081 }, {
1082 .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1083 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1084 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1085 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1086 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1087 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1088 "\xaa\xaa",
1089 .ksize = 80,
1090 .plaintext = "Test Using Larger Than Block-Size Key - Hash Key First",
1091 .psize = 54,
1092 .digest = "\x64\x66\xca\x07\xac\x5e\xac\x29\xe1\xbd"
1093 "\x52\x3e\x5a\xda\x76\x05\xb7\x91\xfd\x8b",
1094 }, {
1095 .key = "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1096 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1097 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1098 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1099 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1100 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
1101 "\xaa\xaa",
1102 .ksize = 80,
1103 .plaintext = "Test Using Larger Than Block-Size Key and Larger Than One "
1104 "Block-Size Data",
1105 .psize = 73,
1106 .digest = "\x69\xea\x60\x79\x8d\x71\x61\x6c\xce\x5f"
1107 "\xd0\x87\x1e\x23\x75\x4c\xd7\x5d\x5a\x0a",
1108 },
1109};
1110
1111/*
820 * HMAC-SHA1 test vectors from RFC2202 1112 * HMAC-SHA1 test vectors from RFC2202
821 */ 1113 */
822#define HMAC_SHA1_TEST_VECTORS 7 1114#define HMAC_SHA1_TEST_VECTORS 7