|
| 1 | +require_relative '../../../spec_helper' |
| 2 | +require_relative '../../../library/digest/sha1/shared/constants' |
| 3 | +require_relative '../../../library/digest/sha256/shared/constants' |
| 4 | +require_relative '../../../library/digest/sha384/shared/constants' |
| 5 | +require_relative '../../../library/digest/sha512/shared/constants' |
| 6 | +require 'openssl' |
| 7 | + |
| 8 | +describe "OpenSSL::Digest#digest_length" do |
| 9 | + describe "digest_length of OpenSSL::Digest.new(name)" do |
| 10 | + it "returns a SHA1 block length" do |
| 11 | + OpenSSL::Digest.new('sha1').digest_length.should == SHA1Constants::DigestLength |
| 12 | + end |
| 13 | + |
| 14 | + it "returns a SHA256 block length" do |
| 15 | + OpenSSL::Digest.new('sha256').digest_length.should == SHA256Constants::DigestLength |
| 16 | + end |
| 17 | + |
| 18 | + it "returns a SHA384 digest_length" do |
| 19 | + OpenSSL::Digest.new('sha384').digest_length.should == SHA384Constants::DigestLength |
| 20 | + end |
| 21 | + |
| 22 | + it "returns a SHA512 digest_length" do |
| 23 | + OpenSSL::Digest.new('sha512').digest_length.should == SHA512Constants::DigestLength |
| 24 | + end |
| 25 | + end |
| 26 | + |
| 27 | + describe "digest_length of subclasses" do |
| 28 | + it "returns a SHA1 block length" do |
| 29 | + OpenSSL::Digest::SHA1.new.digest_length.should == SHA1Constants::DigestLength |
| 30 | + end |
| 31 | + |
| 32 | + it "returns a SHA256 block length" do |
| 33 | + OpenSSL::Digest::SHA256.new.digest_length.should == SHA256Constants::DigestLength |
| 34 | + end |
| 35 | + |
| 36 | + it "returns a SHA384 digest_length" do |
| 37 | + OpenSSL::Digest::SHA384.new.digest_length.should == SHA384Constants::DigestLength |
| 38 | + end |
| 39 | + |
| 40 | + it "returns a SHA512 digest_length" do |
| 41 | + OpenSSL::Digest::SHA512.new.digest_length.should == SHA512Constants::DigestLength |
| 42 | + end |
| 43 | + end |
| 44 | +end |
0 commit comments