Bitcoin Core 28.99.0
P2P Digital Currency
aes.h
Go to the documentation of this file.
1// Copyright (c) 2015-2019 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
10extern "C" {
11#include <crypto/ctaes/ctaes.h>
12}
13
14static const int AES_BLOCKSIZE = 16;
15static const int AES256_KEYSIZE = 32;
16
19{
20private:
22
23public:
24 explicit AES256Encrypt(const unsigned char key[32]);
26 void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const;
27};
28
31{
32private:
34
35public:
36 explicit AES256Decrypt(const unsigned char key[32]);
38 void Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const;
39};
40
42{
43public:
44 AES256CBCEncrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn);
46 int Encrypt(const unsigned char* data, int size, unsigned char* out) const;
47
48private:
50 const bool pad;
51 unsigned char iv[AES_BLOCKSIZE];
52};
53
55{
56public:
57 AES256CBCDecrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn);
59 int Decrypt(const unsigned char* data, int size, unsigned char* out) const;
60
61private:
63 const bool pad;
64 unsigned char iv[AES_BLOCKSIZE];
65};
66
67#endif // BITCOIN_CRYPTO_AES_H
static const int AES256_KEYSIZE
Definition: aes.h:15
static const int AES_BLOCKSIZE
Definition: aes.h:14
const bool pad
Definition: aes.h:63
AES256CBCDecrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn)
Definition: aes.cpp:137
const AES256Decrypt dec
Definition: aes.h:62
int Decrypt(const unsigned char *data, int size, unsigned char *out) const
Definition: aes.cpp:144
~AES256CBCDecrypt()
Definition: aes.cpp:149
unsigned char iv[AES_BLOCKSIZE]
Definition: aes.h:64
AES256CBCEncrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn)
Definition: aes.cpp:121
int Encrypt(const unsigned char *data, int size, unsigned char *out) const
Definition: aes.cpp:127
const bool pad
Definition: aes.h:50
~AES256CBCEncrypt()
Definition: aes.cpp:132
const AES256Encrypt enc
Definition: aes.h:49
unsigned char iv[AES_BLOCKSIZE]
Definition: aes.h:51
A decryption class for AES-256.
Definition: aes.h:31
~AES256Decrypt()
Definition: aes.cpp:33
AES256Decrypt(const unsigned char key[32])
Definition: aes.cpp:28
void Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const
Definition: aes.cpp:38
AES256_ctx ctx
Definition: aes.h:33
An encryption class for AES-256.
Definition: aes.h:19
AES256Encrypt(const unsigned char key[32])
Definition: aes.cpp:13
~AES256Encrypt()
Definition: aes.cpp:18
void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const
Definition: aes.cpp:23
AES256_ctx ctx
Definition: aes.h:21