summaryrefslogtreecommitdiff
path: root/ext/openssl/ossl_hmac.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/openssl/ossl_hmac.c')
-rw-r--r--ext/openssl/ossl_hmac.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/openssl/ossl_hmac.c b/ext/openssl/ossl_hmac.c
index 15b37d0..5d29b8f 100644
--- a/ext/openssl/ossl_hmac.c
+++ b/ext/openssl/ossl_hmac.c
@@ -70,8 +70,10 @@ ossl_hmac_initialize(VALUE self, VALUE key, VALUE digest)
StringValue(key);
GetHMAC(self, ctx);
- HMAC_Init_ex(ctx, RSTRING_PTR(key), RSTRING_LENINT(key),
- GetDigestPtr(digest), NULL);
+ if (HMAC_Init_ex(ctx, RSTRING_PTR(key), RSTRING_LENINT(key),
+ GetDigestPtr(digest), NULL) != 1) {
+ ossl_raise(eHMACError, "HMAC initialization failed.");
+ }
return self;
}
@@ -180,7 +182,9 @@ ossl_hmac_reset(VALUE self)
HMAC_CTX *ctx;
GetHMAC(self, ctx);
- HMAC_Init_ex(ctx, NULL, 0, NULL, NULL);
+ if (HMAC_Init_ex(ctx, NULL, 0, NULL, NULL) != 1) {
+ ossl_raise(eHMACError, "HMAC initialization failed");
+ }
return self;
}