From e55653f085a7dc411a9865c97d92f61b52ad1692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 22 Jul 2020 11:42:57 +0200 Subject: [PATCH] Improve comments about padlen convention MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The convention from the TLS RFC is a bit unusual, so even if the test function's introductory comment mentions that we're taking the RFC's definition, it doesn't hurt to repeat it in crucial places. Signed-off-by: Manuel Pégourié-Gonnard --- tests/suites/test_suite_ssl.function | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/suites/test_suite_ssl.function b/tests/suites/test_suite_ssl.function index 0d2520e74..cbc660cc3 100644 --- a/tests/suites/test_suite_ssl.function +++ b/tests/suites/test_suite_ssl.function @@ -3479,7 +3479,7 @@ void ssl_decrypt_non_etm_cbc( int cipher_type, int hash_id, int trunc_hmac, unsigned char *buf = NULL, *buf_save = NULL; size_t buflen, olen = 0; size_t plaintext_len, block_size, i; - unsigned char padlen; + unsigned char padlen; /* excluding the padding_length byte */ unsigned char add_data[13]; unsigned char mac[MBEDTLS_MD_MAX_SIZE]; int exp_ret; @@ -3502,7 +3502,8 @@ void ssl_decrypt_non_etm_cbc( int cipher_type, int hash_id, int trunc_hmac, { plaintext_len = 0; - /* Minimal padding */ + /* Minimal padding + * The +1 is for the padding_length byte, not counted in padlen. */ padlen = block_size - ( t0.maclen + 1 ) % block_size; /* Maximal padding? */ @@ -3513,7 +3514,8 @@ void ssl_decrypt_non_etm_cbc( int cipher_type, int hash_id, int trunc_hmac, { padlen = length_selector; - /* Minimal non-zero plaintext_length givin desired padding */ + /* Minimal non-zero plaintext_length giving desired padding. + * The +1 is for the padding_length byte, not counted in padlen. */ plaintext_len = block_size - ( padlen + t0.maclen + 1 ) % block_size; }