addons/auth_passkey/_vendor/webauthn/helpers/generate_challenge.py
raw| 1 | import secrets |
| 2 | |
| 3 | |
| 4 | def generate_challenge() -> bytes: |
| 5 | """ |
| 6 | Create a random value for the authenticator to sign, going above and beyond the recommended |
| 7 | number of random bytes as per https://www.w3.org/TR/webauthn-2/#sctn-cryptographic-challenges: |
| 8 | |
| 9 | "In order to prevent replay attacks, the challenges MUST contain enough entropy to make |
| 10 | guessing them infeasible. Challenges SHOULD therefore be at least 16 bytes long." |
| 11 | """ |
| 12 | return secrets.token_bytes(64) |