Merge branch 'constexpr'
commit
be8a9f6742
2
3way.h
2
3way.h
|
|
@ -16,7 +16,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
//! \brief ThreeWay block cipher information
|
||||
struct ThreeWay_Info : public FixedBlockSize<12>, public FixedKeyLength<12>, public VariableRounds<11>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "3-Way";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "3-Way";}
|
||||
};
|
||||
|
||||
//! \class ThreeWay
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public:
|
|||
void Update(const byte *input, size_t length);
|
||||
void TruncatedFinal(byte *hash, size_t size);
|
||||
unsigned int DigestSize() const {return DIGESTSIZE;}
|
||||
static const char * StaticAlgorithmName() {return "Adler32";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Adler32";}
|
||||
std::string AlgorithmName() const {return StaticAlgorithmName();}
|
||||
|
||||
private:
|
||||
|
|
|
|||
4
arc4.h
4
arc4.h
|
|
@ -23,7 +23,7 @@ class CRYPTOPP_NO_VTABLE ARC4_Base : public VariableKeyLength<16, 1, 256>, publi
|
|||
public:
|
||||
~ARC4_Base();
|
||||
|
||||
static const char *StaticAlgorithmName() {return "ARC4";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "ARC4";}
|
||||
|
||||
void GenerateBlock(byte *output, size_t size);
|
||||
void DiscardBytes(size_t n);
|
||||
|
|
@ -55,7 +55,7 @@ DOCUMENTED_TYPEDEF(SymmetricCipherFinal<ARC4_Base>, ARC4)
|
|||
class CRYPTOPP_NO_VTABLE MARC4_Base : public ARC4_Base
|
||||
{
|
||||
public:
|
||||
static const char *StaticAlgorithmName() {return "MARC4";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "MARC4";}
|
||||
|
||||
typedef SymmetricCipherFinal<MARC4_Base> Encryption;
|
||||
typedef SymmetricCipherFinal<MARC4_Base> Decryption;
|
||||
|
|
|
|||
4
blake2.h
4
blake2.h
|
|
@ -39,7 +39,7 @@ struct BLAKE2_Info : public VariableKeyLength<(T_64bit ? 64 : 32),0,(T_64bit ? 6
|
|||
CRYPTOPP_CONSTANT(SALTSIZE = (T_64bit ? 16 : 8))
|
||||
CRYPTOPP_CONSTANT(PERSONALIZATIONSIZE = (T_64bit ? 16 : 8))
|
||||
|
||||
static const char *StaticAlgorithmName() {return (T_64bit ? "BLAKE2b" : "BLAKE2s");}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return (T_64bit ? "BLAKE2b" : "BLAKE2s");}
|
||||
};
|
||||
|
||||
//! \class BLAKE2_ParameterBlock
|
||||
|
|
@ -175,7 +175,7 @@ public:
|
|||
|
||||
//! \brief Retrieve the static algorithm name
|
||||
//! \returns the algorithm name (BLAKE2s or BLAKE2b)
|
||||
static const char *StaticAlgorithmName() {return BLAKE2_Info<T_64bit>::StaticAlgorithmName();}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return BLAKE2_Info<T_64bit>::StaticAlgorithmName();}
|
||||
|
||||
//! \brief Retrieve the object's name
|
||||
//! \returns the object's algorithm name following RFC 7693
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
//! \brief Blowfish block cipher information
|
||||
struct Blowfish_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 4, 56>, public FixedRounds<16>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "Blowfish";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Blowfish";}
|
||||
};
|
||||
|
||||
// <a href="http://www.weidai.com/scan-mirror/cs.html#Blowfish">Blowfish</a>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
//! \brief Camellia block cipher information
|
||||
struct Camellia_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "Camellia";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Camellia";}
|
||||
};
|
||||
|
||||
//! \class Camellia
|
||||
|
|
|
|||
14
cast.h
14
cast.h
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
//! \class CAST
|
||||
//! \brief CAST block cipher base
|
||||
class CAST
|
||||
{
|
||||
protected:
|
||||
|
|
@ -21,7 +23,7 @@ protected:
|
|||
//! \brief CAST128 block cipher information
|
||||
struct CAST128_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 5, 16>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "CAST-128";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "CAST-128";}
|
||||
};
|
||||
|
||||
//! \class CAST128
|
||||
|
|
@ -29,6 +31,8 @@ struct CAST128_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 5,
|
|||
//! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#CAST-128">CAST-128</a>
|
||||
class CAST128 : public CAST128_Info, public BlockCipherDocumentation
|
||||
{
|
||||
//! \class Base
|
||||
//! \brief CAST128 block cipher default operation
|
||||
class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl<CAST128_Info>
|
||||
{
|
||||
public:
|
||||
|
|
@ -39,12 +43,16 @@ class CAST128 : public CAST128_Info, public BlockCipherDocumentation
|
|||
FixedSizeSecBlock<word32, 32> K;
|
||||
};
|
||||
|
||||
//! \class Enc
|
||||
//! \brief CAST128 block cipher encryption operation
|
||||
class CRYPTOPP_NO_VTABLE Enc : public Base
|
||||
{
|
||||
public:
|
||||
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
|
||||
};
|
||||
|
||||
//! \class Dec
|
||||
//! \brief CAST128 block cipher decryption operation
|
||||
class CRYPTOPP_NO_VTABLE Dec : public Base
|
||||
{
|
||||
public:
|
||||
|
|
@ -60,7 +68,7 @@ public:
|
|||
//! \brief CAST256 block cipher information
|
||||
struct CAST256_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 4>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "CAST-256";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "CAST-256";}
|
||||
};
|
||||
|
||||
//! \class CAST256
|
||||
|
|
@ -68,6 +76,8 @@ struct CAST256_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16
|
|||
//! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#CAST-256">CAST-256</a>
|
||||
class CAST256 : public CAST256_Info, public BlockCipherDocumentation
|
||||
{
|
||||
//! \class Base
|
||||
//! \brief CAST256 block cipher default operation
|
||||
class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl<CAST256_Info>
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
4
chacha.h
4
chacha.h
|
|
@ -19,7 +19,9 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
template <unsigned int R>
|
||||
struct ChaCha_Info : public VariableKeyLength<32, 16, 32, 16, SimpleKeyingInterface::UNIQUE_IV, 8>, public FixedRounds<R>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {static const std::string name = "ChaCha" + IntToString(R); return name.c_str();}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {
|
||||
return (R==8?"ChaCha8":(R==12?"ChaCha12":(R==20?"ChaCha20":"ChaCha")));
|
||||
}
|
||||
};
|
||||
|
||||
//! \class ChaCha_Policy
|
||||
|
|
|
|||
9
config.h
9
config.h
|
|
@ -544,7 +544,8 @@ NAMESPACE_END
|
|||
# define CRYPTOPP_NOINLINE
|
||||
#endif
|
||||
|
||||
// how to declare class constants
|
||||
// How to declare class constants
|
||||
// Use enum for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255
|
||||
#if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER) || defined(__BORLANDC__)
|
||||
# define CRYPTOPP_CONSTANT(x) enum {x};
|
||||
#else
|
||||
|
|
@ -901,6 +902,12 @@ NAMESPACE_END
|
|||
# define CRYPTOPP_ALIGN_DATA(x) alignas(x)
|
||||
#endif // CRYPTOPP_CXX11_ALIGNAS
|
||||
|
||||
// Hack... CRYPTOPP_CONSTANT is defined earlier, before C++11 constexpr availability is determined
|
||||
#if defined(CRYPTOPP_CXX11_CONSTEXPR)
|
||||
# undef CRYPTOPP_CONSTANT
|
||||
# define CRYPTOPP_CONSTANT(x) constexpr static int x;
|
||||
#endif
|
||||
|
||||
// OK to comment the following out, but please report it so we can fix it.
|
||||
// C++17 value taken from http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4567.pdf.
|
||||
#if (defined(__cplusplus) && (__cplusplus >= 199711L) && (__cplusplus < 201402L)) && !defined(CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE)
|
||||
|
|
|
|||
|
|
@ -544,7 +544,8 @@ NAMESPACE_END
|
|||
# define CRYPTOPP_NOINLINE
|
||||
#endif
|
||||
|
||||
// how to declare class constants
|
||||
// How to declare class constants
|
||||
// Use enum for OS X 10.5 ld, http://github.com/weidai11/cryptopp/issues/255
|
||||
#if (defined(_MSC_VER) && _MSC_VER <= 1300) || defined(__INTEL_COMPILER) || defined(__BORLANDC__)
|
||||
# define CRYPTOPP_CONSTANT(x) enum {x};
|
||||
#else
|
||||
|
|
@ -901,6 +902,12 @@ NAMESPACE_END
|
|||
# define CRYPTOPP_ALIGN_DATA(x) alignas(x)
|
||||
#endif // CRYPTOPP_CXX11_ALIGNAS
|
||||
|
||||
// Hack... CRYPTOPP_CONSTANT is defined earlier, before C++11 constexpr availability is determined
|
||||
#if defined(CRYPTOPP_CXX11_CONSTEXPR)
|
||||
# undef CRYPTOPP_CONSTANT
|
||||
# define CRYPTOPP_CONSTANT(x) constexpr static int x;
|
||||
#endif
|
||||
|
||||
// OK to comment the following out, but please report it so we can fix it.
|
||||
// C++17 value taken from http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4567.pdf.
|
||||
#if (defined(__cplusplus) && (__cplusplus >= 199711L) && (__cplusplus < 201402L)) && !defined(CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE)
|
||||
|
|
|
|||
4
crc.h
4
crc.h
|
|
@ -31,7 +31,7 @@ public:
|
|||
void Update(const byte *input, size_t length);
|
||||
void TruncatedFinal(byte *hash, size_t size);
|
||||
unsigned int DigestSize() const {return DIGESTSIZE;}
|
||||
static const char * StaticAlgorithmName() {return "CRC32";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "CRC32";}
|
||||
std::string AlgorithmName() const {return StaticAlgorithmName();}
|
||||
|
||||
void UpdateByte(byte b) {m_crc = m_tab[CRC32_INDEX(m_crc) ^ b] ^ CRC32_SHIFTED(m_crc);}
|
||||
|
|
@ -55,7 +55,7 @@ public:
|
|||
void Update(const byte *input, size_t length);
|
||||
void TruncatedFinal(byte *hash, size_t size);
|
||||
unsigned int DigestSize() const {return DIGESTSIZE;}
|
||||
static const char * StaticAlgorithmName() {return "CRC32C";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "CRC32C";}
|
||||
std::string AlgorithmName() const {return StaticAlgorithmName();}
|
||||
|
||||
void UpdateByte(byte b) {m_crc = m_tab[CRC32_INDEX(m_crc) ^ b] ^ CRC32_SHIFTED(m_crc);}
|
||||
|
|
|
|||
14
des.h
14
des.h
|
|
@ -30,17 +30,19 @@ protected:
|
|||
struct DES_Info : public FixedBlockSize<8>, public FixedKeyLength<8>
|
||||
{
|
||||
// disable DES in DLL version by not exporting this function
|
||||
static const char * StaticAlgorithmName() {return "DES";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "DES";}
|
||||
};
|
||||
|
||||
//! \class DES
|
||||
//! \brief DES block cipher
|
||||
//! \details The DES implementation in Crypto++ ignores the parity bits
|
||||
//! \details The DES implementation in Crypto++ ignores the parity bits
|
||||
//! (the least significant bits of each byte) in the key. However you can use CheckKeyParityBits()
|
||||
//! and CorrectKeyParityBits() to check or correct the parity bits if you wish.
|
||||
//! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#DES">DES</a>
|
||||
class DES : public DES_Info, public BlockCipherDocumentation
|
||||
{
|
||||
//! \class Base
|
||||
//! \brief DES block cipher default operation
|
||||
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_Info>, public RawDES
|
||||
{
|
||||
public:
|
||||
|
|
@ -70,6 +72,8 @@ struct DES_EDE2_Info : public FixedBlockSize<8>, public FixedKeyLength<16>
|
|||
/// \sa <a href="http://www.weidai.com/scan-mirror/cs.html#DESede">DES-EDE2</a>
|
||||
class DES_EDE2 : public DES_EDE2_Info, public BlockCipherDocumentation
|
||||
{
|
||||
//! \class Base
|
||||
//! \brief DES_EDE2 block cipher default operation
|
||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_EDE2_Info>
|
||||
{
|
||||
public:
|
||||
|
|
@ -97,6 +101,8 @@ struct DES_EDE3_Info : public FixedBlockSize<8>, public FixedKeyLength<24>
|
|||
//! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#DESede">DES-EDE3</a>
|
||||
class DES_EDE3 : public DES_EDE3_Info, public BlockCipherDocumentation
|
||||
{
|
||||
//! \class Base
|
||||
//! \brief DES_EDE3 block cipher default operation
|
||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_EDE3_Info>
|
||||
{
|
||||
public:
|
||||
|
|
@ -116,7 +122,7 @@ public:
|
|||
//! \brief DESX block cipher information
|
||||
struct DES_XEX3_Info : public FixedBlockSize<8>, public FixedKeyLength<24>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "DES-XEX3";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "DES-XEX3";}
|
||||
};
|
||||
|
||||
//! \class DES_XEX3
|
||||
|
|
@ -124,6 +130,8 @@ struct DES_XEX3_Info : public FixedBlockSize<8>, public FixedKeyLength<24>
|
|||
//! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#DESX">DES-XEX3</a>, AKA DESX
|
||||
class DES_XEX3 : public DES_XEX3_Info, public BlockCipherDocumentation
|
||||
{
|
||||
//! \class Base
|
||||
//! \brief DES_XEX3 block cipher default operation
|
||||
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_XEX3_Info>
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ template <class EC>
|
|||
class DL_Algorithm_ECDSA : public DL_Algorithm_GDSA<typename EC::Point>
|
||||
{
|
||||
public:
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECDSA";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECDSA";}
|
||||
|
||||
#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
|
||||
virtual ~DL_Algorithm_ECDSA() {}
|
||||
|
|
@ -257,7 +257,7 @@ template <class EC>
|
|||
class DL_Algorithm_ECNR : public DL_Algorithm_NR<typename EC::Point>
|
||||
{
|
||||
public:
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECNR";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECNR";}
|
||||
|
||||
#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
|
||||
virtual ~DL_Algorithm_ECNR() {}
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ struct ElGamal
|
|||
{
|
||||
typedef DL_CryptoSchemeOptions<ElGamal, ElGamalKeys, int, int, int> SchemeOptions;
|
||||
|
||||
static const char * StaticAlgorithmName() {return "ElgamalEnc/Crypto++Padding";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "ElgamalEnc/Crypto++Padding";}
|
||||
|
||||
typedef SchemeOptions::GroupParameters GroupParameters;
|
||||
//! implements PK_Encryptor interface
|
||||
|
|
|
|||
2
emsa2.h
2
emsa2.h
|
|
@ -61,7 +61,7 @@ CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA512>;
|
|||
class CRYPTOPP_DLL EMSA2Pad : public EMSA2HashIdLookup<PK_DeterministicSignatureMessageEncodingMethod>
|
||||
{
|
||||
public:
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "EMSA2";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "EMSA2";}
|
||||
|
||||
size_t MinRepresentativeBitLength(size_t hashIdentifierLength, size_t digestLength) const
|
||||
{CRYPTOPP_UNUSED(hashIdentifierLength); return 8*digestLength + 31;}
|
||||
|
|
|
|||
2
esign.h
2
esign.h
|
|
@ -90,7 +90,7 @@ template <class T>
|
|||
class EMSA5Pad : public PK_DeterministicSignatureMessageEncodingMethod
|
||||
{
|
||||
public:
|
||||
static const char *StaticAlgorithmName() {return "EMSA5";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "EMSA5";}
|
||||
|
||||
void ComputeMessageRepresentative(RandomNumberGenerator &rng,
|
||||
const byte *recoverableMessage, size_t recoverableMessageLength,
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ template <class T>
|
|||
class DL_Algorithm_GDSA : public DL_ElgamalLikeSignatureAlgorithm<T>
|
||||
{
|
||||
public:
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "DSA-1363";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "DSA-1363";}
|
||||
|
||||
void Sign(const DL_GroupParameters<T> ¶ms, const Integer &x, const Integer &k, const Integer &e, Integer &r, Integer &s) const
|
||||
{
|
||||
|
|
@ -221,7 +221,7 @@ template <class T>
|
|||
class DL_Algorithm_NR : public DL_ElgamalLikeSignatureAlgorithm<T>
|
||||
{
|
||||
public:
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "NR";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "NR";}
|
||||
|
||||
void Sign(const DL_GroupParameters<T> ¶ms, const Integer &x, const Integer &k, const Integer &e, Integer &r, Integer &s) const
|
||||
{
|
||||
|
|
|
|||
8
gost.h
8
gost.h
|
|
@ -15,7 +15,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
//! \brief GOST block cipher information
|
||||
struct GOST_Info : public FixedBlockSize<8>, public FixedKeyLength<32>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "GOST";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "GOST";}
|
||||
};
|
||||
|
||||
//! \class GOST
|
||||
|
|
@ -23,6 +23,8 @@ struct GOST_Info : public FixedBlockSize<8>, public FixedKeyLength<32>
|
|||
//! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#GOST">GOST</a>
|
||||
class GOST : public GOST_Info, public BlockCipherDocumentation
|
||||
{
|
||||
//! \class Base
|
||||
//! \brief GOST block cipher default operation
|
||||
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<GOST_Info>
|
||||
{
|
||||
public:
|
||||
|
|
@ -38,12 +40,16 @@ class GOST : public GOST_Info, public BlockCipherDocumentation
|
|||
FixedSizeSecBlock<word32, 8> key;
|
||||
};
|
||||
|
||||
//! \class Enc
|
||||
//! \brief GOST block cipher encryption operation
|
||||
class CRYPTOPP_NO_VTABLE Enc : public Base
|
||||
{
|
||||
public:
|
||||
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
|
||||
};
|
||||
|
||||
//! \class Dec
|
||||
//! \brief GOST block cipher decryption operation
|
||||
class CRYPTOPP_NO_VTABLE Dec : public Base
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
2
idea.h
2
idea.h
|
|
@ -15,7 +15,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
//! \brief IDEA block cipher information
|
||||
struct IDEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public FixedRounds<8>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "IDEA";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "IDEA";}
|
||||
};
|
||||
|
||||
//! \class IDEA
|
||||
|
|
|
|||
2
luc.h
2
luc.h
|
|
@ -232,7 +232,7 @@ protected:
|
|||
class DL_Algorithm_LUC_HMP : public DL_ElgamalLikeSignatureAlgorithm<Integer>
|
||||
{
|
||||
public:
|
||||
static const char * StaticAlgorithmName() {return "LUC-HMP";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "LUC-HMP";}
|
||||
|
||||
void Sign(const DL_GroupParameters<Integer> ¶ms, const Integer &x, const Integer &k, const Integer &e, Integer &r, Integer &s) const;
|
||||
bool Verify(const DL_GroupParameters<Integer> ¶ms, const DL_PublicKey<Integer> &publicKey, const Integer &e, const Integer &r, const Integer &s) const;
|
||||
|
|
|
|||
4
mars.h
4
mars.h
|
|
@ -13,9 +13,9 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
|
||||
//! \class MARS_Info
|
||||
//! \brief MARS block cipher information
|
||||
struct MARS_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 56, 4>
|
||||
struct MARS_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "MARS";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "MARS";}
|
||||
};
|
||||
|
||||
//! \class MARS
|
||||
|
|
|
|||
2
md2.h
2
md2.h
|
|
@ -17,7 +17,7 @@ public:
|
|||
void TruncatedFinal(byte *hash, size_t size);
|
||||
unsigned int DigestSize() const {return DIGESTSIZE;}
|
||||
unsigned int BlockSize() const {return BLOCKSIZE;}
|
||||
static const char * StaticAlgorithmName() {return "MD2";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "MD2";}
|
||||
|
||||
CRYPTOPP_CONSTANT(DIGESTSIZE = 16)
|
||||
CRYPTOPP_CONSTANT(BLOCKSIZE = 16)
|
||||
|
|
|
|||
2
md4.h
2
md4.h
|
|
@ -15,7 +15,7 @@ class MD4 : public IteratedHashWithStaticTransform<word32, LittleEndian, 64, 16,
|
|||
public:
|
||||
static void InitState(HashWordType *state);
|
||||
static void Transform(word32 *digest, const word32 *data);
|
||||
static const char *StaticAlgorithmName() {return "MD4";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "MD4";}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
2
md5.h
2
md5.h
|
|
@ -13,7 +13,7 @@ class MD5 : public IteratedHashWithStaticTransform<word32, LittleEndian, 64, 16,
|
|||
public:
|
||||
static void InitState(HashWordType *state);
|
||||
static void Transform(word32 *digest, const word32 *data);
|
||||
static const char * StaticAlgorithmName() {return "MD5";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "MD5";}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
18
mdc.h
18
mdc.h
|
|
@ -1,10 +1,10 @@
|
|||
// mdc.h - written and placed in the public domain by Wei Dai
|
||||
// mdc.h - written and placed in the public domain by Wei Dai
|
||||
|
||||
#ifndef CRYPTOPP_MDC_H
|
||||
#define CRYPTOPP_MDC_H
|
||||
|
||||
/** \file
|
||||
*/
|
||||
//! \file mdc.h
|
||||
//! \brief Classes for the MDC message digest
|
||||
|
||||
#include "seckey.h"
|
||||
#include "secblock.h"
|
||||
|
|
@ -12,18 +12,24 @@
|
|||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
//! _
|
||||
//! \class MDC_Info
|
||||
//! \brief MDC_Info cipher information
|
||||
template <class T>
|
||||
struct MDC_Info : public FixedBlockSize<T::DIGESTSIZE>, public FixedKeyLength<T::BLOCKSIZE>
|
||||
{
|
||||
static std::string StaticAlgorithmName() {return std::string("MDC/")+T::StaticAlgorithmName();}
|
||||
};
|
||||
|
||||
//! <a href="http://www.weidai.com/scan-mirror/cs.html#MDC">MDC</a>
|
||||
/*! a construction by Peter Gutmann to turn an iterated hash function into a PRF */
|
||||
|
||||
//! \class MDC
|
||||
//! \brief MDC cipher
|
||||
//! \details MDC() is a construction by Peter Gutmann to turn an iterated hash function into a PRF
|
||||
//! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#MDC">MDC</a>
|
||||
template <class T>
|
||||
class MDC : public MDC_Info<T>
|
||||
{
|
||||
//! \class Enc
|
||||
//! \brief MDC cipher encryption operation
|
||||
class CRYPTOPP_NO_VTABLE Enc : public BlockCipherImpl<MDC_Info<T> >
|
||||
{
|
||||
typedef typename T::HashWordType HashWordType;
|
||||
|
|
|
|||
18
misc.h
18
misc.h
|
|
@ -1293,6 +1293,7 @@ CRYPTOPP_DLL void CRYPTOPP_API UnalignedDeallocate(void *ptr);
|
|||
// ************** rotate functions ***************
|
||||
|
||||
//! \brief Performs a left rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a portable C/C++ implementation. The value x to be rotated can be 8 to 64-bits.
|
||||
|
|
@ -1314,6 +1315,7 @@ template <class T> inline T rotlFixed(T x, unsigned int y)
|
|||
}
|
||||
|
||||
//! \brief Performs a right rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a portable C/C++ implementation. The value x to be rotated can be 8 to 64-bits.
|
||||
|
|
@ -1335,6 +1337,7 @@ template <class T> inline T rotrFixed(T x, unsigned int y)
|
|||
}
|
||||
|
||||
//! \brief Performs a left rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a portable C/C++ implementation. The value x to be rotated can be 8 to 64-bits.
|
||||
|
|
@ -1352,6 +1355,7 @@ template <class T> inline T rotlVariable(T x, unsigned int y)
|
|||
}
|
||||
|
||||
//! \brief Performs a right rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a portable C/C++ implementation. The value x to be rotated can be 8 to 64-bits.
|
||||
|
|
@ -1369,6 +1373,7 @@ template <class T> inline T rotrVariable(T x, unsigned int y)
|
|||
}
|
||||
|
||||
//! \brief Performs a left rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a portable C/C++ implementation. The value x to be rotated can be 8 to 64-bits.
|
||||
|
|
@ -1382,6 +1387,7 @@ template <class T> inline T rotlMod(T x, unsigned int y)
|
|||
}
|
||||
|
||||
//! \brief Performs a right rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a portable C/C++ implementation. The value x to be rotated can be 8 to 64-bits.
|
||||
|
|
@ -1397,6 +1403,7 @@ template <class T> inline T rotrMod(T x, unsigned int y)
|
|||
#ifdef _MSC_VER
|
||||
|
||||
//! \brief Performs a left rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the 32-bit value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a Microsoft specific implementation using <tt>_lrotl</tt> provided by
|
||||
|
|
@ -1411,6 +1418,7 @@ template<> inline word32 rotlFixed<word32>(word32 x, unsigned int y)
|
|||
}
|
||||
|
||||
//! \brief Performs a right rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the 32-bit value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a Microsoft specific implementation using <tt>_lrotr</tt> provided by
|
||||
|
|
@ -1425,6 +1433,7 @@ template<> inline word32 rotrFixed<word32>(word32 x, unsigned int y)
|
|||
}
|
||||
|
||||
//! \brief Performs a left rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the 32-bit value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a Microsoft specific implementation using <tt>_lrotl</tt> provided by
|
||||
|
|
@ -1438,6 +1447,7 @@ template<> inline word32 rotlVariable<word32>(word32 x, unsigned int y)
|
|||
}
|
||||
|
||||
//! \brief Performs a right rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the 32-bit value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a Microsoft specific implementation using <tt>_lrotr</tt> provided by
|
||||
|
|
@ -1451,6 +1461,7 @@ template<> inline word32 rotrVariable<word32>(word32 x, unsigned int y)
|
|||
}
|
||||
|
||||
//! \brief Performs a left rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the 32-bit value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a Microsoft specific implementation using <tt>_lrotl</tt> provided by
|
||||
|
|
@ -1463,6 +1474,7 @@ template<> inline word32 rotlMod<word32>(word32 x, unsigned int y)
|
|||
}
|
||||
|
||||
//! \brief Performs a right rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the 32-bit value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a Microsoft specific implementation using <tt>_lrotr</tt> provided by
|
||||
|
|
@ -1480,6 +1492,7 @@ template<> inline word32 rotrMod<word32>(word32 x, unsigned int y)
|
|||
// Intel C++ Compiler 10.0 calls a function instead of using the rotate instruction when using these instructions
|
||||
|
||||
//! \brief Performs a left rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the 64-bit value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a Microsoft specific implementation using <tt>_lrotl</tt> provided by
|
||||
|
|
@ -1494,6 +1507,7 @@ template<> inline word64 rotlFixed<word64>(word64 x, unsigned int y)
|
|||
}
|
||||
|
||||
//! \brief Performs a right rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the 64-bit value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a Microsoft specific implementation using <tt>_lrotr</tt> provided by
|
||||
|
|
@ -1508,6 +1522,7 @@ template<> inline word64 rotrFixed<word64>(word64 x, unsigned int y)
|
|||
}
|
||||
|
||||
//! \brief Performs a left rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the 64-bit value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a Microsoft specific implementation using <tt>_lrotl</tt> provided by
|
||||
|
|
@ -1521,6 +1536,7 @@ template<> inline word64 rotlVariable<word64>(word64 x, unsigned int y)
|
|||
}
|
||||
|
||||
//! \brief Performs a right rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the 64-bit value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a Microsoft specific implementation using <tt>_lrotr</tt> provided by
|
||||
|
|
@ -1534,6 +1550,7 @@ template<> inline word64 rotrVariable<word64>(word64 x, unsigned int y)
|
|||
}
|
||||
|
||||
//! \brief Performs a left rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the 64-bit value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a Microsoft specific implementation using <tt>_lrotl</tt> provided by
|
||||
|
|
@ -1546,6 +1563,7 @@ template<> inline word64 rotlMod<word64>(word64 x, unsigned int y)
|
|||
}
|
||||
|
||||
//! \brief Performs a right rotate
|
||||
//! \tparam T the word type
|
||||
//! \param x the 64-bit value to rotate
|
||||
//! \param y the number of bit positions to rotate the value
|
||||
//! \details This is a Microsoft specific implementation using <tt>_lrotr</tt> provided by
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
#include "modes.h"
|
||||
#include "misc.h"
|
||||
|
||||
#ifndef NDEBUG
|
||||
//#ifndef NDEBUG
|
||||
#include "des.h"
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
|
|
|
|||
46
modes.h
46
modes.h
|
|
@ -16,7 +16,7 @@
|
|||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
//! \class CipherModeDocumentation
|
||||
//! \brief Classes for operating block cipher modes of operation
|
||||
//! \brief Block cipher mode of operation information
|
||||
//! \details Each class derived from this one defines two types, Encryption and Decryption,
|
||||
//! both of which implement the SymmetricCipher interface.
|
||||
//! For each mode there are two classes, one of which is a template class,
|
||||
|
|
@ -31,6 +31,8 @@ struct CipherModeDocumentation : public SymmetricCipherDocumentation
|
|||
{
|
||||
};
|
||||
|
||||
//! \class CipherModeBase
|
||||
//! \brief Block cipher mode of operation information
|
||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CipherModeBase : public SymmetricCipher
|
||||
{
|
||||
public:
|
||||
|
|
@ -85,6 +87,9 @@ protected:
|
|||
AlignedSecByteBlock m_register;
|
||||
};
|
||||
|
||||
//! \class ModePolicyCommonTemplate
|
||||
//! \brief Block cipher mode of operation common operations
|
||||
//! \tparam POLICY_INTERFACE common operations
|
||||
template <class POLICY_INTERFACE>
|
||||
class CRYPTOPP_NO_VTABLE ModePolicyCommonTemplate : public CipherModeBase, public POLICY_INTERFACE
|
||||
{
|
||||
|
|
@ -101,11 +106,13 @@ void ModePolicyCommonTemplate<POLICY_INTERFACE>::CipherSetKey(const NameValuePai
|
|||
SetFeedbackSize(feedbackSize);
|
||||
}
|
||||
|
||||
//! \class CFB_ModePolicy
|
||||
//! \brief CFB block cipher mode of operation
|
||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CFB_ModePolicy : public ModePolicyCommonTemplate<CFB_CipherAbstractPolicy>
|
||||
{
|
||||
public:
|
||||
IV_Requirement IVRequirement() const {return RANDOM_IV;}
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "CFB";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "CFB";}
|
||||
|
||||
protected:
|
||||
unsigned int GetBytesPerIteration() const {return m_feedbackSize;}
|
||||
|
|
@ -129,12 +136,14 @@ inline void CopyOrZero(void *dest, const void *src, size_t s)
|
|||
memset(dest, 0, s);
|
||||
}
|
||||
|
||||
//! \class OFB_ModePolicy
|
||||
//! \brief OFB block cipher mode of operation
|
||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE OFB_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy>
|
||||
{
|
||||
public:
|
||||
bool CipherIsRandomAccess() const {return false;}
|
||||
IV_Requirement IVRequirement() const {return UNIQUE_IV;}
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "OFB";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "OFB";}
|
||||
|
||||
private:
|
||||
unsigned int GetBytesPerIteration() const {return BlockSize();}
|
||||
|
|
@ -143,12 +152,14 @@ private:
|
|||
void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length);
|
||||
};
|
||||
|
||||
//! \class CTR_ModePolicy
|
||||
//! \brief CTR block cipher mode of operation
|
||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CTR_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy>
|
||||
{
|
||||
public:
|
||||
bool CipherIsRandomAccess() const {return true;}
|
||||
IV_Requirement IVRequirement() const {return RANDOM_IV;}
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "CTR";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "CTR";}
|
||||
|
||||
protected:
|
||||
virtual void IncrementCounterBy256();
|
||||
|
|
@ -166,6 +177,8 @@ protected:
|
|||
AlignedSecByteBlock m_counterArray;
|
||||
};
|
||||
|
||||
//! \class BlockOrientedCipherModeBase
|
||||
//! \brief Block cipher mode of operation default implementation
|
||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE BlockOrientedCipherModeBase : public CipherModeBase
|
||||
{
|
||||
public:
|
||||
|
|
@ -193,6 +206,8 @@ protected:
|
|||
SecByteBlock m_buffer;
|
||||
};
|
||||
|
||||
//! \class ECB_OneWay
|
||||
//! \brief ECB block cipher mode of operation default implementation
|
||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE ECB_OneWay : public BlockOrientedCipherModeBase
|
||||
{
|
||||
public:
|
||||
|
|
@ -201,31 +216,37 @@ public:
|
|||
IV_Requirement IVRequirement() const {return NOT_RESYNCHRONIZABLE;}
|
||||
unsigned int OptimalBlockSize() const {return BlockSize() * m_cipher->OptimalNumberOfParallelBlocks();}
|
||||
void ProcessData(byte *outString, const byte *inString, size_t length);
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECB";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECB";}
|
||||
};
|
||||
|
||||
//! \class CBC_ModeBase
|
||||
//! \brief CBC block cipher mode of operation default implementation
|
||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_ModeBase : public BlockOrientedCipherModeBase
|
||||
{
|
||||
public:
|
||||
IV_Requirement IVRequirement() const {return UNPREDICTABLE_RANDOM_IV;}
|
||||
bool RequireAlignedInput() const {return false;}
|
||||
unsigned int MinLastBlockSize() const {return 0;}
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "CBC";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "CBC";}
|
||||
};
|
||||
|
||||
//! \class CBC_Encryption
|
||||
//! \brief CBC block cipher mode of operation encryption operation
|
||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_Encryption : public CBC_ModeBase
|
||||
{
|
||||
public:
|
||||
void ProcessData(byte *outString, const byte *inString, size_t length);
|
||||
};
|
||||
|
||||
//! \class CBC_CTS_Encryption
|
||||
//! \brief CBC-CTS block cipher mode of operation encryption operation
|
||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_CTS_Encryption : public CBC_Encryption
|
||||
{
|
||||
public:
|
||||
void SetStolenIV(byte *iv) {m_stolenIV = iv;}
|
||||
unsigned int MinLastBlockSize() const {return BlockSize()+1;}
|
||||
void ProcessLastBlock(byte *outString, const byte *inString, size_t length);
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "CBC/CTS";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "CBC/CTS";}
|
||||
|
||||
protected:
|
||||
void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms)
|
||||
|
|
@ -237,6 +258,8 @@ protected:
|
|||
byte *m_stolenIV;
|
||||
};
|
||||
|
||||
//! \class CBC_Decryption
|
||||
//! \brief CBC block cipher mode of operation decryption operation
|
||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_Decryption : public CBC_ModeBase
|
||||
{
|
||||
public:
|
||||
|
|
@ -258,6 +281,8 @@ protected:
|
|||
AlignedSecByteBlock m_temp;
|
||||
};
|
||||
|
||||
//! \class CBC_CTS_Decryption
|
||||
//! \brief CBC-CTS block cipher mode of operation decryption operation
|
||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_CTS_Decryption : public CBC_Decryption
|
||||
{
|
||||
public:
|
||||
|
|
@ -265,7 +290,8 @@ public:
|
|||
void ProcessLastBlock(byte *outString, const byte *inString, size_t length);
|
||||
};
|
||||
|
||||
//! _
|
||||
//! \class CipherModeFinalTemplate_CipherHolder
|
||||
//! \brief Block cipher mode of operation aggregate
|
||||
template <class CIPHER, class BASE>
|
||||
class CipherModeFinalTemplate_CipherHolder : protected ObjectHolder<CIPHER>, public AlgorithmImpl<BASE, CipherModeFinalTemplate_CipherHolder<CIPHER, BASE> >
|
||||
{
|
||||
|
|
@ -296,8 +322,8 @@ public:
|
|||
};
|
||||
|
||||
//! \class CipherModeFinalTemplate_ExternalCipher
|
||||
//! \tparam BASE CipherModeFinalTemplate_CipherHolder class
|
||||
//! \brief OFB block cipher mode of operation.
|
||||
//! \tparam BASE CipherModeFinalTemplate_CipherHolder base class
|
||||
//! \details
|
||||
template <class BASE>
|
||||
class CipherModeFinalTemplate_ExternalCipher : public BASE
|
||||
{
|
||||
|
|
|
|||
28
panama.h
28
panama.h
|
|
@ -1,7 +1,7 @@
|
|||
// panama.h - written and placed in the public domain by Wei Dai
|
||||
|
||||
//! \file panama.h
|
||||
//! \brief Classes for Panama stream cipher
|
||||
//! \brief Classes for Panama hash and stream cipher
|
||||
|
||||
#ifndef CRYPTOPP_PANAMA_H
|
||||
#define CRYPTOPP_PANAMA_H
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
/// base class, do not use directly
|
||||
// Base class, do not use directly
|
||||
template <class B>
|
||||
class CRYPTOPP_NO_VTABLE Panama
|
||||
{
|
||||
|
|
@ -33,7 +33,9 @@ protected:
|
|||
};
|
||||
|
||||
namespace Weak {
|
||||
/// <a href="http://www.weidai.com/scan-mirror/md.html#Panama">Panama Hash</a>
|
||||
//! \class PanamaHash
|
||||
//! \brief Panama hash
|
||||
//! \sa <a href="http://www.weidai.com/scan-mirror/md.html#Panama">Panama Hash</a>
|
||||
template <class B = LittleEndian>
|
||||
class PanamaHash : protected Panama<B>, public AlgorithmImpl<IteratedHash<word32, NativeByteOrder, 32>, PanamaHash<B> >
|
||||
{
|
||||
|
|
@ -42,7 +44,7 @@ public:
|
|||
PanamaHash() {Panama<B>::Reset();}
|
||||
unsigned int DigestSize() const {return DIGESTSIZE;}
|
||||
void TruncatedFinal(byte *hash, size_t size);
|
||||
static const char * StaticAlgorithmName() {return B::ToEnum() == BIG_ENDIAN_ORDER ? "Panama-BE" : "Panama-LE";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return B::ToEnum() == BIG_ENDIAN_ORDER ? "Panama-BE" : "Panama-LE";}
|
||||
|
||||
protected:
|
||||
void Init() {Panama<B>::Reset();}
|
||||
|
|
@ -52,7 +54,8 @@ protected:
|
|||
};
|
||||
}
|
||||
|
||||
//! MAC construction using a hermetic hash function
|
||||
//! \class HermeticHashFunctionMAC
|
||||
//! \brief MAC construction using a hermetic hash function
|
||||
template <class T_Hash, class T_Info = T_Hash>
|
||||
class HermeticHashFunctionMAC : public AlgorithmImpl<SimpleKeyingInterfaceImpl<TwoBases<MessageAuthenticationCode, VariableKeyLength<32, 0, INT_MAX> > >, T_Info>
|
||||
{
|
||||
|
|
@ -108,7 +111,8 @@ protected:
|
|||
};
|
||||
|
||||
namespace Weak {
|
||||
/// Panama MAC
|
||||
//! \class PanamaMAC
|
||||
//! \brief Panama message authentication code
|
||||
template <class B = LittleEndian>
|
||||
class PanamaMAC : public HermeticHashFunctionMAC<PanamaHash<B> >
|
||||
{
|
||||
|
|
@ -119,14 +123,16 @@ public:
|
|||
};
|
||||
}
|
||||
|
||||
//! algorithm info
|
||||
//! \class PanamaCipherInfo
|
||||
//! \brief Panama stream cipher information
|
||||
template <class B>
|
||||
struct PanamaCipherInfo : public FixedKeyLength<32, SimpleKeyingInterface::UNIQUE_IV, 32>
|
||||
{
|
||||
static const char * StaticAlgorithmName() {return B::ToEnum() == BIG_ENDIAN_ORDER ? "Panama-BE" : "Panama-LE";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return B::ToEnum() == BIG_ENDIAN_ORDER ? "Panama-BE" : "Panama-LE";}
|
||||
};
|
||||
|
||||
//! _
|
||||
//! \class PanamaCipherPolicy
|
||||
//! \brief Panama stream cipher operation
|
||||
template <class B>
|
||||
class PanamaCipherPolicy : public AdditiveCipherConcretePolicy<word32, 8>,
|
||||
public PanamaCipherInfo<B>,
|
||||
|
|
@ -142,7 +148,9 @@ protected:
|
|||
FixedSizeSecBlock<word32, 8> m_key;
|
||||
};
|
||||
|
||||
//! <a href="http://www.cryptolounge.org/wiki/PANAMA">Panama Stream Cipher</a>
|
||||
//! \class PanamaCipher
|
||||
//! \brief Panama stream cipher
|
||||
//! \sa <a href="http://www.cryptolounge.org/wiki/PANAMA">Panama Stream Cipher</a>
|
||||
template <class B = LittleEndian>
|
||||
struct PanamaCipher : public PanamaCipherInfo<B>, public SymmetricCipherDocumentation
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
class PKCS_EncryptionPaddingScheme : public PK_EncryptionMessageEncodingMethod
|
||||
{
|
||||
public:
|
||||
static const char * StaticAlgorithmName() {return "EME-PKCS1-v1_5";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "EME-PKCS1-v1_5";}
|
||||
|
||||
size_t MaxUnpaddedLength(size_t paddedLength) const;
|
||||
void Pad(RandomNumberGenerator &rng, const byte *raw, size_t inputLength, byte *padded, size_t paddedLength, const NameValuePairs ¶meters) const;
|
||||
|
|
@ -60,7 +60,7 @@ CRYPTOPP_DLL_TEMPLATE_CLASS PKCS_DigestDecoration<SHA512>;
|
|||
class CRYPTOPP_DLL PKCS1v15_SignatureMessageEncodingMethod : public PK_DeterministicSignatureMessageEncodingMethod
|
||||
{
|
||||
public:
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "EMSA-PKCS1-v1_5";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "EMSA-PKCS1-v1_5";}
|
||||
|
||||
size_t MinRepresentativeBitLength(size_t hashIdentifierSize, size_t digestSize) const
|
||||
{return 8 * (digestSize + hashIdentifierSize + 10);}
|
||||
|
|
|
|||
4
pubkey.h
4
pubkey.h
|
|
@ -712,7 +712,7 @@ CRYPTOPP_DLL void CRYPTOPP_API P1363_MGF1KDF2_Common(HashTransformation &hash, b
|
|||
class P1363_MGF1 : public MaskGeneratingFunction
|
||||
{
|
||||
public:
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "MGF1";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "MGF1";}
|
||||
void GenerateAndMask(HashTransformation &hash, byte *output, size_t outputLength, const byte *input, size_t inputLength, bool mask = true) const
|
||||
{
|
||||
P1363_MGF1KDF2_Common(hash, output, outputLength, input, inputLength, NULL, 0, mask, 0);
|
||||
|
|
@ -1978,7 +1978,7 @@ public:
|
|||
virtual ~DL_KeyAgreementAlgorithm_DH() {}
|
||||
#endif
|
||||
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName()
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName()
|
||||
{return COFACTOR_OPTION::ToEnum() == INCOMPATIBLE_COFACTOR_MULTIPLICTION ? "DHC" : "DH";}
|
||||
|
||||
Element AgreeWithEphemeralPrivateKey(const DL_GroupParameters<Element> ¶ms, const DL_FixedBasePrecomputation<Element> &publicPrecomputation, const Integer &privateExponent) const
|
||||
|
|
|
|||
2
rc2.h
2
rc2.h
|
|
@ -18,7 +18,7 @@ struct RC2_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 128>
|
|||
{
|
||||
CRYPTOPP_CONSTANT(DEFAULT_EFFECTIVE_KEYLENGTH = 1024)
|
||||
CRYPTOPP_CONSTANT(MAX_EFFECTIVE_KEYLENGTH = 1024)
|
||||
static const char *StaticAlgorithmName() {return "RC2";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "RC2";}
|
||||
};
|
||||
|
||||
//! \class RC2
|
||||
|
|
|
|||
2
rc5.h
2
rc5.h
|
|
@ -15,7 +15,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
//! \brief RC5 block cipher information
|
||||
struct RC5_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 0, 255>, public VariableRounds<16>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "RC5";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "RC5";}
|
||||
typedef word32 RC5_WORD;
|
||||
};
|
||||
|
||||
|
|
|
|||
4
rc6.h
4
rc6.h
|
|
@ -13,9 +13,9 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
|
||||
//! \class RC6_Info
|
||||
//! \brief RC6 block cipher information
|
||||
struct RC6_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 0, 255>, public VariableRounds<20>
|
||||
struct RC6_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>, public VariableRounds<20>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "RC6";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "RC6";}
|
||||
typedef word32 RC6_WORD;
|
||||
};
|
||||
|
||||
|
|
|
|||
12
rdrand.cpp
12
rdrand.cpp
|
|
@ -175,7 +175,8 @@ static int ALL_RRI_GenerateBlock(byte *output, size_t size, unsigned int safety)
|
|||
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
|
||||
if (_rdrand32_step((word32*)output))
|
||||
#else
|
||||
if (_rdrand64_step((word64*)output))
|
||||
// Cast due to GCC, http://github.com/weidai11/cryptopp/issues/236
|
||||
if (_rdrand64_step(reinterpret_cast<unsigned long long*>(output)))
|
||||
#endif
|
||||
{
|
||||
output += sizeof(val);
|
||||
|
|
@ -196,7 +197,8 @@ static int ALL_RRI_GenerateBlock(byte *output, size_t size, unsigned int safety)
|
|||
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
|
||||
if (_rdrand32_step(&val))
|
||||
#else
|
||||
if (_rdrand64_step(&val))
|
||||
// Cast due to GCC, http://github.com/weidai11/cryptopp/issues/236
|
||||
if (_rdrand64_step(reinterpret_cast<unsigned long long*>(&val)))
|
||||
#endif
|
||||
{
|
||||
memcpy(output, &val, size);
|
||||
|
|
@ -348,7 +350,8 @@ static int ALL_RSI_GenerateBlock(byte *output, size_t size, unsigned int safety)
|
|||
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
|
||||
if (_rdseed32_step((word32*)output))
|
||||
#else
|
||||
if (_rdseed64_step((word64*)output))
|
||||
// Cast due to GCC, http://github.com/weidai11/cryptopp/issues/236
|
||||
if (_rdseed64_step(reinterpret_cast<unsigned long long*>(output)))
|
||||
#endif
|
||||
{
|
||||
output += sizeof(val);
|
||||
|
|
@ -369,7 +372,8 @@ static int ALL_RSI_GenerateBlock(byte *output, size_t size, unsigned int safety)
|
|||
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
|
||||
if (_rdseed32_step(&val))
|
||||
#else
|
||||
if (_rdseed64_step(&val))
|
||||
// Cast due to GCC, http://github.com/weidai11/cryptopp/issues/236
|
||||
if (_rdseed64_step(reinterpret_cast<unsigned long long*>(&val)))
|
||||
#endif
|
||||
{
|
||||
memcpy(output, &val, size);
|
||||
|
|
|
|||
8
ripemd.h
8
ripemd.h
|
|
@ -17,7 +17,7 @@ class RIPEMD160 : public IteratedHashWithStaticTransform<word32, LittleEndian, 6
|
|||
public:
|
||||
static void InitState(HashWordType *state);
|
||||
static void Transform(word32 *digest, const word32 *data);
|
||||
static const char * StaticAlgorithmName() {return "RIPEMD-160";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "RIPEMD-160";}
|
||||
};
|
||||
|
||||
/*! Digest Length = 320 bits, Security is similar to RIPEMD-160 */
|
||||
|
|
@ -26,7 +26,7 @@ class RIPEMD320 : public IteratedHashWithStaticTransform<word32, LittleEndian, 6
|
|||
public:
|
||||
static void InitState(HashWordType *state);
|
||||
static void Transform(word32 *digest, const word32 *data);
|
||||
static const char * StaticAlgorithmName() {return "RIPEMD-320";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "RIPEMD-320";}
|
||||
};
|
||||
|
||||
/*! \warning RIPEMD-128 is considered insecure, and should not be used
|
||||
|
|
@ -36,7 +36,7 @@ class RIPEMD128 : public IteratedHashWithStaticTransform<word32, LittleEndian, 6
|
|||
public:
|
||||
static void InitState(HashWordType *state);
|
||||
static void Transform(word32 *digest, const word32 *data);
|
||||
static const char * StaticAlgorithmName() {return "RIPEMD-128";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "RIPEMD-128";}
|
||||
};
|
||||
|
||||
/*! \warning RIPEMD-256 is considered insecure, and should not be used
|
||||
|
|
@ -46,7 +46,7 @@ class RIPEMD256 : public IteratedHashWithStaticTransform<word32, LittleEndian, 6
|
|||
public:
|
||||
static void InitState(HashWordType *state);
|
||||
static void Transform(word32 *digest, const word32 *data);
|
||||
static const char * StaticAlgorithmName() {return "RIPEMD-256";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "RIPEMD-256";}
|
||||
};
|
||||
|
||||
NAMESPACE_END
|
||||
|
|
|
|||
4
rsa.h
4
rsa.h
|
|
@ -152,7 +152,7 @@ public:
|
|||
//! \brief RSA algorithm
|
||||
struct CRYPTOPP_DLL RSA
|
||||
{
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "RSA";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "RSA";}
|
||||
typedef RSAFunction PublicKey;
|
||||
typedef InvertibleRSAFunction PrivateKey;
|
||||
};
|
||||
|
|
@ -181,7 +181,7 @@ struct RSASS : public TF_SS<STANDARD, H, RSA>
|
|||
//! \brief RSA algorithm
|
||||
struct CRYPTOPP_DLL RSA_ISO
|
||||
{
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "RSA-ISO";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "RSA-ISO";}
|
||||
typedef RSAFunction_ISO PublicKey;
|
||||
typedef InvertibleRSAFunction_ISO PrivateKey;
|
||||
};
|
||||
|
|
|
|||
2
rw.cpp
2
rw.cpp
|
|
@ -207,7 +207,7 @@ Integer InvertibleRWFunction::CalculateInverse(RandomNumberGenerator &rng, const
|
|||
Integer re = modn.Square(r);
|
||||
re = modn.Multiply(re, x); // blind
|
||||
|
||||
const Integer &h = re, &p = m_p, &q = m_q, &n = m_n;
|
||||
const Integer &h = re, &p = m_p, &q = m_q;
|
||||
Integer e, f;
|
||||
|
||||
const Integer U = modq.Exponentiate(h, (q+1)/8);
|
||||
|
|
|
|||
20
safer.h
20
safer.h
|
|
@ -1,7 +1,7 @@
|
|||
// safer.h - written and placed in the public domain by Wei Dai
|
||||
|
||||
//! \file safer.h
|
||||
//! \brief Classes for the SAFER block cipher
|
||||
//! \brief Classes for the SAFER and SAFER-K block ciphers
|
||||
|
||||
#ifndef CRYPTOPP_SAFER_H
|
||||
#define CRYPTOPP_SAFER_H
|
||||
|
|
@ -12,10 +12,12 @@
|
|||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
//! \class SAFER
|
||||
//! \brief SAFER base class
|
||||
//! \brief SAFER block cipher
|
||||
class SAFER
|
||||
{
|
||||
public:
|
||||
//! \class Base
|
||||
//! \brief SAFER block cipher default operation
|
||||
class CRYPTOPP_NO_VTABLE Base : public BlockCipher
|
||||
{
|
||||
public:
|
||||
|
|
@ -30,12 +32,16 @@ public:
|
|||
static const byte log_tab[256];
|
||||
};
|
||||
|
||||
//! \class Enc
|
||||
//! \brief SAFER block cipher encryption operation
|
||||
class CRYPTOPP_NO_VTABLE Enc : public Base
|
||||
{
|
||||
public:
|
||||
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
|
||||
};
|
||||
|
||||
//! \class Dec
|
||||
//! \brief SAFER block cipher decryption operation
|
||||
class CRYPTOPP_NO_VTABLE Dec : public Base
|
||||
{
|
||||
public:
|
||||
|
|
@ -43,6 +49,12 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
//! \class SAFER_Impl
|
||||
//! \brief SAFER block cipher default implementation
|
||||
//! \tparam BASE SAFER::Enc or SAFER::Dec derived base class
|
||||
//! \tparam INFO SAFER_Info derived class
|
||||
//! \tparam STR flag indicating a strengthened implementation
|
||||
//! \details SAFER-K is not strengthened; while SAFER-SK is strengthened.
|
||||
template <class BASE, class INFO, bool STR>
|
||||
class CRYPTOPP_NO_VTABLE SAFER_Impl : public BlockCipherImpl<INFO, BASE>
|
||||
{
|
||||
|
|
@ -54,7 +66,7 @@ protected:
|
|||
//! \brief SAFER-K block cipher information
|
||||
struct SAFER_K_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "SAFER-K";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SAFER-K";}
|
||||
};
|
||||
|
||||
//! \class SAFER_K
|
||||
|
|
@ -71,7 +83,7 @@ public:
|
|||
//! \brief SAFER-SK block cipher information
|
||||
struct SAFER_SK_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "SAFER-SK";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SAFER-SK";}
|
||||
};
|
||||
|
||||
//! \class SAFER_SK
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
|
||||
void Salsa20_TestInstantiations()
|
||||
{
|
||||
Salsa20::Encryption x;
|
||||
Salsa20::Encryption x1;
|
||||
XSalsa20::Encryption x2;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
14
salsa.h
14
salsa.h
|
|
@ -19,12 +19,14 @@
|
|||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
//! \class Salsa20_Info
|
||||
//! \brief Salsa stream cipher information
|
||||
//! \brief Salsa20 stream cipher information
|
||||
struct Salsa20_Info : public VariableKeyLength<32, 16, 32, 16, SimpleKeyingInterface::UNIQUE_IV, 8>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "Salsa20";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Salsa20";}
|
||||
};
|
||||
|
||||
//! \class Salsa20_Policy
|
||||
//! \brief Salsa20 stream cipher operation
|
||||
class CRYPTOPP_NO_VTABLE Salsa20_Policy : public AdditiveCipherConcretePolicy<word32, 16>
|
||||
{
|
||||
protected:
|
||||
|
|
@ -43,7 +45,7 @@ protected:
|
|||
};
|
||||
|
||||
//! \class Salsa20
|
||||
//! \brief Salsa20 stream cipher information
|
||||
//! \brief Salsa20 stream cipher
|
||||
//! \details Salsa20 provides a variable number of rounds: 8, 12 or 20. The default number of rounds is 20.
|
||||
//! \sa <a href="http://www.cryptolounge.org/wiki/XSalsa20">XSalsa20</a>
|
||||
struct Salsa20 : public Salsa20_Info, public SymmetricCipherDocumentation
|
||||
|
|
@ -56,9 +58,11 @@ struct Salsa20 : public Salsa20_Info, public SymmetricCipherDocumentation
|
|||
//! \brief XSalsa20 stream cipher information
|
||||
struct XSalsa20_Info : public FixedKeyLength<32, SimpleKeyingInterface::UNIQUE_IV, 24>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "XSalsa20";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "XSalsa20";}
|
||||
};
|
||||
|
||||
//! \class XSalsa20_Policy
|
||||
//! \brief XSalsa20 stream cipher operation
|
||||
class CRYPTOPP_NO_VTABLE XSalsa20_Policy : public Salsa20_Policy
|
||||
{
|
||||
public:
|
||||
|
|
@ -70,7 +74,7 @@ protected:
|
|||
};
|
||||
|
||||
//! \class XSalsa20
|
||||
//! \brief XSalsa20 stream cipher information
|
||||
//! \brief XSalsa20 stream cipher
|
||||
//! \details XSalsa20 provides a variable number of rounds: 8, 12 or 20. The default number of rounds is 20.
|
||||
//! \sa <a href="http://www.cryptolounge.org/wiki/XSalsa20">XSalsa20</a>
|
||||
struct XSalsa20 : public XSalsa20_Info, public SymmetricCipherDocumentation
|
||||
|
|
|
|||
14
seal.h
14
seal.h
|
|
@ -11,13 +11,18 @@
|
|||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
//! _
|
||||
//! \class SEAL_Info
|
||||
//! \brief SEAL stream cipher information
|
||||
//! \tparam B Endianess of the stream cipher
|
||||
template <class B = BigEndian>
|
||||
struct SEAL_Info : public FixedKeyLength<20, SimpleKeyingInterface::INTERNALLY_GENERATED_IV, 4>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "SEAL-3.0-LE" : "SEAL-3.0-BE";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "SEAL-3.0-LE" : "SEAL-3.0-BE";}
|
||||
};
|
||||
|
||||
//! \class SEAL_Policy
|
||||
//! \brief SEAL stream cipher operation
|
||||
//! \tparam B Endianess of the stream cipher
|
||||
template <class B = BigEndian>
|
||||
class CRYPTOPP_NO_VTABLE SEAL_Policy : public AdditiveCipherConcretePolicy<word32, 256>, public SEAL_Info<B>
|
||||
{
|
||||
|
|
@ -37,7 +42,10 @@ private:
|
|||
word32 m_outsideCounter, m_insideCounter;
|
||||
};
|
||||
|
||||
//! <a href="http://www.weidai.com/scan-mirror/cs.html#SEAL-3.0-BE">SEAL</a>
|
||||
//! \class SEAL
|
||||
//! \brief SEAL stream cipher
|
||||
//! \tparam B Endianess of the stream cipher
|
||||
//! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#SEAL-3.0-BE">SEAL</a>
|
||||
template <class B = BigEndian>
|
||||
struct SEAL : public SEAL_Info<B>, public SymmetricCipherDocumentation
|
||||
{
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public:
|
|||
//! because the latter is \a not a \a constexpr. Some compilers, like Clang, do not
|
||||
//! optimize it well under all circumstances. Compilers like GCC, ICC and MSVC appear
|
||||
//! to optimize it well in either form.
|
||||
size_type max_size() const {return (SIZE_MAX/sizeof(T));}
|
||||
CRYPTOPP_CONSTEXPR size_type max_size() const {return (SIZE_MAX/sizeof(T));}
|
||||
|
||||
#if defined(CRYPTOPP_CXX11_VARIADIC_TEMPLATES) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
|
||||
|
||||
|
|
@ -278,7 +278,7 @@ public:
|
|||
assert(false);
|
||||
}
|
||||
|
||||
size_type max_size() const {return 0;}
|
||||
CRYPTOPP_CONSTEXPR size_type max_size() const {return 0;}
|
||||
//LCOV_EXCL_STOP
|
||||
};
|
||||
|
||||
|
|
@ -410,7 +410,7 @@ public:
|
|||
return newPointer;
|
||||
}
|
||||
|
||||
size_type max_size() const {return STDMAX(m_fallbackAllocator.max_size(), S);}
|
||||
CRYPTOPP_CONSTEXPR size_type max_size() const {return STDMAX(m_fallbackAllocator.max_size(), S);}
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
|||
46
seckey.h
46
seckey.h
|
|
@ -70,14 +70,24 @@ public:
|
|||
//! provided by a static function.
|
||||
//! \param keylength the size of the key, in bytes
|
||||
//! \details keylength is unused in the default implementation.
|
||||
static unsigned int StaticGetDefaultRounds(size_t keylength)
|
||||
{CRYPTOPP_UNUSED(keylength); return DEFAULT_ROUNDS;}
|
||||
CRYPTOPP_CONSTEXPR static unsigned int StaticGetDefaultRounds(size_t keylength)
|
||||
{
|
||||
// Comma operator breaks Debug builds with GCC 4.0 - 4.6.
|
||||
// Also see http://github.com/weidai11/cryptopp/issues/255
|
||||
#if defined(CRYPTOPP_CXX11_CONSTEXPR)
|
||||
return CRYPTOPP_UNUSED(keylength), static_cast<unsigned int>(DEFAULT_ROUNDS);
|
||||
#else
|
||||
CRYPTOPP_UNUSED(keylength);
|
||||
return static_cast<unsigned int>(DEFAULT_ROUNDS);
|
||||
#endif
|
||||
}
|
||||
|
||||
protected:
|
||||
//! \brief Validates the number of rounds for an algorithm.
|
||||
//! \param rounds the canddiate number of rounds
|
||||
//! \param rounds the candidate number of rounds
|
||||
//! \param alg an Algorithm object used if the number of rounds are invalid
|
||||
//! \throws InvalidRounds if the number of rounds are invalid
|
||||
//! \details ThrowIfInvalidRounds() validates the number of rounds and throws if invalid.
|
||||
inline void ThrowIfInvalidRounds(int rounds, const Algorithm *alg)
|
||||
{
|
||||
if (M == INT_MAX) // Coverity and result_independent_of_operands
|
||||
|
|
@ -93,10 +103,11 @@ protected:
|
|||
}
|
||||
|
||||
//! \brief Validates the number of rounds for an algorithm
|
||||
//! \param param the canddiate number of rounds
|
||||
//! \param param the candidate number of rounds
|
||||
//! \param alg an Algorithm object used if the number of rounds are invalid
|
||||
//! \returns the number of rounds for the algorithm
|
||||
//! \throws InvalidRounds if the number of rounds are invalid
|
||||
//! \details GetRoundsAndThrowIfInvalid() validates the number of rounds and throws if invalid.
|
||||
inline unsigned int GetRoundsAndThrowIfInvalid(const NameValuePairs ¶m, const Algorithm *alg)
|
||||
{
|
||||
int rounds = param.GetIntValueWithDefault("Rounds", DEFAULT_ROUNDS);
|
||||
|
|
@ -140,8 +151,17 @@ public:
|
|||
//! \param keylength the size of the key, in bytes
|
||||
//! \details The default implementation returns KEYLENGTH. keylength is unused
|
||||
//! in the default implementation.
|
||||
static size_t CRYPTOPP_API StaticGetValidKeyLength(size_t keylength)
|
||||
{CRYPTOPP_UNUSED(keylength); return KEYLENGTH;}
|
||||
CRYPTOPP_CONSTEXPR static size_t CRYPTOPP_API StaticGetValidKeyLength(size_t keylength)
|
||||
{
|
||||
// Comma operator breaks Debug builds with GCC 4.0 - 4.6.
|
||||
// Also see http://github.com/weidai11/cryptopp/issues/255
|
||||
#if defined(CRYPTOPP_CXX11_CONSTEXPR)
|
||||
return CRYPTOPP_UNUSED(keylength), static_cast<size_t>(KEYLENGTH);
|
||||
#else
|
||||
CRYPTOPP_UNUSED(keylength);
|
||||
return static_cast<size_t>(KEYLENGTH);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
//! \class VariableKeyLength
|
||||
|
|
@ -192,6 +212,7 @@ public:
|
|||
//! then keylength is returned. Otherwise, the function returns keylength rounded
|
||||
//! \a down to the next smaller multiple of KEYLENGTH_MULTIPLE.
|
||||
//! \details keylength is provided in bytes, not bits.
|
||||
// TODO: Figure out how to make this CRYPTOPP_CONSTEXPR
|
||||
static size_t CRYPTOPP_API StaticGetValidKeyLength(size_t keylength)
|
||||
{
|
||||
if (keylength < (size_t)MIN_KEYLENGTH)
|
||||
|
|
@ -240,7 +261,7 @@ public:
|
|||
//! then keylength is returned. Otherwise, the function returns keylength rounded
|
||||
//! \a down to the next smaller multiple of KEYLENGTH_MULTIPLE.
|
||||
//! \details keylength is provided in bytes, not bits.
|
||||
static size_t CRYPTOPP_API StaticGetValidKeyLength(size_t keylength)
|
||||
CRYPTOPP_CONSTEXPR static size_t CRYPTOPP_API StaticGetValidKeyLength(size_t keylength)
|
||||
{return T::StaticGetValidKeyLength(keylength);}
|
||||
};
|
||||
|
||||
|
|
@ -250,7 +271,9 @@ public:
|
|||
//! \brief Provides a base implementation of SimpleKeyingInterface
|
||||
//! \tparam BASE a SimpleKeyingInterface derived class
|
||||
//! \tparam INFO a SimpleKeyingInterface derived class
|
||||
//! \sa SimpleKeyingInterface
|
||||
//! \details SimpleKeyingInterfaceImpl() provides a default implementation for ciphers providing a keying interface.
|
||||
//! Functions are virtual and not eligible for C++11 <tt>constexpr</tt>-ness.
|
||||
//! \sa Algorithm(), SimpleKeyingInterface()
|
||||
template <class BASE, class INFO = BASE>
|
||||
class CRYPTOPP_NO_VTABLE SimpleKeyingInterfaceImpl : public BASE
|
||||
{
|
||||
|
|
@ -296,6 +319,9 @@ public:
|
|||
//! \brief Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers
|
||||
//! \tparam INFO a SimpleKeyingInterface derived class
|
||||
//! \tparam BASE a SimpleKeyingInterface derived class
|
||||
//! \details BlockCipherImpl() provides a default implementation for block ciphers using AlgorithmImpl()
|
||||
//! and SimpleKeyingInterfaceImpl(). Functions are virtual and not eligible for C++11 <tt>constexpr</tt>-ness.
|
||||
//! \sa Algorithm(), SimpleKeyingInterface(), AlgorithmImpl(), SimpleKeyingInterfaceImpl()
|
||||
template <class INFO, class BASE = BlockCipher>
|
||||
class CRYPTOPP_NO_VTABLE BlockCipherImpl : public AlgorithmImpl<SimpleKeyingInterfaceImpl<TwoBases<BASE, INFO> > >
|
||||
{
|
||||
|
|
@ -351,6 +377,10 @@ public:
|
|||
//! \brief Provides a base implementation of Algorithm and SimpleKeyingInterface for message authentication codes
|
||||
//! \tparam INFO a SimpleKeyingInterface derived class
|
||||
//! \tparam BASE a SimpleKeyingInterface derived class
|
||||
//! \details MessageAuthenticationCodeImpl() provides a default implementation for message authentication codes
|
||||
//! using AlgorithmImpl() and SimpleKeyingInterfaceImpl(). Functions are virtual and not subject to C++11
|
||||
//! <tt>constexpr</tt>.
|
||||
//! \sa Algorithm(), SimpleKeyingInterface(), AlgorithmImpl(), SimpleKeyingInterfaceImpl()
|
||||
template <class BASE, class INFO = BASE>
|
||||
class MessageAuthenticationCodeImpl : public AlgorithmImpl<SimpleKeyingInterfaceImpl<BASE, INFO>, INFO>
|
||||
{
|
||||
|
|
|
|||
2
seed.h
2
seed.h
|
|
@ -15,7 +15,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
//! \brief SEED block cipher information
|
||||
struct SEED_Info : public FixedBlockSize<16>, public FixedKeyLength<16>, public FixedRounds<16>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "SEED";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SEED";}
|
||||
};
|
||||
|
||||
//! \class SEED
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
|
||||
//! \class Serpent_Info
|
||||
//! \brief Serpent block cipher information
|
||||
struct Serpent_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 0, 32>, public FixedRounds<32>
|
||||
struct Serpent_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>, public FixedRounds<32>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "Serpent";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Serpent";}
|
||||
};
|
||||
|
||||
//! \class Serpent
|
||||
|
|
|
|||
10
sha.h
10
sha.h
|
|
@ -23,7 +23,7 @@ class CRYPTOPP_DLL SHA1 : public IteratedHashWithStaticTransform<word32, BigEndi
|
|||
public:
|
||||
static void CRYPTOPP_API InitState(HashWordType *state);
|
||||
static void CRYPTOPP_API Transform(word32 *digest, const word32 *data);
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-1";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-1";}
|
||||
};
|
||||
|
||||
typedef SHA1 SHA; // for backwards compatibility
|
||||
|
|
@ -37,7 +37,7 @@ public:
|
|||
#endif
|
||||
static void CRYPTOPP_API InitState(HashWordType *state);
|
||||
static void CRYPTOPP_API Transform(word32 *digest, const word32 *data);
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-256";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-256";}
|
||||
};
|
||||
|
||||
//! implements the SHA-224 standard
|
||||
|
|
@ -49,7 +49,7 @@ public:
|
|||
#endif
|
||||
static void CRYPTOPP_API InitState(HashWordType *state);
|
||||
static void CRYPTOPP_API Transform(word32 *digest, const word32 *data) {SHA256::Transform(digest, data);}
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-224";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-224";}
|
||||
};
|
||||
|
||||
//! implements the SHA-512 standard
|
||||
|
|
@ -58,7 +58,7 @@ class CRYPTOPP_DLL SHA512 : public IteratedHashWithStaticTransform<word64, BigEn
|
|||
public:
|
||||
static void CRYPTOPP_API InitState(HashWordType *state);
|
||||
static void CRYPTOPP_API Transform(word64 *digest, const word64 *data);
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-512";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-512";}
|
||||
};
|
||||
|
||||
//! implements the SHA-384 standard
|
||||
|
|
@ -67,7 +67,7 @@ class CRYPTOPP_DLL SHA384 : public IteratedHashWithStaticTransform<word64, BigEn
|
|||
public:
|
||||
static void CRYPTOPP_API InitState(HashWordType *state);
|
||||
static void CRYPTOPP_API Transform(word64 *digest, const word64 *data) {SHA512::Transform(digest, data);}
|
||||
static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-384";}
|
||||
CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-384";}
|
||||
};
|
||||
|
||||
NAMESPACE_END
|
||||
|
|
|
|||
8
sha3.h
8
sha3.h
|
|
@ -52,7 +52,7 @@ public:
|
|||
|
||||
//! \brief Construct a SHA3-224 message digest
|
||||
SHA3_224() : SHA3(DIGESTSIZE) {}
|
||||
static const char * StaticAlgorithmName() {return "SHA-3-224";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHA-3-224";}
|
||||
} CRYPTOPP_DEPRECATED("SHA-3 will be changing in the future due to FIPS 202 finalization");
|
||||
|
||||
//! \class SHA3_256
|
||||
|
|
@ -64,7 +64,7 @@ public:
|
|||
|
||||
//! \brief Construct a SHA3-256 message digest
|
||||
SHA3_256() : SHA3(DIGESTSIZE) {}
|
||||
static const char * StaticAlgorithmName() {return "SHA-3-256";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHA-3-256";}
|
||||
} CRYPTOPP_DEPRECATED("SHA-3 will be changing in the future due to FIPS 202 finalization");
|
||||
|
||||
//! \class SHA3_384
|
||||
|
|
@ -76,7 +76,7 @@ public:
|
|||
|
||||
//! \brief Construct a SHA3-384 message digest
|
||||
SHA3_384() : SHA3(DIGESTSIZE) {}
|
||||
static const char * StaticAlgorithmName() {return "SHA-3-384";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHA-3-384";}
|
||||
} CRYPTOPP_DEPRECATED("SHA-3 will be changing in the future due to FIPS 202 finalization");
|
||||
|
||||
//! \class SHA3_512
|
||||
|
|
@ -88,7 +88,7 @@ public:
|
|||
|
||||
//! \brief Construct a SHA3-512 message digest
|
||||
SHA3_512() : SHA3(DIGESTSIZE) {}
|
||||
static const char * StaticAlgorithmName() {return "SHA-3-512";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHA-3-512";}
|
||||
} CRYPTOPP_DEPRECATED("SHA-3 will be changing in the future due to FIPS 202 finalization");
|
||||
|
||||
NAMESPACE_END
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
//! \brief SHACAL2 block cipher information
|
||||
struct SHACAL2_Info : public FixedBlockSize<32>, public VariableKeyLength<16, 16, 64>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "SHACAL-2";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHACAL-2";}
|
||||
};
|
||||
|
||||
//! \class SHACAL2
|
||||
|
|
|
|||
10
shark.h
10
shark.h
|
|
@ -14,9 +14,9 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
|
||||
//! \class SHARK_Info
|
||||
//! \brief SHARK block cipher information
|
||||
struct SHARK_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 16>, public VariableRounds<6, 2>
|
||||
struct SHARK_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public VariableRounds<6, 2>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "SHARK-E";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHARK-E";}
|
||||
};
|
||||
|
||||
//! \class SHARK
|
||||
|
|
@ -24,6 +24,8 @@ struct SHARK_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 16
|
|||
/// <a href="http://www.weidai.com/scan-mirror/cs.html#SHARK-E">SHARK-E</a>
|
||||
class SHARK : public SHARK_Info, public BlockCipherDocumentation
|
||||
{
|
||||
//! \class Base
|
||||
//! \brief SHARK block cipher default operation
|
||||
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<SHARK_Info>
|
||||
{
|
||||
public:
|
||||
|
|
@ -34,6 +36,8 @@ class SHARK : public SHARK_Info, public BlockCipherDocumentation
|
|||
SecBlock<word64> m_roundKeys;
|
||||
};
|
||||
|
||||
//! \class Enc
|
||||
//! \brief SHARK block cipher encryption operation
|
||||
class CRYPTOPP_NO_VTABLE Enc : public Base
|
||||
{
|
||||
public:
|
||||
|
|
@ -47,6 +51,8 @@ class SHARK : public SHARK_Info, public BlockCipherDocumentation
|
|||
static const word64 cbox[8][256];
|
||||
};
|
||||
|
||||
//! \class Dec
|
||||
//! \brief SHARK block cipher decryption operation
|
||||
class CRYPTOPP_NO_VTABLE Dec : public Base
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -19,10 +19,12 @@ struct SKIPJACK_Info : public FixedBlockSize<8>, public FixedKeyLength<10>
|
|||
};
|
||||
|
||||
//! \class SKIPJACK
|
||||
//! \brief SKIPJACK block cipher information
|
||||
//! \brief SKIPJACK block cipher
|
||||
//! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#SKIPJACK">SKIPJACK</a>
|
||||
class SKIPJACK : public SKIPJACK_Info, public BlockCipherDocumentation
|
||||
{
|
||||
//! \class Base
|
||||
//! \brief SKIPJACK block cipher default operation
|
||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<SKIPJACK_Info>
|
||||
{
|
||||
public:
|
||||
|
|
@ -35,6 +37,8 @@ class SKIPJACK : public SKIPJACK_Info, public BlockCipherDocumentation
|
|||
FixedSizeSecBlock<byte, 10*256> tab;
|
||||
};
|
||||
|
||||
//! \class Enc
|
||||
//! \brief SKIPJACK block cipher encryption operation
|
||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Enc : public Base
|
||||
{
|
||||
public:
|
||||
|
|
@ -44,6 +48,8 @@ class SKIPJACK : public SKIPJACK_Info, public BlockCipherDocumentation
|
|||
static const word32 Te[4][256];
|
||||
};
|
||||
|
||||
//! \class Dec
|
||||
//! \brief SKIPJACK block cipher decryption operation
|
||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Dec : public Base
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
//! algorithm info
|
||||
struct SosemanukInfo : public VariableKeyLength<16, 1, 32, 1, SimpleKeyingInterface::UNIQUE_IV, 16>
|
||||
{
|
||||
static const char * StaticAlgorithmName() {return "Sosemanuk";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Sosemanuk";}
|
||||
};
|
||||
|
||||
//! _
|
||||
|
|
|
|||
2
square.h
2
square.h
|
|
@ -15,7 +15,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
//! \brief Square block cipher information
|
||||
struct Square_Info : public FixedBlockSize<16>, public FixedKeyLength<16>, FixedRounds<8>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "Square";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Square";}
|
||||
};
|
||||
|
||||
//! \class Square
|
||||
|
|
|
|||
24
tea.h
24
tea.h
|
|
@ -16,7 +16,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
//! \brief TEA block cipher information
|
||||
struct TEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public VariableRounds<32>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "TEA";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "TEA";}
|
||||
};
|
||||
|
||||
//! \class TEA
|
||||
|
|
@ -24,6 +24,8 @@ struct TEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public Va
|
|||
//! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#TEA">TEA</a>
|
||||
class TEA : public TEA_Info, public BlockCipherDocumentation
|
||||
{
|
||||
//! \class Base
|
||||
//! \brief TEA block cipher default operation
|
||||
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<TEA_Info>
|
||||
{
|
||||
public:
|
||||
|
|
@ -34,12 +36,16 @@ class TEA : public TEA_Info, public BlockCipherDocumentation
|
|||
word32 m_limit;
|
||||
};
|
||||
|
||||
//! \class Enc
|
||||
//! \brief TEA block cipher encryption operation
|
||||
class CRYPTOPP_NO_VTABLE Enc : public Base
|
||||
{
|
||||
public:
|
||||
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
|
||||
};
|
||||
|
||||
//! \class Dec
|
||||
//! \brief TEA block cipher decryption operation
|
||||
class CRYPTOPP_NO_VTABLE Dec : public Base
|
||||
{
|
||||
public:
|
||||
|
|
@ -58,7 +64,7 @@ typedef TEA::Decryption TEADecryption;
|
|||
//! \brief XTEA block cipher information
|
||||
struct XTEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public VariableRounds<32>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "XTEA";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "XTEA";}
|
||||
};
|
||||
|
||||
//! \class XTEA
|
||||
|
|
@ -66,6 +72,8 @@ struct XTEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public V
|
|||
//! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#TEA">XTEA</a>
|
||||
class XTEA : public XTEA_Info, public BlockCipherDocumentation
|
||||
{
|
||||
//! \class Base
|
||||
//! \brief XTEA block cipher default operation
|
||||
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<XTEA_Info>
|
||||
{
|
||||
public:
|
||||
|
|
@ -76,12 +84,16 @@ class XTEA : public XTEA_Info, public BlockCipherDocumentation
|
|||
word32 m_limit;
|
||||
};
|
||||
|
||||
//! \class Enc
|
||||
//! \brief XTEA block cipher encryption operation
|
||||
class CRYPTOPP_NO_VTABLE Enc : public Base
|
||||
{
|
||||
public:
|
||||
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
|
||||
};
|
||||
|
||||
//! \class Dec
|
||||
//! \brief XTEA block cipher decryption operation
|
||||
class CRYPTOPP_NO_VTABLE Dec : public Base
|
||||
{
|
||||
public:
|
||||
|
|
@ -97,7 +109,7 @@ public:
|
|||
//! \brief BTEA block cipher information
|
||||
struct BTEA_Info : public FixedKeyLength<16>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "BTEA";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "BTEA";}
|
||||
};
|
||||
|
||||
//! \class BTEA
|
||||
|
|
@ -106,6 +118,8 @@ struct BTEA_Info : public FixedKeyLength<16>
|
|||
//! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#TEA">Corrected Block TEA</a>.
|
||||
class BTEA : public BTEA_Info, public BlockCipherDocumentation
|
||||
{
|
||||
//! \class Base
|
||||
//! \brief BTEA block cipher default operation
|
||||
class CRYPTOPP_NO_VTABLE Base : public AlgorithmImpl<SimpleKeyingInterfaceImpl<BlockCipher, BTEA_Info>, BTEA_Info>, public BTEA_Info
|
||||
{
|
||||
public:
|
||||
|
|
@ -123,12 +137,16 @@ class BTEA : public BTEA_Info, public BlockCipherDocumentation
|
|||
unsigned int m_blockSize;
|
||||
};
|
||||
|
||||
//! \class Enc
|
||||
//! \brief BTEA block cipher encryption operation
|
||||
class CRYPTOPP_NO_VTABLE Enc : public Base
|
||||
{
|
||||
public:
|
||||
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
|
||||
};
|
||||
|
||||
//! \class Dec
|
||||
//! \brief BTEA block cipher decryption operation
|
||||
class CRYPTOPP_NO_VTABLE Dec : public Base
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
2
tiger.h
2
tiger.h
|
|
@ -13,7 +13,7 @@ public:
|
|||
static void InitState(HashWordType *state);
|
||||
static void Transform(word64 *digest, const word64 *data);
|
||||
void TruncatedFinal(byte *hash, size_t size);
|
||||
static const char * StaticAlgorithmName() {return "Tiger";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Tiger";}
|
||||
|
||||
protected:
|
||||
static const word64 table[4*256+3];
|
||||
|
|
|
|||
13
ttmac.h
13
ttmac.h
|
|
@ -1,5 +1,8 @@
|
|||
// ttmac.h - written and placed in the public domain by Kevin Springle
|
||||
|
||||
//! \file ttmac.h
|
||||
//! \brief Classes for the TTMAC message authentication code
|
||||
|
||||
#ifndef CRYPTOPP_TTMAC_H
|
||||
#define CRYPTOPP_TTMAC_H
|
||||
|
||||
|
|
@ -9,7 +12,8 @@
|
|||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
//! _
|
||||
//! \class TTMAC_Base
|
||||
//! \brief TTMAC message authentication code information
|
||||
class CRYPTOPP_NO_VTABLE TTMAC_Base : public FixedKeyLength<20>, public IteratedHash<word32, LittleEndian, 64, MessageAuthenticationCode>
|
||||
{
|
||||
public:
|
||||
|
|
@ -30,8 +34,11 @@ protected:
|
|||
FixedSizeSecBlock<word32, 5> m_key;
|
||||
};
|
||||
|
||||
//! <a href="http://www.weidai.com/scan-mirror/mac.html#TTMAC">Two-Track-MAC</a>
|
||||
/*! 160 Bit MAC with 160 Bit Key */
|
||||
//! \class TTMAC
|
||||
//! \brief Two-Track-MAC message authentication code
|
||||
//! \tparam T HashTransformation class
|
||||
//! \details 160-bit MAC with 160-bit key
|
||||
//! \sa MessageAuthenticationCode(), <a href="http://www.weidai.com/scan-mirror/mac.html#TTMAC">Two-Track-MAC</a>
|
||||
DOCUMENTED_TYPEDEF(MessageAuthenticationCodeFinal<TTMAC_Base>, TTMAC)
|
||||
|
||||
NAMESPACE_END
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
|
||||
//! \class Twofish_Info
|
||||
//! \brief Twofish block cipher information
|
||||
struct Twofish_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 0, 32>, FixedRounds<16>
|
||||
struct Twofish_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>, FixedRounds<16>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return "Twofish";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Twofish";}
|
||||
};
|
||||
|
||||
//! \class Twofish
|
||||
|
|
|
|||
421
validat1.cpp
421
validat1.cpp
|
|
@ -2433,93 +2433,240 @@ bool ValidateARC4()
|
|||
bool ValidateRC5()
|
||||
{
|
||||
cout << "\nRC5 validation suite running...\n\n";
|
||||
bool pass1 = true, pass2 = true;
|
||||
|
||||
RC5Encryption enc; // 0 to 2040-bits (255-bytes)
|
||||
pass1 = RC5Encryption::DEFAULT_KEYLENGTH == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(0) == 0 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(254) == 254 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(255) == 255 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(256) == 255 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(SIZE_MAX) == enc.MaxKeyLength() && pass1;
|
||||
|
||||
RC5Decryption dec;
|
||||
pass2 = RC5Decryption::DEFAULT_KEYLENGTH == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(0) == 0 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(254) == 254 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(255) == 255 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(256) == 255 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(SIZE_MAX) == dec.MaxKeyLength() && pass2;
|
||||
cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n";
|
||||
|
||||
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/rc5val.dat", true, new HexDecoder);
|
||||
return BlockTransformationTest(VariableRoundsCipherFactory<RC5Encryption, RC5Decryption>(16, 12), valdata);
|
||||
return BlockTransformationTest(VariableRoundsCipherFactory<RC5Encryption, RC5Decryption>(16, 12), valdata) && pass1 && pass2;
|
||||
}
|
||||
|
||||
bool ValidateRC6()
|
||||
{
|
||||
cout << "\nRC6 validation suite running...\n\n";
|
||||
bool pass1 = true, pass2 = true, pass3 = true;
|
||||
|
||||
RC6Encryption enc;
|
||||
pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(SIZE_MAX) == enc.MaxKeyLength() && pass1;
|
||||
|
||||
RC6Decryption dec;
|
||||
pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(SIZE_MAX) == dec.MaxKeyLength() && pass2;
|
||||
cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n";
|
||||
|
||||
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/rc6val.dat", true, new HexDecoder);
|
||||
bool pass = true;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<RC6Encryption, RC6Decryption>(16), valdata, 2) && pass;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<RC6Encryption, RC6Decryption>(24), valdata, 2) && pass;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<RC6Encryption, RC6Decryption>(32), valdata, 2) && pass;
|
||||
return pass;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<RC6Encryption, RC6Decryption>(16), valdata, 2) && pass3;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<RC6Encryption, RC6Decryption>(24), valdata, 2) && pass3;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<RC6Encryption, RC6Decryption>(32), valdata, 2) && pass3;
|
||||
return pass1 && pass2 && pass3;
|
||||
}
|
||||
|
||||
bool ValidateMARS()
|
||||
{
|
||||
cout << "\nMARS validation suite running...\n\n";
|
||||
bool pass1 = true, pass2 = true, pass3 = true;
|
||||
|
||||
MARSEncryption enc;
|
||||
pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(SIZE_MAX) == enc.MaxKeyLength() && pass1;
|
||||
|
||||
MARSDecryption dec;
|
||||
pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(SIZE_MAX) == dec.MaxKeyLength() && pass2;
|
||||
cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n";
|
||||
|
||||
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/marsval.dat", true, new HexDecoder);
|
||||
bool pass = true;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<MARSEncryption, MARSDecryption>(16), valdata, 4) && pass;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<MARSEncryption, MARSDecryption>(24), valdata, 3) && pass;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<MARSEncryption, MARSDecryption>(32), valdata, 2) && pass;
|
||||
return pass;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<MARSEncryption, MARSDecryption>(16), valdata, 4) && pass3;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<MARSEncryption, MARSDecryption>(24), valdata, 3) && pass3;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<MARSEncryption, MARSDecryption>(32), valdata, 2) && pass3;
|
||||
return pass1 && pass2 && pass3;
|
||||
}
|
||||
|
||||
bool ValidateRijndael()
|
||||
{
|
||||
cout << "\nRijndael (AES) validation suite running...\n\n";
|
||||
bool pass1 = true, pass2 = true, pass3 = true;
|
||||
|
||||
RijndaelEncryption enc;
|
||||
pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(SIZE_MAX) == enc.MaxKeyLength() && pass1;
|
||||
|
||||
RijndaelDecryption dec;
|
||||
pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(SIZE_MAX) == dec.MaxKeyLength() && pass2;
|
||||
cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n";
|
||||
|
||||
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/rijndael.dat", true, new HexDecoder);
|
||||
bool pass = true;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<RijndaelEncryption, RijndaelDecryption>(16), valdata, 4) && pass;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<RijndaelEncryption, RijndaelDecryption>(24), valdata, 3) && pass;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<RijndaelEncryption, RijndaelDecryption>(32), valdata, 2) && pass;
|
||||
pass = RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/aes.txt") && pass;
|
||||
return pass;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<RijndaelEncryption, RijndaelDecryption>(16), valdata, 4) && pass3;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<RijndaelEncryption, RijndaelDecryption>(24), valdata, 3) && pass3;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<RijndaelEncryption, RijndaelDecryption>(32), valdata, 2) && pass3;
|
||||
pass3 = RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/aes.txt") && pass3;
|
||||
return pass1 && pass2 && pass3;
|
||||
}
|
||||
|
||||
bool ValidateTwofish()
|
||||
{
|
||||
cout << "\nTwofish validation suite running...\n\n";
|
||||
bool pass1 = true, pass2 = true, pass3 = true;
|
||||
|
||||
TwofishEncryption enc;
|
||||
pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1;
|
||||
|
||||
TwofishDecryption dec;
|
||||
pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2;
|
||||
cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n";
|
||||
|
||||
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/twofishv.dat", true, new HexDecoder);
|
||||
bool pass = true;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<TwofishEncryption, TwofishDecryption>(16), valdata, 4) && pass;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<TwofishEncryption, TwofishDecryption>(24), valdata, 3) && pass;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<TwofishEncryption, TwofishDecryption>(32), valdata, 2) && pass;
|
||||
return pass;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<TwofishEncryption, TwofishDecryption>(16), valdata, 4) && pass3;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<TwofishEncryption, TwofishDecryption>(24), valdata, 3) && pass3;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<TwofishEncryption, TwofishDecryption>(32), valdata, 2) && pass3;
|
||||
return pass1 && pass2 && pass3;
|
||||
}
|
||||
|
||||
bool ValidateSerpent()
|
||||
{
|
||||
cout << "\nSerpent validation suite running...\n\n";
|
||||
bool pass1 = true, pass2 = true, pass3 = true;
|
||||
|
||||
SerpentEncryption enc;
|
||||
pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1;
|
||||
|
||||
SerpentDecryption dec;
|
||||
pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2;
|
||||
cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n";
|
||||
|
||||
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/serpentv.dat", true, new HexDecoder);
|
||||
bool pass = true;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<SerpentEncryption, SerpentDecryption>(16), valdata, 5) && pass;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<SerpentEncryption, SerpentDecryption>(24), valdata, 4) && pass;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<SerpentEncryption, SerpentDecryption>(32), valdata, 3) && pass;
|
||||
return pass;
|
||||
return pass1 && pass2 && pass3;
|
||||
}
|
||||
|
||||
bool ValidateBlowfish()
|
||||
{
|
||||
cout << "\nBlowfish validation suite running...\n\n";
|
||||
bool pass1 = true, pass2 = true, pass3 = true, fail;
|
||||
|
||||
BlowfishEncryption enc1; // 32 to 448-bits (4 to 56-bytes)
|
||||
pass1 = enc1.StaticGetValidKeyLength(3) == 4 && pass1;
|
||||
pass1 = enc1.StaticGetValidKeyLength(4) == 4 && pass1;
|
||||
pass1 = enc1.StaticGetValidKeyLength(5) == 5 && pass1;
|
||||
pass1 = enc1.StaticGetValidKeyLength(8) == 8 && pass1;
|
||||
pass1 = enc1.StaticGetValidKeyLength(16) == 16 && pass1;
|
||||
pass1 = enc1.StaticGetValidKeyLength(24) == 24 && pass1;
|
||||
pass1 = enc1.StaticGetValidKeyLength(32) == 32 && pass1;
|
||||
pass1 = enc1.StaticGetValidKeyLength(56) == 56 && pass1;
|
||||
pass1 = enc1.StaticGetValidKeyLength(57) == 56 && pass1;
|
||||
pass1 = enc1.StaticGetValidKeyLength(60) == 56 && pass1;
|
||||
pass1 = enc1.StaticGetValidKeyLength(64) == 56 && pass1;
|
||||
pass1 = enc1.StaticGetValidKeyLength(128) == 56 && pass1;
|
||||
|
||||
BlowfishDecryption dec1; // 32 to 448-bits (4 to 56-bytes)
|
||||
pass2 = dec1.StaticGetValidKeyLength(3) == 4 && pass2;
|
||||
pass2 = dec1.StaticGetValidKeyLength(4) == 4 && pass2;
|
||||
pass2 = dec1.StaticGetValidKeyLength(5) == 5 && pass2;
|
||||
pass2 = dec1.StaticGetValidKeyLength(8) == 8 && pass2;
|
||||
pass2 = dec1.StaticGetValidKeyLength(16) == 16 && pass2;
|
||||
pass2 = dec1.StaticGetValidKeyLength(24) == 24 && pass2;
|
||||
pass2 = dec1.StaticGetValidKeyLength(32) == 32 && pass2;
|
||||
pass2 = dec1.StaticGetValidKeyLength(56) == 56 && pass2;
|
||||
pass2 = dec1.StaticGetValidKeyLength(57) == 56 && pass2;
|
||||
pass2 = dec1.StaticGetValidKeyLength(60) == 56 && pass2;
|
||||
pass2 = dec1.StaticGetValidKeyLength(64) == 56 && pass2;
|
||||
pass2 = dec1.StaticGetValidKeyLength(128) == 56 && pass2;
|
||||
cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n";
|
||||
|
||||
HexEncoder output(new FileSink(cout));
|
||||
const char *key[]={"abcdefghijklmnopqrstuvwxyz", "Who is John Galt?"};
|
||||
byte *plain[]={(byte *)"BLOWFISH", (byte *)"\xfe\xdc\xba\x98\x76\x54\x32\x10"};
|
||||
byte *cipher[]={(byte *)"\x32\x4e\xd0\xfe\xf4\x13\xa2\x03", (byte *)"\xcc\x91\x73\x2b\x80\x22\xf6\x84"};
|
||||
byte out[8], outplain[8];
|
||||
bool pass=true, fail;
|
||||
|
||||
for (int i=0; i<2; i++)
|
||||
{
|
||||
ECB_Mode<Blowfish>::Encryption enc((byte *)key[i], strlen(key[i]));
|
||||
enc.ProcessData(out, plain[i], 8);
|
||||
ECB_Mode<Blowfish>::Encryption enc2((byte *)key[i], strlen(key[i]));
|
||||
enc2.ProcessData(out, plain[i], 8);
|
||||
fail = memcmp(out, cipher[i], 8) != 0;
|
||||
|
||||
ECB_Mode<Blowfish>::Decryption dec((byte *)key[i], strlen(key[i]));
|
||||
dec.ProcessData(outplain, cipher[i], 8);
|
||||
ECB_Mode<Blowfish>::Decryption dec2((byte *)key[i], strlen(key[i]));
|
||||
dec2.ProcessData(outplain, cipher[i], 8);
|
||||
fail = fail || memcmp(outplain, plain[i], 8);
|
||||
pass = pass && !fail;
|
||||
pass3 = pass3 && !fail;
|
||||
|
||||
cout << (fail ? "FAILED " : "passed ");
|
||||
cout << '\"' << key[i] << '\"';
|
||||
|
|
@ -2530,76 +2677,196 @@ bool ValidateBlowfish()
|
|||
output.Put(out, 8);
|
||||
cout << endl;
|
||||
}
|
||||
return pass;
|
||||
return pass1 && pass2 && pass3;
|
||||
}
|
||||
|
||||
bool ValidateThreeWay()
|
||||
{
|
||||
cout << "\n3-WAY validation suite running...\n\n";
|
||||
bool pass1 = true, pass2 = true;
|
||||
|
||||
ThreeWayEncryption enc; // 96-bit only
|
||||
pass1 = ThreeWayEncryption::KEYLENGTH == 12 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(8) == 12 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(12) == 12 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(16) == 12 && pass1;
|
||||
|
||||
ThreeWayDecryption dec; // 96-bit only
|
||||
pass2 = ThreeWayDecryption::KEYLENGTH == 12 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(8) == 12 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(12) == 12 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(16) == 12 && pass2;
|
||||
cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n";
|
||||
|
||||
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/3wayval.dat", true, new HexDecoder);
|
||||
return BlockTransformationTest(FixedRoundsCipherFactory<ThreeWayEncryption, ThreeWayDecryption>(), valdata);
|
||||
return BlockTransformationTest(FixedRoundsCipherFactory<ThreeWayEncryption, ThreeWayDecryption>(), valdata) && pass1 && pass2;
|
||||
}
|
||||
|
||||
bool ValidateGOST()
|
||||
{
|
||||
cout << "\nGOST validation suite running...\n\n";
|
||||
bool pass1 = true, pass2 = true;
|
||||
|
||||
GOSTEncryption enc; // 256-bit only
|
||||
pass1 = GOSTEncryption::KEYLENGTH == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(16) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(24) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(40) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1;
|
||||
|
||||
GOSTDecryption dec; // 256-bit only
|
||||
pass2 = GOSTDecryption::KEYLENGTH == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(16) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(24) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(40) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2;
|
||||
cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n";
|
||||
|
||||
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/gostval.dat", true, new HexDecoder);
|
||||
return BlockTransformationTest(FixedRoundsCipherFactory<GOSTEncryption, GOSTDecryption>(), valdata);
|
||||
return BlockTransformationTest(FixedRoundsCipherFactory<GOSTEncryption, GOSTDecryption>(), valdata) && pass1 && pass2;
|
||||
}
|
||||
|
||||
bool ValidateSHARK()
|
||||
{
|
||||
cout << "\nSHARK validation suite running...\n\n";
|
||||
bool pass1 = true, pass2 = true;
|
||||
|
||||
SHARKEncryption enc; // 128-bit only
|
||||
pass1 = SHARKEncryption::KEYLENGTH == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(15) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(17) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(32) == 16 && pass1;
|
||||
|
||||
SHARKDecryption dec; // 128-bit only
|
||||
pass2 = SHARKDecryption::KEYLENGTH == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(15) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(17) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(32) == 16 && pass2;
|
||||
cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n";
|
||||
|
||||
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/sharkval.dat", true, new HexDecoder);
|
||||
return BlockTransformationTest(FixedRoundsCipherFactory<SHARKEncryption, SHARKDecryption>(), valdata);
|
||||
return BlockTransformationTest(FixedRoundsCipherFactory<SHARKEncryption, SHARKDecryption>(), valdata) && pass1 && pass2;
|
||||
}
|
||||
|
||||
bool ValidateCAST()
|
||||
{
|
||||
bool pass = true;
|
||||
|
||||
cout << "\nCAST-128 validation suite running...\n\n";
|
||||
bool pass1 = true, pass2 = true, pass3 = true;
|
||||
|
||||
CAST128Encryption enc1; // 40 to 128-bits (5 to 16-bytes)
|
||||
pass1 = CAST128Encryption::DEFAULT_KEYLENGTH == 16 && pass1;
|
||||
pass1 = enc1.StaticGetValidKeyLength(4) == 5 && pass1;
|
||||
pass1 = enc1.StaticGetValidKeyLength(5) == 5 && pass1;
|
||||
pass1 = enc1.StaticGetValidKeyLength(15) == 15 && pass1;
|
||||
pass1 = enc1.StaticGetValidKeyLength(16) == 16 && pass1;
|
||||
pass1 = enc1.StaticGetValidKeyLength(17) == 16 && pass1;
|
||||
|
||||
CAST128Decryption dec1; // 40 to 128-bits (5 to 16-bytes)
|
||||
pass2 = CAST128Decryption::DEFAULT_KEYLENGTH == 16 && pass2;
|
||||
pass2 = dec1.StaticGetValidKeyLength(4) == 5 && pass2;
|
||||
pass2 = dec1.StaticGetValidKeyLength(5) == 5 && pass2;
|
||||
pass2 = dec1.StaticGetValidKeyLength(15) == 15 && pass2;
|
||||
pass2 = dec1.StaticGetValidKeyLength(16) == 16 && pass2;
|
||||
pass2 = dec1.StaticGetValidKeyLength(17) == 16 && pass2;
|
||||
cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n";
|
||||
|
||||
FileSource val128(CRYPTOPP_DATA_DIR "TestData/cast128v.dat", true, new HexDecoder);
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<CAST128Encryption, CAST128Decryption>(16), val128, 1) && pass;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<CAST128Encryption, CAST128Decryption>(10), val128, 1) && pass;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<CAST128Encryption, CAST128Decryption>(5), val128, 1) && pass;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<CAST128Encryption, CAST128Decryption>(16), val128, 1) && pass3;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<CAST128Encryption, CAST128Decryption>(10), val128, 1) && pass3;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<CAST128Encryption, CAST128Decryption>(5), val128, 1) && pass3;
|
||||
|
||||
cout << "\nCAST-256 validation suite running...\n\n";
|
||||
bool pass4 = true, pass5 = true, pass6 = true;
|
||||
|
||||
CAST256Encryption enc2; // 128, 160, 192, 224, or 256-bits (16 to 32-bytes, step 4)
|
||||
pass1 = CAST128Encryption::DEFAULT_KEYLENGTH == 16 && pass1;
|
||||
pass4 = enc2.StaticGetValidKeyLength(15) == 16 && pass4;
|
||||
pass4 = enc2.StaticGetValidKeyLength(16) == 16 && pass4;
|
||||
pass4 = enc2.StaticGetValidKeyLength(17) == 20 && pass4;
|
||||
pass4 = enc2.StaticGetValidKeyLength(20) == 20 && pass4;
|
||||
pass4 = enc2.StaticGetValidKeyLength(24) == 24 && pass4;
|
||||
pass4 = enc2.StaticGetValidKeyLength(28) == 28 && pass4;
|
||||
pass4 = enc2.StaticGetValidKeyLength(31) == 32 && pass4;
|
||||
pass4 = enc2.StaticGetValidKeyLength(32) == 32 && pass4;
|
||||
pass4 = enc2.StaticGetValidKeyLength(33) == 32 && pass4;
|
||||
|
||||
CAST256Decryption dec2; // 128, 160, 192, 224, or 256-bits (16 to 32-bytes, step 4)
|
||||
pass2 = CAST256Decryption::DEFAULT_KEYLENGTH == 16 && pass2;
|
||||
pass5 = dec2.StaticGetValidKeyLength(15) == 16 && pass5;
|
||||
pass5 = dec2.StaticGetValidKeyLength(16) == 16 && pass5;
|
||||
pass5 = dec2.StaticGetValidKeyLength(17) == 20 && pass5;
|
||||
pass5 = dec2.StaticGetValidKeyLength(20) == 20 && pass5;
|
||||
pass5 = dec2.StaticGetValidKeyLength(24) == 24 && pass5;
|
||||
pass5 = dec2.StaticGetValidKeyLength(28) == 28 && pass5;
|
||||
pass5 = dec2.StaticGetValidKeyLength(31) == 32 && pass5;
|
||||
pass5 = dec2.StaticGetValidKeyLength(32) == 32 && pass5;
|
||||
pass5 = dec2.StaticGetValidKeyLength(33) == 32 && pass5;
|
||||
cout << (pass4 && pass5 ? "passed:" : "FAILED:") << " Algorithm key lengths\n";
|
||||
|
||||
FileSource val256(CRYPTOPP_DATA_DIR "TestData/cast256v.dat", true, new HexDecoder);
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<CAST256Encryption, CAST256Decryption>(16), val256, 1) && pass;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<CAST256Encryption, CAST256Decryption>(24), val256, 1) && pass;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<CAST256Encryption, CAST256Decryption>(32), val256, 1) && pass;
|
||||
pass6 = BlockTransformationTest(FixedRoundsCipherFactory<CAST256Encryption, CAST256Decryption>(16), val256, 1) && pass6;
|
||||
pass6 = BlockTransformationTest(FixedRoundsCipherFactory<CAST256Encryption, CAST256Decryption>(24), val256, 1) && pass6;
|
||||
pass6 = BlockTransformationTest(FixedRoundsCipherFactory<CAST256Encryption, CAST256Decryption>(32), val256, 1) && pass6;
|
||||
|
||||
return pass;
|
||||
return pass1 && pass2 && pass3 && pass4 && pass5 && pass6;
|
||||
}
|
||||
|
||||
bool ValidateSquare()
|
||||
{
|
||||
cout << "\nSquare validation suite running...\n\n";
|
||||
bool pass1 = true, pass2 = true;
|
||||
|
||||
SquareEncryption enc; // 128-bits only
|
||||
pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(15) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(17) == 16 && pass1;
|
||||
|
||||
SquareDecryption dec; // 128-bits only
|
||||
pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(15) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(17) == 16 && pass2;
|
||||
cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n";
|
||||
|
||||
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/squareva.dat", true, new HexDecoder);
|
||||
return BlockTransformationTest(FixedRoundsCipherFactory<SquareEncryption, SquareDecryption>(), valdata);
|
||||
return BlockTransformationTest(FixedRoundsCipherFactory<SquareEncryption, SquareDecryption>(), valdata) && pass1 && pass2;
|
||||
}
|
||||
|
||||
bool ValidateSKIPJACK()
|
||||
{
|
||||
cout << "\nSKIPJACK validation suite running...\n\n";
|
||||
bool pass1 = true, pass2 = true;
|
||||
|
||||
SKIPJACKEncryption enc; // 80-bits only
|
||||
pass1 = enc.StaticGetValidKeyLength(8) == 10 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(9) == 10 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(10) == 10 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(16) == 10 && pass1;
|
||||
|
||||
SKIPJACKDecryption dec; // 80-bits only
|
||||
pass2 = dec.StaticGetValidKeyLength(8) == 10 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(9) == 10 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(10) == 10 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(16) == 10 && pass2;
|
||||
cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n";
|
||||
|
||||
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/skipjack.dat", true, new HexDecoder);
|
||||
return BlockTransformationTest(FixedRoundsCipherFactory<SKIPJACKEncryption, SKIPJACKDecryption>(), valdata);
|
||||
return BlockTransformationTest(FixedRoundsCipherFactory<SKIPJACKEncryption, SKIPJACKDecryption>(), valdata) && pass1 && pass2;
|
||||
}
|
||||
|
||||
bool ValidateSEAL()
|
||||
{
|
||||
byte input[] = {0x37,0xa0,0x05,0x95,0x9b,0x84,0xc4,0x9c,0xa4,0xbe,0x1e,0x05,0x06,0x73,0x53,0x0f,0x5f,0xb0,0x97,0xfd,0xf6,0xa1,0x3f,0xbd,0x6c,0x2c,0xde,0xcd,0x81,0xfd,0xee,0x7c};
|
||||
static const byte input[] = {0x37,0xa0,0x05,0x95,0x9b,0x84,0xc4,0x9c,0xa4,0xbe,0x1e,0x05,0x06,0x73,0x53,0x0f,0x5f,0xb0,0x97,0xfd,0xf6,0xa1,0x3f,0xbd,0x6c,0x2c,0xde,0xcd,0x81,0xfd,0xee,0x7c};
|
||||
static const byte key[] = {0x67, 0x45, 0x23, 0x01, 0xef, 0xcd, 0xab, 0x89, 0x98, 0xba, 0xdc, 0xfe, 0x10, 0x32, 0x54, 0x76, 0xc3, 0xd2, 0xe1, 0xf0};
|
||||
static const byte iv[] = {0x01, 0x35, 0x77, 0xaf};
|
||||
byte output[32];
|
||||
byte key[] = {0x67, 0x45, 0x23, 0x01, 0xef, 0xcd, 0xab, 0x89, 0x98, 0xba, 0xdc, 0xfe, 0x10, 0x32, 0x54, 0x76, 0xc3, 0xd2, 0xe1, 0xf0};
|
||||
byte iv[] = {0x01, 0x35, 0x77, 0xaf};
|
||||
|
||||
cout << "\nSEAL validation suite running...\n\n";
|
||||
|
||||
|
|
@ -2692,24 +2959,66 @@ bool ValidateBaseCode()
|
|||
bool ValidateSHACAL2()
|
||||
{
|
||||
cout << "\nSHACAL-2 validation suite running...\n\n";
|
||||
bool pass1 = true, pass2 = true, pass3 = true;
|
||||
|
||||
SHACAL2Encryption enc; // 128 to 512-bits (16 to 64-bytes)
|
||||
pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(15) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(64) == 64 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(65) == 64 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(128) == 64 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(SIZE_MAX) == enc.MaxKeyLength() && pass1;
|
||||
|
||||
SHACAL2Decryption dec; // 128 to 512-bits (16 to 64-bytes)
|
||||
pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(15) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(64) == 64 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(65) == 64 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(128) == 64 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(SIZE_MAX) == dec.MaxKeyLength() && pass2;
|
||||
cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n";
|
||||
|
||||
bool pass = true;
|
||||
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/shacal2v.dat", true, new HexDecoder);
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<SHACAL2Encryption, SHACAL2Decryption>(16), valdata, 4) && pass;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<SHACAL2Encryption, SHACAL2Decryption>(64), valdata, 10) && pass;
|
||||
return pass;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<SHACAL2Encryption, SHACAL2Decryption>(16), valdata, 4) && pass3;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<SHACAL2Encryption, SHACAL2Decryption>(64), valdata, 10) && pass3;
|
||||
return pass1 && pass2 && pass3;
|
||||
}
|
||||
|
||||
bool ValidateCamellia()
|
||||
{
|
||||
cout << "\nCamellia validation suite running...\n\n";
|
||||
bool pass1 = true, pass2 = true, pass3 = true;
|
||||
|
||||
CamelliaEncryption enc;
|
||||
pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1;
|
||||
pass1 = enc.StaticGetValidKeyLength(SIZE_MAX) == enc.MaxKeyLength() && pass1;
|
||||
|
||||
CamelliaDecryption dec;
|
||||
pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2;
|
||||
pass2 = dec.StaticGetValidKeyLength(SIZE_MAX) == dec.MaxKeyLength() && pass2;
|
||||
cout << (pass1 && pass2 ? "passed:" : "FAILED:") << " Algorithm key lengths\n";
|
||||
|
||||
bool pass = true;
|
||||
FileSource valdata(CRYPTOPP_DATA_DIR "TestData/camellia.dat", true, new HexDecoder);
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<CamelliaEncryption, CamelliaDecryption>(16), valdata, 15) && pass;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<CamelliaEncryption, CamelliaDecryption>(24), valdata, 15) && pass;
|
||||
pass = BlockTransformationTest(FixedRoundsCipherFactory<CamelliaEncryption, CamelliaDecryption>(32), valdata, 15) && pass;
|
||||
return pass;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<CamelliaEncryption, CamelliaDecryption>(16), valdata, 15) && pass3;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<CamelliaEncryption, CamelliaDecryption>(24), valdata, 15) && pass3;
|
||||
pass3 = BlockTransformationTest(FixedRoundsCipherFactory<CamelliaEncryption, CamelliaDecryption>(32), valdata, 15) && pass3;
|
||||
return pass1 && pass2 && pass3;
|
||||
}
|
||||
|
||||
bool ValidateSalsa()
|
||||
|
|
|
|||
13
wake.h
13
wake.h
|
|
@ -12,11 +12,13 @@
|
|||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
//! _
|
||||
//! \class WAKE_OFB_Info
|
||||
//! \brief WAKE stream cipher information
|
||||
//! \tparam B Endianess of the stream cipher
|
||||
template <class B = BigEndian>
|
||||
struct WAKE_OFB_Info : public FixedKeyLength<32>
|
||||
{
|
||||
static const char *StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "WAKE-OFB-LE" : "WAKE-OFB-BE";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "WAKE-OFB-LE" : "WAKE-OFB-BE";}
|
||||
};
|
||||
|
||||
class CRYPTOPP_NO_VTABLE WAKE_Base
|
||||
|
|
@ -29,6 +31,9 @@ protected:
|
|||
word32 r3, r4, r5, r6;
|
||||
};
|
||||
|
||||
//! \class WAKE_Policy
|
||||
//! \brief WAKE stream cipher operation
|
||||
//! \tparam B Endianess of the stream cipher
|
||||
template <class B = BigEndian>
|
||||
class CRYPTOPP_NO_VTABLE WAKE_Policy : public AdditiveCipherConcretePolicy<word32, 1, 64>, protected WAKE_Base
|
||||
{
|
||||
|
|
@ -39,7 +44,9 @@ protected:
|
|||
bool CipherIsRandomAccess() const {return false;}
|
||||
};
|
||||
|
||||
//! WAKE-OFB
|
||||
//! \class WAKE_OFB
|
||||
//! \brief WAKE stream cipher
|
||||
//! \tparam B Endianess of the stream cipher
|
||||
template <class B = BigEndian>
|
||||
struct WAKE_OFB : public WAKE_OFB_Info<B>, public SymmetricCipherDocumentation
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public:
|
|||
static void InitState(HashWordType *state);
|
||||
static void Transform(word64 *digest, const word64 *data);
|
||||
void TruncatedFinal(byte *hash, size_t size);
|
||||
static const char * StaticAlgorithmName() {return "Whirlpool";}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Whirlpool";}
|
||||
};
|
||||
|
||||
NAMESPACE_END
|
||||
|
|
|
|||
Loading…
Reference in New Issue