Only mention generation of key if it's actually happening.
This commit is contained in:
parent
4c1e0564f8
commit
2f7524f14f
75
converse.js
75
converse.js
@ -295,7 +295,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getPrivateKey: function () {
|
getPrivateKey: function (callback) {
|
||||||
var savedKey = this.get('priv_key');
|
var savedKey = this.get('priv_key');
|
||||||
var passCheck = this.get('pass_check');
|
var passCheck = this.get('pass_check');
|
||||||
var cipher = crypto.lib.PasswordBasedCipher;
|
var cipher = crypto.lib.PasswordBasedCipher;
|
||||||
@ -306,16 +306,20 @@
|
|||||||
myKey = otr.DSA.parsePrivate(decrypted.toString(crypto.enc.Latin1));
|
myKey = otr.DSA.parsePrivate(decrypted.toString(crypto.enc.Latin1));
|
||||||
if (cipher.decrypt(crypto.algo.AES, passCheck, pass).toString(crypto.enc.Latin1) === 'match') {
|
if (cipher.decrypt(crypto.algo.AES, passCheck, pass).toString(crypto.enc.Latin1) === 'match') {
|
||||||
// Verified that the user's password is still the same
|
// Verified that the user's password is still the same
|
||||||
return myKey;
|
return callback(myKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Couldn't get stored key, generate a new one.
|
this.trigger('showHelpMessages', [__('Please wait, generating private key...')]);
|
||||||
myKey = new otr.DSA();
|
setTimeout($.proxy(function () {
|
||||||
this.save({
|
// Couldn't get stored key, generate a new one.
|
||||||
'priv_key': cipher.encrypt(crypto.algo.AES, myKey.packPrivate(), pass).toString(),
|
myKey = new otr.DSA();
|
||||||
'pass_check': cipher.encrypt(crypto.algo.AES, 'match', pass).toString()
|
this.trigger('showHelpMessages', [__('Private key generated.')]);
|
||||||
});
|
this.save({
|
||||||
return myKey;
|
'priv_key': cipher.encrypt(crypto.algo.AES, myKey.packPrivate(), pass).toString(),
|
||||||
|
'pass_check': cipher.encrypt(crypto.algo.AES, 'match', pass).toString()
|
||||||
|
});
|
||||||
|
return callback(myKey);
|
||||||
|
}, this));
|
||||||
},
|
},
|
||||||
|
|
||||||
updateOTRStatus: function (state) {
|
updateOTRStatus: function (state) {
|
||||||
@ -358,25 +362,27 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
initiateOTR: function () {
|
initiateOTR: function () {
|
||||||
this.otr = new otr.OTR({
|
this.getPrivateKey($.proxy(function (key) {
|
||||||
fragment_size: 140,
|
this.otr = new otr.OTR({
|
||||||
send_interval: 200,
|
fragment_size: 140,
|
||||||
priv: this.getPrivateKey(),
|
send_interval: 200,
|
||||||
debug: this.debug
|
priv: key,
|
||||||
});
|
debug: this.debug
|
||||||
this.otr.on('status', $.proxy(this.updateOTRStatus, this));
|
});
|
||||||
this.otr.on('smp', $.proxy(this.onSMP, this));
|
this.otr.on('status', $.proxy(this.updateOTRStatus, this));
|
||||||
|
this.otr.on('smp', $.proxy(this.onSMP, this));
|
||||||
|
|
||||||
this.otr.on('ui', $.proxy(function (msg) {
|
this.otr.on('ui', $.proxy(function (msg) {
|
||||||
this.trigger('showReceivedOTRMessage', msg);
|
this.trigger('showReceivedOTRMessage', msg);
|
||||||
|
}, this));
|
||||||
|
this.otr.on('io', $.proxy(function (msg) {
|
||||||
|
this.trigger('sendMessageStanza', msg);
|
||||||
|
}, this));
|
||||||
|
this.otr.on('error', $.proxy(function (msg) {
|
||||||
|
this.trigger('showOTRError', msg);
|
||||||
|
}, this));
|
||||||
|
this.otr.sendQueryMsg();
|
||||||
}, this));
|
}, this));
|
||||||
this.otr.on('io', $.proxy(function (msg) {
|
|
||||||
this.trigger('sendMessageStanza', msg);
|
|
||||||
}, this));
|
|
||||||
this.otr.on('error', $.proxy(function (msg) {
|
|
||||||
this.trigger('showOTRError', msg);
|
|
||||||
}, this));
|
|
||||||
this.otr.sendQueryMsg();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
createMessage: function (message) {
|
createMessage: function (message) {
|
||||||
@ -707,7 +713,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (match[1] === "otr") {
|
else if (match[1] === "otr") {
|
||||||
this.startOTR();
|
this.model.initiateOTR();
|
||||||
return;
|
return;
|
||||||
} else if (match[1] === "endotr") {
|
} else if (match[1] === "endotr") {
|
||||||
if (this.model.otr) {
|
if (this.model.otr) {
|
||||||
@ -792,26 +798,15 @@
|
|||||||
console.log("OTR ERROR:"+msg);
|
console.log("OTR ERROR:"+msg);
|
||||||
},
|
},
|
||||||
|
|
||||||
startOTR: function () {
|
|
||||||
// TODO: this should probably only be shown when a private key
|
|
||||||
// is really being generated. Would have to be via triggered
|
|
||||||
// event.
|
|
||||||
this.showHelpMessages([__('Hold on, generating a private key.')]);
|
|
||||||
setTimeout($.proxy(function () {
|
|
||||||
this.model.initiateOTR();
|
|
||||||
this.showHelpMessages([__('Private key generated.')]);
|
|
||||||
}, this));
|
|
||||||
},
|
|
||||||
|
|
||||||
buddyStartsOTR: function (ev) {
|
buddyStartsOTR: function (ev) {
|
||||||
this.showHelpMessages([__('This user has requested an encrypted session.')]);
|
this.showHelpMessages([__('This user has requested an encrypted session.')]);
|
||||||
this.startOTR();
|
this.model.initiateOTR();
|
||||||
},
|
},
|
||||||
|
|
||||||
startOTRFromToolbar: function (ev) {
|
startOTRFromToolbar: function (ev) {
|
||||||
$(ev.target).parent().parent().slideUp();
|
$(ev.target).parent().parent().slideUp();
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
this.startOTR();
|
this.model.initiateOTR();
|
||||||
},
|
},
|
||||||
|
|
||||||
endOTR: function (ev) {
|
endOTR: function (ev) {
|
||||||
|
Loading…
Reference in New Issue
Block a user