Skip to content

Commit

Permalink
Update tests for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
nealfennimore committed May 30, 2023
1 parent 365e84d commit 7fbcb35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/aes/__tests__/aes_gcm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,10 @@ describe("AES_GCM", () => {
const wrappedKey = await kek.wrapKey("raw", dek.self, {
iv,
});
const unwrappedKey = (await AES.AES_GCM.unwrapKey(
const unwrappedKey = (await kek.unwrapKey(
"raw",
wrappedKey,
{ name: AES.Alg.Mode.AES_GCM },
kek.self,
{ iv }
)) as AES.AesGcmCryptoKey;

Expand Down
17 changes: 11 additions & 6 deletions src/rsa/__tests__/rsa_oaep.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,25 @@ describe("RSA_OAEP", () => {

it("should import and export key", async () => {
const keyPair = await RSA_OAEP.generateKey();
const jwk = await keyPair.publicKey.exportKey("jwk");
const pubJwk = await keyPair.publicKey.exportKey("jwk");
const privJwk = await keyPair.privateKey.exportKey("jwk");
const pubKey = (await RSA_OAEP.importKey(
"jwk",
jwk,
pubJwk,
{ hash: "SHA-512" },
false,
["encrypt"]
)) as RsaOaepProxiedPubCryptoKey;
const text = encode("a message");
const ciphertext = await pubKey.encrypt({ label }, text);
const plaintext = await keyPair.privateKey.decrypt(
{ label },
ciphertext
);
const privKey = (await RSA_OAEP.importKey(
"jwk",
privJwk,
{ hash: "SHA-512" },
false,
["decrypt"]
)) as RSA.RsaOaepProxiedPrivCryptoKey;
const plaintext = await privKey.decrypt({ label }, ciphertext);
expect(decode(plaintext)).toEqual(decode(text));
});
it("should encrypt and decrypt", async () => {
Expand Down

0 comments on commit 7fbcb35

Please sign in to comment.