From 565a7b0aab6530f256a95619ed4d879a7e6ec7c9 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Fri, 21 Jan 2022 16:32:00 -0600 Subject: [PATCH] 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) --- wolfcrypt/src/aes.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index e4bb58c4b..1712aaae9 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -3142,11 +3142,9 @@ int wc_AesSetIV(Aes* aes, const byte* iv) #elif defined(WOLFSSL_DEVCRYPTO_AES) /* implemented in wolfcrypt/src/port/devcrypt/devcrypto_aes.c */ - #elif defined(WOLFSSL_LINUXKM) + #elif defined(WOLFSSL_LINUXKM) && defined(WOLFSSL_AESNI) - #ifdef WOLFSSL_AESNI - - __must_check int wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in) + WARN_UNUSED_RESULT int wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in) { int ret; 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) #ifdef HAVE_AES_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; 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) #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 + /* Allow direct access to one block encrypt */ int wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in) {