| 1 |
#ifndef AWS_CAL_SYMMETRIC_CIPHER_PRIV_H |
| 2 |
#define AWS_CAL_SYMMETRIC_CIPHER_PRIV_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#include <aws/cal/symmetric_cipher.h> |
| 8 |
|
| 9 |
struct aws_symmetric_cipher; |
| 10 |
|
| 11 |
struct aws_symmetric_cipher_vtable { |
| 12 |
const char *alg_name; |
| 13 |
const char *provider; |
| 14 |
void (*destroy)(struct aws_symmetric_cipher *cipher); |
| 15 |
|
| 16 |
|
| 17 |
int (*reset)(struct aws_symmetric_cipher *cipher); |
| 18 |
int (*encrypt)(struct aws_symmetric_cipher *cipher, struct aws_byte_cursor to_encrypt, struct aws_byte_buf *out); |
| 19 |
int (*decrypt)(struct aws_symmetric_cipher *cipher, struct aws_byte_cursor to_decrypt, struct aws_byte_buf *out); |
| 20 |
|
| 21 |
int (*finalize_encryption)(struct aws_symmetric_cipher *cipher, struct aws_byte_buf *out); |
| 22 |
int (*finalize_decryption)(struct aws_symmetric_cipher *cipher, struct aws_byte_buf *out); |
| 23 |
}; |
| 24 |
|
| 25 |
struct aws_symmetric_cipher { |
| 26 |
struct aws_allocator *allocator; |
| 27 |
struct aws_symmetric_cipher_vtable *vtable; |
| 28 |
struct aws_byte_buf iv; |
| 29 |
struct aws_byte_buf key; |
| 30 |
struct aws_byte_buf aad; |
| 31 |
struct aws_byte_buf tag; |
| 32 |
size_t block_size; |
| 33 |
size_t key_length_bits; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
bool good; |
| 43 |
enum aws_symmetric_cipher_state state; |
| 44 |
void *impl; |
| 45 |
}; |
| 46 |
|
| 47 |
AWS_EXTERN_C_BEGIN |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
AWS_CAL_API void aws_symmetric_cipher_generate_initialization_vector( |
| 54 |
size_t len_bytes, |
| 55 |
bool is_counter_mode, |
| 56 |
struct aws_byte_buf *out); |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
AWS_CAL_API void aws_symmetric_cipher_generate_key(size_t len_bytes, struct aws_byte_buf *out); |
| 62 |
|
| 63 |
AWS_EXTERN_C_END |
| 64 |
|
| 65 |
|
| 66 |
int aws_symmetric_cipher_try_ensure_sufficient_buffer_space(struct aws_byte_buf *buf, size_t size); |
| 67 |
|
| 68 |
#endif |