diff --git a/sticker-creator/window/phase3-sticker-functions.ts b/sticker-creator/window/phase3-sticker-functions.ts index 5c678de73..e1b0ed0ea 100644 --- a/sticker-creator/window/phase3-sticker-functions.ts +++ b/sticker-creator/window/phase3-sticker-functions.ts @@ -207,7 +207,6 @@ window.encryptAndUpload = async ( const packKey = getRandomBytes(32); const encryptionKey = deriveStickerPackKey(packKey); - const iv = getRandomBytes(16); const server = WebAPI.connect({ username, @@ -259,15 +258,14 @@ window.encryptAndUpload = async ( const encryptedManifest = await encrypt( Proto.StickerPack.encode(manifestProto).finish(), - encryptionKey, - iv + encryptionKey ); const encryptedStickers = uniqueStickers.map(({ imageData }) => { if (!imageData?.buffer) { throw new Error('encryptStickers: Missing image data on sticker'); } - return encrypt(imageData.buffer, encryptionKey, iv); + return encrypt(imageData.buffer, encryptionKey); }); const packId = await server.putStickers( @@ -283,12 +281,8 @@ window.encryptAndUpload = async ( return { packId, key: hexKey }; }; -function encrypt( - data: Uint8Array, - key: Uint8Array, - iv: Uint8Array -): Uint8Array { - const { ciphertext } = encryptAttachment(data, key, iv); +function encrypt(data: Uint8Array, key: Uint8Array): Uint8Array { + const { ciphertext } = encryptAttachment(data, key); return ciphertext; } diff --git a/ts/Crypto.ts b/ts/Crypto.ts index 0214b843f..fb43fd37d 100644 --- a/ts/Crypto.ts +++ b/ts/Crypto.ts @@ -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); diff --git a/ts/textsecure/SendMessage.ts b/ts/textsecure/SendMessage.ts index 708ba3f44..7671bc08c 100644 --- a/ts/textsecure/SendMessage.ts +++ b/ts/textsecure/SendMessage.ts @@ -700,9 +700,8 @@ export default class MessageSender { const padded = this.getPaddedAttachment(data); const key = getRandomBytes(64); - const iv = getRandomBytes(16); - const result = encryptAttachment(padded, key, iv); + const result = encryptAttachment(padded, key); const id = await this.server.putAttachment(result.ciphertext); const proto = new Proto.AttachmentPointer();