Class: COSE::Key
- Inherits:
-
Object
- Object
- COSE::Key
- Defined in:
- lib/cose/key.rb,
lib/cose/key/ec2.rb,
lib/cose/key/rsa.rb
Defined Under Namespace
Classes: EC2, Exception, NotImplementedError, RSA, UknownAlgorithm
Constant Summary collapse
- KTY =
1
- KID =
2
- ALG =
3
- OPS =
4
- BASE_IV =
5
- KTY_OKP =
1
- KTY_EC2 =
2
- KTY_RSA =
3
- KTY_SYMMETRIC =
4
Instance Attribute Summary collapse
-
#alg ⇒ Object
Returns the value of attribute alg.
-
#base_iv ⇒ Object
Returns the value of attribute base_iv.
-
#kid ⇒ Object
Returns the value of attribute kid.
-
#kty ⇒ Object
Returns the value of attribute kty.
-
#ops ⇒ Object
Returns the value of attribute ops.
-
#raw ⇒ Object
Returns the value of attribute raw.
Class Method Summary collapse
Instance Method Summary collapse
- #alg_key ⇒ Object
- #digest ⇒ Object
-
#initialize(attrs = {}) ⇒ Key
constructor
A new instance of Key.
- #to_key ⇒ Object
Constructor Details
Instance Attribute Details
#alg ⇒ Object
Returns the value of attribute alg.
21 22 23 |
# File 'lib/cose/key.rb', line 21 def alg @alg end |
#base_iv ⇒ Object
Returns the value of attribute base_iv.
21 22 23 |
# File 'lib/cose/key.rb', line 21 def base_iv @base_iv end |
#kid ⇒ Object
Returns the value of attribute kid.
21 22 23 |
# File 'lib/cose/key.rb', line 21 def kid @kid end |
#kty ⇒ Object
Returns the value of attribute kty.
21 22 23 |
# File 'lib/cose/key.rb', line 21 def kty @kty end |
#ops ⇒ Object
Returns the value of attribute ops.
21 22 23 |
# File 'lib/cose/key.rb', line 21 def ops @ops end |
#raw ⇒ Object
Returns the value of attribute raw.
21 22 23 |
# File 'lib/cose/key.rb', line 21 def raw @raw end |
Class Method Details
.decode(cbor) ⇒ Object
44 45 46 47 48 |
# File 'lib/cose/key.rb', line 44 def decode(cbor) key = detect CBOR.decode(cbor) key.raw = cbor key end |
.detect(attrs = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/cose/key.rb', line 50 def detect(attrs = {}) klass = case attrs[KTY] when KTY_OKP raise NotImplementedError, 'Unsupported Key Type: OKP' when KTY_EC2 EC2 when KTY_RSA RSA when KTY_SYMMETRIC raise NotImplementedError, 'Unsupported Key Type: Symmetric' else raise UknownAlgorithm, 'Unknown Key Type' end klass.new attrs end |
Instance Method Details
#alg_key ⇒ Object
31 32 33 |
# File 'lib/cose/key.rb', line 31 def alg_key raise NotImplementedError, 'Implement me' end |
#digest ⇒ Object
35 36 37 |
# File 'lib/cose/key.rb', line 35 def digest raise NotImplementedError, 'Implement me' end |
#to_key ⇒ Object
39 40 41 |
# File 'lib/cose/key.rb', line 39 def to_key raise NotImplementedError, 'Implement me' end |