indicate if user provided key was used in pgp verification

This commit is contained in:
Craig Raw 2024-03-06 12:30:29 +02:00
parent c8165e154a
commit d0afa09870
2 changed files with 4 additions and 2 deletions

View file

@ -75,8 +75,10 @@ public class PGPUtils {
if(subkeyIdentifier != null) { if(subkeyIdentifier != null) {
PGPPublicKey signedByKey = null; PGPPublicKey signedByKey = null;
long primaryKeyId = subkeyIdentifier.getPrimaryKeyId(); long primaryKeyId = subkeyIdentifier.getPrimaryKeyId();
boolean userProvidedKey = false;
if(publicKeyRing != null && publicKeyRing.getPublicKey(primaryKeyId) != null) { if(publicKeyRing != null && publicKeyRing.getPublicKey(primaryKeyId) != null) {
signedByKey = publicKeyRing.getPublicKey(primaryKeyId); signedByKey = publicKeyRing.getPublicKey(primaryKeyId);
userProvidedKey = true;
log.debug("Signed using provided public key"); log.debug("Signed using provided public key");
} else if(appPgpPublicKeyRingCollection != null && appPgpPublicKeyRingCollection.getPublicKey(primaryKeyId) != null } else if(appPgpPublicKeyRingCollection != null && appPgpPublicKeyRingCollection.getPublicKey(primaryKeyId) != null
&& !isExpired(appPgpPublicKeyRingCollection.getPublicKey(primaryKeyId))) { && !isExpired(appPgpPublicKeyRingCollection.getPublicKey(primaryKeyId))) {
@ -102,7 +104,7 @@ public class PGPUtils {
expired = isExpired(signedByKey); expired = isExpired(signedByKey);
} }
return new PGPVerificationResult(primaryKeyId, userId, signatureVerification.getSignature().getCreationTime(), expired); return new PGPVerificationResult(primaryKeyId, userId, signatureVerification.getSignature().getCreationTime(), expired, userProvidedKey);
} }
} }
} }

View file

@ -2,4 +2,4 @@ package com.sparrowwallet.drongo.pgp;
import java.util.Date; import java.util.Date;
public record PGPVerificationResult(long keyId, String userId, Date signatureTimestamp, boolean expired) { } public record PGPVerificationResult(long keyId, String userId, Date signatureTimestamp, boolean expired, boolean userProvidedKey) { }