Class CryptoUtil

  • All Implemented Interfaces:
    ICryptoUtil

    public final class CryptoUtil
    extends java.lang.Object
    implements ICryptoUtil

    Utility class contains encryption and hash functions for digital signature.

    Project:

    Library for the integration with the services of @Firma, eVisor and TS@.

    Version:
    1.2, 14/03/2017.
    • Method Detail

      • digest

        public static byte[] digest​(java.lang.String algorithm,
                                    byte[] data)
                             throws SigningException
        Method that obtains the hash computation from a array bytes.
        Parameters:
        algorithm - Parameter that represents the algorithm used in the hash computation.
        data - Parameter that represents the source data.
        Returns:
        the hash value.
        Throws:
        SigningException - If a MessageDigestSpi implementation for the specified algorithm is not available from the specified Provider object.
      • translateAlgorithmIdentifier

        public static java.lang.String translateAlgorithmIdentifier​(org.bouncycastle.asn1.x509.AlgorithmIdentifier algorithmIdentifier)
        Method that translates a AlgorithmIdentifier object to a digest algorithm string.
        Parameters:
        algorithmIdentifier - Parameter that represents the OID of the digest algorithm.
        Returns:
        the digest algorithm name.
      • getAlgorithmIdentifierByName

        public static org.bouncycastle.asn1.x509.AlgorithmIdentifier getAlgorithmIdentifierByName​(java.lang.String hashAlgorithm)
        Method that obtains the OID of a hash algorithm from the name.
        Parameters:
        hashAlgorithm - Parameter that represents the name of the hash algorithm.
        Returns:
        the OID value.
      • translateXmlDigestAlgorithm

        public static java.lang.String translateXmlDigestAlgorithm​(java.lang.String digestAlg)
        Method that translates a AlgorithmIdentifier object to a digest algorithm string.
        Parameters:
        digestAlg - Parameter that represents the digest method algorithm URI.
        Returns:
        the digest algorithm name.
      • getDigestAlgorithmName

        public static java.lang.String getDigestAlgorithmName​(java.lang.String pseudoName)
        Method that gets the name of a digest algorithm by name or alias.
        Parameters:
        pseudoName - Parameter that represents the name or alias of the digest algorithm.
        Returns:
        the name of the digest algorithm.
      • generateMessageImprintFromXMLAlgorithm

        public static org.bouncycastle.asn1.tsp.MessageImprint generateMessageImprintFromXMLAlgorithm​(java.lang.String hashAlgXML,
                                                                                                      byte[] data)
        Method that obtains the MessageImprint from the digest method algorithm URI.
        Parameters:
        hashAlgXML - Parameter that represents the digest method algorithm URI.
        data - Parameter that represents the hashed message.
        Returns:
        the generated MessageImprint.