Bitcoin Core
32.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
crypto
aes.h
Go to the documentation of this file.
1
// Copyright (c) 2015-present 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
#include <
support/allocators/secure.h
>
11
extern
"C"
{
12
#include <
crypto/ctaes/ctaes.h
>
13
}
14
15
inline
constexpr
int
AES_BLOCKSIZE
= 16;
16
inline
constexpr
int
AES256_KEYSIZE
= 32;
17
19
class
AES256Encrypt
20
{
21
private
:
22
secure_allocator<AES256_ctx>
allocator
;
23
AES256_ctx
*
ctx
;
24
25
public
:
26
explicit
AES256Encrypt
(
const
unsigned
char
key[32]);
27
~AES256Encrypt
();
28
void
Encrypt
(
unsigned
char
ciphertext[16],
const
unsigned
char
plaintext[16])
const
;
29
};
30
32
class
AES256Decrypt
33
{
34
private
:
35
secure_allocator<AES256_ctx>
allocator
;
36
AES256_ctx
*
ctx
;
37
38
public
:
39
explicit
AES256Decrypt
(
const
unsigned
char
key[32]);
40
~AES256Decrypt
();
41
void
Decrypt
(
unsigned
char
plaintext[16],
const
unsigned
char
ciphertext[16])
const
;
42
};
43
44
class
AES256CBCEncrypt
45
{
46
public
:
47
AES256CBCEncrypt
(
const
unsigned
char
key[
AES256_KEYSIZE
],
const
unsigned
char
ivIn[
AES_BLOCKSIZE
],
bool
padIn);
48
~AES256CBCEncrypt
();
49
int
Encrypt
(
const
unsigned
char
* data,
int
size,
unsigned
char
* out)
const
;
50
51
private
:
52
secure_allocator<unsigned char>
allocator
;
53
const
AES256Encrypt
enc
;
54
const
bool
pad
;
55
unsigned
char
*
iv
;
56
};
57
58
class
AES256CBCDecrypt
59
{
60
public
:
61
AES256CBCDecrypt
(
const
unsigned
char
key[
AES256_KEYSIZE
],
const
unsigned
char
ivIn[
AES_BLOCKSIZE
],
bool
padIn);
62
~AES256CBCDecrypt
();
63
int
Decrypt
(
const
unsigned
char
* data,
int
size,
unsigned
char
* out)
const
;
64
65
private
:
66
secure_allocator<unsigned char>
allocator
;
67
const
AES256Decrypt
dec
;
68
const
bool
pad
;
69
unsigned
char
*
iv
;
70
};
71
72
#endif
// BITCOIN_CRYPTO_AES_H
AES_BLOCKSIZE
constexpr int AES_BLOCKSIZE
Definition
aes.h:15
AES256_KEYSIZE
constexpr int AES256_KEYSIZE
Definition
aes.h:16
AES256CBCDecrypt::pad
const bool pad
Definition
aes.h:68
AES256CBCDecrypt::AES256CBCDecrypt
AES256CBCDecrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn)
Definition
aes.cpp:141
AES256CBCDecrypt::dec
const AES256Decrypt dec
Definition
aes.h:67
AES256CBCDecrypt::Decrypt
int Decrypt(const unsigned char *data, int size, unsigned char *out) const
Definition
aes.cpp:149
AES256CBCDecrypt::allocator
secure_allocator< unsigned char > allocator
Definition
aes.h:66
AES256CBCDecrypt::iv
unsigned char * iv
Definition
aes.h:69
AES256CBCEncrypt::AES256CBCEncrypt
AES256CBCEncrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn)
Definition
aes.cpp:124
AES256CBCEncrypt::iv
unsigned char * iv
Definition
aes.h:55
AES256CBCEncrypt::Encrypt
int Encrypt(const unsigned char *data, int size, unsigned char *out) const
Definition
aes.cpp:131
AES256CBCEncrypt::pad
const bool pad
Definition
aes.h:54
AES256CBCEncrypt::enc
const AES256Encrypt enc
Definition
aes.h:53
AES256CBCEncrypt::allocator
secure_allocator< unsigned char > allocator
Definition
aes.h:52
AES256Decrypt
A decryption class for AES-256.
Definition
aes.h:33
AES256Decrypt::allocator
secure_allocator< AES256_ctx > allocator
Definition
aes.h:35
AES256Decrypt::ctx
AES256_ctx * ctx
Definition
aes.h:36
AES256Decrypt::AES256Decrypt
AES256Decrypt(const unsigned char key[32])
Definition
aes.cpp:30
AES256Decrypt::Decrypt
void Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const
Definition
aes.cpp:41
AES256Encrypt
An encryption class for AES-256.
Definition
aes.h:20
AES256Encrypt::allocator
secure_allocator< AES256_ctx > allocator
Definition
aes.h:22
AES256Encrypt::AES256Encrypt
AES256Encrypt(const unsigned char key[32])
Definition
aes.cpp:14
AES256Encrypt::ctx
AES256_ctx * ctx
Definition
aes.h:23
AES256Encrypt::Encrypt
void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const
Definition
aes.cpp:25
ctaes.h
secure.h
AES256_ctx
Definition
ctaes.h:25
secure_allocator
Definition
secure.h:20
Generated on
for Bitcoin Core by
1.18.0