cose 1.1.0 → 1.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 +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/cose/algorithm.rb +4 -3
- data/lib/cose/algorithm/ecdsa.rb +12 -2
- data/lib/cose/algorithm/signature_algorithm.rb +5 -1
- data/lib/cose/key/curve.rb +1 -0
- data/lib/cose/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9bd8e1fa2c7e0f08d903f81ec2303a60a2377e6ba63c548b0c7f72d1c3197ee
|
4
|
+
data.tar.gz: ccf797d8600edc7020c9248db5bfc60ffdfd7c07f11f7c39cad172116176430e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f27deece5637039eb3fd8ce9a8d33baf99c31fab75036462e40d599c4e0df789cf6f5ada85fcd4df75ebfddef91faa49132b0f08486f2e322e731cf2e217808
|
7
|
+
data.tar.gz: 6eebcecddf4fc55ce1b8f7f219d9dc8bd37f1e01a18a4e3877b47b84398de883cae204d6013349e409836111b82c254a6374e9b104e552c4339ad7a94153df4b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v1.2.0] - 2020-07-10
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- Support ES256K signature algorithm
|
8
|
+
|
3
9
|
## [v1.1.0] - 2020-07-09
|
4
10
|
|
5
11
|
### Dependencies
|
@@ -129,6 +135,7 @@ NOTE: No breaking changes. Moving out of `v0.x` to express the intention to keep
|
|
129
135
|
- EC2 key object
|
130
136
|
- Works with ruby 2.5
|
131
137
|
|
138
|
+
[v1.2.0]: https://github.com/cedarcode/cose-ruby/compare/v1.1.0...v1.2.0/
|
132
139
|
[v1.1.0]: https://github.com/cedarcode/cose-ruby/compare/v1.0.0...v1.1.0/
|
133
140
|
[v1.0.0]: https://github.com/cedarcode/cose-ruby/compare/v0.11.0...v1.0.0/
|
134
141
|
[v0.11.0]: https://github.com/cedarcode/cose-ruby/compare/v0.10.0...v0.11.0/
|
data/lib/cose/algorithm.rb
CHANGED
@@ -26,9 +26,10 @@ module COSE
|
|
26
26
|
@registered_by_name[name]
|
27
27
|
end
|
28
28
|
|
29
|
-
register(ECDSA.new(-7, "ES256", hash_function: "SHA256"))
|
30
|
-
register(ECDSA.new(-35, "ES384", hash_function: "SHA384"))
|
31
|
-
register(ECDSA.new(-36, "ES512", hash_function: "SHA512"))
|
29
|
+
register(ECDSA.new(-7, "ES256", hash_function: "SHA256", curve_name: "P-256"))
|
30
|
+
register(ECDSA.new(-35, "ES384", hash_function: "SHA384", curve_name: "P-384"))
|
31
|
+
register(ECDSA.new(-36, "ES512", hash_function: "SHA512", curve_name: "P-521"))
|
32
|
+
register(ECDSA.new(-47, "ES256K", hash_function: "SHA256", curve_name: "secp256k1"))
|
32
33
|
register(RSAPSS.new(-37, "PS256", hash_function: "SHA256", salt_length: 32))
|
33
34
|
register(RSAPSS.new(-38, "PS384", hash_function: "SHA384", salt_length: 48))
|
34
35
|
register(RSAPSS.new(-39, "PS512", hash_function: "SHA512", salt_length: 64))
|
data/lib/cose/algorithm/ecdsa.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "cose/algorithm/signature_algorithm"
|
4
4
|
require "cose/error"
|
5
|
+
require "cose/key/curve"
|
5
6
|
require "cose/key/ec2"
|
6
7
|
require "openssl"
|
7
8
|
require "openssl/signature_algorithm/ecdsa"
|
@@ -9,12 +10,13 @@ require "openssl/signature_algorithm/ecdsa"
|
|
9
10
|
module COSE
|
10
11
|
module Algorithm
|
11
12
|
class ECDSA < SignatureAlgorithm
|
12
|
-
attr_reader :hash_function
|
13
|
+
attr_reader :hash_function, :curve
|
13
14
|
|
14
|
-
def initialize(*args, hash_function:)
|
15
|
+
def initialize(*args, hash_function:, curve_name:)
|
15
16
|
super(*args)
|
16
17
|
|
17
18
|
@hash_function = hash_function
|
19
|
+
@curve = COSE::Key::Curve.by_name(curve_name) || raise("Couldn't find curve with name='#{curve_name}'")
|
18
20
|
end
|
19
21
|
|
20
22
|
private
|
@@ -29,6 +31,14 @@ module COSE
|
|
29
31
|
OpenSSL::SignatureAlgorithm::ECDSA
|
30
32
|
end
|
31
33
|
|
34
|
+
def signature_algorithm_parameters
|
35
|
+
if curve
|
36
|
+
super.merge(curve: curve.pkey_name)
|
37
|
+
else
|
38
|
+
super
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
32
42
|
def to_pkey(key)
|
33
43
|
case key
|
34
44
|
when COSE::Key::EC2
|
@@ -20,7 +20,7 @@ module COSE
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def valid_signature?(key, signature, verification_data)
|
23
|
-
signature_algorithm = signature_algorithm_class.new(
|
23
|
+
signature_algorithm = signature_algorithm_class.new(**signature_algorithm_parameters)
|
24
24
|
signature_algorithm.verify_key = to_pkey(key)
|
25
25
|
|
26
26
|
begin
|
@@ -30,6 +30,10 @@ module COSE
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
def signature_algorithm_parameters
|
34
|
+
{ hash_function: hash_function }
|
35
|
+
end
|
36
|
+
|
33
37
|
def to_cose_key(key)
|
34
38
|
case key
|
35
39
|
when COSE::Key::Base
|
data/lib/cose/key/curve.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: 1.
|
4
|
+
version: 1.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: 2020-07-
|
12
|
+
date: 2020-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cbor
|