Class SignatureAlgorithmResolver
java.lang.Object
io.github.astrapi69.crypt.data.algorithm.SignatureAlgorithmResolver
Utility class for verifying supported signature algorithms based on key pair algorithms and their
key sizes The class provides methods to test and verify if a given combination of key pair and
signature algorithms can successfully generate an X.509 certificate
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetSupportedSignatureAlgorithms
(String serviceName, Class<T> generatorClass, KeySizeInitializer<T> initializer, int minSize, int maxSize, int increment) Retrieves a map of supported signature algorithms for a specified cryptographic service The method generates key pairs for each algorithm and key size within the provided range, and tests whether they can successfully create an X.509 certificate using various signature algorithmsstatic boolean
isAlgorithmValidForCertificate
(CertificateInfo certificateInfo) Tests whether a given signature algorithm can be used to successfully create anX509Certificate
-
Constructor Details
-
SignatureAlgorithmResolver
public SignatureAlgorithmResolver()
-
-
Method Details
-
getSupportedSignatureAlgorithms
public static <T> Map<String,Set<String>> getSupportedSignatureAlgorithms(String serviceName, Class<T> generatorClass, KeySizeInitializer<T> initializer, int minSize, int maxSize, int increment) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException, NoSuchAlgorithmException, NoSuchProviderException Retrieves a map of supported signature algorithms for a specified cryptographic service The method generates key pairs for each algorithm and key size within the provided range, and tests whether they can successfully create an X.509 certificate using various signature algorithms- Type Parameters:
T
- the type of the generator class used to determine key sizes- Parameters:
serviceName
- the name of the cryptographic service (e.g., "KeyPairGenerator")generatorClass
- the class of the generator used to produce cryptographic keysinitializer
- a functional interface or lambda expression that initializes the generator class with a specific key sizeminSize
- the minimum key size to consider in the analysismaxSize
- the maximum key size to consider in the analysisincrement
- the step size for iterating through key sizes between minSize and maxSize- Returns:
- a
Map<String, Set<String>>
where each key is the name of a key pair algorithm, and each value is a set of valid signature algorithms for that algorithm - Throws:
InvocationTargetException
- if an error occurs while invoking the initializer or generator methodsNoSuchMethodException
- if a necessary method to initialize the generator class cannot be foundIllegalAccessException
- if the initializer or generator method is not accessibleNoSuchAlgorithmException
- if the specified algorithm cannot be foundNoSuchProviderException
- if the specified provider cannot be found
-
isAlgorithmValidForCertificate
Tests whether a given signature algorithm can be used to successfully create anX509Certificate
- Parameters:
certificateInfo
- the certificate information containing details like issuer, subject, etc- Returns:
- true if the algorithm is valid and can be used to create the certificate, false otherwise
-