Package com.itextpdf.signatures
Class DigestAlgorithms
java.lang.Object
com.itextpdf.signatures.DigestAlgorithms
Class that contains a map with the different message digest algorithms.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Algorithm available for signatures since PDF 1.7.static final String
Algorithm available for signatures since PDF 1.3.static final String
Algorithm available for signatures since PDF 1.6.static final String
Algorithm available for signatures since PDF 2.0 extended by ISO/TS 32001.static final String
Algorithm available for signatures since PDF 2.0 extended by ISO/TS 32001.static final String
Algorithm available for signatures since PDF 2.0 extended by ISO/TS 32001.static final String
Algorithm available for signatures since PDF 1.7.static final String
Algorithm available for signatures since PDF 1.7.static final String
Algorithm available for signatures since PDF 2.0 extended by ISO/TS 32001. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
digest
(InputStream data, String hashAlgorithm, String provider) Creates a hash using a specific digest algorithm and a provider.static byte[]
digest
(InputStream data, MessageDigest messageDigest) Create a digest based on the inputstream.static String
getAllowedDigest
(String name) Returns the id of a digest algorithms that is allowed in PDF, or null if it isn't allowed.static String
Gets the digest name for a certain idstatic MessageDigest
getMessageDigest
(String hashAlgorithm, String provider) Creates a MessageDigest object that can be used to create a hash.static MessageDigest
getMessageDigestFromOid
(String digestOid, String provider) Get a digest algorithm.static int
getOutputBitLength
(String name) Retrieve the output length in bits of the given digest algorithm.static String
normalizeDigestName
(String algo) Normalize the digest name.
-
Field Details
-
SHA1
Algorithm available for signatures since PDF 1.3.- See Also:
-
SHA256
Algorithm available for signatures since PDF 1.6.- See Also:
-
SHA384
Algorithm available for signatures since PDF 1.7.- See Also:
-
SHA512
Algorithm available for signatures since PDF 1.7.- See Also:
-
RIPEMD160
Algorithm available for signatures since PDF 1.7.- See Also:
-
SHA3_256
Algorithm available for signatures since PDF 2.0 extended by ISO/TS 32001.- See Also:
-
SHA3_512
Algorithm available for signatures since PDF 2.0 extended by ISO/TS 32001.- See Also:
-
SHA3_384
Algorithm available for signatures since PDF 2.0 extended by ISO/TS 32001.- See Also:
-
SHAKE256
Algorithm available for signatures since PDF 2.0 extended by ISO/TS 32001.The output length is fixed at 512 bits (64 bytes).
- See Also:
-
-
Constructor Details
-
DigestAlgorithms
public DigestAlgorithms()
-
-
Method Details
-
getMessageDigestFromOid
public static MessageDigest getMessageDigestFromOid(String digestOid, String provider) throws NoSuchAlgorithmException, NoSuchProviderException Get a digest algorithm.- Parameters:
-
digestOid
- oid of the digest algorithm -
provider
- the provider you want to use to create the hash - Returns:
- MessageDigest object
- Throws:
-
NoSuchAlgorithmException
- thrown when a particular cryptographic algorithm is requested but is not available in the environment -
NoSuchProviderException
- thrown when a particular security provider is requested but is not available in the environment
-
getMessageDigest
public static MessageDigest getMessageDigest(String hashAlgorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException Creates a MessageDigest object that can be used to create a hash.- Parameters:
-
hashAlgorithm
- the algorithm you want to use to create a hash -
provider
- the provider you want to use to create the hash - Returns:
- a MessageDigest object
- Throws:
-
NoSuchAlgorithmException
- thrown when a particular cryptographic algorithm is requested but is not available in the environment -
NoSuchProviderException
- thrown when a particular security provider is requested but is not available in the environment
-
digest
public static byte[] digest(InputStream data, String hashAlgorithm, String provider) throws GeneralSecurityException, IOException Creates a hash using a specific digest algorithm and a provider.- Parameters:
-
data
- the message of which you want to create a hash -
hashAlgorithm
- the algorithm used to create the hash -
provider
- the provider used to create the hash - Returns:
- the hash
- Throws:
-
GeneralSecurityException
- when requested cryptographic algorithm or security provider is not available -
IOException
- signals that an I/O exception has occurred
-
digest
Create a digest based on the inputstream.- Parameters:
-
data
- data to be digested -
messageDigest
- algorithm to be used - Returns:
- digest of the data
- Throws:
-
IOException
- signals that an I/O exception has occurred
-
getDigest
Gets the digest name for a certain id- Parameters:
-
oid
- an id (for instance "1.2.840.113549.2.5") - Returns:
- a digest name (for instance "MD5")
-
normalizeDigestName
Normalize the digest name.- Parameters:
-
algo
- the name to be normalized - Returns:
- normalized name
-
getAllowedDigest
Returns the id of a digest algorithms that is allowed in PDF, or null if it isn't allowed.- Parameters:
-
name
- The name of the digest algorithm. - Returns:
- An oid.
-
getOutputBitLength
Retrieve the output length in bits of the given digest algorithm.- Parameters:
-
name
- the name of the digest algorithm - Returns:
- the length of the output of the algorithm in bits
-