git: 04781697f8e6 - main - cryptosoft: Use POLY1305_BLOCK_LEN instead of a magic number.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 17 Dec 2021 22:00:10 UTC
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=04781697f8e675528078249ff79c3e948a95b7c9 commit 04781697f8e675528078249ff79c3e948a95b7c9 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2021-12-17 21:58:59 +0000 Commit: John Baldwin <jhb@FreeBSD.org> 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); } }