From 8ffc92a1e8f376820c6870a025495525125693f3 Mon Sep 17 00:00:00 2001 From: k-stachowiak Date: Wed, 12 Dec 2018 14:21:59 +0100 Subject: [PATCH 1/6] Add parameter validation for the GCM module --- include/mbedtls/gcm.h | 87 +++++++++----- library/gcm.c | 46 +++++++- tests/CMakeLists.txt | 1 + tests/suites/helpers.function | 1 - tests/suites/test_suite_gcm.function | 160 ++++++++++++++++++++++++++ tests/suites/test_suite_gcm.misc.data | 2 + 6 files changed, 263 insertions(+), 34 deletions(-) create mode 100644 tests/suites/test_suite_gcm.misc.data diff --git a/include/mbedtls/gcm.h b/include/mbedtls/gcm.h index 93d15ee80..f68643d10 100644 --- a/include/mbedtls/gcm.h +++ b/include/mbedtls/gcm.h @@ -85,7 +85,7 @@ mbedtls_gcm_context; * cipher, nor set the key. For this purpose, use * mbedtls_gcm_setkey(). * - * \param ctx The GCM context to initialize. + * \param ctx The GCM context to initialize. This must not be \c NULL. */ void mbedtls_gcm_init( mbedtls_gcm_context *ctx ); @@ -93,9 +93,10 @@ void mbedtls_gcm_init( mbedtls_gcm_context *ctx ); * \brief This function associates a GCM context with a * cipher algorithm and a key. * - * \param ctx The GCM context to initialize. + * \param ctx The GCM context. This must be initialized. * \param cipher The 128-bit block cipher to use. - * \param key The encryption key. + * \param key The encryption key. This must be a readable buffer of at + * least \p keybits bits. * \param keybits The key size in bits. Valid options are: *