Cryptographic Algorithms Supported by WebAuthn

When architecting modern identity systems, understanding the cryptographic primitives underpinning passkeys is non-negotiable. The Web Authentication API (WebAuthn) mandates asymmetric cryptography, replacing shared secrets with mathematically bound key pairs. This guide details the Cryptographic Algorithms Supported by WebAuthn, providing implementation workflows, platform-specific behaviors, compliance mappings, and production-grade code patterns for full-stack developers, security engineers, and compliance officers.


1. Introduction to WebAuthn Cryptographic Standards

The transition from password-based authentication to public-key cryptography hinges on precise algorithm negotiation during credential creation. WebAuthn relies on COSE (CBOR Object Signing and Encryption) identifiers to communicate supported cryptographic suites between the client, authenticator, and Relying Party (RP). As outlined in WebAuthn & FIDO2 Protocol Fundamentals, the RP initiates this negotiation by declaring an ordered preference array, ensuring the authenticator selects the strongest mutually supported algorithm.

Workflow Validation Steps

  1. Client invokes navigator.credentials.create() with a pubKeyCredParams array containing ordered COSE algorithm identifiers.
  2. The authenticator evaluates hardware/software capabilities and selects the highest-priority algorithm from the array.
  3. The RP validates the returned credential’s public key against the negotiated algorithm before persisting it to the credential store.

Platform & Authenticator Variations

  • Browser Defaults: Chromium-based browsers typically prioritize ES256 (-7), while Safari may reorder preferences based on Secure Enclave availability.
  • Legacy Enterprise Constraints: Older hardware security modules (HSMs) or enterprise PKI integrations may restrict operations to RSA-based curves, requiring explicit fallback declarations.

Compliance & Regulatory Alignment

  • NIST SP 800-63B: Aligns with AAL2/AAL3 requirements for cryptographic strength and phishing resistance.
  • OWASP ASVS V2.4: Mandates explicit algorithm negotiation to prevent cryptographic downgrade attacks.

Implementation Code

// Production-ready pubKeyCredParams configuration
const pubKeyCredParams = [
 { type: "public-key", alg: -7 }, // ES256 (ECDSA P-256 + SHA-256)
 { type: "public-key", alg: -257 }, // RS256 (RSA PKCS#1 v1.5 + SHA-256)
 { type: "public-key", alg: -8 } // EdDSA (Ed25519)
];

const publicKeyCredentialCreationOptions = {
 challenge: Uint8Array.from(window.crypto.getRandomValues(new Uint8Array(32))),
 rp: { name: "Example Corp", id: "example.com" },
 user: { id: Uint8Array.from(crypto.getRandomValues(new Uint8Array(16))), name: "[email protected]", displayName: "User" },
 pubKeyCredParams,
 authenticatorSelection: { residentKey: "preferred", userVerification: "required" }
};

Security Pitfalls & Mitigations

  • Assumption Risk: Assuming universal ES256 support across all FIDO2 tokens. Mitigation: Always provide a fallback array.
  • Negotiation Omission: Omitting pubKeyCredParams causes silent credential creation failures or forces browser defaults that may violate RP policy. Mitigation: Explicitly declare all acceptable COSE identifiers.

2. COSE Algorithm Registry and FIDO2 Architecture Alignment

WebAuthn’s cryptographic layer operates within a broader protocol stack. The mapping of COSE identifiers to standard curves ensures interoperability across diverse authenticator form factors. Core supported algorithms include ES256 (-7), RS256 (-257), EdDSA (-8), and PS256 (-37). Understanding how CTAP2 transports these preferences between the platform and the authenticator is critical, as detailed in Understanding WebAuthn vs FIDO2 Architecture.

Workflow Validation Steps

  1. Parse the COSE key structure from the authenticatorData payload post-registration.
  2. Extract elliptic curve coordinates or RSA modulus/exponent based on kty and alg fields.
  3. Verify the assertion signature against the clientDataJSON hash using the exact algorithm negotiated during creation.

Platform & Authenticator Variations

  • iOS Secure Enclave: Strictly enforces ES256 and EdDSA; RSA operations are unsupported on-device.
  • Windows Hello TPM 2.0: Defaults to RS256 for legacy compatibility but supports ES256 when explicitly requested.
  • Android StrongBox: Hardware-backed ECDSA and EdDSA with strict attestation enforcement.

Compliance & Regulatory Alignment

  • FIPS 140-3: Requires validated cryptographic modules for enterprise key storage; ES256 and RS256 are NIST-approved.
  • eIDAS QSCD: Mandates qualified signature creation devices; algorithm selection must align with EU regulatory curves.

Implementation Code

