              Cryptographic utilities DLL by Andy Brown 1994
              ----------------------------------------------

Description
-----------
CRUTILS.DLL offers the user a convenient interface to the other
cryptographic DLL's in this package. Specifically, it allows you to encrypt
and decrypt memory areas using a user supplied passphrase and a
cryptosystem of your choice, operating in a mode of your choice.

Using CRUTILS.DLL
-----------------
For Borland C++ IDE projects, add CRUTILS.LIB to your project. Makefile
based projects need to add CRUTILS.LIB to the linker stage.

Include CRUTILS.H in any of your project files that need to call the
cryptographic routines.

Ensure CRUTILS.DLL is either in somewhere in your PATH environment
variable, or in your Windows SYSTEM directory.


                                   API
                                   ---

VOID FAR PASCAL EncryptWithPassphrase(BYTE huge *buffer,DWORD len,
                LPBYTE passphrase,UINT alg,UINT mode)

buffer      huge pointer to the memory buffer to encrypt
len         length of the memory block. This MUST be a multiple of the block
            size of your chosen cipher
passphrase  passphrase to use as the encryption key. This must be a null
            terminated ASCII string
alg         Cipher to use. Must be one of the following:
              ALG_IDEA          - Swiss IDEA cipher used in PGP
              ALG_DES           - Data Encryption Standard
              ALG_3DES          - Triple DES: E(D(E(K1)K2)K1)
              ALG_MDC           - Based on the MD5 Transform
              ALG_DIAMOND       - Variable key size cipher w/CRC based S-boxes
              ALG_DIAMONDLITE   - Faster 64 bit block version of Diamond
mode      Cipher operating mode. Must be one of the following:
              MODE_ECB          - Electronic Code Book
              MODE_CBC          - Cipher Block Chaining
              MODE_PCBC         - error Propogating Cipher Block Chaining
              MODE_CFB          - Cipher Feedback
              MODE_OFB          - Output Feedback

          Encrypts the given memory block with the supplied parameters. The
          use of huge pointers allows blocks greater than 64K to be used,
          although there is a speed overhead with such a method. The
          encryption keys/IV's are derived from the passphrase using the
          MD5 algorithm repeatedly until enough bits have been generated.

VOID FAR PASCAL DecryptWithPassphrase(BYTE huge *buffer,DWORD len,
                LPBYTE passphrase,UINT alg,UINT mode)

buffer      huge pointer to the memory buffer to decrypt
len         length of the memory block. This MUST be a multiple of the block
            size of your chosen cipher
passphrase  passphrase to use as the decryption key. This must be a null
            terminated ASCII string
alg         Cipher to use. Must be one of the following:
              ALG_IDEA          - Swiss IDEA cipher used in PGP
              ALG_DES           - Data Encryption Standard
              ALG_3DES          - Triple DES: E(D(E(K1)K2)K1)
              ALG_MDC           - Based on the MD5 Transform
              ALG_DIAMOND       - Variable key size cipher w/CRC based S-boxes
              ALG_DIAMONDLITE   - Faster 64 bit block version of Diamond
mode      Cipher operating mode. Must be one of the following:
              MODE_ECB          - Electronic Code Book
              MODE_CBC          - Cipher Block Chaining
              MODE_PCBC         - error Propogating Cipher Block Chaining
              MODE_CFB          - Cipher Feedback
              MODE_OFB          - Output Feedback

          This is the exact inverse of the above function. The cipher
          details must of course be the same for a successfull decryption.

VOID FAR PASCAL EncryptWithKey(BYTE huge *buffer,DWORD len,LPBYTE ukey,
                WORD keysize,LPBYTE uiv,UINT alg,UINT mode)

buffer      huge pointer to the memory buffer to encrypt
len         length of the memory block. This MUST be a multiple of the block
            size of your chosen cipher
ukey        FAR pointer to the encryption key.
keysize     length of the key in bytes. This will be one of the following:
              IDEA        -     16
              DES         -     8
              3DES        -     16
              MDC         -     96
              DIAMOND     -     variable
              DIAMONDLITE -     variable
uiv         Pointer to the Initialisation Vector. For ECB mode this may be
            NULL. This buffer must be as large as the block size of the
            cipher.
alg         Cipher to use. Must be one of the following:
              ALG_IDEA          - Swiss IDEA cipher used in PGP
              ALG_DES           - Data Encryption Standard
              ALG_3DES          - Triple DES: E(D(E(K1)K2)K1)
              ALG_MDC           - Based on the MD5 Transform
              ALG_DIAMOND       - Variable key size cipher w/CRC based S-boxes
              ALG_DIAMONDLITE   - Faster 64 bit block version of Diamond
mode      Cipher operating mode. Must be one of the following:
              MODE_ECB          - Electronic Code Book
              MODE_CBC          - Cipher Block Chaining
              MODE_PCBC         - error Propogating Cipher Block Chaining
              MODE_CFB          - Cipher Feedback
              MODE_OFB          - Output Feedback

          Encrypts the given memory block with the supplied parameters. The
          use of huge pointers allows blocks greater than 64K to be used,
          although there is a speed overhead with such a method.


VOID FAR PASCAL DecryptWithKey(BYTE huge *buffer,DWORD len,LPBYTE ukey,
                WORD keysize,LPBYTE uiv,UINT alg,UINT mode)

buffer      huge pointer to the memory buffer to decrypt
len         length of the memory block. This MUST be a multiple of the block
            size of your chosen cipher
ukey        FAR pointer to the decryption key.
keysize     length of the key in bytes. This will be one of the following:
              IDEA        -     16
              DES         -     8
              3DES        -     16
              MDC         -     96
              DIAMOND     -     variable
              DIAMONDLITE -     variable
uiv         Pointer to the Initialisation Vector. For ECB mode this may be
            NULL. This buffer must be as large as the block size of the
            cipher.
alg         Cipher to use. Must be one of the following:
              ALG_IDEA          - Swiss IDEA cipher used in PGP
              ALG_DES           - Data Encryption Standard
              ALG_3DES          - Triple DES: E(D(E(K1)K2)K1)
              ALG_MDC           - Based on the MD5 Transform
              ALG_DIAMOND       - Variable key size cipher w/CRC based S-boxes
              ALG_DIAMONDLITE   - Faster 64 bit block version of Diamond
mode      Cipher operating mode. Must be one of the following:
              MODE_ECB          - Electronic Code Book
              MODE_CBC          - Cipher Block Chaining
              MODE_PCBC         - error Propogating Cipher Block Chaining
              MODE_CFB          - Cipher Feedback
              MODE_OFB          - Output Feedback

          Decrypts the given memory block with the supplied parameters. The
          use of huge pointers allows blocks greater than 64K to be used,
          although there is a speed overhead with such a method.

Comments
--------
The DLL was compiled with Borland C++ v3.1 with optimizations set to
`fastest', using the 286 instruction set option. You can probably get quite
a speed increase using the 386 instruction set.


Have fun,

Andy

+---------------------------+----------------------------------------------+
| Andy <asb@cs.nott.ac.uk>  | PGP key fingerprint: EC 80 9C 96 54 63 CC 97 |
|    finger for PGP key     |                    : FF 7D C5 69 0B 55 23 63 |
+---------------------------+----------------------------------------------+

