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
Unknown Object (File)
Thu, Jul 11, 9:31 PM
Unknown Object (File)
Thu, Jul 11, 9:31 PM
Unknown Object (File)
Thu, Jul 11, 9:31 PM
Unknown Object (File)
Thu, Jul 11, 9:31 PM
Unknown Object (File)
Thu, Jul 11, 9:27 PM
Unknown Object (File)
Mon, Jul 8, 2:35 AM
Unknown Object (File)
Fri, Jul 5, 4:23 PM
Unknown Object (File)
Thu, Jul 4, 10:26 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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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 ↗(On Diff #31136)

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