Use crypto_contiguous_subsegment().

This driver used a home-rolled version that predated the function and
didn't support mbufs.
This commit is contained in:
John Baldwin 2020-04-15 21:05:38 +00:00
parent d80a924822
commit f91ab858cf
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=359993

View File

@ -169,27 +169,9 @@ padlock_cipher_alloc(struct cryptop *crp, int *allocated)
{
u_char *addr;
switch (crp->crp_buf_type) {
case CRYPTO_BUF_MBUF:
break;
case CRYPTO_BUF_UIO: {
struct uio *uio;
struct iovec *iov;
uio = crp->crp_uio;
if (uio->uio_iovcnt != 1)
break;
iov = uio->uio_iov;
addr = (u_char *)iov->iov_base + crp->crp_payload_start;
if (((uintptr_t)addr & 0xf) != 0) /* 16 bytes aligned? */
break;
*allocated = 0;
return (addr);
}
case CRYPTO_BUF_CONTIG:
addr = (u_char *)crp->crp_buf + crp->crp_payload_start;
if (((uintptr_t)addr & 0xf) != 0) /* 16 bytes aligned? */
break;
addr = crypto_contiguous_subsegment(crp, crp->crp_payload_start,
crp->crp_payload_length);
if (((uintptr_t)addr & 0xf) == 0) { /* 16 bytes aligned? */
*allocated = 0;
return (addr);
}