diff --git a/aes/aarch64/cbc_dec_aes.S b/aes/aarch64/cbc_dec_aes.S index 711ae784..9eb562f7 100644 --- a/aes/aarch64/cbc_dec_aes.S +++ b/aes/aarch64/cbc_dec_aes.S @@ -451,7 +451,7 @@ void _aes_cbc_dec_128( void *in, //!< Input cipher text uint8_t *IV, //!< Must be 16 bytes aligned to a 16 byte boundary - uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key rounds or dec_keys of cbc_key_data + uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key rounds or dec_keys of isal_cbc_key_data void *out, //!< Output plain text uint64_t len_bytes //!< Must be a multiple of 16 bytes ); diff --git a/aes/aarch64/cbc_enc_aes.S b/aes/aarch64/cbc_enc_aes.S index e30b1c1a..1a37222d 100644 --- a/aes/aarch64/cbc_enc_aes.S +++ b/aes/aarch64/cbc_enc_aes.S @@ -79,7 +79,7 @@ void _aes_cbc_dec_128( void *in, //!< Input cipher text uint8_t *IV, //!< Must be 16 bytes aligned to a 16 byte boundary - uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key rounds or dec_keys of cbc_key_data + uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key rounds or dec_keys of isal_cbc_key_data void *out, //!< Output plain text uint64_t len_bytes //!< Must be a multiple of 16 bytes ); diff --git a/aes/aes_param_test.c b/aes/aes_param_test.c index ec2fc2f6..8b3feb77 100644 --- a/aes/aes_param_test.c +++ b/aes/aes_param_test.c @@ -81,9 +81,9 @@ struct test_func { static int test_aes_keyexp_api(aes_keyexp_func aes_keyexp_func_ptr, const char *name) { - uint8_t key[CBC_ROUND_KEY_LEN] = { 0 }; - uint8_t enc_keys[CBC_MAX_KEYS_SIZE] = { 0 }; - uint8_t dec_keys[CBC_MAX_KEYS_SIZE] = { 0 }; + uint8_t key[ISAL_CBC_ROUND_KEY_LEN] = { 0 }; + uint8_t enc_keys[ISAL_CBC_MAX_KEYS_SIZE] = { 0 }; + uint8_t dec_keys[ISAL_CBC_MAX_KEYS_SIZE] = { 0 }; // test null key CHECK_RETURN(aes_keyexp_func_ptr(NULL, enc_keys, dec_keys), ISAL_CRYPTO_ERR_NULL_KEY, name); @@ -103,7 +103,7 @@ test_aes_keyexp_api(aes_keyexp_func aes_keyexp_func_ptr, const char *name) static int test_aes_cbc_api(aes_cbc_func aes_cbc_func_ptr, const char *name) { - uint8_t exp_keys[CBC_MAX_KEYS_SIZE] = { 0 }; + uint8_t exp_keys[ISAL_CBC_MAX_KEYS_SIZE] = { 0 }; uint8_t buf[16] = { 0 }; uint8_t iv[16] = { 0 }; @@ -132,9 +132,9 @@ static int test_aes_xts_api(aes_xts_func aes_xts_func_ptr, const char *name, const int expanded_key) { uint8_t key1[32] = { 0 }; - uint8_t exp_keys1[CBC_MAX_KEYS_SIZE] = { 0 }; + uint8_t exp_keys1[ISAL_CBC_MAX_KEYS_SIZE] = { 0 }; uint8_t key2[32]; - uint8_t exp_keys2[CBC_MAX_KEYS_SIZE]; + uint8_t exp_keys2[ISAL_CBC_MAX_KEYS_SIZE]; uint8_t buf[16] = { 0 }; uint8_t tweak[16] = { 0 }; diff --git a/aes/cbc_ossl_perf.c b/aes/cbc_ossl_perf.c index a696db2a..d58452ea 100644 --- a/aes/cbc_ossl_perf.c +++ b/aes/cbc_ossl_perf.c @@ -65,7 +65,7 @@ static unsigned char *ciphertext = NULL; static unsigned char *ossl_plaintext = NULL; static unsigned char *ossl_ciphertext = NULL; -static uint8_t test_key[CBC_256_BITS]; +static uint8_t test_key[ISAL_CBC_256_BITS]; void mk_rand_data(uint8_t *data, uint32_t size) @@ -83,9 +83,9 @@ aes_128_perf(uint8_t *key) /* Initialize our cipher context, which can use same input vectors */ uint8_t *iv = NULL; - struct cbc_key_data *key_data = NULL; + struct isal_cbc_key_data *key_data = NULL; - ret = posix_memalign((void **) &iv, 16, (CBC_IV_DATA_LEN)); + ret = posix_memalign((void **) &iv, 16, (ISAL_CBC_IV_DATA_LEN)); if (ret) { printf("alloc error: Fail"); return 1; @@ -97,7 +97,7 @@ aes_128_perf(uint8_t *key) goto exit; } - memcpy(iv, ic, CBC_IV_DATA_LEN); + memcpy(iv, ic, ISAL_CBC_IV_DATA_LEN); isal_aes_keyexp_128(key, key_data->enc_keys, key_data->dec_keys); isal_aes_cbc_enc_128(plaintext, iv, key_data->enc_keys, ciphertext, TEST_LEN); @@ -169,9 +169,9 @@ aes_192_perf(uint8_t *key) { int i, ret; uint8_t *iv = NULL; - struct cbc_key_data *key_data = NULL; + struct isal_cbc_key_data *key_data = NULL; - ret = posix_memalign((void **) &iv, 16, (CBC_IV_DATA_LEN)); + ret = posix_memalign((void **) &iv, 16, (ISAL_CBC_IV_DATA_LEN)); if (ret) { printf("alloc error: Fail"); return 1; @@ -183,7 +183,7 @@ aes_192_perf(uint8_t *key) goto exit; } - memcpy(iv, ic, CBC_IV_DATA_LEN); + memcpy(iv, ic, ISAL_CBC_IV_DATA_LEN); isal_aes_keyexp_192(key, key_data->enc_keys, key_data->dec_keys); isal_aes_cbc_enc_192(plaintext, iv, key_data->enc_keys, ciphertext, TEST_LEN); openssl_aes_192_cbc_enc(key, iv, TEST_LEN, plaintext, ossl_ciphertext); @@ -254,9 +254,9 @@ aes_256_perf(uint8_t *key) { int i, ret; uint8_t *iv = NULL; - struct cbc_key_data *key_data = NULL; + struct isal_cbc_key_data *key_data = NULL; - ret = posix_memalign((void **) &iv, 16, (CBC_IV_DATA_LEN)); + ret = posix_memalign((void **) &iv, 16, (ISAL_CBC_IV_DATA_LEN)); if (ret) { printf("alloc error: Fail"); return 1; @@ -269,7 +269,7 @@ aes_256_perf(uint8_t *key) } isal_aes_keyexp_256(key, key_data->enc_keys, key_data->dec_keys); - memcpy(iv, ic, CBC_IV_DATA_LEN); + memcpy(iv, ic, ISAL_CBC_IV_DATA_LEN); isal_aes_cbc_enc_256(plaintext, iv, key_data->enc_keys, ciphertext, TEST_LEN); openssl_aes_256_cbc_enc(key, iv, TEST_LEN, plaintext, ossl_ciphertext); diff --git a/aes/cbc_pre.c b/aes/cbc_pre.c index b5f847de..8fcf439f 100644 --- a/aes/cbc_pre.c +++ b/aes/cbc_pre.c @@ -32,13 +32,13 @@ #include "aes_keyexp_internal.h" int -aes_cbc_precomp(uint8_t *key, int key_size, struct cbc_key_data *keys_blk) +aes_cbc_precomp(uint8_t *key, int key_size, struct isal_cbc_key_data *keys_blk) { - if (CBC_128_BITS == key_size) { + if (ISAL_CBC_128_BITS == key_size) { _aes_keyexp_128(key, keys_blk->enc_keys, keys_blk->dec_keys); - } else if (CBC_192_BITS == key_size) { + } else if (ISAL_CBC_192_BITS == key_size) { _aes_keyexp_192(key, keys_blk->enc_keys, keys_blk->dec_keys); - } else if (CBC_256_BITS == key_size) { + } else if (ISAL_CBC_256_BITS == key_size) { _aes_keyexp_256(key, keys_blk->enc_keys, keys_blk->dec_keys); } else { // Invalid key length diff --git a/aes/cbc_std_vectors.h b/aes/cbc_std_vectors.h index b8e61d22..31eb2b11 100644 --- a/aes/cbc_std_vectors.h +++ b/aes/cbc_std_vectors.h @@ -33,16 +33,16 @@ // struct to hold pointers to the cbc data vectors struct cbc_vector { - uint8_t *K; // AES Key - cbc_key_size K_LEN; // length of key in bits - uint8_t *IV; // initial value used by GCM - uint64_t P_LEN; // length of our plaintext - uint8_t *P; // Plain text + uint8_t *K; // AES Key + isal_cbc_key_size K_LEN; // length of key in bits + uint8_t *IV; // initial value used by GCM + uint64_t P_LEN; // length of our plaintext + uint8_t *P; // Plain text // outputs of encryption uint8_t *EXP_C; // same length as P // used in vector checks, not populated in std vector array uint8_t *C; - struct cbc_key_data *KEYS; + struct isal_cbc_key_data *KEYS; }; /////////////////////////////////////////// diff --git a/aes/cbc_std_vectors_random_test.c b/aes/cbc_std_vectors_random_test.c index f882434a..9cd0be77 100644 --- a/aes/cbc_std_vectors_random_test.c +++ b/aes/cbc_std_vectors_random_test.c @@ -56,7 +56,8 @@ #define MAX_UNALINED (16) #endif -static cbc_key_size const Ksize[] = { CBC_128_BITS, CBC_192_BITS, CBC_256_BITS }; +static isal_cbc_key_size const Ksize[] = { ISAL_CBC_128_BITS, ISAL_CBC_192_BITS, + ISAL_CBC_256_BITS }; typedef void (*aes_cbc_generic)(uint8_t *in, uint8_t *IV, uint8_t *keys, uint8_t *out, uint64_t len_bytes); @@ -64,17 +65,17 @@ typedef void (*aes_cbc_generic)(uint8_t *in, uint8_t *IV, uint8_t *keys, uint8_t int OpenSslEnc(uint8_t k_len, uint8_t *key, uint8_t *in, uint8_t *iv, uint8_t *out, uint64_t len_bytes) { - if (CBC_128_BITS == k_len) { + if (ISAL_CBC_128_BITS == k_len) { #ifdef CBC_VECTORS_EXTRA_VERBOSE printf(" OpenSSL128 "); #endif openssl_aes_128_cbc_enc(key, (uint8_t *) iv, len_bytes, in, out); - } else if (CBC_192_BITS == k_len) { + } else if (ISAL_CBC_192_BITS == k_len) { #ifdef CBC_VECTORS_EXTRA_VERBOSE printf(" OpenSSL192 "); #endif openssl_aes_192_cbc_enc(key, (uint8_t *) iv, len_bytes, in, out); - } else if (CBC_256_BITS == k_len) { + } else if (ISAL_CBC_256_BITS == k_len) { #ifdef CBC_VECTORS_EXTRA_VERBOSE printf(" OpenSSL256 "); fflush(0); @@ -90,17 +91,17 @@ OpenSslEnc(uint8_t k_len, uint8_t *key, uint8_t *in, uint8_t *iv, uint8_t *out, int OpenSslDec(uint8_t k_len, uint8_t *key, uint8_t *in, uint8_t *iv, uint8_t *out, uint64_t len_bytes) { - if (CBC_128_BITS == k_len) { + if (ISAL_CBC_128_BITS == k_len) { #ifdef CBC_VECTORS_EXTRA_VERBOSE printf(" OpenSSL128 "); #endif openssl_aes_128_cbc_dec(key, (uint8_t *) iv, len_bytes, in, out); - } else if (CBC_192_BITS == k_len) { + } else if (ISAL_CBC_192_BITS == k_len) { #ifdef CBC_VECTORS_EXTRA_VERBOSE printf(" OpenSSL192 "); #endif openssl_aes_192_cbc_dec(key, (uint8_t *) iv, len_bytes, in, out); - } else if (CBC_256_BITS == k_len) { + } else if (ISAL_CBC_256_BITS == k_len) { #ifdef CBC_VECTORS_EXTRA_VERBOSE printf(" OpenSSL256 "); #endif @@ -165,21 +166,21 @@ check_vector(struct cbc_vector *vector) printf("."); #endif - if (CBC_128_BITS == vector->K_LEN) { + if (ISAL_CBC_128_BITS == vector->K_LEN) { enc = (aes_cbc_generic) &isal_aes_cbc_enc_128; dec = (aes_cbc_generic) &isal_aes_cbc_dec_128; isal_aes_keyexp_128(vector->K, vector->KEYS->enc_keys, vector->KEYS->dec_keys); #ifdef CBC_VECTORS_EXTRA_VERBOSE printf(" CBC128 "); #endif - } else if (CBC_192_BITS == vector->K_LEN) { + } else if (ISAL_CBC_192_BITS == vector->K_LEN) { enc = (aes_cbc_generic) &isal_aes_cbc_enc_192; dec = (aes_cbc_generic) &isal_aes_cbc_dec_192; isal_aes_keyexp_192(vector->K, vector->KEYS->enc_keys, vector->KEYS->dec_keys); #ifdef CBC_VECTORS_EXTRA_VERBOSE printf(" CBC192 "); #endif - } else if (CBC_256_BITS == vector->K_LEN) { + } else if (ISAL_CBC_256_BITS == vector->K_LEN) { enc = (aes_cbc_generic) &isal_aes_cbc_enc_256; dec = (aes_cbc_generic) &isal_aes_cbc_dec_256; isal_aes_keyexp_256(vector->K, vector->KEYS->enc_keys, vector->KEYS->dec_keys); @@ -259,7 +260,7 @@ test_std_combinations(void) #ifdef CBC_VECTORS_VERBOSE printf("\n"); #endif - ret = posix_memalign((void **) &iv, 16, (CBC_IV_DATA_LEN)); + ret = posix_memalign((void **) &iv, 16, (ISAL_CBC_IV_DATA_LEN)); if ((0 != ret) || (NULL == iv)) return 1; @@ -273,7 +274,7 @@ test_std_combinations(void) } // IV data must be aligned to 16 byte boundary so move data in aligned buffer and // change out the pointer - memcpy(iv, vect.IV, CBC_IV_DATA_LEN); + memcpy(iv, vect.IV, ISAL_CBC_IV_DATA_LEN); vect.IV = iv; vect.C = NULL; vect.C = malloc(vect.P_LEN); @@ -317,7 +318,7 @@ test_random_combinations(void) fflush(0); #endif test.IV = NULL; - ret = posix_memalign((void **) &test.IV, 16, (CBC_IV_DATA_LEN)); + ret = posix_memalign((void **) &test.IV, 16, (ISAL_CBC_IV_DATA_LEN)); if ((0 != ret) || (NULL == test.IV)) return 1; test.KEYS = NULL; @@ -362,7 +363,7 @@ test_random_combinations(void) mk_rand_data(test.P, test.P_LEN); mk_rand_data(test.K, test.K_LEN); - mk_rand_data(test.IV, CBC_IV_DATA_LEN); + mk_rand_data(test.IV, ISAL_CBC_IV_DATA_LEN); #ifdef CBC_VECTORS_EXTRA_VERBOSE printf(" Offset:0x%x ", offset); @@ -428,18 +429,19 @@ test_efence_combinations(void) test.P = P + PAGE_LEN - test.P_LEN - offset; test.C = C + PAGE_LEN - test.P_LEN - offset; test.K = K + PAGE_LEN - test.K_LEN - offset; - test.IV = IV + PAGE_LEN - CBC_IV_DATA_LEN - offset; + test.IV = IV + PAGE_LEN - ISAL_CBC_IV_DATA_LEN - offset; test.IV = test.IV - ((uint64_t) test.IV & 0xff); // align to 16 byte boundary - test.KEYS = (struct cbc_key_data *) (key_data + PAGE_LEN - - sizeof(*test.KEYS) - offset); - test.KEYS = (struct cbc_key_data *) ((uint8_t *) test.KEYS - - ((uint64_t) test.KEYS & - 0xff)); // align to 16 byte boundary + test.KEYS = (struct isal_cbc_key_data *) (key_data + PAGE_LEN - + sizeof(*test.KEYS) - offset); + test.KEYS = + (struct isal_cbc_key_data *) ((uint8_t *) test.KEYS - + ((uint64_t) test.KEYS & + 0xff)); // align to 16 byte boundary mk_rand_data(test.P, test.P_LEN); mk_rand_data(test.K, test.K_LEN); - mk_rand_data(test.IV, CBC_IV_DATA_LEN); + mk_rand_data(test.IV, ISAL_CBC_IV_DATA_LEN); #ifdef CBC_VECTORS_EXTRA_VERBOSE printf(" Offset:0x%x ", offset); #endif diff --git a/aes/cbc_std_vectors_test.c b/aes/cbc_std_vectors_test.c index f8f5eb65..59acb166 100644 --- a/aes/cbc_std_vectors_test.c +++ b/aes/cbc_std_vectors_test.c @@ -81,19 +81,19 @@ check_vector(struct cbc_vector *vector) printf("."); switch (vector->K_LEN) { - case CBC_128_BITS: + case ISAL_CBC_128_BITS: enc = (aes_cbc_generic) &isal_aes_cbc_enc_128; dec = (aes_cbc_generic) &isal_aes_cbc_dec_128; isal_aes_keyexp_128(vector->K, vector->KEYS->enc_keys, vector->KEYS->dec_keys); DEBUG_PRINT((" CBC128 ")); break; - case CBC_192_BITS: + case ISAL_CBC_192_BITS: enc = (aes_cbc_generic) &isal_aes_cbc_enc_192; dec = (aes_cbc_generic) &isal_aes_cbc_dec_192; isal_aes_keyexp_192(vector->K, vector->KEYS->enc_keys, vector->KEYS->dec_keys); DEBUG_PRINT((" CBC192 ")); break; - case CBC_256_BITS: + case ISAL_CBC_256_BITS: enc = (aes_cbc_generic) &isal_aes_cbc_enc_256; dec = (aes_cbc_generic) &isal_aes_cbc_dec_256; isal_aes_keyexp_256(vector->K, vector->KEYS->enc_keys, vector->KEYS->dec_keys); @@ -162,7 +162,7 @@ test_std_combinations(void) printf("AES CBC standard test vectors: "); - ret = posix_memalign((void **) &iv, 16, (CBC_IV_DATA_LEN)); + ret = posix_memalign((void **) &iv, 16, (ISAL_CBC_IV_DATA_LEN)); if ((0 != ret) || (NULL == iv)) return 1; @@ -176,7 +176,7 @@ test_std_combinations(void) } // IV data must be aligned to 16 byte boundary so move data in // aligned buffer and change out the pointer - memcpy(iv, vect.IV, CBC_IV_DATA_LEN); + memcpy(iv, vect.IV, ISAL_CBC_IV_DATA_LEN); vect.IV = iv; vect.C = malloc(vect.P_LEN); if (NULL == vect.C) { diff --git a/examples/saturation_test/aes_thread.c b/examples/saturation_test/aes_thread.c index 67d22057..49c631e9 100644 --- a/examples/saturation_test/aes_thread.c +++ b/examples/saturation_test/aes_thread.c @@ -120,8 +120,8 @@ mk_rand_data(uint8_t *data, uint32_t size) struct cbc_context { struct aes_context base; uint8_t *iv; - uint8_t key[CBC_256_BITS]; - struct cbc_key_data *key_data; + uint8_t key[ISAL_CBC_256_BITS]; + struct isal_cbc_key_data *key_data; }; static int @@ -130,14 +130,14 @@ cbc_dec_pre(struct aes_context *p) struct cbc_context *pCtx = (struct cbc_context *) p; int ret; - ret = posix_memalign((void **) &pCtx->iv, 16, (CBC_IV_DATA_LEN)); + ret = posix_memalign((void **) &pCtx->iv, 16, (ISAL_CBC_IV_DATA_LEN)); ret |= posix_memalign((void **) &pCtx->key_data, 16, (sizeof(*pCtx->key_data))); if ((0 != ret) || (NULL == pCtx->iv) || (NULL == pCtx->key_data)) return 1; mk_rand_data(pCtx->key, sizeof(pCtx->key)); - memcpy(pCtx->iv, ic, CBC_IV_DATA_LEN); + memcpy(pCtx->iv, ic, ISAL_CBC_IV_DATA_LEN); switch (pCtx->base.bits) { case 128: isal_aes_keyexp_128(pCtx->key, pCtx->key_data->enc_keys, pCtx->key_data->dec_keys); diff --git a/fips/aes_self_tests.c b/fips/aes_self_tests.c index 62650070..41935c7b 100644 --- a/fips/aes_self_tests.c +++ b/fips/aes_self_tests.c @@ -351,17 +351,17 @@ cbc_self_test_vector(const struct self_test_cbc_vector *v) memcpy(scratch, v->plaintext, v->plaintext_size); switch (v->cipher_key_size) { - case CBC_128_BITS: + case ISAL_CBC_128_BITS: _aes_keyexp_128(v->cipher_key, aes_keys.expkey_enc, aes_keys.expkey_dec); _aes_cbc_enc_128(scratch, v->cipher_iv, aes_keys.expkey_enc, scratch, v->plaintext_size); break; - case CBC_192_BITS: + case ISAL_CBC_192_BITS: _aes_keyexp_192(v->cipher_key, aes_keys.expkey_enc, aes_keys.expkey_dec); _aes_cbc_enc_192(scratch, v->cipher_iv, aes_keys.expkey_enc, scratch, v->plaintext_size); break; - case CBC_256_BITS: + case ISAL_CBC_256_BITS: _aes_keyexp_256(v->cipher_key, aes_keys.expkey_enc, aes_keys.expkey_dec); _aes_cbc_enc_256(scratch, v->cipher_iv, aes_keys.expkey_enc, scratch, v->plaintext_size); @@ -380,15 +380,15 @@ cbc_self_test_vector(const struct self_test_cbc_vector *v) memcpy(scratch, v->ciphertext, v->plaintext_size); switch (v->cipher_key_size) { - case CBC_128_BITS: + case ISAL_CBC_128_BITS: _aes_cbc_dec_128(scratch, v->cipher_iv, aes_keys.expkey_dec, scratch, v->plaintext_size); break; - case CBC_192_BITS: + case ISAL_CBC_192_BITS: _aes_cbc_dec_192(scratch, v->cipher_iv, aes_keys.expkey_dec, scratch, v->plaintext_size); break; - case CBC_256_BITS: + case ISAL_CBC_256_BITS: _aes_cbc_dec_256(scratch, v->cipher_iv, aes_keys.expkey_dec, scratch, v->plaintext_size); break; diff --git a/include/aes_cbc.h b/include/aes_cbc.h index 33e303ec..ca3278fc 100644 --- a/include/aes_cbc.h +++ b/include/aes_cbc.h @@ -44,21 +44,48 @@ extern "C" { #endif -typedef enum cbc_key_size { CBC_128_BITS = 16, CBC_192_BITS = 24, CBC_256_BITS = 32 } cbc_key_size; -#define CBC_ROUND_KEY_LEN (16) -#define CBC_128_KEY_ROUNDS (10 + 1) /*expanded key holds 10 key rounds plus original key*/ -#define CBC_192_KEY_ROUNDS (12 + 1) /*expanded key holds 12 key rounds plus original key*/ -#define CBC_256_KEY_ROUNDS (14 + 1) /*expanded key holds 14 key rounds plus original key*/ -#define CBC_MAX_KEYS_SIZE (CBC_ROUND_KEY_LEN * CBC_256_KEY_ROUNDS) +/* + * Define enums from API v2.24, so applications that were using this version + * will still be compiled successfully. + * This list does not need to be extended for new definitions. + */ +#ifndef NO_COMPAT_ISAL_CRYPTO_API_2_24 +/***** Previous hash constants and typedefs *****/ +#define CBC_128_BITS ISAL_CBC_128_BITS +#define CBC_192_BITS ISAL_CBC_192_BITS +#define CBC_256_BITS ISAL_CBC_256_BITS + +#define CBC_ROUND_KEY_LEN ISAL_CBC_ROUND_KEY_LEN +#define CBC_128_KEY_ROUNDS ISAL_CBC_128_KEY_ROUNDS +#define CBC_192_KEY_ROUNDS ISAL_CBC_192_KEY_ROUNDS +#define CBC_256_KEY_ROUNDS ISAL_CBC_256_KEY_ROUNDS +#define CBC_MAX_KEYS_SIZE ISAL_CBC_MAX_KEYS_SIZE + +#define CBC_IV_DATA_LEN ISAL_CBC_IV_DATA_LEN + +#define cbc_key_data isal_cbc_key_data +#define cbc_key_size isal_cbc_key_size +#endif /* !NO_COMPAT_ISAL_CRYPTO_API_2_24 */ + +typedef enum isal_cbc_key_size { + ISAL_CBC_128_BITS = 16, + ISAL_CBC_192_BITS = 24, + ISAL_CBC_256_BITS = 32 +} isal_cbc_key_size; +#define ISAL_CBC_ROUND_KEY_LEN (16) +#define ISAL_CBC_128_KEY_ROUNDS (10 + 1) /*expanded key holds 10 key rounds plus original key*/ +#define ISAL_CBC_192_KEY_ROUNDS (12 + 1) /*expanded key holds 12 key rounds plus original key*/ +#define ISAL_CBC_256_KEY_ROUNDS (14 + 1) /*expanded key holds 14 key rounds plus original key*/ +#define ISAL_CBC_MAX_KEYS_SIZE (ISAL_CBC_ROUND_KEY_LEN * ISAL_CBC_256_KEY_ROUNDS) -#define CBC_IV_DATA_LEN (16) +#define ISAL_CBC_IV_DATA_LEN (16) /** @brief holds intermediate key data used in encryption/decryption * */ -struct cbc_key_data { // must be 16 byte aligned - uint8_t enc_keys[CBC_MAX_KEYS_SIZE]; - uint8_t dec_keys[CBC_MAX_KEYS_SIZE]; +struct isal_cbc_key_data { // must be 16 byte aligned + uint8_t enc_keys[ISAL_CBC_MAX_KEYS_SIZE]; + uint8_t dec_keys[ISAL_CBC_MAX_KEYS_SIZE]; }; /** @brief CBC-AES key pre-computation done once for a key @@ -73,7 +100,7 @@ struct cbc_key_data { // must be 16 byte aligned ISAL_DEPRECATED( "Please use isal_aes_keyexp_128(), isal_aes_keyexp_192() or isal_aes_keyexp_256() instead") int -aes_cbc_precomp(uint8_t *key, int key_size, struct cbc_key_data *keys_blk); +aes_cbc_precomp(uint8_t *key, int key_size, struct isal_cbc_key_data *keys_blk); /** @brief CBC-AES 128 bit key Decryption * @@ -91,7 +118,7 @@ void aes_cbc_dec_128(void *in, //!< Input cipher text uint8_t *IV, //!< Must be 16 bytes aligned to a 16 byte boundary uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key - //!< rounds or dec_keys of cbc_key_data + //!< rounds or dec_keys of isal_cbc_key_data void *out, //!< Output plain text uint64_t len_bytes //!< Must be a multiple of 16 bytes ); @@ -107,7 +134,7 @@ void aes_cbc_dec_192(void *in, //!< Input cipher text uint8_t *IV, //!< Must be 16 bytes aligned to a 16 byte boundary uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key - //!< rounds or dec_keys of cbc_key_data + //!< rounds or dec_keys of isal_cbc_key_data void *out, //!< Output plain text uint64_t len_bytes //!< Must be a multiple of 16 bytes ); @@ -123,7 +150,7 @@ void aes_cbc_dec_256(void *in, //!< Input cipher text uint8_t *IV, //!< Must be 16 bytes aligned to a 16 byte boundary uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key - //!< rounds or dec_keys of cbc_key_data + //!< rounds or dec_keys of isal_cbc_key_data void *out, //!< Output plain text uint64_t len_bytes //!< Must be a multiple of 16 bytes ); @@ -144,7 +171,7 @@ int aes_cbc_enc_128(void *in, //!< Input plain text uint8_t *IV, //!< Must be 16 bytes aligned to a 16 byte boundary uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key - //!< rounds or enc_keys of cbc_key_data + //!< rounds or enc_keys of isal_cbc_key_data void *out, //!< Output cipher text uint64_t len_bytes //!< Must be a multiple of 16 bytes ); @@ -159,7 +186,7 @@ int aes_cbc_enc_192(void *in, //!< Input plain text uint8_t *IV, //!< Must be 16 bytes aligned to a 16 byte boundary uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key - //!< rounds or enc_keys of cbc_key_data + //!< rounds or enc_keys of isal_cbc_key_data void *out, //!< Output cipher text uint64_t len_bytes //!< Must be a multiple of 16 bytes ); @@ -175,7 +202,7 @@ int aes_cbc_enc_256(void *in, //!< Input plain text uint8_t *IV, //!< Must be 16 bytes aligned to a 16 byte boundary uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key - //!< rounds or enc_keys of cbc_key_data + //!< rounds or enc_keys of isal_cbc_key_data void *out, //!< Output cipher text uint64_t len_bytes //!< Must be a multiple of 16 bytes ); diff --git a/include/aes_cbc_internal.h b/include/aes_cbc_internal.h index 5adac11f..51c6cd09 100644 --- a/include/aes_cbc_internal.h +++ b/include/aes_cbc_internal.h @@ -56,7 +56,7 @@ void _aes_cbc_dec_128(void *in, //!< Input cipher text uint8_t *IV, //!< Must be 16 bytes aligned to a 16 byte boundary uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key - //!< rounds or dec_keys of cbc_key_data + //!< rounds or dec_keys of isal_cbc_key_data void *out, //!< Output plain text uint64_t len_bytes //!< Must be a multiple of 16 bytes ); @@ -70,7 +70,7 @@ void _aes_cbc_dec_192(void *in, //!< Input cipher text uint8_t *IV, //!< Must be 16 bytes aligned to a 16 byte boundary uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key - //!< rounds or dec_keys of cbc_key_data + //!< rounds or dec_keys of isal_cbc_key_data void *out, //!< Output plain text uint64_t len_bytes //!< Must be a multiple of 16 bytes ); @@ -84,7 +84,7 @@ void _aes_cbc_dec_256(void *in, //!< Input cipher text uint8_t *IV, //!< Must be 16 bytes aligned to a 16 byte boundary uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key - //!< rounds or dec_keys of cbc_key_data + //!< rounds or dec_keys of isal_cbc_key_data void *out, //!< Output plain text uint64_t len_bytes //!< Must be a multiple of 16 bytes ); @@ -103,7 +103,7 @@ int _aes_cbc_enc_128(void *in, //!< Input plain text uint8_t *IV, //!< Must be 16 bytes aligned to a 16 byte boundary uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key - //!< rounds or enc_keys of cbc_key_data + //!< rounds or enc_keys of isal_cbc_key_data void *out, //!< Output cipher text uint64_t len_bytes //!< Must be a multiple of 16 bytes ); @@ -116,7 +116,7 @@ int _aes_cbc_enc_192(void *in, //!< Input plain text uint8_t *IV, //!< Must be 16 bytes aligned to a 16 byte boundary uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key - //!< rounds or enc_keys of cbc_key_data + //!< rounds or enc_keys of isal_cbc_key_data void *out, //!< Output cipher text uint64_t len_bytes //!< Must be a multiple of 16 bytes ); @@ -130,7 +130,7 @@ int _aes_cbc_enc_256(void *in, //!< Input plain text uint8_t *IV, //!< Must be 16 bytes aligned to a 16 byte boundary uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key - //!< rounds or enc_keys of cbc_key_data + //!< rounds or enc_keys of isal_cbc_key_data void *out, //!< Output cipher text uint64_t len_bytes //!< Must be a multiple of 16 bytes ); diff --git a/tests/acvp/acvp_app_isal_cbc.c b/tests/acvp/acvp_app_isal_cbc.c index 165bf992..39d0c9f0 100644 --- a/tests/acvp/acvp_app_isal_cbc.c +++ b/tests/acvp/acvp_app_isal_cbc.c @@ -41,7 +41,7 @@ aes_cbc_handler(ACVP_TEST_CASE *test_case) { ACVP_RESULT ret = ACVP_SUCCESS; ACVP_SYM_CIPHER_TC *tc; - uint8_t expkey_enc[CBC_MAX_KEYS_SIZE], expkey_dec[CBC_MAX_KEYS_SIZE]; + uint8_t expkey_enc[ISAL_CBC_MAX_KEYS_SIZE], expkey_dec[ISAL_CBC_MAX_KEYS_SIZE]; static uint8_t next_iv[16]; void *iv = NULL;