class Vcert::KeyType

Attributes

option[R]
type[R]

Public Class Methods

new(type, option) click to toggle source
# File lib/objects/objects.rb, line 334
def initialize(type, option)
  @type = {"rsa" => "rsa", "ec" => "ecdsa", "ecdsa" => "ecdsa"}[type.downcase]
  if @type == nil
    raise Vcert::VcertError, "bad key type"
  end
  if @type == "rsa"
    unless  [512, 1024, 2048, 3072, 4096, 8192].include?(option)
      raise  Vcert::VcertError,"bad option for rsa key: #{option}. should be one from list 512, 1024, 2048, 3072, 4096, 8192"
    end
  else
    unless SUPPORTED_CURVES.include?(option)
      raise Vcert::VcertError, "bad option for ec key: #{option}. should be one from list #{ SUPPORTED_CURVES}"
    end
  end
  @option = option
end

Public Instance Methods

==(other) click to toggle source
# File lib/objects/objects.rb, line 350
def ==(other)
  unless other.instance_of? KeyType
    return false
  end
  self.type == other.type && self.option == other.option
end