|
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) { WebAuthn::Encoders::Base64UrlEncoder.decode(seeds[:tpm][:credential_creation_options][:challenge]) } |
278 | 277 |
|
279 | 278 | let(:attestation_response) do |
280 | 279 | response = seeds[:tpm][:authenticator_attestation_response] |
281 | 280 |
|
282 | 281 | WebAuthn::AuthenticatorAttestationResponse.new( |
283 | | - attestation_object: Base64.urlsafe_decode64(response[:attestation_object]), |
284 | | - client_data_json: Base64.urlsafe_decode64(response[:client_data_json]) |
| 282 | + attestation_object: WebAuthn::Encoders::Base64UrlEncoder.decode(response[:attestation_object]), |
| 283 | + client_data_json: WebAuthn::Encoders::Base64UrlEncoder.decode(response[:client_data_json]) |
285 | 284 | ) |
286 | 285 | end |
287 | 286 |
|
|
334 | 333 | let(:origin) { "https://7f41ac45.ngrok.io" } |
335 | 334 |
|
336 | 335 | let(:original_challenge) do |
337 | | - Base64.strict_decode64(seeds[:android_safetynet_direct][:credential_creation_options][:challenge]) |
| 336 | + WebAuthn::Encoders::Base64Encoder.decode( |
| 337 | + seeds[:android_safetynet_direct][:credential_creation_options][:challenge] |
| 338 | + ) |
338 | 339 | end |
339 | 340 |
|
340 | 341 | let(:attestation_response) do |
341 | 342 | response = seeds[:android_safetynet_direct][:authenticator_attestation_response] |
342 | 343 |
|
343 | 344 | WebAuthn::AuthenticatorAttestationResponse.new( |
344 | | - attestation_object: Base64.strict_decode64(response[:attestation_object]), |
345 | | - client_data_json: Base64.strict_decode64(response[:client_data_json]) |
| 345 | + attestation_object: WebAuthn::Encoders::Base64Encoder.decode(response[:attestation_object]), |
| 346 | + client_data_json: WebAuthn::Encoders::Base64Encoder.decode(response[:client_data_json]) |
346 | 347 | ) |
347 | 348 | end |
348 | 349 |
|
|
371 | 372 |
|
372 | 373 | context "when android-key attestation" do |
373 | 374 | let(:original_challenge) do |
374 | | - Base64.urlsafe_decode64(seeds[:android_key_direct][:credential_creation_options][:challenge]) |
| 375 | + WebAuthn::Encoders::Base64UrlEncoder.decode(seeds[:android_key_direct][:credential_creation_options][:challenge]) |
375 | 376 | end |
376 | 377 |
|
377 | 378 | let(:attestation_response) do |
378 | 379 | response = seeds[:android_key_direct][:authenticator_attestation_response] |
379 | 380 |
|
380 | 381 | WebAuthn::AuthenticatorAttestationResponse.new( |
381 | | - attestation_object: Base64.urlsafe_decode64(response[:attestation_object]), |
382 | | - client_data_json: Base64.urlsafe_decode64(response[:client_data_json]) |
| 382 | + attestation_object: WebAuthn::Encoders::Base64UrlEncoder.decode(response[:attestation_object]), |
| 383 | + client_data_json: WebAuthn::Encoders::Base64UrlEncoder.decode(response[:client_data_json]) |
383 | 384 | ) |
384 | 385 | end |
385 | 386 |
|
|
468 | 469 | let(:origin) { seeds[:macbook_touch_id][:origin] } |
469 | 470 |
|
470 | 471 | let(:original_challenge) do |
471 | | - Base64.urlsafe_decode64(seeds[:macbook_touch_id][:credential_creation_options][:challenge]) |
| 472 | + WebAuthn::Encoders::Base64UrlEncoder.decode(seeds[:macbook_touch_id][:credential_creation_options][:challenge]) |
472 | 473 | end |
473 | 474 |
|
474 | 475 | let(:attestation_response) do |
475 | 476 | response = seeds[:macbook_touch_id][:authenticator_attestation_response] |
476 | 477 |
|
477 | 478 | WebAuthn::AuthenticatorAttestationResponse.new( |
478 | | - attestation_object: Base64.urlsafe_decode64(response[:attestation_object]), |
479 | | - client_data_json: Base64.urlsafe_decode64(response[:client_data_json]) |
| 479 | + attestation_object: WebAuthn::Encoders::Base64UrlEncoder.decode(response[:attestation_object]), |
| 480 | + client_data_json: WebAuthn::Encoders::Base64UrlEncoder.decode(response[:client_data_json]) |
480 | 481 | ) |
481 | 482 | end |
482 | 483 |
|
|
766 | 767 |
|
767 | 768 | describe "attestation statement verification" do |
768 | 769 | let(:original_challenge) do |
769 | | - Base64.strict_decode64(seeds[:security_key_direct][:credential_creation_options][:challenge]) |
| 770 | + WebAuthn::Encoders::Base64Encoder.decode(seeds[:security_key_direct][:credential_creation_options][:challenge]) |
770 | 771 | end |
771 | 772 |
|
772 | 773 | let(:origin) { "http://localhost:3000" } |
|
775 | 776 | response = seeds[:security_key_direct][:authenticator_attestation_response] |
776 | 777 |
|
777 | 778 | WebAuthn::AuthenticatorAttestationResponse.new( |
778 | | - attestation_object: Base64.strict_decode64(response[:attestation_object]), |
779 | | - client_data_json: Base64.strict_decode64(response[:client_data_json]) |
| 779 | + attestation_object: WebAuthn::Encoders::Base64Encoder.decode(response[:attestation_object]), |
| 780 | + client_data_json: WebAuthn::Encoders::Base64Encoder.decode(response[:client_data_json]) |
780 | 781 | ) |
781 | 782 | end |
782 | 783 |
|
|
0 commit comments