# Python backend routing for dynamic crypto verification
def select_verification_library(cose_alg: int):
    """Dynamically route to appropriate cryptographic backend based on COSE alg"""
    if cose_alg == -7:    # ES256
        return "cryptography.hazmat.primitives.asymmetric.ec"
    elif cose_alg == -257: # RS256
        return "cryptography.hazmat.primitives.asymmetric.rsa"
    elif cose_alg == -8:  # EdDSA
        return "cryptography.hazmat.primitives.asymmetric.ed25519"
    else:
        raise ValueError(f"Unsupported COSE algorithm identifier: {cose_alg}")

Security Pitfalls & Mitigations

  • Hardcoding Algorithms: Locking verification to a single curve breaks cross-device sync and roaming authenticator support. Mitigation: Implement dynamic routing based on the stored credential’s alg field.
  • COSE-to-JWK Conversion Errors: Incorrect byte-ordering or missing curve parameters during conversion causes signature verification failures. Mitigation: Use audited libraries (e.g., cose-js, pycose) that handle RFC 8152 encoding natively.

3. Cross-Platform Authenticator Algorithm Support

Algorithm selection directly dictates credential security posture and interoperability. Hardware security keys, platform authenticators, and cloud-synced passkeys exhibit distinct cryptographic capabilities. As established in Public Key vs Symmetric Credential Types, asymmetric operations are mandatory to achieve phishing-resistant authentication and prevent credential leakage during transit.

Workflow Validation Steps

  1. Query authenticatorSelection criteria during registration to enforce platform or roaming constraints.
  2. Validate returned publicKeyCredentialCreationOptions against RP cryptographic policy.
  3. Enforce minimum algorithm strength thresholds at the RP middleware layer before credential issuance.

Platform & Authenticator Variations

  • YubiKey 5 Series: Supports ES256, RS256, and EdDSA; firmware versions dictate default curve selection.
  • Cloud Passkeys (iCloud/Google): Standardize on ES256 for cross-platform interoperability and efficient sync.
  • Legacy U2F Devices: Restricted to ES256 only; incompatible with RSA or EdDSA requests.

Compliance & Regulatory Alignment

  • SOC 2 Type II: Requires documented cryptographic control matrices and algorithm lifecycle management.
  • PCI-DSS Requirement 3.5: Mandates strong key management practices and prohibits deprecated algorithms in payment environments.

Implementation Code

// Feature detection matrix & conditional algorithm preference
function getOptimalAlgorithms() {
 const isMobile = /Mobi|Android/i.test(navigator.userAgent);
 const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
 
 if (isSafari) {
 // Safari Secure Enclave prefers ES256, fallback to EdDSA
 return [{ type: "public-key", alg: -7 }, { type: "public-key", alg: -8 }];
 } else if (isMobile) {
 // Android/iOS passkeys standardize on ES256
 return [{ type: "public-key", alg: -7 }];
 }
 // Desktop/Enterprise fallback
 return [{ type: "public-key", alg: -7 }, { type: "public-key", alg: -257 }];
}

Security Pitfalls & Mitigations

  • TPM vs Mobile Mismatch: TPMs defaulting to RS256 while mobile defaults to ES256 causes backend verification routing failures. Mitigation: Store the alg identifier alongside the credential ID and use it to route verification.
  • Deprecated Algorithm Acceptance: Failing to explicitly reject RS1 (SHA-1) or weak curves in legacy fallbacks. Mitigation: Implement strict allowlists at the RP middleware.

4. Server-Side Verification and Challenge-Response Flow

Verification workflows must strictly bind the cryptographic operation to the session challenge. The assertion signature is computed over the concatenation of authenticatorData and the SHA-256 hash of clientDataJSON. This process mirrors the principles outlined in The Challenge-Response Authentication Flow, ensuring non-replayability and origin binding. Proper handling of attestation vs assertion payloads and clear delineation of Relying Party and Authenticator Roles are essential for secure verification pipelines.

Workflow Validation Steps

  1. Reconstruct clientDataJSON hash using SHA-256 (SHA-256(clientDataJSON)).
  2. Verify authenticatorData flags (UP, UV, AT, ED) and signature length against algorithm requirements.
  3. Execute cryptographic verify() using the extracted public key and the exact algorithm negotiated during registration.
  4. Validate credential counter progression and ID against stored session state to detect cloning.

Platform & Authenticator Variations

  • Browser Crypto APIs: crypto.subtle (Web Crypto API) handles verification client-side, but server-side verification requires native libraries (OpenSSL, BouncyCastle, cryptography).
  • ASN.1/DER Encoding: Platform implementations vary in signature encoding; ECDSA signatures may be DER-encoded or raw concatenated (r, s) values.

