Skip to content

Commit e4a8493

Browse files
mdcornutkanteck
authored andcommitted
aes: [CBC] add ISAL_ prefix to definitions
Signed-off-by: Marcel Cornu <[email protected]>
1 parent 42a5133 commit e4a8493

13 files changed

+117
-88
lines changed

aes/aarch64/cbc_dec_aes.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@
451451
void _aes_cbc_dec_128(
452452
void *in, //!< Input cipher text
453453
uint8_t *IV, //!< Must be 16 bytes aligned to a 16 byte boundary
454-
uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key rounds or dec_keys of cbc_key_data
454+
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
455455
void *out, //!< Output plain text
456456
uint64_t len_bytes //!< Must be a multiple of 16 bytes
457457
);

aes/aarch64/cbc_enc_aes.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
void _aes_cbc_dec_128(
8080
void *in, //!< Input cipher text
8181
uint8_t *IV, //!< Must be 16 bytes aligned to a 16 byte boundary
82-
uint8_t *keys, //!< Must be on a 16 byte boundary and length of key size * key rounds or dec_keys of cbc_key_data
82+
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
8383
void *out, //!< Output plain text
8484
uint64_t len_bytes //!< Must be a multiple of 16 bytes
8585
);

aes/aes_param_test.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ struct test_func {
8181
static int
8282
test_aes_keyexp_api(aes_keyexp_func aes_keyexp_func_ptr, const char *name)
8383
{
84-
uint8_t key[CBC_ROUND_KEY_LEN] = { 0 };
85-
uint8_t enc_keys[CBC_MAX_KEYS_SIZE] = { 0 };
86-
uint8_t dec_keys[CBC_MAX_KEYS_SIZE] = { 0 };
84+
uint8_t key[ISAL_CBC_ROUND_KEY_LEN] = { 0 };
85+
uint8_t enc_keys[ISAL_CBC_MAX_KEYS_SIZE] = { 0 };
86+
uint8_t dec_keys[ISAL_CBC_MAX_KEYS_SIZE] = { 0 };
8787

8888
// test null key
8989
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)
103103
static int
104104
test_aes_cbc_api(aes_cbc_func aes_cbc_func_ptr, const char *name)
105105
{
106-
uint8_t exp_keys[CBC_MAX_KEYS_SIZE] = { 0 };
106+
uint8_t exp_keys[ISAL_CBC_MAX_KEYS_SIZE] = { 0 };
107107
uint8_t buf[16] = { 0 };
108108
uint8_t iv[16] = { 0 };
109109

@@ -132,9 +132,9 @@ static int
132132
test_aes_xts_api(aes_xts_func aes_xts_func_ptr, const char *name, const int expanded_key)
133133
{
134134
uint8_t key1[32] = { 0 };
135-
uint8_t exp_keys1[CBC_MAX_KEYS_SIZE] = { 0 };
135+
uint8_t exp_keys1[ISAL_CBC_MAX_KEYS_SIZE] = { 0 };
136136
uint8_t key2[32];
137-
uint8_t exp_keys2[CBC_MAX_KEYS_SIZE];
137+
uint8_t exp_keys2[ISAL_CBC_MAX_KEYS_SIZE];
138138
uint8_t buf[16] = { 0 };
139139
uint8_t tweak[16] = { 0 };
140140

aes/cbc_ossl_perf.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static unsigned char *ciphertext = NULL;
6565
static unsigned char *ossl_plaintext = NULL;
6666
static unsigned char *ossl_ciphertext = NULL;
6767

68-
static uint8_t test_key[CBC_256_BITS];
68+
static uint8_t test_key[ISAL_CBC_256_BITS];
6969

7070
void
7171
mk_rand_data(uint8_t *data, uint32_t size)
@@ -83,9 +83,9 @@ aes_128_perf(uint8_t *key)
8383

8484
/* Initialize our cipher context, which can use same input vectors */
8585
uint8_t *iv = NULL;
86-
struct cbc_key_data *key_data = NULL;
86+
struct isal_cbc_key_data *key_data = NULL;
8787

88-
ret = posix_memalign((void **) &iv, 16, (CBC_IV_DATA_LEN));
88+
ret = posix_memalign((void **) &iv, 16, (ISAL_CBC_IV_DATA_LEN));
8989
if (ret) {
9090
printf("alloc error: Fail");
9191
return 1;
@@ -97,7 +97,7 @@ aes_128_perf(uint8_t *key)
9797
goto exit;
9898
}
9999

100-
memcpy(iv, ic, CBC_IV_DATA_LEN);
100+
memcpy(iv, ic, ISAL_CBC_IV_DATA_LEN);
101101

102102
isal_aes_keyexp_128(key, key_data->enc_keys, key_data->dec_keys);
103103
isal_aes_cbc_enc_128(plaintext, iv, key_data->enc_keys, ciphertext, TEST_LEN);
@@ -169,9 +169,9 @@ aes_192_perf(uint8_t *key)
169169
{
170170
int i, ret;
171171
uint8_t *iv = NULL;
172-
struct cbc_key_data *key_data = NULL;
172+
struct isal_cbc_key_data *key_data = NULL;
173173

174-
ret = posix_memalign((void **) &iv, 16, (CBC_IV_DATA_LEN));
174+
ret = posix_memalign((void **) &iv, 16, (ISAL_CBC_IV_DATA_LEN));
175175
if (ret) {
176176
printf("alloc error: Fail");
177177
return 1;
@@ -183,7 +183,7 @@ aes_192_perf(uint8_t *key)
183183
goto exit;
184184
}
185185

186-
memcpy(iv, ic, CBC_IV_DATA_LEN);
186+
memcpy(iv, ic, ISAL_CBC_IV_DATA_LEN);
187187
isal_aes_keyexp_192(key, key_data->enc_keys, key_data->dec_keys);
188188
isal_aes_cbc_enc_192(plaintext, iv, key_data->enc_keys, ciphertext, TEST_LEN);
189189
openssl_aes_192_cbc_enc(key, iv, TEST_LEN, plaintext, ossl_ciphertext);
@@ -254,9 +254,9 @@ aes_256_perf(uint8_t *key)
254254
{
255255
int i, ret;
256256
uint8_t *iv = NULL;
257-
struct cbc_key_data *key_data = NULL;
257+
struct isal_cbc_key_data *key_data = NULL;
258258

259-
ret = posix_memalign((void **) &iv, 16, (CBC_IV_DATA_LEN));
259+
ret = posix_memalign((void **) &iv, 16, (ISAL_CBC_IV_DATA_LEN));
260260
if (ret) {
261261
printf("alloc error: Fail");
262262
return 1;
@@ -269,7 +269,7 @@ aes_256_perf(uint8_t *key)
269269
}
270270

271271
isal_aes_keyexp_256(key, key_data->enc_keys, key_data->dec_keys);
272-
memcpy(iv, ic, CBC_IV_DATA_LEN);
272+
memcpy(iv, ic, ISAL_CBC_IV_DATA_LEN);
273273
isal_aes_cbc_enc_256(plaintext, iv, key_data->enc_keys, ciphertext, TEST_LEN);
274274
openssl_aes_256_cbc_enc(key, iv, TEST_LEN, plaintext, ossl_ciphertext);
275275

aes/cbc_pre.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
#include "aes_keyexp_internal.h"
3333

3434
int
35-
aes_cbc_precomp(uint8_t *key, int key_size, struct cbc_key_data *keys_blk)
35+
aes_cbc_precomp(uint8_t *key, int key_size, struct isal_cbc_key_data *keys_blk)
3636
{
37-
if (CBC_128_BITS == key_size) {
37+
if (ISAL_CBC_128_BITS == key_size) {
3838
_aes_keyexp_128(key, keys_blk->enc_keys, keys_blk->dec_keys);
39-
} else if (CBC_192_BITS == key_size) {
39+
} else if (ISAL_CBC_192_BITS == key_size) {
4040
_aes_keyexp_192(key, keys_blk->enc_keys, keys_blk->dec_keys);
41-
} else if (CBC_256_BITS == key_size) {
41+
} else if (ISAL_CBC_256_BITS == key_size) {
4242
_aes_keyexp_256(key, keys_blk->enc_keys, keys_blk->dec_keys);
4343
} else {
4444
// Invalid key length

aes/cbc_std_vectors.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@
3333

3434
// struct to hold pointers to the cbc data vectors
3535
struct cbc_vector {
36-
uint8_t *K; // AES Key
37-
cbc_key_size K_LEN; // length of key in bits
38-
uint8_t *IV; // initial value used by GCM
39-
uint64_t P_LEN; // length of our plaintext
40-
uint8_t *P; // Plain text
36+
uint8_t *K; // AES Key
37+
isal_cbc_key_size K_LEN; // length of key in bits
38+
uint8_t *IV; // initial value used by GCM
39+
uint64_t P_LEN; // length of our plaintext
40+
uint8_t *P; // Plain text
4141
// outputs of encryption
4242
uint8_t *EXP_C; // same length as P
4343
// used in vector checks, not populated in std vector array
4444
uint8_t *C;
45-
struct cbc_key_data *KEYS;
45+
struct isal_cbc_key_data *KEYS;
4646
};
4747

4848
///////////////////////////////////////////

aes/cbc_std_vectors_random_test.c

+23-21
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,26 @@
5656
#define MAX_UNALINED (16)
5757
#endif
5858

59-
static cbc_key_size const Ksize[] = { CBC_128_BITS, CBC_192_BITS, CBC_256_BITS };
59+
static isal_cbc_key_size const Ksize[] = { ISAL_CBC_128_BITS, ISAL_CBC_192_BITS,
60+
ISAL_CBC_256_BITS };
6061

6162
typedef void (*aes_cbc_generic)(uint8_t *in, uint8_t *IV, uint8_t *keys, uint8_t *out,
6263
uint64_t len_bytes);
6364

6465
int
6566
OpenSslEnc(uint8_t k_len, uint8_t *key, uint8_t *in, uint8_t *iv, uint8_t *out, uint64_t len_bytes)
6667
{
67-
if (CBC_128_BITS == k_len) {
68+
if (ISAL_CBC_128_BITS == k_len) {
6869
#ifdef CBC_VECTORS_EXTRA_VERBOSE
6970
printf(" OpenSSL128 ");
7071
#endif
7172
openssl_aes_128_cbc_enc(key, (uint8_t *) iv, len_bytes, in, out);
72-
} else if (CBC_192_BITS == k_len) {
73+
} else if (ISAL_CBC_192_BITS == k_len) {
7374
#ifdef CBC_VECTORS_EXTRA_VERBOSE
7475
printf(" OpenSSL192 ");
7576
#endif
7677
openssl_aes_192_cbc_enc(key, (uint8_t *) iv, len_bytes, in, out);
77-
} else if (CBC_256_BITS == k_len) {
78+
} else if (ISAL_CBC_256_BITS == k_len) {
7879
#ifdef CBC_VECTORS_EXTRA_VERBOSE
7980
printf(" OpenSSL256 ");
8081
fflush(0);
@@ -90,17 +91,17 @@ OpenSslEnc(uint8_t k_len, uint8_t *key, uint8_t *in, uint8_t *iv, uint8_t *out,
9091
int
9192
OpenSslDec(uint8_t k_len, uint8_t *key, uint8_t *in, uint8_t *iv, uint8_t *out, uint64_t len_bytes)
9293
{
93-
if (CBC_128_BITS == k_len) {
94+
if (ISAL_CBC_128_BITS == k_len) {
9495
#ifdef CBC_VECTORS_EXTRA_VERBOSE
9596
printf(" OpenSSL128 ");
9697
#endif
9798
openssl_aes_128_cbc_dec(key, (uint8_t *) iv, len_bytes, in, out);
98-
} else if (CBC_192_BITS == k_len) {
99+
} else if (ISAL_CBC_192_BITS == k_len) {
99100
#ifdef CBC_VECTORS_EXTRA_VERBOSE
100101
printf(" OpenSSL192 ");
101102
#endif
102103
openssl_aes_192_cbc_dec(key, (uint8_t *) iv, len_bytes, in, out);
103-
} else if (CBC_256_BITS == k_len) {
104+
} else if (ISAL_CBC_256_BITS == k_len) {
104105
#ifdef CBC_VECTORS_EXTRA_VERBOSE
105106
printf(" OpenSSL256 ");
106107
#endif
@@ -165,21 +166,21 @@ check_vector(struct cbc_vector *vector)
165166
printf(".");
166167
#endif
167168

168-
if (CBC_128_BITS == vector->K_LEN) {
169+
if (ISAL_CBC_128_BITS == vector->K_LEN) {
169170
enc = (aes_cbc_generic) &isal_aes_cbc_enc_128;
170171
dec = (aes_cbc_generic) &isal_aes_cbc_dec_128;
171172
isal_aes_keyexp_128(vector->K, vector->KEYS->enc_keys, vector->KEYS->dec_keys);
172173
#ifdef CBC_VECTORS_EXTRA_VERBOSE
173174
printf(" CBC128 ");
174175
#endif
175-
} else if (CBC_192_BITS == vector->K_LEN) {
176+
} else if (ISAL_CBC_192_BITS == vector->K_LEN) {
176177
enc = (aes_cbc_generic) &isal_aes_cbc_enc_192;
177178
dec = (aes_cbc_generic) &isal_aes_cbc_dec_192;
178179
isal_aes_keyexp_192(vector->K, vector->KEYS->enc_keys, vector->KEYS->dec_keys);
179180
#ifdef CBC_VECTORS_EXTRA_VERBOSE
180181
printf(" CBC192 ");
181182
#endif
182-
} else if (CBC_256_BITS == vector->K_LEN) {
183+
} else if (ISAL_CBC_256_BITS == vector->K_LEN) {
183184
enc = (aes_cbc_generic) &isal_aes_cbc_enc_256;
184185
dec = (aes_cbc_generic) &isal_aes_cbc_dec_256;
185186
isal_aes_keyexp_256(vector->K, vector->KEYS->enc_keys, vector->KEYS->dec_keys);
@@ -259,7 +260,7 @@ test_std_combinations(void)
259260
#ifdef CBC_VECTORS_VERBOSE
260261
printf("\n");
261262
#endif
262-
ret = posix_memalign((void **) &iv, 16, (CBC_IV_DATA_LEN));
263+
ret = posix_memalign((void **) &iv, 16, (ISAL_CBC_IV_DATA_LEN));
263264
if ((0 != ret) || (NULL == iv))
264265
return 1;
265266

@@ -273,7 +274,7 @@ test_std_combinations(void)
273274
}
274275
// IV data must be aligned to 16 byte boundary so move data in aligned buffer and
275276
// change out the pointer
276-
memcpy(iv, vect.IV, CBC_IV_DATA_LEN);
277+
memcpy(iv, vect.IV, ISAL_CBC_IV_DATA_LEN);
277278
vect.IV = iv;
278279
vect.C = NULL;
279280
vect.C = malloc(vect.P_LEN);
@@ -317,7 +318,7 @@ test_random_combinations(void)
317318
fflush(0);
318319
#endif
319320
test.IV = NULL;
320-
ret = posix_memalign((void **) &test.IV, 16, (CBC_IV_DATA_LEN));
321+
ret = posix_memalign((void **) &test.IV, 16, (ISAL_CBC_IV_DATA_LEN));
321322
if ((0 != ret) || (NULL == test.IV))
322323
return 1;
323324
test.KEYS = NULL;
@@ -362,7 +363,7 @@ test_random_combinations(void)
362363

363364
mk_rand_data(test.P, test.P_LEN);
364365
mk_rand_data(test.K, test.K_LEN);
365-
mk_rand_data(test.IV, CBC_IV_DATA_LEN);
366+
mk_rand_data(test.IV, ISAL_CBC_IV_DATA_LEN);
366367

367368
#ifdef CBC_VECTORS_EXTRA_VERBOSE
368369
printf(" Offset:0x%x ", offset);
@@ -428,18 +429,19 @@ test_efence_combinations(void)
428429
test.P = P + PAGE_LEN - test.P_LEN - offset;
429430
test.C = C + PAGE_LEN - test.P_LEN - offset;
430431
test.K = K + PAGE_LEN - test.K_LEN - offset;
431-
test.IV = IV + PAGE_LEN - CBC_IV_DATA_LEN - offset;
432+
test.IV = IV + PAGE_LEN - ISAL_CBC_IV_DATA_LEN - offset;
432433
test.IV =
433434
test.IV - ((uint64_t) test.IV & 0xff); // align to 16 byte boundary
434-
test.KEYS = (struct cbc_key_data *) (key_data + PAGE_LEN -
435-
sizeof(*test.KEYS) - offset);
436-
test.KEYS = (struct cbc_key_data *) ((uint8_t *) test.KEYS -
437-
((uint64_t) test.KEYS &
438-
0xff)); // align to 16 byte boundary
435+
test.KEYS = (struct isal_cbc_key_data *) (key_data + PAGE_LEN -
436+
sizeof(*test.KEYS) - offset);
437+
test.KEYS =
438+
(struct isal_cbc_key_data *) ((uint8_t *) test.KEYS -
439+
((uint64_t) test.KEYS &
440+
0xff)); // align to 16 byte boundary
439441

440442
mk_rand_data(test.P, test.P_LEN);
441443
mk_rand_data(test.K, test.K_LEN);
442-
mk_rand_data(test.IV, CBC_IV_DATA_LEN);
444+
mk_rand_data(test.IV, ISAL_CBC_IV_DATA_LEN);
443445
#ifdef CBC_VECTORS_EXTRA_VERBOSE
444446
printf(" Offset:0x%x ", offset);
445447
#endif

aes/cbc_std_vectors_test.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,19 @@ check_vector(struct cbc_vector *vector)
8181
printf(".");
8282

8383
switch (vector->K_LEN) {
84-
case CBC_128_BITS:
84+
case ISAL_CBC_128_BITS:
8585
enc = (aes_cbc_generic) &isal_aes_cbc_enc_128;
8686
dec = (aes_cbc_generic) &isal_aes_cbc_dec_128;
8787
isal_aes_keyexp_128(vector->K, vector->KEYS->enc_keys, vector->KEYS->dec_keys);
8888
DEBUG_PRINT((" CBC128 "));
8989
break;
90-
case CBC_192_BITS:
90+
case ISAL_CBC_192_BITS:
9191
enc = (aes_cbc_generic) &isal_aes_cbc_enc_192;
9292
dec = (aes_cbc_generic) &isal_aes_cbc_dec_192;
9393
isal_aes_keyexp_192(vector->K, vector->KEYS->enc_keys, vector->KEYS->dec_keys);
9494
DEBUG_PRINT((" CBC192 "));
9595
break;
96-
case CBC_256_BITS:
96+
case ISAL_CBC_256_BITS:
9797
enc = (aes_cbc_generic) &isal_aes_cbc_enc_256;
9898
dec = (aes_cbc_generic) &isal_aes_cbc_dec_256;
9999
isal_aes_keyexp_256(vector->K, vector->KEYS->enc_keys, vector->KEYS->dec_keys);
@@ -162,7 +162,7 @@ test_std_combinations(void)
162162

163163
printf("AES CBC standard test vectors: ");
164164

165-
ret = posix_memalign((void **) &iv, 16, (CBC_IV_DATA_LEN));
165+
ret = posix_memalign((void **) &iv, 16, (ISAL_CBC_IV_DATA_LEN));
166166
if ((0 != ret) || (NULL == iv))
167167
return 1;
168168

@@ -176,7 +176,7 @@ test_std_combinations(void)
176176
}
177177
// IV data must be aligned to 16 byte boundary so move data in
178178
// aligned buffer and change out the pointer
179-
memcpy(iv, vect.IV, CBC_IV_DATA_LEN);
179+
memcpy(iv, vect.IV, ISAL_CBC_IV_DATA_LEN);
180180
vect.IV = iv;
181181
vect.C = malloc(vect.P_LEN);
182182
if (NULL == vect.C) {

examples/saturation_test/aes_thread.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ mk_rand_data(uint8_t *data, uint32_t size)
120120
struct cbc_context {
121121
struct aes_context base;
122122
uint8_t *iv;
123-
uint8_t key[CBC_256_BITS];
124-
struct cbc_key_data *key_data;
123+
uint8_t key[ISAL_CBC_256_BITS];
124+
struct isal_cbc_key_data *key_data;
125125
};
126126

127127
static int
@@ -130,14 +130,14 @@ cbc_dec_pre(struct aes_context *p)
130130
struct cbc_context *pCtx = (struct cbc_context *) p;
131131
int ret;
132132

133-
ret = posix_memalign((void **) &pCtx->iv, 16, (CBC_IV_DATA_LEN));
133+
ret = posix_memalign((void **) &pCtx->iv, 16, (ISAL_CBC_IV_DATA_LEN));
134134
ret |= posix_memalign((void **) &pCtx->key_data, 16, (sizeof(*pCtx->key_data)));
135135

136136
if ((0 != ret) || (NULL == pCtx->iv) || (NULL == pCtx->key_data))
137137
return 1;
138138

139139
mk_rand_data(pCtx->key, sizeof(pCtx->key));
140-
memcpy(pCtx->iv, ic, CBC_IV_DATA_LEN);
140+
memcpy(pCtx->iv, ic, ISAL_CBC_IV_DATA_LEN);
141141
switch (pCtx->base.bits) {
142142
case 128:
143143
isal_aes_keyexp_128(pCtx->key, pCtx->key_data->enc_keys, pCtx->key_data->dec_keys);

0 commit comments

Comments
 (0)