cose 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/cose.rb +7 -4
- data/lib/cose/key/curve.rb +32 -0
- data/lib/cose/key/ec2.rb +9 -13
- data/lib/cose/mac.rb +1 -0
- data/lib/cose/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aceb3ea289c6adab5874f31854aebcf18cd5eed0777852858a4fb3a94ac74f54
|
4
|
+
data.tar.gz: a7e16463701f8901a3384cac76b76585927a074c98ec6418ebadf032d2454617
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dbcd246e8a1ab365800f802e3b36433a083d7993c769dc35ab6480657550ff34ff4b68cff867ad2e232d06687c97104074b3994030f6d081c3bfca80087ba8b
|
7
|
+
data.tar.gz: 10b37822696c206a21e682c706dc2457af5edc49209f1939ae49835ba99c4d62d02e5f62ef0c7149aa78efe28390b91e769521cb65cd31f5608c0f69df9bc34d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.7.0] - 2019-05-02
|
4
|
+
|
5
|
+
### Fixed
|
6
|
+
|
7
|
+
- `require "cose"` now correctly requires all features
|
8
|
+
|
3
9
|
## [v0.6.1] - 2019-04-06
|
4
10
|
|
5
11
|
### Fixed
|
@@ -73,6 +79,7 @@
|
|
73
79
|
- EC2 key object
|
74
80
|
- Works with ruby 2.5
|
75
81
|
|
82
|
+
[v0.7.0]: https://github.com/cedarcode/cose-ruby/compare/v0.6.1...v0.7.0/
|
76
83
|
[v0.6.1]: https://github.com/cedarcode/cose-ruby/compare/v0.6.0...v0.6.1/
|
77
84
|
[v0.6.0]: https://github.com/cedarcode/cose-ruby/compare/v0.5.0...v0.6.0/
|
78
85
|
[v0.5.0]: https://github.com/cedarcode/cose-ruby/compare/v0.4.1...v0.5.0/
|
data/lib/cose.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "cose/encrypt"
|
4
|
+
require "cose/encrypt0"
|
5
|
+
require "cose/key"
|
6
|
+
require "cose/mac"
|
7
|
+
require "cose/mac0"
|
8
|
+
require "cose/sign"
|
9
|
+
require "cose/sign1"
|
3
10
|
require "cose/version"
|
4
|
-
|
5
|
-
module COSE
|
6
|
-
# Your code goes here...
|
7
|
-
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module COSE
|
2
|
+
module Key
|
3
|
+
# https://tools.ietf.org/html/rfc8152#section-13.1
|
4
|
+
Curve = Struct.new(:id, :name, :pkey_name) do
|
5
|
+
@curves = {}
|
6
|
+
|
7
|
+
def self.register(id, name, pkey_name)
|
8
|
+
@curves[id] = new(id, name, pkey_name)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.find(id)
|
12
|
+
@curves[id]
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.by_name(name)
|
16
|
+
@curves.values.detect { |curve| curve.name == name }
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.by_pkey_name(pkey_name)
|
20
|
+
@curves.values.detect { |curve| curve.pkey_name == pkey_name }
|
21
|
+
end
|
22
|
+
|
23
|
+
def value
|
24
|
+
id
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
COSE::Key::Curve.register(1, "P-256", "prime256v1")
|
31
|
+
COSE::Key::Curve.register(2, "P-384", "secp384r1")
|
32
|
+
COSE::Key::Curve.register(3, "P-521", "secp521r1")
|
data/lib/cose/key/ec2.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "cose/key/curve"
|
3
4
|
require "cose/key/curve_key"
|
4
5
|
require "openssl"
|
5
6
|
|
@@ -9,15 +10,6 @@ module COSE
|
|
9
10
|
LABEL_Y = -3
|
10
11
|
|
11
12
|
KTY_EC2 = 2
|
12
|
-
CRV_P256 = 1
|
13
|
-
CRV_P384 = 2
|
14
|
-
CRV_P521 = 3
|
15
|
-
|
16
|
-
PKEY_CURVES = {
|
17
|
-
CRV_P256 => "prime256v1",
|
18
|
-
CRV_P384 => "secp384r1",
|
19
|
-
CRV_P521 => "secp521r1"
|
20
|
-
}.freeze
|
21
13
|
|
22
14
|
def self.enforce_type(map)
|
23
15
|
if map[LABEL_KTY] != KTY_EC2
|
@@ -26,7 +18,7 @@ module COSE
|
|
26
18
|
end
|
27
19
|
|
28
20
|
def self.from_pkey(pkey)
|
29
|
-
curve =
|
21
|
+
curve = Curve.by_pkey_name(pkey.group.curve_name) || raise("Unsupported EC curve #{pkey.group.curve_name}")
|
30
22
|
|
31
23
|
case pkey
|
32
24
|
when OpenSSL::PKey::EC::Point
|
@@ -51,7 +43,7 @@ module COSE
|
|
51
43
|
d = private_key.to_s(2)
|
52
44
|
end
|
53
45
|
|
54
|
-
new(crv: curve, x: x, y: y, d: d)
|
46
|
+
new(crv: curve.id, x: x, y: y, d: d)
|
55
47
|
end
|
56
48
|
|
57
49
|
attr_reader :y
|
@@ -76,8 +68,8 @@ module COSE
|
|
76
68
|
end
|
77
69
|
|
78
70
|
def to_pkey
|
79
|
-
if
|
80
|
-
group = OpenSSL::PKey::EC::Group.new(
|
71
|
+
if curve
|
72
|
+
group = OpenSSL::PKey::EC::Group.new(curve.pkey_name)
|
81
73
|
pkey = OpenSSL::PKey::EC.new(group)
|
82
74
|
public_key_bn = OpenSSL::BN.new("\x04" + x + y, 2)
|
83
75
|
public_key_point = OpenSSL::PKey::EC::Point.new(group, public_key_bn)
|
@@ -93,6 +85,10 @@ module COSE
|
|
93
85
|
end
|
94
86
|
end
|
95
87
|
|
88
|
+
def curve
|
89
|
+
Curve.find(crv)
|
90
|
+
end
|
91
|
+
|
96
92
|
def self.keyword_arguments_for_initialize(map)
|
97
93
|
super.merge(y: map[LABEL_Y])
|
98
94
|
end
|
data/lib/cose/mac.rb
CHANGED
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.7.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: 2019-
|
12
|
+
date: 2019-05-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cbor
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- lib/cose/encrypt0.rb
|
145
145
|
- lib/cose/key.rb
|
146
146
|
- lib/cose/key/base.rb
|
147
|
+
- lib/cose/key/curve.rb
|
147
148
|
- lib/cose/key/curve_key.rb
|
148
149
|
- lib/cose/key/ec2.rb
|
149
150
|
- lib/cose/key/okp.rb
|