HomePhabricator
Diffusion Comm 0a9f3ff4fc9d

[web] Implement AES encryption functions

Description

[web] Implement AES encryption functions

Summary:
Implemented functions described in https://linear.app/comm/issue/ENG-388#comment-76a38890

Docs: https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto

Depends on D6994

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();
}, []);

Reviewers: atul, marcin, kamil, michal

Reviewed By: atul

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D7024

Details

Provenance
bartekAuthored on Mar 9 2023, 10:59 AM
Reviewer
atul
Differential Revision
D7024: [web] Implement AES encryption functions
Parents
rCOMMa0951b122781: [native][AES] Implement decrypt function on Android
Branches
Unknown
Tags
Unknown