Klasse AlgorithmExtensions
java.lang.Object
io.github.astrapi69.crypt.data.algorithm.AlgorithmExtensions
The class
AlgorithmExtensions provides methods to validate if a given algorithm is
supported for a specific service and to retrieve the supported algorithms for a service-
Methodenübersicht
Modifizierer und TypMethodeBeschreibunggetAlgorithms(@NonNull String serviceName) Retrieves a set of algorithms for the specified Java cryptographic servicegetAlgorithmsFromServiceName(@NonNull String serviceName, @NonNull String keyAlgorithm) Retrieves a list of algorithms that are appropriate for the specified key algorithm based on the provided service namegetAllServiceNames(Provider[] providers) Retrieves all specified Java cryptographic service names from the givenProviderarray objectgetServiceNames(@NonNull Provider provider) Retrieves all specified Java cryptographic service names from the givenProviderobjectgetSupportedAlgorithmsAndKeySizes(String serviceName, Class<T> generatorClass, KeySizeInitializer<T> initializer, int minSize, int maxSize, int increment) Retrieves a map of supported cryptographic algorithms and their corresponding supported key sizes for a specified service.static booleanValidates if the provided algorithm is supported for the given service name
-
Methodendetails
-
getSupportedAlgorithmsAndKeySizes
public static <T> Map<String,Set<Integer>> getSupportedAlgorithmsAndKeySizes(String serviceName, Class<T> generatorClass, KeySizeInitializer<T> initializer, int minSize, int maxSize, int increment) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException Retrieves a map of supported cryptographic algorithms and their corresponding supported key sizes for a specified service.This method identifies the available algorithms for a given cryptographic service (e.g., "KeyPairGenerator") and determines the supported key sizes for each algorithm within a specified range. The determination is based on the capabilities of a provided generator class and an initializer.
- Typparameter:
T- the type of the generator class used to determine key sizes.- Parameter:
serviceName- the name of the cryptographic service (e.g., "KeyPairGenerator").generatorClass- the class of the generator used to produce cryptographic keys.initializer- a functional interface or lambda expression that initializes the generator class with a specific key size.minSize- the minimum key size to consider in the analysis.maxSize- the maximum key size to consider in the analysis.increment- the step size for iterating through key sizes between minSize and maxSize.- Gibt zurück:
- a
Map<String, Set<Integer>>where each key is the name of a cryptographic algorithm, and each value is a set of integers representing the supported key sizes for that algorithm. - Löst aus:
InvocationTargetException- if an error occurs while invoking the initializer or generator methods.NoSuchMethodException- if a necessary method to initialize the generator class cannot be found.IllegalAccessException- if the initializer or generator method is not accessible.
-
getAlgorithmsFromServiceName
public static List<String> getAlgorithmsFromServiceName(@NonNull @NonNull String serviceName, @NonNull @NonNull String keyAlgorithm) Retrieves a list of algorithms that are appropriate for the specified key algorithm based on the provided service name- Parameter:
serviceName- the name of the service, for instance "Signature"keyAlgorithm- the key algorithm (e.g., "RSA") for which to find appropriate signature algorithms- Gibt zurück:
- a list of algorithms that match the specified key algorithm
-
isValid
public static boolean isValid(@NonNull @NonNull String serviceName, @NonNull @NonNull String algorithm) Validates if the provided algorithm is supported for the given service name- Parameter:
serviceName- the name of the security servicealgorithm- the algorithm to be validated- Gibt zurück:
- true if the algorithm is supported, false otherwise
-
getAlgorithms
Retrieves a set of algorithms for the specified Java cryptographic serviceThis method calls the
Security.getAlgorithms(String)method to obtain a set of algorithm names supported by the specified security service- Parameter:
serviceName- the name of the security service (e.g., "Cipher", "KeyAgreement", "MessageDigest", etc.) for which the supported algorithms are to be retrieved- Gibt zurück:
- a
SetofStringcontaining the names of the algorithms supported by the specified security service. The set is not modifiable - Löst aus:
NullPointerException- ifserviceNameis null- Siehe auch:
-
getServiceNames
Retrieves all specified Java cryptographic service names from the givenProviderobject -
getAllServiceNames
Retrieves all specified Java cryptographic service names from the givenProviderarray object- Parameter:
providers- the array with theProviderobjects- Gibt zurück:
- a set of all specified Java cryptographic service names
-