aliquot-pay 2.0.0 → 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: 3b09f20a26a4ba4bd85ef274044bca8f84fd5471c4393b7e14e3aae8a8ee9e48
4
- data.tar.gz: aa5e97d77be4ce999063378eb5bce12f4bbd6e7509fbd3f100388281197175cd
3
+ metadata.gz: 5c5bffd61e042fd964cca3d4c766cd63ce6e5434602f28cf17e54a70db6001e1
4
+ data.tar.gz: 0b4c0729cba721c98abe88b1bd7ef70a1205acf71f6eba6f03d77e66bc01f252
5
5
  SHA512:
6
- metadata.gz: 1b0747731b0320552cc308b76a32c2786358a9ddd74136498da0b3145981f9584ae184d06fe903cede3b815fc6dc5f82fbccf24dde754aebb3a35961d5df4db9
7
- data.tar.gz: 71018fd9c9885e435a298bd8138f471494bba598a0608c7e52f73d85625b597d4f2993df82cae1c4448dfa6bdd14682864d10692e855433cc14010d7cf032a5e
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.0.0
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clearhaus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-01 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,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.0.0
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.0.0
40
+ version: '2.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  requirements: []
82
- rubygems_version: 3.1.4
82
+ rubygems_version: 3.1.6
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Generates Google Pay test dummy tokens