aboutsummaryrefslogtreecommitdiffstats
path: root/lib/openssl
diff options
context:
space:
mode:
authorBart de Water <bartdewater@gmail.com>2020-04-19 11:14:36 -0400
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-04-21 16:33:09 +1200
commitb28fb2f05c1e90130b2d4fdcbdae5234b66bbb05 (patch)
tree80433a4fb91b4c81ba2a38e2cb96de8b04275bf2 /lib/openssl
parent2ca54fe46e87f8a14ff9b7c41e21f0c2e013e55e (diff)
downloadruby-openssl-b28fb2f05c1e90130b2d4fdcbdae5234b66bbb05.tar.gz
Look up digest by name instead of constant
Diffstat (limited to 'lib/openssl')
-rw-r--r--lib/openssl/digest.rb15
1 files changed, 2 insertions, 13 deletions
diff --git a/lib/openssl/digest.rb b/lib/openssl/digest.rb
index 92d358d2..2ff8398e 100644
--- a/lib/openssl/digest.rb
+++ b/lib/openssl/digest.rb
@@ -15,17 +15,6 @@
module OpenSSL
class Digest
- # You can get a list of all algorithms:
- # openssl list -digest-algorithms
-
- ALGORITHMS = %w(MD4 MD5 RIPEMD160 SHA1 SHA224 SHA256 SHA384 SHA512)
-
- if !OPENSSL_VERSION.include?("LibreSSL") && OPENSSL_VERSION_NUMBER > 0x10101000
- ALGORITHMS.concat %w(BLAKE2b512 BLAKE2s256 SHA3-224 SHA3-256 SHA3-384 SHA3-512 SHA512-224 SHA512-256)
- end
-
- ALGORITHMS.freeze
-
# Return the hash value computed with _name_ Digest. _name_ is either the
# long name or short name of a supported digest algorithm.
#
@@ -35,13 +24,13 @@ module OpenSSL
#
# which is equivalent to:
#
- # OpenSSL::Digest::SHA256.digest("abc")
+ # OpenSSL::Digest.digest('SHA256', "abc")
def self.digest(name, data)
super(data, name)
end
- ALGORITHMS.each do |name|
+ %w(MD4 MD5 RIPEMD160 SHA1 SHA224 SHA256 SHA384 SHA512).each do |name|
klass = Class.new(self) {
define_method(:initialize, ->(data = nil) {super(name, data)})
}