Overview of SHA2
The SHA2 algorithm contains the following variants:
Each variant defines a
NUM_ROUNDS amongst other constants.
All variants contain three main phases.
A set of hash values are initialized to predefined constants. The number and
values of those hashes depend on the algorithm variant. Similarly each variant
has a specific number of rounds
NUM_ROUNDS, and there is a list of constants
predefined for each round.
Incoming data are broken into fixed-size chunks of size
chunk gets operated on and ends up updating all hash values. If size of the
last chunk is not a multiple of
BLOCK_SIZE, it does not get processed for
If the is any remaining unprocessed data, it gets padded to match the
BLOCK_SIZE and we process as chunk.
All hash values are concatenated and this becomes the hash output.