Page MenuHomePhabricator

[web] Implement AES encryption functions
ClosedPublic

Authored by bartek on Thu, Mar 9, 11:05 AM.
Tags
None
Referenced Files
F445878: D7024.id23677.diff
Sun, Mar 26, 7:27 AM
F445337: D7024.id.diff
Sat, Mar 25, 9:28 PM
F445167: D7024.id23587.diff
Sat, Mar 25, 2:51 PM
Unknown Object (File)
Fri, Mar 24, 5:22 AM
Unknown Object (File)
Tue, Mar 21, 11:57 AM
Unknown Object (File)
Sat, Mar 11, 2:17 PM
Unknown Object (File)
Sat, Mar 11, 2:17 PM
Unknown Object (File)
Sat, Mar 11, 7:54 AM
Subscribers

Details

Summary
Test Plan

Unit tests will be added in next diff.

In root component (or any other) I did:

import * as AES from './utils/aes-crypto-module.js';

const f = async () => {
  const key = await AES.generateKey();
  console.log('Key', key);
  const plaintextBytes = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
  const ciphertext = await AES.encrypt(key, plaintextBytes);
  console.log('Ciphertext', ciphertext);
  const decrypted = await AES.decrypt(key, ciphertext);
  console.log('Decrypted', decrypted); // should be equal to plaintextBytes
};

React.useEffect(() => {
  f();
}, []);

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bartek held this revision as a draft.
bartek published this revision for review.Thu, Mar 9, 11:26 AM

Unit tests will be added in next diff.

Sweet, thanks for handling this

web/utils/aes-crypto.js
50 ↗(On Diff #23587)

I think we can do an equality check here?

51 ↗(On Diff #23587)

We mention "size" in the previous error message:

throw new Error('Invalid AES key size');

Should we do the same here for symmetry?

This revision is now accepted and ready to land.Fri, Mar 10, 3:29 PM
  • Rebase on new types
  • Address review feedback
    • Used consistent naming for ciphertext, sealed data etc.
bartek added inline comments.
web/utils/aes-crypto.js
50 ↗(On Diff #23587)

Nope, this can be equal (in case data is 0 length) or longer (with data between them).

Revert accidental changes

This revision is now accepted and ready to land.Mon, Mar 13, 5:21 AM
This revision was automatically updated to reflect the committed changes.