📄 idea.h
字号:
#ifndef IDEA_H
#define IDEA_H
/*
* idea.h - header file for idea.c
*/
/* typedefs for BYTE, WORD16, boolean, etc. */
typedef unsigned char boolean; /* values are TRUE or FALSE */
typedef unsigned char BYTE; /* values are 0-255 */
typedef BYTE *byteptr; /* pointer to BYTE */
typedef char *string; /* pointer to ASCII character string */
typedef unsigned short WORD16; /* values are 0-65535 */
typedef unsigned long WORD32; /* values are 0-4294967295 */
#ifndef TRUE
#define FALSE 0
#define TRUE (!FALSE)
#endif /* if TRUE not already defined */
#ifndef min /* if min macro not already defined */
#define min(a,b) ( (a)<(b) ? (a) : (b) )
#define max(a,b) ( (a)>(b) ? (a) : (b) )
#endif /* if min macro not already defined */
/* end typedefs for BYTE, WORD16, boolean, etc. */
#define IDEAKEYSIZE 16
#define IDEABLOCKSIZE 8
#define IDEAROUNDS 8
#define IDEAKEYLEN (6*IDEAROUNDS+4)
#define MAX_PATHLEN 256
#define KBYTES 1024
/*
* 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];
};
////////////////////////////////////////////////////////////////////////////
static void ideaCipher(BYTE const (inbuf[8]), BYTE (outbuf[8]), WORD16 const *key);
int EncryptFile( char *szSrcFile, char *szEncFile, BYTE *UserKey );
int DecryptFile( char *szSrcFile, char *EncFile, BYTE *UserKey );
////////////////////////////////////////////////////////////////////
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);
#endif /* !IDEA_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -