Module: COSE::Key
- Defined in:
- lib/cose/key.rb,
lib/cose/key/ec2.rb,
lib/cose/key/okp.rb,
lib/cose/key/rsa.rb,
lib/cose/key/base.rb,
lib/cose/key/curve.rb,
lib/cose/key/curve_key.rb,
lib/cose/key/symmetric.rb
Defined Under Namespace
Classes: Base, Curve, CurveKey, EC2, OKP, RSA, Symmetric
Class Method Summary
collapse
Class Method Details
.cbor_decode(data) ⇒ Object
53
54
55
56
57
|
# File 'lib/cose/key.rb', line 53
def self.cbor_decode(data)
CBOR.decode(data)
rescue CBOR::MalformedFormatError, EOFError, FloatDomainError, RegexpError, TypeError, URI::InvalidURIError
raise COSE::MalformedKeyError, "Malformed CBOR key input"
end
|
.deserialize(data) ⇒ Object
.from_pkey(pkey) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/cose/key.rb', line 21
def self.from_pkey(pkey)
case pkey
when OpenSSL::PKey::EC, OpenSSL::PKey::EC::Point
COSE::Key::EC2.from_pkey(pkey)
when OpenSSL::PKey::RSA
COSE::Key::RSA.from_pkey(pkey)
when OpenSSL::PKey::PKey
COSE::Key::OKP.from_pkey(pkey)
else
raise "Unsupported #{pkey.class} object"
end
end
|
.serialize(pkey) ⇒ Object
17
18
19
|
# File 'lib/cose/key.rb', line 17
def self.serialize(pkey)
from_pkey(pkey).serialize
end
|