Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20241221-wolfCrypt-more-AES_BLOCK_SIZE #8310

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions IDE/QNX/example-cmac/cmac-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ static int createTag(const byte* key, int keySz, byte* msg, int msgSz,
byte* msg2, int msg2Sz)
{
Cmac cmac;
byte tag[AES_BLOCK_SIZE];
byte tag[WC_AES_BLOCK_SIZE];
word32 i, tagSz;
byte out[48];
word32 outSz;

XMEMSET(tag, 0, sizeof(tag));
tagSz = AES_BLOCK_SIZE;
tagSz = WC_AES_BLOCK_SIZE;

outSz = 48;
wc_caamCoverKey((byte*)key, keySz, out, &outSz, 0);
Expand Down
46 changes: 23 additions & 23 deletions IDE/Renesas/e2studio/RA6M4/test/src/wolfssl_sce_unit_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ static int sce_aes_cbc_test(int prnt, FSPSM_AES_PWKEY aes_key)

Aes aes[1];

byte cipher[AES_BLOCK_SIZE];
byte plain[AES_BLOCK_SIZE];
byte cipher[WC_AES_BLOCK_SIZE];
byte plain[WC_AES_BLOCK_SIZE];
int ret = 0;

WOLFSSL_SMALL_STACK_STATIC const byte msg[] = {
Expand All @@ -119,8 +119,8 @@ static int sce_aes_cbc_test(int prnt, FSPSM_AES_PWKEY aes_key)
};
byte iv[] = "1234567890abcdef "; /* align */

XMEMSET(cipher, 0, AES_BLOCK_SIZE);
XMEMSET(plain, 0, AES_BLOCK_SIZE);
XMEMSET(cipher, 0, WC_AES_BLOCK_SIZE);
XMEMSET(plain, 0, WC_AES_BLOCK_SIZE);

if (prnt) {
printf(" sce_aes_cbc_test() ");
Expand All @@ -129,9 +129,9 @@ static int sce_aes_cbc_test(int prnt, FSPSM_AES_PWKEY aes_key)
ret = wc_AesInit(aes, NULL, devId);
if (ret == 0) {
ret = wc_AesSetKey(aes, (byte*)aes_key,
AES_BLOCK_SIZE, iv, AES_ENCRYPTION);
WC_AES_BLOCK_SIZE, iv, AES_ENCRYPTION);
if (ret == 0) {
ret = wc_AesCbcEncrypt(aes, cipher, msg, AES_BLOCK_SIZE);
ret = wc_AesCbcEncrypt(aes, cipher, msg, WC_AES_BLOCK_SIZE);
}

wc_AesFree(aes);
Expand All @@ -144,15 +144,15 @@ static int sce_aes_cbc_test(int prnt, FSPSM_AES_PWKEY aes_key)
ret = wc_AesInit(aes, NULL, devId);
if (ret == 0) {
ret = wc_AesSetKey(aes, (byte*)aes_key,
AES_BLOCK_SIZE, iv, AES_ENCRYPTION);
WC_AES_BLOCK_SIZE, iv, AES_ENCRYPTION);
if (ret == 0)
ret = wc_AesCbcDecrypt(aes, plain, cipher, AES_BLOCK_SIZE);
ret = wc_AesCbcDecrypt(aes, plain, cipher, WC_AES_BLOCK_SIZE);

wc_AesFree(aes);
}
if (ret != 0)
ret = -2;
if (XMEMCMP(plain, msg, AES_BLOCK_SIZE) != 0)
if (XMEMCMP(plain, msg, WC_AES_BLOCK_SIZE) != 0)
ret = -3;
#endif /* HAVE_AES_DECRYPT */

Expand Down Expand Up @@ -189,8 +189,8 @@ static void tskAes128_Cbc_Test(void *pvParam)
static int sce_aes256_test(int prnt, FSPSM_AES_PWKEY aes_key)
{
Aes enc[1];
byte cipher[AES_BLOCK_SIZE];
byte plain[AES_BLOCK_SIZE];
byte cipher[WC_AES_BLOCK_SIZE];
byte plain[WC_AES_BLOCK_SIZE];
Aes dec[1];
int ret = 0;

Expand Down Expand Up @@ -219,28 +219,28 @@ static int sce_aes256_test(int prnt, FSPSM_AES_PWKEY aes_key)
}

ret = wc_AesSetKey(enc, (byte*)aes_key,
AES_BLOCK_SIZE*2, iv, AES_ENCRYPTION);
WC_AES_BLOCK_SIZE*2, iv, AES_ENCRYPTION);
if (ret != 0){
ret = -3;
goto out;
}

