Raven Core  3.0.0
P2P Digital Currency
aes.h
Go to the documentation of this file.
1 // Copyright (c) 2015-2016 The Bitcoin Core developers
2 // Copyright (c) 2017-2019 The Raven Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 //
6 // C++ wrapper around ctaes, a constant-time AES implementation
7 
8 #ifndef RAVEN_CRYPTO_AES_H
9 #define RAVEN_CRYPTO_AES_H
10 
11 extern "C" {
12 #include "crypto/ctaes/ctaes.h"
13 }
14 
15 static const int AES_BLOCKSIZE = 16;
16 static const int AES128_KEYSIZE = 16;
17 static const int AES256_KEYSIZE = 32;
18 
21 {
22 private:
24 
25 public:
26  explicit AES128Encrypt(const unsigned char key[16]);
28  void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const;
29 };
30 
33 {
34 private:
36 
37 public:
38  explicit AES128Decrypt(const unsigned char key[16]);
39  ~AES128Decrypt();
40  void Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const;
41 };
42 
45 {
46 private:
48 
49 public:
50  explicit AES256Encrypt(const unsigned char key[32]);
51  ~AES256Encrypt();
52  void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const;
53 };
54 
57 {
58 private:
60 
61 public:
62  explicit AES256Decrypt(const unsigned char key[32]);
63  ~AES256Decrypt();
64  void Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const;
65 };
66 
68 {
69 public:
70  AES256CBCEncrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn);
72  int Encrypt(const unsigned char* data, int size, unsigned char* out) const;
73 
74 private:
76  const bool pad;
77  unsigned char iv[AES_BLOCKSIZE];
78 };
79 
81 {
82 public:
83  AES256CBCDecrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn);
85  int Decrypt(const unsigned char* data, int size, unsigned char* out) const;
86 
87 private:
89  const bool pad;
90  unsigned char iv[AES_BLOCKSIZE];
91 };
92 
94 {
95 public:
96  AES128CBCEncrypt(const unsigned char key[AES128_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn);
98  int Encrypt(const unsigned char* data, int size, unsigned char* out) const;
99 
100 private:
102  const bool pad;
103  unsigned char iv[AES_BLOCKSIZE];
104 };
105 
107 {
108 public:
109  AES128CBCDecrypt(const unsigned char key[AES128_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn);
110  ~AES128CBCDecrypt();
111  int Decrypt(const unsigned char* data, int size, unsigned char* out) const;
112 
113 private:
115  const bool pad;
116  unsigned char iv[AES_BLOCKSIZE];
117 };
118 
119 #endif // RAVEN_CRYPTO_AES_H
AES256_ctx ctx
Definition: aes.h:59
A decryption class for AES-256.
Definition: aes.h:56
AES128Encrypt(const unsigned char key[16])
Definition: aes.cpp:16
const AES256Decrypt dec
Definition: aes.h:88
const AES128Encrypt enc
Definition: aes.h:101
An encryption class for AES-256.
Definition: aes.h:44
~AES128Encrypt()
Definition: aes.cpp:21
const bool pad
Definition: aes.h:102
const AES128Decrypt dec
Definition: aes.h:114
const bool pad
Definition: aes.h:89
void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const
Definition: aes.cpp:26
A decryption class for AES-128.
Definition: aes.h:32
const AES256Encrypt enc
Definition: aes.h:75
AES256_ctx ctx
Definition: aes.h:47
An encryption class for AES-128.
Definition: aes.h:20
AES128_ctx ctx
Definition: aes.h:23
const bool pad
Definition: aes.h:76
const bool pad
Definition: aes.h:115
AES128_ctx ctx
Definition: aes.h:35