Package eu.europa.esig.dss.enumerations
Enum DigestAlgorithm
- java.lang.Object
-
- java.lang.Enum<DigestAlgorithm>
-
- eu.europa.esig.dss.enumerations.DigestAlgorithm
-
- All Implemented Interfaces:
OidAndUriBasedEnum,OidBasedEnum,UriBasedEnum,Serializable,Comparable<DigestAlgorithm>
public enum DigestAlgorithm extends Enum<DigestAlgorithm> implements OidAndUriBasedEnum
Supported Algorithms
-
-
Enum Constant Summary
Enum Constants Enum Constant Description MD2MD2MD5MD5RIPEMD160RIPEMD160SHA1SHA-1SHA224SHA-224SHA256SHA-256SHA3_224SHA3-224SHA3_256SHA3-256SHA3_384SHA3-384SHA3_512SHA3-512SHA384SHA-384SHA512SHA-512SHAKE128SHAKE-128SHAKE256SHAKE-256SHAKE256_512SHAKE-256 + output 512bitsWHIRLPOOLWHIRLPOOL
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DigestAlgorithmforHttpHeader(String hashName)Returns the digest algorithm associated to the given JWS Http Header Hash Algorithm.static DigestAlgorithmforJAdES(String algoId)Returns the digest algorithm associated with the given identifier, according to TS 119 182-1, Annex E (Digest algorithms identifiers for JAdES signatures)static DigestAlgorithmforJavaName(String javaName)Returns the digest algorithm associated to the given JCE name.static DigestAlgorithmforName(String name)Returns the digest algorithm associated to the given name.static DigestAlgorithmforName(String name, DigestAlgorithm defaultValue)Returns the digest algorithm associated to the given name.static DigestAlgorithmforOID(String oid)Returns the digest algorithm associated to the given OID.static DigestAlgorithmforXML(String xmlName)Returns the digest algorithm associated to the given XML url.StringgetHttpHeaderAlgo()Get the algorithm name according to RFC 5843StringgetJAdESId()Get the algorithm id used in JAdES Signatures.StringgetJavaName()Get the JCE algorithm nameMessageDigestgetMessageDigest()Get a new instance of MessageDigest for the current digestAlgorithmMessageDigestgetMessageDigest(Provider provider)Get a new instance of MessageDigest for the current digestAlgorithmStringgetName()Get the algorithm nameStringgetOid()Get the algorithm OIDintgetSaltLength()Get the salt length (PSS)StringgetUri()Get the algorithm uristatic booleanisSupportedAlgorithm(String name)Returns indication if the algorithm with givennameis supportedstatic DigestAlgorithmvalueOf(String name)Returns the enum constant of this type with the specified name.static DigestAlgorithm[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
SHA1
public static final DigestAlgorithm SHA1
SHA-1
-
SHA224
public static final DigestAlgorithm SHA224
SHA-224
-
SHA256
public static final DigestAlgorithm SHA256
SHA-256
-
SHA384
public static final DigestAlgorithm SHA384
SHA-384
-
SHA512
public static final DigestAlgorithm SHA512
SHA-512
-
SHA3_224
public static final DigestAlgorithm SHA3_224
SHA3-224
-
SHA3_256
public static final DigestAlgorithm SHA3_256
SHA3-256
-
SHA3_384
public static final DigestAlgorithm SHA3_384
SHA3-384
-
SHA3_512
public static final DigestAlgorithm SHA3_512
SHA3-512
-
SHAKE128
public static final DigestAlgorithm SHAKE128
SHAKE-128
-
SHAKE256
public static final DigestAlgorithm SHAKE256
SHAKE-256
-
SHAKE256_512
public static final DigestAlgorithm SHAKE256_512
SHAKE-256 + output 512bits
-
RIPEMD160
public static final DigestAlgorithm RIPEMD160
RIPEMD160
-
MD2
public static final DigestAlgorithm MD2
MD2
-
MD5
public static final DigestAlgorithm MD5
MD5
-
WHIRLPOOL
public static final DigestAlgorithm WHIRLPOOL
WHIRLPOOL
-
-
Method Detail
-
values
public static DigestAlgorithm[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (DigestAlgorithm c : DigestAlgorithm.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static DigestAlgorithm valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
forName
public static DigestAlgorithm forName(String name)
Returns the digest algorithm associated to the given name.- Parameters:
name- the algorithm name- Returns:
- the digest algorithm linked to the given name
- Throws:
IllegalArgumentException- if the given name doesn't match any algorithm
-
forName
public static DigestAlgorithm forName(String name, DigestAlgorithm defaultValue)
Returns the digest algorithm associated to the given name.- Parameters:
name- the algorithm namedefaultValue- The default value for theDigestAlgorithm- Returns:
- the corresponding
DigestAlgorithmor the default value
-
isSupportedAlgorithm
public static boolean isSupportedAlgorithm(String name)
Returns indication if the algorithm with givennameis supported- Parameters:
name-Stringtarget algorithm's name- Returns:
- TRUE if the algorithm is supported, FALSE otherwise
-
forJavaName
public static DigestAlgorithm forJavaName(String javaName)
Returns the digest algorithm associated to the given JCE name.- Parameters:
javaName- the JCE algorithm name- Returns:
- the digest algorithm linked to the given name
- Throws:
IllegalArgumentException- if the given name doesn't match any algorithm
-
forOID
public static DigestAlgorithm forOID(String oid)
Returns the digest algorithm associated to the given OID.- Parameters:
oid- the algorithm oid- Returns:
- the digest algorithm linked to the oid
- Throws:
IllegalArgumentException- if the oid doesn't match any digest algorithm
-
forXML
public static DigestAlgorithm forXML(String xmlName)
Returns the digest algorithm associated to the given XML url.- Parameters:
xmlName- the algorithm uri- Returns:
- the digest algorithm linked to the given uri
- Throws:
IllegalArgumentException- if the uri doesn't match any digest algorithm
-
forJAdES
public static DigestAlgorithm forJAdES(String algoId)
Returns the digest algorithm associated with the given identifier, according to TS 119 182-1, Annex E (Digest algorithms identifiers for JAdES signatures)- Parameters:
algoId-StringJAdES algorithm identifier- Returns:
- the digest algorithm linked to the given identifier
- Throws:
IllegalArgumentException- if the name doesn't match any digest algorithm
-
forHttpHeader
public static DigestAlgorithm forHttpHeader(String hashName)
Returns the digest algorithm associated to the given JWS Http Header Hash Algorithm. See RFC 5843.- Parameters:
hashName- the algorithm name by RFC 5843- Returns:
- the digest algorithm linked to the given name
- Throws:
IllegalArgumentException- if the name doesn't match any digest algorithm
-
getName
public String getName()
Get the algorithm name- Returns:
- the algorithm name
-
getJavaName
public String getJavaName()
Get the JCE algorithm name- Returns:
- the java algorithm name
-
getOid
public String getOid()
Get the algorithm OID- Specified by:
getOidin interfaceOidBasedEnum- Returns:
- the ASN1 algorithm OID
-
getUri
public String getUri()
Get the algorithm uri- Specified by:
getUriin interfaceUriBasedEnum- Returns:
- the algorithm uri
-
getJAdESId
public String getJAdESId()
Get the algorithm id used in JAdES Signatures. TS 119-182 Annex E (normative): Digest algorithms identifiers for JAdES signatures- Returns:
- the algorithm JAdES identifier
-
getHttpHeaderAlgo
public String getHttpHeaderAlgo()
Get the algorithm name according to RFC 5843- Returns:
- the algorithm name
-
getSaltLength
public int getSaltLength()
Get the salt length (PSS)- Returns:
- the salt length
-
getMessageDigest
public MessageDigest getMessageDigest() throws NoSuchAlgorithmException
Get a new instance of MessageDigest for the current digestAlgorithm- Returns:
- an instance of MessageDigest
- Throws:
NoSuchAlgorithmException- if the algorithm is not supported
-
getMessageDigest
public MessageDigest getMessageDigest(Provider provider) throws NoSuchAlgorithmException
Get a new instance of MessageDigest for the current digestAlgorithm- Parameters:
provider- the security provider to be used- Returns:
- an instance of MessageDigest
- Throws:
NoSuchAlgorithmException- if the algorithm is not supported
-
-