Get rid of EVP_MD from digest struct, it's redudant. 78/65778/2
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Tue, 12 Apr 2016 11:33:19 +0000 (13:33 +0200)
committerMateusz Kulikowski <mateusz.kulikowski@gmail.com>
Wed, 13 Apr 2016 06:51:18 +0000 (23:51 -0700)
Change-Id: I52d84125d4b0f2ab1face439477efcc82ee0a0fe

src/digest.c

index 4cc0ceb..bd3f62f 100644 (file)
@@ -32,7 +32,6 @@ struct yaca_digest_ctx_s
 {
        struct yaca_ctx_s ctx;
 
-       const EVP_MD *md;
        EVP_MD_CTX *mdctx;
 };
 
@@ -57,7 +56,7 @@ static int get_digest_output_length(const yaca_ctx_h ctx, size_t input_len)
        if (c == NULL)
                return YACA_ERROR_INVALID_ARGUMENT;
 
-       return EVP_MD_size(c->md);
+       return EVP_MD_CTX_size(c->mdctx);
 }
 
 static void destroy_digest_context(yaca_ctx_h ctx)
@@ -117,6 +116,7 @@ API int yaca_digest_init(yaca_ctx_h *ctx, yaca_digest_algo_e algo)
 {
        int ret;
        struct yaca_digest_ctx_s *nc = NULL;
+       const EVP_MD *md;
 
        if (ctx == NULL)
                return YACA_ERROR_INVALID_ARGUMENT;
@@ -129,7 +129,7 @@ API int yaca_digest_init(yaca_ctx_h *ctx, yaca_digest_algo_e algo)
        nc->ctx.ctx_destroy = destroy_digest_context;
        nc->ctx.get_output_length = get_digest_output_length;
 
-       ret = digest_get_algorithm(algo, &nc->md);
+       ret = digest_get_algorithm(algo, &md);
        if (ret < 0)
                goto free;
 
@@ -139,7 +139,7 @@ API int yaca_digest_init(yaca_ctx_h *ctx, yaca_digest_algo_e algo)
                goto free;
        }
 
-       ret = EVP_DigestInit(nc->mdctx, nc->md);
+       ret = EVP_DigestInit(nc->mdctx, md);
        if (ret != 1) {
                ret = YACA_ERROR_OPENSSL_FAILURE;
                goto ctx;