Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

aes.h
Go to the documentation of this file.
1 // Copyright (c) 2015 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 AES128_KEYSIZE = 16;
16 static const int AES256_KEYSIZE = 32;
17 
20 {
21 private:
23 
24 public:
25  explicit AES128Encrypt(const unsigned char key[16]);
27  void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const;
28 };
29 
32 {
33 private:
35 
36 public:
37  explicit AES128Decrypt(const unsigned char key[16]);
39  void Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const;
40 };
41 
44 {
45 private:
47 
48 public:
49  explicit AES256Encrypt(const unsigned char key[32]);
51  void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const;
52 };
53 
56 {
57 private:
59 
60 public:
61  explicit AES256Decrypt(const unsigned char key[32]);
63  void Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const;
64 };
65 
67 {
68 public:
69  AES256CBCEncrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn);
71  int Encrypt(const unsigned char* data, int size, unsigned char* out) const;
72 
73 private:
75  const bool pad;
76  unsigned char iv[AES_BLOCKSIZE];
77 };
78 
80 {
81 public:
82  AES256CBCDecrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn);
84  int Decrypt(const unsigned char* data, int size, unsigned char* out) const;
85 
86 private:
88  const bool pad;
89  unsigned char iv[AES_BLOCKSIZE];
90 };
91 
93 {
94 public:
95  AES128CBCEncrypt(const unsigned char key[AES128_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn);
97  int Encrypt(const unsigned char* data, int size, unsigned char* out) const;
98 
99 private:
101  const bool pad;
102  unsigned char iv[AES_BLOCKSIZE];
103 };
104 
106 {
107 public:
108  AES128CBCDecrypt(const unsigned char key[AES128_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn);
110  int Decrypt(const unsigned char* data, int size, unsigned char* out) const;
111 
112 private:
114  const bool pad;
115  unsigned char iv[AES_BLOCKSIZE];
116 };
117 
118 #endif // BITCOIN_CRYPTO_AES_H
AES256_ctx ctx
Definition: aes.h:58
AES256Encrypt(const unsigned char key[32])
Definition: aes.cpp:45
static const int AES256_KEYSIZE
Definition: aes.h:16
int Decrypt(const unsigned char *data, int size, unsigned char *out) const
Definition: aes.cpp:213
A decryption class for AES-256.
Definition: aes.h:55
AES128Encrypt(const unsigned char key[16])
Definition: aes.cpp:15
void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const
Definition: aes.cpp:55
const AES256Decrypt dec
Definition: aes.h:87
AES128CBCEncrypt(const unsigned char key[AES128_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn)
Definition: aes.cpp:186
~AES256Encrypt()
Definition: aes.cpp:50
const AES128Encrypt enc
Definition: aes.h:100
unsigned char iv[AES_BLOCKSIZE]
Definition: aes.h:89
int Decrypt(const unsigned char *data, int size, unsigned char *out) const
Definition: aes.cpp:176
An encryption class for AES-256.
Definition: aes.h:43
void Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const
Definition: aes.cpp:70
~AES128Encrypt()
Definition: aes.cpp:20
void Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const
Definition: aes.cpp:40
~AES128CBCDecrypt()
Definition: aes.cpp:208
const bool pad
Definition: aes.h:101
const AES128Decrypt dec
Definition: aes.h:113
const bool pad
Definition: aes.h:88
~AES256CBCDecrypt()
Definition: aes.cpp:181
unsigned char iv[AES_BLOCKSIZE]
Definition: aes.h:115
int Encrypt(const unsigned char *data, int size, unsigned char *out) const
Definition: aes.cpp:197
AES256CBCDecrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn)
Definition: aes.cpp:169
AES256CBCEncrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn)
Definition: aes.cpp:153
~AES128Decrypt()
Definition: aes.cpp:35
int Encrypt(const unsigned char *data, int size, unsigned char *out) const
Definition: aes.cpp:159
void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const
Definition: aes.cpp:25
A decryption class for AES-128.
Definition: aes.h:31
const AES256Encrypt enc
Definition: aes.h:74
~AES256Decrypt()
Definition: aes.cpp:65
AES256_ctx ctx
Definition: aes.h:46
static const int AES128_KEYSIZE
Definition: aes.h:15
AES128Decrypt(const unsigned char key[16])
Definition: aes.cpp:30
~AES256CBCEncrypt()
Definition: aes.cpp:164
~AES128CBCEncrypt()
Definition: aes.cpp:192
unsigned char iv[AES_BLOCKSIZE]
Definition: aes.h:102
An encryption class for AES-128.
Definition: aes.h:19
AES128_ctx ctx
Definition: aes.h:22
const bool pad
Definition: aes.h:75
unsigned char iv[AES_BLOCKSIZE]
Definition: aes.h:76
AES128CBCDecrypt(const unsigned char key[AES128_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn)
Definition: aes.cpp:202
AES256Decrypt(const unsigned char key[32])
Definition: aes.cpp:60
static const int AES_BLOCKSIZE
Definition: aes.h:14
const bool pad
Definition: aes.h:114
AES128_ctx ctx
Definition: aes.h:34
Released under the MIT license