mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-11-02 18:26:43 +00:00
followup
This commit is contained in:
parent
d0afa09870
commit
6868b026fb
3 changed files with 13 additions and 4 deletions
|
@ -0,0 +1,5 @@
|
||||||
|
package com.sparrowwallet.drongo.pgp;
|
||||||
|
|
||||||
|
public enum PGPKeySource {
|
||||||
|
USER, GPG, APPLICATION, NONE
|
||||||
|
}
|
|
@ -75,22 +75,26 @@ 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;
|
PGPKeySource keySource;
|
||||||
if(publicKeyRing != null && publicKeyRing.getPublicKey(primaryKeyId) != null) {
|
if(publicKeyRing != null && publicKeyRing.getPublicKey(primaryKeyId) != null) {
|
||||||
signedByKey = publicKeyRing.getPublicKey(primaryKeyId);
|
signedByKey = publicKeyRing.getPublicKey(primaryKeyId);
|
||||||
userProvidedKey = true;
|
keySource = PGPKeySource.USER;
|
||||||
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))) {
|
||||||
signedByKey = appPgpPublicKeyRingCollection.getPublicKey(primaryKeyId);
|
signedByKey = appPgpPublicKeyRingCollection.getPublicKey(primaryKeyId);
|
||||||
|
keySource = PGPKeySource.APPLICATION;
|
||||||
log.debug("Signed using application public key");
|
log.debug("Signed using application public key");
|
||||||
} else if(userPgpPublicKeyRingCollection != null) {
|
} else if(userPgpPublicKeyRingCollection != null) {
|
||||||
signedByKey = userPgpPublicKeyRingCollection.getPublicKey(primaryKeyId);
|
signedByKey = userPgpPublicKeyRingCollection.getPublicKey(primaryKeyId);
|
||||||
|
keySource = PGPKeySource.GPG;
|
||||||
log.debug("Signed using user public key");
|
log.debug("Signed using user public key");
|
||||||
} else if(appPgpPublicKeyRingCollection != null && appPgpPublicKeyRingCollection.getPublicKey(primaryKeyId) != null) {
|
} else if(appPgpPublicKeyRingCollection != null && appPgpPublicKeyRingCollection.getPublicKey(primaryKeyId) != null) {
|
||||||
signedByKey = appPgpPublicKeyRingCollection.getPublicKey(primaryKeyId);
|
signedByKey = appPgpPublicKeyRingCollection.getPublicKey(primaryKeyId);
|
||||||
|
keySource = PGPKeySource.APPLICATION;
|
||||||
log.debug("Signed using expired application public key");
|
log.debug("Signed using expired application public key");
|
||||||
} else {
|
} else {
|
||||||
|
keySource = PGPKeySource.NONE;
|
||||||
log.debug("Could not find public key for primary key id " + primaryKeyId);
|
log.debug("Could not find public key for primary key id " + primaryKeyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +108,7 @@ public class PGPUtils {
|
||||||
expired = isExpired(signedByKey);
|
expired = isExpired(signedByKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PGPVerificationResult(primaryKeyId, userId, signatureVerification.getSignature().getCreationTime(), expired, userProvidedKey);
|
return new PGPVerificationResult(primaryKeyId, userId, signatureVerification.getSignature().getCreationTime(), expired, keySource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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, boolean userProvidedKey) { }
|
public record PGPVerificationResult(long keyId, String userId, Date signatureTimestamp, boolean expired, PGPKeySource keySource) { }
|
||||||
|
|
Loading…
Reference in a new issue