aliquot-pay 2.1.1 → 2.1.2

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: 5f1155997b8d956147e17ca76c1fa36341675f9a8ba4932b3d6a1a6152bec885
4
- data.tar.gz: aec39bc7bac88cc34ae9d36b4d09af287c42247b23c1e134c930e90d6dc86c75
3
+ metadata.gz: 5c5bffd61e042fd964cca3d4c766cd63ce6e5434602f28cf17e54a70db6001e1
4
+ data.tar.gz: 0b4c0729cba721c98abe88b1bd7ef70a1205acf71f6eba6f03d77e66bc01f252
5
5
  SHA512:
6
- metadata.gz: d096ada956941cb30fd187db28f8b83665bd8b667280cd834fed2b2b1fa9535d73a163941674ef11702f429fef1b5804168059f56e02d53478bf0212e9fe3f30
7
- data.tar.gz: ea714b68416696db99049926200cefdcc65f2a14ac55ee6d5ead1c7132d4de0420b3b429610ef3637e1ed2aad3763edcc3162fa8a873bd686a915f04e3e53806
6
+ metadata.gz: e095b875006d99d6e95d6768d482848ba7c304241f72653be631386ac6c2b56b01a79e4d2980c098e6329e2e34635ab11f8569f576389456439d3bf9760e4f3c
7
+ data.tar.gz: b9f02b833e505701d13262d0888168b195f0672d29ab4df64e437189e7d9302765885e0a74bdd992fada5793a4b60006b1febdfa77769aa3c36ee73a84d587ee
@@ -4,7 +4,7 @@ require 'hkdf'
4
4
  class AliquotPay
5
5
  class Util
6
6
  def self.generate_ephemeral_key
7
- OpenSSL::PKey::EC.new(AliquotPay::EC_CURVE).generate_key
7
+ OpenSSL::PKey::EC.generate(AliquotPay::EC_CURVE)
8
8
  end
9
9
 
10
10
  def self.generate_shared_secret(private_key, public_key)
data/lib/aliquot-pay.rb CHANGED
@@ -34,7 +34,7 @@ class AliquotPay
34
34
  end
35
35
 
36
36
  def extract_root_signing_keys
37
- key = Base64.strict_encode64(eckey_to_public(ensure_root_key).to_der)
37
+ key = Base64.strict_encode64(eckey_to_public(ensure_root_key))
38
38
  {
39
39
  'keys' => [
40
40
  'protocolVersion' => @protocol_version,
@@ -43,16 +43,19 @@ class AliquotPay
43
43
  }.to_json
44
44
  end
45
45
 
46
- def eckey_to_public(key)
47
- p = OpenSSL::PKey::EC.new(EC_CURVE)
48
-
49
- p.public_key = key.public_key
50
-
51
- p
46
+ if OpenSSL::VERSION >= '3'
47
+ # pkeys are immutable on OpenSSL >=3.0
48
+ def eckey_to_public(key)
49
+ key.public_to_der
50
+ end
51
+ else
52
+ def eckey_to_public(key)
53
+ k = OpenSSL::PKey::EC.new(EC_CURVE)
54
+ k.public_key = key.public_key
55
+ k.to_der
56
+ end
52
57
  end
53
58
 
54
- #private
55
-
56
59
  def sign(key, message)
57
60
  d = OpenSSL::Digest::SHA256.new
58
61
  def key.private?; private_key?; end
@@ -60,7 +63,7 @@ class AliquotPay
60
63
  end
61
64
 
62
65
  def encrypt(cleartext_message)
63
- @recipient ||= OpenSSL::PKey::EC.new('prime256v1').generate_key
66
+ @recipient ||= OpenSSL::PKey::EC.generate('prime256v1')
64
67
  @info ||= 'Google'
65
68
 
66
69
  eph = AliquotPay::Util.generate_ephemeral_key
@@ -143,13 +146,11 @@ class AliquotPay
143
146
  return @signed_key if @signed_key
144
147
  ensure_intermediate_key
145
148
 
146
- if @intermediate_key.private_key? || @intermediate_key.public_key?
147
- public_key = eckey_to_public(@intermediate_key)
148
- else
149
+ if !@intermediate_key.private_key? && !@intermediate_key.public_key?
149
150
  fail 'Intermediate key must be public and private key'
150
151
  end
151
152
 
152
- default_key_value = Base64.strict_encode64(public_key.to_der)
153
+ default_key_value = Base64.strict_encode64(eckey_to_public(@intermediate_key))
153
154
  default_key_expiration = "#{Time.now.to_i + 3600}000"
154
155
 
155
156
  @signed_key = {
@@ -163,11 +164,11 @@ class AliquotPay
163
164
  end
164
165
 
165
166
  def ensure_root_key
166
- @root_key ||= OpenSSL::PKey::EC.new(EC_CURVE).generate_key
167
+ @root_key ||= OpenSSL::PKey::EC.generate(EC_CURVE)
167
168
  end
168
169
 
169
170
  def ensure_intermediate_key
170
- @intermediate_key ||= OpenSSL::PKey::EC.new(EC_CURVE).generate_key
171
+ @intermediate_key ||= OpenSSL::PKey::EC.generate(EC_CURVE)
171
172
  end
172
173
 
173
174
  def build_signature
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aliquot-pay
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clearhaus
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-09 00:00:00.000000000 Z
11
+ date: 2023-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hkdf
@@ -30,42 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.1.1
33
+ version: '2.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.1.1
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '2.3'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '2.3'
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '13.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '13.0'
40
+ version: '2.1'
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: rspec
71
43
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +52,7 @@ dependencies:
80
52
  - - "~>"
81
53
  - !ruby/object:Gem::Version
82
54
  version: '3'
83
- description:
55
+ description:
84
56
  email: hello@clearhaus.com
85
57
  executables: []
86
58
  extensions: []
@@ -92,7 +64,7 @@ homepage: https://github.com/clearhaus/aliquot-pay
92
64
  licenses:
93
65
  - MIT
94
66
  metadata: {}
95
- post_install_message:
67
+ post_install_message:
96
68
  rdoc_options: []
97
69
  require_paths:
98
70
  - lib
@@ -108,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
80
  version: '0'
109
81
  requirements: []
110
82
  rubygems_version: 3.1.6
111
- signing_key:
83
+ signing_key:
112
84
  specification_version: 4
113
85
  summary: Generates Google Pay test dummy tokens
114
86
  test_files: []