Use newly added functions to simplify the code.
This commit is contained in:
parent
11d2e1e8ff
commit
f34a967b01
@ -2541,24 +2541,18 @@ hifn_process(void *arg, struct cryptop *crp, int hint)
|
||||
|
||||
if ((enccrd->crd_flags & CRD_F_IV_PRESENT)
|
||||
== 0) {
|
||||
if (crp->crp_flags & CRYPTO_F_IMBUF)
|
||||
m_copyback(cmd->src_m,
|
||||
enccrd->crd_inject,
|
||||
ivlen, cmd->iv);
|
||||
else if (crp->crp_flags & CRYPTO_F_IOV)
|
||||
cuio_copyback(cmd->src_io,
|
||||
enccrd->crd_inject,
|
||||
ivlen, cmd->iv);
|
||||
crypto_copyback(crp->crp_flags,
|
||||
crp->crp_buf, enccrd->crd_inject,
|
||||
ivlen, cmd->iv);
|
||||
}
|
||||
} else {
|
||||
if (enccrd->crd_flags & CRD_F_IV_EXPLICIT)
|
||||
bcopy(enccrd->crd_iv, cmd->iv, ivlen);
|
||||
else if (crp->crp_flags & CRYPTO_F_IMBUF)
|
||||
m_copydata(cmd->src_m,
|
||||
enccrd->crd_inject, ivlen, cmd->iv);
|
||||
else if (crp->crp_flags & CRYPTO_F_IOV)
|
||||
cuio_copydata(cmd->src_io,
|
||||
enccrd->crd_inject, ivlen, cmd->iv);
|
||||
else {
|
||||
crypto_copydata(crp->crp_flags,
|
||||
crp->crp_buf, enccrd->crd_inject,
|
||||
ivlen, cmd->iv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2769,14 +2763,9 @@ hifn_callback(struct hifn_softc *sc, struct hifn_command *cmd, u_int8_t *macbuf)
|
||||
}
|
||||
|
||||
if (cmd->sloplen != 0) {
|
||||
if (crp->crp_flags & CRYPTO_F_IMBUF)
|
||||
m_copyback((struct mbuf *)crp->crp_buf,
|
||||
cmd->src_mapsize - cmd->sloplen,
|
||||
cmd->sloplen, (caddr_t)&dma->slop[cmd->slopidx]);
|
||||
else if (crp->crp_flags & CRYPTO_F_IOV)
|
||||
cuio_copyback((struct uio *)crp->crp_buf,
|
||||
cmd->src_mapsize - cmd->sloplen,
|
||||
cmd->sloplen, (caddr_t)&dma->slop[cmd->slopidx]);
|
||||
crypto_copyback(crp->crp_flags, crp->crp_buf,
|
||||
cmd->src_mapsize - cmd->sloplen, cmd->sloplen,
|
||||
(caddr_t)&dma->slop[cmd->slopidx]);
|
||||
}
|
||||
|
||||
i = dma->dstk; u = dma->dstu;
|
||||
@ -2805,15 +2794,9 @@ hifn_callback(struct hifn_softc *sc, struct hifn_command *cmd, u_int8_t *macbuf)
|
||||
continue;
|
||||
ivlen = ((crd->crd_alg == CRYPTO_AES_CBC) ?
|
||||
HIFN_AES_IV_LENGTH : HIFN_IV_LENGTH);
|
||||
if (crp->crp_flags & CRYPTO_F_IMBUF)
|
||||
m_copydata((struct mbuf *)crp->crp_buf,
|
||||
crd->crd_skip + crd->crd_len - ivlen, ivlen,
|
||||
cmd->softc->sc_sessions[cmd->session_num].hs_iv);
|
||||
else if (crp->crp_flags & CRYPTO_F_IOV) {
|
||||
cuio_copydata((struct uio *)crp->crp_buf,
|
||||
crd->crd_skip + crd->crd_len - ivlen, ivlen,
|
||||
cmd->softc->sc_sessions[cmd->session_num].hs_iv);
|
||||
}
|
||||
crypto_copydata(crp->crp_flags, crp->crp_buf,
|
||||
crd->crd_skip + crd->crd_len - ivlen, ivlen,
|
||||
cmd->softc->sc_sessions[cmd->session_num].hs_iv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2829,12 +2812,8 @@ hifn_callback(struct hifn_softc *sc, struct hifn_command *cmd, u_int8_t *macbuf)
|
||||
continue;
|
||||
}
|
||||
len = cmd->softc->sc_sessions[cmd->session_num].hs_mlen;
|
||||
if (crp->crp_flags & CRYPTO_F_IMBUF)
|
||||
m_copyback((struct mbuf *)crp->crp_buf,
|
||||
crd->crd_inject, len, macbuf);
|
||||
else if (crp->crp_flags & CRYPTO_F_IOV)
|
||||
cuio_copyback((struct uio *)crp->crp_buf,
|
||||
crd->crd_inject, len, macbuf);
|
||||
crypto_copyback(crp->crp_flags, crp->crp_buf,
|
||||
crd->crd_inject, len, macbuf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1016,12 +1016,8 @@ safe_process(void *arg, struct cryptop *crp, int hint)
|
||||
else
|
||||
iv = (caddr_t) ses->ses_iv;
|
||||
if ((enccrd->crd_flags & CRD_F_IV_PRESENT) == 0) {
|
||||
if (crp->crp_flags & CRYPTO_F_IMBUF)
|
||||
m_copyback(re->re_src_m,
|
||||
enccrd->crd_inject, ivsize, iv);
|
||||
else if (crp->crp_flags & CRYPTO_F_IOV)
|
||||
cuio_copyback(re->re_src_io,
|
||||
enccrd->crd_inject, ivsize, iv);
|
||||
crypto_copyback(crp->crp_flags, crp->crp_buf,
|
||||
enccrd->crd_inject, ivsize, iv);
|
||||
}
|
||||
bcopy(iv, re->re_sastate.sa_saved_iv, ivsize);
|
||||
cmd0 |= SAFE_SA_CMD0_IVLD_STATE | SAFE_SA_CMD0_SAVEIV;
|
||||
@ -1029,17 +1025,14 @@ safe_process(void *arg, struct cryptop *crp, int hint)
|
||||
} else {
|
||||
cmd0 |= SAFE_SA_CMD0_INBOUND;
|
||||
|
||||
if (enccrd->crd_flags & CRD_F_IV_EXPLICIT)
|
||||
if (enccrd->crd_flags & CRD_F_IV_EXPLICIT) {
|
||||
bcopy(enccrd->crd_iv,
|
||||
re->re_sastate.sa_saved_iv, ivsize);
|
||||
else if (crp->crp_flags & CRYPTO_F_IMBUF)
|
||||
m_copydata(re->re_src_m, enccrd->crd_inject,
|
||||
ivsize,
|
||||
(caddr_t)re->re_sastate.sa_saved_iv);
|
||||
else if (crp->crp_flags & CRYPTO_F_IOV)
|
||||
cuio_copydata(re->re_src_io, enccrd->crd_inject,
|
||||
ivsize,
|
||||
(caddr_t)re->re_sastate.sa_saved_iv);
|
||||
} else {
|
||||
crypto_copydata(crp->crp_flags, crp->crp_buf,
|
||||
enccrd->crd_inject, ivsize,
|
||||
(caddr_t)re->re_sastate.sa_saved_iv);
|
||||
}
|
||||
cmd0 |= SAFE_SA_CMD0_IVLD_STATE;
|
||||
}
|
||||
/*
|
||||
@ -1567,17 +1560,9 @@ safe_callback(struct safe_softc *sc, struct safe_ringentry *re)
|
||||
ivsize = 4*sizeof(u_int32_t);
|
||||
} else
|
||||
continue;
|
||||
if (crp->crp_flags & CRYPTO_F_IMBUF) {
|
||||
m_copydata((struct mbuf *)crp->crp_buf,
|
||||
crd->crd_skip + crd->crd_len - ivsize,
|
||||
ivsize,
|
||||
(caddr_t) sc->sc_sessions[re->re_sesn].ses_iv);
|
||||
} else if (crp->crp_flags & CRYPTO_F_IOV) {
|
||||
cuio_copydata((struct uio *)crp->crp_buf,
|
||||
crd->crd_skip + crd->crd_len - ivsize,
|
||||
ivsize,
|
||||
(caddr_t)sc->sc_sessions[re->re_sesn].ses_iv);
|
||||
}
|
||||
crypto_copydata(crp->crp_flags, crp->crp_buf,
|
||||
crd->crd_skip + crd->crd_len - ivsize, ivsize,
|
||||
(caddr_t)sc->sc_sessions[re->re_sesn].ses_iv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1598,17 +1583,10 @@ safe_callback(struct safe_softc *sc, struct safe_ringentry *re)
|
||||
bswap32(re->re_sastate.sa_saved_indigest[1]);
|
||||
bswap32(re->re_sastate.sa_saved_indigest[2]);
|
||||
}
|
||||
if (crp->crp_flags & CRYPTO_F_IMBUF) {
|
||||
m_copyback((struct mbuf *)crp->crp_buf,
|
||||
crd->crd_inject,
|
||||
sc->sc_sessions[re->re_sesn].ses_mlen,
|
||||
(caddr_t)re->re_sastate.sa_saved_indigest);
|
||||
} else if (crp->crp_flags & CRYPTO_F_IOV) {
|
||||
cuio_copyback((struct uio *)crp->crp_buf,
|
||||
crd->crd_inject,
|
||||
sc->sc_sessions[re->re_sesn].ses_mlen,
|
||||
(caddr_t)re->re_sastate.sa_saved_indigest);
|
||||
}
|
||||
crypto_copyback(crp->crp_flags, crp->crp_buf,
|
||||
crd->crd_inject,
|
||||
sc->sc_sessions[re->re_sesn].ses_mlen,
|
||||
(caddr_t)re->re_sastate.sa_saved_indigest);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1159,27 +1159,18 @@ ubsec_process(void *arg, struct cryptop *crp, int hint)
|
||||
}
|
||||
|
||||
if ((enccrd->crd_flags & CRD_F_IV_PRESENT) == 0) {
|
||||
if (crp->crp_flags & CRYPTO_F_IMBUF)
|
||||
m_copyback(q->q_src_m,
|
||||
enccrd->crd_inject,
|
||||
8, (caddr_t)ctx.pc_iv);
|
||||
else if (crp->crp_flags & CRYPTO_F_IOV)
|
||||
cuio_copyback(q->q_src_io,
|
||||
enccrd->crd_inject,
|
||||
8, (caddr_t)ctx.pc_iv);
|
||||
crypto_copyback(crp->crp_flags, crp->crp_buf,
|
||||
enccrd->crd_inject, 8, (caddr_t)ctx.pc_iv);
|
||||
}
|
||||
} else {
|
||||
ctx.pc_flags |= htole16(UBS_PKTCTX_INBOUND);
|
||||
|
||||
if (enccrd->crd_flags & CRD_F_IV_EXPLICIT)
|
||||
bcopy(enccrd->crd_iv, ctx.pc_iv, 8);
|
||||
else if (crp->crp_flags & CRYPTO_F_IMBUF)
|
||||
m_copydata(q->q_src_m, enccrd->crd_inject,
|
||||
8, (caddr_t)ctx.pc_iv);
|
||||
else if (crp->crp_flags & CRYPTO_F_IOV)
|
||||
cuio_copydata(q->q_src_io,
|
||||
enccrd->crd_inject, 8,
|
||||
(caddr_t)ctx.pc_iv);
|
||||
else {
|
||||
crypto_copydata(crp->crp_flags, crp->crp_buf,
|
||||
enccrd->crd_inject, 8, (caddr_t)ctx.pc_iv);
|
||||
}
|
||||
}
|
||||
|
||||
ctx.pc_deskey[0] = ses->ses_deskey[0];
|
||||
@ -1614,15 +1605,9 @@ ubsec_callback(struct ubsec_softc *sc, struct ubsec_q *q)
|
||||
if (crd->crd_alg != CRYPTO_DES_CBC &&
|
||||
crd->crd_alg != CRYPTO_3DES_CBC)
|
||||
continue;
|
||||
if (crp->crp_flags & CRYPTO_F_IMBUF)
|
||||
m_copydata((struct mbuf *)crp->crp_buf,
|
||||
crd->crd_skip + crd->crd_len - 8, 8,
|
||||
(caddr_t)sc->sc_sessions[q->q_sesn].ses_iv);
|
||||
else if (crp->crp_flags & CRYPTO_F_IOV) {
|
||||
cuio_copydata((struct uio *)crp->crp_buf,
|
||||
crd->crd_skip + crd->crd_len - 8, 8,
|
||||
(caddr_t)sc->sc_sessions[q->q_sesn].ses_iv);
|
||||
}
|
||||
crypto_copydata(crp->crp_flags, crp->crp_buf,
|
||||
crd->crd_skip + crd->crd_len - 8, 8,
|
||||
(caddr_t)sc->sc_sessions[q->q_sesn].ses_iv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1631,16 +1616,9 @@ ubsec_callback(struct ubsec_softc *sc, struct ubsec_q *q)
|
||||
if (crd->crd_alg != CRYPTO_MD5_HMAC &&
|
||||
crd->crd_alg != CRYPTO_SHA1_HMAC)
|
||||
continue;
|
||||
if (crp->crp_flags & CRYPTO_F_IMBUF)
|
||||
m_copyback((struct mbuf *)crp->crp_buf,
|
||||
crd->crd_inject,
|
||||
sc->sc_sessions[q->q_sesn].ses_mlen,
|
||||
(caddr_t)dmap->d_dma->d_macbuf);
|
||||
else if (crp->crp_flags & CRYPTO_F_IOV)
|
||||
cuio_copyback((struct uio *)crp->crp_buf,
|
||||
crd->crd_inject,
|
||||
sc->sc_sessions[q->q_sesn].ses_mlen,
|
||||
(caddr_t)dmap->d_dma->d_macbuf);
|
||||
crypto_copyback(crp->crp_flags, crp->crp_buf, crd->crd_inject,
|
||||
sc->sc_sessions[q->q_sesn].ses_mlen,
|
||||
(caddr_t)dmap->d_dma->d_macbuf);
|
||||
break;
|
||||
}
|
||||
mtx_lock(&sc->sc_freeqlock);
|
||||
|
@ -53,8 +53,7 @@ u_int32_t swcr_sesnum = 0;
|
||||
int32_t swcr_id = -1;
|
||||
|
||||
static int swcr_encdec(struct cryptodesc *, struct swcr_data *, caddr_t, int);
|
||||
static int swcr_authcompute(struct cryptodesc *crd, struct swcr_data *sw,
|
||||
caddr_t buf, int outtype);
|
||||
static int swcr_authcompute(struct cryptodesc *, struct swcr_data *, caddr_t, int);
|
||||
static int swcr_compdec(struct cryptodesc *, struct swcr_data *, caddr_t, int);
|
||||
static int swcr_process(void *, struct cryptop *, int);
|
||||
static int swcr_newsession(void *, u_int32_t *, struct cryptoini *);
|
||||
@ -65,7 +64,7 @@ static int swcr_freesession(void *, u_int64_t);
|
||||
*/
|
||||
static int
|
||||
swcr_encdec(struct cryptodesc *crd, struct swcr_data *sw, caddr_t buf,
|
||||
int outtype)
|
||||
int flags)
|
||||
{
|
||||
unsigned char iv[EALG_MAX_BLOCK_LEN], blk[EALG_MAX_BLOCK_LEN], *idat;
|
||||
unsigned char *ivp, piv[EALG_MAX_BLOCK_LEN];
|
||||
@ -88,9 +87,8 @@ swcr_encdec(struct cryptodesc *crd, struct swcr_data *sw, caddr_t buf,
|
||||
arc4rand(iv, blks, 0);
|
||||
|
||||
/* Do we need to write the IV */
|
||||
if (!(crd->crd_flags & CRD_F_IV_PRESENT)) {
|
||||
COPYBACK(outtype, buf, crd->crd_inject, blks, iv);
|
||||
}
|
||||
if (!(crd->crd_flags & CRD_F_IV_PRESENT))
|
||||
crypto_copyback(flags, buf, crd->crd_inject, blks, iv);
|
||||
|
||||
} else { /* Decryption */
|
||||
/* IV explicitly provided ? */
|
||||
@ -98,7 +96,7 @@ swcr_encdec(struct cryptodesc *crd, struct swcr_data *sw, caddr_t buf,
|
||||
bcopy(crd->crd_iv, iv, blks);
|
||||
else {
|
||||
/* Get IV off buf */
|
||||
COPYDATA(outtype, buf, crd->crd_inject, blks, iv);
|
||||
crypto_copydata(flags, buf, crd->crd_inject, blks, iv);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,40 +112,7 @@ swcr_encdec(struct cryptodesc *crd, struct swcr_data *sw, caddr_t buf,
|
||||
}
|
||||
ivp = iv;
|
||||
|
||||
if (outtype == CRYPTO_BUF_CONTIG) {
|
||||
if (crd->crd_flags & CRD_F_ENCRYPT) {
|
||||
for (i = crd->crd_skip;
|
||||
i < crd->crd_skip + crd->crd_len; i += blks) {
|
||||
/* XOR with the IV/previous block, as appropriate. */
|
||||
if (i == crd->crd_skip)
|
||||
for (k = 0; k < blks; k++)
|
||||
buf[i + k] ^= ivp[k];
|
||||
else
|
||||
for (k = 0; k < blks; k++)
|
||||
buf[i + k] ^= buf[i + k - blks];
|
||||
exf->encrypt(sw->sw_kschedule, buf + i);
|
||||
}
|
||||
} else { /* Decrypt */
|
||||
/*
|
||||
* Start at the end, so we don't need to keep the encrypted
|
||||
* block as the IV for the next block.
|
||||
*/
|
||||
for (i = crd->crd_skip + crd->crd_len - blks;
|
||||
i >= crd->crd_skip; i -= blks) {
|
||||
exf->decrypt(sw->sw_kschedule, buf + i);
|
||||
|
||||
/* XOR with the IV/previous block, as appropriate */
|
||||
if (i == crd->crd_skip)
|
||||
for (k = 0; k < blks; k++)
|
||||
buf[i + k] ^= ivp[k];
|
||||
else
|
||||
for (k = 0; k < blks; k++)
|
||||
buf[i + k] ^= buf[i + k - blks];
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
} else if (outtype == CRYPTO_BUF_MBUF) {
|
||||
if (flags & CRYPTO_F_IMBUF) {
|
||||
struct mbuf *m = (struct mbuf *) buf;
|
||||
|
||||
/* Find beginning of data */
|
||||
@ -272,7 +237,7 @@ swcr_encdec(struct cryptodesc *crd, struct swcr_data *sw, caddr_t buf,
|
||||
}
|
||||
|
||||
return 0; /* Done with mbuf encryption/decryption */
|
||||
} else if (outtype == CRYPTO_BUF_IOV) {
|
||||
} else if (flags & CRYPTO_F_IOV) {
|
||||
struct uio *uio = (struct uio *) buf;
|
||||
struct iovec *iov;
|
||||
|
||||
@ -386,6 +351,39 @@ swcr_encdec(struct cryptodesc *crd, struct swcr_data *sw, caddr_t buf,
|
||||
}
|
||||
|
||||
return 0; /* Done with iovec encryption/decryption */
|
||||
} else { /* contiguous buffer */
|
||||
if (crd->crd_flags & CRD_F_ENCRYPT) {
|
||||
for (i = crd->crd_skip;
|
||||
i < crd->crd_skip + crd->crd_len; i += blks) {
|
||||
/* XOR with the IV/previous block, as appropriate. */
|
||||
if (i == crd->crd_skip)
|
||||
for (k = 0; k < blks; k++)
|
||||
buf[i + k] ^= ivp[k];
|
||||
else
|
||||
for (k = 0; k < blks; k++)
|
||||
buf[i + k] ^= buf[i + k - blks];
|
||||
exf->encrypt(sw->sw_kschedule, buf + i);
|
||||
}
|
||||
} else { /* Decrypt */
|
||||
/*
|
||||
* Start at the end, so we don't need to keep the encrypted
|
||||
* block as the IV for the next block.
|
||||
*/
|
||||
for (i = crd->crd_skip + crd->crd_len - blks;
|
||||
i >= crd->crd_skip; i -= blks) {
|
||||
exf->decrypt(sw->sw_kschedule, buf + i);
|
||||
|
||||
/* XOR with the IV/previous block, as appropriate */
|
||||
if (i == crd->crd_skip)
|
||||
for (k = 0; k < blks; k++)
|
||||
buf[i + k] ^= ivp[k];
|
||||
else
|
||||
for (k = 0; k < blks; k++)
|
||||
buf[i + k] ^= buf[i + k - blks];
|
||||
}
|
||||
}
|
||||
|
||||
return 0; /* Done with contiguous buffer encryption/decryption */
|
||||
}
|
||||
|
||||
/* Unreachable */
|
||||
@ -444,7 +442,7 @@ swcr_authprepare(struct auth_hash *axf, struct swcr_data *sw, u_char *key,
|
||||
*/
|
||||
static int
|
||||
swcr_authcompute(struct cryptodesc *crd, struct swcr_data *sw, caddr_t buf,
|
||||
int outtype)
|
||||
int flags)
|
||||
{
|
||||
unsigned char aalg[HASH_MAX_LEN];
|
||||
struct auth_hash *axf;
|
||||
@ -461,27 +459,10 @@ swcr_authcompute(struct cryptodesc *crd, struct swcr_data *sw, caddr_t buf,
|
||||
|
||||
bcopy(sw->sw_ictx, &ctx, axf->ctxsize);
|
||||
|
||||
switch (outtype) {
|
||||
case CRYPTO_BUF_CONTIG:
|
||||
axf->Update(&ctx, buf + crd->crd_skip, crd->crd_len);
|
||||
break;
|
||||
case CRYPTO_BUF_MBUF:
|
||||
err = m_apply((struct mbuf *) buf, crd->crd_skip, crd->crd_len,
|
||||
(int (*)(void *, void *, unsigned int)) axf->Update,
|
||||
(caddr_t) &ctx);
|
||||
if (err)
|
||||
return err;
|
||||
break;
|
||||
case CRYPTO_BUF_IOV:
|
||||
err = cuio_apply((struct uio *) buf, crd->crd_skip, crd->crd_len,
|
||||
(int (*)(void *, void *, unsigned int)) axf->Update,
|
||||
(caddr_t) &ctx);
|
||||
if (err)
|
||||
return err;
|
||||
break;
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
err = crypto_apply(flags, buf, crd->crd_skip, crd->crd_len,
|
||||
(int (*)(void *, void *, unsigned int))axf->Update, (caddr_t)&ctx);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
switch (sw->sw_alg) {
|
||||
case CRYPTO_MD5_HMAC:
|
||||
@ -514,7 +495,7 @@ swcr_authcompute(struct cryptodesc *crd, struct swcr_data *sw, caddr_t buf,
|
||||
}
|
||||
|
||||
/* Inject the authentication data */
|
||||
COPYBACK(outtype, buf, crd->crd_inject,
|
||||
crypto_copyback(flags, buf, crd->crd_inject,
|
||||
sw->sw_mlen == 0 ? axf->hashsize : sw->sw_mlen, aalg);
|
||||
return 0;
|
||||
}
|
||||
@ -524,7 +505,7 @@ swcr_authcompute(struct cryptodesc *crd, struct swcr_data *sw, caddr_t buf,
|
||||
*/
|
||||
static int
|
||||
swcr_compdec(struct cryptodesc *crd, struct swcr_data *sw,
|
||||
caddr_t buf, int outtype)
|
||||
caddr_t buf, int flags)
|
||||
{
|
||||
u_int8_t *data, *out;
|
||||
struct comp_algo *cxf;
|
||||
@ -541,7 +522,7 @@ swcr_compdec(struct cryptodesc *crd, struct swcr_data *sw,
|
||||
MALLOC(data, u_int8_t *, crd->crd_len, M_CRYPTO_DATA, M_NOWAIT);
|
||||
if (data == NULL)
|
||||
return (EINVAL);
|
||||
COPYDATA(outtype, buf, crd->crd_skip, crd->crd_len, data);
|
||||
crypto_copydata(flags, buf, crd->crd_skip, crd->crd_len, data);
|
||||
|
||||
if (crd->crd_flags & CRD_F_COMP)
|
||||
result = cxf->compress(data, crd->crd_len, &out);
|
||||
@ -565,13 +546,13 @@ swcr_compdec(struct cryptodesc *crd, struct swcr_data *sw,
|
||||
}
|
||||
}
|
||||
|
||||
COPYBACK(outtype, buf, crd->crd_skip, result, out);
|
||||
crypto_copyback(flags, buf, crd->crd_skip, result, out);
|
||||
if (result < crd->crd_len) {
|
||||
adj = result - crd->crd_len;
|
||||
if (outtype == CRYPTO_BUF_MBUF) {
|
||||
if (flags & CRYPTO_F_IMBUF) {
|
||||
adj = result - crd->crd_len;
|
||||
m_adj((struct mbuf *)buf, adj);
|
||||
} else {
|
||||
} else if (flags & CRYPTO_F_IOV) {
|
||||
struct uio *uio = (struct uio *)buf;
|
||||
int ind;
|
||||
|
||||
@ -898,7 +879,6 @@ swcr_process(void *arg, struct cryptop *crp, int hint)
|
||||
struct cryptodesc *crd;
|
||||
struct swcr_data *sw;
|
||||
u_int32_t lid;
|
||||
int type;
|
||||
|
||||
/* Sanity check */
|
||||
if (crp == NULL)
|
||||
@ -915,14 +895,6 @@ swcr_process(void *arg, struct cryptop *crp, int hint)
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (crp->crp_flags & CRYPTO_F_IMBUF) {
|
||||
type = CRYPTO_BUF_MBUF;
|
||||
} else if (crp->crp_flags & CRYPTO_F_IOV) {
|
||||
type = CRYPTO_BUF_IOV;
|
||||
} else {
|
||||
type = CRYPTO_BUF_CONTIG;
|
||||
}
|
||||
|
||||
/* Go through crypto descriptors, processing as we go */
|
||||
for (crd = crp->crp_desc; crd; crd = crd->crd_next) {
|
||||
/*
|
||||
@ -953,7 +925,7 @@ swcr_process(void *arg, struct cryptop *crp, int hint)
|
||||
case CRYPTO_SKIPJACK_CBC:
|
||||
case CRYPTO_RIJNDAEL128_CBC:
|
||||
if ((crp->crp_etype = swcr_encdec(crd, sw,
|
||||
crp->crp_buf, type)) != 0)
|
||||
crp->crp_buf, crp->crp_flags)) != 0)
|
||||
goto done;
|
||||
break;
|
||||
case CRYPTO_NULL_CBC:
|
||||
@ -971,13 +943,13 @@ swcr_process(void *arg, struct cryptop *crp, int hint)
|
||||
case CRYPTO_MD5:
|
||||
case CRYPTO_SHA1:
|
||||
if ((crp->crp_etype = swcr_authcompute(crd, sw,
|
||||
crp->crp_buf, type)) != 0)
|
||||
crp->crp_buf, crp->crp_flags)) != 0)
|
||||
goto done;
|
||||
break;
|
||||
|
||||
case CRYPTO_DEFLATE_COMP:
|
||||
if ((crp->crp_etype = swcr_compdec(crd, sw,
|
||||
crp->crp_buf, type)) != 0)
|
||||
crp->crp_buf, crp->crp_flags)) != 0)
|
||||
goto done;
|
||||
else
|
||||
crp->crp_olen = (int)sw->sw_size;
|
||||
|
Loading…
Reference in New Issue
Block a user