From nobody Fri Dec 17 22:00:10 2021 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 5CD8318F5D18; Fri, 17 Dec 2021 22:00:11 +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 4JG2wB6wC9z3t4s; Fri, 17 Dec 2021 22:00:10 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 C789E235DD; Fri, 17 Dec 2021 22:00:10 +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 1BHM0AcG006651; Fri, 17 Dec 2021 22:00:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BHM0AMa006642; Fri, 17 Dec 2021 22:00:10 GMT (envelope-from git) Date: Fri, 17 Dec 2021 22:00:10 GMT Message-Id: <202112172200.1BHM0AMa006642@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: 04781697f8e6 - main - cryptosoft: Use POLY1305_BLOCK_LEN instead of a magic number. 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: 04781697f8e675528078249ff79c3e948a95b7c9 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639778411; 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=4hQZUXhkVSye5NWAQzBzIkCi8eXAL782/+tr0jeNYlE=; b=AEaQUEoakR/qN92A5NDj7bqAp87nJxHaxtHq+Rm2V6M/9WbaMTmCqL9E7i03Wt3YN1PxPc UHwussnxJAems5QgM5ZTHrQq5TclNxdSNBgyqZvoRhdV6/56Ak/uGd9bI6sdNvxPM4iQ6R TP4B90hijaj7D8OjnQnTzH9yYhaN9j6XqEZyNCvVP94VHLmX+61u64fU9KDI219aXboSjM kSwwkn084ZzCE4fTRwnVfy67qdNT0MpitKr2GiBYO66yrD/N1TITeaeUgoBUrahrHHN3J+ ApEXdUf2SPnt4is6q7mxI/7K6+m1CMwpK9zxPKREuJkmcnOYm+JKf2XZ5BeiYA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639778411; a=rsa-sha256; cv=none; b=XgbEb0Oym18sHDsfPbVkqHgzdOtM9/tpz1kBZGrqd3jpadPtRB7Fkpm+kDJzgzYq6T3od+ AcSB/RdDwv54lf3fop/RxL+A4mNJlhhyrFVlAH2k6XuV3y6y9DPPAfzcF+NRPz/Be4pLEP bFnU9fGi9ZVi8+8vnEv6iVjEe/wrtidXv0DvLqWX0pRHcL1GrgMXA+e9ETgonH5Adcjo1G cxo1dHs1aqOO5WO+tI1CnCnuVox8pZ8pL8vf46CO/QHW81HAxLRZJN+EvOZ4V2VT6+4OB2 d7fWrF9A8z5OJ8WZwLW5Eam+gjR+1w6qVYabWRnm83AxJM5/L6I8qNeI1rQMRQ== 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=04781697f8e675528078249ff79c3e948a95b7c9 commit 04781697f8e675528078249ff79c3e948a95b7c9 Author: John Baldwin AuthorDate: 2021-12-17 21:58:59 +0000 Commit: John Baldwin CommitDate: 2021-12-17 21:58:59 +0000 cryptosoft: Use POLY1305_BLOCK_LEN instead of a magic number. Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33528 --- sys/opencrypto/cryptosoft.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sys/opencrypto/cryptosoft.c b/sys/opencrypto/cryptosoft.c index 0cc4e56550f3..430c8c12bf1e 100644 --- a/sys/opencrypto/cryptosoft.c +++ b/sys/opencrypto/cryptosoft.c @@ -894,10 +894,11 @@ swcr_chacha20_poly1305(const struct swcr_session *ses, struct cryptop *crp) else crypto_apply(crp, crp->crp_aad_start, crp->crp_aad_length, exf->update, ctx); - if (crp->crp_aad_length % 16 != 0) { + if (crp->crp_aad_length % POLY1305_BLOCK_LEN != 0) { /* padding1 */ - memset(blk, 0, 16); - exf->update(ctx, blk, 16 - crp->crp_aad_length % 16); + memset(blk, 0, POLY1305_BLOCK_LEN); + exf->update(ctx, blk, POLY1305_BLOCK_LEN - + crp->crp_aad_length % POLY1305_BLOCK_LEN); } /* Do encryption with MAC */ @@ -936,10 +937,11 @@ swcr_chacha20_poly1305(const struct swcr_session *ses, struct cryptop *crp) crypto_cursor_copyback(&cc_out, resid, blk); } exf->update(ctx, blk, resid); - if (resid % 16 != 0) { + if (resid % POLY1305_BLOCK_LEN != 0) { /* padding2 */ - memset(blk, 0, 16); - exf->update(ctx, blk, 16 - resid % 16); + memset(blk, 0, POLY1305_BLOCK_LEN); + exf->update(ctx, blk, POLY1305_BLOCK_LEN - + resid % POLY1305_BLOCK_LEN); } }