[native][AES] Implement decrypt function on iOS
Summary:
This diff implements the decrypt() 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/open(_:using:)
Inspired by: https://dev.to/craftzdog/how-to-encrypt-decrypt-with-aes-gcm-using-cryptokit-in-swift-24h1
Depends on D7005
Test Plan:
Placed this e.g. in root component render function
import * as AES from './utils/aes-crypto-module.js'; const key = AES.generateKey(); console.log('Key', key); const plaintextBytes = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); const ciphertext = AES.encrypt(key, plaintextBytes); console.log('Ciphertext', ciphertext); const decrypted = AES.decrypt(key, ciphertext); console.log('Decrypted', decrypted); // should be [1,2,3...9,10]
should display sth like:
LOG Key [82, 226, 211, 141, 62, 105, 93, 161, 238, 193, 163, 46, 151, 205, 133, 163, 175, 15, 110, 16, 139, 86, 150, 10, 26, 30, 179, 245, 221, 215, 19, 13] LOG Ciphertext [74, 52, 31, 132, 80, 213, 246, 255, 188, 231, 18, 27, 222, 224, 91, 53, 204, 198, 109, 53, 40, 194, 198, 149, 181, 34, 131, 102, 228, 246, 171, 190, 89, 232, 36, 74, 173, 211] LOG Decrypted [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Reviewers: marcin, atul
Reviewed By: atul
Subscribers: ashoat, tomek
Differential Revision: https://phab.comm.dev/D7006