Unit tests passing
This commit is contained in:
parent
03d0d44061
commit
f57de1ec40
File diff suppressed because one or more lines are too long
|
@ -33,7 +33,7 @@ function CleartextMessage(text, packetlist) {
|
|||
if (!(this instanceof CleartextMessage)) {
|
||||
return new CleartextMessage(packetlist);
|
||||
}
|
||||
this.text = text.replace(/\r/g, '').replace(/[\t ]+\n/g, "\n").replace(/\n/,"\r\n");
|
||||
this.text = text.replace(/\r/g, '').replace(/[\t ]+\n/g, "\n").replace(/\n/g,"\r\n");
|
||||
this.packets = packetlist || new packet.list();
|
||||
}
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ function createcrc24(input) {
|
|||
* or an object with attribute "headers" containing the headers and
|
||||
* and an attribute "body" containing the body.
|
||||
*/
|
||||
function openpgp_encoding_split_headers(text) {
|
||||
function split_headers(text) {
|
||||
var reEmptyLine = /^[\t ]*\n/m;
|
||||
var headers = "";
|
||||
var body = text;
|
||||
|
@ -221,7 +221,7 @@ function openpgp_encoding_split_headers(text) {
|
|||
* or an object with attribute "body" containing the body
|
||||
* and an attribute "checksum" containing the checksum.
|
||||
*/
|
||||
function openpgp_encoding_split_checksum(text) {
|
||||
function split_checksum(text) {
|
||||
var reChecksumStart = /^=/m;
|
||||
var body = text;
|
||||
var checksum = "";
|
||||
|
@ -265,30 +265,30 @@ function dearmor(text) {
|
|||
}
|
||||
|
||||
if (type != 2) {
|
||||
var msg = openpgp_encoding_split_headers(splittext[indexBase].replace(/^- /mg, ''));
|
||||
var msg_sum = openpgp_encoding_split_checksum(msg.body);
|
||||
var msg = split_headers(splittext[indexBase].replace(/^- /mg, ''));
|
||||
var msg_sum = split_checksum(msg.body);
|
||||
|
||||
result = {
|
||||
openpgp: openpgp_encoding_base64_decode(msg_sum.body),
|
||||
data: base64.decode(msg_sum.body),
|
||||
type: type
|
||||
};
|
||||
|
||||
checksum = msg_sum.checksum;
|
||||
} else {
|
||||
var msg = openpgp_encoding_split_headers(splittext[indexBase].replace(/^- /mg, '').replace(/[\t ]+\n/g, "\n"));
|
||||
var sig = openpgp_encoding_split_headers(splittext[indexBase + 1].replace(/^- /mg, ''));
|
||||
var sig_sum = openpgp_encoding_split_checksum(sig.body);
|
||||
var msg = split_headers(splittext[indexBase].replace(/^- /mg, '').replace(/[\t ]+\n/g, "\n"));
|
||||
var sig = split_headers(splittext[indexBase + 1].replace(/^- /mg, ''));
|
||||
var sig_sum = split_checksum(sig.body);
|
||||
|
||||
result = {
|
||||
text: msg.body.replace(/\n$/, '').replace(/\n/g, "\r\n"),
|
||||
openpgp: openpgp_encoding_base64_decode(sig_sum.body),
|
||||
data: base64.decode(sig_sum.body),
|
||||
type: type
|
||||
};
|
||||
|
||||
checksum = sig_sum.checksum;
|
||||
}
|
||||
|
||||
if (!verifyCheckSum(result.openpgp, checksum)) {
|
||||
if (!verifyCheckSum(result.data, checksum)) {
|
||||
util.print_error("Ascii armor integrity check on message failed: '"
|
||||
+ checksum
|
||||
+ "' should be '"
|
||||
|
|
|
@ -310,7 +310,7 @@ var pub_key_arm3 =
|
|||
'=nx90',
|
||||
'-----END PGP MESSAGE-----'].join('\n');
|
||||
|
||||
var plaintext = 'short message\nnext line\n한국어/조선말\n\n';
|
||||
var plaintext = 'short message\r\nnext line\r\n한국어/조선말\r\n\r\n';
|
||||
var esMsg = openpgp.message.readArmored(msg_armor);
|
||||
var pubKey = openpgp.key.readArmored(pub_key_arm2);
|
||||
var privKey = openpgp.key.readArmored(priv_key_arm2);
|
||||
|
@ -394,7 +394,7 @@ var pub_key_arm3 =
|
|||
|
||||
var cleartextSig = openpgp.verifyClearSignedMessage([pubKey2, pubKey3], csMsg);
|
||||
|
||||
verified = verified && cleartextSig.text == plaintext;
|
||||
verified = verified && cleartextSig.text == plaintext.replace(/\r/g,'').replace(/[\t ]+\n/g,"\n").replace(/\n/g,"\r\n");
|
||||
|
||||
verified = verified && cleartextSig.signatures[0].status && cleartextSig.signatures[1].status;
|
||||
|
||||
|
@ -412,7 +412,7 @@ var pub_key_arm3 =
|
|||
|
||||
var cleartextSig = openpgp.verifyClearSignedMessage([pubKey], csMsg);
|
||||
|
||||
var verified = cleartextSig.text == plaintext;
|
||||
var verified = cleartextSig.text == plaintext.replace(/\r/g,'').replace(/[\t ]+\n/g,"\n").replace(/\n/g,"\r\n");
|
||||
|
||||
verified = verified && cleartextSig.signatures[0].status;
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user