From 6ad5d9450a7573973299f870247e6284470bd425 Mon Sep 17 00:00:00 2001 From: Andres AG Date: Mon, 26 Sep 2016 10:09:30 +0100 Subject: [PATCH] Fix documentation for mbedtls_gcm_finish() Fix implementation and documentation missmatch for the function arguments to mbedtls_gcm_finish(). Also, removed redundant if condition that always evaluates to true. --- ChangeLog | 2 ++ include/polarssl/gcm.h | 4 ++-- library/gcm.c | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf5ba2c4b..e91bc2f2d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,8 @@ Bugfix * Fixed the sample applications gen_key.c, cert_req.c and cert_write.c for builds where the configuration POLARSSL_PEM_WRITE_C is not defined. Found by inestlerode. #559. + * Fix documentation and implementation missmatch for function arguments of + mbedtls_gcm_finish(). Found by cmiatpaar. Changes * Add compile time option for relaxed X509 time verification to enable diff --git a/include/polarssl/gcm.h b/include/polarssl/gcm.h index 5a9472298..3326919ff 100644 --- a/include/polarssl/gcm.h +++ b/include/polarssl/gcm.h @@ -186,8 +186,8 @@ int gcm_update( gcm_context *ctx, * 16 bytes. * * \param ctx GCM context - * \param tag buffer for holding the tag (may be NULL if tag_len is 0) - * \param tag_len length of the tag to generate + * \param tag buffer for holding the tag + * \param tag_len length of the tag to generate (must be at least 4) * * \return 0 if successful or POLARSSL_ERR_GCM_BAD_INPUT */ diff --git a/library/gcm.c b/library/gcm.c index 83f2fd2bd..33306e554 100644 --- a/library/gcm.c +++ b/library/gcm.c @@ -410,8 +410,7 @@ int gcm_finish( gcm_context *ctx, if( tag_len > 16 || tag_len < 4 ) return( POLARSSL_ERR_GCM_BAD_INPUT ); - if( tag_len != 0 ) - memcpy( tag, ctx->base_ectr, tag_len ); + memcpy( tag, ctx->base_ectr, tag_len ); if( orig_len || orig_add_len ) {