renamed GPG4Browsers to OpenPGP.js

This commit is contained in:
Alexander Willner 2012-01-15 00:22:14 +01:00
parent f7b505fa0b
commit 7475437d5a
4 changed files with 65 additions and 65 deletions

View File

@ -1,16 +1,16 @@
// 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
@ -21,7 +21,7 @@ if (window.location.href.indexOf("https://mail.google.com/mail/?view=cm") == 0)
} 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;
@ -40,8 +40,8 @@ function find_openpgp(text) {
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();
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;
@ -65,8 +65,8 @@ 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
chrome.extension.sendRequest(msg, function(response) {
// hide_pgp_alert(); // hide pgp alert after opening the openpgp window
});
});
}
@ -90,9 +90,9 @@ function show_pgp_alert() {
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 GPG4Browsers?"));
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 GPG4Browsers?"));
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);
@ -123,7 +123,7 @@ window.setInterval(function() {
* @param text containing the base64 block and the base64 encoded checksum
* @return true if the checksum was correct, false otherwise
*/
function pgp_verifyCheckSum(text) {
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,"");
@ -149,7 +149,7 @@ function getCheckSum(data) {
/**
* calculation routine for a CRC-24 checksum
* @param data
* @return
* @return
*/
function createcrc24 (data) {
var crc = 0xB704CE;

View File

@ -1,7 +1,7 @@
{
"name" : "GPG4Browsers",
"name" : "OpenPGP.js",
"version" : "0.1",
"description" : "An OpenPGP implementation in javascript",
"description" : "OpenPGP.js integration for Google Mail",
"background_page" : "background.html",
"options_page": "options.html",
"page_action" :
@ -22,7 +22,7 @@
"incoginto": "split",
"permissions": [
"https://mail.google.com/*",
"http://keyserver.linux.it/*",
"http://keyserver.linux.it/*",
"unlimitedStorage"
],
"icons" : {

View File

@ -7,7 +7,7 @@
<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 -->
<!-- crypto libs -->
<script type="text/javascript" src="js/ciphers/symmetricencryption/aes.js"></script>
<script type="text/javascript" src="js/ciphers/symmetricencryption/cast5.js"></script>
<script type="text/javascript" src="js/ciphers/symmetricencryption/dessrc.js"></script>
@ -59,7 +59,7 @@
<script type="text/javascript" src="js/openpgp.msg.publickey.js"></script>
<script type="text/javascript" src="js/util.js"></script>
<title>GPG4Browsers</title>
<title>OpenPGP.js</title>
</head>
<style>
@ -71,7 +71,7 @@
margin-top: -10px;
margin-left: -300px;
background-color: #8888FF;
z-index:4;
z-index:4;
border: 2px solid white;
box-shadow: 0px 0px 4px 4px #666;
background-color: #fff;
@ -88,7 +88,7 @@
margin-top: -235px;
margin-left: -300px;
background-color: #8888FF;
z-index:4;
z-index:4;
border: 2px solid white;
box-shadow: 0px 0px 4px 4px #666;
background-color: #fff;
@ -98,19 +98,19 @@
#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;
@ -141,15 +141,15 @@
border-radius: 5px;
width: 670px;
}
body {
background-color: #EFEFEF;
}
#keyselecttable tbody {
overflow: auto;
}
#displaySender, #displayCC,
#displaySender, #displayCC,
</style>
<script language="javascript">
@ -159,7 +159,7 @@ var account_email = null;
function start() {
openpgp.init();
chrome.extension.sendRequest({},
chrome.extension.sendRequest({},
function(response) {
request = response;
if (request.action == 0) { // compose message
@ -178,7 +178,7 @@ function start() {
function show_compose_window() {
$("#composerAddress").html(openpgp_encoding_html_encode(account_email));
$("#displayWindow").hide();
$("#displayWindow").hide();
$("#composeWindow").show();
if (openpgp.config.config.composition_behavior == 0) {
$('#sign_message').attr("checked","checked");
@ -202,7 +202,7 @@ function rfn(result) {
else {
current_message.decrypted = result;
$("#displayMessage").html(openpgp_encoding_html_encode(result));
}
}
}
function show_message_window(request) {
@ -269,7 +269,7 @@ function add_reciepient() {
}
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>"+
@ -277,7 +277,7 @@ function add_reciepient(method, name, isdisabled) {
"</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++;
}
@ -291,7 +291,7 @@ function prepare_send_mail() {
}
if ($('#encrypt_message').attr('checked') != null)
showKeySelection(addr);
else
else
showEncryptionConfirmation();
}
@ -299,7 +299,7 @@ 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);
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);
@ -316,7 +316,7 @@ function show_reply(reply_all) {
$("#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();
show_compose_window();
}
function quote_message (sender, date, msg) {
@ -331,7 +331,7 @@ function get_password(key, msg, sessionkey, successfn) {
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");
@ -354,15 +354,15 @@ function get_password(key, msg, sessionkey, successfn) {
$("#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();
$("#enterPassword").show();
$('#enterPasswordInput').focus();
}
@ -447,12 +447,12 @@ function showKeySelection(emailaddresses) {
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>');
@ -490,7 +490,7 @@ function showEncryptionConfirmation() {
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()));
@ -513,7 +513,7 @@ function showEncryptionConfirmation() {
function showEncryptionCancel() {
$('#keyselect').hide();
$('#block-bg').hide();
$('#block-bg').hide();
}
</script>
@ -558,7 +558,7 @@ function showEncryptionCancel() {
<button type="submit" onmousedown="showEncryptionCancel();">Cancel</button>
</div>
</div>
<div id="encryptionConfirmation">
<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>

View File

@ -1,14 +1,14 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>GPG4Browsers - PGP Message Options</title>
<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 -->
<!-- crypto libs -->
<script type="text/javascript" src="js/ciphers/symmetricencryption/aes.js"></script>
<script type="text/javascript" src="js/ciphers/symmetricencryption/cast5.js"></script>
<script type="text/javascript" src="js/ciphers/symmetricencryption/dessrc.js"></script>
@ -68,7 +68,7 @@ function save_options() {
}
function getAlgorithmString(publicKey) {
var result = publicKey.publicKeyPacket.MPIs[0].mpiByteLength*8+"/";
var result = publicKey.publicKeyPacket.MPIs[0].mpiByteLength*8+"/";
switch (publicKey.publicKeyPacket.publicKeyAlgorithm) {
case 1:
result += "RSA(S/E)";
@ -106,7 +106,7 @@ function getAlgorithmString(publicKey) {
break;
}
}
return result;
return result;
}
function encodeForHtml(text) {
if (text == null)
@ -130,7 +130,7 @@ function importPrivateKey(key) {
function restore_options() {
openpgp.init();
update_tables();
$('#cipher_alg_select').val(""+openpgp.config.config.encryption_cipher);
$('#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);
@ -148,7 +148,7 @@ function show_userIds(k) {
$('#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
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());
@ -160,12 +160,12 @@ function show_userIds(k) {
$('#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)
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)
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>");
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();
@ -289,11 +289,11 @@ function show_search_results() {
margin-bottom: 0px;
z-index: 1;
}
th {
text-align: left;
}
.tabref {
background-color: #eee;
border: 1px solid #aaa;
@ -301,7 +301,7 @@ function show_search_results() {
#options_header {
margin-left: 5px;
}
#publicKeyTable, #privateKeyTable, #searchKeyResults {
border: 1px solid #aaa;
}
@ -311,30 +311,30 @@ function show_search_results() {
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;
@ -346,7 +346,7 @@ function show_search_results() {
padding-bottom: 10px;
border-radius: 5px;
}
</style>
<body onload="restore_options()">
<div id="options_header">
@ -435,7 +435,7 @@ function show_search_results() {
</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;">
<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>