ret = wc_AesSetKey(dec, (byte*)aes_key,
AES_BLOCK_SIZE*2, iv, AES_DECRYPTION);
WC_AES_BLOCK_SIZE*2, iv, AES_DECRYPTION);
if (ret != 0) {
ret = -4;
goto out;
}

XMEMSET(cipher, 0, AES_BLOCK_SIZE);
XMEMSET(cipher, 0, WC_AES_BLOCK_SIZE);
ret = wc_AesCbcEncrypt(enc, cipher, msg, (int) sizeof(msg));

if (ret != 0) {
ret = -5;
goto out;
}

XMEMSET(plain, 0, AES_BLOCK_SIZE);
XMEMSET(plain, 0, WC_AES_BLOCK_SIZE);
ret = wc_AesCbcDecrypt(dec, plain, cipher, (int) sizeof(cipher));

if (ret != 0){
Expand Down Expand Up @@ -340,8 +340,8 @@ static int sce_aesgcm256_test(int prnt, FSPSM_AES_PWKEY aes256_key)
};

byte resultT[sizeof(t1)];
byte resultP[sizeof(p) + AES_BLOCK_SIZE];
byte resultC[sizeof(p) + AES_BLOCK_SIZE];
byte resultP[sizeof(p) + WC_AES_BLOCK_SIZE];
byte resultC[sizeof(p) + WC_AES_BLOCK_SIZE];
int result = 0;
int ret;

Expand All @@ -366,7 +366,7 @@ static int sce_aesgcm256_test(int prnt, FSPSM_AES_PWKEY aes256_key)
}

result = wc_AesGcmSetKey(enc,
(byte*)aes256_key, AES_BLOCK_SIZE*2);
(byte*)aes256_key, WC_AES_BLOCK_SIZE*2);
if (result != 0) {
ret = -3;
goto out;
Expand All @@ -383,7 +383,7 @@ static int sce_aesgcm256_test(int prnt, FSPSM_AES_PWKEY aes256_key)
}

result = wc_AesGcmSetKey(dec,
(byte*)aes256_key, AES_BLOCK_SIZE*2);
(byte*)aes256_key, WC_AES_BLOCK_SIZE*2);
if (result != 0) {
ret = -7;
goto out;
Expand All @@ -408,7 +408,7 @@ static int sce_aesgcm256_test(int prnt, FSPSM_AES_PWKEY aes256_key)
XMEMSET(resultP, 0, sizeof(resultP));

wc_AesGcmSetKey(enc,
(byte*)aes256_key, AES_BLOCK_SIZE*2);
(byte*)aes256_key, WC_AES_BLOCK_SIZE*2);
/* AES-GCM encrypt and decrypt both use AES encrypt internally */
result = wc_AesGcmEncrypt(enc, resultC, p, sizeof(p),
(byte*)iv1, sizeof(iv1),
Expand Down Expand Up @@ -527,8 +527,8 @@ static int sce_aesgcm128_test(int prnt, FSPSM_AES_PWKEY aes128_key)
};

byte resultT[sizeof(t1)];
byte resultP[sizeof(p) + AES_BLOCK_SIZE];
byte resultC[sizeof(p) + AES_BLOCK_SIZE];
byte resultP[sizeof(p) + WC_AES_BLOCK_SIZE];
byte resultC[sizeof(p) + WC_AES_BLOCK_SIZE];
int result = 0;
int ret;

Expand All @@ -553,7 +553,7 @@ static int sce_aesgcm128_test(int prnt, FSPSM_AES_PWKEY aes128_key)
goto out;
}

