Skip to content

Commit 2e9c7a3

Browse files
committed
review feedback
1 parent 2e24db8 commit 2e9c7a3

4 files changed

Lines changed: 9 additions & 6 deletions

File tree

packages/xforms-engine/src/lib/client-reactivity/instance-state/quarantine/encryption.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* More info: README.md
55
*/
66

7-
import { SubmissionManifestDefinition } from '../../../../parse/model/SubmissionManifestDefinition';
7+
import { EncryptedSubmissionManifestDefinition } from '../../../../parse/model/EncryptedSubmissionManifestDefinition';
88
import { type Submission } from '../prepareInstancePayload';
99
import { getEncryptedSymmetricKey } from './asymmetric';
1010
import { encryptAttachments } from './symmetric';
@@ -29,7 +29,7 @@ export const encryptSubmission = async (
2929
const symmetricKey = generateSymmetricKey();
3030
const encryptedSymmetricKey = await getEncryptedSymmetricKey(encryptionKey, symmetricKey);
3131

32-
const manifest = new SubmissionManifestDefinition(
32+
const manifest = new EncryptedSubmissionManifestDefinition(
3333
formId,
3434
formVersion,
3535
instanceId,

packages/xforms-engine/src/parse/model/SubmissionManifestDefinition.ts renamed to packages/xforms-engine/src/parse/model/EncryptedSubmissionManifestDefinition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
ENCRYPTED_SUFFIX,
88
} from '../../lib/client-reactivity/instance-state/quarantine/encryption';
99

10-
export class SubmissionManifestDefinition {
10+
export class EncryptedSubmissionManifestDefinition {
1111
readonly attachments: string[];
1212

1313
constructor(

packages/xforms-engine/test/lib/client-reactivity/instance-state/quarantine/asymmetric.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ describe('asymmetric encryption', () => {
3232
expect(() => atob(actual)).not.toThrow();
3333
});
3434

35+
// ensures attacker cannot figure out what the plaintext is by looking up known encrypted submissions
36+
// See:
37+
// - https://en.wikipedia.org/wiki/Optimal_asymmetric_encryption_padding
38+
// - https://en.wikipedia.org/wiki/Probabilistic_encryption
3539
it('should produce different ciphertexts for the same input', async () => {
36-
// ensures attacker cannot figure out what the plaintext is by looking up known encrypted submissions
3740
const result1 = await getEncryptedSymmetricKey(publicKeyBase64, symmetricKey);
3841
const result2 = await getEncryptedSymmetricKey(publicKeyBase64, symmetricKey);
3942
expect(result1).not.toBe(result2);

packages/xforms-engine/test/lib/client-reactivity/instance-state/quarantine/symmetric.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ describe('symmetric encryption', () => {
8282
});
8383

8484
describe('functions are symmetrical', () => {
85-
[[][0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0x80], [0xff, 0xff, 0xff, 0xff]].forEach(
85+
[[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0x80], [0xff, 0xff, 0xff, 0xff]].forEach(
8686
(input, idx) => {
8787
it(`should not mangle example #${idx}`, () => {
88-
const given = new Uint8Array(input!);
88+
const given = new Uint8Array(input);
8989
const actual = wordArrayToArrayBuffer(arrayBufferToWordArray(given));
9090
expect(actual).to.deep.equal(given);
9191
});

0 commit comments

Comments
 (0)