Bitcoin Core  22.99.0
P2P Digital Currency
Functions | Variables
crypto_tests.cpp File Reference
#include <crypto/aes.h>
#include <crypto/chacha20.h>
#include <crypto/chacha_poly_aead.h>
#include <crypto/hkdf_sha256_32.h>
#include <crypto/hmac_sha256.h>
#include <crypto/hmac_sha512.h>
#include <crypto/poly1305.h>
#include <crypto/ripemd160.h>
#include <crypto/sha1.h>
#include <crypto/sha256.h>
#include <crypto/sha3.h>
#include <crypto/sha512.h>
#include <crypto/muhash.h>
#include <random.h>
#include <streams.h>
#include <test/util/setup_common.h>
#include <util/strencodings.h>
#include <vector>
#include <boost/test/unit_test.hpp>
Include dependency graph for crypto_tests.cpp:

Go to the source code of this file.

Functions

template<typename Hasher , typename In , typename Out >
static void TestVector (const Hasher &h, const In &in, const Out &out)
 
static void TestSHA1 (const std::string &in, const std::string &hexout)
 
static void TestSHA256 (const std::string &in, const std::string &hexout)
 
static void TestSHA512 (const std::string &in, const std::string &hexout)
 
static void TestRIPEMD160 (const std::string &in, const std::string &hexout)
 
static void TestHMACSHA256 (const std::string &hexkey, const std::string &hexin, const std::string &hexout)
 
static void TestHMACSHA512 (const std::string &hexkey, const std::string &hexin, const std::string &hexout)
 
static void TestAES256 (const std::string &hexkey, const std::string &hexin, const std::string &hexout)
 
static void TestAES256CBC (const std::string &hexkey, const std::string &hexiv, bool pad, const std::string &hexin, const std::string &hexout)
 
static void TestChaCha20 (const std::string &hex_message, const std::string &hexkey, uint64_t nonce, uint64_t seek, const std::string &hexout)
 
static void TestPoly1305 (const std::string &hexmessage, const std::string &hexkey, const std::string &hextag)
 
static void TestHKDF_SHA256_32 (const std::string &ikm_hex, const std::string &salt_hex, const std::string &info_hex, const std::string &okm_check_hex)
 
static std::string LongTestString ()
 
 BOOST_AUTO_TEST_CASE (ripemd160_testvectors)
 
 BOOST_AUTO_TEST_CASE (sha1_testvectors)
 
 BOOST_AUTO_TEST_CASE (sha256_testvectors)
 
 BOOST_AUTO_TEST_CASE (sha512_testvectors)
 
 BOOST_AUTO_TEST_CASE (hmac_sha256_testvectors)
 
 BOOST_AUTO_TEST_CASE (hmac_sha512_testvectors)
 
 BOOST_AUTO_TEST_CASE (aes_testvectors)
 
 BOOST_AUTO_TEST_CASE (aes_cbc_testvectors)
 
 BOOST_AUTO_TEST_CASE (chacha20_testvector)
 
 BOOST_AUTO_TEST_CASE (poly1305_testvector)
 
 BOOST_AUTO_TEST_CASE (hkdf_hmac_sha256_l32_tests)
 
static void TestChaCha20Poly1305AEAD (bool must_succeed, unsigned int expected_aad_length, const std::string &hex_m, const std::string &hex_k1, const std::string &hex_k2, const std::string &hex_aad_keystream, const std::string &hex_encrypted_message, const std::string &hex_encrypted_message_seq_999)
 
 BOOST_AUTO_TEST_CASE (chacha20_poly1305_aead_testvector)
 
 BOOST_AUTO_TEST_CASE (countbits_tests)
 
 BOOST_AUTO_TEST_CASE (sha256d64)
 
static void TestSHA3_256 (const std::string &input, const std::string &output)
 
 BOOST_AUTO_TEST_CASE (keccak_tests)
 
 BOOST_AUTO_TEST_CASE (sha3_256_tests)
 
static MuHash3072 FromInt (unsigned char i)
 
 BOOST_AUTO_TEST_CASE (muhash_tests)
 

Variables

const std::string test1 = LongTestString()
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/17]

BOOST_AUTO_TEST_CASE ( aes_cbc_testvectors  )

Definition at line 430 of file crypto_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/17]

BOOST_AUTO_TEST_CASE ( aes_testvectors  )

Definition at line 419 of file crypto_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/17]

BOOST_AUTO_TEST_CASE ( chacha20_poly1305_aead_testvector  )

Definition at line 685 of file crypto_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/17]

BOOST_AUTO_TEST_CASE ( chacha20_testvector  )

Definition at line 461 of file crypto_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [5/17]

BOOST_AUTO_TEST_CASE ( countbits_tests  )

Definition at line 718 of file crypto_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [6/17]

