cose 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +1 -1
- data/.travis.yml +10 -2
- data/CHANGELOG.md +19 -0
- data/README.md +41 -5
- data/cose.gemspec +15 -6
- data/lib/cose/key/base.rb +21 -0
- data/lib/cose/key/ec2.rb +15 -19
- data/lib/cose/key/symmetric.rb +28 -0
- data/lib/cose/version.rb +1 -1
- metadata +29 -19
- data/Gemfile.lock +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 110dd14d01e9d95f2204f1f822e79193f0bfe058eaac32550e8db378acb53d56
|
4
|
+
data.tar.gz: 446fd8dc498be1145266c8582d9b1fe4ad6d416b4a4f8f43dd7fd226fc52f17a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32a204e8b5675c70900f6b255bf877d6951467b8e9508be9f133d4c5abe3aaad9e91a1e29535c25bded3777feb0a44a1c161a2544809ab0b1ce73a8b151921e5
|
7
|
+
data.tar.gz: a80dba546e7fdaadddfb1e3fb05a0e8ce3066928d9e415d24268678cd2fd3fd39d03f6dc67b4243911fbdb2a3b7ab7d396f54510e7e72fa77fa79d8ecb797872
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
3
|
rvm:
|
4
|
-
-
|
5
|
-
|
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
|
-
#
|
1
|
+
# cose
|
2
2
|
|
3
|
-
|
3
|
+
COSE ([RFC 8152](https://tools.ietf.org/html/rfc8152)) in ruby
|
4
4
|
|
5
|
-
|
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
|
-
|
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/
|
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
|
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
|
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", "
|
36
|
+
spec.add_development_dependency "bundler", ">= 1.17", "< 3"
|
28
37
|
spec.add_development_dependency "byebug", "~> 10.0"
|
29
|
-
spec.add_development_dependency "rake", "~>
|
30
|
-
spec.add_development_dependency "rspec", "~> 3.
|
31
|
-
spec.add_development_dependency "rubocop", "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 "
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
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.
|
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:
|
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: '
|
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: '
|
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: '
|
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: '
|
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.
|
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.
|
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.
|
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.
|
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: '
|
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
|
-
|
141
|
-
rubygems_version: 2.7.7
|
151
|
+
rubygems_version: 3.0.2
|
142
152
|
signing_key:
|
143
153
|
specification_version: 4
|
144
|
-
summary: COSE
|
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
|