PDFium Delphi Component Docs

FPdfAes enhed

Enhed: FPdfAes
Ren-Pascal AES-128- og AES-256-blokciffer med nøgleudvidelse, enkeltblok-kryptering/-dekryptering og AES-256-CBC-stream-wrappers brugt af PDF-krypteringshandlerne

Syntax

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 Key: TAes256Key;
  const PlainKeyData: TBytes): TBytes;
function Aes256KeyUnwrap(const Key: TAes256Key; const Wrapped: TBytes;
  out PlainKeyData: TBytes): Boolean;
procedure AesGenerateRandomBytes(Buffer: Pointer; Count: Integer);

Description

FPdfAes er en afhængighedsfri AES-implementering, der leveres, så PDFium Delphi Component kan kryptere og dekryptere PDF-streams på Delphi, C++Builder og Free Pascal uden at stole på et eksternt kryptobibliotek. Den forbruges af PDF AES-256-sikkerhedshandleren i FPdfEncrypt og af GCM-tilstanden i FPdfAesGcm

Blokprimitiverne arbejder på faste 16-byte-blokke via udvidede round keys. CBC-wrapperne håndterer PKCS#7-padding eller ingen padding over byte-arrays af variabel længde, hvilket matcher de to stream-krypteringstilstande, PDF-specifikationen kræver

AesGenerateRandomBytes fylder en buffer med kryptografisk tilfældige bytes, der bruges til IV'er, salt og nøgler

Functions

FunctionDescription
Aes128KeyExpansionExpands a 128-bit key into the 176-byte round-key schedule
Aes128EncryptBlockEncrypts one 16-byte block with an expanded AES-128 key
Aes256KeyExpansionExpands a 256-bit key into the 240-byte round-key schedule
Aes256EncryptBlockEncrypts one 16-byte block with an expanded AES-256 key
Aes256DecryptBlockDecrypts one 16-byte block with an expanded AES-256 key
Aes256CbcEncryptPKCS7Encrypts a byte array in CBC mode with PKCS#7 padding
Aes256CbcEncryptNoPadEncrypts a byte array in CBC mode without padding (input length must be a block multiple)
Aes256CbcDecryptPKCS7Decrypts a CBC ciphertext and strips PKCS#7 padding
Aes256CbcDecryptNoPadDecrypts a CBC ciphertext without removing padding
Aes256KeyWrapWraps key data with AES-256 using RFC 3394 integrity protection
Aes256KeyUnwrapAuthenticates and unwraps RFC 3394 key data, returning no plaintext on integrity failure
AesGenerateRandomBytesFills a buffer with cryptographically random bytes

Constants

ConstantValueDescription
AES_BLOCK_SIZE16AES block size in bytes
AES128_KEY_SIZE16AES-128 key size in bytes
AES128_ROUND_KEY_SIZE176Expanded AES-128 round-key size in bytes
AES256_KEY_SIZE32AES-256 key size in bytes
AES256_ROUND_KEY_SIZE240Expanded AES-256 round-key size in bytes

Remarks

See Also

FPdfAesGcm, FPdfEncrypt