tpm-key_attestation 0.8.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 535e681d5138dba02fee04f040ba56dc32aec3cfc0e120317fd9037e3af5ef48
4
- data.tar.gz: 2aa3fd555c148bffc4be80a98a18bc53083ede8b249ac5c51bca7150f4f10ad7
3
+ metadata.gz: 119c14ff3ec3d663dcd7557406f4d147d8e010e61705f759cd2cba7412045458
4
+ data.tar.gz: a0aae7f5759575312ca4050e94622cfcf5c24719450ba399115061df45b0ae72
5
5
  SHA512:
6
- metadata.gz: 5ba4bb439bede1e2c2eb7bcd4d26de281643c8cc9ed7e1f29b60e5f75ae8efdae671eaa3f2c567aae5f93fdfe98bdcae0b52a7ed0e313ffef70c23be433c8712
7
- data.tar.gz: 37c996a44f6f724490371b12962e08598a6fc85acc454378a7b125284542c9f91b7e4570751b74b33e072faf7e66f2ce1ab55a8e23ce33ea47e90778127a1f3e
6
+ metadata.gz: 92d66d626a3849915ef0379cbe150363a7072e7f74e8988b93273cc0ce0ad0f5093e7a69b2ad80929de319dd682b33f6ef09dfba427b8bb83c56deed08ae08ea
7
+ data.tar.gz: 9ca765e75668c4c9f400acfadabeb8c59bb89b5719adb59e926d8ce25e037efd9a3a05069fa3dfc2aa21559499c177f925fe5d67c1bbeea9ea6ebbc79ec90667
@@ -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'
20
+ - '2.7'
21
+ - '2.6'
22
+ - '2.5'
23
+ - '2.4'
24
+ gemfile:
25
+ - openssl_2_2
26
+ - openssl_2_1
27
+ - openssl_3_0
28
+ exclude:
29
+ - ruby: '2.4'
30
+ gemfile: openssl_3_0
31
+ - ruby: '2.5'
32
+ gemfile: openssl_3_0
33
+ env:
34
+ BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
35
+ steps:
36
+ - uses: actions/checkout@v2
37
+ - run: rm Gemfile.lock
38
+ - uses: ruby/setup-ruby@v1
39
+ with:
40
+ ruby-version: ${{ matrix.ruby }}
41
+ bundler-cache: true
42
+ - run: bundle exec rake
data/.rubocop.yml CHANGED
@@ -3,6 +3,7 @@ AllCops:
3
3
  DisabledByDefault: true
4
4
  Exclude:
5
5
  - "gemfiles/**/*"
6
+ - "vendor/bundle/**/*"
6
7
 
7
8
  Bundler:
8
9
  Enabled: true
data/Appraisals CHANGED
@@ -1,16 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise "openssl_head" do
4
- gem "openssl", git: "https://github.com/ruby/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 "openssl_2_0" do
12
- gem "openssl", "~> 2.0.0"
13
- end
14
-
15
- appraise "openssl_default" do
11
+ appraise "openssl_3_0" do
12
+ gem "openssl", "~> 3.0.0"
16
13
  end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.11.0] - 2022-07-05
4
+
5
+ - Support OpenSSL ~>3.0.0. Credits to @ClearlyClaire <3
6
+
7
+ ## [v0.10.0] - 2020-07-09
8
+
9
+ ### Added
10
+
11
+ - Support ECDSA with NIST P384 and P521 curves
12
+
13
+ ## [v0.9.0] - 2020-05-31
14
+
15
+ ### Fixed
16
+
17
+ - Fixed compatibility with OpenSSL-C (libssl) v1.0.2 ([@santiagorodriguez96])
18
+
3
19
  ## [v0.8.0] - 2020-03-29
4
20
 
5
21
  ### Changed
@@ -55,6 +71,9 @@ replacement of `JOSE` format `algorithm` string
55
71
  - `TPM::EKCertificate` wrapper
