Skip to content

Commit

Permalink
Merge pull request #7
Browse files Browse the repository at this point in the history
To fix a NullPointerException that can be thrown while trying to extract
usage flags from a subkey.
  • Loading branch information
justinludwig committed Aug 31, 2017
2 parents 65c8385 + 08eff83 commit 58c60bd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/org/c02e/jpgpj/Subkey.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPSecretKey;
import org.bouncycastle.openpgp.PGPSignature;
import org.bouncycastle.openpgp.PGPSignatureSubpacketVector;
import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor;
import org.bouncycastle.openpgp.operator.bc.BcPBESecretKeyDecryptorBuilder;
import org.bouncycastle.openpgp.operator.bc.BcPGPDigestCalculatorProvider;
Expand Down Expand Up @@ -247,9 +248,14 @@ public int getUsageFlags() throws PGPException {
// actually only need POSITIVE_CERTIFICATION (for master key)
// and SUBKEY_BINDING (for subkeys)
Iterator<PGPSignature> signatures = publicKey.getSignatures();
while (signatures.hasNext())
flags |= signatures.next().getHashedSubPackets().getKeyFlags();
while (signatures.hasNext()) {
PGPSignature signature = signatures.next();
PGPSignatureSubpacketVector hashedSubPackets =
signature.getHashedSubPackets();

if (hashedSubPackets != null)
flags |= hashedSubPackets.getKeyFlags();
}
return flags;
}

Expand Down

0 comments on commit 58c60bd

Please sign in to comment.