diff --git a/src/subtle.ts b/src/subtle.ts index 47141c5..898a6e4 100644 --- a/src/subtle.ts +++ b/src/subtle.ts @@ -30,7 +30,10 @@ export class SubtleCrypto extends core.SubtleCrypto { //#endregion //#region DES - this.providers.set(new DesCbcProvider()); + const ciphers = crypto.getCiphers(); + if (ciphers.includes("des-cbc")) { + this.providers.set(new DesCbcProvider()); + } this.providers.set(new DesEde3CbcProvider()); //#endregion diff --git a/test/crypto.ts b/test/crypto.ts index c378b55..1f0fa9c 100644 --- a/test/crypto.ts +++ b/test/crypto.ts @@ -1,5 +1,6 @@ -import assert from "assert"; -import process from "process"; +import assert from "node:assert"; +import nodeCrypto from "node:crypto"; +import process from "node:process"; import { WebcryptoTest } from "@peculiar/webcrypto-test"; import { Convert } from "pvtsutils"; import * as core from "webcrypto-core"; @@ -10,7 +11,11 @@ const nodeMajorVersion = parseInt(/^v(\d+)/.exec(process.version)![1], 10); const crypto = new Crypto(); -WebcryptoTest.check(crypto as any, {}); +const ciphers = nodeCrypto.getCiphers(); + +WebcryptoTest.check(crypto as any, { + DESCBC: !ciphers.includes("des-cbc"), +}); context("Crypto", () => { context("getRandomValues", () => {