libmcrypt:

To use libmcrypt in your program include mcrypt.h (this is the lcrypt.h
file in the lib/ directory. It is renamed when make 'install.lib' is
performed). This file defines these algorithms:

# define BLOWFISH 0
# define DES 1 
# define TripleDES 2
# define ThreeWAY 3
# define GOST 4
# define SAFER64 6
# define SAFER128 7
# define CAST128 8
# define TEAN 9      /* TEAN stands for TEA new */
# define TWOFISH 10

Also these functions:

* Misc functions:

int get_block_size(int algorithm);
 Returns the block size of the given algorithm in bytes.
 Algorithm is one of the above.

int get_key_size(int algorithm); 
 Returns the key size of the given algorithm in bytes.

char* get_algorithms_name(int algorithm);
 Returns a character array containing the name of the algorithm.
 This array is malloc'ed so it needs to be freed via free().

CBC, ECB and CFB are the modes that the algorithm may function.
ECB and CBC encrypt in blocks but CFB in bytes (8bits). Note that
"CFB" in the rest of the document represents the "8bit CFB" mode.

* Initialization Functions:

int init_mcrypt_ecb(const int algorithm, void * key,const int lenofkey);
 Starts encryption in ECB mode, and returns a thread descriptor (it has
 nothing to do with the posix threads). 
 Returns (-1) on error.

int init_mcrypt_cbc(const int algorithm, void * key,const int lenofkey);
 Starts encryption in CBC mode, and returns a thread descriptor. 
 If you want to use an IV you must use it as the first block of your message,
 and ignore it at decryption time. The IV does not need to be unique nor 
 secret, just random.
 Returns (-1) on error.

int init_mcrypt_cfb(const int algorithm, void * key,const int lenofkey, IV);
 Starts encryption in CFB mode, and returns a thread descriptor. 
 Unlike CBC mode the IV must be specified (since the whole encryption
 depends on this). That IV does not need to be secret, it can be transmited
 as is. Although it should be unique for every message.
 Returns (-1) on error. 


* Encryption/Decryption Functions:

 ECB:
int mcrypt_ecb(int thread, void *plaintext, int len);
int mdecrypt_ecb(int thread, void *plaintext,int len);

 Using the thread descriptor you can now use these functions. len is the
 length in bytes of the plaintext and it should be k*(algorithms_block_size), 
 The plaintext is replaced by the ciphertext.
 You must have use init_mcrypt_ecb to use these functions.


 CBC:
int mcrypt_cbc(int thread, void *plaintext, int len);
int mdecrypt_cbc(int thread, void *plaintext, int len);

 Using the thread descriptor you can now use these functions.
 len is the length in bytes of the plaintext and it should be 
 k*(algorithms_block_size). Plaintext is replaced by the ciphertext
 You must have use init_mcrypt_cbc to use these functions.


 CFB (8 bit):
int mcrypt_cfb(int thread, void *plaintext, int len);
int mdecrypt_cfb(int thread, void *plaintext, int len);

 Using the thread descriptor you can now use these functions. Since CFB
 encrypts one byte a time there is no limitation for the len.
 Plaintext is replaced with the ciphertext. 
 You must have initialise init_mcrypt_cfb to use these functions.


* Freeing Memory functions:

int end_mcrypt_ecb(int td);
 Finishes (so it clears memory) encryption/decryption for the given
 thread descriptor. For ECB mode.

int end_mcrypt_cbc(int td);
 Finishes (so it clears memory) encryption/decryption for the given
 thread descriptor. For CBC mode only.

int end_mcrypt_cfb(int td);
 Finishes (so it clears memory) encryption/decryption for the given
 thread descriptor. For CFB mode only.


* The init_mcrypt_xxx functions are now re-entrant. If the pthread library is
 found in your system libmcrypt uses pthread_mutex lockings to local
 variables.
