From patchwork Wed Mar 8 17:18:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juliusz Sosinowicz X-Patchwork-Id: 1754267 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=S5ivcuzF; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PWzdw40kdz1yWs for ; Thu, 9 Mar 2023 04:22:28 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ju+ikVeI/dkfk+NuVa7zrpyrhpuV12jDCZpDVbgVLK4=; b=S5ivcuzFpS7a2G n29kGVWVgcRzAyCENeNsGxw9UGttm+TvBnHaERkpCyGe/VyZmUKJSuDYjdOAqzwTPnqTcY4Eg7BZs kRuTioooaAjQNsplyzxSUifI3pn+UPk70WnpH5twhh4am0kAupPUMJJ5Mw/Oe2yiE+F+2vIn2rVPk Eusnq3m4q1CfR+rFpLM02QnI1qfbGZa0yc1n8oVrfT3s93P21BM+7FYYObpwwMHKGRIVOj5OWYoq5 JRfyLDKvTpTDQrO4u8e6VpIpe1niHrbxt9O1oB1aqAeMVg2JcHM0iCOgpLpEb1sHlAXVArXH0Pwct JnODT1BKyCqM91fZMs8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZxTt-0068E6-2I; Wed, 08 Mar 2023 17:21:37 +0000 Received: from p3plsmtpa07-08.prod.phx3.secureserver.net ([173.201.192.237]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZxSV-0067d6-Fz for hostap@lists.infradead.org; Wed, 08 Mar 2023 17:20:12 +0000 Received: from localhost.localdomain ([188.212.135.159]) by :SMTPAUTH: with ESMTPSA id ZxRlp2I9XoJ9VZxSUpM65n; Wed, 08 Mar 2023 10:20:11 -0700 X-CMAE-Analysis: v=2.4 cv=fvwaJn0f c=1 sm=1 tr=0 ts=6408c3cb a=3NKXlI4tpxak3Hs97VqeiA==:117 a=3NKXlI4tpxak3Hs97VqeiA==:17 a=VTTltBjBAAAA:8 a=UJmqBA65KaEb8WzTDs4A:9 a=on_vo79ac8RWgsiwd8Ea:22 X-SECURESERVER-ACCT: juliusz@wolfssl.com From: Juliusz Sosinowicz To: hostap@lists.infradead.org Cc: Juliusz Sosinowicz Subject: [PATCH 09/12] wolfssl: improve error checking and logging in aes functions Date: Wed, 8 Mar 2023 18:18:47 +0100 Message-Id: <20230308171850.267577-9-juliusz@wolfssl.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230308171850.267577-1-juliusz@wolfssl.com> References: <20230308171850.267577-1-juliusz@wolfssl.com> MIME-Version: 1.0 X-CMAE-Envelope: MS4xfJxtL7te/rYjcKd24NiT3yciIVUDtxSo1jH18iNmp0Af7tVeDvgjW/euBDQd/uZJ5INDKdUv+EF2eA7qGL8/v6HjmjozQZByit51LcibZYaje1Q8EIUo 5glCcgiNWxDktR88zklmM2nG6sblu7s9TelIWbiFOohLq8ZxTkuYXw1AZFgoWnBFow3P1B6cP6Oh2YTkwbwus02CAuJIIsDyNhA7xAjPdgYQ87xlvsukXGoC X2fVaVE/Ss712K8eMr2nFg== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230308_092011_570249_27202E96 X-CRM114-Status: GOOD ( 10.39 ) X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Signed-off-by: Juliusz Sosinowicz --- src/crypto/crypto_wolfssl.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/crypto/crypto_wolfssl.c b/src/crypto/crypto_wolfssl.c index 62eeee6a4..14576a98d 100644 --- a/src/crypto/crypto_wolfssl.c +++ b/src/crypto/crypto_wolfssl.c @@ -453,15 +453,20 @@ int d [...] Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [173.201.192.237 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [173.201.192.237 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Signed-off-by: Juliusz Sosinowicz --- src/crypto/crypto_wolfssl.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/crypto/crypto_wolfssl.c b/src/crypto/crypto_wolfssl.c index 62eeee6a4..14576a98d 100644 --- a/src/crypto/crypto_wolfssl.c +++ b/src/crypto/crypto_wolfssl.c @@ -453,15 +453,20 @@ int des_encrypt(const u8 *clear, const u8 *key, u8 *cypher) void * aes_encrypt_init(const u8 *key, size_t len) { Aes *aes; + int err; if (TEST_FAIL()) return NULL; aes = os_malloc(sizeof(Aes)); - if (!aes) + if (!aes) { + LOG_WOLF_ERROR_FUNC_NULL(os_malloc); return NULL; + } - if (wc_AesSetKey(aes, key, len, NULL, AES_ENCRYPTION) < 0) { + err = wc_AesSetKey(aes, key, len, NULL, AES_ENCRYPTION); + if (err < 0) { + LOG_WOLF_ERROR_FUNC(wc_AesSetKey, err); os_free(aes); return NULL; } @@ -472,7 +477,11 @@ void * aes_encrypt_init(const u8 *key, size_t len) int aes_encrypt(void *ctx, const u8 *plain, u8 *crypt) { - wc_AesEncryptDirect(ctx, crypt, plain); + int err = wc_AesEncryptDirect(ctx, crypt, plain); + if (err != 0) { + LOG_WOLF_ERROR_FUNC(wc_AesEncryptDirect, err); + return -1; + } return 0; } @@ -486,15 +495,20 @@ void aes_encrypt_deinit(void *ctx) void * aes_decrypt_init(const u8 *key, size_t len) { Aes *aes; + int err; if (TEST_FAIL()) return NULL; aes = os_malloc(sizeof(Aes)); - if (!aes) + if (!aes) { + LOG_WOLF_ERROR_FUNC_NULL(os_malloc); return NULL; + } - if (wc_AesSetKey(aes, key, len, NULL, AES_DECRYPTION) < 0) { + err = wc_AesSetKey(aes, key, len, NULL, AES_DECRYPTION); + if (err < 0) { + LOG_WOLF_ERROR_FUNC(wc_AesSetKey, err); os_free(aes); return NULL; } @@ -505,7 +519,11 @@ void * aes_decrypt_init(const u8 *key, size_t len) int aes_decrypt(void *ctx, const u8 *crypt, u8 *plain) { - wc_AesDecryptDirect(ctx, plain, crypt); + int err = wc_AesDecryptDirect(ctx, plain, crypt); + if (err != 0) { + LOG_WOLF_ERROR_FUNC(wc_AesDecryptDirect, err); + return -1; + } return 0; }