diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2010-11-15 12:30:30 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2010-11-15 12:30:30 +0000 |
commit | e838fa0e267ba7d57b503ee187136772062402d4 (patch) | |
tree | 0da9beac9e6ac42f70ae3e704c03327e9b6104f6 /sys | |
parent | b544b81be549db791fa1e4454d9d3eae90d66c06 (diff) |
round up crd_len to the blocksize; will be needed for gcm
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/amd64/aesni.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/arch/amd64/amd64/aesni.c b/sys/arch/amd64/amd64/aesni.c index 1a135bd9579..1b788674ddb 100644 --- a/sys/arch/amd64/amd64/aesni.c +++ b/sys/arch/amd64/amd64/aesni.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aesni.c,v 1.11 2010/11/15 11:52:58 mikeb Exp $ */ +/* $OpenBSD: aesni.c,v 1.12 2010/11/15 12:30:29 mikeb Exp $ */ /*- * Copyright (c) 2003 Jason Wright * Copyright (c) 2003, 2004 Theo de Raadt @@ -315,8 +315,7 @@ aesni_encdec(struct cryptop *crp, struct cryptodesc *crd, uint8_t iv[EALG_MAX_BLOCK_LEN]; uint8_t icb[EALG_MAX_BLOCK_LEN]; uint8_t *buf = aesni_sc->sc_buf; - int ivlen = 0; - int err = 0; + int ivlen, rlen, err = 0; if ((crd->crd_len % 16) != 0) { err = EINVAL; @@ -330,11 +329,12 @@ aesni_encdec(struct cryptop *crp, struct cryptodesc *crd, } aesni_sc->sc_buflen = 0; - aesni_sc->sc_buf = buf = malloc(crd->crd_len, M_DEVBUF, - M_NOWAIT|M_ZERO); + rlen = roundup(crd->crd_len, EALG_MAX_BLOCK_LEN); + aesni_sc->sc_buf = buf = malloc(rlen, M_DEVBUF, M_NOWAIT | + M_ZERO); if (buf == NULL) return (ENOMEM); - aesni_sc->sc_buflen = crd->crd_len; + aesni_sc->sc_buflen = rlen; } /* CBC uses 16, CTR only 8 */ @@ -427,7 +427,7 @@ aesni_encdec(struct cryptop *crp, struct cryptodesc *crd, } out: - bzero(buf, crd->crd_len); + bzero(buf, aesni_sc->sc_buflen); return (err); } |