//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 KHUFU_H #define KHUFU_H /* khufu.c */ /* Encrypt input file with the KHUFU cipher */ /* Unless otherwise noted Copyright 1995 Willis E. Howard, III */ /* Willis E. Howard, III email: WEHoward@aol.com mail: POB 1473 Elkhart, IN 46515 */ /* under MSDOS, NMAKE /F KHUFU.MAK all clean */ #include #include #include "crypt.h" #include "rnd.h" #ifndef uint32 typedef unsigned long uint32; typedef unsigned char ubyte; #endif #ifndef bcopy #define bcopy(src, dst, n) memcpy ((dst), (src), (n)) #endif /* This routine uses the common interface to CRYPT.C. Generally, the name of this module becomes the name of the executable file. */ //static int key_defined = 0; /* Set to 1 after a valid key has been defined */ //static int encrypt_or_decrypt_khufu = ENCRYPTION_SELECT; //static char key_string[257]; /* implementation specific defines */ #define ENOUGH 16 #define OCTETS ((ENOUGH+7)/8) uint32 SBoxes[OCTETS][256]; uint32 AuxKeys[4]; void hash128 (int, unsigned char *, unsigned char *, unsigned char *); long hash_string( char * ); void khufu( uint32 * ); void khufuinv( uint32 * ); void hashfilename( char *, char * ); void initialize_SBoxes( void ); /* cipher_doc: This array of strings must have two sections: CIPHER that describes the cipher used and KEY that describes how the key is defined and entered. */ char ** crypt_help_khufu(); /* 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_khufu ( 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_khufu(); /* 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_khufu( 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_khufu( char *source, char *dest ); /* hash_string: hash a string into a long int The string can be up to 256 characters. Zero characters will return the hashed init string. If the string is not a multiple of 16 characters, pad the string with zeroes until it is a multiple of 16 including the zeroes. Otherwise, the hash will not give the same result for the same input string when random bytes fill up the array to a multiple of 16 bytes long. */ long hash_string( char * s ); /* hashfilename: The filename can be of any format, but it must be guaranteed to exist and be findable. In this implementation, this routine is not called until there is a successful open of the file. We will use MSC functions to scan the file name and obtain the simple file name. It will be forced to a length of 8 with padding of spaces if necessary. The name will then be doubled up to get 16 bytes, hashed, and saved in the destination, which must hold 16 characters, or 4 longs. */ void hashfilename( char * filename, char * destination ); /* * Copyright 1989 by Rayan Zachariassen. Use and distribute as you see fit * as long as you send code/cipher improvements or interesting results * back to me. */ void khufu(uint32 * datap); void khufuinv(uint32 * datap); void initialize_SBoxes( void ); #endif // KHUFU_H