From patchwork Mon Aug 9 20:16:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Fillinger X-Patchwork-Id: 1907 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director10.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id uDtdBPgdEmGgdAAAIUCqbw (envelope-from ) for ; Tue, 10 Aug 2021 02:34:32 -0400 Received: from proxy12.mail.iad3b.rsapps.net ([172.31.255.6]) by director10.mail.ord1d.rsapps.net with LMTP id YEnuA/gdEmGbCgAApN4f7A (envelope-from ) for ; Tue, 10 Aug 2021 02:34:32 -0400 Received: from smtp17.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy12.mail.iad3b.rsapps.net with LMTPS id iN6LOvcdEmEOCwAAEsW3lA (envelope-from ) for ; Tue, 10 Aug 2021 02:34:31 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp17.gate.iad3b.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (key not found in DNS) header.d=foxcrypto.com; dmarc=fail (p=none; dis=none) header.from=foxcrypto.com X-Suspicious-Flag: YES X-Classification-ID: 04c36924-f9a5-11eb-acc4-52540094e46f-1-1 Received: from [216.105.38.7] ([216.105.38.7:41868] helo=lists.sourceforge.net) by smtp17.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id E1/58-22984-7FD12116; Tue, 10 Aug 2021 02:34:31 -0400 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1mDLKF-0004eU-H9; Tue, 10 Aug 2021 06:33:23 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDLKE-0004eH-CS for openvpn-devel@lists.sourceforge.net; Tue, 10 Aug 2021 06:33:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:MIME-Version:Message-ID:Date:Subject: CC:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=erxaI9cBqhBnrdwzln5KJeyeyoORLonb3lYFIhZxQYM=; b=d5D8IZDIRAJ9ee12s2/4DLxIXz WPC8XQUi19hAeqRtCieIlsr+5l1F69oRc4quUgFpBRnHFmKXY3YQ6m3w7U5GYajC2l1Ke9K+/OllF Z6nBJNGLYwM06P+cMElfUq2Vk5gbKMrXtf2Z2c6Y5YL+FFPcUB37MV6x1WAQdYy7BNhw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From:Sender: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=erxaI9cBqhBnrdwzln5KJeyeyoORLonb3lYFIhZxQYM=; b=I bFAOmcmZavjrMkeoqXUIMPLaSvE96sUshSsxNta6xPDx4QETF1Uq6JceLkhfa4gGq34DZnUHadhx1 3FKHi0q329vdNVL0feV7MsyUUF8fBt2B8ztwTyzzvQt5pSdK6G9j77LcIhArEnoCxJO8hrVh2b8DL du/rkCfrLaTq0jh8=; Received: from nl-dft-mx-01.fox-it.com ([178.250.144.135]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1mDLK5-0000Iu-Cr for openvpn-devel@lists.sourceforge.net; Tue, 10 Aug 2021 06:33:22 +0000 From: Max Fillinger To: Date: Tue, 10 Aug 2021 08:16:44 +0200 Message-ID: <20210810061644.20353-1-maximilian.fillinger@foxcrypto.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-ClientProxiedBy: FOXDFT1EX01.FOX.local (10.0.0.129) To FOXDFT1EX01.FOX.local (10.0.0.129) X-FE-Policy-ID: 13:3:2:SYSTEM DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; d=foxcrypto.com; s=NL-DFT-MX-01; c=relaxed/relaxed; h=from:to:cc:subject:date:message-id:mime-version:content-type; bh=erxaI9cBqhBnrdwzln5KJeyeyoORLonb3lYFIhZxQYM=; b=FY/yHyYCeSgSUrBA/Q73KDP8wPw5lHy9MVN7fErldA3DSPLl4+8RweQZ+KLrI5CMuNij+sA3IILL 5NZmH6dnHlcZ5O++ePumt0n6qm6yzcyczm9VP4Fi/CYdp7SjGSZid49gxhFQ1zFcDuEGlKGVs25h HJT1KLfrOvg6WxnACsnca7ZDfrIppuqSfVIqmYC8tjlmQheRsRFiSGu5a4FGETGHL+pM3h+ixYty rJvAAbiyMknLImIlAAknMlIAX5kre5aAyd6Gll0vhnTwcVJhWgnsWzdVND3eNh/xt9tpAlG9mVaA eD1RRT1Jikd2PQ3FU6pkoixMK22m/WkL5zspfg== X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.1 DKIM_INVALID DKIM or DK signature exists, but is not valid X-Headers-End: 1mDLK5-0000Iu-Cr Subject: [Openvpn-devel] [PATCH] Replace deprecated mbedtls DRBG update function X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox The function mbedtls_ctr_drbg_update is deprecated as of mbedtls 2.16 and is superseded by mbedtls_ctr_drbg_update_ret, which returns an error code. This commit replaces the call to the deprecated function with the new one and logs a warning in case of an error. For older versions of mbedtls, we add a compatibility function that runs mbedtls_ctr_drbg_update and returns 0. Signed-off-by: Max Fillinger Acked-By: Arne Schwabe Acked-by: Antonio Quartulli --- src/openvpn/ssl_mbedtls.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/openvpn/ssl_mbedtls.c b/src/openvpn/ssl_mbedtls.c index 265ea36f..1853335e 100644 --- a/src/openvpn/ssl_mbedtls.c +++ b/src/openvpn/ssl_mbedtls.c @@ -62,6 +62,21 @@ #include #include +/** + * Compatibility: mbedtls_ctr_drbg_update was deprecated in mbedtls 2.16 and + * replaced with mbedtls_ctr_drbg_update_ret, which returns an error code. + * For older versions, we call mbedtls_ctr_drbg_update and return 0 (success). + */ +#if MBEDTLS_VERSION_NUMBER < 0x02100000 +static int mbedtls_ctr_drbg_update_ret(mbedtls_ctr_drbg_context *ctx, + const unsigned char *additional, + size_t add_len) +{ + mbedtls_ctr_drbg_update(ctx, additional, add_len); + return 0; +} +#endif + static const mbedtls_x509_crt_profile openvpn_x509_crt_profile_legacy = { /* Hashes from SHA-1 and above */ @@ -950,7 +965,10 @@ tls_ctx_personalise_random(struct tls_root_ctx *ctx) if (0 != memcmp(old_sha256_hash, sha256_hash, sizeof(sha256_hash))) { - mbedtls_ctr_drbg_update(cd_ctx, sha256_hash, 32); + if (!mbed_ok(mbedtls_ctr_drbg_update_ret(cd_ctx, sha256_hash, 32))) + { + msg(M_WARN, "WARNING: failed to personalise random, could not update CTR_DRBG"); + } memcpy(old_sha256_hash, sha256_hash, sizeof(old_sha256_hash)); } }