1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/*
* Cryptographic API.
*
* Blowfish Cipher Algorithm, by Bruce Schneier.
* http://www.counterpane.com/blowfish.html
*
* Adapated from Kerneli implementation.
*
* Copyright (c) Herbert Valerio Riedel <hvr@hvrlab.org>
* Copyright (c) Kyle McMartin <kyle@debian.org>
* Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*/
#ifndef _BLOWFISH_
#define _BLOWFISH_
#include "uint.h"
#define BF_BLOCK_SIZE 8
/* key length from 32 to 448 bits, but no checks are made */
#define BF_MIN_KEY_SIZE 4
#define BF_MAX_KEY_SIZE 56
struct blowfish_ctx {
u32 p[18];
u32 s[1024];
};
/*
* Calculates the blowfish S and P boxes for encryption and decryption.
*/
int blowfish_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags);
void blowfish_encrypt(void *cx, u8 *dst, const u8 *src);
void blowfish_decrypt(void *cx, u8 *dst, const u8 *src);
/* memcpy */
/*
void blowfish_encrypt_fake(void *cx, u8 *dst, const u8 *src);
void blowfish_decrypt_fake(void *cx, u8 *dst, const u8 *src);
*/
#endif
|