cose 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 942297236ed3db166f3ca2c214cbb75d796d0540b283eeea274e24670a3046d0
4
- data.tar.gz: 4e4806b02f14c40ef7e7ecd0ce866f0bf153103169eb772b99c37c3145e275b5
3
+ metadata.gz: 110dd14d01e9d95f2204f1f822e79193f0bfe058eaac32550e8db378acb53d56
4
+ data.tar.gz: 446fd8dc498be1145266c8582d9b1fe4ad6d416b4a4f8f43dd7fd226fc52f17a
5
5
  SHA512:
6
- metadata.gz: 75e5802ffb297f37e1157c625a1fa7f22132eb1ba7591d11d226431b755e2777ae432767fa29acc56b61b4963de9307ea937e2f3af644bda1a1bd1b48bf07897
7
- data.tar.gz: ca258ea27541fc9f06df83f5c76593e74491c1190d9e2da0aab3f1658bb90dbd9f3d62a486c96c8d97c5500cede385836888fc4326b0b70bf428bea192f807a3
6
+ metadata.gz: 32a204e8b5675c70900f6b255bf877d6951467b8e9508be9f133d4c5abe3aaad9e91a1e29535c25bded3777feb0a44a1c161a2544809ab0b1ce73a8b151921e5
7
+ data.tar.gz: a80dba546e7fdaadddfb1e3fb05a0e8ce3066928d9e415d24268678cd2fd3fd39d03f6dc67b4243911fbdb2a3b7ab7d396f54510e7e72fa77fa79d8ecb797872
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ /Gemfile.lock
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.4
2
+ TargetRubyVersion: 2.2
3
3
  DisabledByDefault: true
4
4
 
5
5
  Bundler:
