PolarSSL v1.2.12
blowfish.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_BLOWFISH_H
28 #define POLARSSL_BLOWFISH_H
29 
30 #include "config.h"
31 
32 #include <string.h>
33 
34 #ifdef _MSC_VER
35 #include <basetsd.h>
36 typedef UINT32 uint32_t;
37 #else
38 #include <inttypes.h>
39 #endif
40 
41 #define BLOWFISH_ENCRYPT 1
42 #define BLOWFISH_DECRYPT 0
43 #define BLOWFISH_MAX_KEY 448
44 #define BLOWFISH_MIN_KEY 32
45 #define BLOWFISH_ROUNDS 16 /* when increasing this value, make sure to extend the initialisation vectors */
46 #define BLOWFISH_BLOCKSIZE 8 /* Blowfish uses 64 bit blocks */
47 
48 #define POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH -0x0016
49 #define POLARSSL_ERR_BLOWFISH_INVALID_INPUT_LENGTH -0x0018
51 #if !defined(POLARSSL_BLOWFISH_ALT)
52 // Regular implementation
53 //
54 
58 typedef struct
59 {
60  uint32_t P[BLOWFISH_ROUNDS + 2];
61  uint32_t S[4][256];
62 }
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
78 int blowfish_setkey( blowfish_context *ctx, const unsigned char *key, unsigned int keysize );
79 
91  int mode,
92  const unsigned char input[BLOWFISH_BLOCKSIZE],
93  unsigned char output[BLOWFISH_BLOCKSIZE] );
94 
110  int mode,
111  size_t length,
112  unsigned char iv[BLOWFISH_BLOCKSIZE],
113  const unsigned char *input,
114  unsigned char *output );
115 
131  int mode,
132  size_t length,
133  size_t *iv_off,
134  unsigned char iv[BLOWFISH_BLOCKSIZE],
135  const unsigned char *input,
136  unsigned char *output );
137 
156  size_t length,
157  size_t *nc_off,
158  unsigned char nonce_counter[BLOWFISH_BLOCKSIZE],
159  unsigned char stream_block[BLOWFISH_BLOCKSIZE],
160  const unsigned char *input,
161  unsigned char *output );
162 
163 #ifdef __cplusplus
164 }
165 #endif
166 
167 #else /* POLARSSL_BLOWFISH_ALT */
168 #include "blowfish_alt.h"
169 #endif /* POLARSSL_BLOWFISH_ALT */
170 
171 #endif /* blowfish.h */