pedicel-pay 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/pedicel-pay +35 -0
- data/lib/pedicel-pay/backend.rb +11 -0
- data/lib/pedicel-pay/client.rb +7 -0
- data/lib/pedicel-pay/helper.rb +4 -0
- data/lib/pedicel-pay/token_data.rb +1 -1
- data/lib/pedicel-pay/version.rb +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a92860cb4e7c25dc894df194c4fa590e2dfe92075faf8bbd89328b0e00708fb2
|
4
|
+
data.tar.gz: 17dc4fae67dc3b00eea283fa5d281fc91f41c055baf4d38d805d7a63082a75ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87e21de8f44baac69f46be2b9156f0d089cc3c30d445d990c1424dd69c402448f6fd32396f031c17b257b864d87ca6e8421fc7fb8c93a05875d866ee7046e24f
|
7
|
+
data.tar.gz: '097631854de1f3527cddc1f9fc083b84c8a4400a8df6de6b1aebb3eaca3d8416ad73802f8148a8e15fab0883e689d522574c35df91fc9d09e5d0ea7957565a90'
|
data/exe/pedicel-pay
CHANGED
@@ -137,6 +137,19 @@ module PedicelPay
|
|
137
137
|
puts token.to_json
|
138
138
|
end
|
139
139
|
|
140
|
+
desc 'extract-symmetric-key', 'Extract the symmetric key that is used for encryption/decryption of the token'
|
141
|
+
option 'client-path', type: :string, path: true, aliases: :c
|
142
|
+
option 'file', type: :string, aliases: :f
|
143
|
+
|
144
|
+
def extract_symmetric_key
|
145
|
+
raw_token = options['file'] ? File.read(options['file']) : $stdin.read
|
146
|
+
token = JSON.parse(raw_token)
|
147
|
+
|
148
|
+
client = Helper.load_client(options['client-path'])
|
149
|
+
|
150
|
+
puts client.symmetric_key(token)
|
151
|
+
end
|
152
|
+
|
140
153
|
|
141
154
|
desc 'decrypt-token', 'Decrypt a token'
|
142
155
|
option 'client-path', type: :string, path: true, aliases: :c
|
@@ -152,6 +165,28 @@ module PedicelPay
|
|
152
165
|
|
153
166
|
puts client.decrypt(token, ca_certificate_pem: backend.ca_certificate.to_pem)
|
154
167
|
end
|
168
|
+
|
169
|
+
desc 'decrypt-token-from-symmetric-key', 'Decrypt a token using the symmetric key'
|
170
|
+
option 'symmetric-key', type: :string, alias: :k
|
171
|
+
option 'file', type: :string, aliases: :f
|
172
|
+
option 'backend-path', type: :string, path: true, aliases: :b
|
173
|
+
option 'time', type: :string, alias: :t
|
174
|
+
|
175
|
+
def decrypt_token_from_symmetric_key
|
176
|
+
raw_token = options['file'] ? File.read(options['file']) : $stdin.read
|
177
|
+
token = JSON.parse(raw_token)
|
178
|
+
|
179
|
+
params = { symmetric_key: Helper.hex_to_bytestring(options['symmetric-key']) }
|
180
|
+
|
181
|
+
params.merge!(now: Time.parse(options['time'])) if options['time']
|
182
|
+
|
183
|
+
if options['backend-path']
|
184
|
+
backend = Helper.load_backend(options['backend-path'])
|
185
|
+
params.merge!(ca_certificate_pem: backend.ca_certificate.to_pem)
|
186
|
+
end
|
187
|
+
|
188
|
+
puts Pedicel::EC.new(token).decrypt(params)
|
189
|
+
end
|
155
190
|
end
|
156
191
|
|
157
192
|
class Helper
|
data/lib/pedicel-pay/backend.rb
CHANGED
@@ -104,6 +104,17 @@ module PedicelPay
|
|
104
104
|
OpenSSL::PKCS7::BINARY # Handle 0x00 correctly.
|
105
105
|
)
|
106
106
|
|
107
|
+
# Check that the newly created signature is good.
|
108
|
+
flags = \
|
109
|
+
# https://wiki.openssl.org/index.php/Manual:PKCS7_verify(3)#VERIFY_PROCESS
|
110
|
+
OpenSSL::PKCS7::NOCHAIN | # Ignore certs in the message.
|
111
|
+
OpenSSL::PKCS7::NOINTERN # Only look at the supplied certificate.
|
112
|
+
trust_store = OpenSSL::X509::Store.new
|
113
|
+
trust_store.add_cert(ca_certificate).add_cert(intermediate_certificate)
|
114
|
+
unless signature.verify([certificate], trust_store, message, flags)
|
115
|
+
fail 'signature is wrong'
|
116
|
+
end
|
117
|
+
|
107
118
|
if replace
|
108
119
|
# Just replace token.signature.
|
109
120
|
else
|
data/lib/pedicel-pay/client.rb
CHANGED
@@ -38,5 +38,12 @@ module PedicelPay
|
|
38
38
|
new(token).
|
39
39
|
decrypt(private_key: key, certificate: certificate, ca_certificate_pem: ca_certificate_pem, now: now)
|
40
40
|
end
|
41
|
+
|
42
|
+
def symmetric_key(token)
|
43
|
+
Pedicel::EC.
|
44
|
+
new(token).
|
45
|
+
symmetric_key(private_key: key, certificate: certificate).
|
46
|
+
unpack('H*')
|
47
|
+
end
|
41
48
|
end
|
42
49
|
end
|
data/lib/pedicel-pay/helper.rb
CHANGED
data/lib/pedicel-pay/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pedicel-pay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clearhaus A/S
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.1.4
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.1.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 1.1.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.1.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: thor
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,8 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
|
-
|
119
|
-
rubygems_version: 2.7.7
|
118
|
+
rubygems_version: 3.3.5
|
120
119
|
signing_key:
|
121
120
|
specification_version: 4
|
122
121
|
summary: Backend and client part of Apple Pay
|