aboutsummaryrefslogtreecommitdiff
path: root/sys/crypto
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2021-10-06 21:08:46 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2021-10-06 21:08:46 +0000
commit1833d6042c9a0116e8a1198256fd8fbc99cb11ad (patch)
tree153cabff0be6b97e480addd4eeafc719b697e783 /sys/crypto
parentcb128893b92994456107d6ca722fdf6e5028eacc (diff)
downloadsrc-1833d6042c9a0116e8a1198256fd8fbc99cb11ad.tar.gz
src-1833d6042c9a0116e8a1198256fd8fbc99cb11ad.zip
crypto: Permit variable-sized IVs for ciphers with a reinit hook.
Add a 'len' argument to the reinit hook in 'struct enc_xform' to permit support for AEAD ciphers such as AES-CCM and Chacha20-Poly1305 which support different nonce lengths. Reviewed by: markj Sponsored by: Chelsio Communications, The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32105
Diffstat (limited to 'sys/crypto')
-rw-r--r--sys/crypto/chacha20/chacha-sw.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/crypto/chacha20/chacha-sw.c b/sys/crypto/chacha20/chacha-sw.c
index b1bf0a106bfd..8041a3fee8a5 100644
--- a/sys/crypto/chacha20/chacha-sw.c
+++ b/sys/crypto/chacha20/chacha-sw.c
@@ -18,9 +18,10 @@ chacha20_xform_setkey(void *ctx, const uint8_t *key, int len)
}
static void
-chacha20_xform_reinit(void *ctx, const uint8_t *iv)
+chacha20_xform_reinit(void *ctx, const uint8_t *iv, size_t ivlen)
{
-
+ KASSERT(ivlen == CHACHA_NONCELEN + CHACHA_CTRLEN,
+ ("%s: invalid IV length", __func__));
chacha_ivsetup(ctx, iv + 8, iv);
}