aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/tcrypt.h
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/tcrypt.h')
-rw-r--r--crypto/tcrypt.h538
1 files changed, 537 insertions, 1 deletions
diff --git a/crypto/tcrypt.h b/crypto/tcrypt.h
index 48a81362cb85..887527bd5bc6 100644
--- a/crypto/tcrypt.h
+++ b/crypto/tcrypt.h
@@ -12,6 +12,7 @@
12 * Software Foundation; either version 2 of the License, or (at your option) 12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version. 13 * any later version.
14 * 14 *
15 * 2006-12-07 Added SHA384 HMAC and SHA512 HMAC tests
15 * 2004-08-09 Cipher speed tests by Reyk Floeter <reyk@vantronix.net> 16 * 2004-08-09 Cipher speed tests by Reyk Floeter <reyk@vantronix.net>
16 * 2003-09-14 Changes by Kartikey Mahendra Bhatt 17 * 2003-09-14 Changes by Kartikey Mahendra Bhatt
17 * 18 *
@@ -27,7 +28,7 @@
27 28
28struct hash_testvec { 29struct hash_testvec {
29 /* only used with keyed hash algorithms */ 30 /* only used with keyed hash algorithms */
30 char key[128] __attribute__ ((__aligned__(4))); 31 char key[132] __attribute__ ((__aligned__(4)));
31 char plaintext[240]; 32 char plaintext[240];
32 char digest[MAX_DIGEST_SIZE]; 33 char digest[MAX_DIGEST_SIZE];
33 unsigned char tap[MAX_TAP]; 34 unsigned char tap[MAX_TAP];
@@ -1002,6 +1003,248 @@ static struct hash_testvec aes_xcbc128_tv_template[] = {
1002}; 1003};
1003 1004
1004/* 1005/*
1006 * SHA384 HMAC test vectors from RFC4231
1007 */
1008
1009#define HMAC_SHA384_TEST_VECTORS 4
1010
1011static struct hash_testvec hmac_sha384_tv_template[] = {
1012 {
1013 .key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
1014 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
1015 0x0b, 0x0b, 0x0b, 0x0b }, // (20 bytes)
1016 .ksize = 20,
1017 .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65 }, // ("Hi There")
1018 .psize = 8,
1019 .digest = { 0xaf, 0xd0, 0x39, 0x44, 0xd8, 0x48, 0x95, 0x62,
1020 0x6b, 0x08, 0x25, 0xf4, 0xab, 0x46, 0x90, 0x7f,
1021 0x15, 0xf9, 0xda, 0xdb, 0xe4, 0x10, 0x1e, 0xc6,
1022 0x82, 0xaa, 0x03, 0x4c, 0x7c, 0xeb, 0xc5, 0x9c,
1023 0xfa, 0xea, 0x9e, 0xa9, 0x07, 0x6e, 0xde, 0x7f,
1024 0x4a, 0xf1, 0x52, 0xe8, 0xb2, 0xfa, 0x9c, 0xb6 },
1025 }, {
1026 .key = { 0x4a, 0x65, 0x66, 0x65 }, // ("Jefe")
1027 .ksize = 4,
1028 .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
1029 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, // ("what do ya want ")
1030 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
1031 0x69, 0x6e, 0x67, 0x3f }, // ("for nothing?")
1032 .psize = 28,
1033 .digest = { 0xaf, 0x45, 0xd2, 0xe3, 0x76, 0x48, 0x40, 0x31,
1034 0x61, 0x7f, 0x78, 0xd2, 0xb5, 0x8a, 0x6b, 0x1b,
1035 0x9c, 0x7e, 0xf4, 0x64, 0xf5, 0xa0, 0x1b, 0x47,
1036 0xe4, 0x2e, 0xc3, 0x73, 0x63, 0x22, 0x44, 0x5e,
1037 0x8e, 0x22, 0x40, 0xca, 0x5e, 0x69, 0xe2, 0xc7,
1038 0x8b, 0x32, 0x39, 0xec, 0xfa, 0xb2, 0x16, 0x49 },
1039 .np = 4,
1040 .tap = { 7, 7, 7, 7 }
1041 }, {
1042 .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1043 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1044 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1045 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1046 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1047 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1048 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1049 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1050 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1051 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1052 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1053 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1054 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1055 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1056 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1057 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1058 0xaa, 0xaa, 0xaa }, // (131 bytes)
1059 .ksize = 131,
1060 .plaintext = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x69,
1061 0x6e, 0x67, 0x20, 0x4c, 0x61, 0x72, 0x67, 0x65, // ("Test Using Large")
1062 0x72, 0x20, 0x54, 0x68, 0x61, 0x6e, 0x20, 0x42,
1063 0x6c, 0x6f, 0x63, 0x6b, 0x2d, 0x53, 0x69, 0x7a, // ("r Than Block-Siz")
1064 0x65, 0x20, 0x4b, 0x65, 0x79, 0x20, 0x2d, 0x20,
1065 0x48, 0x61, 0x73, 0x68, 0x20, 0x4b, 0x65, 0x79, // ("e Key - Hash Key")
1066 0x20, 0x46, 0x69, 0x72, 0x73, 0x74 }, // (" First")
1067 .psize = 54,
1068 .digest = { 0x4e, 0xce, 0x08, 0x44, 0x85, 0x81, 0x3e, 0x90,
1069 0x88, 0xd2, 0xc6, 0x3a, 0x04, 0x1b, 0xc5, 0xb4,
1070 0x4f, 0x9e, 0xf1, 0x01, 0x2a, 0x2b, 0x58, 0x8f,
1071 0x3c, 0xd1, 0x1f, 0x05, 0x03, 0x3a, 0xc4, 0xc6,
1072 0x0c, 0x2e, 0xf6, 0xab, 0x40, 0x30, 0xfe, 0x82,
1073 0x96, 0x24, 0x8d, 0xf1, 0x63, 0xf4, 0x49, 0x52 },
1074 }, {
1075 .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1076 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1077 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1078 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1079 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1080 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1081 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1082 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1083 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1084 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1085 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1086 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1087 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1088 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1089 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1090 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1091 0xaa, 0xaa, 0xaa }, // (131 bytes)
1092 .ksize = 131,
1093 .plaintext = { 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
1094 0x61, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x75, // ("This is a test u")
1095 0x73, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x6c,
1096 0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74, 0x68, // ("sing a larger th")
1097 0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b,
1098 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x6b, 0x65, // ("an block-size ke")
1099 0x79, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x20,
1100 0x6c, 0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74, // ("y and a larger t")
1101 0x68, 0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63,
1102 0x6b, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x64, // ("han block-size d")
1103 0x61, 0x74, 0x61, 0x2e, 0x20, 0x54, 0x68, 0x65,
1104 0x20, 0x6b, 0x65, 0x79, 0x20, 0x6e, 0x65, 0x65, // ("ata. The key nee")
1105 0x64, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65,
1106 0x20, 0x68, 0x61, 0x73, 0x68, 0x65, 0x64, 0x20, // ("ds to be hashed ")
1107 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x20, 0x62,
1108 0x65, 0x69, 0x6e, 0x67, 0x20, 0x75, 0x73, 0x65, // ("before being use")
1109 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x68, 0x65,
1110 0x20, 0x48, 0x4d, 0x41, 0x43, 0x20, 0x61, 0x6c, // ("d by the HMAC al")
1111 0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x2e }, // ("gorithm.")
1112 .psize = 152,
1113 .digest = { 0x66, 0x17, 0x17, 0x8e, 0x94, 0x1f, 0x02, 0x0d,
1114 0x35, 0x1e, 0x2f, 0x25, 0x4e, 0x8f, 0xd3, 0x2c,
1115 0x60, 0x24, 0x20, 0xfe, 0xb0, 0xb8, 0xfb, 0x9a,
1116 0xdc, 0xce, 0xbb, 0x82, 0x46, 0x1e, 0x99, 0xc5,
1117 0xa6, 0x78, 0xcc, 0x31, 0xe7, 0x99, 0x17, 0x6d,
1118 0x38, 0x60, 0xe6, 0x11, 0x0c, 0x46, 0x52, 0x3e },
1119 },
1120};
1121
1122/*
1123 * SHA512 HMAC test vectors from RFC4231
1124 */
1125
1126#define HMAC_SHA512_TEST_VECTORS 4
1127
1128static struct hash_testvec hmac_sha512_tv_template[] = {
1129 {
1130 .key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
1131 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
1132 0x0b, 0x0b, 0x0b, 0x0b }, // (20 bytes)
1133 .ksize = 20,
1134 .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65 }, // ("Hi There")
1135 .psize = 8,
1136 .digest = { 0x87, 0xaa, 0x7c, 0xde, 0xa5, 0xef, 0x61, 0x9d,
1137 0x4f, 0xf0, 0xb4, 0x24, 0x1a, 0x1d, 0x6c, 0xb0,
1138 0x23, 0x79, 0xf4, 0xe2, 0xce, 0x4e, 0xc2, 0x78,
1139 0x7a, 0xd0, 0xb3, 0x05, 0x45, 0xe1, 0x7c, 0xde,
1140 0xda, 0xa8, 0x33, 0xb7, 0xd6, 0xb8, 0xa7, 0x02,
1141 0x03, 0x8b, 0x27, 0x4e, 0xae, 0xa3, 0xf4, 0xe4,
1142 0xbe, 0x9d, 0x91, 0x4e, 0xeb, 0x61, 0xf1, 0x70,
1143 0x2e, 0x69, 0x6c, 0x20, 0x3a, 0x12, 0x68, 0x54 },
1144 }, {
1145 .key = { 0x4a, 0x65, 0x66, 0x65 }, // ("Jefe")
1146 .ksize = 4,
1147 .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
1148 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, // ("what do ya want ")
1149 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
1150 0x69, 0x6e, 0x67, 0x3f }, // ("for nothing?")
1151 .psize = 28,
1152 .digest = { 0x16, 0x4b, 0x7a, 0x7b, 0xfc, 0xf8, 0x19, 0xe2,
1153 0xe3, 0x95, 0xfb, 0xe7, 0x3b, 0x56, 0xe0, 0xa3,
1154 0x87, 0xbd, 0x64, 0x22, 0x2e, 0x83, 0x1f, 0xd6,
1155 0x10, 0x27, 0x0c, 0xd7, 0xea, 0x25, 0x05, 0x54,
1156 0x97, 0x58, 0xbf, 0x75, 0xc0, 0x5a, 0x99, 0x4a,
1157 0x6d, 0x03, 0x4f, 0x65, 0xf8, 0xf0, 0xe6, 0xfd,
1158 0xca, 0xea, 0xb1, 0xa3, 0x4d, 0x4a, 0x6b, 0x4b,
1159 0x63, 0x6e, 0x07, 0x0a, 0x38, 0xbc, 0xe7, 0x37 },
1160 .np = 4,
1161 .tap = { 7, 7, 7, 7 }
1162 }, {
1163 .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1164 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1165 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1166 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1167 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1168 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1169 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1170 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1171 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1172 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1173 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1174 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1175 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1176 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1177 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1178 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1179 0xaa, 0xaa, 0xaa }, // (131 bytes)
1180 .ksize = 131,
1181 .plaintext = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x69,
1182 0x6e, 0x67, 0x20, 0x4c, 0x61, 0x72, 0x67, 0x65, // ("Test Using Large")
1183 0x72, 0x20, 0x54, 0x68, 0x61, 0x6e, 0x20, 0x42,
1184 0x6c, 0x6f, 0x63, 0x6b, 0x2d, 0x53, 0x69, 0x7a, // ("r Than Block-Siz")
1185 0x65, 0x20, 0x4b, 0x65, 0x79, 0x20, 0x2d, 0x20,
1186 0x48, 0x61, 0x73, 0x68, 0x20, 0x4b, 0x65, 0x79, // ("e Key - Hash Key")
1187 0x20, 0x46, 0x69, 0x72, 0x73, 0x74 }, // (" First")
1188 .psize = 54,
1189 .digest = { 0x80, 0xb2, 0x42, 0x63, 0xc7, 0xc1, 0xa3, 0xeb,
1190 0xb7, 0x14, 0x93, 0xc1, 0xdd, 0x7b, 0xe8, 0xb4,
1191 0x9b, 0x46, 0xd1, 0xf4, 0x1b, 0x4a, 0xee, 0xc1,
1192 0x12, 0x1b, 0x01, 0x37, 0x83, 0xf8, 0xf3, 0x52,
1193 0x6b, 0x56, 0xd0, 0x37, 0xe0, 0x5f, 0x25, 0x98,
1194 0xbd, 0x0f, 0xd2, 0x21, 0x5d, 0x6a, 0x1e, 0x52,
1195 0x95, 0xe6, 0x4f, 0x73, 0xf6, 0x3f, 0x0a, 0xec,
1196 0x8b, 0x91, 0x5a, 0x98, 0x5d, 0x78, 0x65, 0x98 },
1197 }, {
1198 .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1199 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1200 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1201 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1202 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1203 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1204 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1205 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1206 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1207 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1208 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1209 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1210 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1211 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1212 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1213 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1214 0xaa, 0xaa, 0xaa }, // (131 bytes)
1215 .ksize = 131,
1216 .plaintext = { 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
1217 0x61, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x75, // ("This is a test u")
1218 0x73, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x6c,
1219 0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74, 0x68, // ("sing a larger th")
1220 0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b,
1221 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x6b, 0x65, // ("an block-size ke")
1222 0x79, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x20,
1223 0x6c, 0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74, // ("y and a larger t")
1224 0x68, 0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63,
1225 0x6b, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x64, // ("han block-size d")
1226 0x61, 0x74, 0x61, 0x2e, 0x20, 0x54, 0x68, 0x65,
1227 0x20, 0x6b, 0x65, 0x79, 0x20, 0x6e, 0x65, 0x65, // ("ata. The key nee")
1228 0x64, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65,
1229 0x20, 0x68, 0x61, 0x73, 0x68, 0x65, 0x64, 0x20, // ("ds to be hashed ")
1230 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x20, 0x62,
1231 0x65, 0x69, 0x6e, 0x67, 0x20, 0x75, 0x73, 0x65, // ("before being use")
1232 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x68, 0x65,
1233 0x20, 0x48, 0x4d, 0x41, 0x43, 0x20, 0x61, 0x6c, // ("d by the HMAC al")
1234 0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x2e }, // ("gorithm.")
1235 .psize = 152,
1236 .digest = { 0xe3, 0x7b, 0x6a, 0x77, 0x5d, 0xc8, 0x7d, 0xba,
1237 0xa4, 0xdf, 0xa9, 0xf9, 0x6e, 0x5e, 0x3f, 0xfd,
1238 0xde, 0xbd, 0x71, 0xf8, 0x86, 0x72, 0x89, 0x86,
1239 0x5d, 0xf5, 0xa3, 0x2d, 0x20, 0xcd, 0xc9, 0x44,
1240 0xb6, 0x02, 0x2c, 0xac, 0x3c, 0x49, 0x82, 0xb1,
1241 0x0d, 0x5e, 0xeb, 0x55, 0xc3, 0xe4, 0xde, 0x15,
1242 0x13, 0x46, 0x76, 0xfb, 0x6d, 0xe0, 0x44, 0x60,
1243 0x65, 0xc9, 0x74, 0x40, 0xfa, 0x8c, 0x6a, 0x58 },
1244 },
1245};
1246
1247/*
1005 * DES test vectors. 1248 * DES test vectors.
1006 */ 1249 */
1007#define DES_ENC_TEST_VECTORS 10 1250#define DES_ENC_TEST_VECTORS 10
@@ -3316,6 +3559,278 @@ static struct cipher_testvec xeta_dec_tv_template[] = {
3316 } 3559 }
3317}; 3560};
3318 3561
3562/*
3563 * FCrypt test vectors
3564 */
3565#define FCRYPT_ENC_TEST_VECTORS ARRAY_SIZE(fcrypt_pcbc_enc_tv_template)
3566#define FCRYPT_DEC_TEST_VECTORS ARRAY_SIZE(fcrypt_pcbc_dec_tv_template)
3567
3568static struct cipher_testvec fcrypt_pcbc_enc_tv_template[] = {
3569 { /* http://www.openafs.org/pipermail/openafs-devel/2000-December/005320.html */
3570 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3571 .klen = 8,
3572 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3573 .input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3574 .ilen = 8,
3575 .result = { 0x0E, 0x09, 0x00, 0xC7, 0x3E, 0xF7, 0xED, 0x41 },
3576 .rlen = 8,
3577 }, {
3578 .key = { 0x11, 0x44, 0x77, 0xAA, 0xDD, 0x00, 0x33, 0x66 },
3579 .klen = 8,
3580 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3581 .input = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0 },
3582 .ilen = 8,
3583 .result = { 0xD8, 0xED, 0x78, 0x74, 0x77, 0xEC, 0x06, 0x80 },
3584 .rlen = 8,
3585 }, { /* From Arla */
3586 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
3587 .klen = 8,
3588 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3589 .input = "The quick brown fox jumps over the lazy dogs.\0\0",
3590 .ilen = 48,
3591 .result = { 0x00, 0xf0, 0xe, 0x11, 0x75, 0xe6, 0x23, 0x82,
3592 0xee, 0xac, 0x98, 0x62, 0x44, 0x51, 0xe4, 0x84,
3593 0xc3, 0x59, 0xd8, 0xaa, 0x64, 0x60, 0xae, 0xf7,
3594 0xd2, 0xd9, 0x13, 0x79, 0x72, 0xa3, 0x45, 0x03,
3595 0x23, 0xb5, 0x62, 0xd7, 0x0c, 0xf5, 0x27, 0xd1,
3596 0xf8, 0x91, 0x3c, 0xac, 0x44, 0x22, 0x92, 0xef },
3597 .rlen = 48,
3598 }, {
3599 .key = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3600 .klen = 8,
3601 .iv = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
3602 .input = "The quick brown fox jumps over the lazy dogs.\0\0",
3603 .ilen = 48,
3604 .result = { 0xca, 0x90, 0xf5, 0x9d, 0xcb, 0xd4, 0xd2, 0x3c,
3605 0x01, 0x88, 0x7f, 0x3e, 0x31, 0x6e, 0x62, 0x9d,
3606 0xd8, 0xe0, 0x57, 0xa3, 0x06, 0x3a, 0x42, 0x58,
3607 0x2a, 0x28, 0xfe, 0x72, 0x52, 0x2f, 0xdd, 0xe0,
3608 0x19, 0x89, 0x09, 0x1c, 0x2a, 0x8e, 0x8c, 0x94,
3609 0xfc, 0xc7, 0x68, 0xe4, 0x88, 0xaa, 0xde, 0x0f },
3610 .rlen = 48,
3611 }, { /* split-page version */
3612 .key = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3613 .klen = 8,
3614 .iv = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
3615 .input = "The quick brown fox jumps over the lazy dogs.\0\0",
3616 .ilen = 48,
3617 .result = { 0xca, 0x90, 0xf5, 0x9d, 0xcb, 0xd4, 0xd2, 0x3c,
3618 0x01, 0x88, 0x7f, 0x3e, 0x31, 0x6e, 0x62, 0x9d,
3619 0xd8, 0xe0, 0x57, 0xa3, 0x06, 0x3a, 0x42, 0x58,
3620 0x2a, 0x28, 0xfe, 0x72, 0x52, 0x2f, 0xdd, 0xe0,
3621 0x19, 0x89, 0x09, 0x1c, 0x2a, 0x8e, 0x8c, 0x94,
3622 0xfc, 0xc7, 0x68, 0xe4, 0x88, 0xaa, 0xde, 0x0f },
3623 .rlen = 48,
3624 .np = 2,
3625 .tap = { 20, 28 },
3626 }
3627};
3628
3629static struct cipher_testvec fcrypt_pcbc_dec_tv_template[] = {
3630 { /* http://www.openafs.org/pipermail/openafs-devel/2000-December/005320.html */
3631 .key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3632 .klen = 8,
3633 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3634 .input = { 0x0E, 0x09, 0x00, 0xC7, 0x3E, 0xF7, 0xED, 0x41 },
3635 .ilen = 8,
3636 .result = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3637 .rlen = 8,
3638 }, {
3639 .key = { 0x11, 0x44, 0x77, 0xAA, 0xDD, 0x00, 0x33, 0x66 },
3640 .klen = 8,
3641 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
3642 .input = { 0xD8, 0xED, 0x78, 0x74, 0x77, 0xEC, 0x06, 0x80 },
3643 .ilen = 8,
3644 .result = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0 },
3645 .rlen = 8,
3646 }, { /* From Arla */
3647 .key = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
3648 .klen = 8,
3649 .iv = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3650 .input = { 0x00, 0xf0, 0xe, 0x11, 0x75, 0xe6, 0x23, 0x82,
3651 0xee, 0xac, 0x98, 0x62, 0x44, 0x51, 0xe4, 0x84,
3652 0xc3, 0x59, 0xd8, 0xaa, 0x64, 0x60, 0xae, 0xf7,
3653 0xd2, 0xd9, 0x13, 0x79, 0x72, 0xa3, 0x45, 0x03,
3654 0x23, 0xb5, 0x62, 0xd7, 0x0c, 0xf5, 0x27, 0xd1,
3655 0xf8, 0x91, 0x3c, 0xac, 0x44, 0x22, 0x92, 0xef },
3656 .ilen = 48,
3657 .result = "The quick brown fox jumps over the lazy dogs.\0\0",
3658 .rlen = 48,
3659 }, {
3660 .key = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3661 .klen = 8,
3662 .iv = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
3663 .input = { 0xca, 0x90, 0xf5, 0x9d, 0xcb, 0xd4, 0xd2, 0x3c,
3664 0x01, 0x88, 0x7f, 0x3e, 0x31, 0x6e, 0x62, 0x9d,
3665 0xd8, 0xe0, 0x57, 0xa3, 0x06, 0x3a, 0x42, 0x58,
3666 0x2a, 0x28, 0xfe, 0x72, 0x52, 0x2f, 0xdd, 0xe0,
3667 0x19, 0x89, 0x09, 0x1c, 0x2a, 0x8e, 0x8c, 0x94,
3668 0xfc, 0xc7, 0x68, 0xe4, 0x88, 0xaa, 0xde, 0x0f },
3669 .ilen = 48,
3670 .result = "The quick brown fox jumps over the lazy dogs.\0\0",
3671 .rlen = 48,
3672 }, { /* split-page version */
3673 .key = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3674 .klen = 8,
3675 .iv = { 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 },
3676 .input = { 0xca, 0x90, 0xf5, 0x9d, 0xcb, 0xd4, 0xd2, 0x3c,
3677 0x01, 0x88, 0x7f, 0x3e, 0x31, 0x6e, 0x62, 0x9d,
3678 0xd8, 0xe0, 0x57, 0xa3, 0x06, 0x3a, 0x42, 0x58,
3679 0x2a, 0x28, 0xfe, 0x72, 0x52, 0x2f, 0xdd, 0xe0,
3680 0x19, 0x89, 0x09, 0x1c, 0x2a, 0x8e, 0x8c, 0x94,
3681 0xfc, 0xc7, 0x68, 0xe4, 0x88, 0xaa, 0xde, 0x0f },
3682 .ilen = 48,
3683 .result = "The quick brown fox jumps over the lazy dogs.\0\0",
3684 .rlen = 48,
3685 .np = 2,
3686 .tap = { 20, 28 },
3687 }
3688};
3689
3690/*
3691 * CAMELLIA test vectors.
3692 */
3693#define CAMELLIA_ENC_TEST_VECTORS 3
3694#define CAMELLIA_DEC_TEST_VECTORS 3
3695#define CAMELLIA_CBC_ENC_TEST_VECTORS 2
3696#define CAMELLIA_CBC_DEC_TEST_VECTORS 2
3697
3698static struct cipher_testvec camellia_enc_tv_template[] = {
3699 {
3700 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3701 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3702 .klen = 16,
3703 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3704 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3705 .ilen = 16,
3706 .result = { 0x67, 0x67, 0x31, 0x38, 0x54, 0x96, 0x69, 0x73,
3707 0x08, 0x57, 0x06, 0x56, 0x48, 0xea, 0xbe, 0x43 },
3708 .rlen = 16,
3709 }, {
3710 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3711 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
3712 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
3713 .klen = 24,
3714 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3715 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3716 .ilen = 16,
3717 .result = { 0xb4, 0x99, 0x34, 0x01, 0xb3, 0xe9, 0x96, 0xf8,
3718 0x4e, 0xe5, 0xce, 0xe7, 0xd7, 0x9b, 0x09, 0xb9 },
3719 .rlen = 16,
3720 }, {
3721 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3722 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
3723 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
3724 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
3725 .klen = 32,
3726 .input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3727 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3728 .ilen = 16,
3729 .result = { 0x9a, 0xcc, 0x23, 0x7d, 0xff, 0x16, 0xd7, 0x6c,
3730 0x20, 0xef, 0x7c, 0x91, 0x9e, 0x3a, 0x75, 0x09 },
3731 .rlen = 16,
3732 },
3733};
3734
3735static struct cipher_testvec camellia_dec_tv_template[] = {
3736 {
3737 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3738 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3739 .klen = 16,
3740 .input = { 0x67, 0x67, 0x31, 0x38, 0x54, 0x96, 0x69, 0x73,
3741 0x08, 0x57, 0x06, 0x56, 0x48, 0xea, 0xbe, 0x43 },
3742 .ilen = 16,
3743 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3744 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3745 .rlen = 16,
3746 }, {
3747 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3748 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
3749 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 },
3750 .klen = 24,
3751 .input = { 0xb4, 0x99, 0x34, 0x01, 0xb3, 0xe9, 0x96, 0xf8,
3752 0x4e, 0xe5, 0xce, 0xe7, 0xd7, 0x9b, 0x09, 0xb9 },
3753 .ilen = 16,
3754 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3755 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3756 .rlen = 16,
3757 }, {
3758 .key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3759 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
3760 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
3761 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff },
3762 .klen = 32,
3763 .input = { 0x9a, 0xcc, 0x23, 0x7d, 0xff, 0x16, 0xd7, 0x6c,
3764 0x20, 0xef, 0x7c, 0x91, 0x9e, 0x3a, 0x75, 0x09 },
3765 .ilen = 16,
3766 .result = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
3767 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 },
3768 .rlen = 16,
3769 },
3770};
3771
3772static struct cipher_testvec camellia_cbc_enc_tv_template[] = {
3773 {
3774 .key = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b,
3775 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 },
3776 .klen = 16,
3777 .iv = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30,
3778 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 },
3779 .input = { "Single block msg" },
3780 .ilen = 16,
3781 .result = { 0xea, 0x32, 0x12, 0x76, 0x3b, 0x50, 0x10, 0xe7,
3782 0x18, 0xf6, 0xfd, 0x5d, 0xf6, 0x8f, 0x13, 0x51 },
3783 .rlen = 16,
3784 }, {
3785 .key = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0,
3786 0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a },
3787 .klen = 16,
3788 .iv = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28,
3789 0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 },
3790 .input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
3791 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
3792 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
3793 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
3794 .ilen = 32,
3795 .result = { 0xa5, 0xdf, 0x6e, 0x50, 0xda, 0x70, 0x6c, 0x01,
3796 0x4a, 0xab, 0xf3, 0xf2, 0xd6, 0xfc, 0x6c, 0xfd,
3797 0x19, 0xb4, 0x3e, 0x57, 0x1c, 0x02, 0x5e, 0xa0,
3798 0x15, 0x78, 0xe0, 0x5e, 0xf2, 0xcb, 0x87, 0x16 },
3799 .rlen = 32,
3800 },
3801};
3802
3803static struct cipher_testvec camellia_cbc_dec_tv_template[] = {
3804 {
3805 .key = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b,
3806 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 },
3807 .klen = 16,
3808 .iv = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30,
3809 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 },
3810 .input = { 0xea, 0x32, 0x12, 0x76, 0x3b, 0x50, 0x10, 0xe7,
3811 0x18, 0xf6, 0xfd, 0x5d, 0xf6, 0x8f, 0x13, 0x51 },
3812 .ilen = 16,
3813 .result = { "Single block msg" },
3814 .rlen = 16,
3815 }, {
3816 .key = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0,
3817 0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a },
3818 .klen = 16,
3819 .iv = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28,
3820 0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 },
3821 .input = { 0xa5, 0xdf, 0x6e, 0x50, 0xda, 0x70, 0x6c, 0x01,
3822 0x4a, 0xab, 0xf3, 0xf2, 0xd6, 0xfc, 0x6c, 0xfd,
3823 0x19, 0xb4, 0x3e, 0x57, 0x1c, 0x02, 0x5e, 0xa0,
3824 0x15, 0x78, 0xe0, 0x5e, 0xf2, 0xcb, 0x87, 0x16 },
3825 .ilen = 32,
3826 .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
3827 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
3828 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
3829 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
3830 .rlen = 32,
3831 },
3832};
3833
3319/* 3834/*
3320 * Compression stuff. 3835 * Compression stuff.
3321 */ 3836 */
@@ -3769,4 +4284,25 @@ static struct hash_speed generic_hash_speed_template[] = {
3769 { .blen = 0, .plen = 0, } 4284 { .blen = 0, .plen = 0, }
3770}; 4285};
3771 4286
4287static struct cipher_speed camellia_speed_template[] = {
4288 { .klen = 16, .blen = 16, },
4289 { .klen = 16, .blen = 64, },
4290 { .klen = 16, .blen = 256, },
4291 { .klen = 16, .blen = 1024, },
4292 { .klen = 16, .blen = 8192, },
4293 { .klen = 24, .blen = 16, },
4294 { .klen = 24, .blen = 64, },
4295 { .klen = 24, .blen = 256, },
4296 { .klen = 24, .blen = 1024, },
4297 { .klen = 24, .blen = 8192, },
4298 { .klen = 32, .blen = 16, },
4299 { .klen = 32, .blen = 64, },
4300 { .klen = 32, .blen = 256, },
4301 { .klen = 32, .blen = 1024, },
4302 { .klen = 32, .blen = 8192, },
4303
4304 /* End marker */
4305 { .klen = 0, .blen = 0, }
4306};
4307
3772#endif /* _CRYPTO_TCRYPT_H */ 4308#endif /* _CRYPTO_TCRYPT_H */