UNIT _Ciphers;

 (* ********************************************************************** *)
 (*                     Ciphers AND Buffer Control Unit                    *)
 (*                    Hereby distributed as OPEN SOURCE                   *)
 (*                 Copyrighted by (2001) Dutra de Lacerda                 *)
 (* ********************************************************************** *)
 (*                                                                        *)
 (* This code is Open Source in respect to the similar status of Blowfish  *)
 (* It is Copyrighted by "(2001) Dutra de Lacerda"                         *)
 (* You are allowed to use it with the usual conditions:                   *)
 (*   - Maintain this Copyright notice in the code.                        *)
 (*   - Make reference to this code, and Author, in your application.      *)
 (*   - Graciously communicate the Author your use of this code.           *)
 (*                                                                        *)
 (* ---------------------------------------------------------------------- *)
 (*                                                                        *)
 (*                           Finding the Author                           *)
 (*                           ~~~~~~~~~~~~~~~~~~                           *)
 (*  This units author can be reached via the following E-Mail addresses:  *)
 (*                                                                        *)
 (*      Via InterNet    : dulac@ip.pt                                     *)
 (*            ...and    : dutra.lacerda@mail.telepac.pt                   *)
 (*                                                                        *)
 (* ---------------------------------------------------------------------- *)
 (*                                                                        *)
 (*                          Finding New Versions                          *)
 (*                          ~~~~~~~~~~~~~~~~~~~~                          *)
 (*      My Home Site    : http://planeta.ip.pt/~ip200075                  *)
 (*            ...and    : http://www.factor-h.com                         *)
 (*                                                                        *)
 (*      Net Archives    : ftp://garbo.uwasa.fi/pc/crypt                   *)
 (*                      : ftp://garbo.uwasa.fi/pc/security                *)
 (*                      : ftp://ftp.elf.stuba.sk/pub/pc/security          *)
 (*                                                                        *)
 (* ---------------------------------------------------------------------- *)


    (****************************** Header ******************************)
    (****************************** Header ******************************)
    (****************************** Header ******************************)

INTERFACE

uses _BFish5, _Feistel;

const

{$IFDEF DEBUG}
  BufferSize    = $200;  {512}
  MinSize       = $40;   {064}
{$ELSE}
  BufferSize    = $6000; {24k}
  MinSize       = $4000; {16k}
{$ENDIF}

  BlockSize    = SizeOf(Atom32) * 2;
  BufferAtoms  = BufferSize div AtomSize;
  BufferBlocks = BufferSize div BlockSize;


var

{$IFDEF Use_Assembler}
  WORK      : BFC_ASM32;      { Defined in _BFISH5.PAS  }
{$ELSE}
  WORK      : BFC_PAS;        { Defined in _BFISH5.PAS  }
{$ENDIF}
  IV        : Block_2x32;     { Defined in _FEISTEL.PAS }
  Buffer    : Array[0..BufferBlocks-1] of Block_2x32;
  BB        : Array[0..BufferSize-1] of byte ABSOLUTE Buffer;


    (******************************* Code *******************************)
    (******************************* Code *******************************)
    (******************************* Code *******************************)

IMPLEMENTATION

{$IFDEF Use_Assembler}

(*
  ERROR - Assembler Routines are not available in the public
  ~~~~~   domain package... IF you wish the fastest routines
          in the Universe using 16 bits code accepted by all
          x86 family of processors, Blowfish Algorithm only,
          THEN please contact me for detail$.

          You still can confirm the equality of both outputs
          TPAS code and my 8086 ASM routines in the EXE file

            E-MAIL to :  dulac@ip.pt
              ... and :  dutra.lacerda@mail.telepac.pt
*)
{$ENDIF}


Begin
  { No need to initialize Working Objects declared in VAR section... }
End.
