diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2020-06-03 22:15:11 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2020-06-03 22:15:11 +0000 |
| commit | 66f2e4b620f08d689925ae62bc78253e6ac93ab2 (patch) | |
| tree | 5ec1004543a9846aaf585b0192af51cdd2b21e11 /sys/crypto | |
| parent | 20c128da91e42a45f3db46551bacd51a5b0f9cda (diff) | |
Notes
Diffstat (limited to 'sys/crypto')
| -rw-r--r-- | sys/crypto/aesni/aesni.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/crypto/aesni/aesni.c b/sys/crypto/aesni/aesni.c index d47e813e7347f..2ef0f7f39de58 100644 --- a/sys/crypto/aesni/aesni.c +++ b/sys/crypto/aesni/aesni.c @@ -815,6 +815,8 @@ out: explicit_bzero(outbuf, crp->crp_payload_length); free(outbuf, M_AESNI); } + explicit_bzero(iv, sizeof(iv)); + explicit_bzero(tag, sizeof(tag)); return (error); } @@ -826,9 +828,7 @@ aesni_cipher_mac(struct aesni_session *ses, struct cryptop *crp, struct SHA256Context sha2 __aligned(16); struct sha1_ctxt sha1 __aligned(16); } sctx; - uint8_t hmac_key[SHA1_BLOCK_LEN] __aligned(16); uint32_t res[SHA2_256_HASH_LEN / sizeof(uint32_t)]; - uint32_t res2[SHA2_256_HASH_LEN / sizeof(uint32_t)]; const uint8_t *key; int i, keylen; @@ -839,6 +839,8 @@ aesni_cipher_mac(struct aesni_session *ses, struct cryptop *crp, keylen = csp->csp_auth_klen; if (ses->hmac) { + uint8_t hmac_key[SHA1_BLOCK_LEN] __aligned(16); + /* Inner hash: (K ^ IPAD) || data */ ses->hash_init(&sctx); for (i = 0; i < keylen; i++) @@ -869,6 +871,7 @@ aesni_cipher_mac(struct aesni_session *ses, struct cryptop *crp, ses->hash_update(&sctx, hmac_key, sizeof(hmac_key)); ses->hash_update(&sctx, res, ses->hash_len); ses->hash_finalize(res, &sctx); + explicit_bzero(hmac_key, sizeof(hmac_key)); } else { ses->hash_init(&sctx); @@ -889,10 +892,14 @@ aesni_cipher_mac(struct aesni_session *ses, struct cryptop *crp, } if (crp->crp_op & CRYPTO_OP_VERIFY_DIGEST) { + uint32_t res2[SHA2_256_HASH_LEN / sizeof(uint32_t)]; + crypto_copydata(crp, crp->crp_digest_start, ses->mlen, res2); if (timingsafe_bcmp(res, res2, ses->mlen) != 0) return (EBADMSG); + explicit_bzero(res2, sizeof(res2)); } else crypto_copyback(crp, crp->crp_digest_start, ses->mlen, res); + explicit_bzero(res, sizeof(res)); return (0); } |
