diff --git a/firefox_addon/lib/main.js b/firefox_addon/lib/main.js index 7d28a47..8953d5e 100644 --- a/firefox_addon/lib/main.js +++ b/firefox_addon/lib/main.js @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Grégory Soutadé + Copyright (C) 2013-2014 Grégory Soutadé This file is part of gPass. @@ -26,7 +26,7 @@ var pkdbf2 = require("pkdbf2").pkdbf2; var aes = require("jsaes").aes; var parseURI = require("parseuri").parseURI; var prefSet = require("simple-prefs"); -var DEBUG = false; +var DEBUG = true; // http://stackoverflow.com/questions/3745666/how-to-convert-from-hex-to-ascii-in-javascript @@ -54,6 +54,26 @@ function debug(s) console.log(s); } +function wildcard_domain(domain) +{ + parts = domain.split("."); + + if (parts.length >= 3) + { + // Seems to be a two level root domain (ie zzz.xxx.co.uk ...) + if (parts[parts.length-2].lenght <= 3) + { + if (parts.length > 3) + return "*" + "." + parts[parts.length-3] + "." + parts[parts.length-2] + "." + parts[parts.length-1]; + } + // Standard root domain (zzz.xxx.com) + else + return "*" + "." + parts[parts.length-2] + "." + parts[parts.length-1]; + } + + return ""; +} + function on_sumbit(e) { var form = this; @@ -62,6 +82,7 @@ function on_sumbit(e) domain = parseURI.parseUri(form.ownerDocument.baseURI); domain = domain["host"]; + wdomain = wildcard_domain(domain); salt = parseURI.parseUri(prefSet.prefs["account_url"]); salt = salt["host"] + salt["path"]; @@ -116,6 +137,19 @@ function on_sumbit(e) keys += (keys.length != 0) ? "&" : ""; keys += "k" + a + "=" + a2hex(enc); + + if (wdomain != "") + { + v = "@@" + wdomain + ";" + logins[a]; + debug("will encrypt " + v); + debug("with " + a2hex(mkey)); + enc = aes.encryptLongString(v, aes.init(mkey)); + aes.finish(); + debug("res " + enc); + + keys += (keys.length != 0) ? "&" : ""; + keys += "k" + a + "=" + a2hex(enc); + } } debug(keys); diff --git a/firefox_addon/package.json b/firefox_addon/package.json index 3484a34..421370d 100644 --- a/firefox_addon/package.json +++ b/firefox_addon/package.json @@ -5,7 +5,7 @@ "description": "gPass : global password manager", "author": "Grégory Soutadé", "license": "GNU GPL v3", - "version": "0.1", + "version": "0.2", "preferences": [{ "name": "account_url", "title": "Account URL",