Skip to content

SubtleCrypto deriveBits for PBKDF2 #345

Open

Description

@devin-ai-integration

crypto.subtle.deriveBits with PBKDF2 is needed by Fastly Compute apps that do key derivation for cookie/token schemes. A concrete example: the HUMAN Security (PerimeterX) _px3 cookie flow requires PBKDF2-HMAC-SHA256 (hundreds to thousands of iterations, 384 derived bits split into a 32-byte AES-256 key and 16-byte IV) followed by AES-256-CBC decryption. Without native PBKDF2, a JS implementation costs roughly ~45 ms per request versus ~1 ms natively, which is significant inside a Fastly Compute request handler.

Scope for the first increment:

  • crypto.subtle.importKey("raw", keyData, "PBKDF2", extractable, usages) producing a secret CryptoKey usable for deriveBits/deriveKey (usages restricted to those two).
  • crypto.subtle.deriveBits(algorithm, baseKey, length) wired through a CryptoAlgorithmDeriveBits base class, with the PBKDF2 operation implemented via OpenSSL PKCS5_PBKDF2_HMAC and the optional [EnforceRange] unsigned long length coercion semantics from the spec.
  • SHA-1 / SHA-256 / SHA-384 / SHA-512 PRFs.

Follow-on work (not part of the first PR): deriveKey for PBKDF2, AES-CBC encrypt/decrypt to complete the _px3 flow, and the remaining HKDF/ECDH deriveBits algorithms.

Activity

  1. draco2003 commented on Oct 24, 2026

    @draco2003

    Seems like Devin Integration was able to create an Issue, but is not able to delete it?
    Created a PR here: #346 so if someone can close out this Issue that would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions