blob: 4559badb65cac3418300e01417a1a0a0a9525c62 [file] [log] [blame]
James Kuszmaul82f6c042021-01-17 11:30:16 -08001/**
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 */
13enum aes_mode {
14 AES_MODE_CTR, /**< AES Counter mode (CTR) */
15 AES_MODE_GCM, /**< AES Galois Counter Mode (GCM) */
16};
17
18struct aes;
19
20int aes_alloc(struct aes **stp, enum aes_mode mode,
21 const uint8_t *key, size_t key_bits,
22 const uint8_t *iv);
23void aes_set_iv(struct aes *aes, const uint8_t *iv);
24int aes_encr(struct aes *aes, uint8_t *out, const uint8_t *in, size_t len);
25int aes_decr(struct aes *aes, uint8_t *out, const uint8_t *in, size_t len);
26int aes_get_authtag(struct aes *aes, uint8_t *tag, size_t taglen);
27int aes_authenticate(struct aes *aes, const uint8_t *tag, size_t taglen);