The upper 64 bits are filled with zeroes because 128-bit integers are not
available everywhere and it will be a while before lengths overflowing 64
bits are realistically possible.
SHA2<Constants> padded = *this;
char padding[Constants::BLOCK_SIZE] = { static_cast<char>(0x80) };
- padded.update(padding, Constants::BLOCK_SIZE-(this->unprocessed_bytes+8)%Constants::BLOCK_SIZE);
+ padded.update(padding, Constants::BLOCK_SIZE-(this->unprocessed_bytes+Constants::MIN_PADDING)%Constants::BLOCK_SIZE);
+ padded.update(padding+1, Constants::MIN_PADDING-8);
UInt64 message_length = (processed_bytes+this->unprocessed_bytes)*8;
write_word(message_length, padding);
padded.update(padding, 8);
WORD_SIZE = sizeof(WordType),
BLOCK_SIZE = 64, // 512 bits
DIGEST_SIZE = 32, // 256 bits
+ MIN_PADDING = 8,
N_ROUNDS = 64
};
WORD_SIZE = sizeof(WordType),
BLOCK_SIZE = 128, // 1024 bits
DIGEST_SIZE = 64, // 512 bits
+ MIN_PADDING = 16,
N_ROUNDS = 80
};