cose 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +33 -0
- data/.travis.yml +5 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +57 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +10 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/cose.gemspec +32 -0
- data/lib/cose.rb +7 -0
- data/lib/cose/key/ec2.rb +52 -0
- data/lib/cose/version.rb +5 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 942297236ed3db166f3ca2c214cbb75d796d0540b283eeea274e24670a3046d0
|
4
|
+
data.tar.gz: 4e4806b02f14c40ef7e7ecd0ce866f0bf153103169eb772b99c37c3145e275b5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 75e5802ffb297f37e1157c625a1fa7f22132eb1ba7591d11d226431b755e2777ae432767fa29acc56b61b4963de9307ea937e2f3af644bda1a1bd1b48bf07897
|
7
|
+
data.tar.gz: ca258ea27541fc9f06df83f5c76593e74491c1190d9e2da0aab3f1658bb90dbd9f3d62a486c96c8d97c5500cede385836888fc4326b0b70bf428bea192f807a3
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.4
|
3
|
+
DisabledByDefault: true
|
4
|
+
|
5
|
+
Bundler:
|
6
|
+
Enabled: true
|
7
|
+
|
8
|
+
Gemspec:
|
9
|
+
Enabled: true
|
10
|
+
|
11
|
+
Layout:
|
12
|
+
Enabled: true
|
13
|
+
|
14
|
+
Lint:
|
15
|
+
Enabled: true
|
16
|
+
|
17
|
+
Metrics/LineLength:
|
18
|
+
Max: 120
|
19
|
+
|
20
|
+
Naming:
|
21
|
+
Enabled: true
|
22
|
+
|
23
|
+
Performance:
|
24
|
+
Enabled: true
|
25
|
+
|
26
|
+
Security:
|
27
|
+
Enabled: true
|
28
|
+
|
29
|
+
Style/FrozenStringLiteralComment:
|
30
|
+
Enabled: true
|
31
|
+
|
32
|
+
Style/RedundantFreeze:
|
33
|
+
Enabled: true
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,57 @@
|
|
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
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Gonzalo
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Cose
|
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.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'cose'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install cose
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cose.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "cose"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/cose.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "cose/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "cose"
|
9
|
+
spec.version = COSE::VERSION
|
10
|
+
spec.authors = ["Gonzalo Rodriguez", "Braulio Martinez"]
|
11
|
+
spec.email = ["gonzalo@cedarcode.com", "braulio@cedarcode.com"]
|
12
|
+
|
13
|
+
spec.summary = "COSE in ruby"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
17
|
+
# 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
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_dependency "cbor", "~> 0.5.9.2"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
28
|
+
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"
|
32
|
+
end
|
data/lib/cose.rb
ADDED
data/lib/cose/key/ec2.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cbor"
|
4
|
+
|
5
|
+
module COSE
|
6
|
+
module Key
|
7
|
+
class EC2
|
8
|
+
KTY_LABEL = 1
|
9
|
+
ALG_LABEL = 3
|
10
|
+
|
11
|
+
CRV_LABEL = -1
|
12
|
+
X_LABEL = -2
|
13
|
+
Y_LABEL = -3
|
14
|
+
|
15
|
+
KTY_EC2 = 2
|
16
|
+
|
17
|
+
attr_reader :algorithm, :curve, :x_coordinate, :y_coordinate
|
18
|
+
|
19
|
+
def initialize(algorithm: nil, curve:, x_coordinate:, y_coordinate:)
|
20
|
+
if !curve
|
21
|
+
raise ArgumentError, "Required curve is missing"
|
22
|
+
elsif !x_coordinate
|
23
|
+
raise ArgumentError, "Required x-coordinate is missing"
|
24
|
+
elsif !y_coordinate
|
25
|
+
raise ArgumentError, "Required y-coordinate is missing"
|
26
|
+
else
|
27
|
+
@algorithm = algorithm
|
28
|
+
@curve = curve
|
29
|
+
@x_coordinate = x_coordinate
|
30
|
+
@y_coordinate = y_coordinate
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
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))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/cose/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cose
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gonzalo Rodriguez
|
8
|
+
- Braulio Martinez
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2018-06-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: cbor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.5.9.2
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.5.9.2
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.16'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.16'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: byebug
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '10.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '10.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '10.0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '10.0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '3.0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '3.0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rubocop
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 0.57.0
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - '='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 0.57.0
|
98
|
+
description:
|
99
|
+
email:
|
100
|
+
- gonzalo@cedarcode.com
|
101
|
+
- braulio@cedarcode.com
|
102
|
+
executables: []
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- ".rspec"
|
108
|
+
- ".rubocop.yml"
|
109
|
+
- ".travis.yml"
|
110
|
+
- Gemfile
|
111
|
+
- Gemfile.lock
|
112
|
+
- LICENSE.txt
|
113
|
+
- README.md
|
114
|
+
- Rakefile
|
115
|
+
- bin/console
|
116
|
+
- bin/setup
|
117
|
+
- cose.gemspec
|
118
|
+
- lib/cose.rb
|
119
|
+
- lib/cose/key/ec2.rb
|
120
|
+
- lib/cose/version.rb
|
121
|
+
homepage:
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.7.7
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: COSE in ruby
|
145
|
+
test_files: []
|