Class: PkiExpress::RSASignatureAlgorithm

Inherits:
SignatureAlgorithm show all
Defined in:
lib/pki_express/pk_algorithms.rb

Instance Attribute Summary

Attributes inherited from SignatureAlgorithm

#digest_algorithm, #name, #oid, #pk_algorithm, #xml_uri

Instance Method Summary collapse

Methods inherited from SignatureAlgorithm

get_instance_by_api_model, get_instance_by_name, get_instance_by_oid, get_instance_by_xml_uri, #md5_with_rsa, #sha1_with_rsa, #sha256_with_rsa, #sha384_with_rsa, #sha512_with_rsa

Constructor Details

#initialize(digest_algorithm) ⇒ RSASignatureAlgorithm

Returns a new instance of RSASignatureAlgorithm.



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/pki_express/pk_algorithms.rb', line 100

def initialize(digest_algorithm)
  case digest_algorithm
  when DigestAlgorithm.md5
    xml_uri = xml_uri = 'http://www.w3.org/2001/04/xmldsig-more#rsa-md5'
    oid = Oids::MD5_WITH_RSA
  when DigestAlgorithm.sha1
    xml_uri = 'http://www.w3.org/2000/09/xmldsig#rsa-sha1'
    oid = Oids::SHA1_WITH_RSA
  when DigestAlgorithm.sha256
    xml_uri = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'
    oid = Oids::SHA256_WITH_RSA
  when DigestAlgorithm.sha384
    xml_uri = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha384'
    oid = Oids::SHA384_WITH_RSA
  when DigestAlgorithm.sha512
    xml_uri = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha512'
    oid = Oids::SHA512_WITH_RSA
  else
    raise 'Unsupported digest algorithms: ' + digest_algorithm.oid
  end

  super(
    digest_algorithm.name + " with RSA",
    oid,
    xml_uri,
    digest_algorithm,
    PKAlgorithms::RSA)
end