Class: OpenSSL::PKey::RSA

Inherits:
Object
  • Object
show all
Defined in:
lib/microsoft_rsa/core_ext/ossl_pkey_rsa.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_xml(source) ⇒ Object



28
29
30
31
32
33
# File 'lib/microsoft_rsa/core_ext/ossl_pkey_rsa.rb', line 28

def from_xml(source)
  source = ::File.new(source) unless source =~ /RSAKeyValue/

  rsa_params = parse_xml(source)
  build_rsa(rsa_params)
end

Instance Method Details

#to_rexmlObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/microsoft_rsa/core_ext/ossl_pkey_rsa.rb', line 14

def to_rexml
  doc = REXML::Document.new
  doc.add_element('RSAKeyValue')

  MicrosoftRSA::ELEMENTS.each do |k, v|
    next if send(v).nil?
    text = MicrosoftRSA::Utils.bn_to_base64(send(v))
    doc[0] << REXML::Element.new(k).add_text(text)
  end

  doc
end

#to_xmlObject



6
7
8
9
10
11
12
# File 'lib/microsoft_rsa/core_ext/ossl_pkey_rsa.rb', line 6

def to_xml
  rexml = to_rexml

  s = StringIO.new
  rexml.write(s, 2)
  s.string
end