From 19d0de8d6435d296e9af0b4a735e0b6a8cb36457 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Mon, 26 Mar 2018 20:30:07 +0000 Subject: [PATCH] cryptodev: Match intent for enc_xform ciphers with blocksize != ivsize No functional change for Skipjack, AES-ICM, Blowfish, CAST-128, Camellia, DES3, Rijndael128, DES. All of these have identical IV and blocksizes declared in the associated enc_xform. Functional changes for: * AES-GCM: block len of 1, IV len of 12 * AES-XTS: block len of 16, IV len of 8 * NULL: block len of 4, IV len of 0 For these, it seems like the IV specified in the enc_xform is correct (and the blocksize used before was wrong). Additionally, the not-yet-OCFed cipher Chacha20 has a logical block length of 1 byte, and a 16 byte IV + nonce. Rationalize references to IV lengths to refer to the declared ivsize, rather than declared blocksize. Sponsored by: Dell EMC Isilon --- sys/opencrypto/cryptodev.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index 519d73d3e052..58e15212cdb7 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -854,7 +854,7 @@ cryptodev_op( goto bail; } if ((error = copyin(cop->iv, crde->crd_iv, - cse->txform->blocksize))) { + cse->txform->ivsize))) { SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); goto bail; } @@ -864,8 +864,8 @@ cryptodev_op( crde->crd_skip = 0; } else if (crde) { crde->crd_flags |= CRD_F_IV_PRESENT; - crde->crd_skip = cse->txform->blocksize; - crde->crd_len -= cse->txform->blocksize; + crde->crd_skip = cse->txform->ivsize; + crde->crd_len -= cse->txform->ivsize; } if (cop->mac && crda == NULL) { @@ -1032,8 +1032,8 @@ cryptodev_aead( crde->crd_flags |= CRD_F_IV_EXPLICIT | CRD_F_IV_PRESENT; } else { crde->crd_flags |= CRD_F_IV_PRESENT; - crde->crd_skip += cse->txform->blocksize; - crde->crd_len -= cse->txform->blocksize; + crde->crd_skip += cse->txform->ivsize; + crde->crd_len -= cse->txform->ivsize; } if ((error = copyin(caead->tag, (caddr_t)cod->uio.uio_iov[0].iov_base +