56
72
  - `TPM::SAttest` wrapper
57
73
 
74
+ [v0.11.0]: https://github.com/cedarcode/tpm-key_attestation/compare/v0.10.0...v0.11.0/
75
+ [v0.10.0]: https://github.com/cedarcode/tpm-key_attestation/compare/v0.9.0...v0.10.0/
76
+ [v0.9.0]: https://github.com/cedarcode/tpm-key_attestation/compare/v0.8.0...v0.9.0/
58
77
  [v0.8.0]: https://github.com/cedarcode/tpm-key_attestation/compare/v0.7.0...v0.8.0/
59
78
  [v0.7.0]: https://github.com/cedarcode/tpm-key_attestation/compare/v0.6.0...v0.7.0/
60
79
  [v0.6.0]: https://github.com/cedarcode/tpm-key_attestation/compare/v0.5.0...v0.6.0/
@@ -63,3 +82,6 @@ replacement of `JOSE` format `algorithm` string
63
82
  [v0.3.0]: https://github.com/cedarcode/tpm-key_attestation/compare/v0.2.0...v0.3.0/
64
83
  [v0.2.0]: https://github.com/cedarcode/tpm-key_attestation/compare/v0.1.0...v0.2.0/
65
84
  [v0.1.0]: https://github.com/cedarcode/tpm-key_attestation/compare/57c926ef7e83830cee8d111fdc5ccaf99ab2e861...v0.1.0/
85
+
86
+ [@santiagorodriguez96]: https://github.com/santiagorodriguez96
87
+ [@ClearlyClaire]: https://github.com/ClearlyClaire
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tpm-key_attestation (0.8.0)
4
+ tpm-key_attestation (0.10.0)
5
5
  bindata (~> 2.4)
6
- openssl-signature_algorithm (~> 0.4.0)
6
+ openssl (> 2.0, < 3.1)
7
+ openssl-signature_algorithm (~> 1.0)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
@@ -12,31 +13,33 @@ GEM
12
13
  bundler
13
14
  rake
14
15
  thor (>= 0.14.0)
15
- ast (2.4.0)
16
- bindata (2.4.6)
17
- byebug (11.1.1)
18
- diff-lcs (1.3)
16
+ ast (2.4.2)
17
+ bindata (2.4.8)
18
+ byebug (11.1.3)
19
+ diff-lcs (1.4.4)
19
20
  jaro_winkler (1.5.4)
20
- openssl-signature_algorithm (0.4.0)
21
- parallel (1.19.1)
22
- parser (2.7.0.5)
23
- ast (~> 2.4.0)
21
+ openssl (3.0.0)
22
+ openssl-signature_algorithm (1.2.1)
23
+ openssl (> 2.0, < 3.1)
24
+ parallel (1.20.1)
25
+ parser (3.0.0.0)
26
+ ast (~> 2.4.1)
24
27
  rainbow (3.0.0)
25
- rake (13.0.1)
28
+ rake (13.0.3)
26
29
  rexml (3.2.4)
27
- rspec (3.9.0)
28
- rspec-core (~> 3.9.0)
29
- rspec-expectations (~> 3.9.0)
30
- rspec-mocks (~> 3.9.0)
31
- rspec-core (3.9.1)
32
- rspec-support (~> 3.9.1)
33
- rspec-expectations (3.9.1)
30
+ rspec (3.10.0)
31
+ rspec-core (~> 3.10.0)
32
+ rspec-expectations (~> 3.10.0)
33
+ rspec-mocks (~> 3.10.0)
34
+ rspec-core (3.10.1)
35
+ rspec-support (~> 3.10.0)
36
+ rspec-expectations (3.10.1)
34
37
  diff-lcs (>= 1.2.0, < 2.0)
