mirror of
https://github.com/dashpay/dash.git
synced 2024-12-29 05:49:11 +01:00
b902736621
f6ee177f7 Remove unused AES-128 code (practicalswift) Pull request description: Remove unused AES-128 code. As far as I can tell this AES-128 code has never been in use in the project (outside of testing/benchmarking). The AES-256 code is used in `CCrypter::Encrypt`/`CCrypter::Decrypt` (`src/wallet/crypter.cpp`). Trivia: 0.15% of the project's C++ LOC count (excluding dependencies) is trimmed off: ``` $ LOC_BEFORE=$(git grep -I "" HEAD~1 -- "*.cpp" "*.h" ":(exclude)src/leveldb/" ":(exclude)src/secp256k1/" ":(exclude)src/univalue/" | wc -l) $ LOC_AFTER=$(git grep -I "" -- "*.cpp" "*.h" ":(exclude)src/leveldb/" ":(exclude)src/secp256k1/" ":(exclude)src/univalue/" | wc -l) $ bc <<< "scale=4; ${LOC_AFTER}/${LOC_BEFORE}" .9985 ``` :-) Tree-SHA512: 9588a3cd795a89ef658b8ee7323865f57723cb4ed9560c21de793f82d35e2835059e7d6d0705e99e3d16bf6b2a444b4bf19568d50174ff3776caf8a3168f5c85
68 lines
1.7 KiB
C++
68 lines
1.7 KiB
C++
// Copyright (c) 2015 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
//
|
|
// C++ wrapper around ctaes, a constant-time AES implementation
|
|
|
|
#ifndef BITCOIN_CRYPTO_AES_H
|
|
#define BITCOIN_CRYPTO_AES_H
|
|
|
|
extern "C" {
|
|
#include <crypto/ctaes/ctaes.h>
|
|
}
|
|
|
|
static const int AES_BLOCKSIZE = 16;
|
|
static const int AES256_KEYSIZE = 32;
|
|
|
|
/** An encryption class for AES-256. */
|
|
class AES256Encrypt
|
|
{
|
|
private:
|
|
AES256_ctx ctx;
|
|
|
|
public:
|
|
explicit AES256Encrypt(const unsigned char key[32]);
|
|
~AES256Encrypt();
|
|
void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const;
|
|
};
|
|
|
|
/** A decryption class for AES-256. */
|
|
class AES256Decrypt
|
|
{
|
|
private:
|
|
AES256_ctx ctx;
|
|
|
|
public:
|
|
explicit AES256Decrypt(const unsigned char key[32]);
|
|
~AES256Decrypt();
|
|
void Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const;
|
|
};
|
|
|
|
class AES256CBCEncrypt
|
|
{
|
|
public:
|
|
AES256CBCEncrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn);
|
|
~AES256CBCEncrypt();
|
|
int Encrypt(const unsigned char* data, int size, unsigned char* out) const;
|
|
|
|
private:
|
|
const AES256Encrypt enc;
|
|
const bool pad;
|
|
unsigned char iv[AES_BLOCKSIZE];
|
|
};
|
|
|
|
class AES256CBCDecrypt
|
|
{
|
|
public:
|
|
AES256CBCDecrypt(const unsigned char key[AES256_KEYSIZE], const unsigned char ivIn[AES_BLOCKSIZE], bool padIn);
|
|
~AES256CBCDecrypt();
|
|
int Decrypt(const unsigned char* data, int size, unsigned char* out) const;
|
|
|
|
private:
|
|
const AES256Decrypt dec;
|
|
const bool pad;
|
|
unsigned char iv[AES_BLOCKSIZE];
|
|
};
|
|
|
|
#endif // BITCOIN_CRYPTO_AES_H
|