Bitcoin Core
31.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
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
18
class
AES256Encrypt
19
{
20
private
:
21
AES256_ctx
ctx
;
22
23
public
:
24
explicit
AES256Encrypt
(
const
unsigned
char
key[32]);
25
~AES256Encrypt
();
26
void
Encrypt
(
unsigned
char
ciphertext[16],
const
unsigned
char
plaintext[16])
const
;
27
};
28
30
class
AES256Decrypt
31
{
32
private
:
33
AES256_ctx
ctx
;
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
41
class
AES256CBCEncrypt
42
{
43
public
:
44
AES256CBCEncrypt
(
const
unsigned
char
key[
AES256_KEYSIZE
],
const
unsigned
char
ivIn[
AES_BLOCKSIZE
],
bool
padIn);
45
~AES256CBCEncrypt
();
46
int
Encrypt
(
const
unsigned
char
* data,
int
size,
unsigned
char
* out)
const
;
47
48
private
:
49
const
AES256Encrypt
enc
;
50
const
bool
pad
;
51
unsigned
char
iv
[
AES_BLOCKSIZE
];
52
};
53
54
class
AES256CBCDecrypt
55
{
56
public
:
57
AES256CBCDecrypt
(
const
unsigned
char
key[
AES256_KEYSIZE
],
const
unsigned
char
ivIn[
AES_BLOCKSIZE
],
bool
padIn);
58
~AES256CBCDecrypt
();
59
int
Decrypt
(
const
unsigned
char
* data,
int
size,
unsigned
char
* out)
const
;
60
61
private
:
62
const
AES256Decrypt
dec
;
63
const
bool
pad
;
64
unsigned
char
iv
[
AES_BLOCKSIZE
];
65
};
66
67
#endif
// BITCOIN_CRYPTO_AES_H
AES256_KEYSIZE
static const int AES256_KEYSIZE
Definition
aes.h:15
AES_BLOCKSIZE
static const int AES_BLOCKSIZE
Definition
aes.h:14
AES256CBCDecrypt::pad
const bool pad
Definition
aes.h:63
AES256CBCDecrypt::AES256CBCDecrypt
AES256CBCDecrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn)
Definition
aes.cpp:137
AES256CBCDecrypt::dec
const AES256Decrypt dec
Definition
aes.h:62
AES256CBCDecrypt::Decrypt
int Decrypt(const unsigned char *data, int size, unsigned char *out) const
Definition
aes.cpp:144
AES256CBCDecrypt::~AES256CBCDecrypt
~AES256CBCDecrypt()
Definition
aes.cpp:149
AES256CBCDecrypt::iv
unsigned char iv[AES_BLOCKSIZE]
Definition
aes.h:64
AES256CBCEncrypt::AES256CBCEncrypt
AES256CBCEncrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn)
Definition
aes.cpp:121
AES256CBCEncrypt::Encrypt
int Encrypt(const unsigned char *data, int size, unsigned char *out) const
Definition
aes.cpp:127
AES256CBCEncrypt::pad
const bool pad
Definition
aes.h:50
AES256CBCEncrypt::~AES256CBCEncrypt
~AES256CBCEncrypt()
Definition
aes.cpp:132
AES256CBCEncrypt::enc
const AES256Encrypt enc
Definition
aes.h:49
AES256CBCEncrypt::iv
unsigned char iv[AES_BLOCKSIZE]
Definition
aes.h:51
AES256Decrypt
A decryption class for AES-256.
Definition
aes.h:31
AES256Decrypt::~AES256Decrypt
~AES256Decrypt()
Definition
aes.cpp:33
AES256Decrypt::AES256Decrypt
AES256Decrypt(const unsigned char key[32])
Definition
aes.cpp:28
AES256Decrypt::Decrypt
void Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const
Definition
aes.cpp:38
AES256Decrypt::ctx
AES256_ctx ctx
Definition
aes.h:33
AES256Encrypt
An encryption class for AES-256.
Definition
aes.h:19
AES256Encrypt::AES256Encrypt
AES256Encrypt(const unsigned char key[32])
Definition
aes.cpp:13
AES256Encrypt::~AES256Encrypt
~AES256Encrypt()
Definition
aes.cpp:18
AES256Encrypt::Encrypt
void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const
Definition
aes.cpp:23
AES256Encrypt::ctx
AES256_ctx ctx
Definition
aes.h:21
ctaes.h
AES256_ctx
Definition
ctaes.h:25
Generated on
for Bitcoin Core by
1.17.0