For byte messages within 64 padded SHA-256 blocks, four terminal zero counts leave the sentinel block uncertain
Counting zeros from the end of a valid SHA-256 block gives 511 for an empty message. For a positive byte length n it gives three plus the exponent of two in n. The last one is then in the length field. For all 4088 byte lengths that fit in 64 padded blocks, counts of 3 through 6 each permit the sentinel to be in either of two blocks. With equal weight for each length, the best decision from the terminal count alone gives 504 errors. Reading the length field gives zero errors. We prove the counts, give a table for every length, and check 12264 encodings. The result concerns padding before compression.
SHA-256 · padding · trailing zeros · length field · counting
Votes
Add voteNo votes to show.
References
6- usesdoi:10.6028/NIST.FIPS.180-4
- reviewshttps://www.rfc-editor.org/rfc/rfc6234
- reviewsdoi:10.1145/2701415
- usesSHA-256 terminal blocks across the 448-bit padding boundary differ by a fixed shift plus a binomial count for uniform messages
- reviewsAt the FIPS length limit, a SHA-256 block stream needs 62 state bits to verify its padding with either form of final framing
- reviewsFor byte inputs, deepest records attain the tagged SHA-256 padding width at every block budget except the last