summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2007-04-16 21:27:41 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2007-04-16 21:27:41 +0000
commit9e4d75dae49a12568ca06135b1beb07ebf6def2d (patch)
tree81e5d1810a0a25fa10d3067481851de431fe4086
parentf97f957e48a69ca40674a05cd50ec66a6f3d8c18 (diff)
downloadcryptopp-9e4d75dae49a12568ca06135b1beb07ebf6def2d.tar.gz
move ARC4 into Weak namespace
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@326 57ff6487-cd31-0410-9ec3-f628ee90f5f0
-rw-r--r--Readme.txt2
-rw-r--r--arc4.cpp3
-rw-r--r--arc4.h12
-rw-r--r--bench.cpp5
-rw-r--r--regtest.cpp2
-rw-r--r--validat1.cpp13
6 files changed, 27 insertions, 10 deletions
diff --git a/Readme.txt b/Readme.txt
index b6e3d5a..84751c1 100644
--- a/Readme.txt
+++ b/Readme.txt
@@ -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
diff --git a/arc4.cpp b/arc4.cpp
index b78b756..0beeb24 100644
--- a/arc4.cpp
+++ b/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
diff --git a/arc4.h b/arc4.h
index 78f85cd..1942caf 100644
--- a/arc4.h
+++ b/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
diff --git a/bench.cpp b/bench.cpp
index cb9b56b..ee95613 100644
--- a/bench.cpp
+++ b/bench.cpp
@@ -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);
diff --git a/regtest.cpp b/regtest.cpp
index a029b01..ba46633 100644
--- a/regtest.cpp
+++ b/regtest.cpp
@@ -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;
}
diff --git a/validat1.cpp b/validat1.cpp
index b35a55a..c68adad 100644
--- a/validat1.cpp
+++ b/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;