comparison scripts/minifier/otr/dsa-webworker.js @ 12:1596660ddf72

Add minifier script for otr.js and its dependencies
author souliane <souliane@mailoo.org>
date Wed, 03 Sep 2014 19:38:05 +0200
parents
children
comparison
equal deleted inserted replaced
11:4920c8da790b 12:1596660ddf72
1 ;(function (root) {
2 "use strict";
3
4 root.OTR = {}
5 root.DSA = {}
6 root.crypto = {
7 randomBytes: function () {
8 throw new Error("Haven't seeded yet.")
9 }
10 }
11
12 // default imports
13 var imports = [
14 'vendor/salsa20.js'
15 , 'vendor/bigint.js'
16 , 'vendor/crypto.js'
17 , 'vendor/eventemitter.js'
18 , 'lib/const.js'
19 , 'lib/helpers.js'
20 , 'lib/dsa.js'
21 ]
22
23 function sendMsg(type, val) {
24 postMessage({ type: type, val: val })
25 }
26
27 onmessage = function (e) {
28 var data = e.data;
29
30 if (data.imports) imports = data.imports
31 importScripts.apply(root, imports);
32
33 // use salsa20 since there's no prng in webworkers
34 var state = new root.Salsa20(data.seed.slice(0, 32), data.seed.slice(32))
35 root.crypto.randomBytes = function (n) {
36 return state.getBytes(n)
37 }
38
39 if (data.debug) sendMsg('debug', 'DSA key creation started')
40 var dsa
41 try {
42 dsa = new root.DSA()
43 } catch (e) {
44 if (data.debug) sendMsg('debug', e.toString())
45 return
46 }
47 if (data.debug) sendMsg('debug', 'DSA key creation finished')
48
49 sendMsg('data', dsa.packPrivate())
50 }
51
52 }(this))