Search code examples
bitcoinbitcoind

what does this code in bitcoin source code mean?


I am learning SHA-256 algorithm by reading the implement in the bitcoin source code (https://github.com/bitcoin/bitcoin/blob/master/src/crypto/sha256.cpp#L232). But I am confused with this line:

Write(pad, 1 + ((119 - (bytes % 64)) % 64));

I do not get Why using the number 119 here but not other numbers. Why to pad according to 119?The doc is not clear about this and I googled but found nothing helpful.


Solution

  • This is related to the HMAC message length, you will find bellow an explanation i've extracted from "SSL and TLS: Theory and Practice, Second Edition" Book :

    enter image description here