1 /* ==================================================================== 2 * Copyright (c) 2010 The OpenSSL Project. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in 13 * the documentation and/or other materials provided with the 14 * distribution. 15 * 16 * 3. All advertising materials mentioning features or use of this 17 * software must display the following acknowledgment: 18 * "This product includes software developed by the OpenSSL Project 19 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 20 * 21 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 22 * endorse or promote products derived from this software without 23 * prior written permission. For written permission, please contact 24 * openssl-core@openssl.org. 25 * 26 * 5. Products derived from this software may not be called "OpenSSL" 27 * nor may "OpenSSL" appear in their names without prior written 28 * permission of the OpenSSL Project. 29 * 30 * 6. Redistributions of any form whatsoever must retain the following 31 * acknowledgment: 32 * "This product includes software developed by the OpenSSL Project 33 * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 34 * 35 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 46 * OF THE POSSIBILITY OF SUCH DAMAGE. 47 * ==================================================================== 48 */ 49 50 #include <err.h> 51 #include <stdio.h> 52 #include <stdint.h> 53 #include <stdlib.h> 54 #include <string.h> 55 56 #include <openssl/aes.h> 57 #include <openssl/modes.h> 58 59 /* XXX - something like this should be in the public headers. */ 60 struct gcm128_context { 61 uint64_t opaque[64]; 62 }; 63 64 struct gcm128_test { 65 const uint8_t K[128]; 66 size_t K_len; 67 const uint8_t IV[128]; 68 size_t IV_len; 69 const uint8_t P[512]; 70 size_t P_len; 71 const uint8_t A[128]; 72 size_t A_len; 73 const uint8_t C[512]; 74 size_t C_len; 75 const uint8_t T[16]; 76 }; 77 78 struct gcm128_test gcm128_tests[] = { 79 { 80 /* Test Case 1. */ 81 .K = {0}, 82 .K_len = 16, 83 .IV = {0}, 84 .IV_len = 12, 85 .P = {0}, 86 .P_len = 0, 87 .A = {0}, 88 .A_len = 0, 89 .C = {0}, 90 .C_len = 0, 91 .T = { 92 0x58, 0xe2, 0xfc, 0xce, 0xfa, 0x7e, 0x30, 0x61, 93 0x36, 0x7f, 0x1d, 0x57, 0xa4, 0xe7, 0x45, 0x5a, 94 }, 95 }, 96 { 97 /* Test Case 2. */ 98 .K = {0}, 99 .K_len = 16, 100 .IV = {0}, 101 .IV_len = 12, 102 .P = {0}, 103 .P_len = 16, 104 .A = {0}, 105 .A_len = 0, 106 .C = { 107 0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92, 108 0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78, 109 }, 110 .C_len = 16, 111 .T = { 112 0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec, 0x13, 0xbd, 113 0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf, 114 }, 115 }, 116 { 117 /* Test Case 3. */ 118 .K = { 119 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 120 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 121 }, 122 .K_len = 16, 123 .IV = { 124 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 125 0xde, 0xca, 0xf8, 0x88, 126 }, 127 .IV_len = 12, 128 .P = { 129 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 130 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 131 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 132 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 133 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 134 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 135 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 136 0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55, 137 }, 138 .P_len = 64, 139 .A = {0}, 140 .A_len = 0, 141 .C = { 142 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24, 143 0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c, 144 0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0, 145 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e, 146 0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c, 147 0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05, 148 0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97, 149 0x3d, 0x58, 0xe0, 0x91, 0x47, 0x3f, 0x59, 0x85, 150 }, 151 .C_len = 64, 152 .T = { 153 0x4d, 0x5c, 0x2a, 0xf3, 0x27, 0xcd, 0x64, 0xa6, 154 0x2c, 0xf3, 0x5a, 0xbd, 0x2b, 0xa6, 0xfa, 0xb4, 155 } 156 }, 157 { 158 /* Test Case 4. */ 159 .K = { 160 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 161 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 162 }, 163 .K_len = 16, 164 .IV = { 165 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 166 0xde, 0xca, 0xf8, 0x88, 167 }, 168 .IV_len = 12, 169 .P = { 170 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 171 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 172 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 173 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 174 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 175 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 176 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 177 0xba, 0x63, 0x7b, 0x39, 178 }, 179 .P_len = 60, 180 .A = { 181 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 182 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 183 0xab, 0xad, 0xda, 0xd2, 184 }, 185 .A_len = 20, 186 .C = { 187 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24, 188 0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c, 189 0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0, 190 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e, 191 0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c, 192 0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05, 193 0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97, 194 0x3d, 0x58, 0xe0, 0x91, 195 }, 196 .C_len = 60, 197 .T = { 198 0x5b, 0xc9, 0x4f, 0xbc, 0x32, 0x21, 0xa5, 0xdb, 199 0x94, 0xfa, 0xe9, 0x5a, 0xe7, 0x12, 0x1a, 0x47, 200 }, 201 }, 202 { 203 /* Test Case 5. */ 204 /* K, P, A are the same as TC4. */ 205 .K = { 206 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 207 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 208 }, 209 .K_len = 16, 210 .IV = { 211 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 212 }, 213 .IV_len = 8, 214 .P = { 215 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 216 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 217 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 218 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 219 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 220 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 221 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 222 0xba, 0x63, 0x7b, 0x39, 223 }, 224 .P_len = 60, 225 .A = { 226 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 227 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 228 0xab, 0xad, 0xda, 0xd2, 229 }, 230 .A_len = 20, 231 .C = { 232 0x61, 0x35, 0x3b, 0x4c, 0x28, 0x06, 0x93, 0x4a, 233 0x77, 0x7f, 0xf5, 0x1f, 0xa2, 0x2a, 0x47, 0x55, 234 0x69, 0x9b, 0x2a, 0x71, 0x4f, 0xcd, 0xc6, 0xf8, 235 0x37, 0x66, 0xe5, 0xf9, 0x7b, 0x6c, 0x74, 0x23, 236 0x73, 0x80, 0x69, 0x00, 0xe4, 0x9f, 0x24, 0xb2, 237 0x2b, 0x09, 0x75, 0x44, 0xd4, 0x89, 0x6b, 0x42, 238 0x49, 0x89, 0xb5, 0xe1, 0xeb, 0xac, 0x0f, 0x07, 239 0xc2, 0x3f, 0x45, 0x98, 240 }, 241 .C_len = 60, 242 .T = { 243 0x36, 0x12, 0xd2, 0xe7, 0x9e, 0x3b, 0x07, 0x85, 244 0x56, 0x1b, 0xe1, 0x4a, 0xac, 0xa2, 0xfc, 0xcb, 245 }, 246 }, 247 { 248 /* Test Case 6. */ 249 /* K, P, A are the same as TC4. */ 250 .K = { 251 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 252 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 253 }, 254 .K_len = 16, 255 .IV = { 256 0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5, 257 0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa, 258 0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1, 259 0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28, 260 0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39, 261 0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54, 262 0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57, 263 0xa6, 0x37, 0xb3, 0x9b, 264 }, 265 .IV_len = 60, 266 .P = { 267 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 268 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 269 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 270 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 271 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 272 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 273 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 274 0xba, 0x63, 0x7b, 0x39, 275 }, 276 .P_len = 60, 277 .A = { 278 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 279 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 280 0xab, 0xad, 0xda, 0xd2, 281 }, 282 .A_len = 20, 283 .C = { 284 0x8c, 0xe2, 0x49, 0x98, 0x62, 0x56, 0x15, 0xb6, 285 0x03, 0xa0, 0x33, 0xac, 0xa1, 0x3f, 0xb8, 0x94, 286 0xbe, 0x91, 0x12, 0xa5, 0xc3, 0xa2, 0x11, 0xa8, 287 0xba, 0x26, 0x2a, 0x3c, 0xca, 0x7e, 0x2c, 0xa7, 288 0x01, 0xe4, 0xa9, 0xa4, 0xfb, 0xa4, 0x3c, 0x90, 289 0xcc, 0xdc, 0xb2, 0x81, 0xd4, 0x8c, 0x7c, 0x6f, 290 0xd6, 0x28, 0x75, 0xd2, 0xac, 0xa4, 0x17, 0x03, 291 0x4c, 0x34, 0xae, 0xe5, 292 }, 293 .C_len = 60, 294 .T = { 295 0x61, 0x9c, 0xc5, 0xae, 0xff, 0xfe, 0x0b, 0xfa, 296 0x46, 0x2a, 0xf4, 0x3c, 0x16, 0x99, 0xd0, 0x50, 297 }, 298 }, 299 { 300 /* Test Case 7. */ 301 .K = {0}, 302 .K_len = 24, 303 .IV = {0}, 304 .IV_len = 12, 305 .P = {0}, 306 .P_len = 0, 307 .A = {0}, 308 .A_len = 0, 309 .C = {0}, 310 .C_len = 0, 311 .T = { 312 0xcd, 0x33, 0xb2, 0x8a, 0xc7, 0x73, 0xf7, 0x4b, 313 0xa0, 0x0e, 0xd1, 0xf3, 0x12, 0x57, 0x24, 0x35, 314 }, 315 }, 316 { 317 /* Test Case 8. */ 318 .K = {0}, 319 .K_len = 24, 320 .IV = {0}, 321 .IV_len = 12, 322 .P = {0}, 323 .P_len = 16, 324 .A = {0}, 325 .A_len = 0, 326 .C = { 327 0x98, 0xe7, 0x24, 0x7c, 0x07, 0xf0, 0xfe, 0x41, 328 0x1c, 0x26, 0x7e, 0x43, 0x84, 0xb0, 0xf6, 0x00, 329 }, 330 .C_len = 16, 331 .T = { 332 0x2f, 0xf5, 0x8d, 0x80, 0x03, 0x39, 0x27, 0xab, 333 0x8e, 0xf4, 0xd4, 0x58, 0x75, 0x14, 0xf0, 0xfb, 334 }, 335 }, 336 { 337 /* Test Case 9. */ 338 .K = { 339 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 340 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 341 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 342 }, 343 .K_len = 24, 344 .IV = { 345 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 346 0xde, 0xca, 0xf8, 0x88, 347 }, 348 .IV_len = 12, 349 .P = { 350 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 351 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 352 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 353 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 354 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 355 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 356 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 357 0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55, 358 }, 359 .P_len = 64, 360 .A = {0}, 361 .A_len = 0, 362 .C = { 363 0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41, 364 0xeb, 0x06, 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57, 365 0x85, 0x9e, 0x1c, 0xea, 0xa6, 0xef, 0xd9, 0x84, 366 0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1, 0xe1, 0x9c, 367 0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25, 368 0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47, 369 0x18, 0xe2, 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9, 370 0xcc, 0xda, 0x27, 0x10, 0xac, 0xad, 0xe2, 0x56, 371 }, 372 .C_len = 64, 373 .T = { 374 0x99, 0x24, 0xa7, 0xc8, 0x58, 0x73, 0x36, 0xbf, 375 0xb1, 0x18, 0x02, 0x4d, 0xb8, 0x67, 0x4a, 0x14, 376 }, 377 }, 378 { 379 /* Test Case 10. */ 380 /* K and IV are the same as TC9. */ 381 .K = { 382 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 383 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 384 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 385 }, 386 .K_len = 24, 387 .IV = { 388 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 389 0xde, 0xca, 0xf8, 0x88, 390 }, 391 .IV_len = 12, 392 .P = { 393 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 394 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 395 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 396 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 397 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 398 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 399 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 400 0xba, 0x63, 0x7b, 0x39, 401 }, 402 .P_len = 60, 403 .A = { 404 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 405 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 406 0xab, 0xad, 0xda, 0xd2, 407 }, 408 .A_len = 20, 409 .C = { 410 0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41, 411 0xeb, 0x06, 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57, 412 0x85, 0x9e, 0x1c, 0xea, 0xa6, 0xef, 0xd9, 0x84, 413 0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1, 0xe1, 0x9c, 414 0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25, 415 0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47, 416 0x18, 0xe2, 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9, 417 0xcc, 0xda, 0x27, 0x10, 418 }, 419 .C_len = 60, 420 .T = { 421 0x25, 0x19, 0x49, 0x8e, 0x80, 0xf1, 0x47, 0x8f, 422 0x37, 0xba, 0x55, 0xbd, 0x6d, 0x27, 0x61, 0x8c, 423 }, 424 }, 425 { 426 /* Test Case 11. */ 427 /* K is the same as TC9, P and A are the same as TC10. */ 428 .K = { 429 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 430 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 431 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 432 }, 433 .K_len = 24, 434 .IV = { 435 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 436 }, 437 .IV_len = 8, 438 .P = { 439 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 440 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 441 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 442 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 443 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 444 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 445 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 446 0xba, 0x63, 0x7b, 0x39, 447 }, 448 .P_len = 60, 449 .A = { 450 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 451 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 452 0xab, 0xad, 0xda, 0xd2, 453 }, 454 .A_len = 20, 455 .C = { 456 0x0f, 0x10, 0xf5, 0x99, 0xae, 0x14, 0xa1, 0x54, 457 0xed, 0x24, 0xb3, 0x6e, 0x25, 0x32, 0x4d, 0xb8, 458 0xc5, 0x66, 0x63, 0x2e, 0xf2, 0xbb, 0xb3, 0x4f, 459 0x83, 0x47, 0x28, 0x0f, 0xc4, 0x50, 0x70, 0x57, 460 0xfd, 0xdc, 0x29, 0xdf, 0x9a, 0x47, 0x1f, 0x75, 461 0xc6, 0x65, 0x41, 0xd4, 0xd4, 0xda, 0xd1, 0xc9, 462 0xe9, 0x3a, 0x19, 0xa5, 0x8e, 0x8b, 0x47, 0x3f, 463 0xa0, 0xf0, 0x62, 0xf7 464 }, 465 .C_len = 60, 466 .T = { 467 0x65, 0xdc, 0xc5, 0x7f, 0xcf, 0x62, 0x3a, 0x24, 468 0x09, 0x4f, 0xcc, 0xa4, 0x0d, 0x35, 0x33, 0xf8, 469 }, 470 }, 471 { 472 /* Test Case 12. */ 473 /* K is the same as TC9, P and A are the same as TC10. */ 474 .K = { 475 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 476 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 477 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 478 }, 479 .K_len = 24, 480 .IV = { 481 0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5, 482 0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa, 483 0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1, 484 0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28, 485 0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39, 486 0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54, 487 0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57, 488 0xa6, 0x37, 0xb3, 0x9b, 489 }, 490 .IV_len = 60, 491 .P = { 492 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 493 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 494 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 495 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 496 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 497 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 498 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 499 0xba, 0x63, 0x7b, 0x39, 500 }, 501 .P_len = 60, 502 .A = { 503 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 504 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 505 0xab, 0xad, 0xda, 0xd2, 506 }, 507 .A_len = 20, 508 .C = { 509 0xd2, 0x7e, 0x88, 0x68, 0x1c, 0xe3, 0x24, 0x3c, 510 0x48, 0x30, 0x16, 0x5a, 0x8f, 0xdc, 0xf9, 0xff, 511 0x1d, 0xe9, 0xa1, 0xd8, 0xe6, 0xb4, 0x47, 0xef, 512 0x6e, 0xf7, 0xb7, 0x98, 0x28, 0x66, 0x6e, 0x45, 513 0x81, 0xe7, 0x90, 0x12, 0xaf, 0x34, 0xdd, 0xd9, 514 0xe2, 0xf0, 0x37, 0x58, 0x9b, 0x29, 0x2d, 0xb3, 515 0xe6, 0x7c, 0x03, 0x67, 0x45, 0xfa, 0x22, 0xe7, 516 0xe9, 0xb7, 0x37, 0x3b, 517 }, 518 .C_len = 60, 519 .T = { 520 0xdc, 0xf5, 0x66, 0xff, 0x29, 0x1c, 0x25, 0xbb, 521 0xb8, 0x56, 0x8f, 0xc3, 0xd3, 0x76, 0xa6, 0xd9, 522 }, 523 }, 524 { 525 /* Test Case 13. */ 526 .K = {0}, 527 .K_len = 32, 528 .IV = {0}, 529 .IV_len = 12, 530 .P = {0}, 531 .P_len = 0, 532 .A = {0}, 533 .A_len = 0, 534 .C = {0}, 535 .C_len = 0, 536 .T = { 537 0x53, 0x0f, 0x8a, 0xfb, 0xc7, 0x45, 0x36, 0xb9, 538 0xa9, 0x63, 0xb4, 0xf1, 0xc4, 0xcb, 0x73, 0x8b, 539 }, 540 }, 541 { 542 /* Test Case 14. */ 543 .K = {0}, 544 .K_len = 32, 545 .IV = {0}, 546 .IV_len = 12, 547 .P = {0}, 548 .P_len = 16, 549 .A = {0}, 550 .A_len = 0, 551 .C = { 552 0xce, 0xa7, 0x40, 0x3d, 0x4d, 0x60, 0x6b, 0x6e, 553 0x07, 0x4e, 0xc5, 0xd3, 0xba, 0xf3, 0x9d, 0x18, 554 }, 555 .C_len = 16, 556 .T = { 557 0xd0, 0xd1, 0xc8, 0xa7, 0x99, 0x99, 0x6b, 0xf0, 558 0x26, 0x5b, 0x98, 0xb5, 0xd4, 0x8a, 0xb9, 0x19, 559 }, 560 }, 561 { 562 /* Test Case 15. */ 563 .K = { 564 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 565 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 566 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 567 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 568 }, 569 .K_len = 32, 570 .IV = { 571 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 572 0xde, 0xca, 0xf8, 0x88, 573 }, 574 .IV_len = 12, 575 .P = { 576 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 577 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 578 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 579 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 580 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 581 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 582 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 583 0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55, 584 }, 585 .P_len = 64, 586 .A = {0}, 587 .A_len = 0, 588 .C = { 589 0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07, 590 0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d, 591 0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9, 592 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa, 593 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d, 594 0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38, 595 0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a, 596 0xbc, 0xc9, 0xf6, 0x62, 0x89, 0x80, 0x15, 0xad, 597 }, 598 .C_len = 64, 599 .T = { 600 0xb0, 0x94, 0xda, 0xc5, 0xd9, 0x34, 0x71, 0xbd, 601 0xec, 0x1a, 0x50, 0x22, 0x70, 0xe3, 0xcc, 0x6c, 602 }, 603 }, 604 { 605 /* Test Case 16. */ 606 /* K and IV are the same as TC15. */ 607 .K = { 608 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 609 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 610 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 611 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 612 }, 613 .K_len = 32, 614 .IV = { 615 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 616 0xde, 0xca, 0xf8, 0x88, 617 }, 618 .IV_len = 12, 619 .P = { 620 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 621 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 622 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 623 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 624 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 625 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 626 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 627 0xba, 0x63, 0x7b, 0x39, 628 }, 629 .P_len = 60, 630 .A = { 631 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 632 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 633 0xab, 0xad, 0xda, 0xd2, 634 }, 635 .A_len = 20, 636 .C = { 637 0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07, 638 0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d, 639 0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9, 640 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa, 641 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d, 642 0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38, 643 0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a, 644 0xbc, 0xc9, 0xf6, 0x62, 645 }, 646 .C_len = 60, 647 .T = { 648 0x76, 0xfc, 0x6e, 0xce, 0x0f, 0x4e, 0x17, 0x68, 649 0xcd, 0xdf, 0x88, 0x53, 0xbb, 0x2d, 0x55, 0x1b, 650 }, 651 }, 652 { 653 /* Test Case 17. */ 654 /* K is the same as TC15, P and A are the same as TC 16. */ 655 .K = { 656 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 657 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 658 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 659 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 660 }, 661 .K_len = 32, 662 .IV = { 663 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 664 }, 665 .IV_len = 8, 666 .P = { 667 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 668 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 669 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 670 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 671 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 672 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 673 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 674 0xba, 0x63, 0x7b, 0x39, 675 }, 676 .P_len = 60, 677 .A = { 678 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 679 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 680 0xab, 0xad, 0xda, 0xd2, 681 }, 682 .A_len = 20, 683 .C = { 684 0xc3, 0x76, 0x2d, 0xf1, 0xca, 0x78, 0x7d, 0x32, 685 0xae, 0x47, 0xc1, 0x3b, 0xf1, 0x98, 0x44, 0xcb, 686 0xaf, 0x1a, 0xe1, 0x4d, 0x0b, 0x97, 0x6a, 0xfa, 687 0xc5, 0x2f, 0xf7, 0xd7, 0x9b, 0xba, 0x9d, 0xe0, 688 0xfe, 0xb5, 0x82, 0xd3, 0x39, 0x34, 0xa4, 0xf0, 689 0x95, 0x4c, 0xc2, 0x36, 0x3b, 0xc7, 0x3f, 0x78, 690 0x62, 0xac, 0x43, 0x0e, 0x64, 0xab, 0xe4, 0x99, 691 0xf4, 0x7c, 0x9b, 0x1f, 692 }, 693 .C_len = 60, 694 .T = { 695 0x3a, 0x33, 0x7d, 0xbf, 0x46, 0xa7, 0x92, 0xc4, 696 0x5e, 0x45, 0x49, 0x13, 0xfe, 0x2e, 0xa8, 0xf2, 697 }, 698 }, 699 { 700 /* Test Case 18. */ 701 /* K is the same as TC15, P and A are the same as TC 16. */ 702 .K = { 703 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 704 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 705 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 706 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 707 }, 708 .K_len = 32, 709 .IV = { 710 0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5, 711 0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa, 712 0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1, 713 0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28, 714 0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39, 715 0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54, 716 0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57, 717 0xa6, 0x37, 0xb3, 0x9b, 718 }, 719 .IV_len = 60, 720 .P = { 721 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 722 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 723 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 724 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 725 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 726 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 727 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 728 0xba, 0x63, 0x7b, 0x39, 729 }, 730 .P_len = 60, 731 .A = { 732 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 733 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 734 0xab, 0xad, 0xda, 0xd2, 735 }, 736 .A_len = 20, 737 .C = { 738 0x5a, 0x8d, 0xef, 0x2f, 0x0c, 0x9e, 0x53, 0xf1, 739 0xf7, 0x5d, 0x78, 0x53, 0x65, 0x9e, 0x2a, 0x20, 740 0xee, 0xb2, 0xb2, 0x2a, 0xaf, 0xde, 0x64, 0x19, 741 0xa0, 0x58, 0xab, 0x4f, 0x6f, 0x74, 0x6b, 0xf4, 742 0x0f, 0xc0, 0xc3, 0xb7, 0x80, 0xf2, 0x44, 0x45, 743 0x2d, 0xa3, 0xeb, 0xf1, 0xc5, 0xd8, 0x2c, 0xde, 744 0xa2, 0x41, 0x89, 0x97, 0x20, 0x0e, 0xf8, 0x2e, 745 0x44, 0xae, 0x7e, 0x3f, 746 }, 747 .C_len = 60, 748 .T = { 749 0xa4, 0x4a, 0x82, 0x66, 0xee, 0x1c, 0x8e, 0xb0, 750 0xc8, 0xb5, 0xd4, 0xcf, 0x5a, 0xe9, 0xf1, 0x9a, 751 }, 752 }, 753 { 754 /* Test Case 19. */ 755 .K = {0}, 756 .K_len = 16, 757 .IV = {0}, 758 .IV_len = 12, 759 .P = {0}, 760 .P_len = 0, 761 .A = { 762 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 763 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 764 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 765 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 766 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 767 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 768 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 769 0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55, 770 0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07, 771 0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d, 772 0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9, 773 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa, 774 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d, 775 0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38, 776 0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a, 777 0xbc, 0xc9, 0xf6, 0x62, 0x89, 0x80, 0x15, 0xad, 778 }, 779 .A_len = 128, 780 .C = {0}, 781 .C_len = 0, 782 .T = { 783 0x5f, 0xea, 0x79, 0x3a, 0x2d, 0x6f, 0x97, 0x4d, 784 0x37, 0xe6, 0x8e, 0x0c, 0xb8, 0xff, 0x94, 0x92, 785 }, 786 }, 787 { 788 /* Test Case 20. */ 789 .K = {0}, 790 .K_len = 16, 791 .IV = { 792 /* This results in 0xff in counter LSB. */ 793 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 794 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 795 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 796 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 797 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 798 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 799 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 800 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 801 }, 802 .IV_len = 64, 803 .P = {0}, 804 .P_len = 288, 805 .A = {0}, 806 .A_len = 0, 807 .C = { 808 0x56, 0xb3, 0x37, 0x3c, 0xa9, 0xef, 0x6e, 0x4a, 809 0x2b, 0x64, 0xfe, 0x1e, 0x9a, 0x17, 0xb6, 0x14, 810 0x25, 0xf1, 0x0d, 0x47, 0xa7, 0x5a, 0x5f, 0xce, 811 0x13, 0xef, 0xc6, 0xbc, 0x78, 0x4a, 0xf2, 0x4f, 812 0x41, 0x41, 0xbd, 0xd4, 0x8c, 0xf7, 0xc7, 0x70, 813 0x88, 0x7a, 0xfd, 0x57, 0x3c, 0xca, 0x54, 0x18, 814 0xa9, 0xae, 0xff, 0xcd, 0x7c, 0x5c, 0xed, 0xdf, 815 0xc6, 0xa7, 0x83, 0x97, 0xb9, 0xa8, 0x5b, 0x49, 816 0x9d, 0xa5, 0x58, 0x25, 0x72, 0x67, 0xca, 0xab, 817 0x2a, 0xd0, 0xb2, 0x3c, 0xa4, 0x76, 0xa5, 0x3c, 818 0xb1, 0x7f, 0xb4, 0x1c, 0x4b, 0x8b, 0x47, 0x5c, 819 0xb4, 0xf3, 0xf7, 0x16, 0x50, 0x94, 0xc2, 0x29, 820 0xc9, 0xe8, 0xc4, 0xdc, 0x0a, 0x2a, 0x5f, 0xf1, 821 0x90, 0x3e, 0x50, 0x15, 0x11, 0x22, 0x13, 0x76, 822 0xa1, 0xcd, 0xb8, 0x36, 0x4c, 0x50, 0x61, 0xa2, 823 0x0c, 0xae, 0x74, 0xbc, 0x4a, 0xcd, 0x76, 0xce, 824 0xb0, 0xab, 0xc9, 0xfd, 0x32, 0x17, 0xef, 0x9f, 825 0x8c, 0x90, 0xbe, 0x40, 0x2d, 0xdf, 0x6d, 0x86, 826 0x97, 0xf4, 0xf8, 0x80, 0xdf, 0xf1, 0x5b, 0xfb, 827 0x7a, 0x6b, 0x28, 0x24, 0x1e, 0xc8, 0xfe, 0x18, 828 0x3c, 0x2d, 0x59, 0xe3, 0xf9, 0xdf, 0xff, 0x65, 829 0x3c, 0x71, 0x26, 0xf0, 0xac, 0xb9, 0xe6, 0x42, 830 0x11, 0xf4, 0x2b, 0xae, 0x12, 0xaf, 0x46, 0x2b, 831 0x10, 0x70, 0xbe, 0xf1, 0xab, 0x5e, 0x36, 0x06, 832 0x87, 0x2c, 0xa1, 0x0d, 0xee, 0x15, 0xb3, 0x24, 833 0x9b, 0x1a, 0x1b, 0x95, 0x8f, 0x23, 0x13, 0x4c, 834 0x4b, 0xcc, 0xb7, 0xd0, 0x32, 0x00, 0xbc, 0xe4, 835 0x20, 0xa2, 0xf8, 0xeb, 0x66, 0xdc, 0xf3, 0x64, 836 0x4d, 0x14, 0x23, 0xc1, 0xb5, 0x69, 0x90, 0x03, 837 0xc1, 0x3e, 0xce, 0xf4, 0xbf, 0x38, 0xa3, 0xb6, 838 0x0e, 0xed, 0xc3, 0x40, 0x33, 0xba, 0xc1, 0x90, 839 0x27, 0x83, 0xdc, 0x6d, 0x89, 0xe2, 0xe7, 0x74, 840 0x18, 0x8a, 0x43, 0x9c, 0x7e, 0xbc, 0xc0, 0x67, 841 0x2d, 0xbd, 0xa4, 0xdd, 0xcf, 0xb2, 0x79, 0x46, 842 0x13, 0xb0, 0xbe, 0x41, 0x31, 0x5e, 0xf7, 0x78, 843 0x70, 0x8a, 0x70, 0xee, 0x7d, 0x75, 0x16, 0x5c, 844 }, 845 .C_len = 288, 846 .T = { 847 0x8b, 0x30, 0x7f, 0x6b, 0x33, 0x28, 0x6d, 0x0a, 848 0xb0, 0x26, 0xa9, 0xed, 0x3f, 0xe1, 0xe8, 0x5f, 849 }, 850 }, 851 }; 852 853 #define N_TESTS (sizeof(gcm128_tests) / sizeof(*gcm128_tests)) 854 855 static int 856 do_gcm128_test(int test_no, struct gcm128_test *tv) 857 { 858 GCM128_CONTEXT ctx; 859 AES_KEY key; 860 uint8_t *out = NULL; 861 size_t out_len; 862 int ret = 1; 863 864 out_len = tv->P_len; 865 if (out_len != 0) { 866 out = malloc(out_len); 867 if (out == NULL) 868 err(1, "malloc"); 869 } 870 871 AES_set_encrypt_key(tv->K, tv->K_len * 8, &key); 872 873 if (out_len != 0) 874 memset(out, 0, out_len); 875 CRYPTO_gcm128_init(&ctx, &key, (block128_f)AES_encrypt); 876 CRYPTO_gcm128_setiv(&ctx, tv->IV, tv->IV_len); 877 if (tv->A_len > 0) 878 CRYPTO_gcm128_aad(&ctx, tv->A, tv->A_len); 879 if (tv->P_len > 0) 880 CRYPTO_gcm128_encrypt(&ctx, tv->P, out, out_len); 881 if (CRYPTO_gcm128_finish(&ctx, tv->T, 16)) { 882 fprintf(stderr, "TEST %i: CRYPTO_gcm128_finish failed\n", 883 test_no); 884 goto fail; 885 } 886 if (tv->C_len > 0 && memcmp(out, tv->C, out_len)) { 887 fprintf(stderr, "TEST %i: encrypt failed\n", test_no); 888 goto fail; 889 } 890 891 if (out_len != 0) 892 memset(out, 0, out_len); 893 CRYPTO_gcm128_setiv(&ctx, tv->IV, tv->IV_len); 894 if (tv->A_len > 0) 895 CRYPTO_gcm128_aad(&ctx, tv->A, tv->A_len); 896 if (tv->C_len > 0) 897 CRYPTO_gcm128_decrypt(&ctx, tv->C, out, out_len); 898 if (CRYPTO_gcm128_finish(&ctx, tv->T, 16)) { 899 fprintf(stderr, "TEST %i: CRYPTO_gcm128_finish failed\n", 900 test_no); 901 goto fail; 902 } 903 if (tv->P_len > 0 && memcmp(out, tv->P, out_len)) { 904 fprintf(stderr, "TEST %i: decrypt failed\n", test_no); 905 goto fail; 906 } 907 908 ret = 0; 909 910 fail: 911 free(out); 912 return (ret); 913 } 914 915 int 916 main(int argc, char **argv) 917 { 918 int ret = 0; 919 size_t i; 920 921 for (i = 0; i < N_TESTS; i++) 922 ret |= do_gcm128_test(i + 1, &gcm128_tests[i]); 923 924 return ret; 925 } 926