From nobody Fri Apr 22 22:55:22 2022 X-Original-To: dev-commits-src-all@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 1592D1997902; Fri, 22 Apr 2022 22:55:23 +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 4KlV9k6R6pz4pNT; Fri, 22 Apr 2022 22:55:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650668123; 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=o2HIcqpr5XxDAzvYgj4dtL7DQ4p2QbYy7NUBb1qStt4=; b=whkKt+165MCWnFK/tY21LJr8P1KW/5nLXQdABCL76CQp4dCO4WbHgLd3SgUOBkWndoghs9 5IJWAr3Z8ak5RZ/GGO847/39YsGpN/FwVYdrjoLot79rIa7DOUIKqZA+fzp9ed+LSRFg4y EZjUxQkMsbNrJS23d8Lv8Buaf4mF80crHMyvlTZa+V2WtzzlFvLc+OO8TTyAyd8PA5GQp5 q6IP4mZAmi4NpY3nCvGc/tXVHxTxtfde8wAp24HCsugHDIbEb/mQfg7PGKQNBno+Ds5BKs m0YrZHn3uo1kjrOpr+rDQbvvYXWp0WWb79ruJGI43yAFMW/CWQl5GyugS83ppQ== 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 B95E826079; Fri, 22 Apr 2022 22:55:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23MMtM4e093238; Fri, 22 Apr 2022 22:55:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23MMtMYF093237; Fri, 22 Apr 2022 22:55:22 GMT (envelope-from git) Date: Fri, 22 Apr 2022 22:55:22 GMT Message-Id: <202204222255.23MMtMYF093237@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 663ae8f7f949 - main - KTLS: Construct IV directly in crp.crp_iv for TLS 1.3 AEAD encryption. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 663ae8f7f949b4d4fc0c91d8e9b2a01f56e40dc5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650668123; 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=o2HIcqpr5XxDAzvYgj4dtL7DQ4p2QbYy7NUBb1qStt4=; b=gqtfukbvFfxJo/r8D16CdaLAu/zriRbktHPODVh8e9lRqkiTqT6UnpoldO5mEqkp+D7FV6 f65YzOjcqaK4p86stiFu/b74cugFurP3zw6i2BMlnJrSILDg7kavUvb8nYXSh1O298+Rl/ JIdk+qbRThqXgCFN9fwLIho6iQOJE68BHq1F7VdwH8a1A5kRA4gujjEkIHX/EKsPI0Nqyy Q6kdspXD+cUsqZWt0lL19tOJIeVF6LR1al4b5jBQqYJ2jC5K0tIXOOglnNriG7CQHLY3fv V3xFWlU53k2jXtbxkY84rL4Q/TdPACuenAjAPwdpCzRv2vzpwe3s3nLQWRhWcA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1650668123; a=rsa-sha256; cv=none; b=GuxW6L6qs49d68uTx7TFfZnHF3VWRlTawkqpMTWyfUYWXXMGGm/S0rbLG8mqAxg348e1RZ er+iMdX2UJyrwSA6Te+eEmKD78fvwQTiSUGiyPue3LWgWyp9a6wGpvxg9sgo8noN+jlJPY EF8EMNFjwV75yVfd6EX9wcLx4sGziLBXkViNPpq4kijifB4uAciOYBi+kUqX5kXVi1lMBb /P1I/8IMB4sTvKdLJkYbsBDWsnpo8280O9PK9o/OVx5CLWqWn0Ujcb6N7L4rwbD6A9sLdF w9J2f1Pso5f43JWowuvtOKMquxLv4lRTjIx8k+RjLym6leOtbyeEg6IixuqfMw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=663ae8f7f949b4d4fc0c91d8e9b2a01f56e40dc5 commit 663ae8f7f949b4d4fc0c91d8e9b2a01f56e40dc5 Author: John Baldwin AuthorDate: 2022-04-22 22:52:27 +0000 Commit: John Baldwin CommitDate: 2022-04-22 22:52:27 +0000 KTLS: Construct IV directly in crp.crp_iv for TLS 1.3 AEAD encryption. Previously this used a temporary nonce[] buffer. The decrypt hook for TLS 1.3 as well as the hooks for TLS 1.2 already constructed the IV directly in crp.crp_iv. Reviewed by: hselasky Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D35027 --- sys/opencrypto/ktls_ocf.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sys/opencrypto/ktls_ocf.c b/sys/opencrypto/ktls_ocf.c index 575a91f9fe3f..3b330bf7061c 100644 --- a/sys/opencrypto/ktls_ocf.c +++ b/sys/opencrypto/ktls_ocf.c @@ -564,7 +564,6 @@ ktls_ocf_tls13_aead_encrypt(struct ktls_ocf_encrypt_state *state, struct tls_aead_data_13 *ad; struct cryptop *crp; struct ktls_ocf_session *os; - char nonce[12]; int error; os = tls->ocf_session; @@ -575,8 +574,8 @@ ktls_ocf_tls13_aead_encrypt(struct ktls_ocf_encrypt_state *state, crypto_initreq(crp, os->sid); /* Setup the nonce. */ - memcpy(nonce, tls->params.iv, tls->params.iv_len); - *(uint64_t *)(nonce + 4) ^= htobe64(m->m_epg_seqno); + memcpy(crp->crp_iv, tls->params.iv, tls->params.iv_len); + *(uint64_t *)(crp->crp_iv + 4) ^= htobe64(m->m_epg_seqno); /* Setup the AAD. */ ad = &state->aead13; @@ -614,8 +613,6 @@ ktls_ocf_tls13_aead_encrypt(struct ktls_ocf_encrypt_state *state, crp->crp_op = CRYPTO_OP_ENCRYPT | CRYPTO_OP_COMPUTE_DIGEST; crp->crp_flags = CRYPTO_F_CBIMM | CRYPTO_F_IV_SEPARATE; - memcpy(crp->crp_iv, nonce, sizeof(nonce)); - if (tls->params.cipher_algorithm == CRYPTO_AES_NIST_GCM_16) counter_u64_add(ocf_tls13_gcm_encrypts, 1); else