Binary signature on text message: sign and verify text as UTF-8

This commit is contained in:
Daniel Huigens 2020-02-17 12:13:34 +01:00
parent de6ab1db49
commit 92eda27e61
2 changed files with 2 additions and 2 deletions

View File

@ -572,7 +572,7 @@ Signature.prototype.toSign = function (type, data) {
switch (type) { switch (type) {
case t.binary: case t.binary:
if (data.text !== null) { if (data.text !== null) {
return util.str_to_Uint8Array(data.getText(true)); return util.encode_utf8(data.getText(true));
} }
return data.getBytes(true); return data.getBytes(true);

View File

@ -997,7 +997,7 @@ hkJiXopCSWKSlQInL1devkJJUWJmTmZeugJYlpdLAagQJM0JpsCqIQZwKgAA
it('Should verify cleartext message correctly when using a detached binary signature and text literal data', async function () { it('Should verify cleartext message correctly when using a detached binary signature and text literal data', async function () {
const plaintext = 'short message\nnext line \n한국어/조선말'; const plaintext = 'short message\nnext line \n한국어/조선말';
const plaintextArray = openpgp.util.str_to_Uint8Array(plaintext); const plaintextArray = openpgp.util.encode_utf8(plaintext);
const pubKey = (await openpgp.key.readArmored(pub_key_arm2)).keys[0]; const pubKey = (await openpgp.key.readArmored(pub_key_arm2)).keys[0];
const privKey = (await openpgp.key.readArmored(priv_key_arm2)).keys[0]; const privKey = (await openpgp.key.readArmored(priv_key_arm2)).keys[0];
await privKey.decrypt('hello world'); await privKey.decrypt('hello world');