PolarSSL v1.3.1
Main Page
Modules
Data Structures
Files
File List
Globals
include
polarssl
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
55
#ifdef __cplusplus
56
extern
"C"
{
57
#endif
58
62
typedef
struct
63
{
64
uint32_t P[
BLOWFISH_ROUNDS
+ 2];
65
uint32_t S[4][256];
66
}
67
blowfish_context
;
68
78
int
blowfish_setkey
(
blowfish_context
*ctx,
const
unsigned
char
*key,
unsigned
int
keysize );
79
90
int
blowfish_crypt_ecb
(
blowfish_context
*ctx,
91
int
mode,
92
const
unsigned
char
input[
BLOWFISH_BLOCKSIZE
],
93
unsigned
char
output[BLOWFISH_BLOCKSIZE] );
94
95
#if defined(POLARSSL_CIPHER_MODE_CBC)
96
110
int
blowfish_crypt_cbc
(
blowfish_context
*ctx,
111
int
mode,
112
size_t
length,
113
unsigned
char
iv[
BLOWFISH_BLOCKSIZE
],
114
const
unsigned
char
*input,
115
unsigned
char
*output );
116
#endif
/* POLARSSL_CIPHER_MODE_CBC */
117
118
#if defined(POLARSSL_CIPHER_MODE_CFB)
119
132
int
blowfish_crypt_cfb64
(
blowfish_context
*ctx,
133
int
mode,
134
size_t
length,
135
size_t
*iv_off,
136
unsigned
char
iv[
BLOWFISH_BLOCKSIZE
],
137
const
unsigned
char
*input,
138
unsigned
char
*output );
139
#endif
/*POLARSSL_CIPHER_MODE_CFB */
140
141
#if defined(POLARSSL_CIPHER_MODE_CTR)
142
160
int
blowfish_crypt_ctr
(
blowfish_context
*ctx,
161
size_t
length,
162
size_t
*nc_off,
163
unsigned
char
nonce_counter[
BLOWFISH_BLOCKSIZE
],
164
unsigned
char
stream_block[BLOWFISH_BLOCKSIZE],
165
const
unsigned
char
*input,
166
unsigned
char
*output );
167
#endif
/* POLARSSL_CIPHER_MODE_CTR */
168
169
#ifdef __cplusplus
170
}
171
#endif
172
173
#else
/* POLARSSL_BLOWFISH_ALT */
174
#include "blowfish_alt.h"
175
#endif
/* POLARSSL_BLOWFISH_ALT */
176
177
#endif
/* blowfish.h */
Generated on Fri Nov 22 2013 08:28:27 for PolarSSL v1.3.1 by
1.8.3