cose-key 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c399bef4e84efa44f1dd0dd9b9b66880e21d96cbd5bf0e30e7cc8442024584b0
4
- data.tar.gz: 940db110f7cf0aa53e80144055cd37bf588c49c2265185a95daab724cf73cbbb
3
+ metadata.gz: 3cb49170acb17ea18e9ef50d25a4d1a04ffd1f92777dd0093d7d59ababaf558d
4
+ data.tar.gz: a239aef8a89fa66df33a57c77abd9a108a108e984100da0389ba4f62994a42d5
5
5
  SHA512:
6
- metadata.gz: cb61d465aed76f23ef27476acecb3f11a6ff58cff29519a31edb093437eb25aec46f849cb9fd760d40503e06218bff982dfc8f58a16d189775238fc8d6f17bd7
7
- data.tar.gz: 36f7f72d396fd73fee8cc8f5e2c291d4ccca4ee9b57e348a2f07252203c0fda03d9d80be9954470cbf53d23ff204e076ca40cbd7399d7c2ab5144aaf69e8e935
6
+ metadata.gz: 1bdbcf363e1050948b07694c4957b73b44e52c1e042775a30fe68d058c98b9b9419d7c79e80bf1c848de7dd195665d30fd2461f7295c433104cdf21098734c34
7
+ data.tar.gz: bcfb14988ad3b698f7399fd4ea3c200d6ca01ac72b3033fc7b60eb468212ad6dcba4c58c3e3aa40aa61767d98c2e3ff365ed835e93c1b5d82ac3438a6dcc99e7
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/lib/cose/key.rb CHANGED
@@ -14,7 +14,7 @@ module COSE
14
14
  KTY_RSA = 3
15
15
  KTY_SYMMETRIC = 4
16
16
 
17
- attr_accessor :kty, :kid, :alg, :ops, :base_iv
17
+ attr_accessor :kty, :kid, :alg, :ops, :base_iv, :raw
18
18
 
19
19
  def initialize(attrs = {})
20
20
  self.kty = attrs[KTY]
@@ -32,6 +32,10 @@ module COSE
32
32
  raise 'Implement me'
33
33
  end
34
34
 
35
+ def to_s
36
+ raw
37
+ end
38
+
35
39
  def to_pem
36
40
  to_key.to_pem
37
41
  end
@@ -42,7 +46,9 @@ module COSE
42
46
 
43
47
  class << self
44
48
  def decode(cbor)
45
- detect CBOR.decode(cbor)
49
+ key = detect CBOR.decode(cbor)
50
+ key.raw = cbor
51
+ key
46
52
  end
47
53
 
48
54
  def detect(attrs = {})
@@ -10,6 +10,7 @@ RSpec.describe COSE::Key do
10
10
  -----END PUBLIC KEY-----
11
11
  PEM
12
12
  end
13
+ let(:ec2_key) { OpenSSL::PKey::EC.new ec2_pem }
13
14
  let(:decoded) { COSE::Key.decode cbor }
14
15
 
15
16
  context 'for EC keys' do
@@ -34,6 +35,21 @@ RSpec.describe COSE::Key do
34
35
  subject { decoded.to_key }
35
36
  it { should be_instance_of OpenSSL::PKey::EC }
36
37
  end
38
+
39
+ # describe '#to_s' do
40
+ # subject { decoded.to_s }
41
+ # it { should == ec2_cbor }
42
+ # end
43
+
44
+ describe '#to_pem' do
45
+ subject { decoded.to_pem }
46
+ it { should == ec2_pem }
47
+ end
48
+
49
+ describe '#to_text' do
50
+ subject { decoded.to_text }
51
+ it { should == ec2_key.to_text }
52
+ end
37
53
  end
38
54
 
39
55
  context 'for RSA keys' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cose-key
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov matake