pedicel 0.0.5 → 0.0.6

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: 67d155d5766564d4ca2580589ca57cacb94415eb7b7b3bfa9eefe01d6b30e270
4
- data.tar.gz: a384e5e0b28d9aaa8d51fbe80dfe532efd4adfaa27ce44995306385ae0b7363f
3
+ metadata.gz: 004d5f107ed691aa9edd17fc47ab18dc9c795e67b911cf5667ccd73708b7381e
4
+ data.tar.gz: 1c42781d776de29f26364109556cfb0836fa10b42b54374675330b941ecf0298
5
5
  SHA512:
6
- metadata.gz: fda0a0d5b14ddf620e42523352b5ced7c6725d03b1a6d6af12677220e42ca979188fd3049602bc0946d2f456572f8e8c92681a42b8a28cd353834e397f06192f
7
- data.tar.gz: 40b85a602bd41992fb8ddf8e147dac5668422b9148319ff4d8885eb7a825498a0ef638a73655453a08079f2d66426be3b13333cfa7721c0bd1e8bd3241b5bbf8
6
+ metadata.gz: 9d4cc8d8715e4c06d8eeb5ef4b90205a450ed8bd7c8b697faf4cd5a2742f747faab2f064e5b774846b388800b1b42e82f5ce44e6e84b22ee3c1a1c85fd43e19d
7
+ data.tar.gz: 312c53ec2fdd15ec88431634c34b521302e83ab12d4e2ca24f6feb38f4c84f67d4dc75912f58770f654b40212d10dc4e62db943112e5b675dfd247c212be1417
@@ -196,30 +196,21 @@ module Pedicel
196
196
  end
197
197
 
198
198
  def self.verify_x509_chain(root:, intermediate:, leaf:)
199
- store = OpenSSL::X509::Store.new.add_cert(root)
199
+ # Specifically, ensure that the signature was created using the private
200
+ # key corresponding to the leaf certificate, that the leaf certificate is
201
+ # signed by the intermediate CA, and that the intermediate CA is signed by
202
+ # the Apple Root CA - G3.
200
203
 
201
- unless store.verify(root)
202
- raise SignatureError, "invalid chain due to root: #{store.error_string}"
204
+ unless root.verify(root.public_key)
205
+ raise SignatureError, 'invalid chain due to root'
203
206
  end
204
207
 
205
- unless store.verify(intermediate)
206
- raise SignatureError, "invalid chain due to intermediate: #{store.error_string}"
208
+ unless intermediate.verify(root.public_key)
209
+ raise SignatureError, 'invalid chain due to intermediate'
207
210
  end
208
211
 
209
- begin
210
- store.add_cert(intermediate)
211
- rescue OpenSSL::X509::StoreError
212
- raise SignatureError, "invalid chain due to intermediate"
213
- end
214
-
215
- begin
216
- store.add_cert(leaf)
217
- rescue OpenSSL::X509::StoreError
218
- raise SignatureError, "invalid chain due to leaf"
219
- end
220
-
221
- unless store.verify(leaf)
222
- raise SignatureError, "invalid chain due to leaf: #{store.error_string}"
212
+ unless leaf.verify(intermediate.public_key)
213
+ raise SignatureError, 'invalid chain due to leaf'
223
214
  end
224
215
 
225
216
  true
@@ -50,7 +50,7 @@ module Pedicel
50
50
 
51
51
  predicate(:yymmdd?) { |x| str?(x) && match_b.(x, /\A\d{6}\z/) }
52
52
 
53
- predicate(:eci?) { |x| str?(x) && match_b.(x, /\A\d{2}\z/) }
53
+ predicate(:eci?) { |x| str?(x) && match_b.(x, /\A\d{1,2}\z/) }
54
54
 
55
55
  predicate(:ec_public_key?) { |x| base64?(x) && OpenSSL::PKey::EC.new(Base64.decode64(x)).check_key rescue false }
56
56
 
@@ -168,6 +168,16 @@ module Pedicel
168
168
 
169
169
  @validation.errors
170
170
  end
171
+
172
+ def errors_formatted(node = [errors])
173
+ node.pop.flat_map do |key, value|
174
+ if value.is_a?(Array)
175
+ value.map { |error| "#{(node + [key]).join('.')} #{error}" }
176
+ else
177
+ errors_formatted(node + [key, value])
178
+ end
179
+ end
180
+ end
171
181
  end
172
182
 
173
183
  class Token
@@ -1,3 +1,3 @@
1
1
  module Pedicel
2
- VERSION = '0.0.5'.freeze
2
+ VERSION = '0.0.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pedicel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clearhaus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-28 00:00:00.000000000 Z
11
+ date: 2018-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-validation
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  requirements: []
114
114
  rubyforge_project:
115
- rubygems_version: 2.7.4
115
+ rubygems_version: 2.7.7
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: Decryption of Apple Pay payment tokens