hliu
hliu

Reputation: 1047

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.

Upvotes: -1

Views: 235

Answers (1)

Badr Bellaj
Badr Bellaj

Reputation: 12871

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

Upvotes: 1

Related Questions