Harden against padding oracle attacks by treating invalid block
padding as zero length padding, thereby deferring the failure until
after computing the (incorrect) MAC.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
if ( is_block_cipher ( cipher ) ) {
pad_len = tls_verify_padding ( tls, last );
if ( pad_len < 0 ) {
- rc = pad_len;
- return rc;
+ /* Assume zero padding length to avoid timing attacks */
+ pad_len = 0;
}
iob_unput ( last, pad_len );
len -= pad_len;