Skip to content

crypto(webcrypto): ECDH Named curve mismatch #35812

Description

@panva
  • Version: v15.0.1
  • Platform: Darwin C02CX0K5MD6V 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64
  • Subsystem: crypto.webcrypto

What steps will reproduce the bug?

This rejects

subtle.importKey(
    "jwk",
    {
        kty: "EC",
        crv: "P-256",
        x: "kgR_PqO07L8sZOBbw6rvv7O_f7clqDeiE3WnMkb5EoI",
        y: "djI-XqCqSyO9GFk_QT_stROMCAROIvU8KOORBgQUemE",
        d: "5aPFSt0UFVXYGu-ZKyC9FQIUOAMmnjzdIwkxCMe3Iok",
        alg: 'ECDH-ES',
    },
    {
        name: "ECDH",
        namedCurve: "P-256"
    },
    false,
    ["deriveKey", "deriveBits"]
)

This works, difference is the presence of the JWK "alg" (Algorithm) Parameter

subtle.importKey(
    "jwk",
    {
        kty: "EC",
        crv: "P-256",
        x: "kgR_PqO07L8sZOBbw6rvv7O_f7clqDeiE3WnMkb5EoI",
        y: "djI-XqCqSyO9GFk_QT_stROMCAROIvU8KOORBgQUemE",
        d: "5aPFSt0UFVXYGu-ZKyC9FQIUOAMmnjzdIwkxCMe3Iok",
    },
    {
        name: "ECDH",
        namedCurve: "P-256"
    },
    false,
    ["deriveKey", "deriveBits"]
)

What is the expected behavior?

The key import promise should resolve. (I think, at least it does in Chromium's Web Crypto API implementation.

// cc @jasnell

Activity

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

    cryptoIssues and PRs related to the crypto subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions