aes.h (1555B)
1 /* Copyright (c) 2003, Roger Dingledine 2 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 3 * Copyright (c) 2007-2021, The Tor Project, Inc. */ 4 /* See LICENSE for licensing information */ 5 6 /* Implements a minimal interface to counter-mode AES. */ 7 8 #ifndef TOR_AES_H 9 #define TOR_AES_H 10 11 /** 12 * \file aes.h 13 * \brief Headers for aes.c 14 */ 15 16 #include "lib/cc/torint.h" 17 #include "lib/malloc/malloc.h" 18 #include "lib/testsupport/testsupport.h" 19 20 typedef struct aes_cnt_cipher_t aes_cnt_cipher_t; 21 22 aes_cnt_cipher_t* aes_new_cipher(const uint8_t *key, const uint8_t *iv, 23 int key_bits); 24 void aes_cipher_set_iv_aligned(aes_cnt_cipher_t *cipher_, const uint8_t *iv); 25 void aes_cipher_set_key(aes_cnt_cipher_t *cipher_, 26 const uint8_t *key, int key_bits); 27 void aes_cipher_free_(aes_cnt_cipher_t *cipher); 28 #define aes_cipher_free(cipher) \ 29 FREE_AND_NULL(aes_cnt_cipher_t, aes_cipher_free_, (cipher)) 30 void aes_crypt_inplace(aes_cnt_cipher_t *cipher, char *data, size_t len); 31 32 #ifdef USE_AES_RAW 33 typedef struct aes_raw_t aes_raw_t; 34 35 aes_raw_t *aes_raw_new(const uint8_t *key, int key_bits, bool encrypt); 36 void aes_raw_set_key(aes_raw_t **cipher, const uint8_t *key, 37 int key_bits, bool encrypt); 38 void aes_raw_free_(aes_raw_t *cipher); 39 #define aes_raw_free(cipher) \ 40 FREE_AND_NULL(aes_raw_t, aes_raw_free_, (cipher)) 41 void aes_raw_encrypt(const aes_raw_t *cipher, uint8_t *block); 42 void aes_raw_decrypt(const aes_raw_t *cipher, uint8_t *block); 43 #endif 44 45 #endif /* !defined(TOR_AES_H) */