mirror of
https://github.com/ipxe/ipxe
synced 2025-12-11 22:11:08 +03:00
[tls] Treat invalid block padding as zero length padding
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>
This commit is contained in:
@@ -2821,8 +2821,8 @@ static int tls_new_ciphertext ( struct tls_connection *tls,
|
|||||||
if ( is_block_cipher ( cipher ) ) {
|
if ( is_block_cipher ( cipher ) ) {
|
||||||
pad_len = tls_verify_padding ( tls, last );
|
pad_len = tls_verify_padding ( tls, last );
|
||||||
if ( pad_len < 0 ) {
|
if ( pad_len < 0 ) {
|
||||||
rc = pad_len;
|
/* Assume zero padding length to avoid timing attacks */
|
||||||
return rc;
|
pad_len = 0;
|
||||||
}
|
}
|
||||||
iob_unput ( last, pad_len );
|
iob_unput ( last, pad_len );
|
||||||
len -= pad_len;
|
len -= pad_len;
|
||||||
|
|||||||
Reference in New Issue
Block a user