cose-key 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/VERSION +1 -1
 - data/lib/cose/key.rb +8 -2
 - data/spec/cose/key_spec.rb +16 -0
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 3cb49170acb17ea18e9ef50d25a4d1a04ffd1f92777dd0093d7d59ababaf558d
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a239aef8a89fa66df33a57c77abd9a108a108e984100da0389ba4f62994a42d5
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 1bdbcf363e1050948b07694c4957b73b44e52c1e042775a30fe68d058c98b9b9419d7c79e80bf1c848de7dd195665d30fd2461f7295c433104cdf21098734c34
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: bcfb14988ad3b698f7399fd4ea3c200d6ca01ac72b3033fc7b60eb468212ad6dcba4c58c3e3aa40aa61767d98c2e3ff365ed835e93c1b5d82ac3438a6dcc99e7
         
     | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.0. 
     | 
| 
      
 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 = {})
         
     | 
    
        data/spec/cose/key_spec.rb
    CHANGED
    
    | 
         @@ -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
         
     |