diff --git a/background.html b/background.html index 383c15e0938..c26bdca2d9e 100644 --- a/background.html +++ b/background.html @@ -1,15 +1,15 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/ByteBuffer.min.js b/js-deps/ByteBuffer.min.js similarity index 100% rename from ByteBuffer.min.js rename to js-deps/ByteBuffer.min.js diff --git a/Long.min.js b/js-deps/Long.min.js similarity index 100% rename from Long.min.js rename to js-deps/Long.min.js diff --git a/ProtoBuf.min.js b/js-deps/ProtoBuf.min.js similarity index 100% rename from ProtoBuf.min.js rename to js-deps/ProtoBuf.min.js diff --git a/aes.js b/js-deps/aes.js similarity index 100% rename from aes.js rename to js-deps/aes.js diff --git a/hmac-sha256.js b/js-deps/hmac-sha256.js similarity index 100% rename from hmac-sha256.js rename to js-deps/hmac-sha256.js diff --git a/jquery.atmosphere.js b/js-deps/jquery.atmosphere.js similarity index 100% rename from jquery.atmosphere.js rename to js-deps/jquery.atmosphere.js diff --git a/jquery.js b/js-deps/jquery.js similarity index 100% rename from jquery.js rename to js-deps/jquery.js diff --git a/lib-typedarrays.js b/js-deps/lib-typedarrays.js similarity index 100% rename from lib-typedarrays.js rename to js-deps/lib-typedarrays.js diff --git a/background.js b/js/background.js similarity index 100% rename from background.js rename to js/background.js diff --git a/helpers.js b/js/helpers.js similarity index 97% rename from helpers.js rename to js/helpers.js index adb655d53f8..af0f7b9ff23 100644 --- a/helpers.js +++ b/js/helpers.js @@ -58,27 +58,27 @@ function base64ToUint8Array(string) { // Protobuf decodingA //TODO: throw on missing fields everywhere -var IncomingPushMessageProtobuf = dcodeIO.ProtoBuf.loadProtoFile("IncomingPushMessageSignal.proto").build("textsecure.IncomingPushMessageSignal"); +var IncomingPushMessageProtobuf = dcodeIO.ProtoBuf.loadProtoFile("protos/IncomingPushMessageSignal.proto").build("textsecure.IncomingPushMessageSignal"); function decodeIncomingPushMessageProtobuf(string) { return IncomingPushMessageProtobuf.decode(btoa(string)); } -var PushMessageContentProtobuf = dcodeIO.ProtoBuf.loadProtoFile("IncomingPushMessageSignal.proto").build("textsecure.PushMessageContent"); +var PushMessageContentProtobuf = dcodeIO.ProtoBuf.loadProtoFile("protos/IncomingPushMessageSignal.proto").build("textsecure.PushMessageContent"); function decodePushMessageContentProtobuf(string) { return PushMessageContentProtobuf.decode(btoa(string)); } -var WhisperMessageProtobuf = dcodeIO.ProtoBuf.loadProtoFile("WhisperTextProtocol.proto").build("textsecure.WhisperMessage"); +var WhisperMessageProtobuf = dcodeIO.ProtoBuf.loadProtoFile("protos/WhisperTextProtocol.proto").build("textsecure.WhisperMessage"); function decodeWhisperMessageProtobuf(string) { return WhisperMessageProtobuf.decode(btoa(string)); } -var PreKeyWhisperMessageProtobuf = dcodeIO.ProtoBuf.loadProtoFile("WhisperTextProtocol.proto").build("textsecure.PreKeyWhisperMessage"); +var PreKeyWhisperMessageProtobuf = dcodeIO.ProtoBuf.loadProtoFile("protos/WhisperTextProtocol.proto").build("textsecure.PreKeyWhisperMessage"); function decodePreKeyWhisperMessageProtobuf(string) { return PreKeyWhisperMessageProtobuf.decode(btoa(string)); } -var KeyExchangeMessageProtobuf = dcodeIO.ProtoBuf.loadProtoFile("WhisperTextProtocol.proto").build("textsecure.KeyExchangeMessage"); +var KeyExchangeMessageProtobuf = dcodeIO.ProtoBuf.loadProtoFile("protos/WhisperTextProtocol.proto").build("textsecure.KeyExchangeMessage"); function decodeKeyExchangeMessageProtobuf(string) { return KeyExchangeMessageProtobuf.decode(btoa(string)); } @@ -256,6 +256,10 @@ function getRandomBytes(size) { (function(crypto, $, undefined) { var createNewKeyPair = function() { //TODO + var privKey = getRandomBytes(32); + privKey[0] &= 248; + privKey[31] &= 127; + privKey[31] |= 64; var pubKey = "BRTJzsHPUWRRBxyo5MoaBRidMk2fwDlfqvU91b6pzbED"; var privKey = ""; return { pubKey: pubKey, privKey: privKey }; @@ -264,7 +268,7 @@ function getRandomBytes(size) { var crypto_storage = {}; crypto_storage.getNewPubKeySTORINGPrivKey = function(keyName) { - var keyPair = crypto._createNewKeyPair(); + var keyPair = createNewKeyPair(); storage.putEncrypted("25519Key" + keyName, keyPair); return keyPair.pubKey; } @@ -393,7 +397,7 @@ function getRandomBytes(size) { var masterKey = HKDF(ECDHE(remoteKey, ratchet.ephemeralKeyPair.privKey), ratchet.rootKey, "WhisperRatchet"); session[remoteKey] = { messageKeys: {}, chainKey: { counter: 0, key: masterKey.substring(32, 64) } }; - ratchet.ephemeralKeyPair = _createNewKeyPair(); + ratchet.ephemeralKeyPair = createNewKeyPair(); masterKey = HKDF(ECDHE(remoteKey, ratchet.ephemeralKeyPair.privKey), masterKey.substring(0, 32), "WhisperRatchet"); ratchet.rootKey = masterKey.substring(0, 32); session[nextRatchet.ephemeralKeyPair.pubKey] = { messageKeys: {}, chainKey: { counter: 0, key: masterKey.substring(32, 64) } }; diff --git a/options.js b/js/options.js similarity index 100% rename from options.js rename to js/options.js diff --git a/popup.js b/js/popup.js similarity index 100% rename from popup.js rename to js/popup.js diff --git a/test.js b/js/test.js similarity index 100% rename from test.js rename to js/test.js diff --git a/manifest.json b/manifest.json index 2fbafa2dd8a..69b483637b2 100644 --- a/manifest.json +++ b/manifest.json @@ -16,8 +16,8 @@ }, "background": { - "scripts": [ "jquery.js", "jquery.atmosphere.js", "aes.js", "hmac-sha256.js", "lib-typedarrays.js", - "Long.min.js", "ByteBuffer.min.js", "ProtoBuf.min.js", "helpers.js", "background.js" ] + "scripts": [ "js-deps/jquery.js", "js-deps/jquery.atmosphere.js", "js-deps/aes.js", "js-deps/hmac-sha256.js", "js-deps/lib-typedarrays.js", + "js-deps/Long.min.js", "js-deps/ByteBuffer.min.js", "js-deps/ProtoBuf.min.js", "js/helpers.js", "js/background.js" ] }, "options_page": "options.html" diff --git a/options.html b/options.html index 9252af09b5e..d655c911835 100644 --- a/options.html +++ b/options.html @@ -22,15 +22,15 @@

You are now registered on TextSecure with number

- - - - - - - - - - + + + + + + + + + + diff --git a/popup.html b/popup.html index 5acbefbd554..b367f6eb9e4 100644 --- a/popup.html +++ b/popup.html @@ -10,15 +10,15 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/IncomingPushMessageSignal.proto b/protos/IncomingPushMessageSignal.proto similarity index 100% rename from IncomingPushMessageSignal.proto rename to protos/IncomingPushMessageSignal.proto diff --git a/WhisperTextProtocol.proto b/protos/WhisperTextProtocol.proto similarity index 100% rename from WhisperTextProtocol.proto rename to protos/WhisperTextProtocol.proto diff --git a/test.html b/test.html index 467326db14f..841cfbc0f0d 100644 --- a/test.html +++ b/test.html @@ -8,14 +8,14 @@ - - - - - - - - - - + + + + + + + + + +