When parsing: Ignore unrecognizable secret subkeys
@@ -133,15 +133,14 @@ public PGPSecretKeyRing(
while (pIn.nextPacketTag() == PacketTags.SECRET_SUBKEY
|| pIn.nextPacketTag() == PacketTags.PUBLIC_SUBKEY)
{
- if (pIn.nextPacketTag() == PacketTags.SECRET_SUBKEY)
- {
+ try {
+ if (pIn.nextPacketTag() == PacketTags.SECRET_SUBKEY) {
SecretSubkeyPacket sub = (SecretSubkeyPacket) pIn.readPacket();
//
// ignore GPG comment packets if found.
//
- while (pIn.nextPacketTag() == PacketTags.EXPERIMENTAL_2)
- {
+ while (pIn.nextPacketTag() == PacketTags.EXPERIMENTAL_2) {
pIn.readPacket();
}
@@ -149,9 +148,7 @@ public PGPSecretKeyRing(
List sigList = readSignaturesAndTrust(pIn);
keys.add(new PGPSecretKey(sub, new PGPPublicKey(sub.getPublicKeyPacket(), subTrust, sigList, fingerPrintCalculator)));
- }
- else
- {
+ } else {
PublicSubkeyPacket sub = (PublicSubkeyPacket) pIn.readPacket();
TrustPacket subTrust = readOptionalTrustPacket(pIn);
@@ -159,6 +156,9 @@ public PGPSecretKeyRing(
extraPubKeys.add(new PGPPublicKey(sub, subTrust, sigList, fingerPrintCalculator));
}
+ } catch (IOException e) {
+ // skip sub-keys with unrecognized algorithms to be upwards compatible
+ }
}
}
