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
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
- #digest ⇒ Object
-
#initialize(attrs = {}) ⇒ Key
constructor
A new instance of Key.
- #to_key ⇒ Object
- #to_pem ⇒ Object
- #to_s ⇒ Object
- #to_text ⇒ Object
Constructor Details
Instance Attribute Details
#alg ⇒ Object
Returns the value of attribute alg.
17 18 19 |
# File 'lib/cose/key.rb', line 17 def alg @alg end |
#base_iv ⇒ Object
Returns the value of attribute base_iv.
17 18 19 |
# File 'lib/cose/key.rb', line 17 def base_iv @base_iv end |
#kid ⇒ Object
Returns the value of attribute kid.
17 18 19 |
# File 'lib/cose/key.rb', line 17 def kid @kid end |
#kty ⇒ Object
Returns the value of attribute kty.
17 18 19 |
# File 'lib/cose/key.rb', line 17 def kty @kty end |
#ops ⇒ Object
Returns the value of attribute ops.
17 18 19 |
# File 'lib/cose/key.rb', line 17 def ops @ops end |
#raw ⇒ Object
Returns the value of attribute raw.
17 18 19 |
# File 'lib/cose/key.rb', line 17 def raw @raw end |
Class Method Details
.decode(cbor) ⇒ Object
48 49 50 51 52 |
# File 'lib/cose/key.rb', line 48 def decode(cbor) key = detect CBOR.decode(cbor) key.raw = cbor key end |
.detect(attrs = {}) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/cose/key.rb', line 54 def detect(attrs = {}) klass = case attrs[KTY] when KTY_OKP raise 'Unsupported Key Type: OKP' when KTY_EC2 EC2 when KTY_RSA RSA when KTY_SYMMETRIC raise 'Unsupported Key Type: Symmetric' else raise 'Unknown Key Type' end klass.new attrs end |
Instance Method Details
#digest ⇒ Object
27 28 29 |
# File 'lib/cose/key.rb', line 27 def digest raise 'Implement me' end |
#to_key ⇒ Object
31 32 33 |
# File 'lib/cose/key.rb', line 31 def to_key raise 'Implement me' end |
#to_pem ⇒ Object
39 40 41 |
# File 'lib/cose/key.rb', line 39 def to_pem to_key.to_pem end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/cose/key.rb', line 35 def to_s raw end |
#to_text ⇒ Object
43 44 45 |
# File 'lib/cose/key.rb', line 43 def to_text to_key.to_text end |