From 53b8ab534c23e35a7b516105dc3b6fe29ceb4b2e Mon Sep 17 00:00:00 2001 From: microshine Date: Sat, 2 Mar 2019 09:24:51 +0300 Subject: [PATCH] Add optional test param 'wrappedKey' to test helper --- test/aes.ts | 1 + test/helper.ts | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/test/aes.ts b/test/aes.ts index 1d18803..441a89e 100644 --- a/test/aes.ts +++ b/test/aes.ts @@ -89,6 +89,7 @@ context("AES", () => { name: "AES-CBC", iv: Buffer.from("1234567890abcdef"), } as AesCbcParams, + wrappedKey: Convert.FromHex("c630c4bf95977db13f386cc950b18e98521d54c4fda0ba15b2884d2695638bd9"), }, ], }, diff --git a/test/helper.ts b/test/helper.ts index 054b446..e02f141 100644 --- a/test/helper.ts +++ b/test/helper.ts @@ -74,6 +74,7 @@ export interface ITestWrapKeyAction extends ITestAction { key: IImportKeyParams | IImportKeyPairParams; algorithm: Algorithm; wKey: IImportKeyParams; + wrappedKey?: BufferSource; } export interface ITestImportAction extends IImportKeyParams, ITestAction { @@ -336,6 +337,10 @@ export function testCrypto(crypto: Crypto, params: ITestParams[]) { const wrappedKey = await crypto.subtle.wrapKey(action.wKey.format, wKey, key.publicKey, action.algorithm); + if (action.wrappedKey) { + assert.equal(Convert.ToHex(wrappedKey), Convert.ToHex(action.wrappedKey)); + } + const unwrappedKey = await crypto.subtle.unwrapKey( action.wKey.format, wrappedKey,