Generate RSA keypairs when the client starts
This commit is contained in:
parent
70e8981eb4
commit
9a46c1ef04
3 changed files with 12 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
|||
<script src="UnitJS/dom.js"></script>
|
||||
<script src="translations.js"></script>
|
||||
<script src="i18n.js"></script>
|
||||
<script src="lib/jsencrypt.min.js"></script>
|
||||
<script src="fun.js"></script>
|
||||
<script src="screen.js"></script>
|
||||
<script src="messaging.js"></script>
|
||||
|
|
1
www/lib/jsencrypt.min.js
vendored
Normal file
1
www/lib/jsencrypt.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,7 @@
|
|||
function Session(modules) {
|
||||
var key = null;
|
||||
var name = null;
|
||||
var keys = JSON.parse(localStorage.getItem('keys')) || generateKeyPair();
|
||||
|
||||
modules.messaging.addEventListener(["Welcome"], function(o) {
|
||||
key = o.key;
|
||||
|
@ -29,4 +30,13 @@ function Session(modules) {
|
|||
function loggedIn() {
|
||||
return name != undefined;
|
||||
}
|
||||
|
||||
function generateKeyPair() {
|
||||
var crypt = new JSEncrypt({default_key_size: 1024});
|
||||
crypt.getKey();
|
||||
return {
|
||||
priv: crypt.getPrivateKey(),
|
||||
pub: crypt.getPublicKey()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue