]> git.stg.codes - stg.git/blob - libs/crypto/include/stg/blowfish.h
Port to CMake, get rid of os_int.h.
[stg.git] / libs / crypto / 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 #define MAXKEYBYTES 56          /* 448 bits */
12
13 #ifdef __cplusplus
14 #include <cstddef> // size_t
15 #include <cstdint>
16 extern "C" {
17 #else
18 #include <stddef.h> // size_t
19 #include <stdint.h>
20 #endif
21
22 typedef struct {
23   uint32_t P[16 + 2];
24   uint32_t S[4][256];
25 } BLOWFISH_CTX;
26
27 void Blowfish_Init(BLOWFISH_CTX * ctx, unsigned char * key, int keyLen);
28 void Blowfish_Encrypt(const BLOWFISH_CTX * ctx, uint32_t * xl, uint32_t * xr);
29 void Blowfish_Decrypt(const BLOWFISH_CTX * ctx, uint32_t * xl, uint32_t * xr);
30
31 void InitContext(const char * key, size_t length, BLOWFISH_CTX * ctx);
32 void DecryptBlock(void * d, const void * s, const BLOWFISH_CTX * ctx);
33 void EncryptBlock(void * d, const void * s, const BLOWFISH_CTX * ctx);
34
35 void DecryptString(void * d, const void * s, size_t length, const BLOWFISH_CTX * ctx);
36 void EncryptString(void * d, const void * s, size_t length, const BLOWFISH_CTX * ctx);
37
38 #ifdef __cplusplus
39 }
40 #endif
41
42 #endif
43