Padding se na konec přidává u AES v CBC, funguje to podobně jako u PKCS#7, jen obsah je konstanta. Více informací se můžeš dozvědět např. pro TLS 1.0 v RFC 2246 v sekci 6.2.3.2.
CBC je zranitelný na Padding oracle attack právě kvůli paddingu, google ti řekne víc. Před rokem jsme tady třeba řešili BEAST, což je právě variance na padding attack u TLS.
Nejlepší je asi když tady rovnou vycituji dané paragrafy:
padding
Padding that is added to force the length of the plaintext to be
an integral multiple of the block cipher's block length. The
padding may be any length up to 255 bytes long, as long as it
results in the TLSCiphertext.length being an integral multiple of
the block length. Lengths longer than necessary might be
desirable to frustrate attacks on a protocol based on analysis of
the lengths of exchanged messages. Each uint8 in the padding data
vector must be filled with the padding length value.
padding_length
The padding length should be such that the total size of the
GenericBlockCipher structure is a multiple of the cipher's block
length. Legal values range from zero to 255, inclusive. This
length specifies the length of the padding field exclusive of the
padding_length field itself.