1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-22 19:08:00 +01:00

Add SignatureSubpacketsUtil.getRegularExpressions()

This commit is contained in:
Paul Schaub 2023-06-19 10:56:42 +02:00
parent 82cea93e7b
commit 90626a8a76
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -23,6 +23,7 @@ import org.bouncycastle.bcpg.sig.KeyFlags;
import org.bouncycastle.bcpg.sig.NotationData;
import org.bouncycastle.bcpg.sig.PreferredAlgorithms;
import org.bouncycastle.bcpg.sig.PrimaryUserID;
import org.bouncycastle.bcpg.sig.RegularExpression;
import org.bouncycastle.bcpg.sig.Revocable;
import org.bouncycastle.bcpg.sig.RevocationKey;
import org.bouncycastle.bcpg.sig.RevocationReason;
@ -540,6 +541,23 @@ public final class SignatureSubpacketsUtil {
return hashed(signature, SignatureSubpacket.trustSignature);
}
/**
* Return all regular expression subpackets from the hashed area of the given signature.
*
* @param signature signature
* @return list of regular expressions
*/
public static List<RegularExpression> getRegularExpressions(PGPSignature signature) {
org.bouncycastle.bcpg.SignatureSubpacket[] subpackets = signature.getHashedSubPackets()
.getSubpackets(SignatureSubpacket.regularExpression.getCode());
List<RegularExpression> regularExpressions = new ArrayList<>(subpackets.length);
for (org.bouncycastle.bcpg.SignatureSubpacket subpacket : subpackets) {
regularExpressions.add((RegularExpression) subpacket);
}
return regularExpressions;
}
/**
* Select a list of all signature subpackets of the given type, which are present in the hashed area of
* the given signature.