Permalink
Browse files

Return SOTER_INVALID_PARAMETER when the caller tries to reuse a hash …

…context after finalising

Although it did not crash for OpenSSL backend before, this is to bring it in
line with BoringSSL and to make error codes consistent.
  • Loading branch information...
secumod committed Dec 26, 2018
1 parent 94f0ca5 commit ef3fd0d51ddf626ad9b5540957b9cdf6685ea7d2
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/soter/openssl/soter_hash.c
@@ -64,6 +64,11 @@ soter_status_t soter_hash_update(soter_hash_ctx_t *hash_ctx, const void *data, s
return SOTER_INVALID_PARAMETER;
}

if (!EVP_MD_CTX_md(hash_ctx->evp_md_ctx))
{
return SOTER_INVALID_PARAMETER;
}

if (EVP_DigestUpdate(hash_ctx->evp_md_ctx, data, length))
{
return SOTER_SUCCESS;
@@ -83,6 +88,11 @@ soter_status_t soter_hash_final(soter_hash_ctx_t *hash_ctx, uint8_t* hash_value,
return SOTER_INVALID_PARAMETER;
}

if (!EVP_MD_CTX_md(hash_ctx->evp_md_ctx))
{
return SOTER_INVALID_PARAMETER;
}

md_length = (size_t)EVP_MD_CTX_size(hash_ctx->evp_md_ctx);

if (!hash_value || (md_length > *hash_length))

0 comments on commit ef3fd0d

Please sign in to comment.