summaryrefslogtreecommitdiff
path: root/ext/openssl/ossl_digest.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/openssl/ossl_digest.c')
-rw-r--r--ext/openssl/ossl_digest.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/ext/openssl/ossl_digest.c b/ext/openssl/ossl_digest.c
index cb0cade1bf7..ab165c4a84d 100644
--- a/ext/openssl/ossl_digest.c
+++ b/ext/openssl/ossl_digest.c
@@ -68,7 +68,9 @@ ossl_digest_new(const EVP_MD *md)
ret = ossl_digest_alloc(cDigest);
GetDigest(ret, ctx);
- EVP_DigestInit_ex(ctx, md, NULL);
+ if (EVP_DigestInit_ex(ctx, md, NULL) != 1) {
+ ossl_raise(eDigestError, "Digest initialization failed.");
+ }
return ret;
}
@@ -122,7 +124,9 @@ ossl_digest_initialize(int argc, VALUE *argv, VALUE self)
if (!NIL_P(data)) StringValue(data);
GetDigest(self, ctx);
- EVP_DigestInit_ex(ctx, md, NULL);
+ if (EVP_DigestInit_ex(ctx, md, NULL) != 1) {
+ ossl_raise(eDigestError, "Digest initialization failed.");
+ }
if (!NIL_P(data)) return ossl_digest_update(self, data);
return self;
@@ -159,7 +163,9 @@ ossl_digest_reset(VALUE self)
EVP_MD_CTX *ctx;
GetDigest(self, ctx);
- EVP_DigestInit_ex(ctx, EVP_MD_CTX_md(ctx), NULL);
+ if (EVP_DigestInit_ex(ctx, EVP_MD_CTX_md(ctx), NULL) != 1) {
+ ossl_raise(eDigestError, "Digest initialization failed.");
+ }
return self;
}