From nobody Tue Dec 5 18:27:31 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Sl8CS0dqfz53J4g; Tue, 5 Dec 2023 18:27:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Sl8CS073zz3Yvh; Tue, 5 Dec 2023 18:27:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701800852; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IqIq1SDqK58FTcBGdtiMaq8pipmUvrSLiHQfU7XPYfA=; b=cnpbtyzDeD53KzfVC4vZbzDienzCvuQc3xxnMbB3JtPEtxsoElq7kmnU9lYrsDN9Uxxzd+ 9lk9/xFh8fdV7SBXY8oHUQGtYu20zo9THz0QS6dO2bVfPdlKjQIzv4xzE482k1v9g9YQoj Hg3LkxB+0qflc9CKcMi4CidYts5/B4zr/jP7/ZeUS49qYNjKhCDaEbyIbZTkU+NDCMkrNh Hqx6sA08MHov5mC68YLO9wc8igatAH/aUVl22Tx64YJHQU0ySLpQQf4+VpqkJG3+rnvxQ7 aSOeFwJF5LHWihyzXnIdEM4bbEDXr6f9gmjX4hvkpDCGLORPlbacOScxvHkrGw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1701800852; a=rsa-sha256; cv=none; b=YtbpDmHxvcNNTcvwkQQ1nCoECSY2xwsUpmwFY9k9A2u+rKEtKjJAPUFIHDaBzI4SjLNsBW lRVrmZKQQ6CyYsk3zwB/FYvR7wOid5+OnfzkXhXhFnVMleHzJ7GvPmZErtvCjeuFi83ygv 2vwpkTOBSYnp44ILc7dn1NHA3HKPf7ldVySzGp9OWRYRnIX2HIe3dHO5pmX1Rv0ev90VoG 3Mz0JguZtg0qTf1fM3988tlVrqGPDPzNGtaiDaZzci5N/9+D/NK96kLfwNayt+wwexk9fF c0FmKZyh0EKd9XnIrshmO5PK2oWTZ4tfsV0vC9PAa+xQARFeUCnOJQcPFzxk7A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701800852; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IqIq1SDqK58FTcBGdtiMaq8pipmUvrSLiHQfU7XPYfA=; b=nI7gEMeffwRx40PJLi2wDqBYaBy9UZYL9klNwMnpiyqSpkhA9F6h7QLwDKYZDiBMaXElw6 7723S2BA/41kz77FRBA696ZymMBK88SOkrpFLyXf/WCRjwbLxdqYaZ8hIH0BF+xaDlKWb7 I2ivf6N6QM0zPkPg7Dz6T5fzzdem1+MoDmmY4p7VqCtwEQCHUT3fwotU5OFB4DD6NAti79 kxfi+Z+5uKVaASPxYiKlbZWY2lifS3eHPsqgjQZDWbWzoLbUUuKdOgx5TDbUd1dnAui/Gw bmrFyJNAdARjBGoK4fdXogm+sMBdv8KWW8ozHnPV2Advdlf/H1W/ZKuQn5jkaw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Sl8CR6LKzz59v; Tue, 5 Dec 2023 18:27:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3B5IRVSX009140; Tue, 5 Dec 2023 18:27:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3B5IRVOf009137; Tue, 5 Dec 2023 18:27:31 GMT (envelope-from git) Date: Tue, 5 Dec 2023 18:27:31 GMT Message-Id: <202312051827.3B5IRVOf009137@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 7e9e6d5d491c - releng/14.0 - ossl: Fix handling of separate AAD buffers in ossl_aes_gcm() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/14.0 X-Git-Reftype: branch X-Git-Commit: 7e9e6d5d491cd844677331980cc2ea92b9130ed1 Auto-Submitted: auto-generated The branch releng/14.0 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7e9e6d5d491cd844677331980cc2ea92b9130ed1 commit 7e9e6d5d491cd844677331980cc2ea92b9130ed1 Author: Mark Johnston AuthorDate: 2023-11-28 19:35:49 +0000 Commit: Mark Johnston CommitDate: 2023-12-04 14:01:24 +0000 ossl: Fix handling of separate AAD buffers in ossl_aes_gcm() Consumers may optionally provide a reference to a separate buffer containing AAD, but ossl_aes_gcm() didn't handle this and would thus compute an incorrect digest. Fixes: 9a3444d91c70 ("ossl: Add a VAES-based AES-GCM implementation for amd64") Reviewed by: jhb MFC after: 3 days Sponsored by: Klara, Inc. Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D42736 Approved by: so Security: FreeBSD-EN-23:17.ossl (cherry picked from commit 87826c87c63b2995cb69e9c1a624c7e20dd70fcd) (cherry picked from commit 24cd42aeb6232b4678f45dc6d242e8982dbea8e6) --- sys/crypto/openssl/ossl_aes.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/sys/crypto/openssl/ossl_aes.c b/sys/crypto/openssl/ossl_aes.c index 84d694a7199f..40162b6943df 100644 --- a/sys/crypto/openssl/ossl_aes.c +++ b/sys/crypto/openssl/ossl_aes.c @@ -199,14 +199,20 @@ ossl_aes_gcm(struct ossl_session_cipher *s, struct cryptop *crp, crypto_read_iv(crp, iv); ctx->ops->setiv(ctx, iv, csp->csp_ivlen); - crypto_cursor_init(&cc_in, &crp->crp_buf); - crypto_cursor_advance(&cc_in, crp->crp_aad_start); - for (size_t alen = crp->crp_aad_length; alen > 0; alen -= seglen) { - inseg = crypto_cursor_segment(&cc_in, &inlen); - seglen = MIN(alen, inlen); - if (ctx->ops->aad(ctx, inseg, seglen) != 0) + if (crp->crp_aad != NULL) { + if (ctx->ops->aad(ctx, crp->crp_aad, crp->crp_aad_length) != 0) return (EINVAL); - crypto_cursor_advance(&cc_in, seglen); + } else { + crypto_cursor_init(&cc_in, &crp->crp_buf); + crypto_cursor_advance(&cc_in, crp->crp_aad_start); + for (size_t alen = crp->crp_aad_length; alen > 0; + alen -= seglen) { + inseg = crypto_cursor_segment(&cc_in, &inlen); + seglen = MIN(alen, inlen); + if (ctx->ops->aad(ctx, inseg, seglen) != 0) + return (EINVAL); + crypto_cursor_advance(&cc_in, seglen); + } } crypto_cursor_init(&cc_in, &crp->crp_buf);