[PATCH] wolfSSL: Old fips APIs have void return

Juliusz Sosinowicz juliusz at wolfssl.com
Thu Mar 23 08:58:50 PDT 2023


This patch is intended to be applied on top of the previous patchset I submitted.

Fix the calls to wc_AesEncryptDirect. Old versions of wolfCrypt fips had wc_AesEncryptDirect return void instead of int. This patch fixes this build issue.

Signed-off-by: Juliusz Sosinowicz <juliusz at wolfssl.com>
---
 src/crypto/crypto_wolfssl.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/crypto/crypto_wolfssl.c b/src/crypto/crypto_wolfssl.c
index 52f4c70c6..20e922da5 100644
--- a/src/crypto/crypto_wolfssl.c
+++ b/src/crypto/crypto_wolfssl.c
@@ -566,11 +566,17 @@ void * aes_encrypt_init(const u8 *key, size_t len)
 
 int aes_encrypt(void *ctx, const u8 *plain, u8 *crypt)
 {
+#if defined(HAVE_FIPS) && \
+    (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION <= 2))
+	/* Old fips has void return on this API */
+	wc_AesEncryptDirect(ctx, crypt, plain);
+#else
 	int err = wc_AesEncryptDirect(ctx, crypt, plain);
 	if (err != 0) {
 		LOG_WOLF_ERROR_FUNC(wc_AesEncryptDirect, err);
 		return -1;
 	}
+#endif
 	return 0;
 }
 
@@ -608,11 +614,17 @@ void * aes_decrypt_init(const u8 *key, size_t len)
 
 int aes_decrypt(void *ctx, const u8 *crypt, u8 *plain)
 {
+#if defined(HAVE_FIPS) && \
+    (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION <= 2))
+	/* Old fips has void return on this API */
+	wc_AesDecryptDirect(ctx, plain, crypt);
+#else
 	int err = wc_AesDecryptDirect(ctx, plain, crypt);
 	if (err != 0) {
 		LOG_WOLF_ERROR_FUNC(wc_AesDecryptDirect, err);
 		return -1;
 	}
+#endif
 	return 0;
 }
 
-- 
2.25.1




More information about the Hostap mailing list