wc_AesGcmSetKey(enc, (byte*)aes128_key, AES_BLOCK_SIZE);
wc_AesGcmSetKey(enc, (byte*)aes128_key, WC_AES_BLOCK_SIZE);
if (result != 0) {
ret = -3;
goto out;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ static int tsip_aes_cbc_test(int prnt, tsip_aes_key_index_t* aes_key)

Aes aes[1];

byte cipher[AES_BLOCK_SIZE];
byte plain[AES_BLOCK_SIZE];
byte cipher[WC_AES_BLOCK_SIZE];
byte plain[WC_AES_BLOCK_SIZE];
int ret = 0;

WOLFSSL_SMALL_STACK_STATIC const byte msg[] = {
Expand All @@ -139,22 +139,22 @@ static int tsip_aes_cbc_test(int prnt, tsip_aes_key_index_t* aes_key)
byte key[] = "0123456789abcdef "; /* align */
byte iv[] = "1234567890abcdef "; /* align */

ForceZero(cipher, AES_BLOCK_SIZE);
ForceZero(plain, AES_BLOCK_SIZE);
ForceZero(cipher, WC_AES_BLOCK_SIZE);
ForceZero(plain, WC_AES_BLOCK_SIZE);

if (prnt) {
printf(" tsip_aes_cbc_test() ");
}

ret = wc_AesInit(aes, NULL, INVALID_DEVID);
if (ret == 0) {
ret = wc_AesSetKey(aes, key, AES_BLOCK_SIZE, iv, AES_ENCRYPTION);
ret = wc_AesSetKey(aes, key, WC_AES_BLOCK_SIZE, iv, AES_ENCRYPTION);
XMEMCPY(&aes->ctx.tsip_keyIdx, aes_key,
sizeof(tsip_aes_key_index_t));

aes->ctx.keySize = aes->keylen;
if (ret == 0) {
ret = wc_tsip_AesCbcEncrypt(aes, cipher, msg, AES_BLOCK_SIZE);
ret = wc_tsip_AesCbcEncrypt(aes, cipher, msg, WC_AES_BLOCK_SIZE);
}

wc_AesFree(aes);
Expand All @@ -167,18 +167,18 @@ static int tsip_aes_cbc_test(int prnt, tsip_aes_key_index_t* aes_key)
if (ret == 0)
ret = wc_AesInit(aes, NULL, INVALID_DEVID);
if (ret == 0) {
ret = wc_AesSetKey(aes, key, AES_BLOCK_SIZE, iv, AES_DECRYPTION);
ret = wc_AesSetKey(aes, key, WC_AES_BLOCK_SIZE, iv, AES_DECRYPTION);
XMEMCPY(&aes->ctx.tsip_keyIdx, aes_key,
sizeof(tsip_aes_key_index_t));
aes->ctx.keySize = aes->keylen;
if (ret == 0)
ret = wc_tsip_AesCbcDecrypt(aes, plain, cipher, AES_BLOCK_SIZE);
ret = wc_tsip_AesCbcDecrypt(aes, plain, cipher, WC_AES_BLOCK_SIZE);

wc_AesFree(aes);
}
if (ret != 0)
ret = -2;
if (XMEMCMP(plain, msg, AES_BLOCK_SIZE) != 0)
if (XMEMCMP(plain, msg, WC_AES_BLOCK_SIZE) != 0)
ret = -3;
#endif /* HAVE_AES_DECRYPT */

Expand Down Expand Up @@ -216,8 +216,8 @@ static void tskAes128_Cbc_Test(void *pvParam)
static int tsip_aes256_test(int prnt, tsip_aes_key_index_t* aes_key)
{
Aes enc[1];
byte cipher[AES_BLOCK_SIZE];
byte plain[AES_BLOCK_SIZE];
byte cipher[WC_AES_BLOCK_SIZE];
byte plain[WC_AES_BLOCK_SIZE];
Aes dec[1];
int ret = 0;

Expand Down Expand Up @@ -279,15 +279,15 @@ static int tsip_aes256_test(int prnt, tsip_aes_key_index_t* aes_key)
dec->ctx.keySize = dec->keylen;
}

ForceZero(cipher, AES_BLOCK_SIZE);
ForceZero(cipher, WC_AES_BLOCK_SIZE);
ret = wc_tsip_AesCbcEncrypt(enc, cipher, msg, (int) sizeof(msg));

if (ret != 0) {
ret = -5;
goto out;
}

ForceZero(plain, AES_BLOCK_SIZE);
ForceZero(plain, WC_AES_BLOCK_SIZE);
ret = wc_tsip_AesCbcDecrypt(dec, plain, cipher, (int) sizeof(cipher));

if (ret != 0){
Expand Down Expand Up @@ -395,8 +395,8 @@ static int tsip_aesgcm256_test(int prnt, tsip_aes_key_index_t* aes256_key)
};

byte resultT[sizeof(t1)];
byte resultP[sizeof(p) + AES_BLOCK_SIZE];
byte resultC[sizeof(p) + AES_BLOCK_SIZE];
byte resultP[sizeof(p) + WC_AES_BLOCK_SIZE];
byte resultC[sizeof(p) + WC_AES_BLOCK_SIZE];
int result = 0;
int ret;

Expand Down Expand Up @@ -575,8 +575,8 @@ static int tsip_aesgcm128_test(int prnt, tsip_aes_key_index_t* aes128_key)
};

byte resultT[sizeof(t3)];
byte resultP[sizeof(p3) + AES_BLOCK_SIZE];
byte resultC[sizeof(p3) + AES_BLOCK_SIZE];
byte resultP[sizeof(p3) + WC_AES_BLOCK_SIZE];
byte resultC[sizeof(p3) + WC_AES_BLOCK_SIZE];
int result = 0;
int ret;

Expand Down
30 changes: 15 additions & 15 deletions IDE/Renesas/e2studio/RZN2L/test/src/test/wolfssl_rsip_unit_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ static int rsip_aes128_cbc_test(int prnt, FSPSM_AES_PWKEY aes_key)

Aes aes[1];

byte cipher[AES_BLOCK_SIZE];
byte plain[AES_BLOCK_SIZE];
byte cipher[WC_AES_BLOCK_SIZE];
byte plain[WC_AES_BLOCK_SIZE];
word32 keySz = (word32)(128/8);
int ret = 0;

Expand All @@ -147,8 +147,8 @@ static int rsip_aes128_cbc_test(int prnt, FSPSM_AES_PWKEY aes_key)
};
byte iv[] = "1234567890abcdef "; /* align */

XMEMSET(cipher, 0, AES_BLOCK_SIZE);
XMEMSET(plain, 0, AES_BLOCK_SIZE);
XMEMSET(cipher, 0, WC_AES_BLOCK_SIZE);
XMEMSET(plain, 0, WC_AES_BLOCK_SIZE);

if (prnt) {
printf(" rsip_aes_cbc_test() ");
Expand All @@ -159,7 +159,7 @@ static int rsip_aes128_cbc_test(int prnt, FSPSM_AES_PWKEY aes_key)
ret = wc_AesSetKey(aes, (byte*)aes_key, keySz,
iv, AES_ENCRYPTION);
if (ret == 0) {
ret = wc_AesCbcEncrypt(aes, cipher, msg, AES_BLOCK_SIZE);
ret = wc_AesCbcEncrypt(aes, cipher, msg, WC_AES_BLOCK_SIZE);
}

wc_AesFree(aes);
Expand All @@ -174,13 +174,13 @@ static int rsip_aes128_cbc_test(int prnt, FSPSM_AES_PWKEY aes_key)
ret = wc_AesSetKey(aes, (byte*)aes_key, keySz,
iv, AES_DECRYPTION);
if (ret == 0)
ret = wc_AesCbcDecrypt(aes, plain, cipher, AES_BLOCK_SIZE);
ret = wc_AesCbcDecrypt(aes, plain, cipher, WC_AES_BLOCK_SIZE);

wc_AesFree(aes);
}
if (ret != 0)
ret = -2;
if (XMEMCMP(plain, msg, AES_BLOCK_SIZE) != 0)
if (XMEMCMP(plain, msg, WC_AES_BLOCK_SIZE) != 0)
ret = -3;
#endif /* HAVE_AES_DECRYPT */

Expand Down Expand Up @@ -217,8 +217,8 @@ static void tskAes128_Cbc_Test(void *pvParam)
static int rsip_aes256_cbc_test(int prnt, FSPSM_AES_PWKEY aes_key)
{
Aes enc[1];
byte cipher[AES_BLOCK_SIZE];
byte plain[AES_BLOCK_SIZE];
byte cipher[WC_AES_BLOCK_SIZE];
byte plain[WC_AES_BLOCK_SIZE];
Aes dec[1];
const word32 keySz = (word32)(256/8);
int ret = 0;
Expand Down Expand Up @@ -261,15 +261,15 @@ static int rsip_aes256_cbc_test(int prnt, FSPSM_AES_PWKEY aes_key)
goto out;
}

XMEMSET(cipher, 0, AES_BLOCK_SIZE);
XMEMSET(cipher, 0, WC_AES_BLOCK_SIZE);
ret = wc_AesCbcEncrypt(enc, cipher, msg, (int) sizeof(msg));

if (ret != 0) {
ret = -5;
goto out;
}

XMEMSET(plain, 0, AES_BLOCK_SIZE);
XMEMSET(plain, 0, WC_AES_BLOCK_SIZE);
ret = wc_AesCbcDecrypt(dec, plain, cipher, (int) sizeof(cipher));

if (ret != 0){
Expand Down Expand Up @@ -368,8 +368,8 @@ static int rsip_aesgcm256_test(int prnt, FSPSM_AES_PWKEY aes256_key)
};

byte resultT[sizeof(t1)];
byte resultP[sizeof(p) + AES_BLOCK_SIZE];
byte resultC[sizeof(p) + AES_BLOCK_SIZE];
byte resultP[sizeof(p) + WC_AES_BLOCK_SIZE];
byte resultC[sizeof(p) + WC_AES_BLOCK_SIZE];
int result = 0;
int ret;

Expand Down Expand Up @@ -554,8 +554,8 @@ static int rsip_aesgcm128_test(int prnt, FSPSM_AES_PWKEY aes128_key)
};

byte resultT[sizeof(t1)];
byte resultP[sizeof(p) + AES_BLOCK_SIZE];
byte resultC[sizeof(p) + AES_BLOCK_SIZE];
byte resultP[sizeof(p) + WC_AES_BLOCK_SIZE];
byte resultC[sizeof(p) + WC_AES_BLOCK_SIZE];
int result = 0;
int ret;

Expand Down
Loading
Loading