Padding is extra, structured data added to a message before encryption or signing. In public-key cryptography, it does more than fill space: it randomizes inputs, marks message boundaries, and enforces rules that make an algorithm safer to use in practice. For RSA, modern schemes such as OAEP for encryption and PSS for signatures are designed to prevent predictable outputs and reduce the risk of mathematical or protocol-level attacks.
Padding matters because many real-world RSA breaks target the padding layer rather than the core math. Weak or legacy padding can create oracles through error messages, timing differences, or malformed input handling, letting attackers learn whether a guessed plaintext or signature is valid. Defenders reduce this risk by using modern padding schemes, rejecting ambiguous inputs consistently, and avoiding legacy modes that leak information.


