diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2012-01-14 21:40:57 +0300 |
---|---|---|
committer | Simone Willett <swillett@nvidia.com> | 2012-02-09 18:20:23 -0800 |
commit | 15cfa044ea1c1db1c29202f08b2449ed545be372 (patch) | |
tree | d5eded6e47e4a8c8de97ae3191ba232d75ede097 /kernel | |
parent | 34ebfc4201c63d5c1885021423678a35163c48c8 (diff) |
crypto: sha512 - reduce stack usage to safe number
commit 51fc6dc8f948047364f7d42a4ed89b416c6cc0a3 upstream.
For rounds 16--79, W[i] only depends on W[i - 2], W[i - 7], W[i - 15] and W[i - 16].
Consequently, keeping all W[80] array on stack is unnecessary,
only 16 values are really needed.
Using W[16] instead of W[80] greatly reduces stack usage
(~750 bytes to ~340 bytes on x86_64).
Line by line explanation:
* BLEND_OP
array is "circular" now, all indexes have to be modulo 16.
Round number is positive, so remainder operation should be
without surprises.
* initial full message scheduling is trimmed to first 16 values which
come from data block, the rest is calculated before it's needed.
* original loop body is unrolled version of new SHA512_0_15 and
SHA512_16_79 macros, unrolling was done to not do explicit variable
renaming. Otherwise it's the very same code after preprocessing.
See sha1_transform() code which does the same trick.
Patch survives in-tree crypto test and original bugreport test
(ping flood with hmac(sha512).
See FIPS 180-2 for SHA-512 definition
http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
Change-Id: I7945bdc928bd3491117ea5e334a0bc5dd6231299
Reviewed-on: http://git-master/r/79657
Diffstat (limited to 'kernel')
0 files changed, 0 insertions, 0 deletions