Compliance & Regulatory Alignment

  • GDPR Data Minimization: Cryptographic keys must be stored with minimal metadata; avoid logging raw public keys in plaintext audit trails.
  • ISO/IEC 27001 A.10: Requires documented cryptographic controls, key rotation policies, and algorithm deprecation schedules.

Implementation Code

// Step-by-step assertion validation (Node.js example)
const crypto = require('crypto');

async function verifyAssertion(assertion, storedCredential) {
  const clientDataHash = crypto.createHash('sha256')
    .update(Buffer.from(assertion.response.clientDataJSON, 'base64url'))
    .digest();
  const authData  = Buffer.from(assertion.response.authenticatorData, 'base64url');
  const signature = Buffer.from(assertion.response.signature, 'base64url');

  // Signed payload per WebAuthn spec §7.2: authenticatorData ‖ SHA-256(clientDataJSON)
  const signedPayload = Buffer.concat([authData, clientDataHash]);

  // Route hash algorithm by COSE alg ID stored at registration time
  // -7 = ES256 (ECDSA P-256), -257 = RS256 (RSA PKCS#1 v1.5)
  const hashAlg = storedCredential.alg === -7 ? 'SHA256' : 'RSA-SHA256';
  const isValid = crypto.verify(
    hashAlg,
    signedPayload,
    { key: storedCredential.publicKey, dsaEncoding: 'ieee-p1363' }
  );

  if (!isValid) throw new Error('Signature verification failed');

  // signCount is a 4-byte big-endian uint at offset 33 in authenticatorData
  const signCount = authData.readUInt32BE(33);
  if (signCount <= storedCredential.counter) {
    throw new Error('Replay attack or cloned credential detected');
  }
  return { verified: true, newCounter: signCount };
}

Security Pitfalls & Mitigations

  • Incorrect ASN.1/DER Parsing: Raw vs DER signature mismatches cause false-negative verifications. Mitigation: Normalize signatures to IEEE P1363 format before verification.
  • Hash Binding Omission: Skipping clientDataJSON hash concatenation enables replay attacks. Mitigation: Always verify the exact signed payload structure per WebAuthn spec §7.2.

5. Implementation Pitfalls and Migration Strategies

Robust deployment requires proactive monitoring of algorithm negotiation failures and strict enforcement of cryptographic boundaries across the identity stack. Browser inconsistencies in COSE integer mapping, enterprise SSO integrations requiring explicit whitelisting, and legacy system decommissioning demand structured migration pathways.

Workflow Validation Steps

  1. Implement RP-side allowlist validation for supported algorithms before credential creation.
  2. Log unsupported alg responses for client capability analysis and telemetry dashboards.
  3. Deploy staged algorithm rollout with fallback to legacy MFA during transition periods.

Platform & Authenticator Variations

  • Browser COSE Mapping: Safari, Chrome, and Firefox occasionally diverge in how they expose platform capabilities via PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable().
  • Enterprise SSO: SAML/OIDC bridges often require explicit algorithm whitelisting to map WebAuthn credentials to legacy identity providers.

Compliance & Regulatory Alignment

  • SOX / HIPAA Audit Trails: Cryptographic operations must generate immutable logs detailing algorithm selection, verification outcomes, and failure reasons.
  • Zero-Trust Architecture: Algorithm enforcement acts as a cryptographic control point; unverified or unsupported algorithms must trigger immediate session termination.

Implementation Code

// Error handling wrappers & telemetry hooks
function handleAlgorithmNegotiationError(err, context) {
 const telemetry = {
 timestamp: new Date().toISOString(),
 userAgent: navigator.userAgent,
 error: err.message,
 requestedAlgs: context.pubKeyCredParams.map(p => p.alg),
 severity: err.message.includes('unsupported') ? 'high' : 'medium'
 };
 
 // Send to SIEM / monitoring pipeline
 sendTelemetry('webauthn_alg_negotiation_failure', telemetry);
 
 // Graceful fallback
 if (err.message.includes('unsupported')) {
 return { fallback: 'legacy_mfa', message: 'Please use a supported security key or platform authenticator.' };
 }
 throw err;
}

Security Pitfalls & Mitigations

  • Silent Failures on Unsupported Curves: Missing alg validation in pubKeyCredParams causes authenticators to silently fail or return malformed credentials. Mitigation: Validate pubKeyCredParams against a strict RP allowlist before invoking navigator.credentials.create().
  • Over-Reliance on Browser Defaults: Assuming browsers will negotiate optimal algorithms violates zero-trust principles. Mitigation: Explicitly declare and enforce algorithm policies at the RP layer, logging deviations for compliance audits.