35
- rspec-support (~> 3.9.0)
36
- rspec-mocks (3.9.1)
38
+ rspec-support (~> 3.10.0)
39
+ rspec-mocks (3.10.2)
37
40
  diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.9.0)
39
- rspec-support (3.9.2)
41
+ rspec-support (~> 3.10.0)
42
+ rspec-support (3.10.2)
40
43
  rubocop (0.80.1)
41
44
  jaro_winkler (~> 1.5.1)
42
45
  parallel (~> 1.10)
@@ -45,8 +48,8 @@ GEM
45
48
  rexml
46
49
  ruby-progressbar (~> 1.7)
47
50
  unicode-display_width (>= 1.4.0, < 1.7)
48
- ruby-progressbar (1.10.1)
49
- thor (1.0.1)
51
+ ruby-progressbar (1.11.0)
52
+ thor (1.1.0)
50
53
  unicode-display_width (1.6.1)
51
54
 
52
55
  PLATFORMS
@@ -61,4 +64,4 @@ DEPENDENCIES
61
64
  tpm-key_attestation!
62
65
 
63
66
  BUNDLED WITH
64
- 2.1.4
67
+ 2.2.8
data/README.md CHANGED
@@ -3,7 +3,8 @@
3
3
  TPM Key Attestation utitlies
4
4
 
