Class SignatureAlgorithmResolver

java.lang.Object
io.github.astrapi69.crypt.data.algorithm.SignatureAlgorithmResolver

public class SignatureAlgorithmResolver extends Object
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 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 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
      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 methods
      NoSuchMethodException - if a necessary method to initialize the generator class cannot be found
      IllegalAccessException - if the initializer or generator method is not accessible
      NoSuchAlgorithmException - if the specified algorithm cannot be found
      NoSuchProviderException - if the specified provider cannot be found
    • isAlgorithmValidForCertificate

      public static boolean isAlgorithmValidForCertificate(CertificateInfo certificateInfo)
      Tests whether a given signature algorithm can be used to successfully create an X509Certificate
      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