BOOST_AUTO_TEST_CASE ( hkdf_hmac_sha256_l32_tests  )

Definition at line 573 of file crypto_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [7/17]

BOOST_AUTO_TEST_CASE ( hmac_sha256_testvectors  )

Definition at line 298 of file crypto_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [8/17]

BOOST_AUTO_TEST_CASE ( hmac_sha512_testvectors  )

Definition at line 351 of file crypto_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [9/17]

BOOST_AUTO_TEST_CASE ( keccak_tests  )

Definition at line 778 of file crypto_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [10/17]

BOOST_AUTO_TEST_CASE ( muhash_tests  )

Definition at line 867 of file crypto_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [11/17]

BOOST_AUTO_TEST_CASE ( poly1305_testvector  )

Definition at line 503 of file crypto_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [12/17]

BOOST_AUTO_TEST_CASE ( ripemd160_testvectors  )

Definition at line 207 of file crypto_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [13/17]

BOOST_AUTO_TEST_CASE ( sha1_testvectors  )

Definition at line 223 of file crypto_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [14/17]

BOOST_AUTO_TEST_CASE ( sha256_testvectors  )

Definition at line 239 of file crypto_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [15/17]

BOOST_AUTO_TEST_CASE ( sha256d64  )

Definition at line 740 of file crypto_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [16/17]

BOOST_AUTO_TEST_CASE ( sha3_256_tests  )

Definition at line 798 of file crypto_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [17/17]

BOOST_AUTO_TEST_CASE ( sha512_testvectors  )

Definition at line 261 of file crypto_tests.cpp.

Here is the call graph for this function:

◆ FromInt()

static MuHash3072 FromInt ( unsigned char  i)
static

Definition at line 862 of file crypto_tests.cpp.

Here is the caller graph for this function:

◆ LongTestString()

static std::string LongTestString ( )
static

Definition at line 192 of file crypto_tests.cpp.

◆ TestAES256()

static void TestAES256 ( const std::string &  hexkey,
const std::string &  hexin,
const std::string &  hexout 
)
static

Definition at line 73 of file crypto_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestAES256CBC()

static void TestAES256CBC ( const std::string &  hexkey,
const std::string &  hexiv,
bool  pad,
const std::string &  hexin,
const std::string &  hexout 
)
static

Definition at line 92 of file crypto_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestChaCha20()

static void TestChaCha20 ( const std::string &  hex_message,
const std::string &  hexkey,
uint64_t  nonce,
uint64_t  seek,
const std::string &  hexout 
)
static

Definition at line 133 of file crypto_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestChaCha20Poly1305AEAD()

static void TestChaCha20Poly1305AEAD ( bool  must_succeed,
unsigned int  expected_aad_length,
const std::string &  hex_m,
const std::string &  hex_k1,
const std::string &  hex_k2,
const std::string &  hex_aad_keystream,
const std::string &  hex_encrypted_message,
const std::string &  hex_encrypted_message_seq_999 
)
static

Definition at line 593 of file crypto_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestHKDF_SHA256_32()

static void TestHKDF_SHA256_32 ( const std::string &  ikm_hex,
const std::string &  salt_hex,
const std::string &  info_hex,
const std::string &  okm_check_hex 
)
static

Definition at line 176 of file crypto_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestHMACSHA256()

static void TestHMACSHA256 ( const std::string &  hexkey,
const std::string &  hexin,
const std::string &  hexout 
)
static

Definition at line 63 of file crypto_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestHMACSHA512()

static void TestHMACSHA512 ( const std::string &  hexkey,
const std::string &  hexin,
const std::string &  hexout 
)
static

Definition at line 68 of file crypto_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestPoly1305()

static void TestPoly1305 ( const std::string &  hexmessage,
const std::string &  hexkey,
const std::string &  hextag 
)
static

Definition at line 165 of file crypto_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestRIPEMD160()

static void TestRIPEMD160 ( const std::string &  in,
const std::string &  hexout 
)
static

Definition at line 61 of file crypto_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestSHA1()

static void TestSHA1 ( const std::string &  in,
const std::string &  hexout 
)
static

Definition at line 58 of file crypto_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestSHA256()

static void TestSHA256 ( const std::string &  in,
const std::string &  hexout 
)
static

Definition at line 59 of file crypto_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestSHA3_256()

static void TestSHA3_256 ( const std::string &  input,
const std::string &  output 
)
static

Definition at line 756 of file crypto_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestSHA512()

static void TestSHA512 ( const std::string &  in,
const std::string &  hexout 
)
static

Definition at line 60 of file crypto_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestVector()

template<typename Hasher , typename In , typename Out >
static void TestVector ( const Hasher &  h,
const In &  in,
const Out &  out 
)
static

Definition at line 30 of file crypto_tests.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ test1

const std::string test1 = LongTestString()

Definition at line 205 of file crypto_tests.cpp.