HomePhabricator
Diffusion Comm 5789ca85981d

[native][AES] Implement encrypt function on iOS

Description

[native][AES] Implement encrypt function on iOS

Summary:
This diff implements the encrypt() function on iOS.

Its desired behavior is described here: https://linear.app/comm/issue/ENG-388#comment-76a38890

Docs: https://developer.apple.com/documentation/cryptokit/aes/gcm/seal(_:using:nonce:)
Inspired by: https://dev.to/craftzdog/how-to-encrypt-decrypt-with-aes-gcm-using-cryptokit-in-swift-24h1

Depends on D7004

Test Plan:

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

const key = AES.generateKey();
const plaintextBytes = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
const ciphertext = AES.encrypt(key, plaintextBytes);
console.log('Ciphertext', ciphertext);
// ensured that ciphertext is 12+10+16=38 bytes long (ciphertext.length==38)

Reviewers: marcin, atul

Reviewed By: atul

Subscribers: anunay, ashoat, tomek

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

Details

Provenance
bartekAuthored on Mar 13 2023, 4:42 AM
Reviewer
atul
Differential Revision
D7005: [native][AES] Implement encrypt function on iOS
Parents
rCOMM46037bfe9b83: [native][AES] Implement generateKey function
Branches
Unknown
Tags
Unknown