Skip to main content

Crate passkey_rp

Crate passkey_rp 

Source
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

  1. Construct a RelyingParty and reuse its PasskeyRp verifier.
  2. Generate a Challenge and store it with the expected ceremony type, account, user-verification policy, and a short expiration.
  3. Decode the browser response’s base64url fields into bytes.
  4. Build RegistrationVerification or AuthenticationVerification and call the matching verifier method.
  5. Consume the challenge exactly once. Persist the returned StoredCredential only 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§

AuthenticationVerification
Borrowed inputs for verifying one authentication ceremony.
Challenge
A validated WebAuthn challenge retained in server-side ceremony state.
PasskeyRp
A reusable verifier bound to one RelyingParty.
PublicKey
A validated WebAuthn credential public key.
RegistrationVerification
Borrowed inputs for verifying one registration ceremony.
RelyingParty
A validated WebAuthn relying-party ID and accepted browser origin.
StoredCredential
Validated credential state persisted by the relying party.
UserHandleVerification
Account-binding policy for an authentication response user handle.
VerifiedAuthentication
Result of a successfully verified authentication assertion.
VerifiedRegistration
Result of a successfully verified registration response.

Enums§

CoseAlgorithm
COSE algorithms accepted for credential public keys.
CredentialBackupState
Valid combinations of WebAuthn backup eligibility (BE) and backup state (BS).
PasskeyError
Errors returned while constructing or verifying WebAuthn values.
UserVerificationPolicy
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.