Fabcoin Core  0.16.2
P2P Digital Currency
aes.h
Go to the documentation of this file.
1 // Copyright (c) 2015-2017 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 FABCOIN_CRYPTO_AES_H
8 #define FABCOIN_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]);
38  ~AES128Decrypt();
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]);
50  ~AES256Encrypt();
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]);
62  ~AES256Decrypt();
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);
109  ~AES128CBCDecrypt();
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 // FABCOIN_CRYPTO_AES_H
AES256_ctx ctx
Definition: aes.h:58
A decryption class for AES-256.
Definition: aes.h:55
AES128Encrypt(const unsigned char key[16])
Definition: aes.cpp:15
const AES256Decrypt dec
Definition: aes.h:87
const AES128Encrypt enc
Definition: aes.h:100
An encryption class for AES-256.
Definition: aes.h:43
~AES128Encrypt()
Definition: aes.cpp:20
const bool pad
Definition: aes.h:101
const AES128Decrypt dec
Definition: aes.h:113
const bool pad
Definition: aes.h:88
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
uint8_t const size_t const size
Definition: sha3.h:20
AES256_ctx ctx
Definition: aes.h:46
An encryption class for AES-128.
Definition: aes.h:19
AES128_ctx ctx
Definition: aes.h:22
const bool pad
Definition: aes.h:75
uint8_t const * data
Definition: sha3.h:19
const bool pad
Definition: aes.h:114
AES128_ctx ctx
Definition: aes.h:34