mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-30 00:02:06 +01:00
Add SignatureUtils.wasIssuedBy
This commit is contained in:
parent
99496f80f5
commit
1447dfc642
1 changed files with 15 additions and 0 deletions
|
@ -33,6 +33,7 @@ import org.pgpainless.algorithm.SignatureType;
|
||||||
import org.pgpainless.algorithm.negotiation.HashAlgorithmNegotiator;
|
import org.pgpainless.algorithm.negotiation.HashAlgorithmNegotiator;
|
||||||
import org.pgpainless.implementation.ImplementationFactory;
|
import org.pgpainless.implementation.ImplementationFactory;
|
||||||
import org.pgpainless.key.OpenPgpFingerprint;
|
import org.pgpainless.key.OpenPgpFingerprint;
|
||||||
|
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||||
import org.pgpainless.key.util.OpenPgpKeyAttributeUtil;
|
import org.pgpainless.key.util.OpenPgpKeyAttributeUtil;
|
||||||
import org.pgpainless.key.util.RevocationAttributes;
|
import org.pgpainless.key.util.RevocationAttributes;
|
||||||
import org.pgpainless.signature.subpackets.SignatureSubpacketsUtil;
|
import org.pgpainless.signature.subpackets.SignatureSubpacketsUtil;
|
||||||
|
@ -310,4 +311,18 @@ public final class SignatureUtils {
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean wasIssuedBy(byte[] fingerprint, PGPSignature signature) {
|
||||||
|
if (fingerprint.length != 20) {
|
||||||
|
// Unknown fingerprint length
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
OpenPgpV4Fingerprint fp = new OpenPgpV4Fingerprint(fingerprint);
|
||||||
|
OpenPgpFingerprint issuerFp = SignatureSubpacketsUtil.getIssuerFingerprintAsOpenPgpFingerprint(signature);
|
||||||
|
if (issuerFp == null) {
|
||||||
|
return fp.getKeyId() == signature.getKeyID();
|
||||||
|
}
|
||||||
|
|
||||||
|
return fp.equals(issuerFp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue