-1

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.

hliu
  • 1,015
  • 8
  • 16
  • Are you asking what? (the C++ meaning) or why? (what's the meaning of it in the program)? – JomsDev Jul 24 '17 at 10:18
  • @JomsDev I mean why here using 119 but not other numbers else. Does the number 119 has any special meaning? – hliu Jul 24 '17 at 11:23

1 Answers1

1

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

Badr Bellaj
  • 11,560
  • 2
  • 43
  • 44