|
3 | 3 | require "spec_helper" |
4 | 4 | require "support/seeds" |
5 | 5 |
|
6 | | -require "base64" |
7 | 6 | require "webauthn/authenticator_attestation_response" |
8 | 7 | require "openssl" |
9 | 8 |
|
|
114 | 113 |
|
115 | 114 | context "when fido-u2f attestation" do |
116 | 115 | let(:original_challenge) do |
117 | | - Base64.strict_decode64(seeds[:security_key_direct][:credential_creation_options][:challenge]) |
| 116 | + WebAuthn::Encoders::Base64Encoder.decode(seeds[:security_key_direct][:credential_creation_options][:challenge]) |
118 | 117 | end |
119 | 118 |
|
120 | 119 | context "when there is a single origin" do |
|
124 | 123 | response = seeds[:security_key_direct][:authenticator_attestation_response] |
125 | 124 |
|
126 | 125 | WebAuthn::AuthenticatorAttestationResponse.new( |
127 | | - attestation_object: Base64.strict_decode64(response[:attestation_object]), |
128 | | - client_data_json: Base64.strict_decode64(response[:client_data_json]) |
| 126 | + attestation_object: WebAuthn::Encoders::Base64Encoder.decode(response[:attestation_object]), |
| 127 | + client_data_json: WebAuthn::Encoders::Base64Encoder.decode(response[:client_data_json]) |
129 | 128 | ) |
130 | 129 | end |
131 | 130 |
|
|
194 | 193 | let(:origin) { "https://localhost:13010" } |
195 | 194 |
|
196 | 195 | let(:original_challenge) do |
197 | | - Base64.strict_decode64( |
| 196 | + WebAuthn::Encoders::Base64Encoder.decode( |
198 | 197 | seeds[:security_key_packed_self][:credential_creation_options][:challenge] |
199 | 198 | ) |
200 | 199 | end |
|
203 | 202 | response = seeds[:security_key_packed_self][:authenticator_attestation_response] |
204 | 203 |
|
205 | 204 | WebAuthn::AuthenticatorAttestationResponse.new( |
206 | | - attestation_object: Base64.strict_decode64(response[:attestation_object]), |
207 | | - client_data_json: Base64.strict_decode64(response[:client_data_json]) |
| 205 | + attestation_object: WebAuthn::Encoders::Base64Encoder.decode(response[:attestation_object]), |
| 206 | + client_data_json: WebAuthn::Encoders::Base64Encoder.decode(response[:client_data_json]) |
208 | 207 | ) |
209 | 208 | end |
210 | 209 |
|
|
234 | 233 | let(:origin) { "http://localhost:3000" } |
235 | 234 |
|
236 | 235 | let(:original_challenge) do |
237 | | - Base64.strict_decode64( |
| 236 | + WebAuthn::Encoders::Base64Encoder.decode( |
238 | 237 | seeds[:security_key_packed_x5c][:credential_creation_options][:challenge] |
239 | 238 | ) |
240 | 239 | end |
|
243 | 242 | response = seeds[:security_key_packed_x5c][:authenticator_attestation_response] |
244 | 243 |
|
245 | 244 | WebAuthn::AuthenticatorAttestationResponse.new( |
246 | | - attestation_object: Base64.strict_decode64(response[:attestation_object]), |
247 | | - client_data_json: Base64.strict_decode64(response[:client_data_json]) |
| 245 | + attestation_object: WebAuthn::Encoders::Base64Encoder.decode(response[:attestation_object]), |
| 246 | + client_data_json: WebAuthn::Encoders::Base64Encoder.decode(response[:client_data_json]) |
248 | 247 | ) |
249 | 248 | end |
250 | 249 |
|
|
274 | 273 | context "when TPM attestation" do |
275 | 274 | let(:origin) { seeds[:tpm][:origin] } |
276 | 275 | let(:time) { Time.utc(2019, 8, 13, 22, 6) } |
277 | | - let(:challenge) { Base64.urlsafe_decode64(seeds[:tpm][:credential_creation_options][:challenge]) } |
| 276 | + let(:challenge) do |
| 277 | + WebAuthn::Encoders::Base64UrlEncoder.decode(seeds[:tpm][:credential_creation_options][:challenge]) |
| 278 | + end |
278 | 279 |
|
279 | 280 | let(:attestation_response) do |
280 | 281 | response = seeds[:tpm][:authenticator_attestation_response] |
281 | 282 |
|
282 | 283 | WebAuthn::AuthenticatorAttestationResponse.new( |
283 | | - attestation_object: Base64.urlsafe_decode64(response[:attestation_object]), |
284 | | - client_data_json: Base64.urlsafe_decode64(response[:client_data_json]) |
| 284 | + attestation_object: WebAuthn::Encoders::Base64UrlEncoder.decode(response[:attestation_object]), |
| 285 | + client_data_json: WebAuthn::Encoders::Base64UrlEncoder.decode(response[:client_data_json]) |
285 | 286 | ) |
286 | 287 | end |
287 | 288 |
|
|
334 | 335 | let(:origin) { "https://7f41ac45.ngrok.io" } |
335 | 336 |
|
336 | 337 | let(:original_challenge) do |
337 | | - Base64.strict_decode64(seeds[:android_safetynet_direct][:credential_creation_options][:challenge]) |
| 338 | + WebAuthn::Encoders::Base64Encoder.decode( |
| 339 | + seeds[:android_safetynet_direct][:credential_creation_options][:challenge] |
| 340 | + ) |
338 | 341 | end |
339 | 342 |
|
340 | 343 | let(:attestation_response) do |
341 | 344 | response = seeds[:android_safetynet_direct][:authenticator_attestation_response] |
342 | 345 |
|
343 | 346 | WebAuthn::AuthenticatorAttestationResponse.new( |
344 | | - attestation_object: Base64.strict_decode64(response[:attestation_object]), |
345 | | - client_data_json: Base64.strict_decode64(response[:client_data_json]) |
| 347 | + attestation_object: WebAuthn::Encoders::Base64Encoder.decode(response[:attestation_object]), |
| 348 | + client_data_json: WebAuthn::Encoders::Base64Encoder.decode(response[:client_data_json]) |
346 | 349 | ) |
347 | 350 | end |
348 | 351 |
|
|
371 | 374 |
|
372 | 375 | context "when android-key attestation" do |
373 | 376 | let(:original_challenge) do |
374 | | - Base64.urlsafe_decode64(seeds[:android_key_direct][:credential_creation_options][:challenge]) |
| 377 | + WebAuthn::Encoders::Base64UrlEncoder.decode(seeds[:android_key_direct][:credential_creation_options][:challenge]) |
375 | 378 | end |
376 | 379 |
|
377 | 380 | let(:attestation_response) do |
378 | 381 | response = seeds[:android_key_direct][:authenticator_attestation_response] |
379 | 382 |
|
380 | 383 | WebAuthn::AuthenticatorAttestationResponse.new( |
381 | | - attestation_object: Base64.urlsafe_decode64(response[:attestation_object]), |
382 | | - client_data_json: Base64.urlsafe_decode64(response[:client_data_json]) |
| 384 | + attestation_object: WebAuthn::Encoders::Base64UrlEncoder.decode(response[:attestation_object]), |
| 385 | + client_data_json: WebAuthn::Encoders::Base64UrlEncoder.decode(response[:client_data_json]) |
383 | 386 | ) |
384 | 387 | end |
385 | 388 |
|
|
468 | 471 | let(:origin) { seeds[:macbook_touch_id][:origin] } |
469 | 472 |
|
470 | 473 | let(:original_challenge) do |
471 | | - Base64.urlsafe_decode64(seeds[:macbook_touch_id][:credential_creation_options][:challenge]) |
| 474 | + WebAuthn::Encoders::Base64UrlEncoder.decode(seeds[:macbook_touch_id][:credential_creation_options][:challenge]) |
472 | 475 | end |
473 | 476 |
|
474 | 477 | let(:attestation_response) do |
475 | 478 | response = seeds[:macbook_touch_id][:authenticator_attestation_response] |
476 | 479 |
|
477 | 480 | WebAuthn::AuthenticatorAttestationResponse.new( |
478 | | - attestation_object: Base64.urlsafe_decode64(response[:attestation_object]), |
479 | | - client_data_json: Base64.urlsafe_decode64(response[:client_data_json]) |
| 481 | + attestation_object: WebAuthn::Encoders::Base64UrlEncoder.decode(response[:attestation_object]), |
| 482 | + client_data_json: WebAuthn::Encoders::Base64UrlEncoder.decode(response[:client_data_json]) |
480 | 483 | ) |
481 | 484 | end |
482 | 485 |
|
|
766 | 769 |
|
767 | 770 | describe "attestation statement verification" do |
768 | 771 | let(:original_challenge) do |
769 | | - Base64.strict_decode64(seeds[:security_key_direct][:credential_creation_options][:challenge]) |
| 772 | + WebAuthn::Encoders::Base64Encoder.decode(seeds[:security_key_direct][:credential_creation_options][:challenge]) |
770 | 773 | end |
771 | 774 |
|
772 | 775 | let(:origin) { "http://localhost:3000" } |
|
775 | 778 | response = seeds[:security_key_direct][:authenticator_attestation_response] |
776 | 779 |
|
777 | 780 | WebAuthn::AuthenticatorAttestationResponse.new( |
778 | | - attestation_object: Base64.strict_decode64(response[:attestation_object]), |
779 | | - client_data_json: Base64.strict_decode64(response[:client_data_json]) |
| 781 | + attestation_object: WebAuthn::Encoders::Base64Encoder.decode(response[:attestation_object]), |
| 782 | + client_data_json: WebAuthn::Encoders::Base64Encoder.decode(response[:client_data_json]) |
780 | 783 | ) |
781 | 784 | end |
782 | 785 |
|
|
0 commit comments