This commit is contained in:
Jiiks 2018-08-14 11:02:29 +03:00
parent b1f0a4247a
commit 54e5f2149b
2 changed files with 10 additions and 3 deletions

View File

@ -31,6 +31,7 @@ export default new class E2EE extends BuiltinModule {
constructor() {
super();
window.nodecrypto = nodecrypto;
this.encryptNewMessages = true;
this.ecdhDate = START_DATE;
}
@ -117,7 +118,7 @@ export default new class E2EE extends BuiltinModule {
try {
const secret = Security.computeECDHSecret(this.ecdhStorage[dmChannelID], otherKey);
delete this.ecdhStorage[dmChannelID];
return Security.sha256(secret);
return Security.hash('sha384', secret, 'hex');
} catch (e) {
throw e;
}

View File

@ -80,8 +80,14 @@ export default class Security {
});
}
static createECDH() {
return nodecrypto.createECDH('secp521r1');
static createECDH(curve = 'secp384r1') {
return nodecrypto.createECDH(curve);
}
static hash(algorithm, data, encoding) {
const hash = nodecrypto.createHash(algorithm);
hash.update(data);
return hash.digest(encoding);
}
static sha256(text) {