rdubois-crypto / FreshCryptoLib

Cryptographic Primitives for Blockchain Systems (solidity, cairo, C and rust)
MIT License
124 stars 22 forks source link

Fix Issue #11: Replace Base64 encoding with Base64url encoding in WebAuthn_format #12

Closed evmBrahmin closed 11 months ago

evmBrahmin commented 11 months ago

Summary

Detailed Changes

FCL_Webauthn.sol:

Test File: FCL_Webauthn_Base64Url.t.sol


- Explanation of Mock Data Derivation:
  - The response object is provided directly from the WebAuthn Authentication API call and provides several fields.
  - The authenticatorDataMock is the hex representation of bytes obtained by Base64URL decoding the authenticatorData from the above response.
  - The clientDataMock is derived from the clientDataJSON in the response, after Base64URL decoding and converting to hex representation of the decoded bytes.
  - The challengeMock represents bytes from Base64URL decoding the clientDataJSON.
  - The rsMock contains the r and s values of the signature. It's important to note that the provided signature in the response object is the Base64URL encoding of the DER encoding of the signature.
  - The QMock contains the x and y values of the public key, which is generated during the registration process.
- Functions in the Test:
  - test_base64URL_format: Tests the new format and provides logs to illustrate the encoding.
  - test_webauthn_Base64URL_checkSignature: Validates the signature with the new encoding.
  - test_webauthn_format_details: Provides logs to understand the encoding process in detail.

## Request:
Kindly review the modifications and the accompanying tests to validate their efficacy.
A thorough security audit is recommended before integrating these changes into a production environment.
rdubois-crypto commented 11 months ago

Thanks for this perfectly documented correction.

Concerning the (necessary) audit, it will come for production ready code which is not the case yet.