From 850e5b317d17b3fe965ad172b5799e60661a144c Mon Sep 17 00:00:00 2001 From: David Horstmann Date: Fri, 28 Mar 2025 17:33:45 +0000 Subject: [PATCH] Document assumption of mbedtls_get_pkcs_padding Point out that the input length must be the same as the cipher's block size. Signed-off-by: David Horstmann --- library/cipher.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/cipher.c b/library/cipher.c index d0ba01ea01..2ae01dd84d 100644 --- a/library/cipher.c +++ b/library/cipher.c @@ -839,6 +839,11 @@ static void add_pkcs_padding(unsigned char *output, size_t output_len, } } +/* + * Get the length of the PKCS7 padding. + * + * Note: input_len must be the block size of the cipher. + */ MBEDTLS_STATIC_TESTABLE int mbedtls_get_pkcs_padding(unsigned char *input, size_t input_len, size_t *data_len)