From patchwork Mon Apr 29 16:22:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "plaisthos (Code Review)" X-Patchwork-Id: 3691 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:a58b:b0:577:9287:30c5 with SMTP id hj11csp287949mab; Mon, 29 Apr 2024 09:23:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUatMnZgymMqQyvP/4r8CrGO9NqHxEGVtPNanj5GalUZiKIkYgErXMuCgteOWDUcCgsN7auMHBES8LgWD0M48F/uqvc6qc= X-Google-Smtp-Source: AGHT+IFqvDoq4ynLJbEjlja+4AQciMGJUW4KH80RBeCpl2wSOiO3CqSMZ24PEGJ8rlnC8/LFCSwn X-Received: by 2002:a17:90a:d081:b0:2ac:69b:886b with SMTP id k1-20020a17090ad08100b002ac069b886bmr10516454pju.1.1714407796734; Mon, 29 Apr 2024 09:23:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714407796; cv=none; d=google.com; s=arc-20160816; b=lYdrjlhYoAr4PAyUgsbm1AWakS1IIud09C07lrQ1P3br6Je1i9WJpFSVet/35lIE9n eogFrcPtGkFP1djkh6ja5clLwc1oj+AFunuPXHQYl/ra+x2vCmjMjd7pYxQ/U0cMhGkg hyzQ3qdrdMn0+WA2D7SpGMLHAAD5mIsEyw6vNX5zxqP1DyflQSHEF1nq4fEcE4UxG8t9 VqDkidPXn05074VKCrZUgFymIMtEpoehhc2y9koXrwQRmZYMdop/uFO8pLAyI9KtAKNr yLPBG+exme/iQY3Fpf/ExWz6iaWkK+N6DjGpOdAzo1NbqR3Arq/3iBIv8Sqjtjs08wqL ZgVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:user-agent :mime-version:message-id:references:auto-submitted:to:date:from :dkim-signature:dkim-signature:dkim-signature; bh=NKRFKmtByka+X/0dLbGVTZMhCJX29DiNmgotwzp2cA4=; fh=lm0MLPW7DntlrDqRECIiC9JlE1uPxhepE0URYHIf+eE=; b=RLAJCX1ehcdQBtytjQZ/dnWgAEyDLBWizl2apZ40hUx0pPzP9rflgsgG2NTSWxGtxW 9U8q2CumscICJv+SfLlC/u6VkGREXz2O8PD11ok8+SKUL35LfXL8TqRfGukWXx/TT3i5 7HOX1FeDozBeSOSNgu37LEqyFnYhjTLm9qQPZJRMRB3Z5GSt8RuhHbx+zP01r8Mdc3I8 OvaFoa1VUPA/9Rzs05MMa1SaotArHBFjlk5FhynTNh0vp0kJqDhdDc5a+Aq01lDufGcf vwdWvGQ66MXg5rSfLTpdvrnYkvF+OBhqCKL5Qzd6BrNJvRKhy+7Y2LXDRNUBrFYRHA5I 7o7w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=UvBbLHGr; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=NNqaJq4E; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b="GBYYakz/"; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id h5-20020a17090aa88500b002a557ec4174si21661026pjq.82.2024.04.29.09.23.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Apr 2024 09:23:16 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=UvBbLHGr; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=NNqaJq4E; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b="GBYYakz/"; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.net 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.95) (envelope-from ) id 1s1TmD-0000xE-Rk; Mon, 29 Apr 2024 16:22:50 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1s1TmC-0000x7-Uu for openvpn-devel@lists.sourceforge.net; Mon, 29 Apr 2024 16:22:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Reply-To:References:Subject:List-Unsubscribe:List-Id:Cc:To:Date: From:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help: List-Subscribe:List-Post:List-Owner:List-Archive; bh=JJWoENc1WqdbjbyibkeaGfP091nKoH17rWQMSdPZ5g4=; b=UvBbLHGrN0xBCyITMizNQSwwhk dS6eajGcfNB6qWzsj4PeeoQCNgAxLzpnEha+jL4KT+KDLo6YAkUe7FAPOaYIAhU02Adh9ynbd9eqy D5ahPoEEyPh2V83Mj/9glVgO4BM9QDBTAFKfPn3mJUJMDl5JyOlvZ3u2cdv9A/Yy9DSw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Reply-To: References:Subject:List-Unsubscribe:List-Id:Cc:To:Date:From:Sender:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help:List-Subscribe:List-Post: List-Owner:List-Archive; bh=JJWoENc1WqdbjbyibkeaGfP091nKoH17rWQMSdPZ5g4=; b=N NqaJq4EVGwaoKgySJeAzFwrYL6YFp42/Ogp0Kp78bCoEhQzU54TYvliWQHZsXbsUu/U/ibpjMbso5 7NB8R9wPIEC++IbIywWzzC31kI8d69QmnbKc1owNOo6SeMZjN/ETiUN+3LRDZctfJWoyRPsTsGXUr +vFiXapP+PFuWvBY=; Received: from mail-wm1-f49.google.com ([209.85.128.49]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1s1TmB-0002ic-9L for openvpn-devel@lists.sourceforge.net; Mon, 29 Apr 2024 16:22:49 +0000 Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-41ba1ba55ffso17368775e9.1 for ; Mon, 29 Apr 2024 09:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1714407756; x=1715012556; darn=lists.sourceforge.net; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from:from:to:cc :subject:date:message-id:reply-to; bh=JJWoENc1WqdbjbyibkeaGfP091nKoH17rWQMSdPZ5g4=; b=GBYYakz/ErH7nHuuDjCuJMZFvyi74bcFHQGmBmrHqkTb/LDjcZKYhwsd4baXgKlhoZ HmH/HZ1sJiPk/9ShR5JrcXFoDsPmq+XZwNT55Rxde/eQoz2mu7MCq93MIcMTjd+P+3Fe vYZwG9v+jyTQsKEUmSP4pfhZjE1a/9DoWqr1iYttkfDfKlvydeEnXQBMe8vEtWJipLN8 xIcj/Toq/Myq2gDz6zs9zxaetsnRFy0ur264c8IbDDsMTRvJ3ov4JK+XK5NgDAPk18WK s54fFnCyCg755l5SRnKyCqJR0UC2eLdVZlU9eWESFU4EYfGiG1rmeK8SNNG+oOXk/GHZ 0wpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714407756; x=1715012556; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JJWoENc1WqdbjbyibkeaGfP091nKoH17rWQMSdPZ5g4=; b=QxflYlQUzMJ+82Bg/bBzIZbGwkecgXzXZ0nL+fWrwTBtoJ5Vbm9KxwkqEdghAuSYKB 3ib/POmsVsGlFgT+LbKHY0Ib2cpE5CwpfQCB7s/x7SWIfuJbkWxvq0s4twm7zsYLAeWC jijlqitXJG1F+DAcYDuS2olFiJ2unPUyqJ8eQPvxNH+YvE8JTnK829PGlNg5VnWkM11z PZwPaCg7ZVlqeHuEpwLfAXrVnTAy8L9aEvcRdehZMNTdIbvTsF5wYS1wF3alFNCMYQps luqQph0vQfR6Z4xFen5nfJAiaukoVHMfuXz0hf5dsaaDDgw7gWfSf1Y5L2WzOEUe/vCt XpCg== X-Gm-Message-State: AOJu0YxM6bPObRJVuk2SLrHFCk0KXk2uCVcIfOdLNFqSCsKh12d8UwW6 z/Jc012H5h4ZC4dtjcUsnZArDYsQBGU+n/gH6h7dCn60rsjuxQdzeKUgeO0RokB6KcZi6o6eLvA h X-Received: by 2002:a05:600c:4506:b0:41b:4caa:554c with SMTP id t6-20020a05600c450600b0041b4caa554cmr148016wmo.2.1714407755739; Mon, 29 Apr 2024 09:22:35 -0700 (PDT) Received: from gerrit.openvpn.in (ec2-18-159-0-78.eu-central-1.compute.amazonaws.com. [18.159.0.78]) by smtp.gmail.com with ESMTPSA id e1-20020adfef01000000b0034ccd06a6a3sm5120166wro.18.2024.04.29.09.22.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 09:22:35 -0700 (PDT) From: "plaisthos (Code Review)" X-Google-Original-From: "plaisthos (Code Review)" X-Gerrit-PatchSet: 1 Date: Mon, 29 Apr 2024 16:22:34 +0000 To: flichtenheld Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: I5bfa3630ad4dff2807705658bc877c4a429a39ce X-Gerrit-Change-Number: 560 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: a01e87011e8495fa57eaf865f4c65fc69ba41148 References: Message-ID: MIME-Version: 1.0 User-Agent: Gerrit/3.8.2 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", 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: Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: openvpn.net] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.49 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 WEIRD_PORT URI: Uses non-standard port number for HTTP 0.0 HTML_MESSAGE BODY: HTML included in message 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML X-Headers-End: 1s1TmB-0002ic-9L Subject: [Openvpn-devel] [M] Change in openvpn[master]: Remove custom TLS 1.0 PRF implementation only used by LibreSSL 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: , Reply-To: arne-openvpn@rfc2549.org, openvpn-devel@lists.sourceforge.net, frank@lichtenheld.com Cc: openvpn-devel Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1797686869695363723?= X-GMAIL-MSGID: =?utf-8?q?1797686869695363723?= X-getmail-filter-classifier: gerrit message type newchange Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/560?usp=email to review the following change. Change subject: Remove custom TLS 1.0 PRF implementation only used by LibreSSL ...................................................................... Remove custom TLS 1.0 PRF implementation only used by LibreSSL After the removal of the OpenSSL 1.0.2 support, LibreSSL is the only library that still needs the custom implementation. Since our LibreSSL support is always best effort, we can afford to limit LibreSSL support in this way. Change-Id: I5bfa3630ad4dff2807705658bc877c4a429a39ce Signed-off-by: Arne Schwabe --- M src/openvpn/crypto_openssl.c 1 file changed, 4 insertions(+), 173 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/60/560/1 diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c index 64ad346..8256cce 100644 --- a/src/openvpn/crypto_openssl.c +++ b/src/openvpn/crypto_openssl.c @@ -1419,183 +1419,14 @@ return ret; } #else /* if defined(LIBRESSL_VERSION_NUMBER) */ -/* - * Generate the hash required by for the \c tls1_PRF function. - * - * We cannot use our normal hmac_* function as they do not work - * in a FIPS environment (no MD5 allowed, which we need). Instead - * we need to directly use the EVP_MD_* API with the special - * EVP_MD_CTX_FLAG_NON_FIPS_ALLOW flag. - * - * The function below is adapted from OpenSSL 1.0.2t - * - * @param md_kt Message digest to use - * @param sec Secret to base the hash on - * @param sec_len Length of the secret - * @param seed Seed to hash - * @param seed_len Length of the seed - * @param out Output buffer - * @param olen Length of the output buffer - */ -static -bool -tls1_P_hash(const EVP_MD *md, const unsigned char *sec, - int sec_len, const void *seed, int seed_len, - unsigned char *out, int olen) -{ - int chunk; - size_t j; - EVP_MD_CTX *ctx, *ctx_tmp, *ctx_init; - EVP_PKEY *mac_key; - unsigned char A1[EVP_MAX_MD_SIZE]; - size_t A1_len = EVP_MAX_MD_SIZE; - int ret = false; - - chunk = EVP_MD_size(md); - OPENSSL_assert(chunk >= 0); - - ctx = md_ctx_new(); - ctx_tmp = md_ctx_new(); - ctx_init = md_ctx_new(); - EVP_MD_CTX_set_flags(ctx_init, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW); - mac_key = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, sec, sec_len); - if (!mac_key) - { - goto err; - } - if (!EVP_DigestSignInit(ctx_init, NULL, md, NULL, mac_key)) - { - goto err; - } - if (!EVP_MD_CTX_copy_ex(ctx, ctx_init)) - { - goto err; - } - if (!EVP_DigestSignUpdate(ctx, seed, seed_len)) - { - goto err; - } - if (!EVP_DigestSignFinal(ctx, A1, &A1_len)) - { - goto err; - } - - for (;; ) - { - /* Reinit mac contexts */ - if (!EVP_MD_CTX_copy_ex(ctx, ctx_init)) - { - goto err; - } - if (!EVP_DigestSignUpdate(ctx, A1, A1_len)) - { - goto err; - } - if (olen > chunk && !EVP_MD_CTX_copy_ex(ctx_tmp, ctx)) - { - goto err; - } - if (!EVP_DigestSignUpdate(ctx, seed, seed_len)) - { - goto err; - } - - if (olen > chunk) - { - j = olen; - if (!EVP_DigestSignFinal(ctx, out, &j)) - { - goto err; - } - out += j; - olen -= j; - /* calc the next A1 value */ - if (!EVP_DigestSignFinal(ctx_tmp, A1, &A1_len)) - { - goto err; - } - } - else - { - A1_len = EVP_MAX_MD_SIZE; - /* last one */ - if (!EVP_DigestSignFinal(ctx, A1, &A1_len)) - { - goto err; - } - memcpy(out, A1, olen); - break; - } - } - ret = true; -err: - EVP_PKEY_free(mac_key); - EVP_MD_CTX_free(ctx); - EVP_MD_CTX_free(ctx_tmp); - EVP_MD_CTX_free(ctx_init); - OPENSSL_cleanse(A1, sizeof(A1)); - return ret; -} - -/* - * Use the TLS PRF function for generating data channel keys. - * This code is based on the OpenSSL library. - * - * TLS generates keys as such: - * - * master_secret[48] = PRF(pre_master_secret[48], "master secret", - * ClientHello.random[32] + ServerHello.random[32]) - * - * key_block[] = PRF(SecurityParameters.master_secret[48], - * "key expansion", - * SecurityParameters.server_random[32] + - * SecurityParameters.client_random[32]); - * - * Notes: - * - * (1) key_block contains a full set of 4 keys. - * (2) The pre-master secret is generated by the client. - */ +/* LibreSSL does not expose a TLS 1.0/1.1 PRF via the same APIs as + * OpenSSL does. As result LibreSSL will only be able to support + * peers that support TLS EKM like when running with OpenSSL 3.x FIPS */ bool ssl_tls1_PRF(const uint8_t *label, int label_len, const uint8_t *sec, int slen, uint8_t *out1, int olen) { - bool ret = true; - struct gc_arena gc = gc_new(); - /* For some reason our md_get("MD5") fails otherwise in the unit test */ - const EVP_MD *md5 = EVP_md5(); - const EVP_MD *sha1 = EVP_sha1(); - - uint8_t *out2 = (uint8_t *)gc_malloc(olen, false, &gc); - - int len = slen/2; - const uint8_t *S1 = sec; - const uint8_t *S2 = &(sec[len]); - len += (slen&1); /* add for odd, make longer */ - - if (!tls1_P_hash(md5, S1, len, label, label_len, out1, olen)) - { - ret = false; - goto done; - } - - if (!tls1_P_hash(sha1, S2, len, label, label_len, out2, olen)) - { - ret = false; - goto done; - } - - for (int i = 0; i < olen; i++) - { - out1[i] ^= out2[i]; - } - - secure_memzero(out2, olen); - - dmsg(D_SHOW_KEY_SOURCE, "tls1_PRF out[%d]: %s", olen, format_hex(out1, olen, 0, &gc)); -done: - gc_free(&gc); - return ret; + return false; } #endif /* if LIBRESSL_VERSION_NUMBER */ #endif /* ENABLE_CRYPTO_OPENSSL */