Initial version of glue - going to abandon -alloc stuff.
[userv-utils] / ipif / blowfish.h
CommitLineData
2dc68225 1/**/
2
3#ifndef BLOWFISH__H_INCLUDED
4#define BLOWFISH__H_INCLUDED
5
6#define BLOWFISH_BLOCKBYTES 8
7#define BLOWFISH_MAXKEYBYTES 56
8#define BLOWFISH__N 16
9#define BLOWFISH__PSIZE BLOWFISH__N+2
10
11typedef uint32 blowfish__p[BLOWFISH__PSIZE];
12typedef uint32 blowfish__s[4][256];
13
14struct blowfish_expandedkey {
15 blowfish__p p;
16 blowfish__s s;
17};
18
19void blowfish_loadkey(struct blowfish_expandedkey *ek,
20 const uint8 *key, int keybytes);
21void blowfish_encrypt(const struct blowfish_expandedkey *ek,
22 const uint8 plain[BLOWFISH_BLOCKBYTES],
23 uint8 cipher[BLOWFISH_BLOCKBYTES]);
24void blowfish_decrypt(const struct blowfish_expandedkey *ek,
25 const uint8 cipher[BLOWFISH_BLOCKBYTES],
26 uint8 plain[BLOWFISH_BLOCKBYTES]);
27
28struct blowfish_cbc_state {
29 struct blowfish_expandedkey ek;
30 uint32 chainl, chainr;
31};
32
33void blowfish_cbc_setiv(struct blowfish_cbc_state *cs,
34 const uint8 iv[BLOWFISH_BLOCKBYTES]);
35void blowfish_cbc_encrypt(struct blowfish_cbc_state *cs,
36 const uint8 plain[BLOWFISH_BLOCKBYTES],
37 uint8 cipher[BLOWFISH_BLOCKBYTES]);
38void blowfish_cbc_decrypt(struct blowfish_cbc_state *cs,
39 const uint8 cipher[BLOWFISH_BLOCKBYTES],
40 uint8 plain[BLOWFISH_BLOCKBYTES]);
41
42#endif