PDFium Delphi Component Docs

FPdfAes Unità

Unità: FPdfAes
Cifrario a blocchi AES-128 e AES-256 in puro Pascal con espansione delle chiavi, encrypt/decrypt a blocco singolo e wrapper di flusso AES-256-CBC usati dai gestori di crittografia PDF

Sintassi

TAesBlock = array[0..15] of Byte;
TAes128Key = array[0..15] of Byte;
TAes128ExpandedKey = array[0..175] of Byte;
TAes256Key = array[0..31] of Byte;
TAes256ExpandedKey = array[0..239] of Byte;

procedure Aes128KeyExpansion(const Key: TAes128Key; var Expanded: TAes128ExpandedKey);
procedure Aes128EncryptBlock(const Expanded: TAes128ExpandedKey;
  const Input: TAesBlock; var Output: TAesBlock);
procedure Aes256KeyExpansion(const Key: TAes256Key; var Expanded: TAes256ExpandedKey);
procedure Aes256EncryptBlock(const Expanded: TAes256ExpandedKey;
  const Input: TAesBlock; var Output: TAesBlock);
procedure Aes256DecryptBlock(const Expanded: TAes256ExpandedKey;
  const Input: TAesBlock; var Output: TAesBlock);
function Aes256CbcEncryptPKCS7(const Key: TAes256Key; const IV: TAesBlock;
  const Plain: TBytes): TBytes;
function Aes256CbcEncryptNoPad(const Key: TAes256Key; const IV: TAesBlock;
  const Plain: TBytes): TBytes;
function Aes256CbcDecryptPKCS7(const Key: TAes256Key; const IV: TAesBlock;
  const Cipher: TBytes): TBytes;
function Aes256CbcDecryptNoPad(const Key: TAes256Key; const IV: TAesBlock;
  const Cipher: TBytes): TBytes;
function Aes256KeyWrap(const KeyEncryptionKey: TAes256Key;
  const PlainKeyData: TBytes): TBytes;
function Aes256KeyUnwrap(const KeyEncryptionKey: TAes256Key; const WrappedKeyData: TBytes;
  out PlainKeyData: TBytes): Boolean;
procedure AesGenerateRandomBytes(Buffer: Pointer; Count: Integer);

Descrizione

FPdfAes è un'implementazione AES senza dipendenze fornita affinché PDFium Delphi Component possa crittografare e decrittare i flussi PDF su Delphi, C++Builder e Free Pascal senza affidarsi a una libreria crittografica esterna. Viene consumata dal security handler AES-256 PDF in FPdfEncrypt e dalla modalità GCM in FPdfAesGcm

Le primitive a blocchi operano su blocchi fissi di 16 byte tramite chiavi rotonde espanse. I wrapper CBC gestiscono il padding PKCS#7 o nessun padding su array di byte a lunghezza variabile, corrispondendo alle due modalità di crittografia dei flussi richieste dalla specifica PDF

AesGenerateRandomBytes riempie un buffer con byte casuali crittograficamente usati per IV, salt e chiavi

Funzioni

FunctionDescription
Aes128KeyExpansionEspande una chiave a 128 bit nel programma di round-key a 176 byte
Aes128EncryptBlockCifra un blocco da 16 byte con una chiave AES-128 espansa
Aes256KeyExpansionEspande una chiave a 256 bit nel programma di round-key a 240 byte
Aes256EncryptBlockCifra un blocco da 16 byte con una chiave AES-256 espansa
Aes256DecryptBlockDecifra un blocco da 16 byte con una chiave AES-256 espansa
Aes256CbcEncryptPKCS7Cifra un array di byte in modalità CBC con padding PKCS#7
Aes256CbcEncryptNoPadCifra un array di byte in modalità CBC senza padding (la lunghezza dell'input deve essere un multiplo del blocco)
Aes256CbcDecryptPKCS7Decifra un ciphertext CBC e rimuove il padding PKCS#7
Aes256CbcDecryptNoPadDecifra un ciphertext CBC senza rimuovere il padding
Aes256KeyWrapIncapsula dati di chiave con AES-256 usando la protezione di integrità RFC 3394
Aes256KeyUnwrapAutentica e disincapsula dati di chiave RFC 3394, senza restituire plaintext in caso di fallimento dell'integrità
AesGenerateRandomBytesRiempie un buffer con byte casuali crittografici

Tipi

TypeDescription
TAesBlockUn blocco dati AES da 16 byte, l'unità delle primitive a blocco singolo e del passaggio di concatenamento CBC, nonché il tipo IV dei wrapper CBC
TAes128KeyChiave AES-128 da 16 byte accettata da Aes128KeyExpansion
TAes128ExpandedKeyRound-key schedule AES-128 di 176 byte prodotto da Aes128KeyExpansion e consumato da Aes128EncryptBlock
TAes256KeyChiave AES-256 da 32 byte accettata da Aes256KeyExpansion, dai wrapper CBC e dalle funzioni di key-wrap RFC 3394
TAes256ExpandedKeyRound-key schedule AES-256 di 240 byte che copre tutti i 14 round, prodotto da Aes256KeyExpansion e consumato dalle routine di cifratura/decifratura a blocco e CBC

Costanti

ConstantValueDescription
AES_BLOCK_SIZE16Dimensione del blocco AES in byte
AES128_KEY_SIZE16Dimensione della chiave AES-128 in byte
AES128_ROUND_KEY_SIZE176Dimensione del round-key AES-128 espanso in byte
AES256_KEY_SIZE32Dimensione della chiave AES-256 in byte
AES256_ROUND_KEY_SIZE240Dimensione del round-key AES-256 espanso in byte

Osservazioni

Vedi anche

FPdfAesGcm, FPdfEncrypt