Works at least without crypto.
[userv-utils] / ipif / blowfish.h
... / ...
CommitLineData
1/**/
2
3#ifndef BLOWFISH__H_INCLUDED
4#define BLOWFISH__H_INCLUDED
5
6#include <stdint.h>
7
8#define BLOWFISH_BLOCKBYTES 8
9#define BLOWFISH_MAXKEYBYTES 56
10#define BLOWFISH__N 16
11#define BLOWFISH__PSIZE BLOWFISH__N+2
12
13typedef uint32_t blowfish__p[BLOWFISH__PSIZE];
14typedef uint32_t blowfish__s[4][256];
15
16struct blowfish_expandedkey {
17 blowfish__p p;
18 blowfish__s s;
19};
20
21/* It's ok to pass the [_cbc]_(en|de)crypt functions the same
22 * input and output pointers.
23 */
24
25void blowfish_loadkey(struct blowfish_expandedkey *ek,
26 const uint8_t *key, int keybytes);
27void blowfish_encrypt(const struct blowfish_expandedkey *ek,
28 const uint8_t plain[BLOWFISH_BLOCKBYTES],
29 uint8_t cipher[BLOWFISH_BLOCKBYTES]);
30void blowfish_decrypt(const struct blowfish_expandedkey *ek,
31 const uint8_t cipher[BLOWFISH_BLOCKBYTES],
32 uint8_t plain[BLOWFISH_BLOCKBYTES]);
33
34struct blowfish_cbc_state {
35 struct blowfish_expandedkey ek;
36 uint32_t chainl, chainr;
37};
38
39void blowfish_cbc_setiv(struct blowfish_cbc_state *cs,
40 const uint8_t iv[BLOWFISH_BLOCKBYTES]);
41void blowfish_cbc_encrypt(struct blowfish_cbc_state *cs,
42 const uint8_t plain[BLOWFISH_BLOCKBYTES],
43 uint8_t cipher[BLOWFISH_BLOCKBYTES]);
44void blowfish_cbc_decrypt(struct blowfish_cbc_state *cs,
45 const uint8_t cipher[BLOWFISH_BLOCKBYTES],
46 uint8_t plain[BLOWFISH_BLOCKBYTES]);
47
48#endif