class PkiExpress::SignatureAlgorithm

Attributes

digest_algorithm[RW]
name[RW]
oid[RW]
pk_algorithm[RW]
xml_uri[RW]

Public Class Methods

get_instance_by_api_model(api_model) click to toggle source
# File lib/pki_express/pk_algorithms.rb, line 89
def get_instance_by_api_model(api_model)
  algorithms
  unless @algorithms.select{|v| v.api_model.downcase == api_model.downcase}.empty?
    return @algorithms.select{|v| v.api_model.downcase == api_model.downcase}.first
  end
  raise 'Unrecognized signature algorithm: ' + api_model
end
get_instance_by_name(name) click to toggle source
# File lib/pki_express/pk_algorithms.rb, line 65
def get_instance_by_name(name)
  algorithms
  unless @algorithms.select{|v| v.name == name}.empty?
    return @algorithms.select{|v| v.name == name}.first
  end
  raise 'Unrecognized signature algorithm name: ' + name
end
get_instance_by_oid(oid) click to toggle source
# File lib/pki_express/pk_algorithms.rb, line 73
def get_instance_by_oid(oid)
  algorithms
  unless @algorithms.select{|v| v.oid == oid}.empty?
    return @algorithms.select{|v| v.oid == oid}.first
  end
  raise 'Unrecognized signature algorithm oid: ' + oid
end
get_instance_by_xml_uri(xml_uri) click to toggle source
# File lib/pki_express/pk_algorithms.rb, line 81
def get_instance_by_xml_uri(xml_uri)
  algorithms
  unless @algorithms.select{|v| v.xml_uri == xml_uri}.empty?
    return @algorithms.select{|v| v.xml_uri == xml_uri}.first
  end
  raise 'Unrecognized signature algorithm XML URI: ' + xml_uri
end

Private Class Methods

algorithms() click to toggle source
# File lib/pki_express/pk_algorithms.rb, line 55
def self.algorithms
  return [md5_with_rsa, sha1_with_rsa, sha256_with_rsa, sha384_with_rsa, sha512_with_rsa]
end
new(name, oid, xml_uri, digest_algorithm, pk_algorithm) click to toggle source
# File lib/pki_express/pk_algorithms.rb, line 17
def initialize(name, oid, xml_uri, digest_algorithm, pk_algorithm)
  @name = name
  @oid = oid
  @xml_uri = xml_uri
  @digest_algorithm = digest_algorithm
  @pk_algorithm = pk_algorithm
end
safe_algorithms() click to toggle source
# File lib/pki_express/pk_algorithms.rb, line 59
def self.safe_algorithms
  return [sha1_with_rsa, sha256_with_rsa, sha384_with_rsa, sha512_with_rsa]
end

Public Instance Methods

md5_with_rsa() click to toggle source
# File lib/pki_express/pk_algorithms.rb, line 25
def md5_with_rsa
  unless @md5_with_rsa
    @md5_with_rsa = RSASignatureAlgorithm.new(DigestAlgorithm.md5)
  end
end
sha1_with_rsa() click to toggle source
# File lib/pki_express/pk_algorithms.rb, line 31
def sha1_with_rsa
  unless @sha1_with_rsa
    @sha1_with_rsa = RSASignatureAlgorithm.new(DigestAlgorithm.sha1)
  end
end
sha256_with_rsa() click to toggle source
# File lib/pki_express/pk_algorithms.rb, line 37
def sha256_with_rsa
  unless @sha256_with_rsa
    @sha256_with_rsa = RSASignatureAlgorithm.new(DigestAlgorithm.sha256)
  end
end
sha384_with_rsa() click to toggle source
# File lib/pki_express/pk_algorithms.rb, line 43
def sha384_with_rsa
  unless @sha384_with_rsa
    @sha384_with_rsa = RSASignatureAlgorithm.new(DigestAlgorithm.sha384)
  end
end
sha512_with_rsa() click to toggle source
# File lib/pki_express/pk_algorithms.rb, line 49
def sha512_with_rsa
  unless @sha512_with_rsa
    @sha512_with_rsa = RSASignatureAlgorithm.new(DigestAlgorithm.sha512)
  end
end