move ARC4 into Weak namespace
parent
3a3fef7436
commit
deb3228e83
|
|
@ -371,7 +371,7 @@ the mailing list.
|
|||
- enabled optimization flags by default in GNUmakefile
|
||||
- changed PANAMA cipher interface to accept 256-bit key and 256-bit IV
|
||||
- added blinding and error checking for RW private key operation
|
||||
- moved MD2, MD4, MD5, PanamaHash, WAKE_CFB into the namespace "Weak"
|
||||
- moved MD2, MD4, MD5, PanamaHash, ARC4, WAKE_CFB into the namespace "Weak"
|
||||
- removed HAVAL, MD5-MAC, XMAC
|
||||
|
||||
Written by Wei Dai
|
||||
|
|
|
|||
3
arc4.cpp
3
arc4.cpp
|
|
@ -7,9 +7,11 @@
|
|||
// completely in the public domain.
|
||||
|
||||
#include "pch.h"
|
||||
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK
|
||||
#include "arc4.h"
|
||||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
namespace Weak {
|
||||
|
||||
void ARC4_TestInstantiations()
|
||||
{
|
||||
|
|
@ -113,4 +115,5 @@ void ARC4_Base::DiscardBytes(size_t length)
|
|||
m_y = y;
|
||||
}
|
||||
|
||||
}
|
||||
NAMESPACE_END
|
||||
|
|
|
|||
12
arc4.h
12
arc4.h
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
namespace Weak {
|
||||
|
||||
//! _
|
||||
class CRYPTOPP_NO_VTABLE ARC4_Base : public VariableKeyLength<16, 1, 256>, public RandomNumberGenerator, public SymmetricCipher, public SymmetricCipherDocumentation
|
||||
{
|
||||
|
|
@ -52,6 +54,16 @@ protected:
|
|||
//! Modified ARC4: it discards the first 256 bytes of keystream which may be weaker than the rest
|
||||
DOCUMENTED_TYPEDEF(SymmetricCipherFinal<MARC4_Base>, MARC4)
|
||||
|
||||
}
|
||||
#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
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
#include "adler32.h"
|
||||
#include "idea.h"
|
||||
#include "des.h"
|
||||
#include "arc4.h"
|
||||
#include "rc5.h"
|
||||
#include "blowfish.h"
|
||||
#include "wake.h"
|
||||
|
|
@ -280,7 +279,7 @@ void BenchmarkAll(double t, double hertz)
|
|||
cout << "\n<TBODY style=\"background: yellow\">";
|
||||
BenchMarkKeyless<CRC32>("CRC-32", t);
|
||||
BenchMarkKeyless<Adler32>("Adler-32", t);
|
||||
BenchMarkByNameKeyLess<HashTransformation>("MD5", "MD5 (broken)");
|
||||
BenchMarkByNameKeyLess<HashTransformation>("MD5", "MD5 (weak)");
|
||||
BenchMarkByNameKeyLess<HashTransformation>("SHA-1");
|
||||
BenchMarkByNameKeyLess<HashTransformation>("SHA-256");
|
||||
#ifdef WORD64_AVAILABLE
|
||||
|
|
@ -300,7 +299,7 @@ void BenchmarkAll(double t, double hertz)
|
|||
BenchMarkByName<SymmetricCipher>("Salsa20", 0, "Salsa20/12", MakeParameters(Name::Rounds(), 12));
|
||||
BenchMarkByName<SymmetricCipher>("Salsa20", 0, "Salsa20/8", MakeParameters(Name::Rounds(), 8));
|
||||
BenchMarkByName<SymmetricCipher>("Sosemanuk");
|
||||
BenchMarkKeyed<ARC4>("ARC4", t);
|
||||
BenchMarkByName<SymmetricCipher>("MARC4");
|
||||
BenchMarkKeyed<SEAL<BigEndian>::Encryption>("SEAL-3.0-BE", t);
|
||||
BenchMarkKeyed<SEAL<LittleEndian>::Encryption>("SEAL-3.0-LE", t);
|
||||
BenchMarkKeyed<WAKE_OFB<BigEndian>::Encryption>("WAKE-OFB-BE", t);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "tiger.h"
|
||||
#include "md5.h"
|
||||
#include "sosemanuk.h"
|
||||
#include "arc4.h"
|
||||
|
||||
USING_NAMESPACE(CryptoPP)
|
||||
|
||||
|
|
@ -82,6 +83,7 @@ void RegisterFactories()
|
|||
RegisterSymmetricCipherDefaultFactories<CTR_Mode<AES> >();
|
||||
RegisterSymmetricCipherDefaultFactories<Salsa20>();
|
||||
RegisterSymmetricCipherDefaultFactories<Sosemanuk>();
|
||||
RegisterSymmetricCipherDefaultFactories<Weak::MARC4>();
|
||||
|
||||
s_registered = true;
|
||||
}
|
||||
|
|
|
|||
13
validat1.cpp
13
validat1.cpp
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "pch.h"
|
||||
|
||||
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK
|
||||
#include "files.h"
|
||||
#include "hex.h"
|
||||
#include "base32.h"
|
||||
|
|
@ -991,39 +992,39 @@ bool ValidateARC4()
|
|||
0xc0};
|
||||
|
||||
// VC60 workaround: auto_ptr lacks reset()
|
||||
member_ptr<ARC4> arc4;
|
||||
member_ptr<Weak::ARC4> arc4;
|
||||
bool pass=true, fail;
|
||||
int i;
|
||||
|
||||
cout << "\nARC4 validation suite running...\n\n";
|
||||
|
||||
arc4.reset(new ARC4(Key0, sizeof(Key0)));
|
||||
arc4.reset(new Weak::ARC4(Key0, sizeof(Key0)));
|
||||
arc4->ProcessString(Input0, sizeof(Input0));
|
||||
fail = memcmp(Input0, Output0, sizeof(Input0)) != 0;
|
||||
cout << (fail ? "FAILED" : "passed") << " Test 0" << endl;
|
||||
pass = pass && !fail;
|
||||
|
||||
arc4.reset(new ARC4(Key1, sizeof(Key1)));
|
||||
arc4.reset(new Weak::ARC4(Key1, sizeof(Key1)));
|
||||
arc4->ProcessString(Key1, Input1, sizeof(Key1));
|
||||
fail = memcmp(Output1, Key1, sizeof(Key1)) != 0;
|
||||
cout << (fail ? "FAILED" : "passed") << " Test 1" << endl;
|
||||
pass = pass && !fail;
|
||||
|
||||
arc4.reset(new ARC4(Key2, sizeof(Key2)));
|
||||
arc4.reset(new Weak::ARC4(Key2, sizeof(Key2)));
|
||||
for (i=0, fail=false; i<sizeof(Input2); i++)
|
||||
if (arc4->ProcessByte(Input2[i]) != Output2[i])
|
||||
fail = true;
|
||||
cout << (fail ? "FAILED" : "passed") << " Test 2" << endl;
|
||||
pass = pass && !fail;
|
||||
|
||||
arc4.reset(new ARC4(Key3, sizeof(Key3)));
|
||||
arc4.reset(new Weak::ARC4(Key3, sizeof(Key3)));
|
||||
for (i=0, fail=false; i<sizeof(Input3); i++)
|
||||
if (arc4->ProcessByte(Input3[i]) != Output3[i])
|
||||
fail = true;
|
||||
cout << (fail ? "FAILED" : "passed") << " Test 3" << endl;
|
||||
pass = pass && !fail;
|
||||
|
||||
arc4.reset(new ARC4(Key4, sizeof(Key4)));
|
||||
arc4.reset(new Weak::ARC4(Key4, sizeof(Key4)));
|
||||
for (i=0, fail=false; i<sizeof(Input4); i++)
|
||||
if (arc4->ProcessByte(Input4[i]) != Output4[i])
|
||||
fail = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue