| 1 | /********************************************************************* |
| 2 | * Filename: blowfish.h |
| 3 | * Author: Brad Conte (brad AT bradconte.com) |
| 4 | * Copyright: |
| 5 | * Disclaimer: This code is presented "as is" without any guarantees. |
| 6 | * Details: Defines the API for the corresponding Blowfish implementation. |
| 7 | *********************************************************************/ |
| 8 | |
| 9 | #ifndef BLOWFISH_H |
| 10 | #define BLOWFISH_H |
| 11 | |
| 12 | /*************************** HEADER FILES ***************************/ |
| 13 | #include <stddef.h> |
| 14 | |
| 15 | /****************************** MACROS ******************************/ |
| 16 | #define BLOWFISH_BLOCK_SIZE 8 // Blowfish operates on 8 bytes at a time |
| 17 | |
| 18 | /**************************** DATA TYPES ****************************/ |
| 19 | typedef unsigned char BYTE; // 8-bit byte |
| 20 | typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines |
| 21 | |
| 22 | typedef struct { |
| 23 | WORD p[18]; |
| 24 | WORD s[4][256]; |
| 25 | } BLOWFISH_KEY; |
| 26 | |
| 27 | /*********************** FUNCTION DECLARATIONS **********************/ |
| 28 | void blowfish_key_setup(const BYTE user_key[], BLOWFISH_KEY *keystruct, size_t len); |
| 29 | void blowfish_encrypt(const BYTE in[], BYTE out[], const BLOWFISH_KEY *keystruct); |
| 30 | void blowfish_decrypt(const BYTE in[], BYTE out[], const BLOWFISH_KEY *keystruct); |
| 31 | |
| 32 | #endif // BLOWFISH_H |