James Kuszmaul | 82f6c04 | 2021-01-17 11:30:16 -0800 | [diff] [blame^] | 1 | /** |
| 2 | * @file re_aes.h Interface to AES (Advanced Encryption Standard) |
| 3 | * |
| 4 | * Copyright (C) 2010 Creytiv.com |
| 5 | */ |
| 6 | |
| 7 | |
| 8 | #ifndef AES_BLOCK_SIZE |
| 9 | #define AES_BLOCK_SIZE 16 |
| 10 | #endif |
| 11 | |
| 12 | /** AES mode */ |
| 13 | enum aes_mode { |
| 14 | AES_MODE_CTR, /**< AES Counter mode (CTR) */ |
| 15 | AES_MODE_GCM, /**< AES Galois Counter Mode (GCM) */ |
| 16 | }; |
| 17 | |
| 18 | struct aes; |
| 19 | |
| 20 | int aes_alloc(struct aes **stp, enum aes_mode mode, |
| 21 | const uint8_t *key, size_t key_bits, |
| 22 | const uint8_t *iv); |
| 23 | void aes_set_iv(struct aes *aes, const uint8_t *iv); |
| 24 | int aes_encr(struct aes *aes, uint8_t *out, const uint8_t *in, size_t len); |
| 25 | int aes_decr(struct aes *aes, uint8_t *out, const uint8_t *in, size_t len); |
| 26 | int aes_get_authtag(struct aes *aes, uint8_t *tag, size_t taglen); |
| 27 | int aes_authenticate(struct aes *aes, const uint8_t *tag, size_t taglen); |