data/.travis.yml CHANGED
@@ -1,5 +1,13 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.5.1
5
- before_install: gem install bundler -v 1.16.2
4
+ - ruby-head
5
+ - 2.6.1
6
+ - 2.5.3
7
+ - 2.4.5
8
+ before_install: gem install bundler -v 2.0.1
9
+
10
+ matrix:
11
+ fast_finish: true
12
+ allow_failures:
13
+ - rvm: ruby-head
data/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ ## [0.2.0] - 2019-03-04
4
+
5
+ ### Added
6
+
7
+ - Symmetric key object
8
+ - EC2 key suppors D coordinate
9
+ - Works with ruby 2.4
10
+
11
+ ## [v0.1.0] - 2018-06-08
12
+
13
+ ### Added
14
+
15
+ - EC2 key object
16
+ - Works with ruby 2.5
17
+
18
+ [v0.2.0]: https://github.com/cedarcode/cose-ruby/compare/v0.1.0...v.0.2.0/
19
+ [v0.1.0]: https://github.com/cedarcode/cose-ruby/compare/5725d9b5db978f19a21bd59182f092d31a118eff...v0.1.0/
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
- # Cose
1
+ # cose
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cose`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ COSE ([RFC 8152](https://tools.ietf.org/html/rfc8152)) in ruby
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ [![Gem](https://img.shields.io/gem/v/cose.svg?style=flat-square)](https://rubygems.org/gems/cose)
6
+ [![Travis](https://img.shields.io/travis/cedarcode/cose-ruby.svg?style=flat-square)](https://travis-ci.org/cedarcode/cose-ruby)
6
7
 
7
8
  ## Installation
8
9
 
@@ -22,7 +23,42 @@ Or install it yourself as:
22
23
 
23
24
  ## Usage
24
25
 
25
- TODO: Write usage instructions here
26
+ ### Key Objects
27
+
28
+ #### EC2
29
+
30
+ ```ruby
31
+ cbor_data = "..."
32
+
33
+ key = COSE::Key::EC2.from_cbor(cbor_data)
34
+
35
+ key.curve
36
+ key.x_coordinate
37
+ key.y_coordinate
38
+ key.d_coordinate
39
+ ```
40
+
41
+ #### Symmetric
42
+
43
+ ```ruby
44
+ cbor_data = "..."
45
+
46
+ key = COSE::Key::Symmetric.from_cbor(cbor_data)
47
+
48
+ key.key_value
49
+ ```
50
+
51
+ ### Signing Objects
52
+
53
+ _Pending_
54
+
55
+ ### MAC Objects
56
+
57
+ _Pending_
58
+
59
+ ### Encryption Objects
60
+
61
+ _Pending_
26
62
 
27
63
  ## Development
28
64
 
@@ -32,7 +68,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
68
 
33
69
  ## Contributing
34
70
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cose.
71
+ Bug reports and pull requests are welcome on GitHub at https://github.com/cedarcode/cose-ruby.
36
72
 
37
73
  ## License
38
74
 
data/cose.gemspec CHANGED
@@ -10,23 +10,32 @@ Gem::Specification.new do |spec|
10
10
  spec.authors = ["Gonzalo Rodriguez", "Braulio Martinez"]
11
11
  spec.email = ["gonzalo@cedarcode.com", "braulio@cedarcode.com"]
12
12
 
13
- spec.summary = "COSE in ruby"
13
+ spec.summary = "COSE (RFC 8152) ruby library"
14
+ spec.homepage = "https://github.com/cedarcode/cose-ruby"
14
15
  spec.license = "MIT"
15
16
 
17
+ spec.metadata = {
18
+ "bug_tracker_uri" => "https://github.com/cedarcode/cose-ruby/issues",
19
+ "changelog_uri" => "https://github.com/cedarcode/cose-ruby/blob/master/CHANGELOG.md",
20
+ "source_code_uri" => "https://github.com/cedarcode/cose-ruby"
21
+ }
22
+
16
23
  # Specify which files should be added to the gem when it is released.
17
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
26
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
27
  end
21
28
  spec.bindir = "exe"
22
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
30
  spec.require_paths = ["lib"]
24
31
 
32
+ spec.required_ruby_version = ">= 2.2"
33
+
25
34
  spec.add_dependency "cbor", "~> 0.5.9.2"
26
35
 
27
- spec.add_development_dependency "bundler", "~> 1.16"
36
+ spec.add_development_dependency "bundler", ">= 1.17", "< 3"
28
37
  spec.add_development_dependency "byebug", "~> 10.0"
29
- spec.add_development_dependency "rake", "~> 10.0"
30
- spec.add_development_dependency "rspec", "~> 3.0"
31
- spec.add_development_dependency "rubocop", "0.57.0"
38
+ spec.add_development_dependency "rake", "~> 12.3"
39
+ spec.add_development_dependency "rspec", "~> 3.8"
40
+ spec.add_development_dependency "rubocop", "0.58.2"
32
41
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cbor"
4
+
5
+ module COSE
6
+ module Key
7
+ class Base
8
+ KTY_LABEL = 1
9
+
10
+ def self.from_cbor(cbor)
11
+ from_map(CBOR.decode(cbor))
12
+ end
13
+
14
+ def self.enforce_type(map, kty, error_message)
15
+ if map[KTY_LABEL] != kty
16
+ raise error_message
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
data/lib/cose/key/ec2.rb CHANGED
@@ -1,22 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "cbor"
3
+ require "cose/key/base"
4
4
 
5
5
  module COSE
6
6
  module Key
7
- class EC2
8
- KTY_LABEL = 1
7
+ class EC2 < Base
9
8
  ALG_LABEL = 3
10
9
 
11
10
  CRV_LABEL = -1
11
+ D_LABEL = -4
12
12
  X_LABEL = -2
13
13
  Y_LABEL = -3
14
14
 
15
15
  KTY_EC2 = 2
16
16
 
17
- attr_reader :algorithm, :curve, :x_coordinate, :y_coordinate
17
+ attr_reader :algorithm, :curve, :d_coordinate, :x_coordinate, :y_coordinate
18
18
 
19
- def initialize(algorithm: nil, curve:, x_coordinate:, y_coordinate:)
19
+ def initialize(algorithm: nil, curve:, d_coordinate: nil, x_coordinate:, y_coordinate:)
20
20
  if !curve
21
21
  raise ArgumentError, "Required curve is missing"
22
22
  elsif !x_coordinate
@@ -26,26 +26,22 @@ module COSE
26
26
  else
27
27
  @algorithm = algorithm
28
28
  @curve = curve
29
+ @d_coordinate = d_coordinate
29
30
  @x_coordinate = x_coordinate
30
31
  @y_coordinate = y_coordinate
31
32
  end
32
33
  end
33
34
 
34
35
  def self.from_map(map)
35
- if map[KTY_LABEL] == KTY_EC2
36
- new(
37
- algorithm: map[ALG_LABEL],
38
- curve: map[CRV_LABEL],
39
- x_coordinate: map[X_LABEL],
40
- y_coordinate: map[Y_LABEL]
41
- )
42
- else
43
- raise "Not an EC2 key"
44
- end
45
- end
46
-
47
- def self.from_cbor(cbor)
48
- from_map(CBOR.decode(cbor))
36
+ enforce_type(map, KTY_EC2, "Not an EC2 key")
37
+
38
+ new(
39
+ algorithm: map[ALG_LABEL],
40
+ curve: map[CRV_LABEL],
41
+ d_coordinate: map[D_LABEL],
42
+ x_coordinate: map[X_LABEL],
43
+ y_coordinate: map[Y_LABEL]
44
+ )
49
45
  end
50
46
  end
51
47
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cose/key/base"
4
+
5
+ module COSE
6
+ module Key
7
+ class Symmetric < Base
8
+ K_LABEL = -1
9
+ KTY_SYMMETRIC = 4
10
+
11
+ attr_reader :key_value
12
+
13
+ def initialize(key_value:)
14
+ if !key_value
15
+ raise ArgumentError, "Required key value is missing"
16
+ end
17
+
18
+ @key_value = key_value
19
+ end
20
+
21
+ def self.from_map(map)
22
+ enforce_type(map, KTY_SYMMETRIC, "Not a Symmetric key")
23
+
24
+ new(key_value: map[K_LABEL])
25
+ end
26
+ end
27
+ end
28
+ end
data/lib/cose/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module COSE
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gonzalo Rodriguez
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-06-08 00:00:00.000000000 Z
12
+ date: 2019-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cbor
@@ -29,16 +29,22 @@ dependencies:
29
29
  name: bundler
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '1.17'
35
+ - - "<"
33
36
  - !ruby/object:Gem::Version
34
- version: '1.16'
37
+ version: '3'
35
38
  type: :development
36
39
  prerelease: false
37
40
  version_requirements: !ruby/object:Gem::Requirement
38
41
  requirements:
39
- - - "~>"
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '1.17'
45
+ - - "<"
40
46
  - !ruby/object:Gem::Version
41
- version: '1.16'
47
+ version: '3'
42
48
  - !ruby/object:Gem::Dependency
43
49
  name: byebug
44
50
  requirement: !ruby/object:Gem::Requirement
@@ -59,42 +65,42 @@ dependencies:
59
65
  requirements:
60
66
  - - "~>"
61
67
  - !ruby/object:Gem::Version
62
- version: '10.0'
68
+ version: '12.3'
63
69
  type: :development
64
70
  prerelease: false
65
71
  version_requirements: !ruby/object:Gem::Requirement
66
72
  requirements:
67
73
  - - "~>"
68
74
  - !ruby/object:Gem::Version
69
- version: '10.0'
75
+ version: '12.3'
70
76
  - !ruby/object:Gem::Dependency
71
77
  name: rspec
72
78
  requirement: !ruby/object:Gem::Requirement
73
79
  requirements:
74
80
  - - "~>"
75
81
  - !ruby/object:Gem::Version
76
- version: '3.0'
82
+ version: '3.8'
77
83
  type: :development
78
84
  prerelease: false
79
85
  version_requirements: !ruby/object:Gem::Requirement
80
86
  requirements:
81
87
  - - "~>"
82
88
  - !ruby/object:Gem::Version
83
- version: '3.0'
89
+ version: '3.8'
84
90
  - !ruby/object:Gem::Dependency
85
91
  name: rubocop
86
92
  requirement: !ruby/object:Gem::Requirement
87
93
  requirements:
88
94
  - - '='
89
95
  - !ruby/object:Gem::Version
90
- version: 0.57.0
96
+ version: 0.58.2
91
97
  type: :development
92
98
  prerelease: false
93
99
  version_requirements: !ruby/object:Gem::Requirement
94
100
  requirements:
95
101
  - - '='
96
102
  - !ruby/object:Gem::Version
97
- version: 0.57.0
103
+ version: 0.58.2
98
104
  description:
99
105
  email:
100
106
  - gonzalo@cedarcode.com
@@ -107,8 +113,8 @@ files:
107
113
  - ".rspec"
108
114
  - ".rubocop.yml"
109
115
  - ".travis.yml"
116
+ - CHANGELOG.md
110
117
  - Gemfile
111
- - Gemfile.lock
112
118
  - LICENSE.txt
113
119
  - README.md
114
120
  - Rakefile
@@ -116,12 +122,17 @@ files:
116
122
  - bin/setup
117
123
  - cose.gemspec
118
124
  - lib/cose.rb
125
+ - lib/cose/key/base.rb
119
126
  - lib/cose/key/ec2.rb
127
+ - lib/cose/key/symmetric.rb
120
128
  - lib/cose/version.rb
121
- homepage:
129
+ homepage: https://github.com/cedarcode/cose-ruby
122
130
  licenses:
123
131
  - MIT
124
- metadata: {}
132
+ metadata:
133
+ bug_tracker_uri: https://github.com/cedarcode/cose-ruby/issues
134
+ changelog_uri: https://github.com/cedarcode/cose-ruby/blob/master/CHANGELOG.md
135
+ source_code_uri: https://github.com/cedarcode/cose-ruby
125
136
  post_install_message:
126
137
  rdoc_options: []
127
138
  require_paths:
@@ -130,16 +141,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
141
  requirements:
131
142
  - - ">="
132
143
  - !ruby/object:Gem::Version
133
- version: '0'
144
+ version: '2.2'
134
145
  required_rubygems_version: !ruby/object:Gem::Requirement
135
146
  requirements:
136
147
  - - ">="
137
148
  - !ruby/object:Gem::Version
138
149
  version: '0'
139
150
  requirements: []
140
- rubyforge_project:
141
- rubygems_version: 2.7.7
151
+ rubygems_version: 3.0.2
142
152
  signing_key:
143
153
  specification_version: 4
144
- summary: COSE in ruby
154
+ summary: COSE (RFC 8152) ruby library
145
155
  test_files: []
data/Gemfile.lock DELETED
@@ -1,57 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- cose (0.1.0)
5
- cbor (~> 0.5.9.2)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- ast (2.4.0)
11
- byebug (10.0.2)
12
- cbor (0.5.9.2)
13
- diff-lcs (1.3)
14
- jaro_winkler (1.4.0)
15
- parallel (1.12.1)
16
- parser (2.5.1.0)
17
- ast (~> 2.4.0)
18
- powerpack (0.1.1)
19
- rainbow (3.0.0)
20
- rake (10.5.0)
21
- rspec (3.7.0)
22
- rspec-core (~> 3.7.0)
23
- rspec-expectations (~> 3.7.0)
24
- rspec-mocks (~> 3.7.0)
25
- rspec-core (3.7.1)
26
- rspec-support (~> 3.7.0)
27
- rspec-expectations (3.7.0)
28
- diff-lcs (>= 1.2.0, < 2.0)
29
- rspec-support (~> 3.7.0)
30
- rspec-mocks (3.7.0)
31
- diff-lcs (>= 1.2.0, < 2.0)
32
- rspec-support (~> 3.7.0)
33
- rspec-support (3.7.1)
34
- rubocop (0.57.0)
35
- jaro_winkler (~> 1.4.0)
36
- parallel (~> 1.10)
37
- parser (>= 2.5)
38
- powerpack (~> 0.1)
39
- rainbow (>= 2.2.2, < 4.0)
40
- ruby-progressbar (~> 1.7)
41
- unicode-display_width (~> 1.0, >= 1.0.1)
42
- ruby-progressbar (1.9.0)
43
- unicode-display_width (1.4.0)
44
-
45
- PLATFORMS
46
- ruby
47
-
48
- DEPENDENCIES
49
- bundler (~> 1.16)
50
- byebug (~> 10.0)
51
- cose!
52
- rake (~> 10.0)
53
- rspec (~> 3.0)
54
- rubocop (= 0.57.0)
55
-
56
- BUNDLED WITH
57
- 1.16.2