X-Git-Url: http://git.tdb.fi/?p=libs%2Fcrypto.git;a=blobdiff_plain;f=source%2Fsha2.cpp;fp=source%2Fsha2.cpp;h=c7f51a5bb00cffeecc9147e6d1dff116401e1534;hp=24514423580ce6e76ed6a76950248a5294235854;hb=52c9b0b8aacb973b6138ba0eb0e36e0c0cc23f80;hpb=6511a62c3cec0a64bbdd7ac8e3588d39c164af09 diff --git a/source/sha2.cpp b/source/sha2.cpp index 2451442..c7f51a5 100644 --- a/source/sha2.cpp +++ b/source/sha2.cpp @@ -122,8 +122,9 @@ unsigned SHA2::get_digest(char *digest, unsigned len) const SHA2 padded = *this; char padding[Constants::BLOCK_SIZE] = { static_cast(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);