1e1051a39Sopenharmony_ci/* 2e1051a39Sopenharmony_ci * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved. 3e1051a39Sopenharmony_ci * 4e1051a39Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License"). You may not use 5e1051a39Sopenharmony_ci * this file except in compliance with the License. You can obtain a copy 6e1051a39Sopenharmony_ci * in the file LICENSE in the source distribution or at 7e1051a39Sopenharmony_ci * https://www.openssl.org/source/license.html 8e1051a39Sopenharmony_ci */ 9e1051a39Sopenharmony_ci 10e1051a39Sopenharmony_ci/* Internal tests for the modes module */ 11e1051a39Sopenharmony_ci 12e1051a39Sopenharmony_ci/* 13e1051a39Sopenharmony_ci * This file uses the low level AES functions (which are deprecated for 14e1051a39Sopenharmony_ci * non-internal use) in order to test the modes code 15e1051a39Sopenharmony_ci */ 16e1051a39Sopenharmony_ci#include "internal/deprecated.h" 17e1051a39Sopenharmony_ci 18e1051a39Sopenharmony_ci#include <stdio.h> 19e1051a39Sopenharmony_ci#include <string.h> 20e1051a39Sopenharmony_ci 21e1051a39Sopenharmony_ci#include <openssl/aes.h> 22e1051a39Sopenharmony_ci#include <openssl/modes.h> 23e1051a39Sopenharmony_ci#include "testutil.h" 24e1051a39Sopenharmony_ci#include "crypto/modes.h" 25e1051a39Sopenharmony_ci#include "internal/nelem.h" 26e1051a39Sopenharmony_ci 27e1051a39Sopenharmony_citypedef struct { 28e1051a39Sopenharmony_ci size_t size; 29e1051a39Sopenharmony_ci const unsigned char *data; 30e1051a39Sopenharmony_ci} SIZED_DATA; 31e1051a39Sopenharmony_ci 32e1051a39Sopenharmony_ci/********************************************************************** 33e1051a39Sopenharmony_ci * 34e1051a39Sopenharmony_ci * Test of cts128 35e1051a39Sopenharmony_ci * 36e1051a39Sopenharmony_ci ***/ 37e1051a39Sopenharmony_ci 38e1051a39Sopenharmony_ci/* cts128 test vectors from RFC 3962 */ 39e1051a39Sopenharmony_cistatic const unsigned char cts128_test_key[16] = "chicken teriyaki"; 40e1051a39Sopenharmony_cistatic const unsigned char cts128_test_input[64] = 41e1051a39Sopenharmony_ci "I would like the" " General Gau's C" 42e1051a39Sopenharmony_ci "hicken, please, " "and wonton soup."; 43e1051a39Sopenharmony_cistatic const unsigned char cts128_test_iv[] = 44e1051a39Sopenharmony_ci { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 45e1051a39Sopenharmony_ci 46e1051a39Sopenharmony_cistatic const unsigned char vector_17[17] = { 47e1051a39Sopenharmony_ci 0xc6, 0x35, 0x35, 0x68, 0xf2, 0xbf, 0x8c, 0xb4, 48e1051a39Sopenharmony_ci 0xd8, 0xa5, 0x80, 0x36, 0x2d, 0xa7, 0xff, 0x7f, 49e1051a39Sopenharmony_ci 0x97 50e1051a39Sopenharmony_ci}; 51e1051a39Sopenharmony_ci 52e1051a39Sopenharmony_cistatic const unsigned char vector_31[31] = { 53e1051a39Sopenharmony_ci 0xfc, 0x00, 0x78, 0x3e, 0x0e, 0xfd, 0xb2, 0xc1, 54e1051a39Sopenharmony_ci 0xd4, 0x45, 0xd4, 0xc8, 0xef, 0xf7, 0xed, 0x22, 55e1051a39Sopenharmony_ci 0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0, 56e1051a39Sopenharmony_ci 0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5 57e1051a39Sopenharmony_ci}; 58e1051a39Sopenharmony_ci 59e1051a39Sopenharmony_cistatic const unsigned char vector_32[32] = { 60e1051a39Sopenharmony_ci 0x39, 0x31, 0x25, 0x23, 0xa7, 0x86, 0x62, 0xd5, 61e1051a39Sopenharmony_ci 0xbe, 0x7f, 0xcb, 0xcc, 0x98, 0xeb, 0xf5, 0xa8, 62e1051a39Sopenharmony_ci 0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0, 63e1051a39Sopenharmony_ci 0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5, 0x84 64e1051a39Sopenharmony_ci}; 65e1051a39Sopenharmony_ci 66e1051a39Sopenharmony_cistatic const unsigned char vector_47[47] = { 67e1051a39Sopenharmony_ci 0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0, 68e1051a39Sopenharmony_ci 0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5, 0x84, 69e1051a39Sopenharmony_ci 0xb3, 0xff, 0xfd, 0x94, 0x0c, 0x16, 0xa1, 0x8c, 70e1051a39Sopenharmony_ci 0x1b, 0x55, 0x49, 0xd2, 0xf8, 0x38, 0x02, 0x9e, 71e1051a39Sopenharmony_ci 0x39, 0x31, 0x25, 0x23, 0xa7, 0x86, 0x62, 0xd5, 72e1051a39Sopenharmony_ci 0xbe, 0x7f, 0xcb, 0xcc, 0x98, 0xeb, 0xf5 73e1051a39Sopenharmony_ci}; 74e1051a39Sopenharmony_ci 75e1051a39Sopenharmony_cistatic const unsigned char vector_48[48] = { 76e1051a39Sopenharmony_ci 0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0, 77e1051a39Sopenharmony_ci 0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5, 0x84, 78e1051a39Sopenharmony_ci 0x9d, 0xad, 0x8b, 0xbb, 0x96, 0xc4, 0xcd, 0xc0, 79e1051a39Sopenharmony_ci 0x3b, 0xc1, 0x03, 0xe1, 0xa1, 0x94, 0xbb, 0xd8, 80e1051a39Sopenharmony_ci 0x39, 0x31, 0x25, 0x23, 0xa7, 0x86, 0x62, 0xd5, 81e1051a39Sopenharmony_ci 0xbe, 0x7f, 0xcb, 0xcc, 0x98, 0xeb, 0xf5, 0xa8 82e1051a39Sopenharmony_ci}; 83e1051a39Sopenharmony_ci 84e1051a39Sopenharmony_cistatic const unsigned char vector_64[64] = { 85e1051a39Sopenharmony_ci 0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0, 86e1051a39Sopenharmony_ci 0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5, 0x84, 87e1051a39Sopenharmony_ci 0x39, 0x31, 0x25, 0x23, 0xa7, 0x86, 0x62, 0xd5, 88e1051a39Sopenharmony_ci 0xbe, 0x7f, 0xcb, 0xcc, 0x98, 0xeb, 0xf5, 0xa8, 89e1051a39Sopenharmony_ci 0x48, 0x07, 0xef, 0xe8, 0x36, 0xee, 0x89, 0xa5, 90e1051a39Sopenharmony_ci 0x26, 0x73, 0x0d, 0xbc, 0x2f, 0x7b, 0xc8, 0x40, 91e1051a39Sopenharmony_ci 0x9d, 0xad, 0x8b, 0xbb, 0x96, 0xc4, 0xcd, 0xc0, 92e1051a39Sopenharmony_ci 0x3b, 0xc1, 0x03, 0xe1, 0xa1, 0x94, 0xbb, 0xd8 93e1051a39Sopenharmony_ci}; 94e1051a39Sopenharmony_ci 95e1051a39Sopenharmony_ci#define CTS128_TEST_VECTOR(len) \ 96e1051a39Sopenharmony_ci { \ 97e1051a39Sopenharmony_ci sizeof(vector_##len), vector_##len \ 98e1051a39Sopenharmony_ci } 99e1051a39Sopenharmony_cistatic const SIZED_DATA aes_cts128_vectors[] = { 100e1051a39Sopenharmony_ci CTS128_TEST_VECTOR(17), 101e1051a39Sopenharmony_ci CTS128_TEST_VECTOR(31), 102e1051a39Sopenharmony_ci CTS128_TEST_VECTOR(32), 103e1051a39Sopenharmony_ci CTS128_TEST_VECTOR(47), 104e1051a39Sopenharmony_ci CTS128_TEST_VECTOR(48), 105e1051a39Sopenharmony_ci CTS128_TEST_VECTOR(64), 106e1051a39Sopenharmony_ci}; 107e1051a39Sopenharmony_ci 108e1051a39Sopenharmony_cistatic AES_KEY *cts128_encrypt_key_schedule(void) 109e1051a39Sopenharmony_ci{ 110e1051a39Sopenharmony_ci static int init_key = 1; 111e1051a39Sopenharmony_ci static AES_KEY ks; 112e1051a39Sopenharmony_ci 113e1051a39Sopenharmony_ci if (init_key) { 114e1051a39Sopenharmony_ci AES_set_encrypt_key(cts128_test_key, 128, &ks); 115e1051a39Sopenharmony_ci init_key = 0; 116e1051a39Sopenharmony_ci } 117e1051a39Sopenharmony_ci return &ks; 118e1051a39Sopenharmony_ci} 119e1051a39Sopenharmony_ci 120e1051a39Sopenharmony_cistatic AES_KEY *cts128_decrypt_key_schedule(void) 121e1051a39Sopenharmony_ci{ 122e1051a39Sopenharmony_ci static int init_key = 1; 123e1051a39Sopenharmony_ci static AES_KEY ks; 124e1051a39Sopenharmony_ci 125e1051a39Sopenharmony_ci if (init_key) { 126e1051a39Sopenharmony_ci AES_set_decrypt_key(cts128_test_key, 128, &ks); 127e1051a39Sopenharmony_ci init_key = 0; 128e1051a39Sopenharmony_ci } 129e1051a39Sopenharmony_ci return &ks; 130e1051a39Sopenharmony_ci} 131e1051a39Sopenharmony_ci 132e1051a39Sopenharmony_citypedef struct { 133e1051a39Sopenharmony_ci const char *case_name; 134e1051a39Sopenharmony_ci size_t (*last_blocks_correction)(const unsigned char *in, 135e1051a39Sopenharmony_ci unsigned char *out, size_t len); 136e1051a39Sopenharmony_ci size_t (*encrypt_block)(const unsigned char *in, 137e1051a39Sopenharmony_ci unsigned char *out, size_t len, 138e1051a39Sopenharmony_ci const void *key, unsigned char ivec[16], 139e1051a39Sopenharmony_ci block128_f block); 140e1051a39Sopenharmony_ci size_t (*encrypt_stream)(const unsigned char *in, unsigned char *out, 141e1051a39Sopenharmony_ci size_t len, const void *key, 142e1051a39Sopenharmony_ci unsigned char ivec[16], cbc128_f cbc); 143e1051a39Sopenharmony_ci size_t (*decrypt_block)(const unsigned char *in, 144e1051a39Sopenharmony_ci unsigned char *out, size_t len, 145e1051a39Sopenharmony_ci const void *key, unsigned char ivec[16], 146e1051a39Sopenharmony_ci block128_f block); 147e1051a39Sopenharmony_ci size_t (*decrypt_stream)(const unsigned char *in, unsigned char *out, 148e1051a39Sopenharmony_ci size_t len, const void *key, 149e1051a39Sopenharmony_ci unsigned char ivec[16], cbc128_f cbc); 150e1051a39Sopenharmony_ci} CTS128_FIXTURE; 151e1051a39Sopenharmony_ci 152e1051a39Sopenharmony_cistatic size_t last_blocks_correction(const unsigned char *in, 153e1051a39Sopenharmony_ci unsigned char *out, size_t len) 154e1051a39Sopenharmony_ci{ 155e1051a39Sopenharmony_ci size_t tail; 156e1051a39Sopenharmony_ci 157e1051a39Sopenharmony_ci memcpy(out, in, len); 158e1051a39Sopenharmony_ci if ((tail = len % 16) == 0) 159e1051a39Sopenharmony_ci tail = 16; 160e1051a39Sopenharmony_ci tail += 16; 161e1051a39Sopenharmony_ci 162e1051a39Sopenharmony_ci return tail; 163e1051a39Sopenharmony_ci} 164e1051a39Sopenharmony_ci 165e1051a39Sopenharmony_cistatic size_t last_blocks_correction_nist(const unsigned char *in, 166e1051a39Sopenharmony_ci unsigned char *out, size_t len) 167e1051a39Sopenharmony_ci{ 168e1051a39Sopenharmony_ci size_t tail; 169e1051a39Sopenharmony_ci 170e1051a39Sopenharmony_ci if ((tail = len % 16) == 0) 171e1051a39Sopenharmony_ci tail = 16; 172e1051a39Sopenharmony_ci len -= 16 + tail; 173e1051a39Sopenharmony_ci memcpy(out, in, len); 174e1051a39Sopenharmony_ci /* flip two last blocks */ 175e1051a39Sopenharmony_ci memcpy(out + len, in + len + 16, tail); 176e1051a39Sopenharmony_ci memcpy(out + len + tail, in + len, 16); 177e1051a39Sopenharmony_ci len += 16 + tail; 178e1051a39Sopenharmony_ci tail = 16; 179e1051a39Sopenharmony_ci 180e1051a39Sopenharmony_ci return tail; 181e1051a39Sopenharmony_ci} 182e1051a39Sopenharmony_ci 183e1051a39Sopenharmony_cistatic int execute_cts128(const CTS128_FIXTURE *fixture, int num) 184e1051a39Sopenharmony_ci{ 185e1051a39Sopenharmony_ci const unsigned char *test_iv = cts128_test_iv; 186e1051a39Sopenharmony_ci size_t test_iv_len = sizeof(cts128_test_iv); 187e1051a39Sopenharmony_ci const unsigned char *orig_vector = aes_cts128_vectors[num].data; 188e1051a39Sopenharmony_ci size_t len = aes_cts128_vectors[num].size; 189e1051a39Sopenharmony_ci const unsigned char *test_input = cts128_test_input; 190e1051a39Sopenharmony_ci const AES_KEY *encrypt_key_schedule = cts128_encrypt_key_schedule(); 191e1051a39Sopenharmony_ci const AES_KEY *decrypt_key_schedule = cts128_decrypt_key_schedule(); 192e1051a39Sopenharmony_ci unsigned char iv[16]; 193e1051a39Sopenharmony_ci /* The largest test inputs are = 64 bytes. */ 194e1051a39Sopenharmony_ci unsigned char cleartext[64], ciphertext[64], vector[64]; 195e1051a39Sopenharmony_ci size_t tail, size; 196e1051a39Sopenharmony_ci 197e1051a39Sopenharmony_ci TEST_info("%s_vector_%lu", fixture->case_name, (unsigned long)len); 198e1051a39Sopenharmony_ci 199e1051a39Sopenharmony_ci tail = fixture->last_blocks_correction(orig_vector, vector, len); 200e1051a39Sopenharmony_ci 201e1051a39Sopenharmony_ci /* test block-based encryption */ 202e1051a39Sopenharmony_ci memcpy(iv, test_iv, test_iv_len); 203e1051a39Sopenharmony_ci if (!TEST_size_t_eq(fixture->encrypt_block(test_input, ciphertext, len, 204e1051a39Sopenharmony_ci encrypt_key_schedule, iv, 205e1051a39Sopenharmony_ci (block128_f)AES_encrypt), len) 206e1051a39Sopenharmony_ci || !TEST_mem_eq(ciphertext, len, vector, len) 207e1051a39Sopenharmony_ci || !TEST_mem_eq(iv, sizeof(iv), vector + len - tail, sizeof(iv))) 208e1051a39Sopenharmony_ci return 0; 209e1051a39Sopenharmony_ci 210e1051a39Sopenharmony_ci /* test block-based decryption */ 211e1051a39Sopenharmony_ci memcpy(iv, test_iv, test_iv_len); 212e1051a39Sopenharmony_ci size = fixture->decrypt_block(ciphertext, cleartext, len, 213e1051a39Sopenharmony_ci decrypt_key_schedule, iv, 214e1051a39Sopenharmony_ci (block128_f)AES_decrypt); 215e1051a39Sopenharmony_ci if (!TEST_true(len == size || len + 16 == size) 216e1051a39Sopenharmony_ci || !TEST_mem_eq(cleartext, len, test_input, len) 217e1051a39Sopenharmony_ci || !TEST_mem_eq(iv, sizeof(iv), vector + len - tail, sizeof(iv))) 218e1051a39Sopenharmony_ci return 0; 219e1051a39Sopenharmony_ci 220e1051a39Sopenharmony_ci /* test streamed encryption */ 221e1051a39Sopenharmony_ci memcpy(iv, test_iv, test_iv_len); 222e1051a39Sopenharmony_ci if (!TEST_size_t_eq(fixture->encrypt_stream(test_input, ciphertext, len, 223e1051a39Sopenharmony_ci encrypt_key_schedule, iv, 224e1051a39Sopenharmony_ci (cbc128_f) AES_cbc_encrypt), 225e1051a39Sopenharmony_ci len) 226e1051a39Sopenharmony_ci || !TEST_mem_eq(ciphertext, len, vector, len) 227e1051a39Sopenharmony_ci || !TEST_mem_eq(iv, sizeof(iv), vector + len - tail, sizeof(iv))) 228e1051a39Sopenharmony_ci return 0; 229e1051a39Sopenharmony_ci 230e1051a39Sopenharmony_ci /* test streamed decryption */ 231e1051a39Sopenharmony_ci memcpy(iv, test_iv, test_iv_len); 232e1051a39Sopenharmony_ci if (!TEST_size_t_eq(fixture->decrypt_stream(ciphertext, cleartext, len, 233e1051a39Sopenharmony_ci decrypt_key_schedule, iv, 234e1051a39Sopenharmony_ci (cbc128_f)AES_cbc_encrypt), 235e1051a39Sopenharmony_ci len) 236e1051a39Sopenharmony_ci || !TEST_mem_eq(cleartext, len, test_input, len) 237e1051a39Sopenharmony_ci || !TEST_mem_eq(iv, sizeof(iv), vector + len - tail, sizeof(iv))) 238e1051a39Sopenharmony_ci return 0; 239e1051a39Sopenharmony_ci 240e1051a39Sopenharmony_ci return 1; 241e1051a39Sopenharmony_ci} 242e1051a39Sopenharmony_ci 243e1051a39Sopenharmony_cistatic int test_aes_cts128(int idx) 244e1051a39Sopenharmony_ci{ 245e1051a39Sopenharmony_ci static const CTS128_FIXTURE fixture_cts128 = { 246e1051a39Sopenharmony_ci "aes_cts128", last_blocks_correction, 247e1051a39Sopenharmony_ci CRYPTO_cts128_encrypt_block, CRYPTO_cts128_encrypt, 248e1051a39Sopenharmony_ci CRYPTO_cts128_decrypt_block, CRYPTO_cts128_decrypt 249e1051a39Sopenharmony_ci }; 250e1051a39Sopenharmony_ci 251e1051a39Sopenharmony_ci return execute_cts128(&fixture_cts128, idx); 252e1051a39Sopenharmony_ci} 253e1051a39Sopenharmony_ci 254e1051a39Sopenharmony_cistatic int test_aes_cts128_nist(int idx) 255e1051a39Sopenharmony_ci{ 256e1051a39Sopenharmony_ci static const CTS128_FIXTURE fixture_cts128_nist = { 257e1051a39Sopenharmony_ci "aes_cts128_nist", last_blocks_correction_nist, 258e1051a39Sopenharmony_ci CRYPTO_nistcts128_encrypt_block, CRYPTO_nistcts128_encrypt, 259e1051a39Sopenharmony_ci CRYPTO_nistcts128_decrypt_block, CRYPTO_nistcts128_decrypt 260e1051a39Sopenharmony_ci }; 261e1051a39Sopenharmony_ci 262e1051a39Sopenharmony_ci return execute_cts128(&fixture_cts128_nist, idx); 263e1051a39Sopenharmony_ci} 264e1051a39Sopenharmony_ci 265e1051a39Sopenharmony_ci/* 266e1051a39Sopenharmony_ci * 267e1051a39Sopenharmony_ci * Test of gcm128 268e1051a39Sopenharmony_ci * 269e1051a39Sopenharmony_ci */ 270e1051a39Sopenharmony_ci 271e1051a39Sopenharmony_ci/* Test Case 1 */ 272e1051a39Sopenharmony_cistatic const u8 K1[16], P1[] = { 0 }, A1[] = { 0 }, IV1[12], C1[] = { 0 }; 273e1051a39Sopenharmony_cistatic const u8 T1[] = { 274e1051a39Sopenharmony_ci 0x58, 0xe2, 0xfc, 0xce, 0xfa, 0x7e, 0x30, 0x61, 275e1051a39Sopenharmony_ci 0x36, 0x7f, 0x1d, 0x57, 0xa4, 0xe7, 0x45, 0x5a 276e1051a39Sopenharmony_ci}; 277e1051a39Sopenharmony_ci 278e1051a39Sopenharmony_ci/* Test Case 2 */ 279e1051a39Sopenharmony_ci# define K2 K1 280e1051a39Sopenharmony_ci# define A2 A1 281e1051a39Sopenharmony_ci# define IV2 IV1 282e1051a39Sopenharmony_cistatic const u8 P2[16]; 283e1051a39Sopenharmony_cistatic const u8 C2[] = { 284e1051a39Sopenharmony_ci 0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92, 285e1051a39Sopenharmony_ci 0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78 286e1051a39Sopenharmony_ci}; 287e1051a39Sopenharmony_ci 288e1051a39Sopenharmony_cistatic const u8 T2[] = { 289e1051a39Sopenharmony_ci 0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec, 0x13, 0xbd, 290e1051a39Sopenharmony_ci 0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf 291e1051a39Sopenharmony_ci}; 292e1051a39Sopenharmony_ci 293e1051a39Sopenharmony_ci/* Test Case 3 */ 294e1051a39Sopenharmony_ci# define A3 A2 295e1051a39Sopenharmony_cistatic const u8 K3[] = { 296e1051a39Sopenharmony_ci 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 297e1051a39Sopenharmony_ci 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08 298e1051a39Sopenharmony_ci}; 299e1051a39Sopenharmony_ci 300e1051a39Sopenharmony_cistatic const u8 P3[] = { 301e1051a39Sopenharmony_ci 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 302e1051a39Sopenharmony_ci 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 303e1051a39Sopenharmony_ci 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 304e1051a39Sopenharmony_ci 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 305e1051a39Sopenharmony_ci 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 306e1051a39Sopenharmony_ci 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 307e1051a39Sopenharmony_ci 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 308e1051a39Sopenharmony_ci 0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55 309e1051a39Sopenharmony_ci}; 310e1051a39Sopenharmony_ci 311e1051a39Sopenharmony_cistatic const u8 IV3[] = { 312e1051a39Sopenharmony_ci 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 313e1051a39Sopenharmony_ci 0xde, 0xca, 0xf8, 0x88 314e1051a39Sopenharmony_ci}; 315e1051a39Sopenharmony_ci 316e1051a39Sopenharmony_cistatic const u8 C3[] = { 317e1051a39Sopenharmony_ci 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24, 318e1051a39Sopenharmony_ci 0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c, 319e1051a39Sopenharmony_ci 0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0, 320e1051a39Sopenharmony_ci 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e, 321e1051a39Sopenharmony_ci 0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c, 322e1051a39Sopenharmony_ci 0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05, 323e1051a39Sopenharmony_ci 0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97, 324e1051a39Sopenharmony_ci 0x3d, 0x58, 0xe0, 0x91, 0x47, 0x3f, 0x59, 0x85 325e1051a39Sopenharmony_ci}; 326e1051a39Sopenharmony_ci 327e1051a39Sopenharmony_cistatic const u8 T3[] = { 328e1051a39Sopenharmony_ci 0x4d, 0x5c, 0x2a, 0xf3, 0x27, 0xcd, 0x64, 0xa6, 329e1051a39Sopenharmony_ci 0x2c, 0xf3, 0x5a, 0xbd, 0x2b, 0xa6, 0xfa, 0xb4 330e1051a39Sopenharmony_ci}; 331e1051a39Sopenharmony_ci 332e1051a39Sopenharmony_ci/* Test Case 4 */ 333e1051a39Sopenharmony_ci# define K4 K3 334e1051a39Sopenharmony_ci# define IV4 IV3 335e1051a39Sopenharmony_cistatic const u8 P4[] = { 336e1051a39Sopenharmony_ci 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 337e1051a39Sopenharmony_ci 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 338e1051a39Sopenharmony_ci 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 339e1051a39Sopenharmony_ci 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 340e1051a39Sopenharmony_ci 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 341e1051a39Sopenharmony_ci 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 342e1051a39Sopenharmony_ci 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 343e1051a39Sopenharmony_ci 0xba, 0x63, 0x7b, 0x39 344e1051a39Sopenharmony_ci}; 345e1051a39Sopenharmony_ci 346e1051a39Sopenharmony_cistatic const u8 A4[] = { 347e1051a39Sopenharmony_ci 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 348e1051a39Sopenharmony_ci 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 349e1051a39Sopenharmony_ci 0xab, 0xad, 0xda, 0xd2 350e1051a39Sopenharmony_ci}; 351e1051a39Sopenharmony_ci 352e1051a39Sopenharmony_cistatic const u8 C4[] = { 353e1051a39Sopenharmony_ci 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24, 354e1051a39Sopenharmony_ci 0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c, 355e1051a39Sopenharmony_ci 0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0, 356e1051a39Sopenharmony_ci 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e, 357e1051a39Sopenharmony_ci 0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c, 358e1051a39Sopenharmony_ci 0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05, 359e1051a39Sopenharmony_ci 0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97, 360e1051a39Sopenharmony_ci 0x3d, 0x58, 0xe0, 0x91 361e1051a39Sopenharmony_ci}; 362e1051a39Sopenharmony_ci 363e1051a39Sopenharmony_cistatic const u8 T4[] = { 364e1051a39Sopenharmony_ci 0x5b, 0xc9, 0x4f, 0xbc, 0x32, 0x21, 0xa5, 0xdb, 365e1051a39Sopenharmony_ci 0x94, 0xfa, 0xe9, 0x5a, 0xe7, 0x12, 0x1a, 0x47 366e1051a39Sopenharmony_ci}; 367e1051a39Sopenharmony_ci 368e1051a39Sopenharmony_ci/* Test Case 5 */ 369e1051a39Sopenharmony_ci# define K5 K4 370e1051a39Sopenharmony_ci# define P5 P4 371e1051a39Sopenharmony_ci# define A5 A4 372e1051a39Sopenharmony_cistatic const u8 IV5[] = { 373e1051a39Sopenharmony_ci 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad 374e1051a39Sopenharmony_ci}; 375e1051a39Sopenharmony_ci 376e1051a39Sopenharmony_cistatic const u8 C5[] = { 377e1051a39Sopenharmony_ci 0x61, 0x35, 0x3b, 0x4c, 0x28, 0x06, 0x93, 0x4a, 378e1051a39Sopenharmony_ci 0x77, 0x7f, 0xf5, 0x1f, 0xa2, 0x2a, 0x47, 0x55, 379e1051a39Sopenharmony_ci 0x69, 0x9b, 0x2a, 0x71, 0x4f, 0xcd, 0xc6, 0xf8, 380e1051a39Sopenharmony_ci 0x37, 0x66, 0xe5, 0xf9, 0x7b, 0x6c, 0x74, 0x23, 381e1051a39Sopenharmony_ci 0x73, 0x80, 0x69, 0x00, 0xe4, 0x9f, 0x24, 0xb2, 382e1051a39Sopenharmony_ci 0x2b, 0x09, 0x75, 0x44, 0xd4, 0x89, 0x6b, 0x42, 383e1051a39Sopenharmony_ci 0x49, 0x89, 0xb5, 0xe1, 0xeb, 0xac, 0x0f, 0x07, 384e1051a39Sopenharmony_ci 0xc2, 0x3f, 0x45, 0x98 385e1051a39Sopenharmony_ci}; 386e1051a39Sopenharmony_ci 387e1051a39Sopenharmony_cistatic const u8 T5[] = { 388e1051a39Sopenharmony_ci 0x36, 0x12, 0xd2, 0xe7, 0x9e, 0x3b, 0x07, 0x85, 389e1051a39Sopenharmony_ci 0x56, 0x1b, 0xe1, 0x4a, 0xac, 0xa2, 0xfc, 0xcb 390e1051a39Sopenharmony_ci}; 391e1051a39Sopenharmony_ci 392e1051a39Sopenharmony_ci/* Test Case 6 */ 393e1051a39Sopenharmony_ci# define K6 K5 394e1051a39Sopenharmony_ci# define P6 P5 395e1051a39Sopenharmony_ci# define A6 A5 396e1051a39Sopenharmony_cistatic const u8 IV6[] = { 397e1051a39Sopenharmony_ci 0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5, 398e1051a39Sopenharmony_ci 0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa, 399e1051a39Sopenharmony_ci 0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1, 400e1051a39Sopenharmony_ci 0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28, 401e1051a39Sopenharmony_ci 0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39, 402e1051a39Sopenharmony_ci 0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54, 403e1051a39Sopenharmony_ci 0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57, 404e1051a39Sopenharmony_ci 0xa6, 0x37, 0xb3, 0x9b 405e1051a39Sopenharmony_ci}; 406e1051a39Sopenharmony_ci 407e1051a39Sopenharmony_cistatic const u8 C6[] = { 408e1051a39Sopenharmony_ci 0x8c, 0xe2, 0x49, 0x98, 0x62, 0x56, 0x15, 0xb6, 409e1051a39Sopenharmony_ci 0x03, 0xa0, 0x33, 0xac, 0xa1, 0x3f, 0xb8, 0x94, 410e1051a39Sopenharmony_ci 0xbe, 0x91, 0x12, 0xa5, 0xc3, 0xa2, 0x11, 0xa8, 411e1051a39Sopenharmony_ci 0xba, 0x26, 0x2a, 0x3c, 0xca, 0x7e, 0x2c, 0xa7, 412e1051a39Sopenharmony_ci 0x01, 0xe4, 0xa9, 0xa4, 0xfb, 0xa4, 0x3c, 0x90, 413e1051a39Sopenharmony_ci 0xcc, 0xdc, 0xb2, 0x81, 0xd4, 0x8c, 0x7c, 0x6f, 414e1051a39Sopenharmony_ci 0xd6, 0x28, 0x75, 0xd2, 0xac, 0xa4, 0x17, 0x03, 415e1051a39Sopenharmony_ci 0x4c, 0x34, 0xae, 0xe5 416e1051a39Sopenharmony_ci}; 417e1051a39Sopenharmony_ci 418e1051a39Sopenharmony_cistatic const u8 T6[] = { 419e1051a39Sopenharmony_ci 0x61, 0x9c, 0xc5, 0xae, 0xff, 0xfe, 0x0b, 0xfa, 420e1051a39Sopenharmony_ci 0x46, 0x2a, 0xf4, 0x3c, 0x16, 0x99, 0xd0, 0x50 421e1051a39Sopenharmony_ci}; 422e1051a39Sopenharmony_ci 423e1051a39Sopenharmony_ci/* Test Case 7 */ 424e1051a39Sopenharmony_cistatic const u8 K7[24], P7[] = { 0 }, A7[] = { 0 }, IV7[12], C7[] = { 0 }; 425e1051a39Sopenharmony_cistatic const u8 T7[] = { 426e1051a39Sopenharmony_ci 0xcd, 0x33, 0xb2, 0x8a, 0xc7, 0x73, 0xf7, 0x4b, 427e1051a39Sopenharmony_ci 0xa0, 0x0e, 0xd1, 0xf3, 0x12, 0x57, 0x24, 0x35 428e1051a39Sopenharmony_ci}; 429e1051a39Sopenharmony_ci 430e1051a39Sopenharmony_ci/* Test Case 8 */ 431e1051a39Sopenharmony_ci# define K8 K7 432e1051a39Sopenharmony_ci# define IV8 IV7 433e1051a39Sopenharmony_ci# define A8 A7 434e1051a39Sopenharmony_cistatic const u8 P8[16]; 435e1051a39Sopenharmony_cistatic const u8 C8[] = { 436e1051a39Sopenharmony_ci 0x98, 0xe7, 0x24, 0x7c, 0x07, 0xf0, 0xfe, 0x41, 437e1051a39Sopenharmony_ci 0x1c, 0x26, 0x7e, 0x43, 0x84, 0xb0, 0xf6, 0x00 438e1051a39Sopenharmony_ci}; 439e1051a39Sopenharmony_ci 440e1051a39Sopenharmony_cistatic const u8 T8[] = { 441e1051a39Sopenharmony_ci 0x2f, 0xf5, 0x8d, 0x80, 0x03, 0x39, 0x27, 0xab, 442e1051a39Sopenharmony_ci 0x8e, 0xf4, 0xd4, 0x58, 0x75, 0x14, 0xf0, 0xfb 443e1051a39Sopenharmony_ci}; 444e1051a39Sopenharmony_ci 445e1051a39Sopenharmony_ci/* Test Case 9 */ 446e1051a39Sopenharmony_ci# define A9 A8 447e1051a39Sopenharmony_cistatic const u8 K9[] = { 448e1051a39Sopenharmony_ci 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 449e1051a39Sopenharmony_ci 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 450e1051a39Sopenharmony_ci 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c 451e1051a39Sopenharmony_ci}; 452e1051a39Sopenharmony_ci 453e1051a39Sopenharmony_cistatic const u8 P9[] = { 454e1051a39Sopenharmony_ci 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 455e1051a39Sopenharmony_ci 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 456e1051a39Sopenharmony_ci 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 457e1051a39Sopenharmony_ci 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 458e1051a39Sopenharmony_ci 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 459e1051a39Sopenharmony_ci 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 460e1051a39Sopenharmony_ci 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 461e1051a39Sopenharmony_ci 0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55 462e1051a39Sopenharmony_ci}; 463e1051a39Sopenharmony_ci 464e1051a39Sopenharmony_cistatic const u8 IV9[] = { 465e1051a39Sopenharmony_ci 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 466e1051a39Sopenharmony_ci 0xde, 0xca, 0xf8, 0x88 467e1051a39Sopenharmony_ci}; 468e1051a39Sopenharmony_ci 469e1051a39Sopenharmony_cistatic const u8 C9[] = { 470e1051a39Sopenharmony_ci 0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41, 471e1051a39Sopenharmony_ci 0xeb, 0x06, 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57, 472e1051a39Sopenharmony_ci 0x85, 0x9e, 0x1c, 0xea, 0xa6, 0xef, 0xd9, 0x84, 473e1051a39Sopenharmony_ci 0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1, 0xe1, 0x9c, 474e1051a39Sopenharmony_ci 0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25, 475e1051a39Sopenharmony_ci 0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47, 476e1051a39Sopenharmony_ci 0x18, 0xe2, 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9, 477e1051a39Sopenharmony_ci 0xcc, 0xda, 0x27, 0x10, 0xac, 0xad, 0xe2, 0x56 478e1051a39Sopenharmony_ci}; 479e1051a39Sopenharmony_ci 480e1051a39Sopenharmony_cistatic const u8 T9[] = { 481e1051a39Sopenharmony_ci 0x99, 0x24, 0xa7, 0xc8, 0x58, 0x73, 0x36, 0xbf, 482e1051a39Sopenharmony_ci 0xb1, 0x18, 0x02, 0x4d, 0xb8, 0x67, 0x4a, 0x14 483e1051a39Sopenharmony_ci}; 484e1051a39Sopenharmony_ci 485e1051a39Sopenharmony_ci/* Test Case 10 */ 486e1051a39Sopenharmony_ci# define K10 K9 487e1051a39Sopenharmony_ci# define IV10 IV9 488e1051a39Sopenharmony_cistatic const u8 P10[] = { 489e1051a39Sopenharmony_ci 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 490e1051a39Sopenharmony_ci 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 491e1051a39Sopenharmony_ci 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 492e1051a39Sopenharmony_ci 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 493e1051a39Sopenharmony_ci 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 494e1051a39Sopenharmony_ci 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 495e1051a39Sopenharmony_ci 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 496e1051a39Sopenharmony_ci 0xba, 0x63, 0x7b, 0x39 497e1051a39Sopenharmony_ci}; 498e1051a39Sopenharmony_ci 499e1051a39Sopenharmony_cistatic const u8 A10[] = { 500e1051a39Sopenharmony_ci 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 501e1051a39Sopenharmony_ci 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 502e1051a39Sopenharmony_ci 0xab, 0xad, 0xda, 0xd2 503e1051a39Sopenharmony_ci}; 504e1051a39Sopenharmony_ci 505e1051a39Sopenharmony_cistatic const u8 C10[] = { 506e1051a39Sopenharmony_ci 0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41, 507e1051a39Sopenharmony_ci 0xeb, 0x06, 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57, 508e1051a39Sopenharmony_ci 0x85, 0x9e, 0x1c, 0xea, 0xa6, 0xef, 0xd9, 0x84, 509e1051a39Sopenharmony_ci 0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1, 0xe1, 0x9c, 510e1051a39Sopenharmony_ci 0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25, 511e1051a39Sopenharmony_ci 0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47, 512e1051a39Sopenharmony_ci 0x18, 0xe2, 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9, 513e1051a39Sopenharmony_ci 0xcc, 0xda, 0x27, 0x10 514e1051a39Sopenharmony_ci}; 515e1051a39Sopenharmony_ci 516e1051a39Sopenharmony_cistatic const u8 T10[] = { 517e1051a39Sopenharmony_ci 0x25, 0x19, 0x49, 0x8e, 0x80, 0xf1, 0x47, 0x8f, 518e1051a39Sopenharmony_ci 0x37, 0xba, 0x55, 0xbd, 0x6d, 0x27, 0x61, 0x8c 519e1051a39Sopenharmony_ci}; 520e1051a39Sopenharmony_ci 521e1051a39Sopenharmony_ci/* Test Case 11 */ 522e1051a39Sopenharmony_ci# define K11 K10 523e1051a39Sopenharmony_ci# define P11 P10 524e1051a39Sopenharmony_ci# define A11 A10 525e1051a39Sopenharmony_cistatic const u8 IV11[] = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad }; 526e1051a39Sopenharmony_ci 527e1051a39Sopenharmony_cistatic const u8 C11[] = { 528e1051a39Sopenharmony_ci 0x0f, 0x10, 0xf5, 0x99, 0xae, 0x14, 0xa1, 0x54, 529e1051a39Sopenharmony_ci 0xed, 0x24, 0xb3, 0x6e, 0x25, 0x32, 0x4d, 0xb8, 530e1051a39Sopenharmony_ci 0xc5, 0x66, 0x63, 0x2e, 0xf2, 0xbb, 0xb3, 0x4f, 531e1051a39Sopenharmony_ci 0x83, 0x47, 0x28, 0x0f, 0xc4, 0x50, 0x70, 0x57, 532e1051a39Sopenharmony_ci 0xfd, 0xdc, 0x29, 0xdf, 0x9a, 0x47, 0x1f, 0x75, 533e1051a39Sopenharmony_ci 0xc6, 0x65, 0x41, 0xd4, 0xd4, 0xda, 0xd1, 0xc9, 534e1051a39Sopenharmony_ci 0xe9, 0x3a, 0x19, 0xa5, 0x8e, 0x8b, 0x47, 0x3f, 535e1051a39Sopenharmony_ci 0xa0, 0xf0, 0x62, 0xf7 536e1051a39Sopenharmony_ci}; 537e1051a39Sopenharmony_ci 538e1051a39Sopenharmony_cistatic const u8 T11[] = { 539e1051a39Sopenharmony_ci 0x65, 0xdc, 0xc5, 0x7f, 0xcf, 0x62, 0x3a, 0x24, 540e1051a39Sopenharmony_ci 0x09, 0x4f, 0xcc, 0xa4, 0x0d, 0x35, 0x33, 0xf8 541e1051a39Sopenharmony_ci}; 542e1051a39Sopenharmony_ci 543e1051a39Sopenharmony_ci/* Test Case 12 */ 544e1051a39Sopenharmony_ci# define K12 K11 545e1051a39Sopenharmony_ci# define P12 P11 546e1051a39Sopenharmony_ci# define A12 A11 547e1051a39Sopenharmony_cistatic const u8 IV12[] = { 548e1051a39Sopenharmony_ci 0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5, 549e1051a39Sopenharmony_ci 0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa, 550e1051a39Sopenharmony_ci 0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1, 551e1051a39Sopenharmony_ci 0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28, 552e1051a39Sopenharmony_ci 0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39, 553e1051a39Sopenharmony_ci 0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54, 554e1051a39Sopenharmony_ci 0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57, 555e1051a39Sopenharmony_ci 0xa6, 0x37, 0xb3, 0x9b 556e1051a39Sopenharmony_ci}; 557e1051a39Sopenharmony_ci 558e1051a39Sopenharmony_cistatic const u8 C12[] = { 559e1051a39Sopenharmony_ci 0xd2, 0x7e, 0x88, 0x68, 0x1c, 0xe3, 0x24, 0x3c, 560e1051a39Sopenharmony_ci 0x48, 0x30, 0x16, 0x5a, 0x8f, 0xdc, 0xf9, 0xff, 561e1051a39Sopenharmony_ci 0x1d, 0xe9, 0xa1, 0xd8, 0xe6, 0xb4, 0x47, 0xef, 562e1051a39Sopenharmony_ci 0x6e, 0xf7, 0xb7, 0x98, 0x28, 0x66, 0x6e, 0x45, 563e1051a39Sopenharmony_ci 0x81, 0xe7, 0x90, 0x12, 0xaf, 0x34, 0xdd, 0xd9, 564e1051a39Sopenharmony_ci 0xe2, 0xf0, 0x37, 0x58, 0x9b, 0x29, 0x2d, 0xb3, 565e1051a39Sopenharmony_ci 0xe6, 0x7c, 0x03, 0x67, 0x45, 0xfa, 0x22, 0xe7, 566e1051a39Sopenharmony_ci 0xe9, 0xb7, 0x37, 0x3b 567e1051a39Sopenharmony_ci}; 568e1051a39Sopenharmony_ci 569e1051a39Sopenharmony_cistatic const u8 T12[] = { 570e1051a39Sopenharmony_ci 0xdc, 0xf5, 0x66, 0xff, 0x29, 0x1c, 0x25, 0xbb, 571e1051a39Sopenharmony_ci 0xb8, 0x56, 0x8f, 0xc3, 0xd3, 0x76, 0xa6, 0xd9 572e1051a39Sopenharmony_ci}; 573e1051a39Sopenharmony_ci 574e1051a39Sopenharmony_ci/* Test Case 13 */ 575e1051a39Sopenharmony_cistatic const u8 K13[32], P13[] = { 0 }, A13[] = { 0 }, IV13[12], C13[] = { 0 }; 576e1051a39Sopenharmony_cistatic const u8 T13[] = { 577e1051a39Sopenharmony_ci 0x53, 0x0f, 0x8a, 0xfb, 0xc7, 0x45, 0x36, 0xb9, 578e1051a39Sopenharmony_ci 0xa9, 0x63, 0xb4, 0xf1, 0xc4, 0xcb, 0x73, 0x8b 579e1051a39Sopenharmony_ci}; 580e1051a39Sopenharmony_ci 581e1051a39Sopenharmony_ci/* Test Case 14 */ 582e1051a39Sopenharmony_ci# define K14 K13 583e1051a39Sopenharmony_ci# define A14 A13 584e1051a39Sopenharmony_cistatic const u8 P14[16], IV14[12]; 585e1051a39Sopenharmony_cistatic const u8 C14[] = { 586e1051a39Sopenharmony_ci 0xce, 0xa7, 0x40, 0x3d, 0x4d, 0x60, 0x6b, 0x6e, 587e1051a39Sopenharmony_ci 0x07, 0x4e, 0xc5, 0xd3, 0xba, 0xf3, 0x9d, 0x18 588e1051a39Sopenharmony_ci}; 589e1051a39Sopenharmony_ci 590e1051a39Sopenharmony_cistatic const u8 T14[] = { 591e1051a39Sopenharmony_ci 0xd0, 0xd1, 0xc8, 0xa7, 0x99, 0x99, 0x6b, 0xf0, 592e1051a39Sopenharmony_ci 0x26, 0x5b, 0x98, 0xb5, 0xd4, 0x8a, 0xb9, 0x19 593e1051a39Sopenharmony_ci}; 594e1051a39Sopenharmony_ci 595e1051a39Sopenharmony_ci/* Test Case 15 */ 596e1051a39Sopenharmony_ci# define A15 A14 597e1051a39Sopenharmony_cistatic const u8 K15[] = { 598e1051a39Sopenharmony_ci 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 599e1051a39Sopenharmony_ci 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, 600e1051a39Sopenharmony_ci 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 601e1051a39Sopenharmony_ci 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08 602e1051a39Sopenharmony_ci}; 603e1051a39Sopenharmony_ci 604e1051a39Sopenharmony_cistatic const u8 P15[] = { 605e1051a39Sopenharmony_ci 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 606e1051a39Sopenharmony_ci 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 607e1051a39Sopenharmony_ci 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 608e1051a39Sopenharmony_ci 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 609e1051a39Sopenharmony_ci 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 610e1051a39Sopenharmony_ci 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 611e1051a39Sopenharmony_ci 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 612e1051a39Sopenharmony_ci 0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55 613e1051a39Sopenharmony_ci}; 614e1051a39Sopenharmony_ci 615e1051a39Sopenharmony_cistatic const u8 IV15[] = { 616e1051a39Sopenharmony_ci 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 617e1051a39Sopenharmony_ci 0xde, 0xca, 0xf8, 0x88 618e1051a39Sopenharmony_ci}; 619e1051a39Sopenharmony_ci 620e1051a39Sopenharmony_cistatic const u8 C15[] = { 621e1051a39Sopenharmony_ci 0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07, 622e1051a39Sopenharmony_ci 0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d, 623e1051a39Sopenharmony_ci 0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9, 624e1051a39Sopenharmony_ci 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa, 625e1051a39Sopenharmony_ci 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d, 626e1051a39Sopenharmony_ci 0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38, 627e1051a39Sopenharmony_ci 0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a, 628e1051a39Sopenharmony_ci 0xbc, 0xc9, 0xf6, 0x62, 0x89, 0x80, 0x15, 0xad 629e1051a39Sopenharmony_ci}; 630e1051a39Sopenharmony_ci 631e1051a39Sopenharmony_cistatic const u8 T15[] = { 632e1051a39Sopenharmony_ci 0xb0, 0x94, 0xda, 0xc5, 0xd9, 0x34, 0x71, 0xbd, 633e1051a39Sopenharmony_ci 0xec, 0x1a, 0x50, 0x22, 0x70, 0xe3, 0xcc, 0x6c 634e1051a39Sopenharmony_ci}; 635e1051a39Sopenharmony_ci 636e1051a39Sopenharmony_ci/* Test Case 16 */ 637e1051a39Sopenharmony_ci# define K16 K15 638e1051a39Sopenharmony_ci# define IV16 IV15 639e1051a39Sopenharmony_cistatic const u8 P16[] = { 640e1051a39Sopenharmony_ci 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 641e1051a39Sopenharmony_ci 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 642e1051a39Sopenharmony_ci 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 643e1051a39Sopenharmony_ci 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 644e1051a39Sopenharmony_ci 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 645e1051a39Sopenharmony_ci 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 646e1051a39Sopenharmony_ci 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 647e1051a39Sopenharmony_ci 0xba, 0x63, 0x7b, 0x39 648e1051a39Sopenharmony_ci}; 649e1051a39Sopenharmony_ci 650e1051a39Sopenharmony_cistatic const u8 A16[] = { 651e1051a39Sopenharmony_ci 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 652e1051a39Sopenharmony_ci 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef, 653e1051a39Sopenharmony_ci 0xab, 0xad, 0xda, 0xd2 654e1051a39Sopenharmony_ci}; 655e1051a39Sopenharmony_ci 656e1051a39Sopenharmony_cistatic const u8 C16[] = { 657e1051a39Sopenharmony_ci 0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07, 658e1051a39Sopenharmony_ci 0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d, 659e1051a39Sopenharmony_ci 0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9, 660e1051a39Sopenharmony_ci 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa, 661e1051a39Sopenharmony_ci 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d, 662e1051a39Sopenharmony_ci 0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38, 663e1051a39Sopenharmony_ci 0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a, 664e1051a39Sopenharmony_ci 0xbc, 0xc9, 0xf6, 0x62 665e1051a39Sopenharmony_ci}; 666e1051a39Sopenharmony_ci 667e1051a39Sopenharmony_cistatic const u8 T16[] = { 668e1051a39Sopenharmony_ci 0x76, 0xfc, 0x6e, 0xce, 0x0f, 0x4e, 0x17, 0x68, 669e1051a39Sopenharmony_ci 0xcd, 0xdf, 0x88, 0x53, 0xbb, 0x2d, 0x55, 0x1b 670e1051a39Sopenharmony_ci}; 671e1051a39Sopenharmony_ci 672e1051a39Sopenharmony_ci/* Test Case 17 */ 673e1051a39Sopenharmony_ci# define K17 K16 674e1051a39Sopenharmony_ci# define P17 P16 675e1051a39Sopenharmony_ci# define A17 A16 676e1051a39Sopenharmony_cistatic const u8 IV17[] = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad }; 677e1051a39Sopenharmony_ci 678e1051a39Sopenharmony_cistatic const u8 C17[] = { 679e1051a39Sopenharmony_ci 0xc3, 0x76, 0x2d, 0xf1, 0xca, 0x78, 0x7d, 0x32, 680e1051a39Sopenharmony_ci 0xae, 0x47, 0xc1, 0x3b, 0xf1, 0x98, 0x44, 0xcb, 681e1051a39Sopenharmony_ci 0xaf, 0x1a, 0xe1, 0x4d, 0x0b, 0x97, 0x6a, 0xfa, 682e1051a39Sopenharmony_ci 0xc5, 0x2f, 0xf7, 0xd7, 0x9b, 0xba, 0x9d, 0xe0, 683e1051a39Sopenharmony_ci 0xfe, 0xb5, 0x82, 0xd3, 0x39, 0x34, 0xa4, 0xf0, 684e1051a39Sopenharmony_ci 0x95, 0x4c, 0xc2, 0x36, 0x3b, 0xc7, 0x3f, 0x78, 685e1051a39Sopenharmony_ci 0x62, 0xac, 0x43, 0x0e, 0x64, 0xab, 0xe4, 0x99, 686e1051a39Sopenharmony_ci 0xf4, 0x7c, 0x9b, 0x1f 687e1051a39Sopenharmony_ci}; 688e1051a39Sopenharmony_ci 689e1051a39Sopenharmony_cistatic const u8 T17[] = { 690e1051a39Sopenharmony_ci 0x3a, 0x33, 0x7d, 0xbf, 0x46, 0xa7, 0x92, 0xc4, 691e1051a39Sopenharmony_ci 0x5e, 0x45, 0x49, 0x13, 0xfe, 0x2e, 0xa8, 0xf2 692e1051a39Sopenharmony_ci}; 693e1051a39Sopenharmony_ci 694e1051a39Sopenharmony_ci/* Test Case 18 */ 695e1051a39Sopenharmony_ci# define K18 K17 696e1051a39Sopenharmony_ci# define P18 P17 697e1051a39Sopenharmony_ci# define A18 A17 698e1051a39Sopenharmony_cistatic const u8 IV18[] = { 699e1051a39Sopenharmony_ci 0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5, 700e1051a39Sopenharmony_ci 0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa, 701e1051a39Sopenharmony_ci 0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1, 702e1051a39Sopenharmony_ci 0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28, 703e1051a39Sopenharmony_ci 0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39, 704e1051a39Sopenharmony_ci 0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54, 705e1051a39Sopenharmony_ci 0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57, 706e1051a39Sopenharmony_ci 0xa6, 0x37, 0xb3, 0x9b 707e1051a39Sopenharmony_ci}; 708e1051a39Sopenharmony_ci 709e1051a39Sopenharmony_cistatic const u8 C18[] = { 710e1051a39Sopenharmony_ci 0x5a, 0x8d, 0xef, 0x2f, 0x0c, 0x9e, 0x53, 0xf1, 711e1051a39Sopenharmony_ci 0xf7, 0x5d, 0x78, 0x53, 0x65, 0x9e, 0x2a, 0x20, 712e1051a39Sopenharmony_ci 0xee, 0xb2, 0xb2, 0x2a, 0xaf, 0xde, 0x64, 0x19, 713e1051a39Sopenharmony_ci 0xa0, 0x58, 0xab, 0x4f, 0x6f, 0x74, 0x6b, 0xf4, 714e1051a39Sopenharmony_ci 0x0f, 0xc0, 0xc3, 0xb7, 0x80, 0xf2, 0x44, 0x45, 715e1051a39Sopenharmony_ci 0x2d, 0xa3, 0xeb, 0xf1, 0xc5, 0xd8, 0x2c, 0xde, 716e1051a39Sopenharmony_ci 0xa2, 0x41, 0x89, 0x97, 0x20, 0x0e, 0xf8, 0x2e, 717e1051a39Sopenharmony_ci 0x44, 0xae, 0x7e, 0x3f 718e1051a39Sopenharmony_ci}; 719e1051a39Sopenharmony_ci 720e1051a39Sopenharmony_cistatic const u8 T18[] = { 721e1051a39Sopenharmony_ci 0xa4, 0x4a, 0x82, 0x66, 0xee, 0x1c, 0x8e, 0xb0, 722e1051a39Sopenharmony_ci 0xc8, 0xb5, 0xd4, 0xcf, 0x5a, 0xe9, 0xf1, 0x9a 723e1051a39Sopenharmony_ci}; 724e1051a39Sopenharmony_ci 725e1051a39Sopenharmony_ci/* Test Case 19 */ 726e1051a39Sopenharmony_ci# define K19 K1 727e1051a39Sopenharmony_ci# define P19 P1 728e1051a39Sopenharmony_ci# define IV19 IV1 729e1051a39Sopenharmony_ci# define C19 C1 730e1051a39Sopenharmony_cistatic const u8 A19[] = { 731e1051a39Sopenharmony_ci 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 732e1051a39Sopenharmony_ci 0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 733e1051a39Sopenharmony_ci 0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda, 734e1051a39Sopenharmony_ci 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72, 735e1051a39Sopenharmony_ci 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, 736e1051a39Sopenharmony_ci 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 737e1051a39Sopenharmony_ci 0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 738e1051a39Sopenharmony_ci 0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55, 739e1051a39Sopenharmony_ci 0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07, 740e1051a39Sopenharmony_ci 0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d, 741e1051a39Sopenharmony_ci 0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9, 742e1051a39Sopenharmony_ci 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa, 743e1051a39Sopenharmony_ci 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d, 744e1051a39Sopenharmony_ci 0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38, 745e1051a39Sopenharmony_ci 0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a, 746e1051a39Sopenharmony_ci 0xbc, 0xc9, 0xf6, 0x62, 0x89, 0x80, 0x15, 0xad 747e1051a39Sopenharmony_ci}; 748e1051a39Sopenharmony_ci 749e1051a39Sopenharmony_cistatic const u8 T19[] = { 750e1051a39Sopenharmony_ci 0x5f, 0xea, 0x79, 0x3a, 0x2d, 0x6f, 0x97, 0x4d, 751e1051a39Sopenharmony_ci 0x37, 0xe6, 0x8e, 0x0c, 0xb8, 0xff, 0x94, 0x92 752e1051a39Sopenharmony_ci}; 753e1051a39Sopenharmony_ci 754e1051a39Sopenharmony_ci/* Test Case 20 */ 755e1051a39Sopenharmony_ci# define K20 K1 756e1051a39Sopenharmony_ci# define A20 A1 757e1051a39Sopenharmony_ci/* this results in 0xff in counter LSB */ 758e1051a39Sopenharmony_cistatic const u8 IV20[64] = { 0xff, 0xff, 0xff, 0xff }; 759e1051a39Sopenharmony_ci 760e1051a39Sopenharmony_cistatic const u8 P20[288]; 761e1051a39Sopenharmony_cistatic const u8 C20[] = { 762e1051a39Sopenharmony_ci 0x56, 0xb3, 0x37, 0x3c, 0xa9, 0xef, 0x6e, 0x4a, 763e1051a39Sopenharmony_ci 0x2b, 0x64, 0xfe, 0x1e, 0x9a, 0x17, 0xb6, 0x14, 764e1051a39Sopenharmony_ci 0x25, 0xf1, 0x0d, 0x47, 0xa7, 0x5a, 0x5f, 0xce, 765e1051a39Sopenharmony_ci 0x13, 0xef, 0xc6, 0xbc, 0x78, 0x4a, 0xf2, 0x4f, 766e1051a39Sopenharmony_ci 0x41, 0x41, 0xbd, 0xd4, 0x8c, 0xf7, 0xc7, 0x70, 767e1051a39Sopenharmony_ci 0x88, 0x7a, 0xfd, 0x57, 0x3c, 0xca, 0x54, 0x18, 768e1051a39Sopenharmony_ci 0xa9, 0xae, 0xff, 0xcd, 0x7c, 0x5c, 0xed, 0xdf, 769e1051a39Sopenharmony_ci 0xc6, 0xa7, 0x83, 0x97, 0xb9, 0xa8, 0x5b, 0x49, 770e1051a39Sopenharmony_ci 0x9d, 0xa5, 0x58, 0x25, 0x72, 0x67, 0xca, 0xab, 771e1051a39Sopenharmony_ci 0x2a, 0xd0, 0xb2, 0x3c, 0xa4, 0x76, 0xa5, 0x3c, 772e1051a39Sopenharmony_ci 0xb1, 0x7f, 0xb4, 0x1c, 0x4b, 0x8b, 0x47, 0x5c, 773e1051a39Sopenharmony_ci 0xb4, 0xf3, 0xf7, 0x16, 0x50, 0x94, 0xc2, 0x29, 774e1051a39Sopenharmony_ci 0xc9, 0xe8, 0xc4, 0xdc, 0x0a, 0x2a, 0x5f, 0xf1, 775e1051a39Sopenharmony_ci 0x90, 0x3e, 0x50, 0x15, 0x11, 0x22, 0x13, 0x76, 776e1051a39Sopenharmony_ci 0xa1, 0xcd, 0xb8, 0x36, 0x4c, 0x50, 0x61, 0xa2, 777e1051a39Sopenharmony_ci 0x0c, 0xae, 0x74, 0xbc, 0x4a, 0xcd, 0x76, 0xce, 778e1051a39Sopenharmony_ci 0xb0, 0xab, 0xc9, 0xfd, 0x32, 0x17, 0xef, 0x9f, 779e1051a39Sopenharmony_ci 0x8c, 0x90, 0xbe, 0x40, 0x2d, 0xdf, 0x6d, 0x86, 780e1051a39Sopenharmony_ci 0x97, 0xf4, 0xf8, 0x80, 0xdf, 0xf1, 0x5b, 0xfb, 781e1051a39Sopenharmony_ci 0x7a, 0x6b, 0x28, 0x24, 0x1e, 0xc8, 0xfe, 0x18, 782e1051a39Sopenharmony_ci 0x3c, 0x2d, 0x59, 0xe3, 0xf9, 0xdf, 0xff, 0x65, 783e1051a39Sopenharmony_ci 0x3c, 0x71, 0x26, 0xf0, 0xac, 0xb9, 0xe6, 0x42, 784e1051a39Sopenharmony_ci 0x11, 0xf4, 0x2b, 0xae, 0x12, 0xaf, 0x46, 0x2b, 785e1051a39Sopenharmony_ci 0x10, 0x70, 0xbe, 0xf1, 0xab, 0x5e, 0x36, 0x06, 786e1051a39Sopenharmony_ci 0x87, 0x2c, 0xa1, 0x0d, 0xee, 0x15, 0xb3, 0x24, 787e1051a39Sopenharmony_ci 0x9b, 0x1a, 0x1b, 0x95, 0x8f, 0x23, 0x13, 0x4c, 788e1051a39Sopenharmony_ci 0x4b, 0xcc, 0xb7, 0xd0, 0x32, 0x00, 0xbc, 0xe4, 789e1051a39Sopenharmony_ci 0x20, 0xa2, 0xf8, 0xeb, 0x66, 0xdc, 0xf3, 0x64, 790e1051a39Sopenharmony_ci 0x4d, 0x14, 0x23, 0xc1, 0xb5, 0x69, 0x90, 0x03, 791e1051a39Sopenharmony_ci 0xc1, 0x3e, 0xce, 0xf4, 0xbf, 0x38, 0xa3, 0xb6, 792e1051a39Sopenharmony_ci 0x0e, 0xed, 0xc3, 0x40, 0x33, 0xba, 0xc1, 0x90, 793e1051a39Sopenharmony_ci 0x27, 0x83, 0xdc, 0x6d, 0x89, 0xe2, 0xe7, 0x74, 794e1051a39Sopenharmony_ci 0x18, 0x8a, 0x43, 0x9c, 0x7e, 0xbc, 0xc0, 0x67, 795e1051a39Sopenharmony_ci 0x2d, 0xbd, 0xa4, 0xdd, 0xcf, 0xb2, 0x79, 0x46, 796e1051a39Sopenharmony_ci 0x13, 0xb0, 0xbe, 0x41, 0x31, 0x5e, 0xf7, 0x78, 797e1051a39Sopenharmony_ci 0x70, 0x8a, 0x70, 0xee, 0x7d, 0x75, 0x16, 0x5c 798e1051a39Sopenharmony_ci}; 799e1051a39Sopenharmony_ci 800e1051a39Sopenharmony_cistatic const u8 T20[] = { 801e1051a39Sopenharmony_ci 0x8b, 0x30, 0x7f, 0x6b, 0x33, 0x28, 0x6d, 0x0a, 802e1051a39Sopenharmony_ci 0xb0, 0x26, 0xa9, 0xed, 0x3f, 0xe1, 0xe8, 0x5f 803e1051a39Sopenharmony_ci}; 804e1051a39Sopenharmony_ci 805e1051a39Sopenharmony_ci#define GCM128_TEST_VECTOR(n) \ 806e1051a39Sopenharmony_ci { \ 807e1051a39Sopenharmony_ci {sizeof(K##n), K##n}, \ 808e1051a39Sopenharmony_ci {sizeof(IV##n), IV##n}, \ 809e1051a39Sopenharmony_ci {sizeof(A##n), A##n}, \ 810e1051a39Sopenharmony_ci {sizeof(P##n), P##n}, \ 811e1051a39Sopenharmony_ci {sizeof(C##n), C##n}, \ 812e1051a39Sopenharmony_ci {sizeof(T##n), T##n} \ 813e1051a39Sopenharmony_ci } 814e1051a39Sopenharmony_cistatic struct gcm128_data { 815e1051a39Sopenharmony_ci const SIZED_DATA K; 816e1051a39Sopenharmony_ci const SIZED_DATA IV; 817e1051a39Sopenharmony_ci const SIZED_DATA A; 818e1051a39Sopenharmony_ci const SIZED_DATA P; 819e1051a39Sopenharmony_ci const SIZED_DATA C; 820e1051a39Sopenharmony_ci const SIZED_DATA T; 821e1051a39Sopenharmony_ci} gcm128_vectors[] = { 822e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(1), 823e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(2), 824e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(3), 825e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(4), 826e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(5), 827e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(6), 828e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(7), 829e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(8), 830e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(9), 831e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(10), 832e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(11), 833e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(12), 834e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(13), 835e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(14), 836e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(15), 837e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(16), 838e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(17), 839e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(18), 840e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(19), 841e1051a39Sopenharmony_ci GCM128_TEST_VECTOR(20) 842e1051a39Sopenharmony_ci}; 843e1051a39Sopenharmony_ci 844e1051a39Sopenharmony_cistatic int test_gcm128(int idx) 845e1051a39Sopenharmony_ci{ 846e1051a39Sopenharmony_ci unsigned char out[512]; 847e1051a39Sopenharmony_ci SIZED_DATA K = gcm128_vectors[idx].K; 848e1051a39Sopenharmony_ci SIZED_DATA IV = gcm128_vectors[idx].IV; 849e1051a39Sopenharmony_ci SIZED_DATA A = gcm128_vectors[idx].A; 850e1051a39Sopenharmony_ci SIZED_DATA P = gcm128_vectors[idx].P; 851e1051a39Sopenharmony_ci SIZED_DATA C = gcm128_vectors[idx].C; 852e1051a39Sopenharmony_ci SIZED_DATA T = gcm128_vectors[idx].T; 853e1051a39Sopenharmony_ci GCM128_CONTEXT ctx; 854e1051a39Sopenharmony_ci AES_KEY key; 855e1051a39Sopenharmony_ci 856e1051a39Sopenharmony_ci /* Size 1 inputs are special-cased to signal NULL. */ 857e1051a39Sopenharmony_ci if (A.size == 1) 858e1051a39Sopenharmony_ci A.data = NULL; 859e1051a39Sopenharmony_ci if (P.size == 1) 860e1051a39Sopenharmony_ci P.data = NULL; 861e1051a39Sopenharmony_ci if (C.size == 1) 862e1051a39Sopenharmony_ci C.data = NULL; 863e1051a39Sopenharmony_ci 864e1051a39Sopenharmony_ci AES_set_encrypt_key(K.data, K.size * 8, &key); 865e1051a39Sopenharmony_ci 866e1051a39Sopenharmony_ci CRYPTO_gcm128_init(&ctx, &key, (block128_f)AES_encrypt); 867e1051a39Sopenharmony_ci CRYPTO_gcm128_setiv(&ctx, IV.data, IV.size); 868e1051a39Sopenharmony_ci memset(out, 0, P.size); 869e1051a39Sopenharmony_ci if (A.data != NULL) 870e1051a39Sopenharmony_ci CRYPTO_gcm128_aad(&ctx, A.data, A.size); 871e1051a39Sopenharmony_ci if (P.data != NULL) 872e1051a39Sopenharmony_ci if (!TEST_int_ge(CRYPTO_gcm128_encrypt( &ctx, P.data, out, P.size), 0)) 873e1051a39Sopenharmony_ci return 0; 874e1051a39Sopenharmony_ci if (!TEST_false(CRYPTO_gcm128_finish(&ctx, T.data, 16)) 875e1051a39Sopenharmony_ci || (C.data != NULL 876e1051a39Sopenharmony_ci && !TEST_mem_eq(out, P.size, C.data, P.size))) 877e1051a39Sopenharmony_ci return 0; 878e1051a39Sopenharmony_ci 879e1051a39Sopenharmony_ci CRYPTO_gcm128_setiv(&ctx, IV.data, IV.size); 880e1051a39Sopenharmony_ci memset(out, 0, P.size); 881e1051a39Sopenharmony_ci if (A.data != NULL) 882e1051a39Sopenharmony_ci CRYPTO_gcm128_aad(&ctx, A.data, A.size); 883e1051a39Sopenharmony_ci if (C.data != NULL) 884e1051a39Sopenharmony_ci CRYPTO_gcm128_decrypt(&ctx, C.data, out, P.size); 885e1051a39Sopenharmony_ci if (!TEST_false(CRYPTO_gcm128_finish(&ctx, T.data, 16)) 886e1051a39Sopenharmony_ci || (P.data != NULL 887e1051a39Sopenharmony_ci && !TEST_mem_eq(out, P.size, P.data, P.size))) 888e1051a39Sopenharmony_ci return 0; 889e1051a39Sopenharmony_ci 890e1051a39Sopenharmony_ci return 1; 891e1051a39Sopenharmony_ci} 892e1051a39Sopenharmony_ci 893e1051a39Sopenharmony_ciint setup_tests(void) 894e1051a39Sopenharmony_ci{ 895e1051a39Sopenharmony_ci ADD_ALL_TESTS(test_aes_cts128, OSSL_NELEM(aes_cts128_vectors)); 896e1051a39Sopenharmony_ci ADD_ALL_TESTS(test_aes_cts128_nist, OSSL_NELEM(aes_cts128_vectors)); 897e1051a39Sopenharmony_ci ADD_ALL_TESTS(test_gcm128, OSSL_NELEM(gcm128_vectors)); 898e1051a39Sopenharmony_ci return 1; 899e1051a39Sopenharmony_ci} 900