class Xml::Kit::KeyInfo
An implementation of the KeyInfo
element. www.w3.org/TR/xmldsig-core1/#sec-KeyInfo
@since 0.3.0
Attributes
encrypted_key[RW]
key_name[RW]
x509_data[RW]
Public Class Methods
new(x509: nil, encrypted_key: nil) { |self| ... }
click to toggle source
# File lib/xml/kit/key_info.rb, line 19 def initialize(x509: nil, encrypted_key: nil) @encrypted_key = encrypted_key @x509_data = x509 yield self if block_given? end
Public Instance Methods
asymmetric_cipher(algorithm: Crypto::RsaCipher::ALGORITHM)
click to toggle source
Calls superclass method
Xml::Kit::Templatable#asymmetric_cipher
# File lib/xml/kit/key_info.rb, line 25 def asymmetric_cipher(algorithm: Crypto::RsaCipher::ALGORITHM) return encrypted_key.asymmetric_cipher if encrypted_key if x509_data return Crypto.cipher_for( derive_algorithm_from(x509_data.public_key), x509_data.public_key ) end super(algorithm: algorithm) end
key_value()
click to toggle source
# File lib/xml/kit/key_info.rb, line 44 def key_value @key_value ||= KeyValue.new end
retrieval_method()
click to toggle source
# File lib/xml/kit/key_info.rb, line 48 def retrieval_method @retrieval_method ||= RetrievalMethod.new end
subject_key_identifier()
click to toggle source
# File lib/xml/kit/key_info.rb, line 52 def subject_key_identifier ski = x509_data.extensions.find { |x| x.oid == 'subjectKeyIdentifier' } return if ski.nil? Base64.strict_encode64(ski.value) end
symmetric_cipher()
click to toggle source
Calls superclass method
Xml::Kit::Templatable#symmetric_cipher
# File lib/xml/kit/key_info.rb, line 38 def symmetric_cipher return super if encrypted_key.nil? encrypted_key.symmetric_cipher end
Private Instance Methods
derive_algorithm_from(key)
click to toggle source
# File lib/xml/kit/key_info.rb, line 61 def derive_algorithm_from(key) case key when OpenSSL::PKey::RSA "#{::Xml::Kit::Namespaces::XMLENC}rsa-1_5" else raise ::Xml::Kit::Error, "#{key.try(:class)} is not supported" end end