[PM-8436] [PM-8483] Support Asymmetric Mac Encryption Types in EncString (#9441)

* Support Asymmetric Mac Encryption Types in EncString

* Add EncString Tests
This commit is contained in:
Justin Baur 2024-05-30 16:01:24 -04:00 committed by GitHub
parent de92720d7e
commit 93e7a6ae87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 0 deletions

View File

@ -55,6 +55,26 @@ describe("EncString", () => {
encryptionType: 3,
});
});
const cases = [
"aXY=|Y3Q=", // AesCbc256_B64 w/out header
"aXY=|Y3Q=|cnNhQ3Q=", // AesCbc128_HmacSha256_B64 w/out header
"0.QmFzZTY0UGFydA==|QmFzZTY0UGFydA==", // AesCbc256_B64 with header
"1.QmFzZTY0UGFydA==|QmFzZTY0UGFydA==|QmFzZTY0UGFydA==", // AesCbc128_HmacSha256_B64
"2.QmFzZTY0UGFydA==|QmFzZTY0UGFydA==|QmFzZTY0UGFydA==", // AesCbc256_HmacSha256_B64
"3.QmFzZTY0UGFydA==", // Rsa2048_OaepSha256_B64
"4.QmFzZTY0UGFydA==", // Rsa2048_OaepSha1_B64
"5.QmFzZTY0UGFydA==|QmFzZTY0UGFydA==", // Rsa2048_OaepSha256_HmacSha256_B64
"6.QmFzZTY0UGFydA==|QmFzZTY0UGFydA==", // Rsa2048_OaepSha1_HmacSha256_B64
];
it.each(cases)("can retrieve data bytes for %s", (encryptedString) => {
const encString = new EncString(encryptedString);
const dataBytes = encString.dataBytes;
expect(dataBytes).not.toBeNull();
expect(dataBytes.length).toBeGreaterThan(0);
});
});
describe("decrypt", () => {

View File

@ -97,6 +97,11 @@ export class EncString implements Encrypted {
case EncryptionType.Rsa2048_OaepSha1_B64:
this.data = encPieces[0];
break;
case EncryptionType.Rsa2048_OaepSha256_HmacSha256_B64:
case EncryptionType.Rsa2048_OaepSha1_HmacSha256_B64:
this.data = encPieces[0];
this.mac = encPieces[1];
break;
default:
return;
}