IT lexicon › Security › Zero padding

Zero padding

Security På svenska → Updated: 2026-10-13

Filling the last block with null bytes: simple, but ambiguous when it comes to removing the padding again.

Zero padding fills an incomplete block with null bytes until it reaches the block size. It is simple and needs no length field, but it cannot be removed unambiguously. If the plaintext itself ends in null bytes, the receiver has no way of knowing where the real data stops. That is why it rarely appears in new protocols, where PKCS#7 is the usual choice.

Anyone who needs unambiguous unpadding has to add a length field or a MAC, or switch to PKCS#7. The same principle applies to every padding scheme: unpadding must be able to tell data apart from padding.

← Back to the lexicon