5
5
  [![Gem](https://img.shields.io/gem/v/tpm-key_attestation.svg?style=flat-square&color=informational)](https://rubygems.org/gems/tpm-key_attestation)
6
- [![Travis](https://img.shields.io/travis/cedarcode/tpm-key_attestation.svg?style=flat-square)](https://travis-ci.org/cedarcode/tpm-key_attestation)
6
+ [![Actions Build](https://github.com/cedarcode/tpm-key_attestation/workflows/build/badge.svg)](https://github.com/cedarcode/tpm-key_attestation/actions)
7
+ [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-informational.svg?style=flat-square)](https://conventionalcommits.org)
7
8
 
8
9
  ## Installation
9
10
 
@@ -4,9 +4,9 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal", "~> 2.2.0"
6
6
  gem "byebug", "~> 11.0"
7
- gem "rake", "~> 12.0"
7
+ gem "rake", "~> 13.0"
8
8
  gem "rspec", "~> 3.0"
9
- gem "rubocop", "~> 0.79.0"
9
+ gem "rubocop", "~> 0.80.1"
10
10
  gem "openssl", "~> 2.1.0"
11
11
 
12
12
  gemspec path: "../"
@@ -4,9 +4,9 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal", "~> 2.2.0"
6
6
  gem "byebug", "~> 11.0"
7
- gem "rake", "~> 12.0"
7
+ gem "rake", "~> 13.0"
8
8
  gem "rspec", "~> 3.0"
9
- gem "rubocop", "~> 0.79.0"
10
- gem "openssl", "~> 2.0.0"
9
+ gem "rubocop", "~> 0.80.1"
10
+ gem "openssl", "~> 2.2.0"
11
11
 
12
12
  gemspec path: "../"
@@ -4,8 +4,9 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal", "~> 2.2.0"
6
6
  gem "byebug", "~> 11.0"
7
- gem "rake", "~> 12.0"
7
+ gem "rake", "~> 13.0"
8
8
  gem "rspec", "~> 3.0"
9
- gem "rubocop", "~> 0.79.0"
9
+ gem "rubocop", "~> 0.80.1"
10
+ gem "openssl", "~> 3.0.0"
10
11
 
11
12
  gemspec path: "../"
@@ -6,7 +6,7 @@ require "tpm/s_attest"
6
6
 
7
7
  module TPM
8
8
  class CertifyValidator
9
- attr_reader :info, :signature, :nonce, :object, :signature_algorithm, :hash_algorithm
9
+ attr_reader :info, :signature, :nonce, :public_area, :signature_algorithm, :hash_algorithm
10
10
 
11
11
  TPM_SIGNATURE_ALG_TO_OPENSSL = {
12
12
  ALG_RSASSA => OpenSSL::SignatureAlgorithm::RSAPKCS1,
@@ -16,14 +16,16 @@ module TPM
16
16
 
17
17
  TPM_HASH_ALG_TO_OPENSSL = {
18
18
  ALG_SHA1 => "SHA1",
19
- ALG_SHA256 => "SHA256"
19
+ ALG_SHA256 => "SHA256",
20
+ ALG_SHA384 => "SHA384",
21
+ ALG_SHA512 => "SHA512"
20
22
  }.freeze
21
23
 
22
- def initialize(info, signature, nonce, object, signature_algorithm: ALG_RSASSA, hash_algorithm: ALG_SHA256)
24
+ def initialize(info, signature, nonce, public_area, signature_algorithm: ALG_RSASSA, hash_algorithm: ALG_SHA256)
23
25
  @info = info
24
26
  @signature = signature
25
27
  @nonce = nonce
26
- @object = object
28
+ @public_area = public_area
27
29
  @signature_algorithm = signature_algorithm
28
30
  @hash_algorithm = hash_algorithm
29
31
  end
@@ -38,30 +40,38 @@ module TPM
38
40
  attest.attested_type == TPM::ST_ATTEST_CERTIFY &&
39
41
  attest.extra_data.buffer == nonce &&
40
42
  attest.magic == TPM::GENERATED_VALUE &&
41
- attest.attested.name.valid_for?(object)
43
+ attest.attested.name.valid_for?(public_area.name)
42
44
  end
43
45
 
44
46
  def valid_signature?(verify_key)
45
- openssl_signature_algorithm = openssl_signature_algorithm_class.new(openssl_hash_function[3..-1])
47
+ openssl_signature_algorithm = openssl_signature_algorithm_class.new(**openssl_signature_algorithm_parameters)
46
48
  openssl_signature_algorithm.verify_key = verify_key
47
-
48
- begin
49
- openssl_signature_algorithm.verify(signature, info)
50
- rescue OpenSSL::SignatureAlgorithm::Error
51
- false
52
- end
49
+ openssl_signature_algorithm.verify(signature, info)
50
+ rescue OpenSSL::SignatureAlgorithm::Error
51
+ false
53
52
  end
54
53
 
55
54
  def attest
56
55
  @attest ||= TPM::SAttest.deserialize(info)
57
56
  end
58
57
 
58
+ def openssl_signature_algorithm_parameters
59
+ parameters = { hash_function: openssl_hash_function }
60
+
61
+ if public_area.ecc?
62
+ parameters[:curve] = public_area.openssl_curve_name
63
+ end
64
+
65
+ parameters
66
+ end
67
+
59
68
  def openssl_hash_function
60
69
  TPM_HASH_ALG_TO_OPENSSL[hash_algorithm] || raise("Unsupported hash algorithm #{hash_algorithm}")
61
70
  end
62
71
 
63
72
  def openssl_signature_algorithm_class
64
- TPM_SIGNATURE_ALG_TO_OPENSSL[signature_algorithm] || raise("Unsupported signature algorithm #{algorithm}")
73
+ TPM_SIGNATURE_ALG_TO_OPENSSL[signature_algorithm] ||
74
+ raise("Unsupported signature algorithm #{signature_algorithm}")
65
75
  end
66
76
  end
67
77
  end
data/lib/tpm/constants.rb CHANGED
@@ -11,6 +11,8 @@ module TPM
11
11
  ALG_RSA = 0x0001
12
12
  ALG_SHA1 = 0x0004
13
13
  ALG_SHA256 = 0x000B
14
+ ALG_SHA384 = 0x000C
15
+ ALG_SHA512 = 0x000D
14
16
  ALG_NULL = 0x0010
15
17
  ALG_RSASSA = 0x0014
16
18
  ALG_RSAPSS = 0x0016
@@ -19,6 +21,8 @@ module TPM
19
21
 
20
22
  # ECC curves
21
23
  ECC_NIST_P256 = 0x0003
24
+ ECC_NIST_P384 = 0x0004
25
+ ECC_NIST_P521 = 0x0005
22
26
 
23
27
  # https://trustedcomputinggroup.org/resource/vendor-id-registry/ section 2 "TPM Capabilities Vendor ID (CAP_VID)"
24
28
  VENDOR_IDS = {
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TPM
4
4
  class KeyAttestation
5
- VERSION = "0.8.0"
5
+ VERSION = "0.11.0"
6
6
  end
7
7
  end
@@ -2,14 +2,16 @@
2
2
 
3
3
  require "openssl"
4
4
  require "tpm/key_attestation/version"
5
+
5
6
  require "tpm/aik_certificate"
6
7
  require "tpm/certify_validator"
7
8
  require "tpm/constants"
9
+ require "tpm/public_area"
8
10
 
9
11
  module TPM
10
12
  class KeyAttestation
11
13
  # https://docs.microsoft.com/en-us/windows-server/security/guarded-fabric-shielded-vm/guarded-fabric-install-trusted-tpm-root-certificates
12
- ROOT_CERTIFICATES =
14
+ TRUSTED_CERTIFICATES =
13
15
  begin
14
16
  pattern = File.expand_path(File.join(__dir__, "certificates", "*", "RootCA", "*.*"))
15
17
  Dir.glob(pattern).map do |filename|
@@ -27,7 +29,7 @@ module TPM
27
29
  :signature_algorithm,
28
30
  :hash_algorithm,
29
31
  :qualifying_data,
30
- :root_certificates
32
+ :trusted_certificates
31
33
  )
32
34
 
33
35
  def initialize(
@@ -38,7 +40,7 @@ module TPM
38
40
  qualifying_data,
39
41
  signature_algorithm: ALG_RSASSA,
40
42
  hash_algorithm: ALG_SHA256,
41
- root_certificates: ROOT_CERTIFICATES
43
+ trusted_certificates: TRUSTED_CERTIFICATES
42
44
  )
43
45
  @certify_info = certify_info
44
46
  @signature = signature
@@ -48,7 +50,7 @@ module TPM
48
50
  @signature_algorithm = signature_algorithm
49
51
  @hash_algorithm = hash_algorithm
50
52
  @qualifying_data = qualifying_data
51
- @root_certificates = root_certificates
53
+ @trusted_certificates = trusted_certificates
52
54
  end
53
55
 
54
56
  def key
@@ -71,7 +73,7 @@ module TPM
71
73
  certify_info,
72
74
  signature,
73
75
  qualifying_data,
74
- certified_key,
76
+ public_area,
75
77
  signature_algorithm: signature_algorithm,
76
78
  hash_algorithm: hash_algorithm
77
79
  )
@@ -86,7 +88,7 @@ module TPM
86
88
  def trust_store
87
89
  @trust_store ||=
88
90
  OpenSSL::X509::Store.new.tap do |trust_store|
89
- root_certificates.each { |root_certificate| trust_store.add_cert(root_certificate) }
91
+ trusted_certificates.uniq(&:serial).each { |trusted_certificate| trust_store.add_cert(trusted_certificate) }
90
92
  end
91
93
  end
92
94
 
@@ -24,6 +24,14 @@ module TPM
24
24
  t_public.key
25
25
  end
26
26
 
27
+ def ecc?
28
+ t_public.ecc?
29
+ end
30
+
31
+ def openssl_curve_name
32
+ t_public.openssl_curve_name
33
+ end
34
+
27
35
  private
28
36
 
29
37
  def name_digest
data/lib/tpm/t_public.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bindata"
4
+ require "openssl"
4
5
  require "tpm/constants"
5
6
  require "tpm/sized_buffer"
6
7
  require "tpm/t_public/s_ecc_parms"
@@ -10,7 +11,16 @@ module TPM
10
11
  # Section 12.2.4 in https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-01.38.pdf
11
12
  class TPublic < BinData::Record
12
13
  BYTE_LENGTH = 8
13
- CURVE_TPM_TO_OPENSSL = { TPM::ECC_NIST_P256 => "prime256v1" }.freeze
14
+
15
+ CURVE_TPM_TO_OPENSSL = {
16
+ TPM::ECC_NIST_P256 => "prime256v1",
17
+ TPM::ECC_NIST_P384 => "secp384r1",
18
+ TPM::ECC_NIST_P521 => "secp521r1",
19
+ }.freeze
20
+
21
+ BN_BASE = 2
22
+ RSA_KEY_DEFAULT_PUBLIC_EXPONENT = 2**16 + 1
23
+ ECC_UNCOMPRESSED_POINT_INDICATOR = "\x04"
14
24
 
15
25
  class << self
16
26
  alias_method :deserialize, :read
@@ -36,12 +46,19 @@ module TPM
36
46
  sized_buffer TPM::ALG_RSA
37
47
  end
38
48
 
49
+ def rsa?
50
+ alg_type == TPM::ALG_RSA
51
+ end
52
+
53
+ def ecc?
54
+ alg_type == TPM::ALG_ECC
55
+ end
56
+
39
57
  def key
40
58
  if parameters.symmetric == TPM::ALG_NULL
41
- case alg_type
42
- when TPM::ALG_ECC
59
+ if ecc?
43
60
  ecc_key
44
- when TPM::ALG_RSA
61
+ elsif rsa?
45
62
  rsa_key
46
63
  else
47
64
  raise "Type #{alg_type} not supported"
@@ -49,21 +66,33 @@ module TPM
49
66
  end
50
67
  end
51
68
 
69
+ def openssl_curve_name
70
+ if ecc?
71
+ CURVE_TPM_TO_OPENSSL[parameters.curve_id] || raise("Unknown curve #{parameters.curve_id}")
72
+ end
73
+ end
74
+
52
75
  private
53
76
 
54
77
  def ecc_key
55
78
  if parameters.scheme == TPM::ALG_ECDSA
56
- curve = CURVE_TPM_TO_OPENSSL[parameters.curve_id]
57
-
58
- if curve
59
- group = OpenSSL::PKey::EC::Group.new(curve)
60
- pkey = OpenSSL::PKey::EC.new(group)
61
- public_key_bn = OpenSSL::BN.new("\x04" + unique.buffer.value, 2)
62
- public_key_point = OpenSSL::PKey::EC::Point.new(group, public_key_bn)
63
- pkey.public_key = public_key_point
64
-
65
- pkey
66
- end
79
+ group = OpenSSL::PKey::EC::Group.new(openssl_curve_name)
80
+ point = OpenSSL::PKey::EC::Point.new(group, bn(ECC_UNCOMPRESSED_POINT_INDICATOR + unique.buffer.value))
81
+
82
+ # RFC5480 SubjectPublicKeyInfo
83
+ asn1 = OpenSSL::ASN1::Sequence(
84
+ [
85
+ OpenSSL::ASN1::Sequence(
86
+ [
87
+ OpenSSL::ASN1::ObjectId("id-ecPublicKey"),
88
+ OpenSSL::ASN1::ObjectId(group.curve_name),
89
+ ]
90
+ ),
91
+ OpenSSL::ASN1::BitString(point.to_octet_string(:uncompressed))
92
+ ]
93
+ )
94
+
95
+ OpenSSL::PKey::EC.new(asn1.to_der)
67
96
  end
68
97
  end
69
98
 
@@ -73,17 +102,22 @@ module TPM
73
102
  n = unique.buffer.value
74
103
 
75
104
  if parameters.key_bits / BYTE_LENGTH == n.size
76
- key = OpenSSL::PKey::RSA.new(parameters.key_bits.value)
77
- key.set_key(bn(n), nil, nil)
78
-
79
- key.public_key
105
+ # PKCS#1 RSAPublicKey
106
+ asn1 = OpenSSL::ASN1::Sequence(
107
+ [
108
+ OpenSSL::ASN1::Integer.new(bn(n)),
109
+ OpenSSL::ASN1::Integer.new(bn(RSA_KEY_DEFAULT_PUBLIC_EXPONENT)),
110
+ ]
111
+ )
112
+
113
+ OpenSSL::PKey::RSA.new(asn1.to_der)
80
114
  end
81
115
  end
82
116
  end
83
117
 
84
118
  def bn(data)
85
119
  if data
86
- OpenSSL::BN.new(data, 2)
120
+ OpenSSL::BN.new(data, BN_BASE)
87
121
  end
88
122
  end
89
123
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bindata"
4
- require "tpm/public_area"
5
4
  require "tpm/tpmt_ha"
6
5
 
7
6
  module TPM
@@ -11,8 +10,8 @@ module TPM
11
10
  uint16 :name_size, value: lambda { name.to_binary_s.size }
12
11
  tpmt_ha :name, read_length: :name_size
13
12
 
14
- def valid_for?(object)
15
- name.to_binary_s == TPM::PublicArea.new(object).name
13
+ def valid_for?(other_name)
14
+ name.to_binary_s == other_name
16
15
  end
17
16
  end
18
17
  end
@@ -26,5 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.require_paths = ["lib"]
27
27
 
28
28
  spec.add_dependency "bindata", "~> 2.4"
29
- spec.add_dependency "openssl-signature_algorithm", "~> 0.4.0"
29
+ spec.add_dependency "openssl", "> 2.0", "< 3.1"
30
+ spec.add_dependency "openssl-signature_algorithm", "~> 1.0"
30
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tpm-key_attestation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gonzalo
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-29 00:00:00.000000000 Z
11
+ date: 2022-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bindata
@@ -24,30 +24,50 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: openssl
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '3.1'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">"
42
+ - !ruby/object:Gem::Version
43
+ version: '2.0'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.1'
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: openssl-signature_algorithm
29
49
  requirement: !ruby/object:Gem::Requirement
30
50
  requirements:
31
51
  - - "~>"
32
52
  - !ruby/object:Gem::Version
33
- version: 0.4.0
53
+ version: '1.0'
34
54
  type: :runtime
35
55
  prerelease: false
36
56
  version_requirements: !ruby/object:Gem::Requirement
37
57
  requirements:
38
58
  - - "~>"
39
59
  - !ruby/object:Gem::Version
40
- version: 0.4.0
41
- description:
42
- email:
60
+ version: '1.0'
61
+ description:
62
+ email:
43
63
  executables: []
44
64
  extensions: []
45
65
  extra_rdoc_files: []
46
66
  files:
67
+ - ".github/workflows/build.yml"
47
68
  - ".gitignore"
48
69
  - ".rspec"
49
70
  - ".rubocop.yml"
50
- - ".travis.yml"
51
71
  - Appraisals
52
72
  - CHANGELOG.md
53
73
  - Gemfile
@@ -58,17 +78,15 @@ files:
58
78
  - SECURITY.md
59
79
  - bin/console
60
80
  - bin/setup
61
- - gemfiles/openssl_2_0.gemfile
62
81
  - gemfiles/openssl_2_1.gemfile
63
- - gemfiles/openssl_default.gemfile
64
- - gemfiles/openssl_head.gemfile
82
+ - gemfiles/openssl_2_2.gemfile
83
+ - gemfiles/openssl_3_0.gemfile
65
84
  - lib/tpm/aik_certificate.rb
66
85
  - lib/tpm/certificates/AMD/RootCA/AMD-fTPM-ECC-RootCA.crt
67
86
  - lib/tpm/certificates/AMD/RootCA/AMD-fTPM-RSA-RootCA.crt
68
87
  - lib/tpm/certificates/Atmel/RootCA/Atmel TPM Root Signing Module.der
69
88
  - lib/tpm/certificates/Infineon/RootCA/IFX TPM EK Root CA.cer
70
89
  - lib/tpm/certificates/Infineon/RootCA/IFX-RootCA.cer
71
- - lib/tpm/certificates/Infineon/RootCA/IFX_TPM_RootCert_008.crt
72
90
  - lib/tpm/certificates/Infineon/RootCA/Infineon OPTIGA(TM) ECC Root CA.crt
73
91
  - lib/tpm/certificates/Infineon/RootCA/Infineon OPTIGA(TM) RSA Root CA.crt
74
92
  - lib/tpm/certificates/Intel/RootCA/EKRootPublicKey.cer
@@ -85,7 +103,6 @@ files:
85
103
  - lib/tpm/certificates/Nuvoton/RootCA/Nuvoton TPM Root CA 2011.cer
86
104
  - lib/tpm/certificates/Nuvoton/RootCA/Nuvoton TPM Root CA 2110.cer
87
105
  - lib/tpm/certificates/Nuvoton/RootCA/Nuvoton TPM Root CA 2111.cer
88
- - lib/tpm/certificates/QC/RootCA/Microsoft TPM Root Certificate Authority 2014.cer
89
106
  - lib/tpm/certificates/STMicro/RootCA/GlobalSign Trusted Computing CA.crt
90
107
  - lib/tpm/certificates/STMicro/RootCA/GlobalSign Trusted Platform Module ECC Root
91
108
  CA.crt
@@ -112,7 +129,7 @@ metadata:
112
129
  homepage_uri: https://github.com/cedarcode/tpm-key_attestation
113
130
  source_code_uri: https://github.com/cedarcode/tpm-key_attestation
114
131
  changelog_uri: https://github.com/cedarcode/tpm-key_attestation/blob/master/CHANGELOG.md
115
- post_install_message:
132
+ post_install_message:
116
133
  rdoc_options: []
117
134
  require_paths:
118
135
  - lib
@@ -127,8 +144,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
144
  - !ruby/object:Gem::Version
128
145
  version: '0'
129
146
  requirements: []
130
- rubygems_version: 3.1.2
131
- signing_key:
147
+ rubygems_version: 3.2.32
148
+ signing_key:
132
149
  specification_version: 4
133
150
  summary: TPM Key Attestation verifier
134
151
  test_files: []
data/.travis.yml DELETED
@@ -1,27 +0,0 @@
1
- ---
2
- dist: bionic
3
- language: ruby
4
- cache: bundler
5
-
6
- rvm:
7
- - ruby-head
8
- - 2.7.0
9
- - 2.6.5
10
- - 2.5.7
11
- - 2.4.9
12
-
13
- gemfile:
14
- - gemfiles/openssl_head.gemfile
15
- - gemfiles/openssl_2_1.gemfile
16
- - gemfiles/openssl_2_0.gemfile
17
- - gemfiles/openssl_default.gemfile
18
-
19
- matrix:
20
- fast_finish: true
21
- allow_failures:
22
- - rvm: ruby-head
23
- - gemfile: gemfiles/openssl_head.gemfile
24
-
25
- before_install:
26
- - gem install bundler -v "~> 2.0"
27
- - rm Gemfile.lock
@@ -1,12 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "appraisal", "~> 2.2.0"
6
- gem "byebug", "~> 11.0"
7
- gem "rake", "~> 12.0"
8
- gem "rspec", "~> 3.0"
9
- gem "rubocop", "~> 0.79.0"
10
- gem "openssl", git: "https://github.com/ruby/openssl"
11
-
12
- gemspec path: "../"