summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal/crypto/util.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/polyfills/internal/crypto/util.ts')
-rw-r--r--ext/node/polyfills/internal/crypto/util.ts44
1 files changed, 43 insertions, 1 deletions
diff --git a/ext/node/polyfills/internal/crypto/util.ts b/ext/node/polyfills/internal/crypto/util.ts
index ccb772631..2e269b7fa 100644
--- a/ext/node/polyfills/internal/crypto/util.ts
+++ b/ext/node/polyfills/internal/crypto/util.ts
@@ -46,6 +46,47 @@ const digestAlgorithms = [
"sha1",
];
+export type EllipticCurve = {
+ name: string;
+ ephemeral: boolean;
+ privateKeySize: number;
+ publicKeySize: number;
+ sharedSecretSize: number;
+};
+
+export const ellipticCurves: Array<EllipticCurve> = [
+ {
+ name: "secp256k1",
+ privateKeySize: 32,
+ publicKeySize: 65,
+ sharedSecretSize: 32,
+ }, // Weierstrass-class EC used by Bitcoin
+ {
+ name: "prime256v1",
+ privateKeySize: 32,
+ publicKeySize: 65,
+ sharedSecretSize: 32,
+ }, // NIST P-256 EC
+ {
+ name: "secp256r1",
+ privateKeySize: 32,
+ publicKeySize: 65,
+ sharedSecretSize: 32,
+ }, // NIST P-256 EC (same as above)
+ {
+ name: "secp384r1",
+ privateKeySize: 48,
+ publicKeySize: 97,
+ sharedSecretSize: 48,
+ }, // NIST P-384 EC
+ {
+ name: "secp224r1",
+ privateKeySize: 28,
+ publicKeySize: 57,
+ sharedSecretSize: 28,
+ }, // NIST P-224 EC
+];
+
// deno-fmt-ignore
const supportedCiphers = [
"aes-128-ecb", "aes-192-ecb",
@@ -114,8 +155,9 @@ export function getHashes(): readonly string[] {
return digestAlgorithms;
}
+const curveNames = ellipticCurves.map((x) => x.name);
export function getCurves(): readonly string[] {
- notImplemented("crypto.getCurves");
+ return curveNames;
}
export interface SecureHeapUsage {