diff --git a/pgpainless-core/src/main/java/org/pgpainless/signature/subpackets/SignatureSubpacketsUtil.java b/pgpainless-core/src/main/java/org/pgpainless/signature/subpackets/SignatureSubpacketsUtil.java index 97b8ecaa..846635fd 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/signature/subpackets/SignatureSubpacketsUtil.java +++ b/pgpainless-core/src/main/java/org/pgpainless/signature/subpackets/SignatureSubpacketsUtil.java @@ -108,6 +108,13 @@ public class SignatureSubpacketsUtil { return hashedOrUnhashed(signature, SignatureSubpacket.issuerKeyId); } + /** + * Inspect the given signature's {@link IssuerKeyID} packet to determine the issuer key-id. + * If no such packet is present, return null. + * + * @param signature signature + * @return issuer key-id as {@link Long} + */ public static Long getIssuerKeyIdAsLong(PGPSignature signature) { IssuerKeyID keyID = getIssuerKeyId(signature); if (keyID == null) { @@ -220,6 +227,14 @@ public class SignatureSubpacketsUtil { return hashed(signature, SignatureSubpacket.preferredSymmetricAlgorithms); } + /** + * Return the preferred {@link SymmetricKeyAlgorithm SymmetricKeyAlgorithms} as present in the signature. + * If no preference is given with regard to symmetric encryption algorithms, return an empty set. + * + * In any case, the resulting set is ordered by occurrence ({@link LinkedHashSet}). + * @param signature signature + * @return ordered set of symmetric key algorithm preferences + */ public static Set parsePreferredSymmetricKeyAlgorithms(PGPSignature signature) { Set algorithms = new LinkedHashSet<>(); PreferredAlgorithms preferences = getPreferredSymmetricAlgorithms(signature); @@ -241,6 +256,14 @@ public class SignatureSubpacketsUtil { return hashed(signature, SignatureSubpacket.preferredHashAlgorithms); } + /** + * Return the preferred {@link HashAlgorithm HashAlgorithms} as present in the signature. + * If no preference is given with regard to hash algorithms, return an empty set. + * + * In any case, the resulting set is ordered by occurrence ({@link LinkedHashSet}). + * @param signature signature + * @return ordered set of hash algorithm preferences + */ public static Set parsePreferredHashAlgorithms(PGPSignature signature) { Set algorithms = new LinkedHashSet<>(); PreferredAlgorithms preferences = getPreferredHashAlgorithms(signature); @@ -262,6 +285,14 @@ public class SignatureSubpacketsUtil { return hashed(signature, SignatureSubpacket.preferredCompressionAlgorithms); } + /** + * Return the preferred {@link CompressionAlgorithm CompressionAlgorithms} as present in the signature. + * If no preference is given with regard to compression algorithms, return an empty set. + * + * In any case, the resulting set is ordered by occurrence ({@link LinkedHashSet}). + * @param signature signature + * @return ordered set of compression algorithm preferences + */ public static Set parsePreferredCompressionAlgorithms(PGPSignature signature) { Set algorithms = new LinkedHashSet<>(); PreferredAlgorithms preferences = getPreferredCompressionAlgorithms(signature); @@ -343,6 +374,14 @@ public class SignatureSubpacketsUtil { return Arrays.asList(notations); } + /** + * Return a list of all {@link NotationData} objects from the hashed area of the signature that have a + * notation name equal to the given notationName argument. + * + * @param signature signature + * @param notationName notation name + * @return list of matching notation data objects + */ public static List getHashedNotationData(PGPSignature signature, String notationName) { List allNotations = getHashedNotationData(signature); List withName = new ArrayList<>(); @@ -365,6 +404,14 @@ public class SignatureSubpacketsUtil { return Arrays.asList(notations); } + /** + * Return a list of all {@link NotationData} objects from the unhashed area of the signature that have a + * notation name equal to the given notationName argument. + * + * @param signature signature + * @param notationName notation name + * @return list of matching notation data objects + */ public static List getUnhashedNotationData(PGPSignature signature, String notationName) { List allNotations = getUnhashedNotationData(signature); List withName = new ArrayList<>();