Tor 0.4.9.2-alpha-dev
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
aes.h
Go to the documentation of this file.
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"
19
21
22aes_cnt_cipher_t* aes_new_cipher(const uint8_t *key, const uint8_t *iv,
23 int key_bits);
24void aes_cipher_set_iv_aligned(aes_cnt_cipher_t *cipher_, const uint8_t *iv);
26 const uint8_t *key, int key_bits);
27void 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))
30void aes_crypt_inplace(aes_cnt_cipher_t *cipher, char *data, size_t len);
31
32#ifdef USE_AES_RAW
33typedef struct aes_raw_t aes_raw_t;
34
35aes_raw_t *aes_raw_new(const uint8_t *key, int key_bits, bool encrypt);
36void aes_raw_set_key(aes_raw_t **cipher, const uint8_t *key,
37 int key_bits, bool encrypt);
38void aes_raw_free_(aes_raw_t *cipher);
39#define aes_raw_free(cipher) \
40 FREE_AND_NULL(aes_raw_t, aes_raw_free_, (cipher))
41void aes_raw_encrypt(const aes_raw_t *cipher, uint8_t *block);
42void aes_raw_decrypt(const aes_raw_t *cipher, uint8_t *block);
43#endif
44
45#endif /* !defined(TOR_AES_H) */
void aes_cipher_set_key(aes_cnt_cipher_t *cipher_, const uint8_t *key, int key_bits)
Definition: aes_nss.c:115
void aes_cipher_set_iv_aligned(aes_cnt_cipher_t *cipher_, const uint8_t *iv)
Definition: aes_nss.c:105
void aes_raw_set_key(aes_raw_t **cipher_, const uint8_t *key, int key_bits, bool encrypt)
Definition: aes_openssl.c:219
void aes_raw_encrypt(const aes_raw_t *cipher, uint8_t *block)
Definition: aes_openssl.c:259
void aes_raw_decrypt(const aes_raw_t *cipher, uint8_t *block)
Definition: aes_openssl.c:271
void aes_raw_free_(aes_raw_t *cipher_)
Definition: aes_openssl.c:240
aes_raw_t * aes_raw_new(const uint8_t *key, int key_bits, bool encrypt)
Definition: aes_openssl.c:193
Headers for util_malloc.c.
Macros to implement mocking and selective exposure for the test code.
Integer definitions used throughout Tor.