root/common/trunk/src/qfDES.h @ 3

Revision 3, 2.4 KB (checked in by ucaccsp, 15 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*****************************************************************************
2
3
4
5
6Saleem N. Bhatti
7February 1993
8*****************************************************************************/
9
10#if !defined(_qfDES_h_)
11#define      _qfDES_h_
12
13/* what */
14typedef enum QFDES_what_e {qfDES_encrypt, qfDES_decrypt} QFDES_what;
15
16/* mode */
17typedef enum QFDES_mode_e {qfDES_ecb, qfDES_cbc, qfDES_cfb, qfDES_ofb} QFDES_mode;
18
19/* parity */
20typedef enum QFDES_parity_e {qfDES_even, qfDES_odd} QFDES_parity;
21
22/* key/IV generation */
23typedef enum QFDES_generate_e {qfDES_key, qfDES_iv} QFDES_generate;
24
25/* This does it all */
26int qfDES (unsigned char *key, unsigned char *data, unsigned int size, const QFDES_what what, const QFDES_mode mode, unsigned char *initVec);
27
28/* Handy macros */
29#define qfDES_ECB_e(_key, _data, _size) qfDES(_key, _data, _size, qfDES_encrypt, qfDES_ecb, (unsigned char *) 0)
30#define qfDES_ECB_d(_key, _data, _size) qfDES(_key, _data, _size, qfDES_decrypt, qfDES_ecb, (unsigned char *) 0)
31
32#define qfDES_CBC_e(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_encrypt, qfDES_cbc, _initVec)
33#define qfDES_CBC_d(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_decrypt, qfDES_cbc, _initVec)
34
35#define qfDES_CFB_e(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_encrypt, qfDES_cfb, _initVec)
36#define qfDES_CFB_d(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_decrypt, qfDES_cfb, _initVec)
37
38#define qfDES_OFB_e(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_encrypt, qfDES_ofb, _initVec)
39#define qfDES_OFB_d(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_decrypt, qfDES_ofb, _initVec)
40
41/* Padded [m|re]alloc() */
42unsigned char    qfDES_setPad (unsigned char pad);
43#define qfDES_padSpace() qfDES_setPad((unsigned char) ' ')
44#define qfDES_padZero() qfDES_setPad((unsigned char) '\0')
45
46/* The size of text in a qfDES_malloc()ed block */
47#define qfDES_plainTextSize(_ptr, _size) (unsigned int) ((_size) - (unsigned int) (_ptr)[(_size) - 1])
48
49/* Keys */
50void qfDES_setParity (unsigned char *ptr, unsigned int size, const QFDES_parity parity);
51unsigned int qfDES_checkParity (unsigned char *ptr, unsigned int size, const QFDES_parity parity);
52
53unsigned char *qfDES_generate (const QFDES_generate what); /* returns a pointer to static memory */
54#define qfDES_generateKey() qfDES_generate(qfDES_key)
55#define qfDES_generateIV() qfDES_generate(qfDES_iv)
56
57int qfDES_checkWeakKeys (unsigned char *key);
58
59#endif /* !_qfDES_h_ */
Note: See TracBrowser for help on using the browser.