mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-26 12:58:02 +01:00
Use assert statements to flag impossible NPEs
This commit is contained in:
parent
d05ffd0451
commit
21ae48d8c1
3 changed files with 8 additions and 1 deletions
|
@ -544,6 +544,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
|
|||
for (Tuple<PGPSecretKey, PGPPublicKeyEncryptedData> k : postponedDueToMissingPassphrase) {
|
||||
PGPSecretKey key = k.getA();
|
||||
PGPSecretKeyRing keys = getDecryptionKey(key.getKeyID());
|
||||
assert (keys != null);
|
||||
keyIds.add(new SubkeyIdentifier(keys, key.getKeyID()));
|
||||
}
|
||||
if (!keyIds.isEmpty()) {
|
||||
|
@ -556,6 +557,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
|
|||
PGPSecretKey secretKey = missingPassphrases.getA();
|
||||
long keyId = secretKey.getKeyID();
|
||||
PGPSecretKeyRing decryptionKey = getDecryptionKey(keyId);
|
||||
assert (decryptionKey != null);
|
||||
SubkeyIdentifier decryptionKeyId = new SubkeyIdentifier(decryptionKey, keyId);
|
||||
if (hasUnsupportedS2KSpecifier(secretKey, decryptionKeyId)) {
|
||||
continue;
|
||||
|
|
|
@ -275,6 +275,7 @@ public class CertifyCertificate {
|
|||
// We only support certification-capable primary keys
|
||||
OpenPgpFingerprint fingerprint = info.getFingerprint();
|
||||
PGPPublicKey certificationPubKey = info.getPublicKey(fingerprint);
|
||||
assert (certificationPubKey != null);
|
||||
if (!info.isKeyValidlyBound(certificationPubKey.getKeyID())) {
|
||||
throw new KeyException.RevokedKeyException(fingerprint);
|
||||
}
|
||||
|
|
|
@ -182,7 +182,10 @@ public class SecretKeyRingEditor implements SecretKeyRingEditorInterface {
|
|||
}
|
||||
|
||||
// We need to unmark this user-id as primary
|
||||
if (info.getLatestUserIdCertification(otherUserId).getHashedSubPackets().isPrimaryUserID()) {
|
||||
PGPSignature userIdCertification = info.getLatestUserIdCertification(otherUserId);
|
||||
assert (userIdCertification != null);
|
||||
|
||||
if (userIdCertification.getHashedSubPackets().isPrimaryUserID()) {
|
||||
addUserId(otherUserId, new SelfSignatureSubpackets.Callback() {
|
||||
@Override
|
||||
public void modifyHashedSubpackets(SelfSignatureSubpackets hashedSubpackets) {
|
||||
|
@ -601,6 +604,7 @@ public class SecretKeyRingEditor implements SecretKeyRingEditorInterface {
|
|||
}
|
||||
|
||||
if (prevUserIdSig.getHashedSubPackets().isPrimaryUserID()) {
|
||||
assert (primaryUserId != null);
|
||||
PGPSignature userIdSig = reissueNonPrimaryUserId(secretKeyRingProtector, userId, prevUserIdSig);
|
||||
secretKeyRing = KeyRingUtils.injectCertification(secretKeyRing, primaryUserId, userIdSig);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue