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 b9d9899085816d2c6ef50fe85b2f753f9117ba52..d95a7c2f6a214eacb2fc97fc307ee3d3ec39c971 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 64b88f4ee8d6ba1f17ffa61611cdac4438123d5c..b003e97099a0663df099c08e97b132ff64ca81b2 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 98543e0710bdce1c9661ede1f94a00e63a8fdf7b..5dd261cf21ad8d27fe5aff13637883e867e8a9da 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);