//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 IDEA_H #define IDEA_H /* * idea.h - header file for idea.c */ #include "usuals.h" /* typedefs for byte, word16, boolean, etc. */ #define IDEAKEYSIZE 16 #define IDEABLOCKSIZE 8 #define IDEAROUNDS 8 #define IDEAKEYLEN (6*IDEAROUNDS+4) /* * iv[] is used as a circular buffer. bufleft is the number of * bytes at the end which have to be filled in before we crank * the block cipher again. We do the block cipher operation * lazily: bufleft may be 0. When we need one more byte, we * crank the block cipher and set bufleft to 7. */ struct IdeaCfbContext { byte iv[8]; word16 key[IDEAKEYLEN]; int bufleft; }; struct IdeaRandContext { byte outbuf[8]; word16 key[IDEAKEYLEN]; int bufleft; byte internalbuf[8]; byte timestamp[8]; }; void ideaCfbReinit(struct IdeaCfbContext *context, byte const *iv); void ideaCfbInit(struct IdeaCfbContext *context, byte const (key[16])); void ideaCfbDestroy(struct IdeaCfbContext *context); void ideaCfbEncrypt(struct IdeaCfbContext *context, byte const *src, byte *dest, int count); void ideaCfbDecrypt(struct IdeaCfbContext *context, byte const *src, byte *dest, int count); void ideaRandInit(struct IdeaRandContext *context, byte const (key[16]), byte const (seed[8]), word32 timestamp); byte ideaRandByte(struct IdeaRandContext *c); char ** crypt_help_idea (); /* 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_idea (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_idea (); /* 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_idea (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_idea (char *source, char *dest); #endif // IDEA_H