HomePhabricator
Diffusion Comm 9a08fd6f2883

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

Description

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

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'
}

Reviewers: atul, varun, bartek, ginsu

Reviewed By: varun

Subscribers: ashoat, tomek, bartek

Differential Revision: https://phab.comm.dev/D9202