Set RSAPublicKey#sha1, #sha256
This commit is contained in:
parent
abcdea4e43
commit
a9484918a5
2 changed files with 27 additions and 0 deletions
|
@ -11,6 +11,9 @@ class CreateRSAKeys
|
|||
|
||||
public_key.bits = BITS
|
||||
|
||||
public_key.sha1 = Digest::SHA1.hexdigest pkey.public_key.to_der
|
||||
public_key.sha256 = Digest::SHA256.hexdigest pkey.public_key.to_der
|
||||
|
||||
public_key.public_key_pem = pkey.public_key.to_pem.freeze
|
||||
public_key.private_key_pem = pkey.to_pem.freeze
|
||||
|
||||
|
|
|
@ -13,6 +13,14 @@ RSpec.describe CreateRSAKeys do
|
|||
expect(subject.public_key).to be_instance_of RSAPublicKey
|
||||
end
|
||||
|
||||
specify do
|
||||
expect(subject.public_key.sha1).not_to be_blank
|
||||
end
|
||||
|
||||
specify do
|
||||
expect(subject.public_key.sha256).not_to be_blank
|
||||
end
|
||||
|
||||
specify do
|
||||
expect(subject.public_key.private_key_pem).not_to be_blank
|
||||
end
|
||||
|
@ -32,6 +40,22 @@ RSpec.describe CreateRSAKeys do
|
|||
raise_error
|
||||
end
|
||||
|
||||
specify do
|
||||
expect(subject.public_key.sha1).to eq(
|
||||
Digest::SHA1.hexdigest(
|
||||
OpenSSL::PKey::RSA.new(subject.public_key.public_key_pem).to_der,
|
||||
),
|
||||
)
|
||||
end
|
||||
|
||||
specify do
|
||||
expect(subject.public_key.sha256).to eq(
|
||||
Digest::SHA256.hexdigest(
|
||||
OpenSSL::PKey::RSA.new(subject.public_key.public_key_pem).to_der,
|
||||
),
|
||||
)
|
||||
end
|
||||
|
||||
specify do
|
||||
expect(subject.public_key.public_key_pem).to eq(
|
||||
OpenSSL::PKey::RSA.new(subject.public_key.private_key_pem)
|
||||
|
|
Reference in a new issue