From b4888d60c1b69205db39cd46485e158ccb1b49b3 Mon Sep 17 00:00:00 2001 From: Lukasz Pawelczyk Date: Thu, 16 Jun 2016 12:55:25 +0200 Subject: [PATCH] For get_output_length in digest and sign require input_len == 0 Change-Id: If195121b6c56fcd91c6d88d469d213b13b88dcc9 --- api/yaca/yaca_crypto.h | 2 +- src/digest.c | 4 ++-- src/sign.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/yaca/yaca_crypto.h b/api/yaca/yaca_crypto.h index b9d9899..d95a7c2 100644 --- a/api/yaca/yaca_crypto.h +++ b/api/yaca/yaca_crypto.h @@ -259,7 +259,7 @@ int yaca_context_destroy(yaca_context_h ctx); * * @remarks This function can be used to learn the required size of the output buffer * for a single operation (eg. *_update or *_finalize). In case the operation - * has no input (eg. *_finalize), the value of @b input_len should be set to 0. + * has no input (eg. *_finalize), the value of @b input_len has to be set to 0. * * @param[in] ctx Previously initialized crypto context * @param[in] input_len Length of the input data to be processed diff --git a/src/digest.c b/src/digest.c index 64b88f4..b003e97 100644 --- a/src/digest.c +++ b/src/digest.c @@ -51,14 +51,14 @@ static struct yaca_digest_ctx_s *get_digest_ctx(const yaca_context_h ctx) } static int get_digest_output_length(const yaca_context_h ctx, - UNUSED size_t input_len, + size_t input_len, size_t *output_len) { assert(output_len != NULL); struct yaca_digest_ctx_s *c = get_digest_ctx(ctx); - if (c == NULL) + if (c == NULL || input_len != 0) return YACA_ERROR_INVALID_PARAMETER; int md_size = EVP_MD_CTX_size(c->mdctx); diff --git a/src/sign.c b/src/sign.c index 98543e0..5dd261c 100644 --- a/src/sign.c +++ b/src/sign.c @@ -64,14 +64,14 @@ static struct yaca_sign_ctx_s *get_sign_ctx(const yaca_context_h ctx) } static int get_sign_output_length(const yaca_context_h ctx, - UNUSED size_t input_len, + size_t input_len, size_t *output_len) { assert(output_len != NULL); struct yaca_sign_ctx_s *c = get_sign_ctx(ctx); - if (c == NULL) + if (c == NULL || input_len != 0) return YACA_ERROR_INVALID_PARAMETER; assert(c->mdctx != NULL); -- 2.7.4