[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