Class: Vcert::KeyType
- Inherits:
-
Object
- Object
- Vcert::KeyType
- Defined in:
- lib/objects/objects.rb
Instance Attribute Summary collapse
-
#option ⇒ Object
readonly
Returns the value of attribute option.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(type, option) ⇒ KeyType
constructor
A new instance of KeyType.
Constructor Details
#initialize(type, option) ⇒ KeyType
Returns a new instance of KeyType.
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
# 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 |
Instance Attribute Details
#option ⇒ Object (readonly)
Returns the value of attribute option.
332 333 334 |
# File 'lib/objects/objects.rb', line 332 def option @option end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
332 333 334 |
# File 'lib/objects/objects.rb', line 332 def type @type end |
Instance Method Details
#==(other) ⇒ Object
350 351 352 353 354 355 |
# 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 |