diff options
Diffstat (limited to 'src/apk_crypto.h')
-rw-r--r-- | src/apk_crypto.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/apk_crypto.h b/src/apk_crypto.h index 0330694..18bf3b5 100644 --- a/src/apk_crypto.h +++ b/src/apk_crypto.h @@ -90,10 +90,16 @@ static inline int apk_digest_ctx_init(struct apk_digest_ctx *dctx, uint8_t alg) #ifdef EVP_MD_CTX_FLAG_FINALISE EVP_MD_CTX_set_flags(dctx->mdctx, EVP_MD_CTX_FLAG_FINALISE); #endif - EVP_DigestInit_ex(dctx->mdctx, apk_digest_alg_to_evp(alg), 0); + if (alg != APK_DIGEST_NONE) EVP_DigestInit_ex(dctx->mdctx, apk_digest_alg_to_evp(alg), 0); return 0; } +static inline void apk_digest_ctx_reset(struct apk_digest_ctx *dctx, uint8_t alg) +{ + dctx->alg = alg; + EVP_DigestInit_ex(dctx->mdctx, apk_digest_alg_to_evp(alg), 0); +} + static inline void apk_digest_ctx_free(struct apk_digest_ctx *dctx) { EVP_MD_CTX_free(dctx->mdctx); dctx->mdctx = 0; |