lib/cose/key.rb in cose-0.7.0 vs lib/cose/key.rb in cose-0.8.0

- old
+ new

@@ -8,16 +8,20 @@ module COSE class UnknownKeyType < StandardError; end module Key def self.serialize(pkey) + from_pkey(pkey).serialize + end + + def self.from_pkey(pkey) case pkey when OpenSSL::PKey::EC, OpenSSL::PKey::EC::Point - COSE::Key::EC2.from_pkey(pkey).serialize + COSE::Key::EC2.from_pkey(pkey) when OpenSSL::PKey::RSA - COSE::Key::RSA.from_pkey(pkey).serialize + COSE::Key::RSA.from_pkey(pkey) else - raise "Unsupported serialization of #{pkey.class} object" + raise "Unsupported #{pkey.class} object" end end def self.deserialize(data) map = CBOR.decode(data)