From 5845655942116f9561a10a75d18a6c59f03ebfd0 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 6 Nov 2017 00:49:34 +0100 Subject: receive: hoist fpu outside of receive loop Signed-off-by: Jason A. Donenfeld --- src/crypto/chacha20poly1305.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/crypto/chacha20poly1305.c') diff --git a/src/crypto/chacha20poly1305.c b/src/crypto/chacha20poly1305.c index 2ce7cbb..a9c3bf8 100644 --- a/src/crypto/chacha20poly1305.c +++ b/src/crypto/chacha20poly1305.c @@ -792,7 +792,8 @@ bool chacha20poly1305_decrypt(u8 *dst, const u8 *src, const size_t src_len, bool chacha20poly1305_decrypt_sg(struct scatterlist *dst, struct scatterlist *src, const size_t src_len, const u8 *ad, const size_t ad_len, - const u64 nonce, const u8 key[CHACHA20POLY1305_KEYLEN]) + const u64 nonce, const u8 key[CHACHA20POLY1305_KEYLEN], + bool have_simd) { struct poly1305_ctx poly1305_state; struct chacha20_ctx chacha20_state; @@ -803,13 +804,10 @@ bool chacha20poly1305_decrypt_sg(struct scatterlist *dst, struct scatterlist *sr size_t dst_len; __le64 len; __le64 le_nonce = cpu_to_le64(nonce); - bool have_simd; if (unlikely(src_len < POLY1305_MAC_SIZE)) return false; - have_simd = chacha20poly1305_init_simd(); - chacha20_keysetup(&chacha20_state, key, (u8 *)&le_nonce); chacha20_crypt(&chacha20_state, block0, block0, sizeof(block0), have_simd); @@ -856,7 +854,6 @@ err: memzero_explicit(read_mac, POLY1305_MAC_SIZE); memzero_explicit(computed_mac, POLY1305_MAC_SIZE); memzero_explicit(&chacha20_state, sizeof(chacha20_state)); - chacha20poly1305_deinit_simd(have_simd); return !ret; } -- cgit v1.2.3