wire / wire-format / sha1-block
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.
aka: SHA-1 (block structure)
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.
| field | size | meaning |
|---|---|---|
| Message block | 64 bytes (512 bits) | Input chunk, padded to multiple of 64 bytes. |
| W[0..15] | 16 x 4 bytes | The 16 32-bit words of the message block (big-endian). |
| W[16..79] | 64 x 4 bytes | Extended words: W[t] = (W[t-3] XOR W[t-8] XOR W[t-14] XOR W[t-16]) <<< 1. |
| Working variables | 5 x 4 bytes | a, b, c, d, e (initial: H0-H4). |
| Round function | 80 rounds | 4 stages (20 rounds each) with different functions: Ch, Parity, Maj, Parity. K constants per stage. |
| Output | 20 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'
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/sha1-block
or /wire-format/sha1-block.json