Expand description
A small, pure Rust Passkey and WebAuthn relying-party verification core.
passkey-rp verifies decoded server-side ceremony responses without
depending on OpenSSL. Its deliberately narrow profile supports ES256
credentials on P-256 and registration with the none attestation format.
Unsupported algorithms and attestation formats fail closed.
The crate does not create browser options, provide HTTP handlers, store ceremony state, authorize accounts, or implement account recovery. Device provenance and attestation trust are also out of scope.
§Ceremony workflow
- Construct a
RelyingPartyand reuse itsPasskeyRpverifier. - Generate a
Challengeand store it with the expected ceremony type, account, user-verification policy, and a short expiration. - Decode the browser response’s base64url fields into bytes.
- Build
RegistrationVerificationorAuthenticationVerificationand call the matching verifier method. - Consume the challenge exactly once. Persist the returned
StoredCredentialonly after successful verification.
Authentication requires an explicit UserHandleVerification so the
response is bound to trusted server-side account state. User verification is
required by default; use UserVerificationPolicy::Preferred only when the
same policy was selected when the ceremony began.
§Security responsibilities
The caller must authorize registration, enforce credential-ID uniqueness
within the relying party, rate-limit attempts, and protect ceremony state
against tampering and replay. Authentication success and the updated
credential returned by VerifiedAuthentication::into_credential must be
committed atomically; concurrent updates must not move the stored signature
counter backwards.
Client extension results are not accepted by this API. Authenticator extension CBOR is checked for structural validity but not interpreted. If an application relies on an extension, it must validate both the signed authenticator output and corresponding client output separately.
§Creating a verifier
use passkey_rp::{Challenge, PasskeyRp, RelyingParty};
let rp = PasskeyRp::new(RelyingParty::new(
"example.com",
"https://example.com",
)?);
let challenge = Challenge::generate()?;
assert_eq!(rp.relying_party().id(), "example.com");
assert_eq!(challenge.as_bytes().len(), 32);Structs§
- Authentication
Verification - Borrowed inputs for verifying one authentication ceremony.
- Challenge
- A validated
WebAuthnchallenge retained in server-side ceremony state. - Passkey
Rp - A reusable verifier bound to one
RelyingParty. - Public
Key - A validated
WebAuthncredential public key. - Registration
Verification - Borrowed inputs for verifying one registration ceremony.
- Relying
Party - A validated
WebAuthnrelying-party ID and accepted browser origin. - Stored
Credential - Validated credential state persisted by the relying party.
- User
Handle Verification - Account-binding policy for an authentication response user handle.
- Verified
Authentication - Result of a successfully verified authentication assertion.
- Verified
Registration - Result of a successfully verified registration response.
Enums§
- Cose
Algorithm - COSE algorithms accepted for credential public keys.
- Credential
Backup State - Valid combinations of
WebAuthnbackup eligibility (BE) and backup state (BS). - Passkey
Error - Errors returned while constructing or verifying
WebAuthnvalues. - User
Verification Policy - User-verification policy enforced while verifying a ceremony.
Constants§
- CHALLENGE_
LENGTH - Length, in bytes, of challenges created by
Challenge::generate.
Functions§
- decode_
base64url - Decodes padded or unpadded base64url data into bytes.
- encode_
base64url - Encodes bytes using unpadded base64url.