pedicel-pay 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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: 12084da10c8a033bfa52a0bb9ab055780a1985760044e98f964afec44143dc27
|
4
|
+
data.tar.gz: 2c5c9b7e328b0ce6fb94b198a85e0212d503046b30f1e797145d0ebf343a3249
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66085fa5b654cd9bfe01a347865df7332435b4047ed0115a5cdff639ddd6fe524808cfc80f50aed1017eb454ac1c71f1191597cb1641f49c2d2915ae15de2ba7
|
7
|
+
data.tar.gz: 0c4f411ea8648e9b86c848197a4e6a57b26b30f0ebd621f4c453a9af0686521c5b2f183c039a47b2a30c0b63d73759ebbdb1e8cbd3c9d3ac085e5a63f18425f5
|
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.6
|
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: 2022-09-14 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.0.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.0.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.1.6
|
120
119
|
signing_key:
|
121
120
|
specification_version: 4
|
122
121
|
summary: Backend and client part of Apple Pay
|