Package com.itextpdf.text.pdf.security
Class DigestAlgorithms
java.lang.Object
com.itextpdf.text.pdf.security.DigestAlgorithms
Class that contains a map with the different message digest algorithms.
-
Field Summary
FieldsModifier and TypeFieldDescriptionMaps the name of a digest algorithm with its ID.Maps the digest IDs with the human-readable name of the digest algorithm.Maps digest algorithm that are unknown by the JDKs MessageDigest object to a known one.static final String
Algorithm available for signatures since PDF 1.7static final String
Algorithm available for signatures since PDF 1.3static final String
Algorithm available for signatures since PDF 1.6static final String
Algorithm available for signatures since PDF 1.7static final String
Algorithm available for signatures since PDF 1.7 -
Constructor Summary
Constructors -
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) static String
getAllowedDigests
(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) static String
normalizeDigestName
(String algo)
-
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:
-
digestNames
Maps the digest IDs with the human-readable name of the digest algorithm. -
fixNames
Maps digest algorithm that are unknown by the JDKs MessageDigest object to a known one. -
allowedDigests
Maps the name of a digest algorithm with its ID.
-
-
Constructor Details
-
DigestAlgorithms
public DigestAlgorithms()
-
-
Method Details
-
getMessageDigestFromOid
public static MessageDigest getMessageDigestFromOid(String digestOid, String provider) throws NoSuchAlgorithmException, NoSuchProviderException -
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 hashprovider
- the provider you want to use to create the hash- Returns:
- a MessageDigest object
- Throws:
NoSuchAlgorithmException
NoSuchProviderException
GeneralSecurityException
-
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 hashhashAlgorithm
- the algorithm used to create the hashprovider
- the provider used to create the hash- Returns:
- the hash
- Throws:
GeneralSecurityException
IOException
-
digest
public static byte[] digest(InputStream data, MessageDigest messageDigest) throws GeneralSecurityException, IOException - Throws:
GeneralSecurityException
IOException
-
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
-
getAllowedDigests
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
-