From d6f662ac8280511fb4ef0f81777a0a6c5c08c0fa Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Sun, 11 Aug 2024 02:29:53 -0700 Subject: fix(ext/node): support ieee-p1363 ECDSA signatures and pss salt len (#24981) Fixes https://github.com/denoland/deno/issues/22919 --- tests/unit_node/crypto/crypto_sign_test.ts | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'tests/unit_node') diff --git a/tests/unit_node/crypto/crypto_sign_test.ts b/tests/unit_node/crypto/crypto_sign_test.ts index 557eea08e..c33c9758f 100644 --- a/tests/unit_node/crypto/crypto_sign_test.ts +++ b/tests/unit_node/crypto/crypto_sign_test.ts @@ -1,7 +1,13 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. import { assert, assertEquals } from "@std/assert"; -import { createSign, createVerify, sign, verify } from "node:crypto"; +import { + createSign, + createVerify, + generateKeyPairSync, + sign, + verify, +} from "node:crypto"; import { Buffer } from "node:buffer"; import fixtures from "../testdata/crypto_digest_fixtures.json" with { type: "json", @@ -179,3 +185,25 @@ Deno.test("crypto.createVerify|verify - compare with node", async (t) => { }); } }); + +Deno.test("crypto sign|verify dsaEncoding", () => { + const { privateKey, publicKey } = generateKeyPairSync("ec", { + namedCurve: "P-256", + }); + + const sign = createSign("SHA256"); + sign.write("some data to sign"); + sign.end(); + + // @ts-ignore FIXME: types dont allow this + privateKey.dsaEncoding = "ieee-p1363"; + const signature = sign.sign(privateKey, "hex"); + + const verify = createVerify("SHA256"); + verify.write("some data to sign"); + verify.end(); + + // @ts-ignore FIXME: types dont allow this + publicKey.dsaEncoding = "ieee-p1363"; + assert(verify.verify(publicKey, signature, "hex")); +}); -- cgit v1.2.3