Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
2f7524f1
Commit
2f7524f1
authored
Aug 31, 2013
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only mention generation of key if it's actually happening.
parent
4c1e0564
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
40 deletions
+35
-40
converse.js
converse.js
+35
-40
No files found.
converse.js
View file @
2f7524f1
...
...
@@ -295,7 +295,7 @@
}
},
getPrivateKey
:
function
()
{
getPrivateKey
:
function
(
callback
)
{
var
savedKey
=
this
.
get
(
'
priv_key
'
);
var
passCheck
=
this
.
get
(
'
pass_check
'
);
var
cipher
=
crypto
.
lib
.
PasswordBasedCipher
;
...
...
@@ -306,16 +306,20 @@
myKey
=
otr
.
DSA
.
parsePrivate
(
decrypted
.
toString
(
crypto
.
enc
.
Latin1
));
if
(
cipher
.
decrypt
(
crypto
.
algo
.
AES
,
passCheck
,
pass
).
toString
(
crypto
.
enc
.
Latin1
)
===
'
match
'
)
{
// Verified that the user's password is still the same
return
myKey
;
return
callback
(
myKey
)
;
}
}
// Couldn't get stored key, generate a new one.
myKey
=
new
otr
.
DSA
();
this
.
save
({
'
priv_key
'
:
cipher
.
encrypt
(
crypto
.
algo
.
AES
,
myKey
.
packPrivate
(),
pass
).
toString
(),
'
pass_check
'
:
cipher
.
encrypt
(
crypto
.
algo
.
AES
,
'
match
'
,
pass
).
toString
()
});
return
myKey
;
this
.
trigger
(
'
showHelpMessages
'
,
[
__
(
'
Please wait, generating private key...
'
)]);
setTimeout
(
$
.
proxy
(
function
()
{
// Couldn't get stored key, generate a new one.
myKey
=
new
otr
.
DSA
();
this
.
trigger
(
'
showHelpMessages
'
,
[
__
(
'
Private key generated.
'
)]);
this
.
save
({
'
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
)
{
...
...
@@ -358,25 +362,27 @@
},
initiateOTR
:
function
()
{
this
.
otr
=
new
otr
.
OTR
({
fragment_size
:
140
,
send_interval
:
200
,
priv
:
this
.
getPrivateKey
(),
debug
:
this
.
debug
});
this
.
otr
.
on
(
'
status
'
,
$
.
proxy
(
this
.
updateOTRStatus
,
this
));
this
.
otr
.
on
(
'
smp
'
,
$
.
proxy
(
this
.
onSMP
,
this
));
this
.
getPrivateKey
(
$
.
proxy
(
function
(
key
)
{
this
.
otr
=
new
otr
.
OTR
({
fragment_size
:
140
,
send_interval
:
200
,
priv
:
key
,
debug
:
this
.
debug
});
this
.
otr
.
on
(
'
status
'
,
$
.
proxy
(
this
.
updateOTRStatus
,
this
));
this
.
otr
.
on
(
'
smp
'
,
$
.
proxy
(
this
.
onSMP
,
this
));
this
.
otr
.
on
(
'
ui
'
,
$
.
proxy
(
function
(
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
.
otr
.
on
(
'
ui
'
,
$
.
proxy
(
function
(
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
.
otr
.
sendQueryMsg
();
},
createMessage
:
function
(
message
)
{
...
...
@@ -707,7 +713,7 @@
return
;
}
else
if
(
match
[
1
]
===
"
otr
"
)
{
this
.
start
OTR
();
this
.
model
.
initiate
OTR
();
return
;
}
else
if
(
match
[
1
]
===
"
endotr
"
)
{
if
(
this
.
model
.
otr
)
{
...
...
@@ -792,26 +798,15 @@
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
)
{
this
.
showHelpMessages
([
__
(
'
This user has requested an encrypted session.
'
)]);
this
.
start
OTR
();
this
.
model
.
initiate
OTR
();
},
startOTRFromToolbar
:
function
(
ev
)
{
$
(
ev
.
target
).
parent
().
parent
().
slideUp
();
ev
.
stopPropagation
();
this
.
start
OTR
();
this
.
model
.
initiate
OTR
();
},
endOTR
:
function
(
ev
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment