Add optional test param 'wrappedKey' to test helper
This commit is contained in:
parent
79e553d06c
commit
53b8ab534c
|
@ -89,6 +89,7 @@ context("AES", () => {
|
||||||
name: "AES-CBC",
|
name: "AES-CBC",
|
||||||
iv: Buffer.from("1234567890abcdef"),
|
iv: Buffer.from("1234567890abcdef"),
|
||||||
} as AesCbcParams,
|
} as AesCbcParams,
|
||||||
|
wrappedKey: Convert.FromHex("c630c4bf95977db13f386cc950b18e98521d54c4fda0ba15b2884d2695638bd9"),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
|
@ -74,6 +74,7 @@ export interface ITestWrapKeyAction extends ITestAction {
|
||||||
key: IImportKeyParams | IImportKeyPairParams;
|
key: IImportKeyParams | IImportKeyPairParams;
|
||||||
algorithm: Algorithm;
|
algorithm: Algorithm;
|
||||||
wKey: IImportKeyParams;
|
wKey: IImportKeyParams;
|
||||||
|
wrappedKey?: BufferSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITestImportAction extends IImportKeyParams, ITestAction {
|
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);
|
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(
|
const unwrappedKey = await crypto.subtle.unwrapKey(
|
||||||
action.wKey.format,
|
action.wKey.format,
|
||||||
wrappedKey,
|
wrappedKey,
|
||||||
|
|
Reference in New Issue