Skip to content

Commit

Permalink
Initialize RSA public key through ASN1 sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
tobischo committed Apr 15, 2023
1 parent 926cb2c commit 131c1bd
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/epics/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,11 @@ def HPB
modulus = Base64.decode64(node.at_xpath(".//*[local-name() = 'Modulus']").content)
exponent = Base64.decode64(node.at_xpath(".//*[local-name() = 'Exponent']").content)

bank = OpenSSL::PKey::RSA.new
if bank.respond_to?(:set_key)
bank.set_key(OpenSSL::BN.new(modulus, 2), OpenSSL::BN.new(exponent, 2), nil)
else
bank.n = OpenSSL::BN.new(modulus, 2)
bank.e = OpenSSL::BN.new(exponent, 2)
end
sequence = []
sequence << OpenSSL::ASN1::Integer.new(OpenSSL::BN.new(modulus, 2))
sequence << OpenSSL::ASN1::Integer.new(OpenSSL::BN.new(exponent, 2))

bank = OpenSSL::PKey::RSA.new(OpenSSL::ASN1::Sequence(sequence).to_der)

self.keys["#{host_id.upcase}.#{type}"] = Epics::Key.new(bank)
end
Expand Down

0 comments on commit 131c1bd

Please sign in to comment.