Граф коммитов

427 Коммитов

Автор SHA1 Сообщение Дата
John M. Schanck d611d68f65 Use rsaEncryption OID for RSA keys 2024-09-04 10:57:32 -07:00
Emil Lundberg c3defd344c
Add support for WebAuthn PRF extension (#337)
* Add support for WebAuthn PRF extension

Original context: https://bugzilla.mozilla.org/show_bug.cgi?id=1863819

* Send correct PIN protocol ID in hmac-secret

Before this change, OpenSK (tag 2.1, commit
893faa5113f47457337ddb826b1a58870f00bc78) returns CTAP2_ERR_INVALID_PARAMETER in
response to attempts to use the WebAuthn PRF extension.

Original context: https://bugzilla.mozilla.org/show_bug.cgi?id=1863819

* Extract function HmacSecretResponse::decrypt_secrets

* Clarify and correct hmac-secret and PRF client outputs in makeCredential

* Delete unnecessary impl Default

* Rename HmacSecretFromHmacSecretOrPrf to HmacCreateSecretOrPrf

* Use HmacGetSecretOrPrf data model in getAssertion too

* Add examples/prf.rs

* Construct channels outside loop

* Remove unused loop

* Add tests for HmacSecretResponse::decrypt_secrets

* Extract function AuthenticationExtensionsPRFInputs::eval_to_salt

* Extract AuthenticationExtensionsPRFInputs::select_eval and ::select_credential

* Add doc comment to AuthenticationExtensionsPRFInputs::calculate

* Fix clippy lint

* Return empty prf output if no eval or evalByCredential entry matched

* Extract function HmacGetSecretOrPrf::calculate

* Add tests of calculating hmac-secret/PRF inputs

* Fix outdated error messages

* Separate hmac_secret tests that require a crypto backend

* Add debug output to error paths of HmacSecretResponse::decrypt_secrets

* Fix a typo and a cryptic comment

* Eliminate unnecessary sha256 function

* Simplify to Sha256::digest where possible

* Derive PartialEq always, not just in cfg(test)

* Document generation of hmac_secret test data

* Remove unnecessary comma

* Tweak imports per review

* Take PinUvAuthToken as reference in HmacSecretExtension::calculate

* Deduplicate decrypt_pin_token code in tests

* Extract function GetAssertion::process_hmac_secret_and_prf_extension

* Move allow_list assignment to top level scope

* Add tests of hmac-secret and prf processing in GetAssertion::finalize_result

* Fail hmac-secret salt calculation if input salts are too long

This is prescribed by the [CTAP spec][ctap]:

>**Client extension processing**
>1. [...]
>2. If present in a get():
>  1. Verify that salt1 is a 32-byte ArrayBuffer.
>  2. If salt2 is present, verify that it is a 32-byte ArrayBuffer.
>  [...]

[ctap]: https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html#sctn-hmac-secret-extension

* Add tests of GetAssertion::process_hmac_secret_and_prf_extension

* Propagate WrongSaltLength as InvalidRelyingPartyInput in GetAssertion::process_hmac_secret_and_prf_extension

* Return PrfUnmatched instead of None when shared secret is not available

This is needed because the PRF extension should return an empty extension output
`prf: {}` when the extension is processed but no eligible authenticator is
found. Thus we need to differentiate these cases so that
`GetAssertion::finalize_result` can match on `PrfUnmatched` and generate the
empty output.

* Add debug logging when no shared secret is available

* Add debug logging when hmac-secret output decryption fails

* Add test of serializing uninitialized and unmatched PRF inputs

* Add missing test of serializing hmac-secret with PIN protocol 2
2024-07-25 10:06:59 -07:00
Emil Lundberg 86ca74704e Fix typo 2024-07-18 17:28:20 -07:00
Emil Lundberg aace29d1e7 Remove identifier from first 10 entries of serialize_map_optional! 2024-07-18 17:28:20 -07:00
Emil Lundberg a05a04c704 Add tests of serialize_map_optional! 2024-07-18 17:28:20 -07:00
Emil Lundberg fb98f433aa Don't require crypto backend for util::decode_hex 2024-07-18 17:28:20 -07:00
Emil Lundberg eaf32fc403 Eliminate single-use variable 2024-07-18 17:28:20 -07:00
Emil Lundberg 2af9bf5905 Use fully qualified type and method names in serialize_map! macros 2024-07-18 17:28:20 -07:00
Emil Lundberg 83f10e18d9 Move SerializeMap import inside serialize_map! macros 2024-07-18 17:28:20 -07:00
Emil Lundberg 30bdcbad2d Serialize AttestationStatementFidoU2F in canonical order 2024-07-18 17:28:20 -07:00
Emil Lundberg 5132d8c5c5 Use macro serialize_map! in impl Serialize for AttestationObject 2024-07-18 17:28:20 -07:00
Emil Lundberg 9d141ae751 Don't evaluate values twice in serialize_map! 2024-07-18 17:28:20 -07:00
Emil Lundberg e3a81a350b Extract serialize_map! macros 2024-07-18 17:28:20 -07:00
Emil Lundberg 214a760462 Add test of BioEnrollment serialization 2024-07-18 17:28:20 -07:00
Emil Lundberg d342d8b5bf Add test of BioEnrollmentParams serialization 2024-07-18 17:28:20 -07:00
Emil Lundberg 0b45ce73ba Add test of CredManagementParams serialization 2024-07-18 17:28:20 -07:00
Emil Lundberg d67563c71c Add test of AuthenticatorConfig serialization 2024-07-18 17:28:20 -07:00
Emil Lundberg 7acca2a2db Add test of SetMinPINLength serialization 2024-07-18 17:28:20 -07:00
Emil Lundberg 2381450023 Add test of ClientPIN serialization 2024-07-18 17:28:20 -07:00
Emil Lundberg f8243224ef Add test of GetAssertion serialization 2024-07-18 17:28:20 -07:00
Emil Lundberg 3679ed054a Add test of MakeCredentials serialization 2024-07-18 17:28:20 -07:00
Emil Lundberg 713867c640 Add tests of AttestationObject and AttestationStatement serialization 2024-07-18 17:28:20 -07:00
Martin Sirringhaus 32f8e144ea Fix #319: CTAP2.0 bug in preflighting, which can omit credential data
Extend the mock device to be able to skip the low-level byte-by-byte
comparison of incoming and outgoing data, and instead use CTAP requests
and responses directly, for higher-level business-logic testing.
Add tests for preflighting.
2023-11-17 16:15:52 -08:00
John M. Schanck be6526c432 Handle present-but-empty extension data when serializing AuthenticatorData 2023-11-08 12:56:53 -08:00
Martin Sirringhaus 593f5052ba Fix new clippy warnings 2023-11-08 11:22:41 -08:00
John M. Schanck cb8a2c1d7d Return authenticator attachment with results 2023-09-27 09:59:59 -07:00
John M. Schanck 925b9b8dc6 Remove support for credProps for CTAP 2.0 devices 2023-09-27 09:59:59 -07:00
John M. Schanck c9a6692cfa Make finalize_result take a FidoDevice as input 2023-09-27 09:59:59 -07:00
John M. Schanck d37f5ad4b2 Remove unnecessary RelyingPartyWrapper type 2023-09-26 11:50:55 -07:00
John M. Schanck d3a0d09f48 Add StatusUpdate::SelectResultNotice 2023-09-19 15:39:26 -07:00
John M. Schanck 5d20800714 Rename User to PublicKeyCredentialUserEntity 2023-09-19 15:39:26 -07:00
John M. Schanck f96f75384d Forbid empty integer in DER encoder 2023-09-15 12:38:39 -07:00
John M. Schanck 4eab8e204a Add der_spki() methods for all supported key types 2023-09-15 12:38:39 -07:00
John M. Schanck 0c72ccaa4e Fix OKP key map length 2023-09-15 12:38:39 -07:00
Martin Sirringhaus 7fa6364de4 Dont ignore cached PUATs for devices < FIDO_2_1 2023-09-13 13:19:57 -07:00
John M. Schanck 282a08c89e Remove legacy_register and legacy_sign 2023-09-11 14:47:16 -07:00
John M. Schanck 7227568b00 Allow FnOnce callback functions 2023-09-11 14:47:05 -07:00
John M. Schanck 2cff8a50ed Call finalize_result after CTAP1 MakeCredentials requests 2023-09-11 09:39:09 -07:00
John M. Schanck fc99667f4e Fix credProtect support detection for CTAP1 devices 2023-09-11 09:39:09 -07:00
John M. Schanck bf76a7dc66 clippy 2023-09-11 09:39:09 -07:00
John M. Schanck 8f4914023e Update support for hmac-secret extension in MakeCredentials 2023-09-11 09:39:09 -07:00
John M. Schanck 1a1d712e9e rustfmt 2023-09-11 09:39:09 -07:00
John M. Schanck d5092e7637 Rename MakeCredentialsExtensions::has_extensions to has_content 2023-09-11 09:39:09 -07:00
John M. Schanck 9fb9fa9504 Derive Serialize for GetAssertionExtensions 2023-09-11 09:39:09 -07:00
John M. Schanck 0cb2b9573b Make Extension::has_some public for virtual authenticators 2023-09-11 09:39:09 -07:00
John M. Schanck b2b2fb3977 Add support for the credProtect extension 2023-09-11 09:39:09 -07:00
John M. Schanck bbba54700e Add support for the minPinLength extension 2023-09-11 09:39:09 -07:00
John M. Schanck d512ad9b5d Rework support for AppId extension 2023-09-11 09:39:09 -07:00
John M. Schanck a00fd64edc Add support for the credProps extension 2023-09-11 09:39:09 -07:00
John M. Schanck cb8391a834 Add finalize_result to MakeCredentials/GetAssertion for extension handling 2023-09-11 09:39:09 -07:00