Skip to content

Commit

Permalink
Fix sticker creator
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny-signal committed Oct 6, 2021
1 parent 7c9b8e9 commit 4fefd3c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions sticker-creator/preload.js
Expand Up @@ -13,7 +13,12 @@ const pMap = require('p-map');
// It is important to call this as early as possible
require('../ts/windows/context');

const { deriveStickerPackKey } = require('../ts/Crypto');
const {
deriveStickerPackKey,
encryptAttachment,
getRandomBytes,
} = require('../ts/Crypto');
const Bytes = require('../ts/Bytes');
const { SignalService: Proto } = require('../ts/protobuf');
const {
getEnvironment,
Expand Down Expand Up @@ -190,9 +195,9 @@ window.encryptAndUpload = async (
const { value: oldUsername } = oldUsernameItem;
const { value: password } = passwordItem;

const packKey = window.Signal.Crypto.getRandomBytes(32);
const packKey = getRandomBytes(32);
const encryptionKey = deriveStickerPackKey(packKey);
const iv = window.Signal.Crypto.getRandomBytes(16);
const iv = getRandomBytes(16);

const server = WebAPI.connect({
username: username || oldUsername,
Expand Down Expand Up @@ -241,19 +246,15 @@ window.encryptAndUpload = async (
onProgress
);

const hexKey = window.Signal.Crypto.hexFromBytes(packKey);
const hexKey = Bytes.toHex(packKey);

ipc.send('install-sticker-pack', packId, hexKey);

return { packId, key: hexKey };
};

async function encrypt(data, key, iv) {
const { ciphertext } = await window.textsecure.crypto.encryptAttachment(
data,
key,
iv
);
const { ciphertext } = await encryptAttachment(data, key, iv);

return ciphertext;
}
Expand Down

0 comments on commit 4fefd3c

Please sign in to comment.