Axe tmp_iv from the cryptodev session structure.

Just copyin the IV into the crypto descriptor directly.  This avoids
copying the IV twice for each operation.

Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D13847
This commit is contained in:
jhb 2018-01-11 18:07:21 +00:00
parent aff7b08106
commit 219ebd26d7

View File

@ -278,7 +278,6 @@ struct csession {
caddr_t key; caddr_t key;
int keylen; int keylen;
u_char tmp_iv[EALG_MAX_BLOCK_LEN];
caddr_t mackey; caddr_t mackey;
int mackeylen; int mackeylen;
@ -823,12 +822,11 @@ cryptodev_op(
error = EINVAL; error = EINVAL;
goto bail; goto bail;
} }
if ((error = copyin(cop->iv, cse->tmp_iv, if ((error = copyin(cop->iv, crde->crd_iv,
cse->txform->blocksize))) { cse->txform->blocksize))) {
SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__);
goto bail; goto bail;
} }
bcopy(cse->tmp_iv, crde->crd_iv, cse->txform->blocksize);
crde->crd_flags |= CRD_F_IV_EXPLICIT | CRD_F_IV_PRESENT; crde->crd_flags |= CRD_F_IV_EXPLICIT | CRD_F_IV_PRESENT;
crde->crd_skip = 0; crde->crd_skip = 0;
} else if (cse->cipher == CRYPTO_ARC4) { /* XXX use flag? */ } else if (cse->cipher == CRYPTO_ARC4) { /* XXX use flag? */
@ -1005,17 +1003,16 @@ cryptodev_aead(
crp->crp_opaque = (void *)cse; crp->crp_opaque = (void *)cse;
if (caead->iv) { if (caead->iv) {
if (caead->ivlen > sizeof cse->tmp_iv) { if (caead->ivlen > sizeof(crde->crd_iv)) {
error = EINVAL; error = EINVAL;
SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__);
goto bail; goto bail;
} }
if ((error = copyin(caead->iv, cse->tmp_iv, caead->ivlen))) { if ((error = copyin(caead->iv, crde->crd_iv, caead->ivlen))) {
SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__); SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__);
goto bail; goto bail;
} }
bcopy(cse->tmp_iv, crde->crd_iv, caead->ivlen);
crde->crd_flags |= CRD_F_IV_EXPLICIT | CRD_F_IV_PRESENT; crde->crd_flags |= CRD_F_IV_EXPLICIT | CRD_F_IV_PRESENT;
} else { } else {
crde->crd_flags |= CRD_F_IV_PRESENT; crde->crd_flags |= CRD_F_IV_PRESENT;