move MD2, MD4, MD5, PanamaHash, WAKE_CFB into the namespace 'Weak'
parent
837bc18cba
commit
45fab64526
3
md2.cpp
3
md2.cpp
|
|
@ -15,9 +15,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
|
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK
|
||||||
#include "md2.h"
|
#include "md2.h"
|
||||||
|
|
||||||
NAMESPACE_BEGIN(CryptoPP)
|
NAMESPACE_BEGIN(CryptoPP)
|
||||||
|
namespace Weak {
|
||||||
|
|
||||||
MD2::MD2()
|
MD2::MD2()
|
||||||
: m_X(48), m_C(16), m_buf(16)
|
: m_X(48), m_C(16), m_buf(16)
|
||||||
|
|
@ -114,4 +116,5 @@ void MD2::TruncatedFinal(byte *hash, size_t size)
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
NAMESPACE_END
|
NAMESPACE_END
|
||||||
|
|
|
||||||
15
md2.h
15
md2.h
|
|
@ -6,8 +6,9 @@
|
||||||
|
|
||||||
NAMESPACE_BEGIN(CryptoPP)
|
NAMESPACE_BEGIN(CryptoPP)
|
||||||
|
|
||||||
/// <a href="http://www.weidai.com/scan-mirror/md.html#MD2">MD2</a>
|
namespace Weak {
|
||||||
/** 128 Bit Hash */
|
|
||||||
|
/// <a href="http://www.cryptolounge.org/wiki/MD2">MD2</a>
|
||||||
class MD2 : public HashTransformation
|
class MD2 : public HashTransformation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -28,6 +29,16 @@ private:
|
||||||
unsigned int m_count;
|
unsigned int m_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#ifndef CRYPTOPP_ENABLE_NAMESPACE_WEAK
|
||||||
|
using namespace Weak;
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#warning "You may be using a weak algorithm that has been retained for backwards compatibility. Please define CRYPTOPP_ENABLE_NAMESPACE_WEAK and prepend the class name with 'Weak::' to remove this warning."
|
||||||
|
#else
|
||||||
|
#pragma message("You may be using a weak algorithm that has been retained for backwards compatibility. Please define CRYPTOPP_ENABLE_NAMESPACE_WEAK and prepend the class name with 'Weak::' to remove this warning.")
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
NAMESPACE_END
|
NAMESPACE_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
3
md4.cpp
3
md4.cpp
|
|
@ -15,10 +15,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
|
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK
|
||||||
#include "md4.h"
|
#include "md4.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
NAMESPACE_BEGIN(CryptoPP)
|
NAMESPACE_BEGIN(CryptoPP)
|
||||||
|
namespace Weak {
|
||||||
|
|
||||||
void MD4::InitState(HashWordType *state)
|
void MD4::InitState(HashWordType *state)
|
||||||
{
|
{
|
||||||
|
|
@ -104,4 +106,5 @@ void MD4::Transform (word32 *digest, const word32 *in)
|
||||||
digest[3]+=D;
|
digest[3]+=D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
NAMESPACE_END
|
NAMESPACE_END
|
||||||
|
|
|
||||||
12
md4.h
12
md4.h
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
NAMESPACE_BEGIN(CryptoPP)
|
NAMESPACE_BEGIN(CryptoPP)
|
||||||
|
|
||||||
|
namespace Weak {
|
||||||
|
|
||||||
//! <a href="http://www.weidai.com/scan-mirror/md.html#MD4">MD4</a>
|
//! <a href="http://www.weidai.com/scan-mirror/md.html#MD4">MD4</a>
|
||||||
/*! \warning MD4 is considered insecure, and should not be used
|
/*! \warning MD4 is considered insecure, and should not be used
|
||||||
unless you absolutely need it for compatibility. */
|
unless you absolutely need it for compatibility. */
|
||||||
|
|
@ -16,6 +18,16 @@ public:
|
||||||
static const char *StaticAlgorithmName() {return "MD4";}
|
static const char *StaticAlgorithmName() {return "MD4";}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#ifndef CRYPTOPP_ENABLE_NAMESPACE_WEAK
|
||||||
|
using namespace Weak;
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#warning "You may be using a weak algorithm that has been retained for backwards compatibility. Please define CRYPTOPP_ENABLE_NAMESPACE_WEAK and prepend the class name with 'Weak::' to remove this warning."
|
||||||
|
#else
|
||||||
|
#pragma message("You may be using a weak algorithm that has been retained for backwards compatibility. Please define CRYPTOPP_ENABLE_NAMESPACE_WEAK and prepend the class name with 'Weak::' to remove this warning.")
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
NAMESPACE_END
|
NAMESPACE_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
3
md5.cpp
3
md5.cpp
|
|
@ -2,10 +2,12 @@
|
||||||
// any modifications are placed in the public domain
|
// any modifications are placed in the public domain
|
||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
|
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK
|
||||||
#include "md5.h"
|
#include "md5.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
NAMESPACE_BEGIN(CryptoPP)
|
NAMESPACE_BEGIN(CryptoPP)
|
||||||
|
namespace Weak {
|
||||||
|
|
||||||
void MD5_TestInstantiations()
|
void MD5_TestInstantiations()
|
||||||
{
|
{
|
||||||
|
|
@ -112,4 +114,5 @@ void MD5::Transform (word32 *digest, const word32 *in)
|
||||||
digest[3]+=d;
|
digest[3]+=d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
NAMESPACE_END
|
NAMESPACE_END
|
||||||
|
|
|
||||||
16
md5.h
16
md5.h
|
|
@ -5,9 +5,9 @@
|
||||||
|
|
||||||
NAMESPACE_BEGIN(CryptoPP)
|
NAMESPACE_BEGIN(CryptoPP)
|
||||||
|
|
||||||
//! <a href="http://www.weidai.com/scan-mirror/md.html#MD5">MD5</a>
|
namespace Weak {
|
||||||
/*! \warning MD5 is considered insecure, and should not be used
|
|
||||||
unless you absolutely need it for compatibility. */
|
//! <a href="http://www.cryptolounge.org/wiki/MD5">MD5</a>
|
||||||
class MD5 : public IteratedHashWithStaticTransform<word32, LittleEndian, 64, 16, MD5>
|
class MD5 : public IteratedHashWithStaticTransform<word32, LittleEndian, 64, 16, MD5>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -16,6 +16,16 @@ public:
|
||||||
static const char * StaticAlgorithmName() {return "MD5";}
|
static const char * StaticAlgorithmName() {return "MD5";}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#ifndef CRYPTOPP_ENABLE_NAMESPACE_WEAK
|
||||||
|
using namespace Weak;
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#warning "You may be using a weak algorithm that has been retained for backwards compatibility. Please define CRYPTOPP_ENABLE_NAMESPACE_WEAK and prepend the class name with 'Weak::' to remove this warning."
|
||||||
|
#else
|
||||||
|
#pragma message("You may be using a weak algorithm that has been retained for backwards compatibility. Please define CRYPTOPP_ENABLE_NAMESPACE_WEAK and prepend the class name with 'Weak::' to remove this warning.")
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
NAMESPACE_END
|
NAMESPACE_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
27
wake.cpp
27
wake.cpp
|
|
@ -7,8 +7,8 @@ NAMESPACE_BEGIN(CryptoPP)
|
||||||
|
|
||||||
void WAKE_TestInstantiations()
|
void WAKE_TestInstantiations()
|
||||||
{
|
{
|
||||||
WAKE_CFB<>::Encryption x1;
|
Weak::WAKE_CFB<>::Encryption x1;
|
||||||
WAKE_CFB<>::Decryption x3;
|
Weak::WAKE_CFB<>::Decryption x3;
|
||||||
WAKE_OFB<>::Encryption x2;
|
WAKE_OFB<>::Encryption x2;
|
||||||
WAKE_OFB<>::Decryption x4;
|
WAKE_OFB<>::Decryption x4;
|
||||||
}
|
}
|
||||||
|
|
@ -85,16 +85,21 @@ void WAKE_Policy<B>::Iterate(byte *output, const byte *input, CipherDir dir, siz
|
||||||
template <class B>
|
template <class B>
|
||||||
void WAKE_Policy<B>::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount)
|
void WAKE_Policy<B>::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount)
|
||||||
{
|
{
|
||||||
KeystreamOutput<B> keystreamOperation(operation, output, input);
|
#define WAKE_OUTPUT(x)\
|
||||||
|
while (iterationCount--)\
|
||||||
while (iterationCount--)
|
{\
|
||||||
{
|
CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, B::ToEnum(), 0, r6);\
|
||||||
keystreamOperation(r6);
|
r3 = M(r3, r6);\
|
||||||
r3 = M(r3, r6);
|
r4 = M(r4, r3);\
|
||||||
r4 = M(r4, r3);
|
r5 = M(r5, r4);\
|
||||||
r5 = M(r5, r4);
|
r6 = M(r6, r5);\
|
||||||
r6 = M(r6, r5);
|
output += 4;\
|
||||||
|
if (x == XOR_KEYSTREAM)\
|
||||||
|
input += 4;\
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef word32 WordType;
|
||||||
|
CRYPTOPP_KEYSTREAM_OUTPUT_SWITCH(WAKE_OUTPUT, 0);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
template <class B>
|
template <class B>
|
||||||
|
|
|
||||||
4
wake.h
4
wake.h
|
|
@ -47,13 +47,15 @@ protected:
|
||||||
bool IsRandomAccess() const {return false;}
|
bool IsRandomAccess() const {return false;}
|
||||||
};
|
};
|
||||||
|
|
||||||
//! <a href="http://www.weidai.com/scan-mirror/cs.html#WAKE-CFB-BE">WAKE-CFB-BE</a>
|
namespace Weak {
|
||||||
|
//! <a href="http://www.cryptolounge.org/wiki/WAKE">WAKE-CFB-BE</a>
|
||||||
template <class B = BigEndian>
|
template <class B = BigEndian>
|
||||||
struct WAKE_CFB : public WAKE_CFB_Info<B>, public SymmetricCipherDocumentation
|
struct WAKE_CFB : public WAKE_CFB_Info<B>, public SymmetricCipherDocumentation
|
||||||
{
|
{
|
||||||
typedef SymmetricCipherFinal<ConcretePolicyHolder<WAKE_Policy<B>, CFB_EncryptionTemplate<> >, WAKE_CFB_Info<B> > Encryption;
|
typedef SymmetricCipherFinal<ConcretePolicyHolder<WAKE_Policy<B>, CFB_EncryptionTemplate<> >, WAKE_CFB_Info<B> > Encryption;
|
||||||
typedef SymmetricCipherFinal<ConcretePolicyHolder<WAKE_Policy<B>, CFB_DecryptionTemplate<> >, WAKE_CFB_Info<B> > Decryption;
|
typedef SymmetricCipherFinal<ConcretePolicyHolder<WAKE_Policy<B>, CFB_DecryptionTemplate<> >, WAKE_CFB_Info<B> > Decryption;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
//! WAKE-OFB
|
//! WAKE-OFB
|
||||||
template <class B = BigEndian>
|
template <class B = BigEndian>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue