| 1 | #ifndef _BLOCK_BASE |
| 2 | #define _BLOCK_BASE |
| 3 | |
| 4 | #include "common.h" |
| 5 | |
| 6 | struct _BlockBase; |
| 7 | |
| 8 | typedef int (*CipherOperation)(const struct _BlockBase *state, const uint8_t *in, uint8_t *out, size_t data_len); |
| 9 | |
| 10 | typedef struct _BlockBase { |
| 11 | CipherOperation encrypt; |
| 12 | CipherOperation decrypt; |
| 13 | int (*destructor)(struct _BlockBase *state); |
| 14 | size_t block_len; |
| 15 | } BlockBase; |
| 16 | |
| 17 | struct block_state; |
| 18 | |
| 19 | #ifdef MODULE_NAME |
| 20 | |
| 21 | #ifndef NON_STANDARD_START_OPERATION |
| 22 | static int block_init(struct block_state *state, const uint8_t *key, size_t keylen); |
| 23 | #endif |
| 24 | |
| 25 | #ifndef NON_STANDARD_ENCRYPT_OPERATION |
| 26 | static void block_encrypt(struct block_state *self, const uint8_t *in, uint8_t *out); |
| 27 | #endif |
| 28 | |
| 29 | static void block_decrypt(struct block_state *self, const uint8_t *in, uint8_t *out); |
| 30 | static void block_finalize(struct block_state* self); |
| 31 | |
| 32 | #endif |
| 33 | |
| 34 | #endif |