aliquot-pay 0.5.0 → 0.6.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: ea8a43259ca5f437e1aa0d86b3c8ee3b93a257ec1ebcd20274cf1d3b0d7fdea6
4
- data.tar.gz: f231c69d8d5d2314cc0f835cdb55b8e5b60a13200c37a5b6c5ec3eb7fee1c335
3
+ metadata.gz: d6ef1cc665eda9098620eba68b1ad54f84fbf95a7451000aed962e955df683bc
4
+ data.tar.gz: a6126ced2a1928849052ebed350163990d5f74aff97d26100f54a60189bb092f
5
5
  SHA512:
6
- metadata.gz: 7d7d6ef3b956607876f48f02c29e24a0b9015cbc569470974bcd8232da578f4f3964bc0936d5f579fe7f9ad44146c95913211cac323205aa5076140ab4d4f7b7
7
- data.tar.gz: 3952d7c0b71eca60300e7cea0472392d96f2827abfa721417ec68a17b5e007237f14698d69f80c3ad1f6ae4b467eddd1970695629b1773b1c4deb72aa7530c52
6
+ metadata.gz: 7ad4156b308d5f0cb263f0ceb2b64db99ec373f073bb71339cb0866812979448345cfee99beddebeaf816cdd38e0d17cb793c39832f366dfa108c9d368a257a8
7
+ data.tar.gz: 87a621a3d085c84cec0b393a737a3d05ae5d7afa5b144cfecac0babd1e8ce55d06727428b7fabad9f247c3191a2b26c6ae3369b9c2137e0930d4a9fb8f7ab362
@@ -12,8 +12,13 @@ module AliquotPay
12
12
  end
13
13
 
14
14
  def self.derive_keys(ephemeral_public_key, shared_secret, info)
15
- ikm = ephemeral_public_key + shared_secret
16
- hbytes = HKDF.new(ikm, algorithm: 'SHA256', info: info).next_bytes(32)
15
+ input_keying_material = ephemeral_public_key + shared_secret
16
+ if OpenSSL.const_defined?(:KDF) && OpenSSL::KDF.respond_to?(:hkdf)
17
+ h = OpenSSL::Digest::SHA256.new
18
+ hbytes = OpenSSL::KDF.hkdf(input_keying_material, hash: h, salt: '', length: 32, info: info)
19
+ else
20
+ hbytes = HKDF.new(input_keying_material, algorithm: 'SHA256', info: info).next_bytes(32)
21
+ end
17
22
 
18
23
  {
19
24
  aes_key: hbytes[0..15],
data/lib/aliquot-pay.rb CHANGED
@@ -90,18 +90,18 @@ module AliquotPay
90
90
  end
91
91
 
92
92
  # payment:: Google Pay token as a ruby Hash
93
- # signing_key:: OpenSSL::PKEY::EC
94
- # recipient:: OpenSSL::PKey::EC
95
- # message:: SignedMessage
96
- def self.generate_token(payment, signing_key, recipient, message = nil)
97
- message ||= AliquotPay.encrypt(JSON.unparse(payment), recipient)
93
+ # signing_key:: OpenSSL::PKEY::EC
94
+ # recipient:: OpenSSL::PKey::EC
95
+ # encrypted_message:: SignedMessage
96
+ def self.generate_token(payment, signing_key, recipient, signed_message = nil)
97
+ signed_message ||= JSON.unparse(AliquotPay.encrypt(JSON.unparse(payment), recipient))
98
98
 
99
- signature_string = AliquotPay.signature_string(JSON.unparse(message))
99
+ signature_string = AliquotPay.signature_string(signed_message)
100
100
 
101
101
  {
102
102
  'protocolVersion' => 'ECv1',
103
103
  'signature' => AliquotPay.sign(signing_key, signature_string),
104
- 'signedMessage' => JSON.unparse(message),
104
+ 'signedMessage' => signed_message,
105
105
  }
106
106
  end
107
107
  end
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: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clearhaus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-28 00:00:00.000000000 Z
11
+ date: 2019-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hkdf