Details
Details
Run this code on a physical iOS device:
fn test(promise_id: u32) { RUNTIME.spawn(async move { let f = move || -> Result<String, cxx::Exception> { let key = &mut [0; constants::aes::KEY_SIZE]; ffi::generate_key(key)?; let plaintext = &mut [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let sealed_data = &mut [0; 10 + constants::aes::IV_LENGTH + constants::aes::TAG_LENGTH]; ffi::encrypt(key, plaintext, sealed_data)?; let plaintext2 = &mut [0; 10]; ffi::decrypt(key, sealed_data, plaintext2)?; Ok(format!( " Key: {key:?} Plaintext: {plaintext:?} Sealed Data: {sealed_data:?} Plaintext2: {plaintext2:?}" )) }; handle_string_result_as_callback(f(), promise_id); }); }
Example output:
Key: [25, 165, 133, 47, 109, 170, 104, 88, 70, 47, 174, 67, 235, 86, 27, 48, 117, 195, 150, 178, 120, 34, 117, 120, 115, 73, 135, 50, 216, 152, 37, 40] Plaintext: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Sealed Data: [75, 154, 51, 64, 189, 35, 46, 50, 39, 181, 228, 130, 86, 208, 62, 48, 14, 103, 18, 191, 92, 117, 248, 186, 35, 8, 134, 109, 251, 54, 182, 192, 74, 244, 175, 46, 228, 120] Plaintext2: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Also I've run it a few times anc checked that the key was different each time. Also run the encryption with invalid length of sealed_data and decryption with invalid data and in both cases it failed gracefully with Result::Err.
Diff Detail
Diff Detail
- Repository
- rCOMM Comm
- Lint
Lint Not Applicable - Unit
Tests Not Applicable