Bitcoin Core 31.99.0
P2P Digital Currency
aes.h
Go to the documentation of this file.
1// Copyright (c) 2015-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4//
5// C++ wrapper around ctaes, a constant-time AES implementation
6
7#ifndef BITCOIN_CRYPTO_AES_H
8#define BITCOIN_CRYPTO_AES_H
9
11extern "C" {
12#include <crypto/ctaes/ctaes.h>
13}
14
15static const int AES_BLOCKSIZE = 16;
16static const int AES256_KEYSIZE = 32;
17
20{
21private:
24
25public:
26 explicit AES256Encrypt(const unsigned char key[32]);
28 void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const;
29};
30
33{
34private:
37
38public:
39 explicit AES256Decrypt(const unsigned char key[32]);
41 void Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const;
42};
43
45{
46public:
47 AES256CBCEncrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn);
49 int Encrypt(const unsigned char* data, int size, unsigned char* out) const;
50
51private:
54 const bool pad;
55 unsigned char *iv;
56};
57
59{
60public:
61 AES256CBCDecrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn);
63 int Decrypt(const unsigned char* data, int size, unsigned char* out) const;
64
65private:
68 const bool pad;
69 unsigned char *iv;
70};
71
72#endif // BITCOIN_CRYPTO_AES_H
static const int AES256_KEYSIZE
Definition: aes.h:16
static const int AES_BLOCKSIZE
Definition: aes.h:15
const bool pad
Definition: aes.h:68
AES256CBCDecrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn)
Definition: aes.cpp:141
const AES256Decrypt dec
Definition: aes.h:67
int Decrypt(const unsigned char *data, int size, unsigned char *out) const
Definition: aes.cpp:149
~AES256CBCDecrypt()
Definition: aes.cpp:154
secure_allocator< unsigned char > allocator
Definition: aes.h:66
unsigned char * iv
Definition: aes.h:69
AES256CBCEncrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn)
Definition: aes.cpp:124
unsigned char * iv
Definition: aes.h:55
int Encrypt(const unsigned char *data, int size, unsigned char *out) const
Definition: aes.cpp:131
const bool pad
Definition: aes.h:54
~AES256CBCEncrypt()
Definition: aes.cpp:136
const AES256Encrypt enc
Definition: aes.h:53
secure_allocator< unsigned char > allocator
Definition: aes.h:52
A decryption class for AES-256.
Definition: aes.h:33
secure_allocator< AES256_ctx > allocator
Definition: aes.h:35
AES256_ctx * ctx
Definition: aes.h:36
~AES256Decrypt()
Definition: aes.cpp:36
AES256Decrypt(const unsigned char key[32])
Definition: aes.cpp:30
void Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const
Definition: aes.cpp:41
An encryption class for AES-256.
Definition: aes.h:20
secure_allocator< AES256_ctx > allocator
Definition: aes.h:22
AES256Encrypt(const unsigned char key[32])
Definition: aes.cpp:14
~AES256Encrypt()
Definition: aes.cpp:20
AES256_ctx * ctx
Definition: aes.h:23
void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const
Definition: aes.cpp:25