]> git.baikalelectronics.ru Git - kernel.git/commit
crypto: lib/sha256 - Clear W[] in sha256_update() instead of sha256_transform()
authorArvind Sankar <nivedita@alum.mit.edu>
Sun, 25 Oct 2020 14:31:17 +0000 (10:31 -0400)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 30 Oct 2020 06:35:03 +0000 (17:35 +1100)
commit5e1c9afe060e3bb3d023c2abc9a33c5462a3c269
tree5c7ef309f029a74a63ed469a3dc2d45e0116e2c9
parent45286e181a8cd706ddf79f070e67d2e247bc66a0
crypto: lib/sha256 - Clear W[] in sha256_update() instead of sha256_transform()

The temporary W[] array is currently zeroed out once every call to
sha256_transform(), i.e. once every 64 bytes of input data. Moving it to
sha256_update() instead so that it is cleared only once per update can
save about 2-3% of the total time taken to compute the digest, with a
reasonable memset() implementation, and considerably more (~20%) with a
bad one (eg the x86 purgatory currently uses a memset() coded in C).

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
lib/crypto/sha256.c