For get_output_length in digest and sign require input_len == 0 54/75054/3
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Thu, 16 Jun 2016 10:55:25 +0000 (12:55 +0200)
committerLukasz Pawelczyk <l.pawelczyk@samsung.com>
Thu, 16 Jun 2016 16:00:52 +0000 (18:00 +0200)
Change-Id: If195121b6c56fcd91c6d88d469d213b13b88dcc9

api/yaca/yaca_crypto.h
src/digest.c
src/sign.c

index b9d9899..d95a7c2 100644 (file)
@@ -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
index 64b88f4..b003e97 100644 (file)
@@ -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);
index 98543e0..5dd261c 100644 (file)
@@ -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);