From e3b146b9d9ab3a5abe9fc630c18d4a6658d47856 Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Mon, 11 Apr 2016 12:11:35 +0200 Subject: [PATCH] Fix Keyid.fromId() --- src/type/keyid.js | 4 ++-- test/general/key.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/type/keyid.js b/src/type/keyid.js index 286b1432..2846d6cb 100644 --- a/src/type/keyid.js +++ b/src/type/keyid.js @@ -39,7 +39,7 @@ export default function Keyid() { /** * Parsing method for a key id - * @param {String} input Input to read the key id from + * @param {Uint8Array} input Input to read the key id from */ Keyid.prototype.read = function(bytes) { this.bytes = util.Uint8Array2str(bytes.subarray(0, 8)); @@ -73,6 +73,6 @@ Keyid.fromClone = function (clone) { Keyid.fromId = function (hex) { var keyid = new Keyid(); - keyid.read(util.hex2bin(hex)); + keyid.read(util.str2Uint8Array(util.hex2bin(hex))); return keyid; }; diff --git a/test/general/key.js b/test/general/key.js index 4344cfb8..f5b342eb 100644 --- a/test/general/key.js +++ b/test/general/key.js @@ -426,6 +426,13 @@ var pgp_desktop_priv = done(); }); + it('Create new key ID with fromId()', function() { + var pubKeyV4 = openpgp.key.readArmored(twoKeys).keys[0]; + var keyId = pubKeyV4.primaryKey.getKeyId(); + var newKeyId = keyId.constructor.fromId(keyId.toHex()); + expect(newKeyId.toHex()).to.equal(keyId.toHex()); + }); + it('Testing key method getSubkeyPackets', function(done) { var pubKeys = openpgp.key.readArmored(pub_sig_test);