//This program is free software: you can redistribute it and/or modify it under the terms #of the GNU General Public License as published by the Free Software Foundation, either #version 3 of the License, or (at your option) any later version. //This program is distributed in the hope that it will be useful, but WITHOUT ANY #WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A #PARTICULAR PURPOSE. See the GNU General Public License for more details. //You should have received a copy of the GNU General Public License along with this #program. If not, see #ifndef DES_H #define DES_H /* des64.h * * Headers and defines for des64.c. Also for des128.c and des192.c * if the appropriate defines are used. * Graven Imagery, 1992. * * Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge * (GEnie : OUTER; CIS : [71755,204]) * * Modifications Copyright 1994 Willis E. Howard, III */ /* unless size is really important, define everything */ #define D3_DES /* NOTE: You will need to define D2_DES or D3_DES if you want to use makekey() */ #ifdef D3_DES #ifndef D2_DES #define D2_DES /* D2_DES is needed for D3_DES */ #endif #endif #define EN0 0 /* MODE == encrypt */ #define DE1 1 /* MODE == decrypt */ extern void deskey(unsigned char *, short); /* hexkey[8] MODE * Sets the internal key register according to the hexadecimal * key contained in the 8 bytes of hexkey, according to the DES, * for encryption or decryption according to MODE. */ extern void usekey(unsigned long *); /* cookedkey[32] * Loads the internal key register with the data in cookedkey. */ extern void cpkey(unsigned long *); /* cookedkey[32] * Copies the contents of the internal key register into the storage * located at &cookedkey[0]. */ extern void des(unsigned char *, unsigned char *); /* from[8] to[8] * Encrypts/Decrypts (according to the key currently loaded in the * internal key register) one block of eight bytes at address 'from' * into the block at address 'to'. They can be the same. */ #ifdef D2_DES #define desDkey(a,b) des2key((a),(b)) extern void des2key(unsigned char *, short); /* hexkey[16] MODE * Sets the internal key registerS according to the hexadecimal * keyS contained in the 16 bytes of hexkey, according to the DES, * for DOUBLE encryption or decryption according to MODE. * NOTE: this clobbers all three key registers! */ extern void Ddes(unsigned char *, unsigned char *); /* from[8] to[8] * Encrypts/Decrypts (according to the keyS currently loaded in the * internal key registerS) one block of eight bytes at address 'from' * into the block at address 'to'. They can be the same. */ extern void D2des(unsigned char *, unsigned char *); /* from[16] to[16] * Encrypts/Decrypts (according to the keyS currently loaded in the * internal key registerS) one block of SIXTEEN bytes at address 'from' * into the block at address 'to'. They can be the same. */ extern void makekey(char *, unsigned char *); /* *password, single-length key[8] * With a double-length default key, this routine hashes a NULL-terminated * string into an eight-byte random-looking key, suitable for use with the * deskey() routine. */ #define makeDkey(a,b) make2key((a),(b)) extern void make2key(char *, unsigned char *); /* *password, double-length key[16] * With a double-length default key, this routine hashes a NULL-terminated * string into a sixteen-byte random-looking key, suitable for use with the * des2key() routine. */ #ifndef D3_DES /* D2_DES only */ #define useDkey(a) use2key((a)) #define cpDkey(a) cp2key((a)) extern void use2key(unsigned long *); /* cookedkey[64] * Loads the internal key registerS with the data in cookedkey. * NOTE: this clobbers all three key registers! */ extern void cp2key(unsigned long *); /* cookedkey[64] * Copies the contents of the internal key registerS into the storage * located at &cookedkey[0]. */ #else /* D3_DES too */ #define useDkey(a) use3key((a)) #define cpDkey(a) cp3key((a)) extern void des3key(unsigned char *, short); /* hexkey[24] MODE * Sets the internal key registerS according to the hexadecimal * keyS contained in the 24 bytes of hexkey, according to the DES, * for DOUBLE encryption or decryption according to MODE. */ extern void use3key(unsigned long *); /* cookedkey[96] * Loads the 3 internal key registerS with the data in cookedkey. */ extern void cp3key(unsigned long *); /* cookedkey[96] * Copies the contents of the 3 internal key registerS into the storage * located at &cookedkey[0]. */ extern void make3key(char *, unsigned char *); /* *password, triple-length key[24] * With a triple-length default key, this routine hashes a NULL-terminated * string into a twenty-four-byte random-looking key, suitable for use with * the des3key() routine. */ #endif /* D3_DES */ #endif /* D2_DES */ /* original source: d3des.h V5.09 rwo 9208.04 15:06 Graven Imagery ********************************************************************/ char ** crypt_help_des (); /* crypt_key: Get the key from the passed string (that may be a file name in some implementations) or from a key file name. Return 0 on success but exit on error. */ int crypt_key_des (int key_type, char *key_text); /* crypt_key_erase: If a local copy of the key has been made, erase it from memory. This increases security that the key can not be obtained from an examination of memory. */ void crypt_key_erase_des (); /* crypt_select: If encryption and decryption require different ciphers, this routine defines the direction. Valid choices are ENCRYPTION_SELECT and DECRYPTION_SELECT. */ int crypt_select_des (int selection); /* crypt_file: encrypt or decrypt the source to the destination file. Do not exit from this routine. Return 0 on success and return 1 on error. Use an fprintf(stderr, ... ) to report the nature of the error and close any open files. This allows the main routine to do some cleanup before exiting. */ int crypt_file_des (char *source, char *dest); #endif // DES_H