Fix checksum failure debug message
This commit is contained in:
parent
63db9246c6
commit
8110782633
|
@ -7422,7 +7422,7 @@ function openpgp_config() {
|
|||
keyserver: "keyserver.linux.it" // "pgp.mit.edu:11371"
|
||||
};
|
||||
|
||||
this.versionstring ="OpenPGP.js v.1.20131201";
|
||||
this.versionstring ="OpenPGP.js v.1.20131202";
|
||||
this.commentstring ="http://openpgpjs.org";
|
||||
/**
|
||||
* Reads the config out of the HTML5 local storage
|
||||
|
@ -7570,6 +7570,8 @@ function openpgp_encoding_deArmor(text) {
|
|||
// so we know the index of the data we are interested in.
|
||||
var indexBase = 1;
|
||||
|
||||
var result, checksum;
|
||||
|
||||
if (text.search(reSplit) != splittedtext[0].length) {
|
||||
indexBase = 0;
|
||||
}
|
||||
|
@ -7581,20 +7583,11 @@ function openpgp_encoding_deArmor(text) {
|
|||
var msg = openpgp_encoding_split_headers(splittedtext[indexBase].replace(/^- /mg, ''));
|
||||
var msg_sum = openpgp_encoding_split_checksum(msg.body);
|
||||
|
||||
var data = {
|
||||
result = {
|
||||
openpgp: openpgp_encoding_base64_decode(msg_sum.body),
|
||||
type: type
|
||||
};
|
||||
|
||||
if (verifyCheckSum(data.openpgp, msg_sum.checksum)) {
|
||||
return data;
|
||||
} else {
|
||||
util.print_error("Ascii armor integrity check on message failed: '"
|
||||
+ msg_sum.checksum
|
||||
+ "' should be '"
|
||||
+ getCheckSum(data) + "'");
|
||||
return false;
|
||||
}
|
||||
checksum = msg_sum.checksum;
|
||||
} else {
|
||||
// splittedtext[indexBase] - the message
|
||||
// splittedtext[indexBase + 1] - the signature and checksum
|
||||
|
@ -7603,18 +7596,23 @@ function openpgp_encoding_deArmor(text) {
|
|||
var sig = openpgp_encoding_split_headers(splittedtext[indexBase + 1].replace(/^- /mg, ''));
|
||||
var sig_sum = openpgp_encoding_split_checksum(sig.body);
|
||||
|
||||
var result = {
|
||||
result = {
|
||||
text: msg.body.replace(/\n$/, "").replace(/\n/g, "\r\n"),
|
||||
openpgp: openpgp_encoding_base64_decode(sig_sum.body),
|
||||
type: type
|
||||
};
|
||||
|
||||
if (verifyCheckSum(result.openpgp, sig_sum.checksum)) {
|
||||
return result;
|
||||
} else {
|
||||
util.print_error("Ascii armor integrity check on message failed");
|
||||
return false;
|
||||
}
|
||||
checksum = sig_sum.checksum;
|
||||
}
|
||||
|
||||
if (!verifyCheckSum(result.openpgp, checksum)) {
|
||||
util.print_error("Ascii armor integrity check on message failed: '"
|
||||
+ checksum
|
||||
+ "' should be '"
|
||||
+ getCheckSum(result) + "'");
|
||||
return false;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
8
resources/openpgp.min.js
vendored
8
resources/openpgp.min.js
vendored
|
@ -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.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",
|
||||
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.20131202";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].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_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);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}):(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});d=d.checksum;if(verifyCheckSum(c.openpgp,d))return c;util.print_error("Ascii armor integrity check on message failed: '"+d+"' should be '"+getCheckSum(c)+"'");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;
|
||||
|
|
|
@ -37,6 +37,8 @@ function openpgp_encoding_deArmor(text) {
|
|||
// so we know the index of the data we are interested in.
|
||||
var indexBase = 1;
|
||||
|
||||
var result, checksum;
|
||||
|
||||
if (text.search(reSplit) != splittedtext[0].length) {
|
||||
indexBase = 0;
|
||||
}
|
||||
|
@ -48,20 +50,11 @@ function openpgp_encoding_deArmor(text) {
|
|||
var msg = openpgp_encoding_split_headers(splittedtext[indexBase].replace(/^- /mg, ''));
|
||||
var msg_sum = openpgp_encoding_split_checksum(msg.body);
|
||||
|
||||
var data = {
|
||||
result = {
|
||||
openpgp: openpgp_encoding_base64_decode(msg_sum.body),
|
||||
type: type
|
||||
};
|
||||
|
||||
if (verifyCheckSum(data.openpgp, msg_sum.checksum)) {
|
||||
return data;
|
||||
} else {
|
||||
util.print_error("Ascii armor integrity check on message failed: '"
|
||||
+ msg_sum.checksum
|
||||
+ "' should be '"
|
||||
+ getCheckSum(data) + "'");
|
||||
return false;
|
||||
}
|
||||
checksum = msg_sum.checksum;
|
||||
} else {
|
||||
// splittedtext[indexBase] - the message
|
||||
// splittedtext[indexBase + 1] - the signature and checksum
|
||||
|
@ -70,18 +63,23 @@ function openpgp_encoding_deArmor(text) {
|
|||
var sig = openpgp_encoding_split_headers(splittedtext[indexBase + 1].replace(/^- /mg, ''));
|
||||
var sig_sum = openpgp_encoding_split_checksum(sig.body);
|
||||
|
||||
var result = {
|
||||
result = {
|
||||
text: msg.body.replace(/\n$/, "").replace(/\n/g, "\r\n"),
|
||||
openpgp: openpgp_encoding_base64_decode(sig_sum.body),
|
||||
type: type
|
||||
};
|
||||
|
||||
if (verifyCheckSum(result.openpgp, sig_sum.checksum)) {
|
||||
return result;
|
||||
} else {
|
||||
util.print_error("Ascii armor integrity check on message failed");
|
||||
return false;
|
||||
}
|
||||
checksum = sig_sum.checksum;
|
||||
}
|
||||
|
||||
if (!verifyCheckSum(result.openpgp, checksum)) {
|
||||
util.print_error("Ascii armor integrity check on message failed: '"
|
||||
+ checksum
|
||||
+ "' should be '"
|
||||
+ getCheckSum(result) + "'");
|
||||
return false;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user