Page MenuHomePhabricator

[keyserver/web/native] Covert AES-256 key from Uint8Array representation to hex string representation
ClosedPublic

Authored by rohan on Sep 14 2023, 7:58 AM.
Tags
None
Referenced Files
F3140469: D9202.diff
Sun, Nov 3, 4:39 AM
Unknown Object (File)
Thu, Oct 31, 2:39 PM
Unknown Object (File)
Thu, Oct 31, 2:39 PM
Unknown Object (File)
Thu, Oct 31, 2:39 PM
Unknown Object (File)
Thu, Oct 31, 2:39 PM
Unknown Object (File)
Thu, Oct 31, 2:36 PM
Unknown Object (File)
Tue, Oct 29, 7:01 PM
Unknown Object (File)
Mon, Oct 28, 1:36 PM

Details

Summary

I think it makes the most sense to handle this conversion from Uint8Array to string before encoding the data in the QR codes, so clients reading the QR code don't need to handle it. I used @bartek's helper functions in lib/media/data-utils.js to achieve this.

Addresses ENG-4934

Depends on D9181

Test Plan

Logged the URL being encoded into the QR code, and parsed out the keys to make sure they were correct

const url = 'comm://qr-code/%7B%22aes256%22%3A%22b7990e4614f46bd8958df23c5c799110fdef8bc29a9a8821de60aad9e9e72c7f%22%2C%22ed25519%22%3A%22dbe%2FGygnpkyvW0GVMqwLuaiWAL6F9yoAwS3FO2BMhls%22%7D';

const qrCodeKeysRegex = /qr-code\/(\S+)$/;
const qrCodeKeysMatch = qrCodeKeysRegex.exec(url)[1];

const keys = JSON.parse(decodeURIComponent(qrCodeKeysMatch));

console.log(keys);

Output:

{
  aes256: 'b7990e4614f46bd8958df23c5c799110fdef8bc29a9a8821de60aad9e9e72c7f',
  ed25519: 'dbe/GygnpkyvW0GVMqwLuaiWAL6F9yoAwS3FO2BMhls'
}

Diff Detail

Repository
rCOMM Comm
Branch
terminal_qr
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

rohan added reviewers: atul, varun, bartek.
rohan added a reviewer: ginsu.
rohan requested review of this revision.Sep 14 2023, 8:16 AM

Code looks good to me, but resigning to give others a chance to review

accepting with nit inline

web/account/qr-code-login.react.js
25–26

i think we can name these better. maybe rawAESKey and aesKeyAsHexString. open to alternatives, just don't love calling the Uint8Array version of the key aes256

same in native

This revision is now accepted and ready to land.Sep 20 2023, 10:01 PM

Use rawAESKey and aesKeyAsHexString