cose 1.0.0 → 1.3.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/.github/workflows/build.yml +42 -0
- data/Appraisals +4 -4
- data/CHANGELOG.md +25 -1
- data/README.md +1 -1
- data/bin/setup +2 -0
- data/cose.gemspec +1 -1
- data/gemfiles/{openssl_2_0.gemfile → openssl_2_2.gemfile} +1 -1
- data/gemfiles/{openssl_head.gemfile → openssl_3_0.gemfile} +1 -1
- data/lib/cose/algorithm/ecdsa.rb +12 -2
- data/lib/cose/algorithm/eddsa.rb +41 -0
- data/lib/cose/algorithm/signature_algorithm.rb +5 -1
- data/lib/cose/algorithm.rb +6 -3
- data/lib/cose/key/base.rb +2 -4
- data/lib/cose/key/curve.rb +3 -0
- data/lib/cose/key/curve_key.rb +2 -4
- data/lib/cose/key/ec2.rb +29 -8
- data/lib/cose/key/okp.rb +48 -0
- data/lib/cose/key/rsa.rb +25 -26
- data/lib/cose/key.rb +2 -0
- data/lib/cose/version.rb +1 -1
- metadata +13 -12
- data/.travis.yml +0 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8a7da6d20b462494510800b95be262f6100a46b0b066c8255de6f1250a41429b
|
|
4
|
+
data.tar.gz: a758caf5a05445bc36b4c8e2e64f562c181546eb9740d065e48d2c3c5ea22726
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 47e4e46bb5e633a1e0eccb8fc9081411d1ff09439046f8ead15070aa2a2f3329d3b34e9744aa56a13a1cb0e6ff0490abc3148efe8e87d5d9efcaeb0f86fa514b
|
|
7
|
+
data.tar.gz: 2bc529d8091353b0a90a7b04b8e33d490371bfc87c43149a977cde769234b69e9645d9ca8c5677088a91faef8630806c24435ad304551fe467dba4d0cd421971
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
2
|
+
# They are provided by a third-party and are governed by
|
|
3
|
+
# separate terms of service, privacy policy, and support
|
|
4
|
+
# documentation.
|
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
|
7
|
+
|
|
8
|
+
name: build
|
|
9
|
+
|
|
10
|
+
on: push
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
runs-on: ubuntu-20.04
|
|
15
|
+
strategy:
|
|
16
|
+
fail-fast: false
|
|
17
|
+
matrix:
|
|
18
|
+
ruby:
|
|
19
|
+
- 3.0.0
|
|
20
|
+
- 2.7.2
|
|
21
|
+
- 2.6.6
|
|
22
|
+
- 2.5.8
|
|
23
|
+
- 2.4.10
|
|
24
|
+
gemfile:
|
|
25
|
+
- openssl_3_0
|
|
26
|
+
- openssl_2_2
|
|
27
|
+
- openssl_2_1
|
|
28
|
+
- openssl_default
|
|
29
|
+
exclude:
|
|
30
|
+
- ruby: '2.4.10'
|
|
31
|
+
gemfile: openssl_3_0
|
|
32
|
+
- ruby: '2.5.8'
|
|
33
|
+
gemfile: openssl_3_0
|
|
34
|
+
env:
|
|
35
|
+
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v2
|
|
38
|
+
- uses: ruby/setup-ruby@v1
|
|
39
|
+
with:
|
|
40
|
+
ruby-version: ${{ matrix.ruby }}
|
|
41
|
+
bundler-cache: true
|
|
42
|
+
- run: bundle exec rake
|
data/Appraisals
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
appraise "
|
|
4
|
-
gem "openssl",
|
|
3
|
+
appraise "openssl_2_2" do
|
|
4
|
+
gem "openssl", "~> 2.2.0"
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
appraise "openssl_2_1" do
|
|
8
8
|
gem "openssl", "~> 2.1.0"
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
appraise "
|
|
12
|
-
gem "openssl", "~>
|
|
11
|
+
appraise "openssl_3_0" do
|
|
12
|
+
gem "openssl", "~> 3.0.0"
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
appraise "openssl_default" do
|
data/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [v1.3.0] - 2022-10-28
|
|
4
|
+
|
|
5
|
+
- Add support for EdDSA (#55). Credits to @bdewater.
|
|
6
|
+
|
|
7
|
+
## [v1.2.1] - 2022-07-03
|
|
8
|
+
|
|
9
|
+
- Support OpenSSL ~>3.0.0. Credits to @ClearlyClaire <3
|
|
10
|
+
|
|
11
|
+
## [v1.2.0] - 2020-07-10
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Support ES256K signature algorithm
|
|
16
|
+
|
|
17
|
+
## [v1.1.0] - 2020-07-09
|
|
18
|
+
|
|
19
|
+
### Dependencies
|
|
20
|
+
|
|
21
|
+
- Update `openssl-signature_algorithm` runtime dependency from `~> 0.4.0` to `~> 1.0`.
|
|
22
|
+
|
|
3
23
|
## [v1.0.0] - 2020-03-29
|
|
4
24
|
|
|
5
25
|
### Added
|
|
6
26
|
|
|
7
27
|
- Signature verification validates key `alg` is compatible with the signature algorithm
|
|
8
28
|
|
|
9
|
-
NOTE: No breaking changes. Moving out of v0.x` to express the intention to keep the public API stable.
|
|
29
|
+
NOTE: No breaking changes. Moving out of `v0.x` to express the intention to keep the public API stable.
|
|
10
30
|
|
|
11
31
|
## [v0.11.0] - 2020-01-30
|
|
12
32
|
|
|
@@ -123,6 +143,10 @@ NOTE: No breaking changes. Moving out of v0.x` to express the intention to keep
|
|
|
123
143
|
- EC2 key object
|
|
124
144
|
- Works with ruby 2.5
|
|
125
145
|
|
|
146
|
+
[v1.3.0]: https://github.com/cedarcode/cose-ruby/compare/v1.2.1...v1.3.0/
|
|
147
|
+
[v1.2.1]: https://github.com/cedarcode/cose-ruby/compare/v1.2.0...v1.2.1/
|
|
148
|
+
[v1.2.0]: https://github.com/cedarcode/cose-ruby/compare/v1.1.0...v1.2.0/
|
|
149
|
+
[v1.1.0]: https://github.com/cedarcode/cose-ruby/compare/v1.0.0...v1.1.0/
|
|
126
150
|
[v1.0.0]: https://github.com/cedarcode/cose-ruby/compare/v0.11.0...v1.0.0/
|
|
127
151
|
[v0.11.0]: https://github.com/cedarcode/cose-ruby/compare/v0.10.0...v0.11.0/
|
|
128
152
|
[v0.10.0]: https://github.com/cedarcode/cose-ruby/compare/v0.9.0...v0.10.0/
|
data/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Ruby implementation of RFC [8152](https://tools.ietf.org/html/rfc8152) CBOR Object Signing and Encryption (COSE)
|
|
4
4
|
|
|
5
5
|
[](https://rubygems.org/gems/cose)
|
|
6
|
-
[](https://github.com/cedarcode/cose-ruby/actions)
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
data/bin/setup
CHANGED
data/cose.gemspec
CHANGED
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
|
32
32
|
spec.required_ruby_version = ">= 2.4"
|
|
33
33
|
|
|
34
34
|
spec.add_dependency "cbor", "~> 0.5.9"
|
|
35
|
-
spec.add_dependency "openssl-signature_algorithm", "~>
|
|
35
|
+
spec.add_dependency "openssl-signature_algorithm", "~> 1.0"
|
|
36
36
|
|
|
37
37
|
spec.add_development_dependency "appraisal", "~> 2.2.0"
|
|
38
38
|
spec.add_development_dependency "bundler", ">= 1.17", "< 3"
|
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
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "cose/algorithm/signature_algorithm"
|
|
4
|
+
require "cose/error"
|
|
5
|
+
require "cose/key/okp"
|
|
6
|
+
require "openssl"
|
|
7
|
+
|
|
8
|
+
module COSE
|
|
9
|
+
module Algorithm
|
|
10
|
+
class EdDSA < SignatureAlgorithm
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def valid_key?(key)
|
|
14
|
+
cose_key = to_cose_key(key)
|
|
15
|
+
|
|
16
|
+
cose_key.is_a?(COSE::Key::OKP) && (!cose_key.alg || cose_key.alg == id)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def to_pkey(key)
|
|
20
|
+
case key
|
|
21
|
+
when COSE::Key::OKP
|
|
22
|
+
key.to_pkey
|
|
23
|
+
when OpenSSL::PKey::PKey
|
|
24
|
+
key
|
|
25
|
+
else
|
|
26
|
+
raise(COSE::Error, "Incompatible key for algorithm")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def valid_signature?(key, signature, verification_data)
|
|
31
|
+
pkey = to_pkey(key)
|
|
32
|
+
|
|
33
|
+
begin
|
|
34
|
+
pkey.verify(nil, signature, verification_data)
|
|
35
|
+
rescue OpenSSL::PKey::PKeyError
|
|
36
|
+
false
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -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/algorithm.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "cose/algorithm/ecdsa"
|
|
4
|
+
require "cose/algorithm/eddsa"
|
|
4
5
|
require "cose/algorithm/hmac"
|
|
5
6
|
require "cose/algorithm/rsa_pss"
|
|
6
7
|
|
|
@@ -26,9 +27,11 @@ module COSE
|
|
|
26
27
|
@registered_by_name[name]
|
|
27
28
|
end
|
|
28
29
|
|
|
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"))
|
|
30
|
+
register(ECDSA.new(-7, "ES256", hash_function: "SHA256", curve_name: "P-256"))
|
|
31
|
+
register(ECDSA.new(-35, "ES384", hash_function: "SHA384", curve_name: "P-384"))
|
|
32
|
+
register(ECDSA.new(-36, "ES512", hash_function: "SHA512", curve_name: "P-521"))
|
|
33
|
+
register(ECDSA.new(-47, "ES256K", hash_function: "SHA256", curve_name: "secp256k1"))
|
|
34
|
+
register(EdDSA.new(-8, "EdDSA"))
|
|
32
35
|
register(RSAPSS.new(-37, "PS256", hash_function: "SHA256", salt_length: 32))
|
|
33
36
|
register(RSAPSS.new(-38, "PS384", hash_function: "SHA384", salt_length: 48))
|
|
34
37
|
register(RSAPSS.new(-39, "PS512", hash_function: "SHA512", salt_length: 64))
|
data/lib/cose/key/base.rb
CHANGED
data/lib/cose/key/curve.rb
CHANGED
|
@@ -32,3 +32,6 @@ end
|
|
|
32
32
|
COSE::Key::Curve.register(1, "P-256", "prime256v1")
|
|
33
33
|
COSE::Key::Curve.register(2, "P-384", "secp384r1")
|
|
34
34
|
COSE::Key::Curve.register(3, "P-521", "secp521r1")
|
|
35
|
+
COSE::Key::Curve.register(6, "Ed25519", "ED25519")
|
|
36
|
+
COSE::Key::Curve.register(7, "Ed448", "ED448")
|
|
37
|
+
COSE::Key::Curve.register(8, "secp256k1", "secp256k1")
|
data/lib/cose/key/curve_key.rb
CHANGED
data/lib/cose/key/ec2.rb
CHANGED
|
@@ -59,27 +59,48 @@ module COSE
|
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
def map
|
|
62
|
-
|
|
62
|
+
super.merge(
|
|
63
63
|
Base::LABEL_KTY => KTY_EC2,
|
|
64
64
|
LABEL_Y => y,
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
map.reject { |_k, v| v.nil? }
|
|
65
|
+
).compact
|
|
68
66
|
end
|
|
69
67
|
|
|
70
68
|
def to_pkey
|
|
71
69
|
if curve
|
|
72
70
|
group = OpenSSL::PKey::EC::Group.new(curve.pkey_name)
|
|
73
|
-
pkey = OpenSSL::PKey::EC.new(group)
|
|
74
71
|
public_key_bn = OpenSSL::BN.new("\x04" + x + y, 2)
|
|
75
72
|
public_key_point = OpenSSL::PKey::EC::Point.new(group, public_key_bn)
|
|
76
|
-
|
|
73
|
+
|
|
74
|
+
# RFC5480 SubjectPublicKeyInfo
|
|
75
|
+
asn1 = OpenSSL::ASN1::Sequence(
|
|
76
|
+
[
|
|
77
|
+
OpenSSL::ASN1::Sequence(
|
|
78
|
+
[
|
|
79
|
+
OpenSSL::ASN1::ObjectId("id-ecPublicKey"),
|
|
80
|
+
OpenSSL::ASN1::ObjectId(curve.pkey_name),
|
|
81
|
+
]
|
|
82
|
+
),
|
|
83
|
+
OpenSSL::ASN1::BitString(public_key_point.to_octet_string(:uncompressed))
|
|
84
|
+
]
|
|
85
|
+
)
|
|
77
86
|
|
|
78
87
|
if d
|
|
79
|
-
|
|
88
|
+
# RFC5915 ECPrivateKey
|
|
89
|
+
asn1 = OpenSSL::ASN1::Sequence(
|
|
90
|
+
[
|
|
91
|
+
OpenSSL::ASN1::Integer.new(1),
|
|
92
|
+
# Not properly padded but OpenSSL doesn't mind
|
|
93
|
+
OpenSSL::ASN1::OctetString(OpenSSL::BN.new(d, 2).to_s(2)),
|
|
94
|
+
OpenSSL::ASN1::ObjectId(curve.pkey_name, 0, :EXPLICIT),
|
|
95
|
+
OpenSSL::ASN1::BitString(public_key_point.to_octet_string(:uncompressed), 1, :EXPLICIT),
|
|
96
|
+
]
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
der = asn1.to_der
|
|
100
|
+
return OpenSSL::PKey::EC.new(der)
|
|
80
101
|
end
|
|
81
102
|
|
|
82
|
-
|
|
103
|
+
OpenSSL::PKey::EC.new(asn1.to_der)
|
|
83
104
|
else
|
|
84
105
|
raise "Unsupported curve #{crv}"
|
|
85
106
|
end
|
data/lib/cose/key/okp.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
|
|
|
@@ -14,9 +15,56 @@ module COSE
|
|
|
14
15
|
end
|
|
15
16
|
end
|
|
16
17
|
|
|
18
|
+
def self.from_pkey(pkey)
|
|
19
|
+
curve = Curve.by_pkey_name(pkey.oid) || raise("Unsupported edwards curve #{pkey.oid}")
|
|
20
|
+
attributes = { crv: curve.id }
|
|
21
|
+
|
|
22
|
+
asymmetric_key = pkey.public_to_der
|
|
23
|
+
public_key_bit_string = OpenSSL::ASN1.decode(asymmetric_key).value.last.value
|
|
24
|
+
attributes[:x] = public_key_bit_string
|
|
25
|
+
begin
|
|
26
|
+
asymmetric_key = pkey.private_to_der
|
|
27
|
+
private_key = OpenSSL::ASN1.decode(asymmetric_key).value.last.value
|
|
28
|
+
curve_private_key = OpenSSL::ASN1.decode(private_key).value
|
|
29
|
+
attributes[:d] = curve_private_key
|
|
30
|
+
rescue OpenSSL::PKey::PKeyError
|
|
31
|
+
# work around lack of https://github.com/ruby/openssl/pull/527, otherwise raises this error
|
|
32
|
+
# with message 'i2d_PKCS8PrivateKey_bio: error converting private key' for public keys
|
|
33
|
+
nil
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
new(**attributes)
|
|
37
|
+
end
|
|
38
|
+
|
|
17
39
|
def map
|
|
18
40
|
super.merge(LABEL_KTY => KTY_OKP)
|
|
19
41
|
end
|
|
42
|
+
|
|
43
|
+
def to_pkey
|
|
44
|
+
if curve
|
|
45
|
+
private_key_algo = OpenSSL::ASN1::Sequence.new(
|
|
46
|
+
[OpenSSL::ASN1::ObjectId.new(curve.pkey_name)]
|
|
47
|
+
)
|
|
48
|
+
seq = if d
|
|
49
|
+
version = OpenSSL::ASN1::Integer.new(0)
|
|
50
|
+
curve_private_key = OpenSSL::ASN1::OctetString.new(d).to_der
|
|
51
|
+
private_key = OpenSSL::ASN1::OctetString.new(curve_private_key)
|
|
52
|
+
[version, private_key_algo, private_key]
|
|
53
|
+
else
|
|
54
|
+
public_key = OpenSSL::ASN1::BitString.new(x)
|
|
55
|
+
[private_key_algo, public_key]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
asymmetric_key = OpenSSL::ASN1::Sequence.new(seq)
|
|
59
|
+
OpenSSL::PKey.read(asymmetric_key.to_der)
|
|
60
|
+
else
|
|
61
|
+
raise "Unsupported curve #{crv}"
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def curve
|
|
66
|
+
Curve.find(crv)
|
|
67
|
+
end
|
|
20
68
|
end
|
|
21
69
|
end
|
|
22
70
|
end
|
data/lib/cose/key/rsa.rb
CHANGED
|
@@ -74,7 +74,7 @@ module COSE
|
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
def map
|
|
77
|
-
|
|
77
|
+
super.merge(
|
|
78
78
|
Base::LABEL_KTY => KTY_RSA,
|
|
79
79
|
LABEL_N => n,
|
|
80
80
|
LABEL_E => e,
|
|
@@ -84,37 +84,36 @@ module COSE
|
|
|
84
84
|
LABEL_DP => dp,
|
|
85
85
|
LABEL_DQ => dq,
|
|
86
86
|
LABEL_QINV => qinv
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
map.reject { |_k, v| v.nil? }
|
|
87
|
+
).compact
|
|
90
88
|
end
|
|
91
89
|
|
|
92
90
|
def to_pkey
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
end
|
|
91
|
+
# PKCS#1 RSAPublicKey
|
|
92
|
+
asn1 = OpenSSL::ASN1::Sequence(
|
|
93
|
+
[
|
|
94
|
+
OpenSSL::ASN1::Integer.new(bn(n)),
|
|
95
|
+
OpenSSL::ASN1::Integer.new(bn(e)),
|
|
96
|
+
]
|
|
97
|
+
)
|
|
98
|
+
pkey = OpenSSL::PKey::RSA.new(asn1.to_der)
|
|
102
99
|
|
|
103
100
|
if private?
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
101
|
+
# PKCS#1 RSAPrivateKey
|
|
102
|
+
asn1 = OpenSSL::ASN1::Sequence(
|
|
103
|
+
[
|
|
104
|
+
OpenSSL::ASN1::Integer.new(0),
|
|
105
|
+
OpenSSL::ASN1::Integer.new(bn(n)),
|
|
106
|
+
OpenSSL::ASN1::Integer.new(bn(e)),
|
|
107
|
+
OpenSSL::ASN1::Integer.new(bn(d)),
|
|
108
|
+
OpenSSL::ASN1::Integer.new(bn(p)),
|
|
109
|
+
OpenSSL::ASN1::Integer.new(bn(q)),
|
|
110
|
+
OpenSSL::ASN1::Integer.new(bn(dp)),
|
|
111
|
+
OpenSSL::ASN1::Integer.new(bn(dq)),
|
|
112
|
+
OpenSSL::ASN1::Integer.new(bn(qinv)),
|
|
113
|
+
]
|
|
114
|
+
)
|
|
110
115
|
|
|
111
|
-
|
|
112
|
-
pkey.set_crt_params(bn(dp), bn(dq), bn(qinv))
|
|
113
|
-
else
|
|
114
|
-
pkey.dmp1 = bn(dp)
|
|
115
|
-
pkey.dmq1 = bn(dq)
|
|
116
|
-
pkey.iqmp = bn(qinv)
|
|
117
|
-
end
|
|
116
|
+
pkey = OpenSSL::PKey::RSA.new(asn1.to_der)
|
|
118
117
|
end
|
|
119
118
|
|
|
120
119
|
pkey
|
data/lib/cose/key.rb
CHANGED
data/lib/cose/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cose
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gonzalo Rodriguez
|
|
8
8
|
- Braulio Martinez
|
|
9
|
-
autorequire:
|
|
9
|
+
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2022-10-28 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: cbor
|
|
@@ -31,14 +31,14 @@ dependencies:
|
|
|
31
31
|
requirements:
|
|
32
32
|
- - "~>"
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version:
|
|
34
|
+
version: '1.0'
|
|
35
35
|
type: :runtime
|
|
36
36
|
prerelease: false
|
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
38
|
requirements:
|
|
39
39
|
- - "~>"
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
|
-
version:
|
|
41
|
+
version: '1.0'
|
|
42
42
|
- !ruby/object:Gem::Dependency
|
|
43
43
|
name: appraisal
|
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -143,7 +143,7 @@ dependencies:
|
|
|
143
143
|
- - "~>"
|
|
144
144
|
- !ruby/object:Gem::Version
|
|
145
145
|
version: '1.4'
|
|
146
|
-
description:
|
|
146
|
+
description:
|
|
147
147
|
email:
|
|
148
148
|
- gonzalo@cedarcode.com
|
|
149
149
|
- braulio@cedarcode.com
|
|
@@ -151,11 +151,11 @@ executables: []
|
|
|
151
151
|
extensions: []
|
|
152
152
|
extra_rdoc_files: []
|
|
153
153
|
files:
|
|
154
|
+
- ".github/workflows/build.yml"
|
|
154
155
|
- ".gitignore"
|
|
155
156
|
- ".gitmodules"
|
|
156
157
|
- ".rspec"
|
|
157
158
|
- ".rubocop.yml"
|
|
158
|
-
- ".travis.yml"
|
|
159
159
|
- Appraisals
|
|
160
160
|
- CHANGELOG.md
|
|
161
161
|
- Gemfile
|
|
@@ -166,14 +166,15 @@ files:
|
|
|
166
166
|
- bin/console
|
|
167
167
|
- bin/setup
|
|
168
168
|
- cose.gemspec
|
|
169
|
-
- gemfiles/openssl_2_0.gemfile
|
|
170
169
|
- gemfiles/openssl_2_1.gemfile
|
|
170
|
+
- gemfiles/openssl_2_2.gemfile
|
|
171
|
+
- gemfiles/openssl_3_0.gemfile
|
|
171
172
|
- gemfiles/openssl_default.gemfile
|
|
172
|
-
- gemfiles/openssl_head.gemfile
|
|
173
173
|
- lib/cose.rb
|
|
174
174
|
- lib/cose/algorithm.rb
|
|
175
175
|
- lib/cose/algorithm/base.rb
|
|
176
176
|
- lib/cose/algorithm/ecdsa.rb
|
|
177
|
+
- lib/cose/algorithm/eddsa.rb
|
|
177
178
|
- lib/cose/algorithm/hmac.rb
|
|
178
179
|
- lib/cose/algorithm/rsa_pss.rb
|
|
179
180
|
- lib/cose/algorithm/signature_algorithm.rb
|
|
@@ -204,7 +205,7 @@ metadata:
|
|
|
204
205
|
bug_tracker_uri: https://github.com/cedarcode/cose-ruby/issues
|
|
205
206
|
changelog_uri: https://github.com/cedarcode/cose-ruby/blob/master/CHANGELOG.md
|
|
206
207
|
source_code_uri: https://github.com/cedarcode/cose-ruby
|
|
207
|
-
post_install_message:
|
|
208
|
+
post_install_message:
|
|
208
209
|
rdoc_options: []
|
|
209
210
|
require_paths:
|
|
210
211
|
- lib
|
|
@@ -219,8 +220,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
219
220
|
- !ruby/object:Gem::Version
|
|
220
221
|
version: '0'
|
|
221
222
|
requirements: []
|
|
222
|
-
rubygems_version: 3.
|
|
223
|
-
signing_key:
|
|
223
|
+
rubygems_version: 3.2.32
|
|
224
|
+
signing_key:
|
|
224
225
|
specification_version: 4
|
|
225
226
|
summary: Ruby implementation of RFC 8152 CBOR Object Signing and Encryption (COSE)
|
|
226
227
|
test_files: []
|
data/.travis.yml
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
dist: bionic
|
|
2
|
-
language: ruby
|
|
3
|
-
cache: bundler
|
|
4
|
-
|
|
5
|
-
rvm:
|
|
6
|
-
- ruby-head
|
|
7
|
-
- 2.7.0
|
|
8
|
-
- 2.6.5
|
|
9
|
-
- 2.5.7
|
|
10
|
-
- 2.4.9
|
|
11
|
-
|
|
12
|
-
gemfile:
|
|
13
|
-
- gemfiles/openssl_head.gemfile
|
|
14
|
-
- gemfiles/openssl_2_1.gemfile
|
|
15
|
-
- gemfiles/openssl_2_0.gemfile
|
|
16
|
-
- gemfiles/openssl_default.gemfile
|
|
17
|
-
|
|
18
|
-
before_install: gem install bundler -v '~> 2.0'
|
|
19
|
-
|
|
20
|
-
matrix:
|
|
21
|
-
fast_finish: true
|
|
22
|
-
allow_failures:
|
|
23
|
-
- rvm: ruby-head
|
|
24
|
-
- gemfile: gemfiles/openssl_head.gemfile
|