Bugfix: drop unsupported packets in packetlist.read()
add unit test for RSA key with ECC subkey
This commit is contained in:
parent
377b81a121
commit
490d8e4e90
|
@ -36,12 +36,14 @@ Packetlist.prototype.read = function (bytes) {
|
|||
var parsed = packetParser.read(bytes, i, bytes.length - i);
|
||||
i = parsed.offset;
|
||||
|
||||
var tag = enums.read(enums.packet, parsed.tag);
|
||||
var packet = packets.newPacketFromTag(tag);
|
||||
|
||||
this.push(packet);
|
||||
|
||||
packet.read(parsed.packet);
|
||||
try {
|
||||
var tag = enums.read(enums.packet, parsed.tag);
|
||||
var packet = packets.newPacketFromTag(tag);
|
||||
this.push(packet);
|
||||
packet.read(parsed.packet);
|
||||
} catch(e) {
|
||||
this.pop(); // drop unsupported packet
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -77,6 +79,22 @@ Packetlist.prototype.push = function (packet) {
|
|||
this.length++;
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove a packet from the list and return it.
|
||||
* @return {Object} The packet that was removed
|
||||
*/
|
||||
Packetlist.prototype.pop = function() {
|
||||
if (this.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var packet = this[this.length - 1];
|
||||
delete this[this.length - 1];
|
||||
this.length--;
|
||||
|
||||
return packet;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new PacketList with all packets that pass the test implemented by the provided function.
|
||||
*/
|
||||
|
|
|
@ -391,6 +391,151 @@ var pgp_desktop_priv =
|
|||
'=63Nq',
|
||||
'-----END PGP PRIVATE KEY BLOCK-----'].join('\n');
|
||||
|
||||
var rsa_ecc_pub =
|
||||
['pub rsa4096/C9DEDC77 2015-10-17 [expires: 2018-10-16]',
|
||||
'uid Google Security Team <security@google.com>',
|
||||
'sub nistp384/70C16E3C 2015-10-17 [expires: 2018-10-16]',
|
||||
'sub rsa4096/50CB43FB 2015-10-17 [expires: 2018-10-16]',
|
||||
'sub nistp384/102D9086 2015-10-17 [expires: 2018-10-16]',
|
||||
'sub rsa4096/DFC40367 2015-10-17 [expires: 2018-10-16]',
|
||||
'',
|
||||
'-----BEGIN PGP PUBLIC KEY BLOCK-----',
|
||||
'Version: GnuPG v2',
|
||||
'',
|
||||
'mQINBFYiIB8BEACxs55+7GG6ONQV3UFYf36UDSVFbuvNB5V1NaEnkY0t+RVMigLR',
|
||||
'Zdl0HHsiaTKfKs4jqjLQAoR6Fcre9jlEhatotRg3AvHV1XYebxRlzdfXxyD0d6i9',
|
||||
'Quc1zbca0T8F1C5c7xfYP5g9iKWn5yFtHC3S7mLeOg7Ltx84bTo8AF7bHGA3uIQf',
|
||||
'uCtE8l6Z57HTeaf2IR/893jLOir8lvmTef83m/+e1j6ZwmKxxZO2s+aGKre6Fqsz',
|
||||
'Oo89CpWKNrdZ3IN8+Y4udZNlr7u0os7ffY0shfbLrqt+eVEu4EHfbpQTJxvalZJK',
|
||||
'tEnGtV8S7Z3dcPcimxvO7HZu7Wz8VnRzY/AZtee4fC+i2yBu1rWKgY3V1tFKdxVr',
|
||||
'KDnmS5MBgBAxv69mM3bf8QPinL4mtIQ65/Dt4ksJuysRmGwQ8LkjSLQCMMepnjBs',
|
||||
'/63wJ3e4wN1LCwnJonA2f8gZQHNeGPUhVVd/dWFDtmQaLwKFcI0GS/DiUPBIJir5',
|
||||
'DWnrEedtlcSLlwwcUglFsG4Sds/tLr+z5yE88ZrDrIlX9fb9cCAsDq7c8/NCzgvw',
|
||||
'kFez14sXgGhMz6ZfFzM49o0XwlvAeuSJRWBvnKonxM7/laqv4gK0zur3a6+D6qCN',
|
||||
'vt9iWO/YG+0Fvhmyxe34/Q71nXWc9t5aLcokmYLGY1Dpzf9oB8hDRdMCAQARAQAB',
|
||||
'tCpHb29nbGUgU2VjdXJpdHkgVGVhbSA8c2VjdXJpdHlAZ29vZ2xlLmNvbT6JAjwE',
|
||||
'EwEIACYFAlYiIB8CGwEFCQWjmoAFCwkIBwIGFQgJCgsCAxYCAQIeAQIXgAAKCRC4',
|
||||
'5BBcyd7cd8MzD/9YdMV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gd3UIL16lsYnNyq1O0cdWgW+xCUMLVKb5',
|
||||
'Q9f59ld3/yNF5XPyPNH9Ybb5kQJjYsDaIa+NPg9YLZ8DdONgqZyWgKiW5klMSk5Q',
|
||||
'1+pxcXjT13eX5L0Ru/w3UjsSaCQOA/OuNep7Nwg29tWogTOSkhwC92Zpjd5PfoJi',
|
||||
'j3EuhPUeTupRYM58jib/b9/1mQ1+wVyDEpIxTDjU0x1u4E59HcAu0naLNGd9bJMw',
|
||||
'EeiVzNNyKUihENSQh9nsPniQvXgF3pPGQ8ZpS+9R9NyYQID5t3W8UrLpguvAE2U=',
|
||||
'=Q/kB',
|
||||
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
|
||||
|
||||
it('Parsing armored text with RSA key and ECC subkey', function(done) {
|
||||
var pubKeys = openpgp.key.readArmored(rsa_ecc_pub);
|
||||
expect(pubKeys).to.exist;
|
||||
expect(pubKeys.err).to.not.exist;
|
||||
expect(pubKeys.keys).to.have.length(1);
|
||||
expect(pubKeys.keys[0].primaryKey.getKeyId().toHex()).to.equal('b8e4105cc9dedc77');
|
||||
done();
|
||||
});
|
||||
|
||||
it('Parsing armored text with two keys', function(done) {
|
||||
var pubKeys = openpgp.key.readArmored(twoKeys);
|
||||
expect(pubKeys).to.exist;
|
||||
|
|
Loading…
Reference in New Issue
Block a user