aes.c: in linuxkm clause of WOLFSSL_AES_DIRECT section, gate on WOLFSSL_LINUXKM && WOLFSSL_AESNI (with no-asm falling through to the generic definition), and use wolfssl-idiomatic WARN_UNUSED_RESULT, not linux-kernel-idiomatic __must_check. (thanks to John S peer review)

This commit is contained in:
Daniel Pouzzner
2022-01-21 16:32:00 -06:00
parent a718637c6f
commit 565a7b0aab

View File

@@ -3142,11 +3142,9 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
#elif defined(WOLFSSL_DEVCRYPTO_AES) #elif defined(WOLFSSL_DEVCRYPTO_AES)
/* implemented in wolfcrypt/src/port/devcrypt/devcrypto_aes.c */ /* implemented in wolfcrypt/src/port/devcrypt/devcrypto_aes.c */
#elif defined(WOLFSSL_LINUXKM) #elif defined(WOLFSSL_LINUXKM) && defined(WOLFSSL_AESNI)
#ifdef WOLFSSL_AESNI WARN_UNUSED_RESULT int wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
__must_check int wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
{ {
int ret; int ret;
if (haveAESNI && aes->use_aesni) if (haveAESNI && aes->use_aesni)
@@ -3163,7 +3161,7 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
#define wc_AesEncryptDirect(aes, out, in) wc_AesEncrypt(aes, in, out) #define wc_AesEncryptDirect(aes, out, in) wc_AesEncrypt(aes, in, out)
#ifdef HAVE_AES_DECRYPT #ifdef HAVE_AES_DECRYPT
/* Allow direct access to one block decrypt */ /* Allow direct access to one block decrypt */
__must_check int wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in) WARN_UNUSED_RESULT int wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in)
{ {
int ret; int ret;
if (haveAESNI && aes->use_aesni) if (haveAESNI && aes->use_aesni)
@@ -3176,25 +3174,8 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
#define wc_AesDecryptDirect(aes, out, in) wc_AesDecrypt(aes, in, out) #define wc_AesDecryptDirect(aes, out, in) wc_AesDecrypt(aes, in, out)
#endif /* HAVE_AES_DECRYPT */ #endif /* HAVE_AES_DECRYPT */
#else /* !WOLFSSL_AESNI */
__must_check int wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
{
return wc_AesEncrypt(aes, in, out);
}
#define wc_AesEncryptDirect(aes, out, in) wc_AesEncrypt(aes, in, out)
#ifdef HAVE_AES_DECRYPT
/* Allow direct access to one block decrypt */
__must_check int wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in)
{
return wc_AesDecrypt(aes, in, out);
}
#define wc_AesDecryptDirect(aes, out, in) wc_AesDecrypt(aes, in, out)
#endif /* HAVE_AES_DECRYPT */
#endif /* WOLFSSL_AESNI */
#else #else
/* Allow direct access to one block encrypt */ /* Allow direct access to one block encrypt */
int wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in) int wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
{ {