From d0afa0987021284f11c45a51ffccbf7cb6d13ca2 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Wed, 6 Mar 2024 12:30:29 +0200 Subject: [PATCH] indicate if user provided key was used in pgp verification --- src/main/java/com/sparrowwallet/drongo/pgp/PGPUtils.java | 4 +++- .../com/sparrowwallet/drongo/pgp/PGPVerificationResult.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sparrowwallet/drongo/pgp/PGPUtils.java b/src/main/java/com/sparrowwallet/drongo/pgp/PGPUtils.java index 2b218b2..26d076b 100644 --- a/src/main/java/com/sparrowwallet/drongo/pgp/PGPUtils.java +++ b/src/main/java/com/sparrowwallet/drongo/pgp/PGPUtils.java @@ -75,8 +75,10 @@ public class PGPUtils { if(subkeyIdentifier != null) { PGPPublicKey signedByKey = null; long primaryKeyId = subkeyIdentifier.getPrimaryKeyId(); + boolean userProvidedKey = false; if(publicKeyRing != null && publicKeyRing.getPublicKey(primaryKeyId) != null) { signedByKey = publicKeyRing.getPublicKey(primaryKeyId); + userProvidedKey = true; log.debug("Signed using provided public key"); } else if(appPgpPublicKeyRingCollection != null && appPgpPublicKeyRingCollection.getPublicKey(primaryKeyId) != null && !isExpired(appPgpPublicKeyRingCollection.getPublicKey(primaryKeyId))) { @@ -102,7 +104,7 @@ public class PGPUtils { expired = isExpired(signedByKey); } - return new PGPVerificationResult(primaryKeyId, userId, signatureVerification.getSignature().getCreationTime(), expired); + return new PGPVerificationResult(primaryKeyId, userId, signatureVerification.getSignature().getCreationTime(), expired, userProvidedKey); } } } diff --git a/src/main/java/com/sparrowwallet/drongo/pgp/PGPVerificationResult.java b/src/main/java/com/sparrowwallet/drongo/pgp/PGPVerificationResult.java index 65b307c..de6dea6 100644 --- a/src/main/java/com/sparrowwallet/drongo/pgp/PGPVerificationResult.java +++ b/src/main/java/com/sparrowwallet/drongo/pgp/PGPVerificationResult.java @@ -2,4 +2,4 @@ package com.sparrowwallet.drongo.pgp; 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) { }