crypto: x86/poly1305 - Clear key material from stack in SSE2 variant
Subsystems (2)
PATCH 1/1 crypto: x86/poly1305 - Clear key material from stack in SSE2 variant
1-block SSE2 variant of poly1305 stores variables s1..s4 containing key material on the stack. This commit adds missing zeroing of the stack memory. Benchmarks show negligible performance hit (tested on i7-3770).
---
Similarly, poly1305_blocks() in crypto/poly1305_generic.c stores s1..s4 as well as r0..r4 to local variables which may be stored in the stack by the compiler. Fixing that is less trivial and left for another patch.
Tests were run with poly1305_simd_blocks() patched to call only 1-block SSE2 poly1305 function.
--- arch/x86/crypto/poly1305-sse2-x86_64.S | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/crypto/poly1305-sse2-x86_64.S +4 -0
@@ -272,6 +272,10 @@ ENTRY(poly1305_block_sse2) dec %rcx jnz .Ldoblock + # Zeroing of key material + mov %rcx,0x00(%rsp) + mov %rcx,0x08(%rsp) + add $0x10,%rsp pop %r12 pop %rbx
Signature · 1 line
2.20.1
Herbert Xu
maintainerQuoted 10 lines · Tommi Hirvola
1-block SSE2 variant of poly1305 stores variables s1..s4 containing key material on the stack. This commit adds missing zeroing of the stack memory. Benchmarks show negligible performance hit (tested on i7-3770).
Signed-off-by Tommi Hirvola <[email protected]>---
Similarly,poly1305_blocks()incrypto/poly1305_generic.cstores s1..s4 as well as r0..r4 to local variables which may be stored in the stack by the compiler. Fixing that is less trivial and left for another patch.
Quoted 5 lines
Tests were run with
poly1305_simd_blocks()patched to call only 1-block SSE2 poly1305 function.--- arch/x86/crypto/poly1305-sse2-x86_64.S | 4 ++++ 1 file changed, 4 insertions(+)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt