mirror of
https://github.com/ipxe/ipxe
synced 2026-06-29 00:07:28 +03:00
327378a764
All of our current digest algorithms (MD4, MD5, SHA-1, and the SHA-2 family) use a Merkle-Damgård construction, with only the compression function, the initial digest values, the field sizes, and the endianness differing between algorithms. Provide a common implementation for Merkle-Damgård hash algorithms to reduce code size. Values are now held as host-endian quantities, with any swapping performed byte-by-byte as data is accumulated (using a compile-time constant that is XORed with the byte index). For the SHA family of algorithms, the values w[] are now calculated iteratively as we progress through the main loop: this substantially reduces the stack space required for the compression function. Signed-off-by: Michael Brown <mcb30@ipxe.org>