mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 02:37:28 +02:00
wolfcrypt/src/aes.c for linuxkm: add missing vector register push/pops.
This commit is contained in:
@ -1697,8 +1697,10 @@ static void wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
|
||||
tmp_align = tmp + (AESNI_ALIGN - ((size_t)tmp % AESNI_ALIGN));
|
||||
|
||||
XMEMCPY(tmp_align, inBlock, AES_BLOCK_SIZE);
|
||||
SAVE_VECTOR_REGISTERS();
|
||||
AES_ECB_encrypt(tmp_align, tmp_align, AES_BLOCK_SIZE,
|
||||
(byte*)aes->key, aes->rounds);
|
||||
RESTORE_VECTOR_REGISTERS();
|
||||
XMEMCPY(outBlock, tmp_align, AES_BLOCK_SIZE);
|
||||
XFREE(tmp, aes->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
return;
|
||||
@ -1708,8 +1710,10 @@ static void wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
|
||||
#endif
|
||||
}
|
||||
|
||||
SAVE_VECTOR_REGISTERS();
|
||||
AES_ECB_encrypt(inBlock, outBlock, AES_BLOCK_SIZE, (byte*)aes->key,
|
||||
aes->rounds);
|
||||
RESTORE_VECTOR_REGISTERS();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1993,8 +1997,10 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
|
||||
/* if input and output same will overwrite input iv */
|
||||
if ((const byte*)aes->tmp != inBlock)
|
||||
XMEMCPY(aes->tmp, inBlock, AES_BLOCK_SIZE);
|
||||
SAVE_VECTOR_REGISTERS();
|
||||
AES_ECB_decrypt(inBlock, outBlock, AES_BLOCK_SIZE, (byte*)aes->key,
|
||||
aes->rounds);
|
||||
RESTORE_VECTOR_REGISTERS();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
@ -3555,8 +3561,10 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
|
||||
|
||||
tmp_align = tmp + (AESNI_ALIGN - ((size_t)tmp % AESNI_ALIGN));
|
||||
XMEMCPY(tmp_align, in, sz);
|
||||
SAVE_VECTOR_REGISTERS();
|
||||
AES_CBC_encrypt(tmp_align, tmp_align, (byte*)aes->reg, sz,
|
||||
(byte*)aes->key, aes->rounds);
|
||||
RESTORE_VECTOR_REGISTERS();
|
||||
/* store iv for next call */
|
||||
XMEMCPY(aes->reg, tmp_align + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
|
||||
|
||||
@ -3569,8 +3577,10 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
|
||||
#endif
|
||||
}
|
||||
|
||||
SAVE_VECTOR_REGISTERS();
|
||||
AES_CBC_encrypt(in, out, (byte*)aes->reg, sz, (byte*)aes->key,
|
||||
aes->rounds);
|
||||
RESTORE_VECTOR_REGISTERS();
|
||||
/* store iv for next call */
|
||||
XMEMCPY(aes->reg, out + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
|
||||
|
||||
@ -3650,6 +3660,7 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
|
||||
|
||||
/* if input and output same will overwrite input iv */
|
||||
XMEMCPY(aes->tmp, in + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
|
||||
SAVE_VECTOR_REGISTERS();
|
||||
#if defined(WOLFSSL_AESNI_BY4)
|
||||
AES_CBC_decrypt_by4(in, out, (byte*)aes->reg, sz, (byte*)aes->key,
|
||||
aes->rounds);
|
||||
@ -3662,6 +3673,7 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
|
||||
#endif /* WOLFSSL_AESNI_BYx */
|
||||
/* store iv for next call */
|
||||
XMEMCPY(aes->reg, aes->tmp, AES_BLOCK_SIZE);
|
||||
RESTORE_VECTOR_REGISTERS();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@ -7258,8 +7270,10 @@ int wc_AesCcmEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
|
||||
while (inSz >= AES_BLOCK_SIZE * 4) {
|
||||
AesCcmCtrIncSet4(B, lenSz);
|
||||
|
||||
SAVE_VECTOR_REGISTERS();
|
||||
AES_ECB_encrypt(B, A, AES_BLOCK_SIZE * 4, (byte*)aes->key,
|
||||
aes->rounds);
|
||||
RESTORE_VECTOR_REGISTERS();
|
||||
xorbuf(A, in, AES_BLOCK_SIZE * 4);
|
||||
XMEMCPY(out, A, AES_BLOCK_SIZE * 4);
|
||||
|
||||
@ -7340,8 +7354,10 @@ int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
|
||||
while (oSz >= AES_BLOCK_SIZE * 4) {
|
||||
AesCcmCtrIncSet4(B, lenSz);
|
||||
|
||||
SAVE_VECTOR_REGISTERS();
|
||||
AES_ECB_encrypt(B, A, AES_BLOCK_SIZE * 4, (byte*)aes->key,
|
||||
aes->rounds);
|
||||
RESTORE_VECTOR_REGISTERS();
|
||||
xorbuf(A, in, AES_BLOCK_SIZE * 4);
|
||||
XMEMCPY(o, A, AES_BLOCK_SIZE * 4);
|
||||
|
||||
|
Reference in New Issue
Block a user