ext-cryptopp/regtest2.cpp
Jeffrey Walton 5603661eec
Add ChaChaTLS implementation (GH #265)
We tweaked ChaCha to arrive at the IETF's implementation specified by RFC 7539. We are not sure how to handle block counter wrap. At the moment the caller is responsible for managing it. We were not able to find a reference implementation so we disable SIMD implementations like SSE, AVX, NEON and Power4. We need the wide block tests for corner cases to ensure our implementation is correct.
2019-01-24 09:36:05 -05:00

103 lines
3.6 KiB
C++

// regtest2.cpp - originally written and placed in the public domain by Wei Dai
// regtest.cpp split into 3 files due to OOM kills by JW
// in April 2017. A second split occured in July 2018.
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
#include "cryptlib.h"
#include "factory.h"
#include "bench.h"
#include "cpu.h"
// For MAC's
#include "hmac.h"
#include "cmac.h"
#include "dmac.h"
#include "vmac.h"
#include "ttmac.h"
// Ciphers
#include "md5.h"
#include "keccak.h"
#include "sha.h"
#include "sha3.h"
#include "blake2.h"
#include "ripemd.h"
#include "poly1305.h"
#include "siphash.h"
#include "panama.h"
// Stream ciphers
#include "arc4.h"
#include "seal.h"
#include "wake.h"
#include "chacha.h"
#include "salsa.h"
#include "rabbit.h"
#include "hc128.h"
#include "hc256.h"
#include "panama.h"
#include "sosemanuk.h"
// Block for CMAC
#include "aes.h"
#include "des.h"
// Aggressive stack checking with VS2005 SP1 and above.
#if (_MSC_FULL_VER >= 140050727)
# pragma strict_gs_check (on)
#endif
#if CRYPTOPP_MSC_VERSION
# pragma warning(disable: 4505 4355)
#endif
USING_NAMESPACE(CryptoPP)
// MAC ciphers
void RegisterFactories2()
{
RegisterDefaultFactoryFor<MessageAuthenticationCode, HMAC<Weak::MD5> >();
RegisterDefaultFactoryFor<MessageAuthenticationCode, HMAC<RIPEMD160> >();
RegisterDefaultFactoryFor<MessageAuthenticationCode, HMAC<SHA1> >();
RegisterDefaultFactoryFor<MessageAuthenticationCode, HMAC<SHA224> >();
RegisterDefaultFactoryFor<MessageAuthenticationCode, HMAC<SHA256> >();
RegisterDefaultFactoryFor<MessageAuthenticationCode, HMAC<SHA384> >();
RegisterDefaultFactoryFor<MessageAuthenticationCode, HMAC<SHA512> >();
RegisterDefaultFactoryFor<MessageAuthenticationCode, TTMAC>();
RegisterDefaultFactoryFor<MessageAuthenticationCode, VMAC<AES> >();
RegisterDefaultFactoryFor<MessageAuthenticationCode, VMAC<AES, 64> >();
RegisterDefaultFactoryFor<MessageAuthenticationCode, Weak::PanamaMAC<LittleEndian> >();
RegisterDefaultFactoryFor<MessageAuthenticationCode, Weak::PanamaMAC<BigEndian> >();
RegisterDefaultFactoryFor<MessageAuthenticationCode, CMAC<AES> >();
RegisterDefaultFactoryFor<MessageAuthenticationCode, DMAC<AES> >();
RegisterDefaultFactoryFor<MessageAuthenticationCode, Poly1305<AES> >();
RegisterDefaultFactoryFor<MessageAuthenticationCode, CMAC<DES_EDE3> >();
RegisterDefaultFactoryFor<MessageAuthenticationCode, BLAKE2s>();
RegisterDefaultFactoryFor<MessageAuthenticationCode, BLAKE2b>();
RegisterDefaultFactoryFor<MessageAuthenticationCode, SipHash<2,4> >();
RegisterDefaultFactoryFor<MessageAuthenticationCode, SipHash<4,8> >();
}
// Stream ciphers
void RegisterFactories3()
{
RegisterSymmetricCipherDefaultFactories<Weak::MARC4>();
RegisterSymmetricCipherDefaultFactories<SEAL<> >();
RegisterSymmetricCipherDefaultFactories<SEAL<LittleEndian> >();
RegisterSymmetricCipherDefaultFactories<WAKE_OFB<LittleEndian> >();
RegisterSymmetricCipherDefaultFactories<WAKE_OFB<BigEndian> >();
RegisterSymmetricCipherDefaultFactories<PanamaCipher<LittleEndian> >();
RegisterSymmetricCipherDefaultFactories<PanamaCipher<BigEndian> >();
RegisterSymmetricCipherDefaultFactories<Salsa20>();
RegisterSymmetricCipherDefaultFactories<XSalsa20>();
RegisterSymmetricCipherDefaultFactories<ChaCha>();
RegisterSymmetricCipherDefaultFactories<ChaChaTLS>();
RegisterSymmetricCipherDefaultFactories<Sosemanuk>();
RegisterSymmetricCipherDefaultFactories<Rabbit>();
RegisterSymmetricCipherDefaultFactories<RabbitWithIV>();
RegisterSymmetricCipherDefaultFactories<HC128>();
RegisterSymmetricCipherDefaultFactories<HC256>();
}