Class PdfEncryption
- Namespace
- iTextSharp.text.pdf
- Assembly
- iTextSharp.LGPLv2.Core.dll
@author Paulo Soares (psoares@consiste.pt) and some of it has been ported from https://github.com/LibrePDF/OpenPDF/pull/802
public class PdfEncryption
- Inheritance
-
PdfEncryption
- Inherited Members
Constructors
PdfEncryption()
public PdfEncryption()
PdfEncryption(PdfEncryption)
public PdfEncryption(PdfEncryption enc)
Parameters
enc
PdfEncryption
Fields
AES_128
public const int AES_128 = 4
Field Value
AES_256_V3
public const int AES_256_V3 = 6
Field Value
PublicKeyHandler
The public key security handler for certificate encryption
protected PdfPublicKeySecurityHandler PublicKeyHandler
Field Value
STANDARD_ENCRYPTION_128
public const int STANDARD_ENCRYPTION_128 = 3
Field Value
STANDARD_ENCRYPTION_40
public const int STANDARD_ENCRYPTION_40 = 2
Field Value
Properties
FileId
public PdfObject FileId { get; }
Property Value
Methods
AddRecipient(X509Certificate, int)
public void AddRecipient(X509Certificate cert, int permission)
Parameters
cert
X509Certificatepermission
int
CalculateStreamSize(int)
public int CalculateStreamSize(int n)
Parameters
n
int
Returns
ComputeUserPassword(byte[])
public byte[] ComputeUserPassword(byte[] ownerPassword)
Parameters
ownerPassword
byte[]
Returns
- byte[]
CreateDocumentId()
public static byte[] CreateDocumentId()
Returns
- byte[]
CreateInfoId(byte[])
public static PdfObject CreateInfoId(byte[] id)
Parameters
id
byte[]
Returns
DecryptAndCheckPerms(byte[])
implements step f of Algorithm 2.A: Retrieving the file encryption key from an encrypted document in order to decrypt it (revision 6 and later) - ISO 32000-2 section 7.6.4.3.3
public bool DecryptAndCheckPerms(byte[] permsValue)
Parameters
permsValue
byte[]
Returns
DecryptByteArray(byte[])
public byte[] DecryptByteArray(byte[] b)
Parameters
b
byte[]
Returns
- byte[]
EncryptByteArray(byte[])
public byte[] EncryptByteArray(byte[] b)
Parameters
b
byte[]
Returns
- byte[]
GetCryptoMode()
public int GetCryptoMode()
Returns
GetDecryptor()
public StandardDecryption GetDecryptor()
Returns
GetEncryptionDictionary()
public PdfDictionary GetEncryptionDictionary()
Returns
GetEncryptionStream(Stream)
public OutputStreamEncryption GetEncryptionStream(Stream os)
Parameters
os
Stream
Returns
HashAlg2B(byte[], byte[], byte[])
implements Algorithm 2.B: Computing a hash (revision 6 and later) - ISO 32000-2 section 7.6.4.3.4
public static byte[] HashAlg2B(byte[] input, byte[] salt, byte[] userKey)
Parameters
Returns
- byte[]
IsEmbeddedFilesOnly()
Indicates if only the embedded files have to be encrypted. @since 2.1.3
public bool IsEmbeddedFilesOnly()
Returns
- bool
if true only the embedded files will be encrypted
IsMetadataEncrypted()
public bool IsMetadataEncrypted()
Returns
SetCryptoMode(int, int)
public void SetCryptoMode(int mode, int kl)
Parameters
SetHashKey(int, int)
public void SetHashKey(int number, int generation)
Parameters
SetupAllKeys(byte[], byte[], int)
gets keylength and revision and uses revison to choose the initial values for permissions
public void SetupAllKeys(byte[] userPassword, byte[] ownerPassword, int permissions)
Parameters
SetupByEncryptionKey(byte[], int)
public void SetupByEncryptionKey(byte[] key, int keyLength)
Parameters
SetupByOwnerPassword(byte[], byte[], byte[], byte[], byte[], byte[], int)
implements step d of Algorithm 2.A: Retrieving the file encryption key from an encrypted document in order to decrypt it (revision 6 and later) - ISO 32000-2 section 7.6.4.3.3
public void SetupByOwnerPassword(byte[] documentId, byte[] ownerPassword, byte[] uValue, byte[] ueValue, byte[] oValue, byte[] oeValue, int permissions)
Parameters
documentId
byte[]ownerPassword
byte[]uValue
byte[]ueValue
byte[]oValue
byte[]oeValue
byte[]permissions
int
SetupByOwnerPassword(byte[], byte[], byte[], byte[], int)
public void SetupByOwnerPassword(byte[] documentId, byte[] ownerPassword, byte[] userKey, byte[] ownerKey, int permissions)
Parameters
SetupByUserPassword(byte[], byte[], byte[], byte[], byte[], byte[], int)
implements step e of Algorithm 2.A: Retrieving the file encryption key from an encrypted document in order to decrypt it (revision 6 and later) - ISO 32000-2 section 7.6.4.3.3
public void SetupByUserPassword(byte[] documentId, byte[] userPassword, byte[] uValue, byte[] ueValue, byte[] oValue, byte[] oeValue, int permissions)
Parameters
documentId
byte[]userPassword
byte[]uValue
byte[]ueValue
byte[]oValue
byte[]oeValue
byte[]permissions
int
SetupByUserPassword(byte[], byte[], byte[], int)
public void SetupByUserPassword(byte[] documentId, byte[] userPassword, byte[] ownerKey, int permissions)