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