Block URL request if masterkey is present in parameters

This commit is contained in:
2017-07-08 08:43:26 +02:00
parent 7a7d2fd724
commit e341963675
6 changed files with 176 additions and 13 deletions
+15 -6
View File
@@ -29,6 +29,12 @@ function notify(text, data)
browser.runtime.sendMessage({type: "notification", options:{"message":text}});
}
function block_url(url)
{
debug("Block URL " + url);
browser.runtime.sendMessage({type: "block_url", options:{"url":url}});
}
// https://stackoverflow.com/questions/6965107/converting-between-strings-and-arraybuffers
function ab2str(buf) {
return String.fromCharCode.apply(null, new Uint8Array(buf));
@@ -119,9 +125,6 @@ function _encrypt(mkey, iv, data)
while ((data.length % 16))
data += "\0";
debug("Encrypt " + data);
debug("Encrypt " + iv.length);
data = str2ab(data);
promise = mkey.then(function(mkey){
@@ -148,8 +151,6 @@ async function _decrypt(mkey, iv, data)
pkcs7_padding = new Uint8Array([16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16]);
pkcs7_padding = await _encrypt(mkey, nulliv, ab2str(pkcs7_padding));
debug("Decrypt " + data);
data = str2ab(data + pkcs7_padding);
nulliv = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
@@ -173,6 +174,8 @@ async function encrypt_ecb(mkey, data)
{
var result = "";
console.log("Encrypt ECB " + data);
nulliv = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
while (data.length > 16)
@@ -191,6 +194,8 @@ async function encrypt_ecb(mkey, data)
async function decrypt_ecb(mkey, data)
{
var result = "";
console.log("Decrypt ECB " + data);
nulliv = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
@@ -208,7 +213,9 @@ async function decrypt_ecb(mkey, data)
}
async function encrypt_cbc(mkey, iv, data)
{
{
console.log("Encrypt CBC " + data);
var result = await _encrypt(mkey, str2ab(iv), data);
// Remove PKCS7 padding
@@ -217,6 +224,8 @@ async function encrypt_cbc(mkey, iv, data)
async function decrypt_cbc(mkey, iv, data)
{
console.log("Decrypt CBC " + data);
var result = await _decrypt(mkey, str2ab(iv), data);
// Remove PKCS7 padding