Simplify sticker upload

This commit is contained in:
Fedor Indutny 2022-12-15 13:47:38 -08:00 committed by GitHub
parent 47b0ee6135
commit d608b81292
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 17 deletions

View file

@ -455,8 +455,7 @@ export function decryptAttachment(
export function encryptAttachment(
plaintext: Uint8Array,
keys: Uint8Array,
iv: Uint8Array
keys: Uint8Array
): EncryptedAttachment {
if (!(plaintext instanceof Uint8Array)) {
throw new TypeError(
@ -467,9 +466,7 @@ export function encryptAttachment(
if (keys.byteLength !== 64) {
throw new Error('Got invalid length attachment keys');
}
if (iv.byteLength !== 16) {
throw new Error('Got invalid length attachment iv');
}
const iv = getRandomBytes(16);
const aesKey = keys.slice(0, 32);
const macKey = keys.slice(32, 64);