wire / wire-format / sha1-block

SHA-1 (block structure)

SHA-1 processes input in 512-bit (64-byte) blocks. Similar to SHA-256 but with 160-bit (20-byte) output. 80 rounds (vs SHA-256's 64). Uses 5 working variables (a-e). Broken for collision resistance (SHAttered attack, 2017). Still used in Git (object IDs), TLS (legacy), and many systems.

wire-format kind wire-format status standard verification verified tier B wire-format@1

aka: SHA-1 (block structure)

wire format

spec: FIPS 180-4 (SHA-1)

SHA-1 processes input in 512-bit (64-byte) blocks. Similar to SHA-256 but with 160-bit (20-byte) output. 80 rounds (vs SHA-256's 64). Uses 5 working variables (a-e). Broken for collision resistance (SHAttered attack, 2017). Still used in Git (object IDs), TLS (legacy), and many systems.

fieldsizemeaning
Message block64 bytes (512 bits)Input chunk, padded to multiple of 64 bytes.
W[0..15]16 x 4 bytesThe 16 32-bit words of the message block (big-endian).
W[16..79]64 x 4 bytesExtended words: W[t] = (W[t-3] XOR W[t-8] XOR W[t-14] XOR W[t-16]) <<< 1.
Working variables5 x 4 bytesa, b, c, d, e (initial: H0-H4).
Round function80 rounds4 stages (20 rounds each) with different functions: Ch, Parity, Maj, Parity. K constants per stage.
Output20 bytes (160 bits)Final hash = H0-H4 (each 4 bytes, big-endian).

example:

61 62 63 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18

SHA-1 padding for 'abc'


provenance

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/sha1-block or /wire-format/sha1-block.json