iText 9.1.0 API
iText.Kernel.Mac.AbstractMacIntegrityProtector Class Reference

Class responsible for integrity protection in encrypted documents, which uses MAC container. More...

Public Member Functions

virtual void  SetFileEncryptionKey (byte[] fileEncryptionKey)
  Sets file encryption key to be used during MAC calculation. More...
 
virtual byte[]  GetKdfSalt ()
  Gets KDF salt bytes, which are used during MAC key encryption. More...
 
virtual void  SetKdfSalt (byte[] kdfSalt)
  Sets KDF salt bytes, to be used during MAC key encryption. More...
 
virtual void  ValidateMacToken ()
  Validates MAC container integrity. More...
 

Package Functions

  AbstractMacIntegrityProtector (PdfDocument document, MacProperties macProperties)
  Creates AbstractMacIntegrityProtector instance from the provided MacProperties. More...
 
  AbstractMacIntegrityProtector (PdfDocument document, PdfDictionary authDictionary)
  Creates AbstractMacIntegrityProtector instance from the Auth dictionary. More...
 
virtual byte[]  DigestBytes (byte[] bytes)
  Digests provided bytes based on hash algorithm, specified for this class instance. More...
 
virtual byte[]  DigestBytes (Stream inputStream)
  Digests provided input stream based on hash algorithm, specified for this class instance. More...
 
virtual IDerSequence  CreateMacContainer (byte[] dataDigest, byte[] macKey, byte[] signature)
  Creates MAC container as ASN1 object based on data digest, MAC key and signature parameters. More...
 

Static Package Functions

static byte[]  GenerateRandomBytes (int length)
 

Package Attributes

readonly PdfDocument  document
 
readonly MacProperties  macProperties
 
byte[]  kdfSalt = null
 
byte[]  fileEncryptionKey = new byte[0]
 

Detailed Description

Class responsible for integrity protection in encrypted documents, which uses MAC container.

Constructor & Destructor Documentation

◆ AbstractMacIntegrityProtector() [1/2]

iText.Kernel.Mac.AbstractMacIntegrityProtector.AbstractMacIntegrityProtector ( PdfDocument  document,
MacProperties  macProperties 
)
inlinepackage

Creates AbstractMacIntegrityProtector instance from the provided MacProperties.

Parameters
document

iText.Kernel.Pdf.PdfDocument for which integrity protection is required

Parameters
macProperties

MacProperties used to provide MAC algorithm properties

◆ AbstractMacIntegrityProtector() [2/2]

iText.Kernel.Mac.AbstractMacIntegrityProtector.AbstractMacIntegrityProtector ( PdfDocument  document,
PdfDictionary  authDictionary 
)
inlinepackage

Creates AbstractMacIntegrityProtector instance from the Auth dictionary.

Parameters
document

iText.Kernel.Pdf.PdfDocument for which integrity protection is required

Parameters
authDictionary

iText.Kernel.Pdf.PdfDictionary representing Auth dictionary in which MAC container is stored

Member Function Documentation

◆ CreateMacContainer()

virtual IDerSequence iText.Kernel.Mac.AbstractMacIntegrityProtector.CreateMacContainer ( byte[]  dataDigest,
byte[]  macKey,
byte[]  signature 
)
inlinepackagevirtual

Creates MAC container as ASN1 object based on data digest, MAC key and signature parameters.

Parameters
dataDigest data digest as byte[] to be used during MAC container creation
macKey MAC key as byte[] to be used during MAC container creation
signature signature value as byte[] to be used during MAC container creation
Returns
MAC container as iText.Commons.Bouncycastle.Asn1.IDerSequence.

◆ DigestBytes() [1/2]

virtual byte [] iText.Kernel.Mac.AbstractMacIntegrityProtector.DigestBytes ( byte[]  bytes )
inlinepackagevirtual

Digests provided bytes based on hash algorithm, specified for this class instance.

Parameters
bytes

byte[] to be digested

Returns
digested bytes.

◆ DigestBytes() [2/2]

virtual byte [] iText.Kernel.Mac.AbstractMacIntegrityProtector.DigestBytes ( Stream  inputStream )
inlinepackagevirtual

Digests provided input stream based on hash algorithm, specified for this class instance.

Parameters
inputStream

System.IO.Stream to be digested

Returns
digested bytes.

◆ GetKdfSalt()

virtual byte [] iText.Kernel.Mac.AbstractMacIntegrityProtector.GetKdfSalt ( )
inlinevirtual

Gets KDF salt bytes, which are used during MAC key encryption.

Returns

byte[] KDF salt bytes.

◆ SetFileEncryptionKey()

virtual void iText.Kernel.Mac.AbstractMacIntegrityProtector.SetFileEncryptionKey ( byte[]  fileEncryptionKey )
inlinevirtual

Sets file encryption key to be used during MAC calculation.

Parameters
fileEncryptionKey

byte[] file encryption key bytes

◆ SetKdfSalt()

virtual void iText.Kernel.Mac.AbstractMacIntegrityProtector.SetKdfSalt ( byte[]  kdfSalt )
inlinevirtual

Sets KDF salt bytes, to be used during MAC key encryption.

Parameters
kdfSalt

byte[] KDF salt bytes.

◆ ValidateMacToken()

virtual void iText.Kernel.Mac.AbstractMacIntegrityProtector.ValidateMacToken ( )
inlinevirtual

Validates MAC container integrity.

Validates MAC container integrity. This method throws iText.Kernel.Exceptions.PdfException in case of any modifications, introduced to the document in question, after MAC container is integrated.