Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it(item.name, async () => {
const buf = Convert.FromHex(item.raw);
const bundle = await PreKeyBundleProtocol.importProto(buf);
const identity = await createIdentity(2);
try {
await AsymmetricRatchet.create(identity, bundle);
assert.isTrue(false, "Must be error");
} catch (err) {
// console.log(err.message);
}
});
});
// x: "AJGuTezC-8F-d_0bBpS502OK0z63vo87Dw99a3NUm6gm5pQC1rwu7LcblGqFWOuFBZhsF8I6OFjYvsR-z3u7hhCA",
// y: "AFQT8BB9hBf7UwwBUV4im8bFJ7_MD0qOZMVetmdbooMjfec1q3wU5cSoy4LvCnWAaFqu5havUxwnAUuPUWGG_InR",
},
algorithm: {
name: "ECDSA",
namedCurve: "P-521",
} as EcKeyImportParams,
extractable: true,
keyUsages: ["sign"],
},
//#endregion
//#region PKCS8
{
name: "PKCS8 P-256",
format: "pkcs8" as KeyFormat,
data: Convert.FromHex("304d020100301306072a8648ce3d020106082a8648ce3d030107043330310201010420895118e4e168dc9ee0d419d2c3f5845b2918fda96b84d9a91012f2ffb70d9ee1a00a06082a8648ce3d030107"),
algorithm: {
name: "ECDSA",
namedCurve: "P-256",
} as EcKeyImportParams,
extractable: true,
keyUsages: ["sign"],
},
{
name: "PKCS8 P-384",
format: "pkcs8" as KeyFormat,
data: Convert.FromHex("3057020100301006072a8648ce3d020106052b810400220440303e020101043098d7c6a318f0a02efe1a17552492884c11a079314d4cc9f92e1504905436072d61539fc7fd73371eeda4c80e3902c743a00706052b81040022"),
algorithm: {
name: "ECDSA",
namedCurve: "P-384",
} as EcKeyImportParams,
extractable: true,
{
algorithm: {
name: "RSAES-PKCS1-v1_5",
publicExponent: new Uint8Array([1, 0, 1]),
modulusLength: 1024,
} as RsaKeyGenParams,
extractable: false,
keyUsages: ["encrypt", "decrypt"],
} as ITestGenerateKeyAction,
],
encrypt: [
{
algorithm: {
name: "RSAES-PKCS1-v1_5",
} as Algorithm,
data: Convert.FromHex("01435e62ad3ec4850720e34f8cab620e203749f2315b203d"),
encData: Convert.FromHex("76e5ea6e1df52471454f790923f60e2baa7adf5017fe0a36c0af3e32f6390d570e1d592375ba6035fdf4ffa70764b797ab54d0ab1efe89cf31d7fc98240a4d08c2476b7eb4c2d92355b8bf60e3897c3fcbfe09f20c7b159d9a9c4a6b2ce5021dd313e492afa762c24930f97f03a429f7b2b1e1d6088651d60e323835807c6fefe7952f74e5da29e8e327ea46e69a0a6684272f022bf18ec602ffcd10a62666b35a51ec7c7d101096f663ddfa0924a86bdbcde0433b4f71dc42bfd9facf329558026f8667f1a71c3365e09843a12339d8aaf31987b0d800e53fd0835e990096cb145e278153faf1188cd5713c6fcd289cb77d80515e1d200139b8ccac4d3bcebc"),
key: {
publicKey: {
format: "jwk" as KeyFormat,
algorithm: { name: "RSAES-PKCS1-v1_5" } as Algorithm,
data: {
alg: "RS1",
e: "AQAB",
ext: true,
key_ops: ["encrypt"],
kty: "RSA",
n: "xr8ELXq5dGFycys8jrc8vVPkWl2GzuRgyOxATtjcNIy5MD7j1XVsUH62VVdIVUUGt0IQ7K288ij3gkIPcIkRO6GmV0vbQAqHrjSHYUAtKQXbIgNRIuJGZvO5AXsxSo1X-tfhOxe140pseOkaehz1bGduhdcYWNR3xLmp7i-GQTRDo-v6CQXtFvSUwG_EIOXnl1trN2Q1Yw4wA1dbtY9FDz69uH-dEWTx7BFCAXVTQMjNe7BTvgGeQcX7XZIw5e2pd0pXjdIgb0xMgziwmc5bbABrGlhK7TmKqA47RlWzY_Lcj7VcTUfMfh7YKKichGTUbqxlgsRTma_e-0-vgDEz6w",
},
extractable: true,
keyUsages: ["encrypt"] as KeyUsage[],
},
{
algorithm: {
name: "RSAES-PKCS1-v1_5",
publicExponent: new Uint8Array([1, 0, 1]),
modulusLength: 1024,
} as RsaKeyGenParams,
extractable: false,
keyUsages: ["encrypt", "decrypt"],
} as ITestGenerateKeyAction,
],
encrypt: [
{
algorithm: {
name: "RSAES-PKCS1-v1_5",
} as Algorithm,
data: Convert.FromHex("01435e62ad3ec4850720e34f8cab620e203749f2315b203d"),
encData: Convert.FromHex("76e5ea6e1df52471454f790923f60e2baa7adf5017fe0a36c0af3e32f6390d570e1d592375ba6035fdf4ffa70764b797ab54d0ab1efe89cf31d7fc98240a4d08c2476b7eb4c2d92355b8bf60e3897c3fcbfe09f20c7b159d9a9c4a6b2ce5021dd313e492afa762c24930f97f03a429f7b2b1e1d6088651d60e323835807c6fefe7952f74e5da29e8e327ea46e69a0a6684272f022bf18ec602ffcd10a62666b35a51ec7c7d101096f663ddfa0924a86bdbcde0433b4f71dc42bfd9facf329558026f8667f1a71c3365e09843a12339d8aaf31987b0d800e53fd0835e990096cb145e278153faf1188cd5713c6fcd289cb77d80515e1d200139b8ccac4d3bcebc"),
key: {
publicKey: {
format: "jwk" as KeyFormat,
algorithm: { name: "RSAES-PKCS1-v1_5" } as Algorithm,
data: {
alg: "RS1",
e: "AQAB",
ext: true,
key_ops: ["encrypt"],
kty: "RSA",
n: "xr8ELXq5dGFycys8jrc8vVPkWl2GzuRgyOxATtjcNIy5MD7j1XVsUH62VVdIVUUGt0IQ7K288ij3gkIPcIkRO6GmV0vbQAqHrjSHYUAtKQXbIgNRIuJGZvO5AXsxSo1X-tfhOxe140pseOkaehz1bGduhdcYWNR3xLmp7i-GQTRDo-v6CQXtFvSUwG_EIOXnl1trN2Q1Yw4wA1dbtY9FDz69uH-dEWTx7BFCAXVTQMjNe7BTvgGeQcX7XZIw5e2pd0pXjdIgb0xMgziwmc5bbABrGlhK7TmKqA47RlWzY_Lcj7VcTUfMfh7YKKichGTUbqxlgsRTma_e-0-vgDEz6w",
},
extractable: true,
keyUsages: ["encrypt"] as KeyUsage[],
},
name: "AES-128-ECB",
actions: {
generateKey: [
{
algorithm: { name: "AES-ECB", length: 128 } as AesKeyGenParams,
extractable: true,
keyUsages: ["encrypt", "decrypt"] as KeyUsage[],
},
],
encrypt: [
{
algorithm: {
name: "AES-ECB",
} as Algorithm,
data: Convert.FromUtf8String("test message"),
encData: Convert.FromHex("c6ec2f91a9f48e10062ae41e86cb299f"),
key: {
format: "raw" as KeyFormat,
data: Convert.FromUtf8String("1234567890abcdef"),
algorithm: { name: "AES-ECB" },
extractable: true,
keyUsages: ["encrypt", "decrypt"] as KeyUsage[],
},
},
],
import: [
{
name: "raw",
format: "raw" as KeyFormat,
data: Convert.FromUtf8String("1234567890abcdef"),
algorithm: "AES-ECB",
extractable: true,
name: "AES-192-ECB",
actions: {
generateKey: [
{
algorithm: { name: "AES-ECB", length: 192 } as AesKeyGenParams,
extractable: true,
keyUsages: ["encrypt", "decrypt"] as KeyUsage[],
},
],
encrypt: [
{
algorithm: {
name: "AES-ECB",
} as Algorithm,
data: Convert.FromUtf8String("test message"),
encData: Convert.FromHex("8c9f297827ad6aaa9e7501e79fb45ca5"),
key: {
format: "raw" as KeyFormat,
data: Convert.FromUtf8String("1234567890abcdef12345678"),
algorithm: { name: "AES-ECB" },
extractable: true,
keyUsages: ["encrypt", "decrypt"] as KeyUsage[],
},
},
],
import: [
{
name: "raw",
format: "raw" as KeyFormat,
data: Convert.FromUtf8String("1234567890abcdef12345678"),
algorithm: "AES-ECB",
extractable: true,
data: Convert.FromBase64("AQIDBAUGBwgJAAECAwQFBg"),
extractable: true,
keyUsages: ["wrapKey", "unwrapKey"],
},
wKey: {
format: "raw" as KeyFormat,
data: Convert.FromUtf8String("1234567890abcdef"),
algorithm: "AES-CBC",
extractable: true,
keyUsages: ["encrypt", "decrypt"],
},
algorithm: {
name: "AES-CBC",
iv: Convert.FromUtf8String("1234567890abcdef"),
} as AesCbcParams,
wrappedKey: Convert.FromHex("c630c4bf95977db13f386cc950b18e98521d54c4fda0ba15b2884d2695638bd9"),
},
],
},
},
{
name: "AES-192-CBC",
actions: {
generateKey: [
{
algorithm: { name: "AES-CBC", length: 192 } as AesKeyGenParams,
extractable: true,
keyUsages: ["encrypt", "decrypt"] as KeyUsage[],
},
],
encrypt: [
{
actions: {
generateKey: [
{
algorithm: { name: "AES-CBC", length: 256 } as AesKeyGenParams,
extractable: true,
keyUsages: ["encrypt", "decrypt"],
},
],
encrypt: [
{
algorithm: {
name: "AES-CBC",
iv: Convert.FromUtf8String("1234567890abcdef"),
} as AesCbcParams,
data: Convert.FromUtf8String("test message"),
encData: Convert.FromHex("d827c1c6aee9f0f552c62f30ddee83af"),
key: {
format: "raw",
data: Convert.FromUtf8String("1234567890abcdef1234567809abcdef"),
algorithm: { name: "AES-CBC" },
extractable: true,
keyUsages: ["encrypt", "decrypt"],
},
},
],
import: [
{
name: "raw",
format: "raw",
data: Convert.FromUtf8String("1234567890abcdef1234567890abcdef"),
algorithm: "AES-CBC",
extractable: true,
actions: {
generateKey: [
{
algorithm: { name: "AES-GCM", length: 128 } as AesKeyGenParams,
extractable: true,
keyUsages: ["encrypt", "decrypt", "wrapKey", "unwrapKey"],
},
],
encrypt: [
{
algorithm: {
name: "AES-GCM",
iv: Convert.FromUtf8String("1234567890ab"),
} as AesGcmParams,
data: Convert.FromUtf8String("test message"),
encData: Convert.FromHex("68d645649ddf8152a253304d698185072f28cdcf7644ac6064bcb240"),
key: {
format: "raw",
data: Convert.FromUtf8String("1234567890abcdef"),
algorithm: { name: "AES-GCM" },
extractable: true,
keyUsages: ["encrypt", "decrypt"],
},
},
],
import: [
{
name: "raw",
format: "raw",
data: Convert.FromUtf8String("1234567890abcdef"),
algorithm: "AES-GCM",
extractable: true,
algorithm: "AES-KW",
data: Convert.FromHex("000102030405060708090A0B0C0D0E0F"),
extractable: true,
keyUsages: ["wrapKey", "unwrapKey"],
},
wKey: {
format: "raw" as KeyFormat,
data: Convert.FromHex("00112233445566778899AABBCCDDEEFF"),
algorithm: "AES-KW",
extractable: true,
keyUsages: ["wrapKey", "unwrapKey"],
},
algorithm: {
name: "AES-KW",
},
wrappedKey: Convert.FromHex("1FA68B0A8112B447AEF34BD8FB5A7B829D3E862371D2CFE5"),
},
],
import: [
{
name: "raw",
format: "raw" as KeyFormat,
data: Convert.FromUtf8String("1234567890abcdef"),
algorithm: "AES-KW",
extractable: true,
keyUsages: ["wrapKey", "unwrapKey"] as KeyUsage[],
},
{
name: "jwk",
format: "jwk",
data: {
kty: "oct",