mirror of
https://github.com/moparisthebest/mail
synced 2024-11-26 02:42:17 -05:00
fix signature verfication by formatting newlines before encryption
This commit is contained in:
parent
497d5eb4f9
commit
3700e211ec
@ -159,6 +159,9 @@ define(function(require) {
|
|||||||
receiverKeys[i] = openpgp.read_publicKey(receiverKeys[i])[0];
|
receiverKeys[i] = openpgp.read_publicKey(receiverKeys[i])[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// format: \n -> \r\n
|
||||||
|
plaintext = plaintext.replace(/\r\n/g, '\n').replace(/[\t ]+\n/g, "\n").replace(/\n/g, '\r\n');
|
||||||
|
|
||||||
// encrypt and sign the plaintext
|
// encrypt and sign the plaintext
|
||||||
try {
|
try {
|
||||||
ct = openpgp.write_signed_and_encrypted_message(privateKey, receiverKeys, plaintext);
|
ct = openpgp.write_signed_and_encrypted_message(privateKey, receiverKeys, plaintext);
|
||||||
|
@ -118,7 +118,11 @@ define(function(require) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Encryption', function() {
|
describe('Encryption', function() {
|
||||||
var message = 'Hello, World!';
|
var message = 'asdfs\n\nThursday, Nov 21, 2013 7:38 PM asdf@example.com wrote:\n' +
|
||||||
|
'> asdf\n' +
|
||||||
|
'> \n' +
|
||||||
|
'> Thursday, Nov 21, 2013 7:32 PM asdf@example.com wrote:\n' +
|
||||||
|
'> > secret 3';
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
pgp.importKeys({
|
pgp.importKeys({
|
||||||
@ -195,7 +199,7 @@ define(function(require) {
|
|||||||
it('should work', function(done) {
|
it('should work', function(done) {
|
||||||
pgp.decrypt(ciphertext, pubkey, function(err, pt) {
|
pgp.decrypt(ciphertext, pubkey, function(err, pt) {
|
||||||
expect(err).to.not.exist;
|
expect(err).to.not.exist;
|
||||||
expect(pt).to.equal(message);
|
expect(pt).to.equal(message.replace(/\r\n/g, '\n').replace(/[\t ]+\n/g, "\n").replace(/\n/g, '\r\n'));
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user