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

Revision 205, 2.5 KB (checked in by piers, 15 years ago)

Updated .h files for cplusplus compatibility. Also added ifndef for
#define EAFNOSUPPORT WSAEAFNOSUPPORT
required by inet_pton.c

  • 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#if defined(__cplusplus)
14extern "C" {
15#endif
16
17/* what */
18typedef enum QFDES_what_e {qfDES_encrypt, qfDES_decrypt} QFDES_what;
19
20/* mode */
21typedef enum QFDES_mode_e {qfDES_ecb, qfDES_cbc, qfDES_cfb, qfDES_ofb} QFDES_mode;
22
23/* parity */
24typedef enum QFDES_parity_e {qfDES_even, qfDES_odd} QFDES_parity;
25
26/* key/IV generation */
27typedef enum QFDES_generate_e {qfDES_key, qfDES_iv} QFDES_generate;
28
29
30/* This does it all */
31int qfDES (unsigned char *key, unsigned char *data, unsigned int size, const QFDES_what what, const QFDES_mode mode, unsigned char *initVec);
32
33/* Handy macros */
34#define qfDES_ECB_e(_key, _data, _size) qfDES(_key, _data, _size, qfDES_encrypt, qfDES_ecb, (unsigned char *) 0)
35#define qfDES_ECB_d(_key, _data, _size) qfDES(_key, _data, _size, qfDES_decrypt, qfDES_ecb, (unsigned char *) 0)
36
37#define qfDES_CBC_e(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_encrypt, qfDES_cbc, _initVec)
38#define qfDES_CBC_d(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_decrypt, qfDES_cbc, _initVec)
39
40#define qfDES_CFB_e(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_encrypt, qfDES_cfb, _initVec)
41#define qfDES_CFB_d(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_decrypt, qfDES_cfb, _initVec)
42
43#define qfDES_OFB_e(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_encrypt, qfDES_ofb, _initVec)
44#define qfDES_OFB_d(_key, _data, _size, _initVec) qfDES(_key, _data, _size, qfDES_decrypt, qfDES_ofb, _initVec)
45
46/* Padded [m|re]alloc() */
47unsigned char    qfDES_setPad (unsigned char pad);
48
49#define qfDES_padSpace() qfDES_setPad((unsigned char) ' ')
50#define qfDES_padZero() qfDES_setPad((unsigned char) '\0')
51
52/* The size of text in a qfDES_malloc()ed block */
53#define qfDES_plainTextSize(_ptr, _size) (unsigned int) ((_size) - (unsigned int) (_ptr)[(_size) - 1])
54
55/* Keys */
56void qfDES_setParity (unsigned char *ptr, unsigned int size, const QFDES_parity parity);
57unsigned int qfDES_checkParity (unsigned char *ptr, unsigned int size, const QFDES_parity parity);
58
59unsigned char *qfDES_generate (const QFDES_generate what); /* returns a pointer to static memory */
60
61#define qfDES_generateKey() qfDES_generate(qfDES_key)
62#define qfDES_generateIV() qfDES_generate(qfDES_iv)
63
64int qfDES_checkWeakKeys (unsigned char *key);
65
66#if defined(__cplusplus)
67}
68#endif
69
70#endif /* !_qfDES_h_ */
Note: See TracBrowser for help on using the browser.