Merge pull request #437 from openpgpjs/keyid_fix

Fix Keyid.fromId()
This commit is contained in:
Thomas Oberndörfer 2016-04-12 09:40:34 +02:00
commit acf66eb012
2 changed files with 9 additions and 2 deletions

View File

@ -39,7 +39,7 @@ export default function Keyid() {
/** /**
* Parsing method for a key id * 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) { Keyid.prototype.read = function(bytes) {
this.bytes = util.Uint8Array2str(bytes.subarray(0, 8)); this.bytes = util.Uint8Array2str(bytes.subarray(0, 8));
@ -73,6 +73,6 @@ Keyid.fromClone = function (clone) {
Keyid.fromId = function (hex) { Keyid.fromId = function (hex) {
var keyid = new Keyid(); var keyid = new Keyid();
keyid.read(util.hex2bin(hex)); keyid.read(util.str2Uint8Array(util.hex2bin(hex)));
return keyid; return keyid;
}; };

View File

@ -426,6 +426,13 @@ var pgp_desktop_priv =
done(); 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) { it('Testing key method getSubkeyPackets', function(done) {
var pubKeys = openpgp.key.readArmored(pub_sig_test); var pubKeys = openpgp.key.readArmored(pub_sig_test);