1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-23 04:42:06 +01:00

Fix KeyAccessor.ViaKeyId sourcing primary user-id signature

This commit is contained in:
Paul Schaub 2022-01-15 00:59:01 +01:00
parent e177dafd60
commit b58bdf8ff1

View file

@ -110,18 +110,13 @@ public abstract class KeyAccessor {
@Override
public @Nonnull PGPSignature getSignatureWithPreferences() {
PGPSignature signature;
if (key.getPrimaryKeyId() != key.getSubkeyId()) {
signature = info.getCurrentSubkeyBindingSignature(key.getSubkeyId());
} else {
String primaryUserId = info.getPrimaryUserId();
// If the key is located by Key ID, the algorithm of the primary User ID of the key provides the
// preferred symmetric algorithm.
PGPSignature signature = info.getLatestUserIdCertification(primaryUserId);
if (signature == null) {
signature = info.getLatestDirectKeySelfSignature();
}
if (signature != null) {
return signature;
}
signature = info.getLatestUserIdCertification(info.getPrimaryUserId());
if (signature == null) {
throw new IllegalStateException("No valid signature found.");
}