Enhance debugging output and fix escaped dashes.
This commit is contained in:
parent
e1908496c7
commit
63db9246c6
|
@ -3834,6 +3834,8 @@ function openpgp_crypto_verifySignature(algo, hash_algo, msg_MPIs, publickey_MPI
|
|||
util.print_error("PKCS1 padding in message or key incorrect. Aborting...");
|
||||
return false;
|
||||
}
|
||||
util.print_debug('hash: '+util.hexdump(hash));
|
||||
util.print_debug('calc_hash: '+util.hexdump(calc_hash));
|
||||
return hash == calc_hash;
|
||||
|
||||
case 16: // Elgamal (Encrypt-Only) [ELGAMAL] [HAC]
|
||||
|
@ -7420,7 +7422,7 @@ function openpgp_config() {
|
|||
keyserver: "keyserver.linux.it" // "pgp.mit.edu:11371"
|
||||
};
|
||||
|
||||
this.versionstring ="OpenPGP.js v.1.20131130";
|
||||
this.versionstring ="OpenPGP.js v.1.20131201";
|
||||
this.commentstring ="http://openpgpjs.org";
|
||||
/**
|
||||
* Reads the config out of the HTML5 local storage
|
||||
|
@ -7576,7 +7578,7 @@ function openpgp_encoding_deArmor(text) {
|
|||
// splittedtext[indexBase] - the message and checksum
|
||||
|
||||
// chunks separated by blank lines
|
||||
var msg = openpgp_encoding_split_headers(splittedtext[indexBase]);
|
||||
var msg = openpgp_encoding_split_headers(splittedtext[indexBase].replace(/^- /mg, ''));
|
||||
var msg_sum = openpgp_encoding_split_checksum(msg.body);
|
||||
|
||||
var data = {
|
||||
|
@ -7597,8 +7599,8 @@ function openpgp_encoding_deArmor(text) {
|
|||
// splittedtext[indexBase] - the message
|
||||
// splittedtext[indexBase + 1] - the signature and checksum
|
||||
|
||||
var msg = openpgp_encoding_split_headers(splittedtext[indexBase]);
|
||||
var sig = openpgp_encoding_split_headers(splittedtext[indexBase + 1]);
|
||||
var msg = openpgp_encoding_split_headers(splittedtext[indexBase].replace(/^- /mg, ''));
|
||||
var sig = openpgp_encoding_split_headers(splittedtext[indexBase + 1].replace(/^- /mg, ''));
|
||||
var sig_sum = openpgp_encoding_split_checksum(sig.body);
|
||||
|
||||
var result = {
|
||||
|
@ -11713,7 +11715,7 @@ function openpgp_packet_signature() {
|
|||
input.charCodeAt(mypos++))* 1000);
|
||||
|
||||
// storing data appended to data which gets verified
|
||||
this.signatureData = input.substring(position, mypos);
|
||||
this.signatureData = input.substring(sigpos, mypos);
|
||||
|
||||
// Eight-octet Key ID of signer.
|
||||
this.keyId = input.substring(mypos, mypos +8);
|
||||
|
@ -12122,6 +12124,11 @@ function openpgp_packet_signature() {
|
|||
.replace(/\r\n/g,"\n")
|
||||
.replace(/[\t ]+\n/g, "\n")
|
||||
.replace(/\n/g,"\r\n");
|
||||
if (openpgp.config.debug) {
|
||||
util.print_debug('tohash: '+util.hexdump(tohash));
|
||||
util.print_debug('signatureData: '+util.hexdump(this.signatureData));
|
||||
util.print_debug('trailer: '+util.hexdump(trailer));
|
||||
}
|
||||
if (this.version == 4) {
|
||||
this.verified = openpgp_crypto_verifySignature(this.publicKeyAlgorithm, this.hashAlgorithm,
|
||||
this.MPIs, key.obj.publicKeyPacket.MPIs, tohash+this.signatureData+trailer);
|
||||
|
@ -13368,6 +13375,8 @@ var Util = function() {
|
|||
return checksum.s;
|
||||
};
|
||||
|
||||
this.printLevel = { error: 1, warning: 2, info: 3, debug: 4 };
|
||||
|
||||
/**
|
||||
* Helper function to print a debug message. Debug
|
||||
* messages are only printed if
|
||||
|
@ -13381,8 +13390,7 @@ var Util = function() {
|
|||
*/
|
||||
this.print_debug = function(str) {
|
||||
if (openpgp.config.debug) {
|
||||
str = openpgp_encoding_html_encode(str);
|
||||
showMessages("<tt><p style=\"background-color: #ffffff; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\">"+str.replace(/\n/g,"<br>")+"</p></tt>");
|
||||
this.print_output(this.printLevel.debug, str);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -13401,8 +13409,7 @@ var Util = function() {
|
|||
this.print_debug_hexstr_dump = function(str,strToHex) {
|
||||
if (openpgp.config.debug) {
|
||||
str = str + this.hexstrdump(strToHex);
|
||||
str = openpgp_encoding_html_encode(str);
|
||||
showMessages("<tt><p style=\"background-color: #ffffff; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\">"+str.replace(/\n/g,"<br>")+"</p></tt>");
|
||||
this.print_output(this.printLevel.debug, str);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -13416,8 +13423,7 @@ var Util = function() {
|
|||
* containing the HTML encoded error message
|
||||
*/
|
||||
this.print_error = function(str) {
|
||||
str = openpgp_encoding_html_encode(str);
|
||||
showMessages("<p style=\"font-size: 80%; background-color: #FF8888; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\"><span style=\"color: #888;\"><b>ERROR:</b></span> "+str.replace(/\n/g,"<br>")+"</p>");
|
||||
this.print_output(this.printLevel.error, str);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -13430,15 +13436,39 @@ var Util = function() {
|
|||
* containing the HTML encoded info message
|
||||
*/
|
||||
this.print_info = function(str) {
|
||||
str = openpgp_encoding_html_encode(str);
|
||||
showMessages("<p style=\"font-size: 80%; background-color: #88FF88; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\"><span style=\"color: #888;\"><b>INFO:</b></span> "+str.replace(/\n/g,"<br>")+"</p>");
|
||||
this.print_output(this.printLevel.info, str);
|
||||
};
|
||||
|
||||
this.print_warning = function(str) {
|
||||
str = openpgp_encoding_html_encode(str);
|
||||
showMessages("<p style=\"font-size: 80%; background-color: #FFAA88; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\"><span style=\"color: #888;\"><b>WARNING:</b></span> "+str.replace(/\n/g,"<br>")+"</p>");
|
||||
this.print_output(this.printLevel.warning, str);
|
||||
};
|
||||
|
||||
this.print_output = function(level, str) {
|
||||
var html;
|
||||
str = openpgp_encoding_html_encode(str).replace(/\n/g,"<br>");
|
||||
if (level == this.printLevel.debug) {
|
||||
html = "<tt><p style=\"background-color: #ffffff; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\">"+str+"</p></tt>";
|
||||
} else {
|
||||
var color, heading;
|
||||
switch (level) {
|
||||
case this.printLevel.error:
|
||||
color = "FF8888";
|
||||
heading = "ERROR";
|
||||
break;
|
||||
case this.printLevel.warning:
|
||||
color = 'FFAA88';
|
||||
heading = "WARNING";
|
||||
break;
|
||||
case this.printLevel.info:
|
||||
color = '88FF88';
|
||||
heading = 'INFO';
|
||||
break;
|
||||
}
|
||||
html = "<p style=\"font-size: 80%; background-color: #"+color+"; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\"><span style=\"color: #888;\"><b>"+heading+":</b></span>"+str+"</p>";
|
||||
}
|
||||
showMessages(html);
|
||||
}
|
||||
|
||||
this.getLeftNBits = function (string, bitcount) {
|
||||
var rest = bitcount % 8;
|
||||
if (rest == 0)
|
||||
|
|
48
resources/openpgp.min.js
vendored
48
resources/openpgp.min.js
vendored
|
@ -112,8 +112,8 @@ function openpgp_crypto_asymetricDecrypt(b,a,c,d){switch(b){case 1:case 2:case 3
|
|||
function openpgp_crypto_getPrefixRandom(b){switch(b){case 2:case 3:case 4:return openpgp_crypto_getRandomBytes(8);case 7:case 8:case 9:case 10:return openpgp_crypto_getRandomBytes(16);default:return null}}
|
||||
function openpgp_crypto_MDCSystemBytes(b,a,c){util.print_debug_hexstr_dump("openpgp_crypto_symmetricDecrypt:\nencrypteddata:",c);switch(b){case 0:return c;case 2:return openpgp_cfb_mdc(desede,8,a,c,openpgp_cfb);case 3:return openpgp_cfb_mdc(cast5_encrypt,8,a,c);case 4:return openpgp_cfb_mdc(BFencrypt,8,a,c);case 7:case 8:case 9:return openpgp_cfb_mdc(AESencrypt,16,keyExpansion(a),c);case 10:return openpgp_cfb_mdc(TFencrypt,16,a,c);case 1:util.print_error(""+(1==b?"IDEA Algorithm not implemented":
|
||||
"Twofish Algorithm not implemented"))}return null}function openpgp_crypto_generateSessionKey(b){switch(b){case 2:case 8:return openpgp_crypto_getRandomBytes(24);case 3:case 4:case 7:return util.print_debug("length = 16:\n"+util.hexstrdump(openpgp_crypto_getRandomBytes(16))),openpgp_crypto_getRandomBytes(16);case 9:case 10:return openpgp_crypto_getRandomBytes(32)}return null}
|
||||
function openpgp_crypto_verifySignature(b,a,c,d,e){var f=openpgp_crypto_hashData(a,e);switch(b){case 1:case 2:case 3:e=new RSA;b=d[0].toBigInteger();d=d[1].toBigInteger();c=c[0].toBigInteger();d=e.verify(c,d,b);a=openpgp_encoding_emsa_pkcs1_decode(a,d.toMPI().substring(2));return-1==a?(util.print_error("PKCS1 padding in message or key incorrect. Aborting..."),!1):a==f;case 16:return util.print_error("signing with Elgamal is not defined in the OpenPGP standard."),null;case 17:var b=new DSA,f=c[0].toBigInteger(),
|
||||
c=c[1].toBigInteger(),g=d[0].toBigInteger(),h=d[1].toBigInteger(),j=d[2].toBigInteger(),d=d[3].toBigInteger(),d=b.verify(a,f,c,e,g,h,j,d);return 0==d.compareTo(f);default:return null}}
|
||||
function openpgp_crypto_verifySignature(b,a,c,d,e){var f=openpgp_crypto_hashData(a,e);switch(b){case 1:case 2:case 3:e=new RSA;b=d[0].toBigInteger();d=d[1].toBigInteger();c=c[0].toBigInteger();d=e.verify(c,d,b);a=openpgp_encoding_emsa_pkcs1_decode(a,d.toMPI().substring(2));if(-1==a)return util.print_error("PKCS1 padding in message or key incorrect. Aborting..."),!1;util.print_debug("hash: "+util.hexdump(a));util.print_debug("calc_hash: "+util.hexdump(f));return a==f;case 16:return util.print_error("signing with Elgamal is not defined in the OpenPGP standard."),
|
||||
null;case 17:var b=new DSA,f=c[0].toBigInteger(),c=c[1].toBigInteger(),g=d[0].toBigInteger(),h=d[1].toBigInteger(),j=d[2].toBigInteger(),d=d[3].toBigInteger(),d=b.verify(a,f,c,e,g,h,j,d);return 0==d.compareTo(f);default:return null}}
|
||||
function openpgp_crypto_signData(b,a,c,d,e){switch(a){case 1:case 2:case 3:var a=new RSA,d=d[0].toBigInteger(),f=c[0].toBigInteger(),b=openpgp_encoding_emsa_pkcs1_encode(b,e,c[0].mpiByteLength);util.print_debug("signing using RSA");return a.sign(b,d,f).toMPI();case 17:a=new DSA;util.print_debug("DSA Sign: q size in Bytes:"+c[1].getByteLength());var f=c[0].toBigInteger(),g=c[1].toBigInteger(),h=c[2].toBigInteger();c[3].toBigInteger();c=d[0].toBigInteger();b=a.sign(b,e,h,f,g,c);util.print_debug("signing using DSA\n result:"+
|
||||
util.hexstrdump(b[0])+"|"+util.hexstrdump(b[1]));return b[0]+b[1];case 16:return util.print_debug("signing with Elgamal is not defined in the OpenPGP standard."),null;default:return null}}function openpgp_crypto_hashData(b,a){var c=null;switch(b){case 1:c=MD5(a);break;case 2:c=str_sha1(a);break;case 3:c=RMDstring(a);break;case 8:c=str_sha256(a);break;case 9:c=str_sha384(a);break;case 10:c=str_sha512(a);break;case 11:c=str_sha224(a)}return c}
|
||||
function openpgp_crypto_getHashByteLength(b){switch(b){case 1:return 16;case 2:case 3:return 20;case 8:return 32;case 9:return 48;case 10:return 64;case 11:return 28}return null}function openpgp_crypto_getRandomBytes(b){for(var a="",c=0;c<b;c++)a+=String.fromCharCode(openpgp_crypto_getSecureRandomOctet());return a}function openpgp_crypto_getPseudoRandom(b,a){return Math.round(Math.random()*(a-b))+b}
|
||||
|
@ -286,13 +286,13 @@ JXG.Util.asciiCharCodeAt=function(b,a){var c=b.charCodeAt(a);if(255<c)switch(c){
|
|||
151;break;case 732:c=152;break;case 8482:c=153;break;case 353:c=154;break;case 8250:c=155;break;case 339:c=156;break;case 382:c=158;break;case 376:c=159}return c};
|
||||
JXG.Util.utf8Decode=function(b){var a=[],c=0,d=0,e=0,f;if(!JXG.exists(b))return"";for(;c<b.length;)d=b.charCodeAt(c),128>d?(a.push(String.fromCharCode(d)),c++):191<d&&224>d?(e=b.charCodeAt(c+1),a.push(String.fromCharCode((d&31)<<6|e&63)),c+=2):(e=b.charCodeAt(c+1),f=b.charCodeAt(c+2),a.push(String.fromCharCode((d&15)<<12|(e&63)<<6|f&63)),c+=3);return a.join("")};
|
||||
JXG.Util.genUUID=function(){for(var b="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),a=Array(36),c=0,d,e=0;36>e;e++)8==e||13==e||18==e||23==e?a[e]="-":14==e?a[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,a[e]=b[19==e?d&3|8:d]);return a.join("")};
|
||||
function openpgp_config(){this.config=null;this.default_config={prefer_hash_algorithm:8,encryption_cipher:9,compression:1,show_version:!0,show_comment:!0,integrity_protect:!0,composition_behavior:0,keyserver:"keyserver.linux.it"};this.versionstring="OpenPGP.js v.1.20131130";this.commentstring="http://openpgpjs.org";this.debug=!1;this.read=function(){var b=JSON.parse(window.localStorage.getItem("config"));null==b?(this.config=this.default_config,this.write()):this.config=b};this.write=function(){window.localStorage.setItem("config",
|
||||
function openpgp_config(){this.config=null;this.default_config={prefer_hash_algorithm:8,encryption_cipher:9,compression:1,show_version:!0,show_comment:!0,integrity_protect:!0,composition_behavior:0,keyserver:"keyserver.linux.it"};this.versionstring="OpenPGP.js v.1.20131201";this.commentstring="http://openpgpjs.org";this.debug=!1;this.read=function(){var b=JSON.parse(window.localStorage.getItem("config"));null==b?(this.config=this.default_config,this.write()):this.config=b};this.write=function(){window.localStorage.setItem("config",
|
||||
JSON.stringify(this.config))}}var b64s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
function s2r(b){var a,c,d,e="",f=0,g=0,h=b.length;for(d=0;d<h;d++)c=b.charCodeAt(d),0==g?(e+=b64s.charAt(c>>2&63),a=(c&3)<<4):1==g?(e+=b64s.charAt(a|c>>4&15),a=(c&15)<<2):2==g&&(e+=b64s.charAt(a|c>>6&3),f+=1,0==f%60&&(e+="\n"),e+=b64s.charAt(c&63)),f+=1,0==f%60&&(e+="\n"),g+=1,3==g&&(g=0);0<g&&(e+=b64s.charAt(a),f+=1,0==f%60&&(e+="\n"),e+="=",f+=1);1==g&&(0==f%60&&(e+="\n"),e+="=");"\n"===e.charAt(e.length-1)&&(e=e.slice(0,-1));return e}
|
||||
function r2s(b){var a,c,d="",e=0,f=0,g=b.length;for(c=0;c<g;c++)a=b64s.indexOf(b.charAt(c)),0<=a&&(e&&(d+=String.fromCharCode(f|a>>6-e&255)),e=e+2&7,f=a<<e&255);return d}
|
||||
function openpgp_encoding_deArmor(b){var a=/^-----[^-]+-----$\n/m,b=b.replace(/\r/g,""),c=openpgp_encoding_get_type(b),d=b.split(a),e=1;b.search(a)!=d[0].length&&(e=0);if(2!=c){b=openpgp_encoding_split_headers(d[e]);d=openpgp_encoding_split_checksum(b.body);c={openpgp:openpgp_encoding_base64_decode(d.body),type:c};if(verifyCheckSum(c.openpgp,d.checksum))return c;util.print_error("Ascii armor integrity check on message failed: '"+d.checksum+"' should be '"+getCheckSum(c)+"'");return!1}b=openpgp_encoding_split_headers(d[e]);
|
||||
d=openpgp_encoding_split_headers(d[e+1]);d=openpgp_encoding_split_checksum(d.body);c={text:b.body.replace(/\n$/,"").replace(/\n/g,"\r\n"),openpgp:openpgp_encoding_base64_decode(d.body),type:c};if(verifyCheckSum(c.openpgp,d.checksum))return c;util.print_error("Ascii armor integrity check on message failed");return!1}function openpgp_encoding_split_headers(b){var a="",c=b,d=/^[\t ]*\n/m.exec(b);null!=d&&(a=b.slice(0,d.index),c=b.slice(d.index+d[0].length));return{headers:a,body:c}}
|
||||
function openpgp_encoding_split_checksum(b){var a=b,c="",d=/^=/m.exec(b);null!=d&&(a=b.slice(0,d.index),c=b.slice(d.index+1));return{body:a,checksum:c}}
|
||||
function openpgp_encoding_deArmor(b){var a=/^-----[^-]+-----$\n/m,b=b.replace(/\r/g,""),c=openpgp_encoding_get_type(b),d=b.split(a),e=1;b.search(a)!=d[0].length&&(e=0);if(2!=c){b=openpgp_encoding_split_headers(d[e].replace(/^- /mg,""));d=openpgp_encoding_split_checksum(b.body);c={openpgp:openpgp_encoding_base64_decode(d.body),type:c};if(verifyCheckSum(c.openpgp,d.checksum))return c;util.print_error("Ascii armor integrity check on message failed: '"+d.checksum+"' should be '"+getCheckSum(c)+"'");return!1}b=
|
||||
openpgp_encoding_split_headers(d[e].replace(/^- /mg,""));d=openpgp_encoding_split_headers(d[e+1].replace(/^- /mg,""));d=openpgp_encoding_split_checksum(d.body);c={text:b.body.replace(/\n$/,"").replace(/\n/g,"\r\n"),openpgp:openpgp_encoding_base64_decode(d.body),type:c};if(verifyCheckSum(c.openpgp,d.checksum))return c;util.print_error("Ascii armor integrity check on message failed");return!1}
|
||||
function openpgp_encoding_split_headers(b){var a="",c=b,d=/^[\t ]*\n/m.exec(b);null!=d&&(a=b.slice(0,d.index),c=b.slice(d.index+d[0].length));return{headers:a,body:c}}function openpgp_encoding_split_checksum(b){var a=b,c="",d=/^=/m.exec(b);null!=d&&(a=b.slice(0,d.index),c=b.slice(d.index+1));return{body:a,checksum:c}}
|
||||
function openpgp_encoding_get_type(b){b=b.match(/^-----([^-]+)-----$\n/m);if(b[1].match(/BEGIN PGP MESSAGE, PART \d+\/\d+/))return 0;if(b[1].match(/BEGIN PGP MESSAGE, PART \d+/))return 1;if(b[1].match(/BEGIN PGP SIGNED MESSAGE/))return 2;if(b[1].match(/BEGIN PGP MESSAGE/))return 3;if(b[1].match(/BEGIN PGP PUBLIC KEY BLOCK/))return 4;if(b[1].match(/BEGIN PGP PRIVATE KEY BLOCK/))return 5}
|
||||
function openpgp_encoding_armor_addheader(){var b="";openpgp.config.config.show_version&&(b+="Version: "+openpgp.config.versionstring+"\r\n");openpgp.config.config.show_comment&&(b+="Comment: "+openpgp.config.commentstring+"\r\n");return b+"\r\n"}
|
||||
function openpgp_encoding_armor(b,a,c,d){var e="";switch(b){case 0:e=e+("-----BEGIN PGP MESSAGE, PART "+c+"/"+d+"-----\r\n")+openpgp_encoding_armor_addheader();e+=openpgp_encoding_base64_encode(a);e+="\r\n="+getCheckSum(a)+"\r\n";e+="-----END PGP MESSAGE, PART "+c+"/"+d+"-----\r\n";break;case 1:e=e+("-----BEGIN PGP MESSAGE, PART "+c+"-----\r\n")+openpgp_encoding_armor_addheader();e+=openpgp_encoding_base64_encode(a);e+="\r\n="+getCheckSum(a)+"\r\n";e+="-----END PGP MESSAGE, PART "+c+"-----\r\n";break;
|
||||
|
@ -430,19 +430,19 @@ g+" @:"+e+" subplen:"+f+" len:"+d),f+1;default:return util.print_error("openpgp.
|
|||
this.keyId:null};this.write_message_signature=function(a,c,d){var e=d.privateKeyPacket.publicKey,f=d.getPreferredSignatureHashAlgorithm(),g=String.fromCharCode(4),g=g+String.fromCharCode(a),g=g+String.fromCharCode(e.publicKeyAlgorithm),g=g+String.fromCharCode(f),a=Math.round((new Date).getTime()/1E3),a=b(2,""+String.fromCharCode(a>>24&255)+String.fromCharCode(a>>16&255)+String.fromCharCode(a>>8&255)+String.fromCharCode(a&255)),h=b(16,d.getKeyId()),g=g+String.fromCharCode(a.length+h.length>>8&255),
|
||||
g=g+String.fromCharCode(a.length+h.length&255),g=g+a+h,a=""+String.fromCharCode(4),a=a+String.fromCharCode(255),a=a+String.fromCharCode(g.length>>24),a=a+String.fromCharCode(g.length>>16&255),a=a+String.fromCharCode(g.length>>8&255),a=a+String.fromCharCode(g.length&255),h=String.fromCharCode(0),h=h+String.fromCharCode(0),j=openpgp_crypto_hashData(f,c+g+a);util.print_debug("DSA Signature is calculated with:|"+c+g+a+"|\n"+util.hexstrdump(c+g+a)+"\n hash:"+util.hexstrdump(j));h+=j.charAt(0);h+=j.charAt(1);
|
||||
h+=openpgp_crypto_signData(f,d.privateKeyPacket.publicKey.publicKeyAlgorithm,e.MPIs,d.privateKeyPacket.secMPIs,c+g+a);return{openpgp:openpgp_packet.write_packet_header(2,(g+h).length)+g+h,hash:util.get_hashAlgorithmString(f)}};this.verify=function(a,b){var d;d=""+String.fromCharCode(this.version);d+=String.fromCharCode(255);d+=String.fromCharCode(this.signatureData.length>>24);d+=String.fromCharCode(this.signatureData.length>>16&255);d+=String.fromCharCode(this.signatureData.length>>8&255);d+=String.fromCharCode(this.signatureData.length&
|
||||
255);switch(this.signatureType){case 0:this.verified=4==this.version?openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.obj.publicKeyPacket.MPIs,a+this.signatureData+d):3==this.version?openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.obj.publicKeyPacket.MPIs,a+this.signatureData):!1;break;case 1:var e=a.replace(/\r\n/g,"\n").replace(/[\t ]+\n/g,"\n").replace(/\n/g,"\r\n");this.verified=4==this.version?openpgp_crypto_verifySignature(this.publicKeyAlgorithm,
|
||||
this.hashAlgorithm,this.MPIs,b.obj.publicKeyPacket.MPIs,e+this.signatureData+d):3==this.version?openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.obj.publicKeyPacket.MPIs,e+this.signatureData):!1;break;case 2:this.verified=4==this.version?openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.obj.publicKeyPacket.MPIs,this.signatureData+d):!1;break;case 16:case 17:case 18:case 19:case 48:this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm,
|
||||
this.hashAlgorithm,this.MPIs,b.MPIs,a+this.signatureData+d);break;case 24:if(3==this.version){this.verified=!1;break}this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.MPIs,a+this.signatureData+d);break;case 25:case 31:case 32:case 40:this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.MPIs,a+this.signatureData+d);break;default:util.print_error("openpgp.packet.signature.js\nsignature verification for type"+
|
||||
this.signatureType+" not implemented"),this.verified=!1}return this.verified};this.read_packet=function(a,b,d){this.data=a.substring(b,b+d);if(0>d)return util.print_debug("openpgp.packet.signature.js\nopenpgp_packet_signature read_packet length < 0 @:"+b),null;var e=b;this.packetLength=d;this.version=a.charCodeAt(e++);switch(this.version){case 3:5!=a.charCodeAt(e++)&&util.print_debug("openpgp.packet.signature.js\ninvalid One-octet length of following hashed material. MUST be 5. @:"+(e-1));this.signatureType=
|
||||
a.charCodeAt(e++);this.creationTime=new Date(1E3*(a.charCodeAt(e++)<<24|a.charCodeAt(e++)<<16|a.charCodeAt(e++)<<8|a.charCodeAt(e++)));this.signatureData=a.substring(b,e);this.keyId=a.substring(e,e+8);e+=8;this.publicKeyAlgorithm=a.charCodeAt(e++);this.hashAlgorithm=a.charCodeAt(e++);this.signedHashValue=a.charCodeAt(e++)<<8|a.charCodeAt(e++);d=0;0<this.publicKeyAlgorithm&&4>this.publicKeyAlgorithm?d=1:17==this.publicKeyAlgorithm&&(d=2);this.MPIs=[];for(var f=0;f<d;f++)this.MPIs[f]=new openpgp_type_mpi,
|
||||
null!=this.MPIs[f].read(a,e,e-b)&&!this.packetLength<e-b?e+=this.MPIs[f].packetLength:util.print_error("signature contains invalid MPI @:"+e);break;case 4:this.signatureType=a.charCodeAt(e++);this.publicKeyAlgorithm=a.charCodeAt(e++);this.hashAlgorithm=a.charCodeAt(e++);f=(a.charCodeAt(e++)<<8)+a.charCodeAt(e++);for(d=0;f!=d;)f<d&&util.print_debug("openpgp.packet.signature.js\nhashed missed something: "+e+" c:"+f+" l:"+d),d+=this._raw_read_signature_sub_packet(a,e+d,f-d);e+=f;this.signatureData=a.substring(b,
|
||||
e);f=(a.charCodeAt(e++)<<8)+a.charCodeAt(e++);for(d=0;f!=d;)f<d&&util.print_debug("openpgp.packet.signature.js\nmissed something: "+d+" c:"+f+" l:"+d),d+=this._raw_read_signature_sub_packet(a,e+d,f-d);e+=f;this.signedHashValue=a.charCodeAt(e++)<<8|a.charCodeAt(e++);d=0;0<this.publicKeyAlgorithm&&4>this.publicKeyAlgorithm?d=1:17==this.publicKeyAlgorithm&&(d=2);this.MPIs=[];for(f=0;f<d;f++)this.MPIs[f]=new openpgp_type_mpi,null!=this.MPIs[f].read(a,e,e-b)&&!this.packetLength<e-b?e+=this.MPIs[f].packetLength:
|
||||
util.print_error("signature contains invalid MPI @:"+e);break;default:util.print_error("openpgp.packet.signature.js\nunknown signature packet version"+this.version)}return this};this.toString=function(){for(var a=3==this.version?"5.2. Signature Packet (Tag 2)\nPacket Length: :"+this.packetLength+"\nPacket version: :"+this.version+"\nOne-octet signature type :"+this.signatureType+"\nFour-octet creation time. :"+this.creationTime+"\nEight-octet Key ID of signer. :"+
|
||||
util.hexidump(this.keyId)+"\nOne-octet public-key algorithm. :"+this.publicKeyAlgorithm+"\nOne-octet hash algorithm. :"+this.hashAlgorithm+"\nTwo-octet field holding left\n 16 bits of signed hash value. :"+this.signedHashValue+"\n":"5.2. Signature Packet (Tag 2)\nPacket Length: :"+this.packetLength+"\nPacket version: :"+this.version+"\nOne-octet signature type :"+this.signatureType+"\nOne-octet public-key algorithm. :"+this.publicKeyAlgorithm+
|
||||
"\nOne-octet hash algorithm. :"+this.hashAlgorithm+"\nTwo-octet field holding left\n 16 bits of signed hash value. :"+this.signedHashValue+"\nSignature Creation Time :"+this.creationTime+"\nSignature Expiration Time :"+this.signatureExpirationTime+"\nSignature Never Expires :"+this.signatureNeverExpires+"\nExportable Certification :"+this.exportable+"\nTrust Signature level: :"+this.trustLevel+" amount"+this.trustAmount+"\nRegular Expression :"+
|
||||
this.regular_expression+"\nRevocable :"+this.revocable+"\nKey Expiration Time :"+this.keyExpirationTime+" "+this.keyNeverExpires+"\nPreferred Symmetric Algorithms :"+this.preferredSymmetricAlgorithms+"\nRevocation Key\n ( 1 octet of class, :"+this.revocationKeyClass+"\n 1 octet of public-key ID, :"+this.revocationKeyAlgorithm+"\n 20 octets of fingerprint) :"+this.revocationKeyFingerprint+"\nIssuer :"+
|
||||
util.hexstrdump(this.issuerKeyId)+"\nPreferred Hash Algorithms :"+this.preferredHashAlgorithms+"\nPreferred Compression Alg. :"+this.preferredCompressionAlgorithms+"\nKey Server Preferences :"+this.keyServerPreferences+"\nPreferred Key Server :"+this.preferredKeyServer+"\nPrimary User ID :"+this.isPrimaryUserID+"\nPolicy URI :"+this.policyURI+"\nKey Flags :"+this.keyFlags+"\nSigner's User ID :"+
|
||||
this.signersUserId+"\nNotation :"+this.notationName+" = "+this.notationValue+"\nReason for Revocation\n Flag :"+this.reasonForRevocationFlag+"\n Reason :"+this.reasonForRevocationString+"\nMPI:\n",b=0;b<this.MPIs.length;b++)a+=this.MPIs[b].toString();return a}}
|
||||
255);switch(this.signatureType){case 0:this.verified=4==this.version?openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.obj.publicKeyPacket.MPIs,a+this.signatureData+d):3==this.version?openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.obj.publicKeyPacket.MPIs,a+this.signatureData):!1;break;case 1:var e=a.replace(/\r\n/g,"\n").replace(/[\t ]+\n/g,"\n").replace(/\n/g,"\r\n");openpgp.config.debug&&(util.print_debug("tohash: "+util.hexdump(e)),
|
||||
util.print_debug("signatureData: "+util.hexdump(this.signatureData)),util.print_debug("trailer: "+util.hexdump(d)));this.verified=4==this.version?openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.obj.publicKeyPacket.MPIs,e+this.signatureData+d):3==this.version?openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.obj.publicKeyPacket.MPIs,e+this.signatureData):!1;break;case 2:this.verified=4==this.version?openpgp_crypto_verifySignature(this.publicKeyAlgorithm,
|
||||
this.hashAlgorithm,this.MPIs,b.obj.publicKeyPacket.MPIs,this.signatureData+d):!1;break;case 16:case 17:case 18:case 19:case 48:this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.MPIs,a+this.signatureData+d);break;case 24:if(3==this.version){this.verified=!1;break}this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.MPIs,a+this.signatureData+d);break;case 25:case 31:case 32:case 40:this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm,
|
||||
this.hashAlgorithm,this.MPIs,b.MPIs,a+this.signatureData+d);break;default:util.print_error("openpgp.packet.signature.js\nsignature verification for type"+this.signatureType+" not implemented"),this.verified=!1}return this.verified};this.read_packet=function(a,b,d){this.data=a.substring(b,b+d);if(0>d)return util.print_debug("openpgp.packet.signature.js\nopenpgp_packet_signature read_packet length < 0 @:"+b),null;var e=b;this.packetLength=d;this.version=a.charCodeAt(e++);switch(this.version){case 3:5!=
|
||||
a.charCodeAt(e++)&&util.print_debug("openpgp.packet.signature.js\ninvalid One-octet length of following hashed material. MUST be 5. @:"+(e-1));d=e;this.signatureType=a.charCodeAt(e++);this.creationTime=new Date(1E3*(a.charCodeAt(e++)<<24|a.charCodeAt(e++)<<16|a.charCodeAt(e++)<<8|a.charCodeAt(e++)));this.signatureData=a.substring(d,e);this.keyId=a.substring(e,e+8);e+=8;this.publicKeyAlgorithm=a.charCodeAt(e++);this.hashAlgorithm=a.charCodeAt(e++);this.signedHashValue=a.charCodeAt(e++)<<8|a.charCodeAt(e++);
|
||||
d=0;0<this.publicKeyAlgorithm&&4>this.publicKeyAlgorithm?d=1:17==this.publicKeyAlgorithm&&(d=2);this.MPIs=[];for(var f=0;f<d;f++)this.MPIs[f]=new openpgp_type_mpi,null!=this.MPIs[f].read(a,e,e-b)&&!this.packetLength<e-b?e+=this.MPIs[f].packetLength:util.print_error("signature contains invalid MPI @:"+e);break;case 4:this.signatureType=a.charCodeAt(e++);this.publicKeyAlgorithm=a.charCodeAt(e++);this.hashAlgorithm=a.charCodeAt(e++);f=(a.charCodeAt(e++)<<8)+a.charCodeAt(e++);for(d=0;f!=d;)f<d&&util.print_debug("openpgp.packet.signature.js\nhashed missed something: "+
|
||||
e+" c:"+f+" l:"+d),d+=this._raw_read_signature_sub_packet(a,e+d,f-d);e+=f;this.signatureData=a.substring(b,e);f=(a.charCodeAt(e++)<<8)+a.charCodeAt(e++);for(d=0;f!=d;)f<d&&util.print_debug("openpgp.packet.signature.js\nmissed something: "+d+" c:"+f+" l:"+d),d+=this._raw_read_signature_sub_packet(a,e+d,f-d);e+=f;this.signedHashValue=a.charCodeAt(e++)<<8|a.charCodeAt(e++);d=0;0<this.publicKeyAlgorithm&&4>this.publicKeyAlgorithm?d=1:17==this.publicKeyAlgorithm&&(d=2);this.MPIs=[];for(f=0;f<d;f++)this.MPIs[f]=
|
||||
new openpgp_type_mpi,null!=this.MPIs[f].read(a,e,e-b)&&!this.packetLength<e-b?e+=this.MPIs[f].packetLength:util.print_error("signature contains invalid MPI @:"+e);break;default:util.print_error("openpgp.packet.signature.js\nunknown signature packet version"+this.version)}return this};this.toString=function(){for(var a=3==this.version?"5.2. Signature Packet (Tag 2)\nPacket Length: :"+this.packetLength+"\nPacket version: :"+this.version+"\nOne-octet signature type :"+
|
||||
this.signatureType+"\nFour-octet creation time. :"+this.creationTime+"\nEight-octet Key ID of signer. :"+util.hexidump(this.keyId)+"\nOne-octet public-key algorithm. :"+this.publicKeyAlgorithm+"\nOne-octet hash algorithm. :"+this.hashAlgorithm+"\nTwo-octet field holding left\n 16 bits of signed hash value. :"+this.signedHashValue+"\n":"5.2. Signature Packet (Tag 2)\nPacket Length: :"+this.packetLength+"\nPacket version: :"+this.version+
|
||||
"\nOne-octet signature type :"+this.signatureType+"\nOne-octet public-key algorithm. :"+this.publicKeyAlgorithm+"\nOne-octet hash algorithm. :"+this.hashAlgorithm+"\nTwo-octet field holding left\n 16 bits of signed hash value. :"+this.signedHashValue+"\nSignature Creation Time :"+this.creationTime+"\nSignature Expiration Time :"+this.signatureExpirationTime+"\nSignature Never Expires :"+this.signatureNeverExpires+"\nExportable Certification :"+
|
||||
this.exportable+"\nTrust Signature level: :"+this.trustLevel+" amount"+this.trustAmount+"\nRegular Expression :"+this.regular_expression+"\nRevocable :"+this.revocable+"\nKey Expiration Time :"+this.keyExpirationTime+" "+this.keyNeverExpires+"\nPreferred Symmetric Algorithms :"+this.preferredSymmetricAlgorithms+"\nRevocation Key\n ( 1 octet of class, :"+this.revocationKeyClass+"\n 1 octet of public-key ID, :"+
|
||||
this.revocationKeyAlgorithm+"\n 20 octets of fingerprint) :"+this.revocationKeyFingerprint+"\nIssuer :"+util.hexstrdump(this.issuerKeyId)+"\nPreferred Hash Algorithms :"+this.preferredHashAlgorithms+"\nPreferred Compression Alg. :"+this.preferredCompressionAlgorithms+"\nKey Server Preferences :"+this.keyServerPreferences+"\nPreferred Key Server :"+this.preferredKeyServer+"\nPrimary User ID :"+this.isPrimaryUserID+
|
||||
"\nPolicy URI :"+this.policyURI+"\nKey Flags :"+this.keyFlags+"\nSigner's User ID :"+this.signersUserId+"\nNotation :"+this.notationName+" = "+this.notationValue+"\nReason for Revocation\n Flag :"+this.reasonForRevocationFlag+"\n Reason :"+this.reasonForRevocationString+"\nMPI:\n",b=0;b<this.MPIs.length;b++)a+=this.MPIs[b].toString();return a}}
|
||||
function openpgp_packet_userattribute(){this.tagType=17;this.certificationSignatures=[];this.certificationRevocationSignatures=[];this.revocationSignatures=[];this.parentNode=null;this.read_packet=function(b,a,c){var d=0;this.packetLength=c;this.userattributes=[];for(var e=a;c!=d;){var f=0;192>b.charCodeAt(e)?(packet_length=b.charCodeAt(e++),f=1):192<=b.charCodeAt(e)&&224>b.charCodeAt(e)?(packet_length=(b.charCodeAt(e++)-192<<8)+b.charCodeAt(e++)+192,f=2):223<b.charCodeAt(e)&&255>b.charCodeAt(e)?
|
||||
(packet_length=1<<(b.charCodeAt(e++)&31),f=1):(f=5,e++,packet_length=b.charCodeAt(e++)<<24|b.charCodeAt(e++)<<16|b.charCodeAt(e++)<<8|b.charCodeAt(e++));b.charCodeAt(e++);packet_length--;f++;this.userattributes[0]=[];this.userattributes[0]=b.substring(e,e+packet_length);e+=packet_length;d+=f+packet_length}this.packetLength=e-a;return this};this.read_nodes=function(b,a,c,d){this.parentNode=b;for(var e=c,f=d;a.length!=e;){var g=openpgp_packet.read_packet(a,e,f);if(null==g){util.print_error("openpgp.packet.userattribute.js\n[user_attr] parsing ends here @:"+
|
||||
e+" l:"+f);break}else switch(g.tagType){case 2:15<g.signatureType&&20>g.signatureType?this.certificationSignatures[this.certificationSignatures.length]=g:32==g.signatureType&&(this.certificationRevocationSignatures[this.certificationRevocationSignatures.length]=g);e+=g.packetLength+g.headerLength;f=d-(e-c);break;default:return this.data=a,this.position=c-b.packetLength,this.len=e-c}}this.data=a;this.position=c-b.packetLength;return this.len=e-c};this.toString=function(){for(var b="5.12. User Attribute Packet (Tag 17)\n AttributePackets: (count = "+
|
||||
|
@ -467,8 +467,8 @@ if(0==this.type)return openpgp_crypto_hashData(this.hashAlgorithm,b);if(1==this.
|
|||
c)}return null}}
|
||||
var Util=function(){this.emailRegEx=/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;this.hexdump=function(a){for(var b=[],e=a.length,f=0,g,h=0;f<e;){for(g=a.charCodeAt(f++).toString(16);2>g.length;)g="0"+g;b.push(" "+g);h++;0==h%32&&b.push("\n ")}return b.join("")};this.hexstrdump=function(a){if(null==a)return"";for(var b=[],e=a.length,f=0,g;f<e;){for(g=a.charCodeAt(f++).toString(16);2>g.length;)g="0"+
|
||||
g;b.push(""+g)}return b.join("")};this.hex2bin=function(a){for(var b="",e=0;e<a.length;e+=2)b+=String.fromCharCode(parseInt(a.substr(e,2),16));return b};this.hexidump=function(a){for(var b=[],e=a.length,f=0,g;f<e;){for(g=a[f++].toString(16);2>g.length;)g="0"+g;b.push(""+g)}return b.join("")};this.encode_utf8=function(a){return unescape(encodeURIComponent(a))};this.decode_utf8=function(a){try{return decodeURIComponent(escape(a))}catch(b){return a}};var b=function(a,b){for(var e=0;e<a.length;e++)b[e]=
|
||||
a.charCodeAt(e);return b},a=function(a){for(var b=[],e=0;e<a.length;e++)b.push(String.fromCharCode(a[e]));return b.join("")};this.str2bin=function(a){return b(a,Array(a.length))};this.bin2str=a;this.str2Uint8Array=function(a){return b(a,new Uint8Array(new ArrayBuffer(a.length)))};this.Uint8Array2str=a;this.calc_checksum=function(a){for(var b={s:0,add:function(a){this.s=(this.s+a)%65536}},e=0;e<a.length;e++)b.add(a.charCodeAt(e));return b.s};this.print_debug=function(a){openpgp.config.debug&&(a=openpgp_encoding_html_encode(a),
|
||||
showMessages('<tt><p style="background-color: #ffffff; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;">'+a.replace(/\n/g,"<br>")+"</p></tt>"))};this.print_debug_hexstr_dump=function(a,b){openpgp.config.debug&&(a+=this.hexstrdump(b),a=openpgp_encoding_html_encode(a),showMessages('<tt><p style="background-color: #ffffff; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;">'+a.replace(/\n/g,"<br>")+"</p></tt>"))};this.print_error=
|
||||
function(a){a=openpgp_encoding_html_encode(a);showMessages('<p style="font-size: 80%; background-color: #FF8888; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;"><span style="color: #888;"><b>ERROR:</b></span>\t'+a.replace(/\n/g,"<br>")+"</p>")};this.print_info=function(a){a=openpgp_encoding_html_encode(a);showMessages('<p style="font-size: 80%; background-color: #88FF88; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;"><span style="color: #888;"><b>INFO:</b></span>\t'+
|
||||
a.replace(/\n/g,"<br>")+"</p>")};this.print_warning=function(a){a=openpgp_encoding_html_encode(a);showMessages('<p style="font-size: 80%; background-color: #FFAA88; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;"><span style="color: #888;"><b>WARNING:</b></span>\t'+a.replace(/\n/g,"<br>")+"</p>")};this.getLeftNBits=function(a,b){var e=b%8;return 0==e?a.substring(0,b/8):this.shiftRight(a.substring(0,(b-e)/8+1),8-e)};this.shiftRight=function(a,b){var e=
|
||||
util.str2bin(a);if(0!=b%8)for(var f=e.length-1;0<=f;f--)e[f]>>=b%8,0<f&&(e[f]|=e[f-1]<<8-b%8&255);else return a;return util.bin2str(e)};this.get_hashAlgorithmString=function(a){switch(a){case 1:return"MD5";case 2:return"SHA1";case 3:return"RIPEMD160";case 8:return"SHA256";case 9:return"SHA384";case 10:return"SHA512";case 11:return"SHA224"}return"unknown"}},util=new Util;
|
||||
a.charCodeAt(e);return b},a=function(a){for(var b=[],e=0;e<a.length;e++)b.push(String.fromCharCode(a[e]));return b.join("")};this.str2bin=function(a){return b(a,Array(a.length))};this.bin2str=a;this.str2Uint8Array=function(a){return b(a,new Uint8Array(new ArrayBuffer(a.length)))};this.Uint8Array2str=a;this.calc_checksum=function(a){for(var b={s:0,add:function(a){this.s=(this.s+a)%65536}},e=0;e<a.length;e++)b.add(a.charCodeAt(e));return b.s};this.printLevel={error:1,warning:2,info:3,debug:4};this.print_debug=
|
||||
function(a){openpgp.config.debug&&this.print_output(this.printLevel.debug,a)};this.print_debug_hexstr_dump=function(a,b){openpgp.config.debug&&(a+=this.hexstrdump(b),this.print_output(this.printLevel.debug,a))};this.print_error=function(a){this.print_output(this.printLevel.error,a)};this.print_info=function(a){this.print_output(this.printLevel.info,a)};this.print_warning=function(a){this.print_output(this.printLevel.warning,a)};this.print_output=function(a,b){var e,b=openpgp_encoding_html_encode(b).replace(/\n/g,
|
||||
"<br>");if(a==this.printLevel.debug)e='<tt><p style="background-color: #ffffff; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;">'+b+"</p></tt>";else{var f;switch(a){case this.printLevel.error:e="FF8888";f="ERROR";break;case this.printLevel.warning:e="FFAA88";f="WARNING";break;case this.printLevel.info:e="88FF88",f="INFO"}e='<p style="font-size: 80%; background-color: #'+e+'; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;"><span style="color: #888;"><b>'+
|
||||
f+":</b></span>"+b+"</p>"}showMessages(e)};this.getLeftNBits=function(a,b){var e=b%8;return 0==e?a.substring(0,b/8):this.shiftRight(a.substring(0,(b-e)/8+1),8-e)};this.shiftRight=function(a,b){var e=util.str2bin(a);if(0!=b%8)for(var f=e.length-1;0<=f;f--)e[f]>>=b%8,0<f&&(e[f]|=e[f-1]<<8-b%8&255);else return a;return util.bin2str(e)};this.get_hashAlgorithmString=function(a){switch(a){case 1:return"MD5";case 2:return"SHA1";case 3:return"RIPEMD160";case 8:return"SHA256";case 9:return"SHA384";case 10:return"SHA512";
|
||||
case 11:return"SHA224"}return"unknown"}},util=new Util;
|
||||
|
|
|
@ -185,6 +185,8 @@ function openpgp_crypto_verifySignature(algo, hash_algo, msg_MPIs, publickey_MPI
|
|||
util.print_error("PKCS1 padding in message or key incorrect. Aborting...");
|
||||
return false;
|
||||
}
|
||||
util.print_debug('hash: '+util.hexdump(hash));
|
||||
util.print_debug('calc_hash: '+util.hexdump(calc_hash));
|
||||
return hash == calc_hash;
|
||||
|
||||
case 16: // Elgamal (Encrypt-Only) [ELGAMAL] [HAC]
|
||||
|
|
|
@ -45,7 +45,7 @@ function openpgp_encoding_deArmor(text) {
|
|||
// splittedtext[indexBase] - the message and checksum
|
||||
|
||||
// chunks separated by blank lines
|
||||
var msg = openpgp_encoding_split_headers(splittedtext[indexBase]);
|
||||
var msg = openpgp_encoding_split_headers(splittedtext[indexBase].replace(/^- /mg, ''));
|
||||
var msg_sum = openpgp_encoding_split_checksum(msg.body);
|
||||
|
||||
var data = {
|
||||
|
@ -66,8 +66,8 @@ function openpgp_encoding_deArmor(text) {
|
|||
// splittedtext[indexBase] - the message
|
||||
// splittedtext[indexBase + 1] - the signature and checksum
|
||||
|
||||
var msg = openpgp_encoding_split_headers(splittedtext[indexBase]);
|
||||
var sig = openpgp_encoding_split_headers(splittedtext[indexBase + 1]);
|
||||
var msg = openpgp_encoding_split_headers(splittedtext[indexBase].replace(/^- /mg, ''));
|
||||
var sig = openpgp_encoding_split_headers(splittedtext[indexBase + 1].replace(/^- /mg, ''));
|
||||
var sig_sum = openpgp_encoding_split_checksum(sig.body);
|
||||
|
||||
var result = {
|
||||
|
|
|
@ -101,7 +101,7 @@ function openpgp_packet_signature() {
|
|||
input.charCodeAt(mypos++))* 1000);
|
||||
|
||||
// storing data appended to data which gets verified
|
||||
this.signatureData = input.substring(position, mypos);
|
||||
this.signatureData = input.substring(sigpos, mypos);
|
||||
|
||||
// Eight-octet Key ID of signer.
|
||||
this.keyId = input.substring(mypos, mypos +8);
|
||||
|
@ -510,6 +510,11 @@ function openpgp_packet_signature() {
|
|||
.replace(/\r\n/g,"\n")
|
||||
.replace(/[\t ]+\n/g, "\n")
|
||||
.replace(/\n/g,"\r\n");
|
||||
if (openpgp.config.debug) {
|
||||
util.print_debug('tohash: '+util.hexdump(tohash));
|
||||
util.print_debug('signatureData: '+util.hexdump(this.signatureData));
|
||||
util.print_debug('trailer: '+util.hexdump(trailer));
|
||||
}
|
||||
if (this.version == 4) {
|
||||
this.verified = openpgp_crypto_verifySignature(this.publicKeyAlgorithm, this.hashAlgorithm,
|
||||
this.MPIs, key.obj.publicKeyPacket.MPIs, tohash+this.signatureData+trailer);
|
||||
|
|
|
@ -176,6 +176,8 @@ var Util = function() {
|
|||
return checksum.s;
|
||||
};
|
||||
|
||||
this.printLevel = { error: 1, warning: 2, info: 3, debug: 4 };
|
||||
|
||||
/**
|
||||
* Helper function to print a debug message. Debug
|
||||
* messages are only printed if
|
||||
|
@ -189,8 +191,7 @@ var Util = function() {
|
|||
*/
|
||||
this.print_debug = function(str) {
|
||||
if (openpgp.config.debug) {
|
||||
str = openpgp_encoding_html_encode(str);
|
||||
showMessages("<tt><p style=\"background-color: #ffffff; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\">"+str.replace(/\n/g,"<br>")+"</p></tt>");
|
||||
this.print_output(this.printLevel.debug, str);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -209,8 +210,7 @@ var Util = function() {
|
|||
this.print_debug_hexstr_dump = function(str,strToHex) {
|
||||
if (openpgp.config.debug) {
|
||||
str = str + this.hexstrdump(strToHex);
|
||||
str = openpgp_encoding_html_encode(str);
|
||||
showMessages("<tt><p style=\"background-color: #ffffff; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\">"+str.replace(/\n/g,"<br>")+"</p></tt>");
|
||||
this.print_output(this.printLevel.debug, str);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -224,8 +224,7 @@ var Util = function() {
|
|||
* containing the HTML encoded error message
|
||||
*/
|
||||
this.print_error = function(str) {
|
||||
str = openpgp_encoding_html_encode(str);
|
||||
showMessages("<p style=\"font-size: 80%; background-color: #FF8888; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\"><span style=\"color: #888;\"><b>ERROR:</b></span> "+str.replace(/\n/g,"<br>")+"</p>");
|
||||
this.print_output(this.printLevel.error, str);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -238,15 +237,39 @@ var Util = function() {
|
|||
* containing the HTML encoded info message
|
||||
*/
|
||||
this.print_info = function(str) {
|
||||
str = openpgp_encoding_html_encode(str);
|
||||
showMessages("<p style=\"font-size: 80%; background-color: #88FF88; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\"><span style=\"color: #888;\"><b>INFO:</b></span> "+str.replace(/\n/g,"<br>")+"</p>");
|
||||
this.print_output(this.printLevel.info, str);
|
||||
};
|
||||
|
||||
this.print_warning = function(str) {
|
||||
str = openpgp_encoding_html_encode(str);
|
||||
showMessages("<p style=\"font-size: 80%; background-color: #FFAA88; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\"><span style=\"color: #888;\"><b>WARNING:</b></span> "+str.replace(/\n/g,"<br>")+"</p>");
|
||||
this.print_output(this.printLevel.warning, str);
|
||||
};
|
||||
|
||||
this.print_output = function(level, str) {
|
||||
var html;
|
||||
str = openpgp_encoding_html_encode(str).replace(/\n/g,"<br>");
|
||||
if (level == this.printLevel.debug) {
|
||||
html = "<tt><p style=\"background-color: #ffffff; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\">"+str+"</p></tt>";
|
||||
} else {
|
||||
var color, heading;
|
||||
switch (level) {
|
||||
case this.printLevel.error:
|
||||
color = "FF8888";
|
||||
heading = "ERROR";
|
||||
break;
|
||||
case this.printLevel.warning:
|
||||
color = 'FFAA88';
|
||||
heading = "WARNING";
|
||||
break;
|
||||
case this.printLevel.info:
|
||||
color = '88FF88';
|
||||
heading = 'INFO';
|
||||
break;
|
||||
}
|
||||
html = "<p style=\"font-size: 80%; background-color: #"+color+"; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\"><span style=\"color: #888;\"><b>"+heading+":</b></span>"+str+"</p>";
|
||||
}
|
||||
showMessages(html);
|
||||
}
|
||||
|
||||
this.getLeftNBits = function (string, bitcount) {
|
||||
var rest = bitcount % 8;
|
||||
if (rest == 0)
|
||||
|
|
Loading…
Reference in New Issue
Block a user