PolarSSL v1.2.5
blowfish.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_BLOWFISH_H
28 #define POLARSSL_BLOWFISH_H
29 
30 #include <string.h>
31 
32 #ifdef _MSC_VER
33 #include <basetsd.h>
34 typedef UINT32 uint32_t;
35 #else
36 #include <inttypes.h>
37 #endif
38 
39 #define BLOWFISH_ENCRYPT 1
40 #define BLOWFISH_DECRYPT 0
41 #define BLOWFISH_MAX_KEY 448
42 #define BLOWFISH_MIN_KEY 32
43 #define BLOWFISH_ROUNDS 16 /* when increasing this value, make sure to extend the initialisation vectors */
44 #define BLOWFISH_BLOCKSIZE 8 /* Blowfish uses 64 bit blocks */
45 
46 #define POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH -0x0016
47 #define POLARSSL_ERR_BLOWFISH_INVALID_INPUT_LENGTH -0x0018
52 typedef struct
53 {
54  uint32_t P[BLOWFISH_ROUNDS + 2];
55  uint32_t S[4][256];
56 }
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
72 int blowfish_setkey( blowfish_context *ctx, const unsigned char *key, unsigned int keysize );
73 
85  int mode,
86  const unsigned char input[BLOWFISH_BLOCKSIZE],
87  unsigned char output[BLOWFISH_BLOCKSIZE] );
88 
104  int mode,
105  size_t length,
106  unsigned char iv[BLOWFISH_BLOCKSIZE],
107  const unsigned char *input,
108  unsigned char *output );
109 
125  int mode,
126  size_t length,
127  size_t *iv_off,
128  unsigned char iv[BLOWFISH_BLOCKSIZE],
129  const unsigned char *input,
130  unsigned char *output );
131 
150  size_t length,
151  size_t *nc_off,
152  unsigned char nonce_counter[BLOWFISH_BLOCKSIZE],
153  unsigned char stream_block[BLOWFISH_BLOCKSIZE],
154  const unsigned char *input,
155  unsigned char *output );
156 
157 #ifdef __cplusplus
158 }
159 #endif
160 
161 #endif /* blowfish.h */