public abstract class AbstractMacIntegrityProtector extends Object
| Modifier and Type | Field and Description |
|---|---|
protected PdfDocument |
document |
protected byte[] |
fileEncryptionKey |
protected byte[] |
kdfSalt |
protected MacProperties |
macProperties |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractMacIntegrityProtector(PdfDocument document,
MacProperties macProperties)
Creates
AbstractMacIntegrityProtector instance from the provided MacProperties. |
protected |
AbstractMacIntegrityProtector(PdfDocument document,
PdfDictionary authDictionary)
Creates
AbstractMacIntegrityProtector instance from the Auth dictionary. |
| Modifier and Type | Method and Description |
|---|---|
protected com.itextpdf.commons.bouncycastle.asn1.IDERSequence |
createMacContainer(byte[] dataDigest,
byte[] macKey,
byte[] signature)
Creates MAC container as ASN1 object based on data digest, MAC key and signature parameters.
|
protected byte[] |
digestBytes(byte[] bytes)
Digests provided bytes based on hash algorithm, specified for this class instance.
|
protected byte[] |
digestBytes(InputStream inputStream)
Digests provided input stream based on hash algorithm, specified for this class instance.
|
protected static byte[] |
generateRandomBytes(int length) |
byte[] |
getKdfSalt()
Gets KDF salt bytes, which are used during MAC key encryption.
|
void |
setFileEncryptionKey(byte[] fileEncryptionKey)
Sets file encryption key to be used during MAC calculation.
|
void |
setKdfSalt(byte[] kdfSalt)
Sets KDF salt bytes, to be used during MAC key encryption.
|
void |
validateMacToken()
Validates MAC container integrity.
|
protected final PdfDocument document
protected final MacProperties macProperties
protected byte[] kdfSalt
protected byte[] fileEncryptionKey
protected AbstractMacIntegrityProtector(PdfDocument document, MacProperties macProperties)
AbstractMacIntegrityProtector instance from the provided MacProperties.document - PdfDocument for which integrity protection is requiredmacProperties - MacProperties used to provide MAC algorithm propertiesprotected AbstractMacIntegrityProtector(PdfDocument document, PdfDictionary authDictionary)
AbstractMacIntegrityProtector instance from the Auth dictionary.document - PdfDocument for which integrity protection is requiredauthDictionary - PdfDictionary representing Auth dictionary in which MAC container is storedpublic void setFileEncryptionKey(byte[] fileEncryptionKey)
fileEncryptionKey - byte[] file encryption key bytespublic byte[] getKdfSalt()
byte[] KDF salt bytes.public void setKdfSalt(byte[] kdfSalt)
kdfSalt - byte[] KDF salt bytes.public void validateMacToken()
PdfException in case of any modifications,
introduced to the document in question, after MAC container is integrated.protected byte[] digestBytes(byte[] bytes)
throws NoSuchAlgorithmException,
IOException,
NoSuchProviderException
bytes - byte[] to be digestedNoSuchAlgorithmException - in case of digesting algorithm related exceptionsIOException - in case of input-output related exceptionsNoSuchProviderException - thrown when a particular security provider is
requested but is not available in the environmentprotected byte[] digestBytes(InputStream inputStream) throws NoSuchAlgorithmException, IOException, NoSuchProviderException
inputStream - InputStream to be digestedNoSuchAlgorithmException - in case of digesting algorithm related exceptionsIOException - in case of input-output related exceptionsNoSuchProviderException - thrown when a particular security provider is
requested but is not available in the environmentprotected com.itextpdf.commons.bouncycastle.asn1.IDERSequence createMacContainer(byte[] dataDigest,
byte[] macKey,
byte[] signature)
throws GeneralSecurityException,
IOException
dataDigest - data digest as byte[] to be used during MAC container creationmacKey - MAC key as byte[] to be used during MAC container creationsignature - signature value as byte[] to be used during MAC container creationIDERSequence.GeneralSecurityException - in case of security related exceptionsIOException - in case of input-output related exceptionsprotected static byte[] generateRandomBytes(int length)
Copyright © 1998–2025 Apryse Group NV. All rights reserved.