amosnier/sha-2

Possible memory optimization

ledvinap opened this issue · 2 comments

Hello,
when computing w[] array in https://github.com/amosnier/sha-2/blob/master/sha-256.c#L168, only last 16 entries are necessary and only w[round] is used in compression loop.
Splitting compression function into 4*16 nested loop will allow computing next w[16] entries on the fly, considerably reducing stack usage (192 bytes saved), with small performance impact ...

This cleverness made my evening. Thanks a lot!

@ledvinap, I'll happily take further comments.

I will try to react a little faster in the future.

I close the issue for now. We'll reopen it if necessary.