DCPcrypt v2: Users Guide - Block Ciphers

DCPcrypt Cryptographic Component Library v2
Copyright © 1999-2002 David Barton
http://www.cityinthesky.co.uk/
crypto@cityinthesky.co.uk

Block Ciphers - TDCP_blockcipher

All block ciphers are inherited from the TDCP_blockcipher component via either the TDCP_blockcipher64 and TDCP_blockcipher128 components (the latter implement the block size specific code).

The TDCP_blockcipher component extends the TDCP_cipher component to provide chaining mode functions. Functions available are:

          property Initialized: boolean;
          property Id: integer;
          property Algorithm: string;
          property MaxKeySize: integer;
          property BlockSize: integer;
          property CipherMode: TDCP_ciphermode;

          class function SelfTest: boolean;

          procedure SetIV(const Value);
          procedure GetIV(var Value);

          procedure Init(const Key; Size: longword; InitVector: pointer);
          procedure InitStr(const Key: string; HashType: TDCP_hashclass);
          procedure Burn;
          procedure Reset;
          procedure Encrypt(const Indata; var Outdata; Size: longword);
          procedure Decrypt(const Indata; var Outdata; Size: longword);
          function EncryptStream(InStream, OutStream: TStream; Size: longword): longword;
          function DecryptStream(InStream, OutStream: TStream; Size: longword): longword;
          function EncryptString(const Str: string): string;
          function DecryptString(const Str: string): string;
          procedure EncryptECB(const Indata; var Outdata);
          procedure DecryptECB(const Indata; var Outdata);
          procedure EncryptCBC(const Indata; var Outdata; Size: longword);
          procedure DecryptCBC(const Indata; var Outdata; Size: longword);
          procedure EncryptCFB8bit(const Indata; var Outdata; Size: longword);
          procedure DecryptCFB8bit(const Indata; var Outdata; Size: longword);
          procedure EncryptCFBblock(const Indata; var Outdata; Size: longword);
          procedure DecryptCFBblock(const Indata; var Outdata; Size: longword);
          procedure EncryptOFB(const Indata; var Outdata; Size: longword);
          procedure DecryptOFB(const Indata; var Outdata; Size: longword);
          procedure EncryptCTR(const Indata; var Outdata; Size: longword);
          procedure DecryptCTR(const Indata; var Outdata; Size: longword);

Function descriptions

property BlockSize: integer;

This contains the block size of the cipher in BITS.

property CipherMode: TDCP_ciphermode;

This is the current chaining mode used when Encrypt is called. The available modes are:

- cmCBC - Cipher block chaining.
- cmCFB8bit - 8bit cipher feedback.
- cmCFBblock - Cipher feedback (using the block size of the algorithm).
- cmOFB - Output feedback.
- cmCTR - Counter.

Each chaining mode has it's own pro's and cons. See any good book on cryptography or the NIST publication SP800-38A for details on each.

procedure SetIV(const Value);

Use this procedure to set the current chaining mode information to Value. This variable should be the same size as the block size. When Reset is called subsequent to this, the chaining information will be set back to Value.

procedure GetIV(var Value);

This returns in Value the current chaining mode information, to get the initial chaining mode information you need to call Reset before calling GetIV. The variable passed in Value must be at least the same size as the block size otherwise you will get a buffer overflow.

procedure EncryptCBC(const Indata; var Outdata; Size: longword);
procedure DecryptCBC(const Indata; var Outdata; Size: longword);
procedure EncryptCFB8bit(const Indata; var Outdata; Size: longword);
procedure DecryptCFB8bit(const Indata; var Outdata; Size: longword);
procedure EncryptCFBblock(const Indata; var Outdata; Size: longword);
procedure DecryptCFBblock(const Indata; var Outdata; Size: longword);
procedure EncryptOFB(const Indata; var Outdata; Size: longword);
procedure DecryptOFB(const Indata; var Outdata; Size: longword);
procedure EncryptCTR(const Indata; var Outdata; Size: longword);
procedure DecryptCTR(const Indata; var Outdata; Size: longword);

These procedures encrypt/decrypt Size bytes of data from Indata and places the result in Outdata. These all employ chaining mode methods of encryption/decryption and so may need to be used inconjunction with Reset. The CBC method uses short block encryption as specified in Bruce Schneier's "Applied Cryptography" for data blocks that are not multiples of the block size.

Index, Ciphers, Hashes

DCPcrypt is copyrighted © 1999-2002 David Barton.
All trademarks are property of their respective owners.