Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit 751e558

Browse files
author
Tobias Haagen Michaelsen
committed
Check if OpenSSL is loaded.
Since we changed from `Digest::HMAC` to `OpenSSL::HMAC`, we should check for if `OpenSSL` is loaded, and then we can safely assume that `HMAC` is available. Before `Digest` was always defined, so we had to check if it had loaded its submodules.
1 parent ce2e30d commit 751e558

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib/openid/cryptutil.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def CryptUtil.sha1(text)
3737
end
3838

3939
def CryptUtil.hmac_sha1(key, text)
40-
if OpenSSL.const_defined? :HMAC, false
40+
if defined? OpenSSL
4141
OpenSSL::HMAC.digest(OpenSSL::Digest::SHA1.new, key, text)
4242
else
4343
return HMAC::SHA1.digest(key, text)
@@ -49,7 +49,7 @@ def CryptUtil.sha256(text)
4949
end
5050

5151
def CryptUtil.hmac_sha256(key, text)
52-
if OpenSSL.const_defined? :HMAC, false
52+
if defined? OpenSSL
5353
OpenSSL::HMAC.digest(OpenSSL::Digest::SHA256.new, key, text)
5454
else
5555
return HMAC::SHA256.digest(key, text)

0 commit comments

Comments
 (0)