HomePhabricator
Diffusion Comm a0951b122781

[native][AES] Implement decrypt function on Android

Description

[native][AES] Implement decrypt function on Android

Summary:
Counterpart of D7006 for Android. More context in that diff.

Docs: https://developer.android.com/reference/kotlin/javax/crypto/Cipher
Inspired by: https://levelup.gitconnected.com/doing-aes-gcm-in-android-adventures-in-the-field-72617401269d

Depends on D7007

Test Plan:
The same as in D7006:

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 equal to plaintextBytes

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/D7008

Details

Provenance
bartekAuthored on Mar 8 2023, 6:56 AM
Reviewer
atul
Differential Revision
D7008: [native][AES] Implement decrypt function on Android
Parents
rCOMMfc7383f60b2e: [native][AES] Implement encrypt function on Android
Branches
Unknown
Tags
Unknown