remove unnecessary files and update README
This commit is contained in:
parent
1cec81d576
commit
7d8bf90c32
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -6,3 +6,7 @@ npm*
|
|||
test/lib/
|
||||
resources/keyring_nodebug.js
|
||||
resources/openpgp_nodebug.js
|
||||
resources/keyring.js
|
||||
resources/keyring.min.js
|
||||
resources/openpgp.js
|
||||
resources/openpgp.min.js
|
||||
|
|
11
README.md
11
README.md
|
@ -1,10 +1,15 @@
|
|||
[](http://travis-ci.org/openpgpjs/openpgpjs)
|
||||
OpenPGP.js [](http://travis-ci.org/openpgpjs/openpgpjs)
|
||||
==========
|
||||
|
||||
# What is OpenPGP.js?
|
||||
[OpenPGP.js](http://openpgpjs.org/) is a Javascript implementation of the OpenPGP protocol. This is defined in [RFC 4880](http://tools.ietf.org/html/rfc4880).
|
||||
|
||||
# How do I use it?
|
||||
As a developer, the best place to start is in the `resources/` directory. Within this you will find a basic example implementation and the "binary" files for this library. It is likely that you will want to use `resources/openpgp.min.js` on your site, this is a minified version of our library.
|
||||
To build the library, download a tagged version from [releases](https://github.com/openpgpjs/openpgpjs/releases) and the build the library like so:
|
||||
|
||||
npm install && grunt
|
||||
|
||||
Then take the use the minified file from `resources/openpgp.min.js` and use it in your project.
|
||||
|
||||
# I need some help
|
||||
## Mailing List
|
||||
|
@ -15,7 +20,7 @@ A jsdoc build of our code comments is available at [doc/index.html](doc/index.ht
|
|||
|
||||
# How do I get involved?
|
||||
You want to help, great! Go ahead and fork our repo, make your changes
|
||||
and make a pull request. **For any significant changes, use the "devel" branch. This will eventually be merged into the current master.** Please be sure that you run `make minify` from the root directory to concatenate and minify the library into the `resources/` directory.
|
||||
and make a pull request.
|
||||
|
||||
It is extra awesome if you write tests for the code you change. Our test coverage is relatively weak, so if you can add cases that is great.
|
||||
|
||||
|
|
|
@ -1,133 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript">
|
||||
//GPG4Browsers - An OpenPGP implementation in javascript
|
||||
//Copyright (C) 2011 Recurity Labs GmbH
|
||||
//
|
||||
//This library is free software; you can redistribute it and/or
|
||||
//modify it under the terms of the GNU Lesser General Public
|
||||
//License as published by the Free Software Foundation; either
|
||||
//version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
//This library is distributed in the hope that it will be useful,
|
||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
//Lesser General Public License for more details.
|
||||
//
|
||||
//You should have received a copy of the GNU Lesser General Public
|
||||
//License along with this library; if not, write to the Free Software
|
||||
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
var tab_registry = new Array();
|
||||
|
||||
var account_name = null;
|
||||
|
||||
/**
|
||||
* Event listener for chrom.extension message interface.
|
||||
* This is the main data exchange interface for communication between windows.
|
||||
*/
|
||||
function onRequest(request, sender, sendResponse) {
|
||||
// only the extension itself
|
||||
if (document.URL.split("/")[2] != sender.id)
|
||||
return;
|
||||
|
||||
/* the following code is currently not working, but a check for incognito mode would be nice to have here.
|
||||
|
||||
if (chrome.extension.inIncognitoContext != true)
|
||||
alert("enable incognito mode for GPG4Browsers Extension!"+JSON.stringify(chrome.extension.inIncognitoContext));
|
||||
*/
|
||||
|
||||
|
||||
// Show the page action for the tab that the sender (content script)
|
||||
// was on.
|
||||
if (tab_registry[sender.tab.id] != null) {
|
||||
|
||||
sendResponse(tab_registry[sender.tab.id]);
|
||||
tab_registry[sender.tab.id] = null;
|
||||
return;
|
||||
}
|
||||
// page action... open the pgp tab with compose
|
||||
if (request.action == 0) {
|
||||
openComposeWindow(request);
|
||||
sendResponse({});
|
||||
return;
|
||||
}
|
||||
// request from contentscript on gmail interface to open a openpgp window with a message to decrypt/verify
|
||||
if (request.action == 1) {
|
||||
openComposeWindow(request);
|
||||
sendResponse({});
|
||||
return;
|
||||
}
|
||||
|
||||
// openpgp is requesting to open a gmail compose window
|
||||
if (request.action == 2 && sender.tab.id) {
|
||||
openGmailComposeWindow(request);
|
||||
sendResponse({});
|
||||
return;
|
||||
}
|
||||
// contentscript on gmail compose window requesting the message
|
||||
// not used due to missing implemenation
|
||||
if (request.action == 3 && sender.tab.id) {
|
||||
sendResponse(tab_registry[sender.tab.id]);
|
||||
return;
|
||||
}
|
||||
|
||||
account_name = request.account;
|
||||
chrome.pageAction.show(sender.tab.id);
|
||||
|
||||
// Return nothing to let the connection be cleaned up.
|
||||
sendResponse({});
|
||||
}
|
||||
|
||||
chrome.pageAction.onClicked.addListener(pageActionListener);
|
||||
|
||||
/**
|
||||
* opens the Gmail ComposeWindow and transmits the email data
|
||||
* @param to string of recipient email addresses separated by ", "
|
||||
* @param cc string of recipient email addresses separated by ", " receiving a copy
|
||||
* @param cc string of recipient email addresses separated by ", " receiving a blind copy
|
||||
* @param subject email subject as string
|
||||
*/
|
||||
function openGmailComposeWindow(request) {
|
||||
var tab = chrome.tabs.create(
|
||||
{url: "https://mail.google.com/mail/?view=cm&fs=1&tf=1&to="+
|
||||
encodeURIComponent(request.to)+"&cc="+
|
||||
encodeURIComponent(request.cc)+"&bcc="+
|
||||
encodeURIComponent(request.bcc)+"&su="+
|
||||
encodeURIComponent(request.subject)+"&body="+
|
||||
// TODO: long bodys result in an error on the google mail server because the URL gets too long
|
||||
encodeURIComponent(request.body)+"&shva=1", selected: true});
|
||||
// its a good idea to store the request...
|
||||
// once the gmail compose window has opened, the content
|
||||
// script could fetch the request to insert message data
|
||||
// into the forms this would be a proper solution to the
|
||||
// "url too long" issue. Problem: the page is rendered
|
||||
// within an iframe so contentscript has no access to
|
||||
// fill in the data. We have'nt tried the basic html
|
||||
// approach yet.. see action == "3"
|
||||
tab_registry[tab.id] = request;
|
||||
}
|
||||
|
||||
/**
|
||||
* the page action listener event handler:
|
||||
* opens a compose window (openpgp.html)
|
||||
*/
|
||||
function pageActionListener(tab) {
|
||||
openComposeWindow({action: 0, account: account_name});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function openComposeWindow(request) {
|
||||
var tab = chrome.tabs.create({url: "openpgp.html", selected: true }, function(tab) {
|
||||
tab_registry[tab.id] = request;
|
||||
});
|
||||
}
|
||||
|
||||
// Listen for the content script to send a message to the background page.
|
||||
chrome.extension.onRequest.addListener(onRequest);
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
|
@ -1,244 +0,0 @@
|
|||
// GPG4Browsers - An OpenPGP implementation in javascript
|
||||
// Copyright (C) 2011 Recurity Labs GmbH
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
if (window.location.href.indexOf("https://mail.google.com/mail/?view=cm") == 0) {
|
||||
// we are running in the compose window
|
||||
} else {
|
||||
// we are running in the normal interface
|
||||
chrome.extension.sendRequest({account: document.getElementsByTagName("script")[4].text.split(",")[10].replace(/"/g,"").trim()}, function(response) {});
|
||||
|
||||
}
|
||||
|
||||
var current_message_type = -1;
|
||||
var current_message = null;
|
||||
|
||||
/**
|
||||
* searches the given text for a pgp message. If a message is available the openpgp message dialog is shown
|
||||
* @param text text to be searched
|
||||
*/
|
||||
function find_openpgp(text) {
|
||||
text = text.replace(/\r\n/g,"\n");
|
||||
if (document.location.hash != current_message) {
|
||||
if (/-----BEGIN PGP MESSAGE-----/.test(text) && /-----END PGP MESSAGE-----/.test(text)) {
|
||||
current_message= document.location.hash;
|
||||
current_message_type = 0;
|
||||
current_pgp_block = text.substring(text.indexOf("-----BEGIN PGP MESSAGE-----"), text.indexOf("-----END PGP MESSAGE-----")+25);
|
||||
current_pgp_block = current_pgp_block.replace(/\n/g,"").replace(/<br>/g,"\n").replace(/<wbr>/g,"");
|
||||
if (pgp_verifyCheckSum(current_pgp_block))
|
||||
show_pgp_alert();
|
||||
|
||||
} else if (/-----BEGIN PGP SIGNED MESSAGE-----/.test(text) && /-----END PGP SIGNATURE-----/.test(text)) {
|
||||
current_message= document.location.hash;
|
||||
current_message_type = 1;
|
||||
current_pgp_block = text.substring(text.indexOf("-----BEGIN PGP SIGNED MESSAGE-----"), text.indexOf("-----END PGP SIGNATURE-----")+26);
|
||||
current_pgp_block = current_pgp_block.replace(/\n/g,"").replace(/<br>/g,"\n").replace(/<wbr>/g,"");
|
||||
if (pgp_verifyCheckSum(current_pgp_block.substring(current_pgp_block.indexOf("-----BEGIN PGP SIGNATURE-----"))))
|
||||
show_pgp_alert();
|
||||
} else {
|
||||
hide_pgp_alert();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var doc = null;
|
||||
|
||||
/**
|
||||
* call routine to open the openpgp.html page for handling a message
|
||||
* @return null
|
||||
*/
|
||||
function start_pgp_dialog() {
|
||||
//Gmail does not provide a generic way. to get message data out of the HTML interface so we parse the DOM
|
||||
Gmail.getMail(function(msg) {
|
||||
msg.action = 1;
|
||||
chrome.extension.sendRequest(msg, function(response) {
|
||||
// hide_pgp_alert(); // hide pgp alert after opening the openpgp window
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* showing the pgp alert
|
||||
* @return
|
||||
*/
|
||||
function show_pgp_alert() {
|
||||
var div = document.createElement("div");
|
||||
var buttonyes = document.createElement("button");
|
||||
var buttonno = document.createElement("button");
|
||||
buttonyes.setAttribute("type", "submit");
|
||||
buttonyes.addEventListener("mousedown", function () {
|
||||
var msg = start_pgp_dialog();
|
||||
});
|
||||
buttonno.setAttribute("type", "submit");
|
||||
buttonno.addEventListener("mousedown", function() { hide_pgp_alert(); }, true);
|
||||
buttonyes.appendChild(document.createTextNode("Yes"));
|
||||
buttonno.appendChild(document.createTextNode("No"));
|
||||
div.setAttribute("id", "gpg4browsers_alert");
|
||||
div.setAttribute("style","position: fixed; top: 0px; width: 100%; background-color: #eeeeff; border-bottom: 1px solid #aaa;");
|
||||
if (current_message_type == 0)
|
||||
div.appendChild(document.createTextNode("This mail is encrypted. Do you want to open it with OpenPGP.js?"));
|
||||
else if (current_message_type == 1)
|
||||
div.appendChild(document.createTextNode("This mail is signed. Do you want to open it with OpenPGP.js?"));
|
||||
div.appendChild(buttonyes);
|
||||
div.appendChild(buttonno);
|
||||
document.body.appendChild(div);
|
||||
};
|
||||
|
||||
/**
|
||||
* hiding the pgp alert
|
||||
* @return
|
||||
*/
|
||||
function hide_pgp_alert() {
|
||||
if (document.getElementById("gpg4browsers_alert") != null) {
|
||||
document.getElementById("gpg4browsers_alert").parentNode.removeChild(document.getElementById("gpg4browsers_alert"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* background process timer to constantly check the displayed page for pgp messages
|
||||
*/
|
||||
window.setInterval(function() {
|
||||
find_openpgp(document.body.innerHTML);
|
||||
if (document.getElementById("canvas_frame") != null)
|
||||
find_openpgp(document.getElementById("canvas_frame").contentDocument.body.innerHTML);
|
||||
}, 1000);
|
||||
|
||||
|
||||
/**
|
||||
* verifies the checksum of an base64 encrypted pgp block
|
||||
* @param text containing the base64 block and the base64 encoded checksum
|
||||
* @return true if the checksum was correct, false otherwise
|
||||
*/
|
||||
function pgp_verifyCheckSum(text) {
|
||||
var splittedtext = text.split('-----');
|
||||
var data = r2s(splittedtext[2].split('\n\n')[1].split("\n=")[0]);
|
||||
var checksum = splittedtext[2].split('\n\n')[1].split("\n=")[1].replace(/\n/g,"");
|
||||
var c = getCheckSum(data);
|
||||
var d = checksum;
|
||||
return c[0] == d[0] && c[1] == d[1] && c[2] == d[2];
|
||||
}
|
||||
|
||||
/**
|
||||
* calculates the checksum over a given block of data
|
||||
* @param data block to be used
|
||||
* @return a string containing the base64 encoded checksum
|
||||
*/
|
||||
function getCheckSum(data) {
|
||||
var c = createcrc24(data);
|
||||
var str = "" + String.fromCharCode(c >> 16)+
|
||||
String.fromCharCode((c >> 8) & 0xFF)+
|
||||
String.fromCharCode(c & 0xFF);
|
||||
return s2r(str);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* calculation routine for a CRC-24 checksum
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
function createcrc24 (data) {
|
||||
var crc = 0xB704CE;
|
||||
var i;
|
||||
var mypos = 0;
|
||||
var len = data.length;
|
||||
while (len--) {
|
||||
crc ^= (data[mypos++].charCodeAt()) << 16;
|
||||
for (i = 0; i < 8; i++) {
|
||||
crc <<= 1;
|
||||
if (crc & 0x1000000)
|
||||
crc ^= 0x1864CFB;
|
||||
}
|
||||
}
|
||||
return crc & 0xFFFFFF;
|
||||
}
|
||||
|
||||
// base64 implementation
|
||||
|
||||
var b64s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||
|
||||
/**
|
||||
* Converting Base64 data to a string
|
||||
* @param t base64 encoded data string
|
||||
* @return data string
|
||||
*/
|
||||
function r2s(t) {
|
||||
var c, n;
|
||||
var r = '', s = 0, a = 0;
|
||||
var tl = t.length;
|
||||
|
||||
for (n = 0; n < tl; n++) {
|
||||
c = b64s.indexOf(t.charAt(n));
|
||||
if (c >= 0) {
|
||||
if (s)
|
||||
r += String.fromCharCode(a | (c >> (6 - s)) & 255);
|
||||
s = (s + 2) & 7;
|
||||
a = (c << s) & 255;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converting a data string to a base64 encoded string
|
||||
* @param t data string
|
||||
* @return base64 encoded data string
|
||||
*/
|
||||
function s2r(t) {
|
||||
var a, c, n;
|
||||
var r = '', l = 0, s = 0;
|
||||
var tl = t.length;
|
||||
|
||||
for (n = 0; n < tl; n++) {
|
||||
c = t.charCodeAt(n);
|
||||
if (s == 0) {
|
||||
r += b64s.charAt((c >> 2) & 63);
|
||||
a = (c & 3) << 4;
|
||||
} else if (s == 1) {
|
||||
r += b64s.charAt((a | (c >> 4) & 15));
|
||||
a = (c & 15) << 2;
|
||||
} else if (s == 2) {
|
||||
r += b64s.charAt(a | ((c >> 6) & 3));
|
||||
l += 1;
|
||||
if ((l % 60) == 0)
|
||||
r += "\n";
|
||||
r += b64s.charAt(c & 63);
|
||||
}
|
||||
l += 1;
|
||||
if ((l % 60) == 0)
|
||||
r += "\n";
|
||||
|
||||
s += 1;
|
||||
if (s == 3)
|
||||
s = 0;
|
||||
}
|
||||
if (s > 0) {
|
||||
r += b64s.charAt(a);
|
||||
l += 1;
|
||||
if ((l % 60) == 0)
|
||||
r += "\n";
|
||||
r += '=';
|
||||
l += 1;
|
||||
}
|
||||
if (s == 1) {
|
||||
if ((l % 60) == 0)
|
||||
r += "\n";
|
||||
r += '=';
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB |
18
plugins/chrome/jquery.min.js
vendored
18
plugins/chrome/jquery.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
../../src/
|
|
@ -1,32 +0,0 @@
|
|||
{
|
||||
"name" : "OpenPGP.js",
|
||||
"version" : "0.1",
|
||||
"description" : "OpenPGP.js integration for Google Mail",
|
||||
"background_page" : "background.html",
|
||||
"options_page": "options.html",
|
||||
"page_action" :
|
||||
{
|
||||
"default_icon" : "images/icons/logo.png",
|
||||
"default_title" : "Create encrypted Message"
|
||||
},
|
||||
"content_scripts" : [
|
||||
{
|
||||
"matches" : [
|
||||
"https://mail.google.com/*"
|
||||
],
|
||||
"js" : ["jquery.min.js", "contentscripts.js", "gmail.js"],
|
||||
"run_at" : "document_idle",
|
||||
"all_frames" : false
|
||||
}
|
||||
],
|
||||
"incoginto": "split",
|
||||
"permissions": [
|
||||
"https://mail.google.com/*",
|
||||
"http://keyserver.linux.it/*",
|
||||
"unlimitedStorage"
|
||||
],
|
||||
"icons" : {
|
||||
"48" : "images/icons/logo.png",
|
||||
"128" : "images/icons/logo.png"
|
||||
}
|
||||
}
|
|
@ -1,565 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<script type="text/javascript" src="jquery.min.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/hash/sha.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/hash/md5.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/hash/ripe-md.js"></script>
|
||||
|
||||
<!-- crypto libs -->
|
||||
<script type="text/javascript" src="js/ciphers/symmetric/aes.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/symmetric/cast5.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/symmetric/dessrc.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/symmetric/twofish.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/symmetric/blowfish.js"></script>
|
||||
|
||||
<script type="text/javascript" src="js/ciphers/asymmetric/jsbn.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/asymmetric/jsbn2.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/asymmetric/dsa.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/asymmetric/elgamal.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/asymmetric/rsa.js"></script>
|
||||
|
||||
<script type="text/javascript" src="js/ciphers/openpgp.crypto.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/openpgp.cfb.js"></script>
|
||||
|
||||
<!-- compression -->
|
||||
|
||||
<!-- encoding -->
|
||||
<script type="text/javascript" src="js/encoding/base64.js"></script>
|
||||
<script type="text/javascript" src="js/encoding/openpgp.encoding.asciiarmor.js"></script>
|
||||
<script type="text/javascript" src="js/encoding/openpgp.encoding.js"></script>
|
||||
|
||||
<!-- openpgp types -->
|
||||
<script type="text/javascript" src="js/type/openpgp.type.keyid.js"></script>
|
||||
<script type="text/javascript" src="js/type/openpgp.type.mpi.js"></script>
|
||||
<script type="text/javascript" src="js/type/openpgp.type.s2k.js"></script>
|
||||
|
||||
<!-- openpgp packets -->
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.compressed.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.encrypteddata.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.encryptedintegrityprotecteddata.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.encryptedsessionkey.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.keymaterial.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.literaldata.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.marker.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.modificationdetectioncode.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.onepasssignature.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.signature.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.userattribute.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.userid.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.js"></script>
|
||||
|
||||
<!-- openpgp impl. -->
|
||||
<script type="text/javascript" src="js/openpgp.js"></script>
|
||||
<script type="text/javascript" src="js/config/openpgp.config.js"></script>
|
||||
<script type="text/javascript" src="js/openpgp.keyring.js"></script>
|
||||
<script type="text/javascript" src="js/openpgp.msg.message.js"></script>
|
||||
<script type="text/javascript" src="js/openpgp.msg.privatekey.js"></script>
|
||||
<script type="text/javascript" src="js/openpgp.msg.publickey.js"></script>
|
||||
<script type="text/javascript" src="js/util/util.js"></script>
|
||||
|
||||
<title>OpenPGP.js</title>
|
||||
</head>
|
||||
<style>
|
||||
|
||||
#enterPassword {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
margin-top: -10px;
|
||||
margin-left: -300px;
|
||||
background-color: #8888FF;
|
||||
z-index:4;
|
||||
border: 2px solid white;
|
||||
box-shadow: 0px 0px 4px 4px #666;
|
||||
background-color: #fff;
|
||||
border: 2px solid white; box-shadow: 0px 0px 4px 4px #666;
|
||||
padding: 3px;
|
||||
}
|
||||
#keyselect {
|
||||
display: none;
|
||||
margin: 0 auto;
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
font-size: 89%;
|
||||
margin-top: -235px;
|
||||
margin-left: -300px;
|
||||
background-color: #8888FF;
|
||||
z-index:4;
|
||||
border: 2px solid white;
|
||||
box-shadow: 0px 0px 4px 4px #666;
|
||||
background-color: #fff;
|
||||
width: 600px;
|
||||
height: 470px;
|
||||
}
|
||||
#keyselecttable {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#keyselecttable th {
|
||||
background-color: #eee;
|
||||
border-bottom: 1px solid #000;
|
||||
padding: 2px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#keyselecttable td {
|
||||
padding: 2px;
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
|
||||
#reciepientTable {
|
||||
border: none;
|
||||
border-spacing: 2px;
|
||||
overflow: auto;
|
||||
}
|
||||
input, select {
|
||||
width: 570px;
|
||||
}
|
||||
.reciepientSelect {
|
||||
width: 50px;
|
||||
}
|
||||
.disabledkeys, .keys, .otherkeys {
|
||||
width: 15px;
|
||||
}
|
||||
.reciepientAdd {
|
||||
width: 21px;
|
||||
height: 21px;
|
||||
}
|
||||
#displayWindow, #composeWindow {
|
||||
margin-top: 2px;
|
||||
border: 1px solid #AAA;
|
||||
background-color: white;
|
||||
box-shadow: 2px 2px 5px #888;
|
||||
z-index: 2;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
padding-bottom: 10px;
|
||||
border-radius: 5px;
|
||||
width: 670px;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #EFEFEF;
|
||||
}
|
||||
|
||||
#keyselecttable tbody {
|
||||
overflow: auto;
|
||||
}
|
||||
#displaySender, #displayCC,
|
||||
</style>
|
||||
<script language="javascript">
|
||||
|
||||
// we rely on jquery here
|
||||
var current_message = null;
|
||||
var account_email = null;
|
||||
|
||||
function start() {
|
||||
openpgp.init();
|
||||
chrome.extension.sendRequest({},
|
||||
function(response) {
|
||||
request = response;
|
||||
if (request.action == 0) { // compose message
|
||||
account_email = request.account;
|
||||
show_compose_window();
|
||||
} else if (request.action == 1) { // decrypt message
|
||||
current_message = request;
|
||||
account_email = request.account;
|
||||
show_message_window(response);
|
||||
} else {
|
||||
show_compose_window();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function show_compose_window() {
|
||||
$("#composerAddress").html(openpgp_encoding_html_encode(account_email));
|
||||
$("#displayWindow").hide();
|
||||
$("#composeWindow").show();
|
||||
if (openpgp.config.config.composition_behavior == 0) {
|
||||
$('#sign_message').attr("checked","checked");
|
||||
$('#encrypt_message').attr("checked","checked");
|
||||
} else if (openpgp.config.config.composition_behavior == 1) {
|
||||
$('#sign_message').attr("checked","checked");
|
||||
$('#encrypt_message').removeAttr("checked");
|
||||
} else if (openpgp.config.config.composition_behavior == 2) {
|
||||
$('#encrypt_message').attr("checked","checked");
|
||||
$('#sign_message').removeAttr("checked");
|
||||
}
|
||||
}
|
||||
var msg = null;
|
||||
function rfn(result) {
|
||||
if (result == -2)
|
||||
util.print_warning("unable to decrypt message: no private key available");
|
||||
else if (result == -1)
|
||||
util.print_error("No valid passphrase supplied");
|
||||
else if (result == -3)
|
||||
util.print_error("unable to decrypt message: error during decryption");
|
||||
else {
|
||||
current_message.decrypted = result;
|
||||
$("#displayMessage").html(openpgp_encoding_html_encode(result));
|
||||
}
|
||||
}
|
||||
|
||||
function show_message_window(request) {
|
||||
current_request = request;
|
||||
$("#composeWindow").hide();
|
||||
$("#displayWindow").show();
|
||||
$("#displaySender").html(openpgp_encoding_html_encode(request.from));
|
||||
for (var i = 0; i < request.to.length; i++)
|
||||
$("#displayReceipients").html(openpgp_encoding_html_encode(request.to[i]));
|
||||
if (request.cc != null && request.cc.length > 0) {
|
||||
$("#displayCC").html("");
|
||||
for (var i = 0; i < request.cc.length; i++)
|
||||
$("#displayCC").append(openpgp_encoding_html_encode(request.cc[i]));
|
||||
$("#displayCC").show();
|
||||
} else {
|
||||
$("#displayCC").hide();
|
||||
}
|
||||
if (request.bcc != null) {
|
||||
$("#displayBCC").html(openpgp_encoding_html_encode(request.bcc));
|
||||
$("#displayBCC").show();
|
||||
} else {
|
||||
$("#displayBCC").hide();
|
||||
}
|
||||
$("#displaySubject").html(openpgp_encoding_html_encode(request.subject));
|
||||
$("#displayMessage").html(openpgp_encoding_html_encode(request.body));
|
||||
|
||||
msg = openpgp.read_message(request.body);
|
||||
if (msg != null)
|
||||
for (var m = 0; m < msg.length; m++) {
|
||||
if (!(msg[m].sessionKeys == null)) {
|
||||
var found = false;
|
||||
for (var i = 0; i < msg[m].sessionKeys.length; i++) {
|
||||
if (openpgp.keyring.getPrivateKeyForKeyId(msg[m].sessionKeys[i].keyId)) {
|
||||
var key = openpgp.keyring.getPrivateKeyForKeyId(msg[m].sessionKeys[i].keyId);
|
||||
if (key.length != 0)
|
||||
found = true;
|
||||
for (var j = 0; j < key.length; j++) {
|
||||
if (!key[j].keymaterial.hasUnencryptedSecretKeyData) {
|
||||
get_password(key[j], msg[m], msg[m].sessionKeys[i], rfn);
|
||||
} else {
|
||||
rfn(msg[m].decrypt_message(key[j], null));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rfn(-2);
|
||||
}
|
||||
}
|
||||
if (!found || openpgp.keyring.privateKeys.length == 0)
|
||||
rfn(-2);
|
||||
} else if (msg[m].type == 2) {
|
||||
if (msg[m].verifySignature())
|
||||
rfn(msg[m].text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var encryptionkeys = new Array();
|
||||
var otherkeys = new Array();
|
||||
var reciepient_count = 2;
|
||||
|
||||
function add_reciepient() {
|
||||
add_reciepient(null,null,null);
|
||||
}
|
||||
|
||||
function add_reciepient(method, name, isdisabled) {
|
||||
|
||||
$("#reciepientTable").append("<tr class=\"reciepientsRow\"><td><select class=\"reciepientSelect\" "+((isdisabled != null) ? "disabled=\"disabled\" ":"")+"id=\"reciepient_method_"+reciepient_count+"\">"+
|
||||
"<option value=\"0\""+((method == 0) ? " selected=\"selected\"" : "")+">To:</option>"+
|
||||
"<option value=\"1\""+((method == 1) ? " selected=\"selected\"" : "")+">Cc:</option>"+
|
||||
"<option value=\"2\""+((method == 2) ? " selected=\"selected\"" : "")+">Bcc:</option>"+
|
||||
"</select></td><td>"+
|
||||
"<input name=\"recepient_"+reciepient_count+"\" type=\"text\" value=\""+((name != null) ? name : "")+"\"></input>"+
|
||||
"</td><td><input class=\"reciepientAdd\" id=\"reciepientAdd_"+reciepient_count+"\" type=\"button\" value=\"+\" onmousedown=\"add_reciepient();\"></input></td></tr>");
|
||||
|
||||
for (var i =1; i < reciepient_count; i++) $("#reciepientAdd_"+i).remove();
|
||||
reciepient_count++;
|
||||
}
|
||||
|
||||
function prepare_send_mail() {
|
||||
var i = 1;
|
||||
var addr = new Array();
|
||||
while ($('[name="recepient_'+i+'"]').val() != null) {
|
||||
addr[i-1] = $('[name="recepient_'+i+'"]').val();
|
||||
i++;
|
||||
}
|
||||
if ($('#encrypt_message').attr('checked') != null)
|
||||
showKeySelection(addr);
|
||||
else
|
||||
showEncryptionConfirmation();
|
||||
}
|
||||
|
||||
function show_reply(reply_all) {
|
||||
if (reply_all) {
|
||||
// adding replys "To"
|
||||
if (current_message.to.length < 2)
|
||||
add_reciepient(0,current_message.to[0], null);
|
||||
else for (var i = 0; i < request.to.length; i++)
|
||||
if (!getEmailAddress(request.to[i]).match(account_email)) {
|
||||
add_reciepient(0,current_message.to[i], null);
|
||||
}
|
||||
// adding reply copies (CC)
|
||||
if (current_request.cc != null)
|
||||
for (var i = 0; i < current_request.cc.length; i++)
|
||||
if (!getEmailAddress(current_request.cc[i]).match(account_email)) {
|
||||
add_reciepient(1,current_message.cc[i], null);
|
||||
}
|
||||
}
|
||||
$("#subjectInput").val("Re: "+current_message.subject);
|
||||
$("#composerAddress").html(openpgp_encoding_html_encode(account_email));
|
||||
$("#messageBody").html(openpgp_encoding_html_encode(quote_message(current_message.from, new Date(current_message.date), current_message.decrypted)));
|
||||
$("#firstto").val(current_message.from);
|
||||
$("#displayWindow").hide();
|
||||
show_compose_window();
|
||||
}
|
||||
|
||||
function quote_message (sender, date, msg) {
|
||||
return "\n\nOn "+date.toLocaleDateString()+" "+date.toLocaleTimeString()+" \""+getName(sender)+"\" wrote:"+"\n> "+msg.replace(/\n/g,"\n> ");
|
||||
}
|
||||
|
||||
function get_password(key, msg, sessionkey, successfn) {
|
||||
$("#enterPasswordSubmit").removeAttr("disabled");
|
||||
$("#enterPasswordInput").removeAttr("disabled");
|
||||
$("#enterPasswordInput").attr("value","");
|
||||
$('#enterPassword').css('background-color','#fff');
|
||||
var count = 0;
|
||||
$("#enterPasswordText").html("Please enter password for keyID: 0x"+util.hexstrdump(key.key.obj.getKeyId()));
|
||||
$("#enterPasswordKeyId").html(key.key.obj.userIds[0]);
|
||||
|
||||
$("#enterPasswordSubmit").click(function() {
|
||||
$("#enterPassword").fadeOut(100);
|
||||
$("#enterPasswordSubmit").attr("disabled","disabled");
|
||||
$("#enterPasswordInput").attr("disabled","disabled");
|
||||
if (key.keymaterial.decryptSecretMPIs($("#enterPasswordInput").val())) {
|
||||
$("#block-bg").hide();
|
||||
if (msg == null) {
|
||||
successfn();
|
||||
}
|
||||
successfn(msg.decrypt(key, sessionkey));
|
||||
} else {
|
||||
if (count == 2) {
|
||||
$("#block-bg").hide();
|
||||
successfn(-1);
|
||||
current_message.decrypted = current_message.body;
|
||||
count = 0;
|
||||
return;
|
||||
}
|
||||
$('#enterPassword').css('background-color','#f88');
|
||||
$("#enterPasswordSubmit").removeAttr("disabled");
|
||||
$("#enterPasswordInput").removeAttr("disabled");
|
||||
$("#enterPasswordText").html("enterered Password was wrong. try again for keyID: 0x"+util.hexstrdump(key.key.keyId));
|
||||
|
||||
$('#enterPasswordInput').focus();
|
||||
$('#enterPassword').fadeIn(100);
|
||||
count++;
|
||||
}
|
||||
|
||||
});
|
||||
$("#block-bg").show();
|
||||
$("#enterPassword").show();
|
||||
$('#enterPasswordInput').focus();
|
||||
}
|
||||
|
||||
function send_mail(encrypted_text) {
|
||||
var i = 1;
|
||||
var to = "";
|
||||
var cc = "";
|
||||
var bcc = "";
|
||||
while($('[name="recepient_'+i+'"]').val() != null) {
|
||||
if ($('#reciepient_method_'+i).val() == 0)
|
||||
if (to != "")
|
||||
to += ", "+$('[name="recepient_'+i+'"]').val();
|
||||
else
|
||||
to = $('[name="recepient_'+i+'"]').val();
|
||||
else if ($('#reciepient_method_'+i).val() == 1)
|
||||
if (cc != "")
|
||||
cc += ", "+$('[name="recepient_'+i+'"]').val();
|
||||
else
|
||||
cc = $('[name="recepient_'+i+'"]').val();
|
||||
else if ($('#reciepient_method_'+i).val() == 2)
|
||||
if (bcc != "")
|
||||
bcc += ", "+$('[name="recepient_'+i+'"]').val();
|
||||
else
|
||||
bcc = $('[name="recepient_'+i+'"]').val();
|
||||
i++;
|
||||
}
|
||||
var subject = $("#subjectInput").val();
|
||||
$("#enterPassword").hide();
|
||||
chrome.extension.sendRequest({action: 2, to: to, bcc: bcc, cc: cc, subject: subject, body: encrypted_text}, function() {});
|
||||
window.close();
|
||||
}
|
||||
|
||||
function getName(email_address) {
|
||||
var o = email_address.indexOf("<");
|
||||
if (o == -1)
|
||||
return email_address;
|
||||
return email_address.split("<")[0].trim();
|
||||
}
|
||||
|
||||
function getEmailAddress(reciepient) {
|
||||
var o = reciepient.indexOf("<");
|
||||
var c = reciepient.indexOf(">");
|
||||
if (o == -1 || c == -1)
|
||||
return reciepient;
|
||||
return reciepient.substring(o+1,u);
|
||||
}
|
||||
|
||||
function showMessages(html) {
|
||||
if ($('#displayWindow').is(':visible'))
|
||||
$('#MessageDisplayOpenPGP').append(html);
|
||||
else if ($('#composeWindow').is(':visible'))
|
||||
$('#MessageComposeOpenPGP').append(html);
|
||||
}
|
||||
|
||||
function doDownload(mimetype, data) {
|
||||
window.open("data:"+mimetype+";fileName=\"msg.txt\";charset=\"ISO8859-1\";base64,"+s2r(data));
|
||||
}
|
||||
|
||||
function showKeySelection(emailaddresses) {
|
||||
$('#keyselecttable').empty();
|
||||
$('#keyselecttable').append('<tr><th><input class="disabledkeys" type="checkbox" disabled="disabled" checked="checked"></input></th><th>Account / User ID</th><th>Trust</th><th>Key ID</th></tr>');
|
||||
encryptionkeys = new Array();
|
||||
otherkeys = new Array();
|
||||
for (var j = 0; j < emailaddresses.length; j++) {
|
||||
var addr = emailaddresses[j].match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
|
||||
for (var i = 0; i < openpgp.keyring.publicKeys.length; i++) {
|
||||
for (var k = 0; k < openpgp.keyring.publicKeys[i].obj.userIds.length; k++) {
|
||||
if (openpgp.keyring.publicKeys[i].obj.userIds[k].verify(openpgp.keyring.publicKeys[i].obj.publicKeyPacket) != 0)
|
||||
continue;
|
||||
if (addr == openpgp.keyring.publicKeys[i].obj.userIds[k].text.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi)) {
|
||||
encryptionkeys[keys.length] = openpgp.keyring.publicKeys[i];
|
||||
emailaddresses.splice(j,1);
|
||||
} else {
|
||||
otherkeys[otherkeys.length] = openpgp.keyring.publicKeys[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// we got all keys
|
||||
if (emailaddresses.length == 0) {
|
||||
showEncryptionConfirmation();
|
||||
}
|
||||
$('#keyselecttext').empty();
|
||||
|
||||
$('#keyselecttext').append("Select keys for the following email addresses:<br>");
|
||||
for (var i= 0; i < emailaddresses.length; i++) {
|
||||
$('#keyselecttext').append("<i>"+openpgp_encoding_html_encode(emailaddresses[i])+"</i>, ");
|
||||
}
|
||||
|
||||
for (var i=0; i < encryptionkeys.length; i++)
|
||||
$('#keyselecttable').append('<tr class="validkey"><td><input class="keys" value="'+i+'" type="checkbox" checked="checked"></input></td><td></td>'+
|
||||
openpgp_encoding_html_encode(encryptionkeys[i].obj.userIds[0].text)+'<td>valid</td><td>0x'+openpgp_encoding_html_encode(util.hexstrdump(encryptionkeys[i].obj.getKeyId()).substring(8))+'</td></tr>');
|
||||
for (var i = 0; i < otherkeys.length; i++) {
|
||||
if (!otherkeys[i].obj.verifyBasicSignatures()) {
|
||||
$('#keyselecttable').append('<tr class="invalidkey"><td><input class="disabledkeys" type="checkbox" disabled="disabled"></input></td><td><i style="color: #888;">'+
|
||||
openpgp_encoding_html_encode(otherkeys[i].obj.userIds[0].text)+'</i></td><td>invalid</td><td>0x'+openpgp_encoding_html_encode(util.hexstrdump(otherkeys[i].obj.getKeyId()).substring(8))+'</td></tr>');
|
||||
} else {
|
||||
$('#keyselecttable').append('<tr class="validkey"><td><input class="otherkeys" value="'+i+'"type="checkbox"></input></td><td>'+
|
||||
openpgp_encoding_html_encode(otherkeys[i].obj.userIds[0].text)+'</td><td>valid</td><td>0x'+openpgp_encoding_html_encode(util.hexstrdump(otherkeys[i].obj.getKeyId()).substring(8))+'</td></tr>');
|
||||
}
|
||||
}
|
||||
$('#keyselect').show();
|
||||
$('#block-bg').show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function showEncryptionConfirmation() {
|
||||
if ($('#encrypt_message').attr('checked') != null) {
|
||||
$('#keyselect').hide();
|
||||
var keys = new Array();
|
||||
var input1 = $('input.keys:checked');
|
||||
var input2 = $('input.otherkeys:checked');
|
||||
for (var i = 0; i < input1.length; i++) {
|
||||
keys[keys.length] = encryptionkeys[parseInt(input1[i].getAttribute("value"))].obj;
|
||||
}
|
||||
for (var i = 0; i < input2.length; i++) {
|
||||
keys[keys.length] = otherkeys[parseInt(input2[i].getAttribute("value"))].obj;
|
||||
}
|
||||
|
||||
if ($('#sign_message').attr('checked') != null) {
|
||||
var privatekey = openpgp.keyring.getPrivateKeyForAddress(account_email);
|
||||
if (privatekey.length == 0) {
|
||||
alert("no private key found! Go to options and import or create one.");
|
||||
showEncryptioncancel();
|
||||
}
|
||||
|
||||
get_password({ key: privatekey[0], keymaterial: privatekey[0].obj.privateKeyPacket},null,null, function(ret) {
|
||||
if (!(ret < 0))
|
||||
send_mail(openpgp.write_signed_and_encrypted_message(privatekey[0].obj, keys, $('#messageBody').val()));
|
||||
});
|
||||
} else {
|
||||
send_mail(openpgp.write_encrypted_message(keys, $('#messageBody').val()));
|
||||
}
|
||||
} else {
|
||||
var privatekey = openpgp.keyring.getPrivateKeyForAddress(account_email);
|
||||
if (privatekey.length == 0) {
|
||||
alert("no private key found! Go to options and import or create one.");
|
||||
showEncryptioncancel();
|
||||
}
|
||||
get_password({ key: privatekey[0], keymaterial: privatekey[0].obj.privateKeyPacket},null,null, function(ret) {
|
||||
if (!(ret < 0))
|
||||
send_mail(openpgp.write_signed_message(privatekey[0].obj, $('#messageBody').val()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function showEncryptionCancel() {
|
||||
$('#keyselect').hide();
|
||||
$('#block-bg').hide();
|
||||
}
|
||||
|
||||
</script>
|
||||
<body onload="start();" style="font-family: sans-serif;">
|
||||
<table id="displayWindow">
|
||||
<tr><td colspan="2"><button type="submit" onmousedown="show_reply(false);" style="width: 80px; height: 50px"> <- Reply</button> <button type="submit" onmousedown="show_reply(true);" style="width: 100px; height: 50px"> <= Reply All</button> <button type="submit" onmousedown="forward();" style="width: 80px; height: 50px">Forward -></button></td></tr>
|
||||
<tr><td>From:</td><td id="displaySender" style="font-weight: bold;"></td></tr>
|
||||
<tr><td>To:</td><td id="displayReceipients" style="font-weight: bold;"></td></tr>
|
||||
<tr><td>CC:</td><td id="displayCC" style="display: none;"></td></tr>
|
||||
<tr><td>BCC:</td><td id="displayBCC" style="display: none;"></td></tr>
|
||||
<tr><td>Subject:</td><td id="displaySubject"></td></tr>
|
||||
<tr><td id="MessageDisplayOpenPGP" colspan="2"></td></tr>
|
||||
<tr><td colspan="2"><textarea cols="80" rows="30" readonly="readonly" id="displayMessage"></textarea></td></tr>
|
||||
<tr><td colspan="2"><button type="button" onclick="doDownload('application/octet-stream',$('#displayMessage').val());">Download</button></td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
<table id="composeWindow">
|
||||
<tr><td>
|
||||
<table id="reciepientTable">
|
||||
<tr><td style="text-align: left;"><button id="encrypt" style="width: 50px; height: 50px" onmousedown="prepare_send_mail();">send</button></td><td colspan="2" style="text-align: left; font-size: 89%; border-bottom: 1px solid #aaa"><input style="width: 20px;" type="checkbox" id="sign_message"> Sign message <br/><input style="width: 20px;" type="checkbox" id="encrypt_message"> Encrypt message </td></tr>
|
||||
<tr class="reciepientsRow"><td>From:</td><td id="composerAddress"></td></tr>
|
||||
<tr class="reciepientsRow"><td><select class="reciepientSelect" id="reciepient_method_1" disabled="disabled"><option value="0">To:</option><option value="1">Cc:</option><option value="2">Bcc:</option></select></td><td><input id="firstto" name="recepient_1" type="text"></input></td><td><input class="reciepientAdd" id="reciepientAdd_1" type="button" value="+" onmousedown="add_reciepient();"></input></td></tr>
|
||||
</table></td></tr>
|
||||
<tr><td id="composeSubject">Subject:<input id="subjectInput" type="text" name="subject"></input></td></tr>
|
||||
<tr><td id="MessageComposeOpenPGP" colspan="2"></td></tr>
|
||||
<tr><td><textarea rows="30" cols="80" id="messageBody"></textarea></td></tr>
|
||||
</table>
|
||||
|
||||
<div id="enterPassword">
|
||||
<span id="enterPasswordText">Enter your Password for key</span> <span id="enterPasswordKeyId"></span>:<br/>
|
||||
<input type="password" id="enterPasswordInput" onkeypress="if (event.keyCode == 13) $('#enterPasswordSubmit').click(); "><button type="submit" id="enterPasswordSubmit">OK</button>
|
||||
</div>
|
||||
<div id="keyselect">
|
||||
<div id="keyselecttext" style="margin: 5px;"></div>
|
||||
<div style="overflow: auto; height: 390px;">
|
||||
<table id="keyselecttable">
|
||||
</table>
|
||||
</div>
|
||||
<div style="text-align: right; margin: 5px;">
|
||||
<button type="submit" onmousedown="showEncryptionConfirmation();">OK</button>
|
||||
<button type="submit" onmousedown="showEncryptionCancel();">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="encryptionConfirmation">
|
||||
</div>
|
||||
<div id="block-bg" style=" width: 100%; height: 100%; z-index: 2; display: none; position: fixed; top: 0px; background-color: black; opacity: 0.5;"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,446 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>OpenPGP.js - PGP Message Options</title>
|
||||
</head>
|
||||
<script type="text/javascript" src="jquery.min.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/hash/sha.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/hash/md5.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/hash/ripe-md.js"></script>
|
||||
|
||||
<!-- crypto libs -->
|
||||
<script type="text/javascript" src="js/ciphers/symmetric/aes.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/symmetric/cast5.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/symmetric/dessrc.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/symmetric/twofish.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/symmetric/blowfish.js"></script>
|
||||
|
||||
<script type="text/javascript" src="js/ciphers/asymmetric/jsbn.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/asymmetric/jsbn2.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/asymmetric/dsa.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/asymmetric/elgamal.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/asymmetric/rsa.js"></script>
|
||||
|
||||
<script type="text/javascript" src="js/ciphers/openpgp.crypto.js"></script>
|
||||
<script type="text/javascript" src="js/ciphers/openpgp.cfb.js"></script>
|
||||
|
||||
<!-- compression -->
|
||||
|
||||
<!-- encoding -->
|
||||
<script type="text/javascript" src="js/encoding/base64.js"></script>
|
||||
<script type="text/javascript" src="js/encoding/openpgp.encoding.asciiarmor.js"></script>
|
||||
<script type="text/javascript" src="js/encoding/openpgp.encoding.js"></script>
|
||||
|
||||
<!-- openpgp types -->
|
||||
<script type="text/javascript" src="js/type/openpgp.type.keyid.js"></script>
|
||||
<script type="text/javascript" src="js/type/openpgp.type.mpi.js"></script>
|
||||
<script type="text/javascript" src="js/type/openpgp.type.s2k.js"></script>
|
||||
|
||||
<!-- openpgp packets -->
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.compressed.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.encrypteddata.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.encryptedintegrityprotecteddata.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.encryptedsessionkey.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.keymaterial.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.literaldata.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.marker.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.modificationdetectioncode.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.onepasssignature.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.signature.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.userattribute.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.userid.js"></script>
|
||||
<script type="text/javascript" src="js/packet/openpgp.packet.js"></script>
|
||||
|
||||
<!-- openpgp impl. -->
|
||||
<script type="text/javascript" src="js/openpgp.js"></script>
|
||||
<script type="text/javascript" src="js/config/openpgp.config.js"></script>
|
||||
<script type="text/javascript" src="js/openpgp.keyring.js"></script>
|
||||
<script type="text/javascript" src="js/openpgp.msg.message.js"></script>
|
||||
<script type="text/javascript" src="js/openpgp.msg.privatekey.js"></script>
|
||||
<script type="text/javascript" src="js/openpgp.msg.publickey.js"></script>
|
||||
<script type="text/javascript" src="js/util/util.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
// Saves options to localStorage.
|
||||
function save_options() {
|
||||
openpgp.keyring.store();
|
||||
}
|
||||
|
||||
function getAlgorithmString(publicKey) {
|
||||
var result = publicKey.publicKeyPacket.MPIs[0].mpiByteLength*8+"/";
|
||||
switch (publicKey.publicKeyPacket.publicKeyAlgorithm) {
|
||||
case 1:
|
||||
result += "RSA(S/E)";
|
||||
break;
|
||||
case 2:
|
||||
result +="RSA(E)";
|
||||
break;
|
||||
case 3:
|
||||
result += "RSA(S)";
|
||||
break;
|
||||
case 16:
|
||||
result += "Elg";
|
||||
break;
|
||||
case 17:
|
||||
result += "DSA";
|
||||
break;
|
||||
}
|
||||
if (publicKey.subKeys.length > 0) {
|
||||
result += ", "+(publicKey.subKeys[0].MPIs[0].mpiByteLength * 8)+"/";
|
||||
switch (publicKey.subKeys[0].publicKeyAlgorithm) {
|
||||
case 1:
|
||||
result += "(RSA(S/E)";
|
||||
break;
|
||||
case 2:
|
||||
result +="RSA(E)";
|
||||
break;
|
||||
case 3:
|
||||
result += "RSA(S)";
|
||||
break;
|
||||
case 16:
|
||||
result += "Elg.";
|
||||
break;
|
||||
case 17:
|
||||
result += "DSA";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function encodeForHtml(text) {
|
||||
if (text == null)
|
||||
return "";
|
||||
return $('<div/>').text(text+"").html();
|
||||
}
|
||||
|
||||
function importPublicKey(key) {
|
||||
openpgp.keyring.importPublicKey(key);
|
||||
save_options();
|
||||
update_tables();
|
||||
}
|
||||
|
||||
function importPrivateKey(key) {
|
||||
openpgp.keyring.importPrivateKey(key);
|
||||
save_options();
|
||||
update_tables();
|
||||
}
|
||||
|
||||
// Restores select box state to saved value from localStorage.
|
||||
function restore_options() {
|
||||
openpgp.init();
|
||||
update_tables();
|
||||
$('#cipher_alg_select').val(""+openpgp.config.config.encryption_cipher);
|
||||
$('#hash_alg_select').val(""+openpgp.config.config.prefer_hash_algorithm);
|
||||
$('#compression_alg_select').val(""+openpgp.config.config.compression);
|
||||
$('#integrity').attr("checked", openpgp.config.config.integrity_protect);
|
||||
$('#aaversion').attr("checked", openpgp.config.config.show_version);
|
||||
$('#keyserver').val(""+openpgp.config.config.keyserver);
|
||||
show_tab(0);
|
||||
}
|
||||
|
||||
function show_userIds(k) {
|
||||
var publicKey = openpgp.keyring.publicKeys[k];
|
||||
var certsigs = publicKey.obj.verifyCertificationSignatures();
|
||||
$('#show_ids_'+k).empty();
|
||||
for (var i = 0; i < publicKey.obj.userIds.length; i++) {
|
||||
if (certsigs[i].indexOf(6) != -1)
|
||||
$('#show_ids_'+k).append("<tr style=\"background-color: #fdd\"><td>rev</td><td class=\"uid_revoked\" colspan=\"2\"><s>"+encodeForHtml(publicKey.obj.userIds[i].text)+"</s></td></tr>");
|
||||
else if (certsigs[i].indexOf(5) != -1)
|
||||
$('#show_ids_'+k).append("<tr style=\"background-color: #ffd\"><td>exp</td><td class=\"uid_expired\" colspan=\"2\"><i>"+encodeForHtml(publicKey.obj.userIds[i].text)+"</i></td></tr>");
|
||||
else
|
||||
$('#show_ids_'+k).append("<tr style=\"background-color: #dfd\"><td>uid</td><td class=\"uid_normal\" colspan=\"2\"><b>"+encodeForHtml(publicKey.obj.userIds[i].text)+"</b></td></tr>");
|
||||
for (var j = 0; j < publicKey.obj.userIds[i].certificationSignatures.length; j++) {
|
||||
var istr = util.hexstrdump(publicKey.obj.userIds[i].certificationSignatures[j].getIssuer());
|
||||
var issuer = publicKey.obj.userIds[i].certificationSignatures[j].getIssuerKey();
|
||||
var sigclass = publicKey.obj.userIds[i].certificationSignatures[j].signatureType - 0x10;
|
||||
if (issuer != null)
|
||||
istr = issuer.obj.userIds[0].text;
|
||||
if (certsigs[i][j] == 0)
|
||||
$('#show_ids_'+k).append("<tr><td>sig"+(sigclass == 0 ? "" : sigclass)+"</td><td>BAD</td><td class=\"sig_bad\">"+encodeForHtml(istr)+"</td></tr>");
|
||||
if (certsigs[i][j] == 1)
|
||||
$('#show_ids_'+k).append("<tr><td>sig"+(sigclass == 0 ? "" : sigclass)+"</td><td>exp</td><td class=\"sig_exp\"><i>"+encodeForHtml(istr)+"</i></td></tr>");
|
||||
if (certsigs[i][j] == 2)
|
||||
$('#show_ids_'+k).append("<tr><td>sig"+(sigclass == 0 ? "" : sigclass)+"</td><td>unk</td><td class=\"sig_unk\">"+encodeForHtml(istr)+"</td></tr>");
|
||||
if (certsigs[i][j] == 3)
|
||||
$('#show_ids_'+k).append("<tr><td>sig"+(sigclass == 0 ? "" : sigclass)+"</td><td>rev</td><td class=\"sig_unk\"><s>"+encodeForHtml(istr)+"</s></td></tr>");
|
||||
if (certsigs[i][j] == 4)
|
||||
$('#show_ids_'+k).append("<tr><td>sig"+(sigclass == 0 ? "" : sigclass)+"</td><td></td><td class=\"sig_normal\">"+encodeForHtml(istr)+"</td></tr>");
|
||||
}
|
||||
}
|
||||
$('#show_ids_'+k).toggle();
|
||||
}
|
||||
|
||||
function update_tables() {
|
||||
$('#publicKeyTable').empty();
|
||||
$('#publicKeyTable').append("<tr><th>Key ID</th><th>Person</th><th>Length/Alg.</th><th>Status</th><th>Action</th></tr>");
|
||||
for (var i = 0; i < openpgp.keyring.publicKeys.length; i++) {
|
||||
var status = openpgp.keyring.publicKeys[i].obj.verifyBasicSignatures();
|
||||
var result = "<tr><td>0x"+
|
||||
util.hexstrdump(openpgp.keyring.publicKeys[i].obj.getKeyId()).toUpperCase().substring(8)+ "</td>";
|
||||
result += "<td><button id=\"show_button"+i+"\" onmousedown=\"show_userIds("+i+");\">+</button>"+encodeForHtml(openpgp.keyring.publicKeys[i].obj.userIds[0].text)+"<table style=\"display: none;\" id=\"show_ids_"+i+"\"></table></td>";
|
||||
result += "<td>"+getAlgorithmString(openpgp.keyring.publicKeys[i].obj)+"</td>";
|
||||
result += "<td>"+(status ? "valid" : "invalid")+"</td>";
|
||||
result += "<td><a href=\"#\" onmousedown=\"openpgp.keyring.removePublicKey("+i+"); update_tables();\">remove</a></td>";
|
||||
$("#publicKeyTable").append(result+"</tr>");
|
||||
}
|
||||
$('#privateKeyTable').empty();
|
||||
$('#privateKeyTable').append("<tr><th>Key ID</th><th>Person</th><th>Length/Alg.</th><th>Expires on</th><th>Action</th></tr>");
|
||||
for (var i = 0; i < openpgp.keyring.privateKeys.length; i++) {
|
||||
for (var j = 0; j < openpgp.keyring.privateKeys[i].obj.userIds.length; j++) {
|
||||
$("#privateKeyTable").append("<tr><td>"
|
||||
+util.hexstrdump(openpgp.keyring.privateKeys[i].obj.getKeyId())+ "</td><td>"+
|
||||
": "+encodeForHtml(openpgp.keyring.privateKeys[i].obj.userIds[j].text)+"</td></tr>");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var current_tab = -1;
|
||||
function show_tab(num) {
|
||||
if (current_tab != num) {
|
||||
$("#tab_"+current_tab).hide();
|
||||
$('#tabref_'+current_tab).attr("class","tabref");
|
||||
$("#tab_"+num).show();
|
||||
$('#tabref_'+num).attr("class","tabref-select");
|
||||
}
|
||||
current_tab = num;
|
||||
}
|
||||
function importKeyId(string) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
var searchtext = $('#searchKeyText').val();
|
||||
xhr.open("GET", "http://"+encodeURIComponent(openpgp.config.config.keyserver)+"/pks/lookup?op=get&search=0x"+encodeURIComponent(string)+"&options=mr",true);
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == 4) {
|
||||
var key = xhr.responseText.split('<pre>')[1];
|
||||
importPublicKey(key);
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
function showMessages(html) {
|
||||
$('#debug').append(html);
|
||||
}
|
||||
|
||||
function show_search_results() {
|
||||
$('#searchKeyResults').empty();
|
||||
var xhr = new XMLHttpRequest();
|
||||
var searchtext = $('#searchKeyText').val();
|
||||
xhr.open("GET", "http://"+encodeURIComponent(openpgp.config.config.keyserver)+"/pks/lookup?op=index&search="+encodeURIComponent(searchtext)+"&options=mr",true);
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == 4) {
|
||||
$('#searchKeyResults').append("<tr><th>Key ID</th><th>Person</th><th>Length/Alg.</th><th>CreatedOn</th><th>Action</th></tr>");
|
||||
var text = xhr.responseText.split('\n');
|
||||
for (var i =1; i < text.length; i++) {
|
||||
var col = text[i].split(":");
|
||||
var keyId = null;
|
||||
var created = null;
|
||||
var algorithm = null;
|
||||
var length = null;
|
||||
var uids = null;
|
||||
var revoked = null;
|
||||
var r = 1;
|
||||
if (col[0] == "pub") {
|
||||
keyId = col[1];
|
||||
algorithm = col[2];
|
||||
length = col[3];
|
||||
created = new Date(parseInt(col[4]+"000"));
|
||||
revoked = !(col[6].indexOf('r') < 0);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
uids = "";
|
||||
while (text[i+r].split(":")[0] == "uid") {
|
||||
uids += encodeForHtml(text[i+r].split(":")[1])+"<br>";
|
||||
r++;
|
||||
}
|
||||
i += r-1;
|
||||
$('#searchKeyResults').append("<tr><td>"+keyId+"</td>"+
|
||||
"<td>"+uids+"</td>"+
|
||||
"<td>"+length+"/"+(algorithm == "1" ? "RSA" : "DSA-Elgamal")+"</td>"+
|
||||
"<td>"+created+"</td>"+
|
||||
"<td>"+
|
||||
(!revoked ? "<a href=\"#\" onclick=\"importKeyId('"+encodeForHtml(keyId).trim()+"');\"> Import Key</a>" : "key is revoked")+"</td></tr>");
|
||||
}
|
||||
$('#searchKeyResults').show();
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
background-color: #efefef;
|
||||
}
|
||||
* {
|
||||
font-size: 98%;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
.tabref, .tabref-select {
|
||||
border: 1px solid #aaa;
|
||||
border-bottom: none;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
padding-top: 2px;
|
||||
padding-bottom: 2px;
|
||||
margin-left: 3px;
|
||||
margin-bottom: 0px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.tabref {
|
||||
background-color: #eee;
|
||||
border: 1px solid #aaa;
|
||||
}
|
||||
#options_header {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
#publicKeyTable, #privateKeyTable, #searchKeyResults {
|
||||
border: 1px solid #aaa;
|
||||
}
|
||||
|
||||
#publicKeyTable th, #privateKeyTable th, #searchKeyResults th {
|
||||
background-color: #eee;
|
||||
border-bottom: 1px solid #000;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
#publicKeyTable td, #privateKeyTable td, #searchKeyResults td {
|
||||
padding: 3px;
|
||||
border-bottom: 1px solid #aaa;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.tabref-select {
|
||||
background-color: #fff;
|
||||
border-bottom: 1px solid #fff;
|
||||
}
|
||||
|
||||
h2 {
|
||||
|
||||
font: 1.5em;
|
||||
width: 100%;
|
||||
border-bottom: 1px solid #888;
|
||||
}
|
||||
|
||||
h1, h2 {
|
||||
font: 1.5em "Impact";
|
||||
|
||||
}
|
||||
|
||||
#tab_1, #tab_2, #tab_3, #tab_0 {
|
||||
margin-top: 2px;
|
||||
border: 1px solid #aaa;
|
||||
background-color: #fff;
|
||||
box-shadow: 2px 2px 5px #888;
|
||||
z-index: 2;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
padding-bottom: 10px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<body onload="restore_options()">
|
||||
<div id="options_header">
|
||||
<a href="#" class="tabref" id="tabref_0" onmousedown="show_tab(0);">Settings</a>
|
||||
<a href="#" class="tabref" id="tabref_1" onmousedown="show_tab(1);">Public Keys</a>
|
||||
<a href="#" class="tabref" id="tabref_2" onmousedown="show_tab(2);">Private Keys</a>
|
||||
</div>
|
||||
<div id="tab_0" style="display: none">
|
||||
<h2>Composition Settings</h2>
|
||||
<ul><li><select id="composition_behavior" onchange="openpgp.config.config.composition_behavior = parseInt($('#composition_behavior').val()); openpgp.config.write();">
|
||||
<option value="0"> Sign & Encrypt</option>
|
||||
<option value="1"> Sign only</option>
|
||||
<option value="2"> Encrypt only</option>
|
||||
</select> when creating messages </li>
|
||||
<li><input type="checkbox" id="integrity" onchange="openpgp.config.config.integrity_protect = ($('#integrity').attr('checked') ? true: false); openpgp.config.write();">Generate integrity protected messages<br></li>
|
||||
<li><input type="checkbox" id="aaversion" onchange="openpgp.config.config.show_version = ($('#aaversion').attr('checked') ? true: false); openpgp.config.write();">Insert version into ASCII Armor<br></li>
|
||||
<li>PGP Key Server Host (no slashes): http://<input type="text" id="keyserver"><button type="submit" onclick="openpgp.config.config.keyserver = $('#keyserver').val(); openpgp.config.write();">Save</button></li>
|
||||
</ul>
|
||||
<h2>Encryption Algorithms</h2>
|
||||
<table><tr><td>Preferred Hash Algorithm:</td>
|
||||
<td><select id="hash_alg_select" onchange=" openpgp.config.config.prefer_hash_algorithm = parseInt($('#hash_alg_select').val()); openpgp.config.write();">
|
||||
<option value="1">MD5 (deprecated)</option>
|
||||
<option value="3">RIPE-MD/160</option>
|
||||
<option value="2">SHA-1 (GnuPG default)</option>
|
||||
<option value="11">SHA224</option>
|
||||
<option value="8">SHA256</option>
|
||||
<option value="9">SHA384</option>
|
||||
<option value="10">SHA512</option>
|
||||
</select></td></tr>
|
||||
<tr><td>Symmetric Cipher Algorithm:</td>
|
||||
<td><select id="cipher_alg_select" onchange="openpgp.config.config.encryption_cipher = parseInt($('#cipher_alg_select').val()); openpgp.config.write();">
|
||||
<option value="2">TripleDES (compatible mode)</option>
|
||||
<option value="3">CAST5</option>
|
||||
<option value="4">Blowfish</option>
|
||||
<option value="7">AES with 128-bit key</option>
|
||||
<option value="8">AES with 192-bit key</option>
|
||||
<option value="9">AES with 256-bit key (GnuPG default)</option>
|
||||
<option value="10">Twofish</option>
|
||||
</select></td></tr>
|
||||
<tr><td>Message Compression:</td>
|
||||
<td><select id="compression_alg_select" onchange="openpgp.config.config.compression = parseInt($('#compression_alg_select').val()); openpgp.config.write();">
|
||||
<option value="0">Plaintext (no compression)</option>
|
||||
<!-- <option value="1">ZIP </option> -->
|
||||
</select></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
<div id="tab_1" style="display: none">
|
||||
<h2>Public Keys in Keyring</h2>
|
||||
<table id="publicKeyTable">
|
||||
<tr><th>Key ID</th><th>Person</th><th>Length/Alg.</th><th>Status</th><th>Action</th></tr>
|
||||
</table>
|
||||
<h2>Import a Public Key</h2>
|
||||
<b><a href="#" onclick="$('#importSearchedKey').toggle();">Search Key</a></b><br>
|
||||
<div id="importSearchedKey" style="display: none;margin-left: 5px; border-left: 1px solid #aaa; padding-left: 5px;">
|
||||
KeyID or UserId: <input type="text" id="searchKeyText"></input><button type="submit" onclick="show_search_results();">search</button>
|
||||
<table id="searchKeyResults" style="display: none">
|
||||
<tr><th>Key ID</th><th>Person</th><th>Length/Alg.</th><th>CreatedOn</th><th>Action</th></tr>
|
||||
</table>
|
||||
</div>
|
||||
<b><a href="#" onclick="$('#importPastedPublicKey').toggle();">Import pasted public key</a></b><br>
|
||||
<div id="importPastedPublicKey" style="display: none; margin-left: 5px; border-left: 1px solid #aaa; padding-left: 5px;">
|
||||
<textarea rows="25" cols="80" id="importKeyTextfield"></textarea>
|
||||
<button onclick="importPublicKey($('#importKeyTextfield').val());">Import</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="tab_2" style="display: none; ">
|
||||
<h2>Private Keys in Keyring</h2>
|
||||
<table id="privateKeyTable">
|
||||
<tr><th>Key ID</th><th>Person</th><th>Length/Alg.</th><th>Expires on</th></tr>
|
||||
</table>
|
||||
<h2>Add a Private Key</h2>
|
||||
<b><a href="#" onclick="$('#generatePrivateKey').toggle();">Generate a new private key</a></b><br>
|
||||
<div id="generatePrivateKey" style="display: none; margin-left: 5px; border-left: 1px solid #aaa; padding-left: 5px;">
|
||||
<table>
|
||||
<tr><td>Length in Bits:</td>
|
||||
<td><select><option value="1024">1024</option><option value="2048" selected="selected">2048</option><option value="4096">4096</option></select></td></tr>
|
||||
<tr><td>Algorithm:</td>
|
||||
<td><input type="radio" checked="checked" name="algorithm" value="16"> DSA / Elgamal (Sign & Encrypt)<br>
|
||||
<input type="radio" name="algorithm" value="17"> DSA (Sign Only)<br>
|
||||
<input type="radio" name="algorithm" value="1"> RSA (Sign & Encrypt)<br></td></tr>
|
||||
<tr><td>Username:</td><td><input type="text" name="username"></input> (e.g "John Doe")</td></tr>
|
||||
<tr><td>Alias:</td><td><input type="text" name="alias"></input> (e.g "Johns Company")</td></tr>
|
||||
<tr><td>Email Address:</td><td><input type="text" name="email"></input> (e.g "john@doe.com")</td></tr>
|
||||
<tr><td>Expires on:</td><td><input type="radio" name="expiry" value="0" onclick="$('#expiryDate').attr('disabled','disabled');" checked="checked"></input>Never | <input type="radio" name="expiry" value="1" onclick="$('#expiryDate').removeAttr('disabled');">Date: <input type="text" id="expiryDate" disabled="disabled"></td></tr>
|
||||
<tr><td></td><td><button type="submit" onclick="generateKey();">Generate Key</button></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
<b><a href="#" onclick="$('#pastePrivateKey').toggle();">Paste a private key</a></b><br>
|
||||
<div id="pastePrivateKey" style="display: none; margin-left: 5px; border-left: 1px solid #aaa; padding-left: 5px;">
|
||||
<textarea rows="30" cols="80" id="importPrivateKeyTextfield"></textarea>
|
||||
<button onclick="importPrivateKey($('#importPrivateKeyTextfield').val()); $('#generatePrivateKey').toggle();">Import Key</button>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div id="debug"></div>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
1
resources/keyring.min.js
vendored
1
resources/keyring.min.js
vendored
|
@ -1 +0,0 @@
|
|||
/*! OpenPGPjs.org this is LGPL licensed code, see LICENSE/our website for more information.- v0.0.1 - 2014-01-02 */require=function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({fjvtDg:[function(a,b){b.exports=a("./keyring.js"),b.exports.localstore=a("./localstore.js")},{"./keyring.js":3,"./localstore.js":4}],keyring:[function(a,b){b.exports=a("fjvtDg")},{}],3:[function(a,b){var c=a("openpgp");b.exports=function(b){function d(a,b){a=a.toLowerCase();for(var c,d=b.getUserIds();c<d.length;c++)if(keyEmail=d[c].split("<")[1].split(">")[0].trim().toLowerCase(),keyEmail==a)return!0;return!1}function e(a,b){for(var d=b.getKeyIds(),e=0;e<d.length;e++)if(c.util.hexstrdump(d[e].write())==a)return!0;return!1}function f(a,b,d,e){for(var f=[],g=0;g<a.length;g++){var h=a[g];switch(e){case c.enums.packet.public_key:h.isPublic()&&b(d,h)&&f.push(h);break;case c.enums.packet.private_key:h.isPrivate()&&b(d,h)&&f.push(h)}}return f}b||(b=new(a("./localstore.js"))),this.storeHandler=b,this.keys=this.storeHandler.load(),this.store=function(){this.storeHandler.store(this.keys)},this.clear=function(){this.keys=[]},this.getPublicKeyForAddress=function(a){return f(this.keys,d,a,c.enums.packet.public_key)},this.getPrivateKeyForAddress=function(a){return f(this.keys,d,a,c.enums.packet.secret_key)},this.getKeysForKeyId=function(a){return f(this.keys,e,a,c.enums.packet.public_key)},this.importKey=function(a){return this.keys=this.keys.concat(c.key.readArmored(a).keys),!0},this.exportKey=function(a){return this.keys[a].armor()},this.removeKey=function(a){var b=this.keys.splice(a,1);return b},this.exportPublicKey=function(a){return this.keys[a].toPublic().armor()}}},{"./localstore.js":4}],4:[function(a,b){var c=a("openpgp");b.exports=function(){this.load=function(){var a=JSON.parse(window.localStorage.getItem("armoredKeys")),b=[];if(null!==a&&0!==a.length)for(var d,e=0;e<a.length;e++)d=c.key.readArmored(a[e]),b.push(d);return b},this.store=function(a){for(var b=[],c=0;c<a.length;c++)b.push(a[c].armor());window.localStorage.setItem("armoredKeys",JSON.stringify(b))}}},{}]},{},[]);
|
14155
resources/openpgp.js
14155
resources/openpgp.js
File diff suppressed because one or more lines are too long
6
resources/openpgp.min.js
vendored
6
resources/openpgp.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,27 +0,0 @@
|
|||
#!/bin/bash
|
||||
################################################################################
|
||||
# OpenPGP.js browser extension build script
|
||||
#
|
||||
# @author Alex
|
||||
################################################################################
|
||||
|
||||
echo "Setup..."
|
||||
dir_extension="plugins/chrome/"
|
||||
dir_webcode="webmail/googlemail.com/"
|
||||
dir_target="`mktemp -d browserext.XXX`"
|
||||
dir_build="build/";
|
||||
sh_pack="./scripts/pack.sh"
|
||||
file_key="resources/openpgpjs.pem"
|
||||
file_extension="build/openpgpjs.crx"
|
||||
mkdir -p "$dir_build"
|
||||
|
||||
echo "Copying files..."
|
||||
cp -R "$dir_extension"/* "$dir_target"
|
||||
cp -R "$dir_webcode"/* "$dir_target"
|
||||
|
||||
echo "Creating extension..."
|
||||
$sh_pack "$dir_target" "$file_key"
|
||||
|
||||
echo "Cleaning up..."
|
||||
rm -rf "$dir_target"
|
||||
mv "$dir_target".crx "$file_extension"
|
|
@ -1,7 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "Setup..."
|
||||
_src="src";
|
||||
|
||||
echo "Analyzing..."
|
||||
find "$_src" -name "*.js" -exec gjslint "{}" \;
|
|
@ -1,19 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "Setup..."
|
||||
_src="src";
|
||||
_tmp="resources/openpgp.js.tmp";
|
||||
_raw="resources/openpgp.js";
|
||||
_min="resources/openpgp.min.js";
|
||||
_compiler="resources/compiler.jar";
|
||||
_majorVersion=".1"
|
||||
:>"$_raw"
|
||||
:>"$_min"
|
||||
|
||||
echo "Concatenating..."
|
||||
find "$_src" -name "*.js" | sort | xargs cat > "$_tmp"
|
||||
sed "s/OpenPGP.js VERSION/OpenPGP.js v$_majorVersion.$(date +%Y%m%d)/g" "$_tmp" > "$_raw";
|
||||
rm "$_tmp";
|
||||
|
||||
echo "Minimizing..."
|
||||
java -jar "$_compiler" --js "$_raw" --js_output_file "$_min"
|
|
@ -1,44 +0,0 @@
|
|||
#!/bin/bash -e
|
||||
#
|
||||
# Purpose: Pack a Chromium extension directory into crx format
|
||||
|
||||
if test $# -ne 2; then
|
||||
echo "Usage: crxmake.sh <extension dir> <pem path>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dir=$1
|
||||
key=$2
|
||||
name=$(basename "$dir")
|
||||
crx="$name.crx"
|
||||
pub="$name.pub"
|
||||
sig="$name.sig"
|
||||
zip="$name.zip"
|
||||
trap 'rm -f "$pub" "$sig" "$zip"' EXIT
|
||||
|
||||
# zip up the crx dir
|
||||
cwd=$(pwd -P)
|
||||
(cd "$dir" && zip -qr -9 -X "$cwd/$zip" .)
|
||||
|
||||
# signature
|
||||
openssl sha1 -sha1 -binary -sign "$key" < "$zip" > "$sig"
|
||||
|
||||
# public key
|
||||
openssl rsa -pubout -outform DER < "$key" > "$pub" 2>/dev/null
|
||||
|
||||
byte_swap () {
|
||||
# Take "abcdefgh" and return it as "ghefcdab"
|
||||
echo "${1:6:2}${1:4:2}${1:2:2}${1:0:2}"
|
||||
}
|
||||
|
||||
crmagic_hex="4372 3234" # Cr24
|
||||
version_hex="0200 0000" # 2
|
||||
pub_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$pub" | awk '{print $5}')))
|
||||
sig_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$sig" | awk '{print $5}')))
|
||||
(
|
||||
echo "$crmagic_hex $version_hex $pub_len_hex $sig_len_hex" | xxd -r -p
|
||||
cat "$pub" "$sig" "$zip"
|
||||
) > "$crx"
|
||||
echo "Wrote $crx"
|
||||
|
||||
exit 0
|
|
@ -1,70 +0,0 @@
|
|||
// GPG4Browsers - An OpenPGP implementation in javascript
|
||||
// Copyright (C) 2011 Recurity Labs GmbH
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
// The google mail interface
|
||||
// these functions retrieve an email out of html
|
||||
var Gmail = {
|
||||
|
||||
getMail : function(callback) {
|
||||
var unquote_printable = function(text) {
|
||||
var result = "";
|
||||
while (text.indexOf("=") != -1) {
|
||||
var i = text.indexOf("=");
|
||||
result += text.substring(0, i);
|
||||
result += String.fromCharCode(parseInt(text.substring(i+1, i+3),16));
|
||||
text = text.substring(i+3);
|
||||
}
|
||||
result += text;
|
||||
return result;
|
||||
};
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "https://mail.google.com/mail/h/?v=om&th="+document.location.hash.split("/")[1],true);
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == 4) {
|
||||
var mail = new Object();
|
||||
var msg = xhr.responseText.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n");
|
||||
var header = msg.substring(0, msg.indexOf("\r\n\r\n")).replace(/\r\n /g," ").split("\r\n");
|
||||
mail.body = msg.substring(msg.indexOf("\r\n\r\n")+4);
|
||||
for (var i = 0; i < header.length; i++) {
|
||||
var split = header[i].split(": ")
|
||||
if (split[0] == "Content-Transfer-Encoding" && split[1] == "quoted-printable")
|
||||
mail.body = unquote_printable(mail.body);
|
||||
}
|
||||
mail.account = document.getElementsByTagName("title")[0].textContent.split(" - ")[2];
|
||||
|
||||
for (var i = 0; i < header.length; i++) {
|
||||
var split = header[i].split(": ");
|
||||
if (split.length < 2) continue;
|
||||
if (split[0] == "To")
|
||||
mail.to = split[1].split(", ");
|
||||
else if (split[0] == "CC")
|
||||
mail.cc = split[1].split(", ");
|
||||
else if (split[0] == "Subject")
|
||||
mail.subject = split[1];
|
||||
else if (split[0] == "From")
|
||||
mail.from = split[1];
|
||||
else if (split[0] == "Date")
|
||||
mail.date = new Date(split[1]);
|
||||
}
|
||||
callback(mail);
|
||||
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user