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)) {
|
if (!(this instanceof CleartextMessage)) {
|
||||||
return new CleartextMessage(packetlist);
|
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();
|
this.packets = packetlist || new packet.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ function createcrc24(input) {
|
||||||
* or an object with attribute "headers" containing the headers and
|
* or an object with attribute "headers" containing the headers and
|
||||||
* and an attribute "body" containing the body.
|
* and an attribute "body" containing the body.
|
||||||
*/
|
*/
|
||||||
function openpgp_encoding_split_headers(text) {
|
function split_headers(text) {
|
||||||
var reEmptyLine = /^[\t ]*\n/m;
|
var reEmptyLine = /^[\t ]*\n/m;
|
||||||
var headers = "";
|
var headers = "";
|
||||||
var body = text;
|
var body = text;
|
||||||
|
@ -221,7 +221,7 @@ function openpgp_encoding_split_headers(text) {
|
||||||
* or an object with attribute "body" containing the body
|
* or an object with attribute "body" containing the body
|
||||||
* and an attribute "checksum" containing the checksum.
|
* and an attribute "checksum" containing the checksum.
|
||||||
*/
|
*/
|
||||||
function openpgp_encoding_split_checksum(text) {
|
function split_checksum(text) {
|
||||||
var reChecksumStart = /^=/m;
|
var reChecksumStart = /^=/m;
|
||||||
var body = text;
|
var body = text;
|
||||||
var checksum = "";
|
var checksum = "";
|
||||||
|
@ -265,30 +265,30 @@ function dearmor(text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != 2) {
|
if (type != 2) {
|
||||||
var msg = openpgp_encoding_split_headers(splittext[indexBase].replace(/^- /mg, ''));
|
var msg = split_headers(splittext[indexBase].replace(/^- /mg, ''));
|
||||||
var msg_sum = openpgp_encoding_split_checksum(msg.body);
|
var msg_sum = split_checksum(msg.body);
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
openpgp: openpgp_encoding_base64_decode(msg_sum.body),
|
data: base64.decode(msg_sum.body),
|
||||||
type: type
|
type: type
|
||||||
};
|
};
|
||||||
|
|
||||||
checksum = msg_sum.checksum;
|
checksum = msg_sum.checksum;
|
||||||
} else {
|
} else {
|
||||||
var msg = openpgp_encoding_split_headers(splittext[indexBase].replace(/^- /mg, '').replace(/[\t ]+\n/g, "\n"));
|
var msg = split_headers(splittext[indexBase].replace(/^- /mg, '').replace(/[\t ]+\n/g, "\n"));
|
||||||
var sig = openpgp_encoding_split_headers(splittext[indexBase + 1].replace(/^- /mg, ''));
|
var sig = split_headers(splittext[indexBase + 1].replace(/^- /mg, ''));
|
||||||
var sig_sum = openpgp_encoding_split_checksum(sig.body);
|
var sig_sum = split_checksum(sig.body);
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
text: msg.body.replace(/\n$/, '').replace(/\n/g, "\r\n"),
|
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
|
type: type
|
||||||
};
|
};
|
||||||
|
|
||||||
checksum = sig_sum.checksum;
|
checksum = sig_sum.checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!verifyCheckSum(result.openpgp, checksum)) {
|
if (!verifyCheckSum(result.data, checksum)) {
|
||||||
util.print_error("Ascii armor integrity check on message failed: '"
|
util.print_error("Ascii armor integrity check on message failed: '"
|
||||||
+ checksum
|
+ checksum
|
||||||
+ "' should be '"
|
+ "' should be '"
|
||||||
|
|
|
@ -310,7 +310,7 @@ var pub_key_arm3 =
|
||||||
'=nx90',
|
'=nx90',
|
||||||
'-----END PGP MESSAGE-----'].join('\n');
|
'-----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 esMsg = openpgp.message.readArmored(msg_armor);
|
||||||
var pubKey = openpgp.key.readArmored(pub_key_arm2);
|
var pubKey = openpgp.key.readArmored(pub_key_arm2);
|
||||||
var privKey = openpgp.key.readArmored(priv_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);
|
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;
|
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 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;
|
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