remove unused crypto marking us as coinminer

hopefully
pull/1671/head
Audric Ackermann 3 years ago
parent c45dc5876e
commit d6b7463f5f
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -30,9 +30,7 @@
"node_modules/mustache/mustache.js",
"node_modules/underscore/underscore.js",
"node_modules/backbone/backbone.js",
"components/indexeddb-backbonejs-adapter/**/*.js",
"components/qrcode/**/*.js",
"components/multibase/dist/index.js"
"components/indexeddb-backbonejs-adapter/**/*.js"
],
"libtextsecure": [
"node_modules/long/dist/long.js",
@ -40,8 +38,7 @@
],
"libloki": [
"node_modules/long/dist/long.js",
"components/JSBI/dist/jsbi.mjs",
"components/multibase/dist/index.js"
"components/JSBI/dist/jsbi.mjs"
]
}
}

File diff suppressed because it is too large Load Diff

@ -1,15 +1,8 @@
export interface CryptoInterface {
DHDecrypt: any;
DHEncrypt: any;
DecryptAESGCM: (symmetricKey: ArrayBuffer, ivAndCiphertext: ArrayBuffer) => Promise<ArrayBuffer>; // AES-GCM
deriveSymmetricKey: (pubkey: ArrayBuffer, seckey: ArrayBuffer) => Promise<ArrayBuffer>;
EncryptAESGCM: any; // AES-GCM
_decodeSnodeAddressToPubKey: any;
decryptToken: any;
encryptForPubkey: (
publicKey: string,
data: Uint8Array
) => Promise<{ ciphertext: Uint8Array; symmetricKey: ArrayBuffer; ephemeralKey: ArrayBuffer }>;
generateEphemeralKeyPair: any;
sha512: any;
}

@ -2,11 +2,9 @@
window,
libsignal,
StringView,
Multibase,
TextEncoder,
TextDecoder,
crypto,
dcodeIO,
libloki
*/
@ -14,18 +12,8 @@
(function() {
window.libloki = window.libloki || {};
const IV_LENGTH = 16;
const NONCE_LENGTH = 12;
async function DHEncrypt(symmetricKey, plainText) {
const iv = libsignal.crypto.getRandomBytes(IV_LENGTH);
const ciphertext = await libsignal.crypto.encrypt(symmetricKey, plainText, iv);
const ivAndCiphertext = new Uint8Array(iv.byteLength + ciphertext.byteLength);
ivAndCiphertext.set(new Uint8Array(iv));
ivAndCiphertext.set(new Uint8Array(ciphertext), iv.byteLength);
return ivAndCiphertext;
}
async function deriveSymmetricKey(x25519PublicKey, x25519PrivateKey) {
const ephemeralSecret = await libsignal.Curve.async.calculateAgreement(
x25519PublicKey,
@ -90,24 +78,6 @@
return crypto.subtle.decrypt({ name: 'AES-GCM', iv: nonce }, key, ciphertext);
}
async function DHDecrypt(symmetricKey, ivAndCiphertext) {
const iv = ivAndCiphertext.slice(0, IV_LENGTH);
const ciphertext = ivAndCiphertext.slice(IV_LENGTH);
return libsignal.crypto.decrypt(symmetricKey, ciphertext, iv);
}
const base32zIndex = Multibase.names.indexOf('base32z');
const base32zCode = Multibase.codes[base32zIndex];
function decodeSnodeAddressToPubKey(snodeAddress) {
const snodeAddressClean = snodeAddress
.replace('.snode', '')
.replace('https://', '')
.replace('http://', '');
return Multibase.decode(`${base32zCode}${snodeAddressClean}`);
}
async function generateEphemeralKeyPair() {
const keys = await libsignal.Curve.async.generateKeyPair();
// Signal protocol prepends with "0x05"
@ -115,40 +85,11 @@
return keys;
}
async function decryptToken({ cipherText64, serverPubKey64 }) {
const ivAndCiphertext = new Uint8Array(
dcodeIO.ByteBuffer.fromBase64(cipherText64).toArrayBuffer()
);
const serverPubKey = new Uint8Array(
dcodeIO.ByteBuffer.fromBase64(serverPubKey64).toArrayBuffer()
);
const item = await window.Signal.Data.getItemById('identityKey');
const keyPair = (item && item.value) || undefined;
if (!keyPair) {
throw new Error('Failed to get keypair for token decryption');
}
const { privKey } = keyPair;
const symmetricKey = await libsignal.Curve.async.calculateAgreement(serverPubKey, privKey);
const token = await DHDecrypt(symmetricKey, ivAndCiphertext);
const tokenString = dcodeIO.ByteBuffer.wrap(token).toString('utf8');
return tokenString;
}
const sha512 = data => crypto.subtle.digest('SHA-512', data);
window.libloki.crypto = {
DHEncrypt,
EncryptAESGCM, // AES-GCM
DHDecrypt,
DecryptAESGCM, // AES-GCM
decryptToken,
deriveSymmetricKey,
generateEphemeralKeyPair,
encryptForPubkey,
_decodeSnodeAddressToPubKey: decodeSnodeAddressToPubKey,
sha512,
};
})();

@ -26,7 +26,6 @@ export type KeyPair = {
interface CurveSync {
generateKeyPair(): KeyPair;
createKeyPair(privKey: ArrayBuffer): KeyPair;
calculateAgreement(pubKey: ArrayBuffer, privKey: ArrayBuffer): ArrayBuffer;
verifySignature(pubKey: ArrayBuffer, msg: ArrayBuffer, sig: ArrayBuffer): void;
calculateSignature(privKey: ArrayBuffer, message: ArrayBuffer): ArrayBuffer;
validatePubKeyFormat(pubKey: ArrayBuffer): ArrayBuffer;
@ -35,7 +34,6 @@ interface CurveSync {
interface CurveAsync {
generateKeyPair(): Promise<KeyPair>;
createKeyPair(privKey: ArrayBuffer): Promise<KeyPair>;
calculateAgreement(pubKey: ArrayBuffer, privKey: ArrayBuffer): Promise<ArrayBuffer>;
verifySignature(pubKey: ArrayBuffer, msg: ArrayBuffer, sig: ArrayBuffer): Promise<void>;
calculateSignature(privKey: ArrayBuffer, message: ArrayBuffer): Promise<ArrayBuffer>;
validatePubKeyFormat(pubKey: ArrayBuffer): Promise<ArrayBuffer>;

@ -41,7 +41,7 @@ import { forceRefreshRandomSnodePool } from '../../session/snode_api/snodePool';
import { SwarmPolling } from '../../session/snode_api/swarmPolling';
import { IMAGE_JPEG } from '../../types/MIME';
import { FSv2 } from '../../fileserver';
import { debounce } from 'underscore';
import { debounce } from 'lodash';
import { DURATION } from '../../session/constants';
// tslint:disable-next-line: no-import-side-effect no-submodule-imports

@ -1,4 +1,4 @@
import _ from 'underscore';
import _ from 'lodash';
import { FileServerV2Request } from '../../fileserver/FileServerApiV2';
import { PubKey } from '../../session/types';
import { allowOnlyOneAtATime } from '../../session/utils/Promise';

1
ts/window.d.ts vendored

@ -9,7 +9,6 @@ import { LibTextsecure } from '../libtextsecure';
import { ConfirmationDialogParams } from '../background';
import { ConversationControllerType } from '../js/ConversationController';
import { any } from 'underscore';
import { Store } from 'redux';
import { MessageController } from './session/messages/MessageController';
import { DefaultTheme } from 'styled-components';

Loading…
Cancel
Save