]> git.stg.codes - stg.git/blob - stglibs/crypto.lib/include/stg/blowfish.h
Some changes in crypto.lib. Added tests.
[stg.git] / stglibs / crypto.lib / include / stg / blowfish.h
1 /*
2  * Author     :  Paul Kocher
3  * E-mail     :  pck@netcom.com
4  * Date       :  1997
5  * Description:  C implementation of the Blowfish algorithm.
6  */
7
8 #ifndef BLOWFISH_H
9 #define BLOWFISH_H
10
11 #include "stg/os_int.h"
12
13 #define MAXKEYBYTES 56          /* 448 bits */
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 typedef struct {
20   uint32_t P[16 + 2];
21   uint32_t S[4][256];
22 } BLOWFISH_CTX;
23
24 void Blowfish_Init(BLOWFISH_CTX * ctx, unsigned char * key, int keyLen);
25 void Blowfish_Encrypt(const BLOWFISH_CTX * ctx, uint32_t * xl, uint32_t * xr);
26 void Blowfish_Decrypt(const BLOWFISH_CTX * ctx, uint32_t * xl, uint32_t * xr);
27
28 void InitContext(const char * key, size_t length, BLOWFISH_CTX * ctx);
29 void DecryptBlock(void * d, const void * s, const BLOWFISH_CTX * ctx);
30 void EncryptBlock(void * d, const void * s, const BLOWFISH_CTX * ctx);
31
32 void DecryptString(void * d, const void * s, size_t length, const BLOWFISH_CTX * ctx);
33 void EncryptString(void * d, const void * s, size_t length, const BLOWFISH_CTX * ctx);
34
35 #ifdef __cplusplus
36 }
37 #endif
38
39 #endif
40