WARNING: This is not compliant with the W3 WebCrypto specification.
interface DesEde3CbcParams {
// The initialization vector. MUST be 8 bytes.
iv: BufferSource;
}
Operation | Parameters | Result |
---|---|---|
generateKey | DesKeyGenParams | CryptoKey |
importKey | None | CryptoKey |
exportKey | None | JsonWebKey or BufferSource |
encrypt | DesEde3CbcParams | ArrayBuffer |
decrypt | DesEde3CbcParams | ArrayBuffer |
wrapKey | DesEde3CbcParams | ArrayBuffer |
unwrapKey | DesEde3CbcParams | CryptoKey |
const key = await crypto.subtle.generateKey(
{
name: "DES-EDE3-CBC",
length: 192, // 192-bit only
},
false, // extractable
["encrypt", "decrypt", "wrapKey", "unwrapKey"], // key usages
);
const key = await crypto.subtle.importKey(
"raw", // raw or jwk
rawData, // BufferSource
"DES-EDE3-CBC",
false, // extractable
["encrypt", "decrypt"],
);
const raw = await crypto.subtle.exportKey(
"raw", // raw or jwk
key,
);
const iv = crypto.getRandomValues(new Uint8Array(8));
const encData = await crypto.subtle.encrypt(
{
name: "DES-EDE3-CBC",
iv, // BufferSource
},
key, // DES key
data, // BufferSource
);
const data = await crypto.subtle.decrypt(
{
name: "DES-EDE3-CBC",
iv, // BufferSource
},
key, // DES key
encData, // BufferSource
);
const iv = crypto.getRandomValues(new Uint8Array(8));
const wrappedKey = await crypto.subtle.wrapKey(
"pkcs8", // raw, pkcs8, spki, or jwk
anyKey, // Crypto key
key, // DES key
{
name: "DES-EDE3-CBC",
iv, // BufferSource
},
);
const unwrappedKey = await crypto.subtle.unwrapKey(
"pkcs8", // raw, pkcs8, spki, or jwk
wrappedKey, // BufferSource
key, // DES key
{
name: "DES-EDE3-CBC",
iv, // BufferSource
},
{
name: "RSA-PSS",
hash: "SHA-256",
}
false, // extractable
["sign", "verify"],
);