summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Readme.txt4
-rw-r--r--algparam.h14
-rw-r--r--argnames.h11
-rw-r--r--base64.cpp16
-rw-r--r--base64.h2
-rw-r--r--basecode.cpp20
-rw-r--r--basecode.h19
-rw-r--r--bench.cpp38
-rw-r--r--cryptdll.dsp4
-rw-r--r--cryptest.dsp8
-rw-r--r--cryptlib.cpp6
-rw-r--r--cryptlib.dsp14
-rw-r--r--cryptlib.h8
-rw-r--r--datatest.cpp6
-rw-r--r--dlltest.dsp6
-rw-r--r--hex.cpp13
-rw-r--r--hex.h8
-rw-r--r--modes.h17
-rw-r--r--network.h4
-rw-r--r--oaep.cpp6
-rw-r--r--rsa.cpp11
-rw-r--r--stdcpp.h2
-rw-r--r--test.cpp30
-rw-r--r--usage.dat3
-rw-r--r--validat1.cpp20
25 files changed, 191 insertions, 99 deletions
diff --git a/Readme.txt b/Readme.txt
index e449bb5..44b32d7 100644
--- a/Readme.txt
+++ b/Readme.txt
@@ -264,4 +264,6 @@ History
5.2 - Merged in changes for 5.01 - 5.0.4
- added support for using encoding parameters and key derivation parameters
- with public key encryption (implemented by OAEP and DLIES)
+ with public key encryption (implemented by OAEP and DL/ECIES)
+ - added Camellia, SHACAL-2, Two-Track-MAC, Whirlpool, RIPEMD-320,
+ RIPEMD-128, RIPEMD-256, Base 32 coding
diff --git a/algparam.h b/algparam.h
index 95a9077..b6f2102 100644
--- a/algparam.h
+++ b/algparam.h
@@ -67,7 +67,7 @@ private:
unsigned int m_size;
};
-class CombinedNameValuePairs : public NameValuePairs
+class CRYPTOPP_DLL CombinedNameValuePairs : public NameValuePairs
{
public:
CombinedNameValuePairs(const NameValuePairs &pairs1, const NameValuePairs &pairs2)
@@ -323,6 +323,12 @@ public:
return AlgorithmParameters<AlgorithmParameters<PARENT,T>, R>(*this, name, value, m_throwIfNotUsed);
}
+ template <class R>
+ AlgorithmParameters<AlgorithmParameters<PARENT,T>, R> operator()(const char *name, const R &value, bool throwIfNotUsed) const
+ {
+ return AlgorithmParameters<AlgorithmParameters<PARENT,T>, R>(*this, name, value, throwIfNotUsed);
+ }
+
private:
const NameValuePairs & GetParent() const {return m_parent;}
PARENT m_parent;
@@ -331,7 +337,11 @@ private:
//! Create an object that implements NameValuePairs for passing parameters
/*! \param throwIfNotUsed if true, the object will throw an exception if the value is not accessed
\note throwIfNotUsed is ignored if using a compiler that does not support std::uncaught_exception(),
- such as MSVC 7.0 and earlier. */
+ such as MSVC 7.0 and earlier.
+ \note A NameValuePairs object containing an arbitrary number of name value pairs may be constructed by
+ repeatedly using operator() on the object returned by MakeParameters, for example:
+ const NameValuePairs &parameters = MakeParameters(name1, value1)(name2, value2)(name3, value3);
+*/
template <class T>
AlgorithmParameters<NullNameValuePairs,T> MakeParameters(const char *name, const T &value, bool throwIfNotUsed = true)
{
diff --git a/argnames.h b/argnames.h
index d5ac705..eb35b68 100644
--- a/argnames.h
+++ b/argnames.h
@@ -55,6 +55,17 @@ CRYPTOPP_DEFINE_NAME_STRING(OutputStreamPointer) //!< std::ostream *
CRYPTOPP_DEFINE_NAME_STRING(OutputBinaryMode) //!< bool
CRYPTOPP_DEFINE_NAME_STRING(EncodingParameters) //!< ConstByteArrayParameter
CRYPTOPP_DEFINE_NAME_STRING(KeyDerivationParameters) //!< ConstByteArrayParameter
+CRYPTOPP_DEFINE_NAME_STRING(Separator) //< ConstByteArrayParameter
+CRYPTOPP_DEFINE_NAME_STRING(Terminator) //< ConstByteArrayParameter
+CRYPTOPP_DEFINE_NAME_STRING(Uppercase) //< bool
+CRYPTOPP_DEFINE_NAME_STRING(GroupSize) //< int
+CRYPTOPP_DEFINE_NAME_STRING(Pad) //< bool
+CRYPTOPP_DEFINE_NAME_STRING(PaddingByte) //< byte
+CRYPTOPP_DEFINE_NAME_STRING(Log2Base) //< int
+CRYPTOPP_DEFINE_NAME_STRING(EncodingLookupArray) //< const byte *
+CRYPTOPP_DEFINE_NAME_STRING(DecodingLookupArray) //< const byte *
+CRYPTOPP_DEFINE_NAME_STRING(InsertLineBreaks) //< bool
+CRYPTOPP_DEFINE_NAME_STRING(MaxLineLength) //< int
DOCUMENTED_NAMESPACE_END
diff --git a/base64.cpp b/base64.cpp
index 2670155..f86dc6e 100644
--- a/base64.cpp
+++ b/base64.cpp
@@ -11,19 +11,19 @@ static const byte s_padding = '=';
void Base64Encoder::IsolatedInitialize(const NameValuePairs &parameters)
{
- bool insertLineBreaks = parameters.GetValueWithDefault("InsertLineBreaks", true);
- int maxLineLength = parameters.GetIntValueWithDefault("MaxLineLength", 72);
+ bool insertLineBreaks = parameters.GetValueWithDefault(Name::InsertLineBreaks(), true);
+ int maxLineLength = parameters.GetIntValueWithDefault(Name::MaxLineLength(), 72);
const char *lineBreak = insertLineBreaks ? "\n" : "";
m_filter->Initialize(CombinedNameValuePairs(
parameters,
- MakeParameters("EncodingLookupArray", (const byte *)s_vec)
- ("PaddingByte", s_padding)
- ("Log2Base", 6)
- ("GroupSize", insertLineBreaks ? maxLineLength : 0)
- ("Separator", ConstByteArrayParameter(lineBreak))
- ("Terminator", ConstByteArrayParameter(lineBreak))));
+ MakeParameters(Name::EncodingLookupArray(), &s_vec[0], false)
+ (Name::PaddingByte(), s_padding)
+ (Name::GroupSize(), insertLineBreaks ? maxLineLength : 0)
+ (Name::Separator(), ConstByteArrayParameter(lineBreak))
+ (Name::Terminator(), ConstByteArrayParameter(lineBreak))
+ (Name::Log2Base(), 6, true)));
}
const int *Base64Decoder::GetDecodingLookupArray()
diff --git a/base64.h b/base64.h
index 33072a0..b9ba801 100644
--- a/base64.h
+++ b/base64.h
@@ -12,7 +12,7 @@ public:
Base64Encoder(BufferedTransformation *attachment = NULL, bool insertLineBreaks = true, int maxLineLength = 72)
: SimpleProxyFilter(new BaseN_Encoder(new Grouper), attachment)
{
- IsolatedInitialize(MakeParameters("InsertLineBreaks", insertLineBreaks)("MaxLineLength", maxLineLength));
+ IsolatedInitialize(MakeParameters(Name::InsertLineBreaks(), insertLineBreaks)(Name::MaxLineLength(), maxLineLength));
}
void IsolatedInitialize(const NameValuePairs &parameters);
diff --git a/basecode.cpp b/basecode.cpp
index 8b42073..e439e10 100644
--- a/basecode.cpp
+++ b/basecode.cpp
@@ -12,16 +12,16 @@ NAMESPACE_BEGIN(CryptoPP)
void BaseN_Encoder::IsolatedInitialize(const NameValuePairs &parameters)
{
- parameters.GetRequiredParameter("BaseN_Encoder", "EncodingLookupArray", m_alphabet);
+ parameters.GetRequiredParameter("BaseN_Encoder", Name::EncodingLookupArray(), m_alphabet);
- parameters.GetRequiredIntParameter("BaseN_Encoder", "Log2Base", m_bitsPerChar);
+ parameters.GetRequiredIntParameter("BaseN_Encoder", Name::Log2Base(), m_bitsPerChar);
if (m_bitsPerChar <= 0 || m_bitsPerChar >= 8)
throw InvalidArgument("BaseN_Encoder: Log2Base must be between 1 and 7 inclusive");
byte padding;
bool pad;
- if (parameters.GetValue("PaddingByte", padding))
- pad = parameters.GetValueWithDefault("Pad", true);
+ if (parameters.GetValue(Name::PaddingByte(), padding))
+ pad = parameters.GetValueWithDefault(Name::Pad(), true);
else
pad = false;
m_padding = pad ? padding : -1;
@@ -105,9 +105,9 @@ unsigned int BaseN_Encoder::Put2(const byte *begin, unsigned int length, int mes
void BaseN_Decoder::IsolatedInitialize(const NameValuePairs &parameters)
{
- parameters.GetRequiredParameter("BaseN_Decoder", "DecodingLookupArray", m_lookup);
+ parameters.GetRequiredParameter("BaseN_Decoder", Name::DecodingLookupArray(), m_lookup);
- parameters.GetRequiredIntParameter("BaseN_Decoder", "Log2Base", m_bitsPerChar);
+ parameters.GetRequiredIntParameter("BaseN_Decoder", Name::Log2Base(), m_bitsPerChar);
if (m_bitsPerChar <= 0 || m_bitsPerChar >= 8)
throw InvalidArgument("BaseN_Decoder: Log2Base must be between 1 and 7 inclusive");
@@ -189,13 +189,13 @@ void BaseN_Decoder::InitializeDecodingLookupArray(int *lookup, const byte *alpha
void Grouper::IsolatedInitialize(const NameValuePairs &parameters)
{
- m_groupSize = parameters.GetIntValueWithDefault("GroupSize", 0);
+ m_groupSize = parameters.GetIntValueWithDefault(Name::GroupSize(), 0);
ConstByteArrayParameter separator, terminator;
if (m_groupSize)
- parameters.GetRequiredParameter("Grouper", "Separator", separator);
+ parameters.GetRequiredParameter("Grouper", Name::Separator(), separator);
else
- parameters.GetValue("Separator", separator);
- parameters.GetValue("Terminator", terminator);
+ parameters.GetValue(Name::Separator(), separator);
+ parameters.GetValue(Name::Terminator(), terminator);
m_separator.Assign(separator.begin(), separator.size());
m_terminator.Assign(terminator.begin(), terminator.size());
diff --git a/basecode.h b/basecode.h
index b2e53b6..d1fa3b5 100644
--- a/basecode.h
+++ b/basecode.h
@@ -3,6 +3,7 @@
#include "filters.h"
#include "algparam.h"
+#include "argnames.h"
NAMESPACE_BEGIN(CryptoPP)
@@ -15,10 +16,10 @@ public:
BaseN_Encoder(const byte *alphabet, int log2base, BufferedTransformation *attachment=NULL, int padding=-1)
: Unflushable<Filter>(attachment)
{
- IsolatedInitialize(MakeParameters("EncodingLookupArray", alphabet)
- ("Log2Base", log2base)
- ("Pad", padding != -1)
- ("PaddingByte", byte(padding)));
+ IsolatedInitialize(MakeParameters(Name::EncodingLookupArray(), alphabet)
+ (Name::Log2Base(), log2base)
+ (Name::Pad(), padding != -1)
+ (Name::PaddingByte(), byte(padding)));
}
void IsolatedInitialize(const NameValuePairs &parameters);
@@ -40,13 +41,13 @@ public:
BaseN_Decoder(const int *lookup, int log2base, BufferedTransformation *attachment=NULL)
: Unflushable<Filter>(attachment)
{
- IsolatedInitialize(MakeParameters("DecodingLookupArray", lookup)("Log2Base", log2base));
+ IsolatedInitialize(MakeParameters(Name::DecodingLookupArray(), lookup)(Name::Log2Base(), log2base));
}
void IsolatedInitialize(const NameValuePairs &parameters);
unsigned int Put2(const byte *begin, unsigned int length, int messageEnd, bool blocking);
- static void InitializeDecodingLookupArray(int *lookup, const byte *alphabet, unsigned int log2base, bool caseInsensitive);
+ static void InitializeDecodingLookupArray(int *lookup, const byte *alphabet, unsigned int base, bool caseInsensitive);
private:
const int *m_lookup;
@@ -64,9 +65,9 @@ public:
Grouper(int groupSize, const std::string &separator, const std::string &terminator, BufferedTransformation *attachment=NULL)
: Bufferless<Filter>(attachment)
{
- IsolatedInitialize(MakeParameters("GroupSize", groupSize)
- ("Separator", ConstByteArrayParameter(separator))
- ("Terminator", ConstByteArrayParameter(terminator)));
+ IsolatedInitialize(MakeParameters(Name::GroupSize(), groupSize)
+ (Name::Separator(), ConstByteArrayParameter(separator))
+ (Name::Terminator(), ConstByteArrayParameter(terminator)));
}
void IsolatedInitialize(const NameValuePairs &parameters);
diff --git a/bench.cpp b/bench.cpp
index 8670d37..82f8446 100644
--- a/bench.cpp
+++ b/bench.cpp
@@ -87,11 +87,11 @@ static const byte *const key=(byte *)"0123456789abcdefghijklmnopqrstuvwxyzABCDEF
static double logtotal = 0;
static unsigned int logcount = 0;
-void OutputResultBytes(const char *name, unsigned long length, double timeTaken)
+void OutputResultBytes(const char *name, double length, double timeTaken)
{
double mbs = length / timeTaken / (1024*1024);
cout << "<TR><TH>" << name;
- cout << "<TD>" << length;
+ cout << "<TD>" << setprecision(3) << length / (1024*1024);
cout << setiosflags(ios::fixed);
cout << "<TD>" << setprecision(3) << timeTaken;
cout << "<TD>" << setprecision(3) << mbs << endl;
@@ -120,18 +120,18 @@ void BenchMark(const char *name, BlockTransformation &cipher, double timeTotal)
const int nBlocks = BUF_SIZE / cipher.BlockSize();
clock_t start = clock();
- unsigned long i=0, length=BUF_SIZE;
+ unsigned long i=0, blocks=1;
double timeTaken;
do
{
- length *= 2;
- for (; i<length; i+=BUF_SIZE)
+ blocks *= 2;
+ for (; i<blocks; i++)
cipher.ProcessAndXorMultipleBlocks(buf, NULL, buf, nBlocks);
timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND;
}
while (timeTaken < 2.0/3*timeTotal);
- OutputResultBytes(name, length, timeTaken);
+ OutputResultBytes(name, double(blocks) * BUF_SIZE, timeTaken);
}
void BenchMark(const char *name, StreamTransformation &cipher, double timeTotal)
@@ -140,18 +140,18 @@ void BenchMark(const char *name, StreamTransformation &cipher, double timeTotal)
SecByteBlock buf(BUF_SIZE);
clock_t start = clock();
- unsigned long i=0, length=BUF_SIZE;
+ unsigned long i=0, blocks=1;
double timeTaken;
do
{
- length *= 2;
- for (; i<length; i+=BUF_SIZE)
+ blocks *= 2;
+ for (; i<blocks; i++)
cipher.ProcessString(buf, BUF_SIZE);
timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND;
}
while (timeTaken < 2.0/3*timeTotal);
- OutputResultBytes(name, length, timeTaken);
+ OutputResultBytes(name, double(blocks) * BUF_SIZE, timeTaken);
}
void BenchMark(const char *name, HashTransformation &hash, double timeTotal)
@@ -162,18 +162,18 @@ void BenchMark(const char *name, HashTransformation &hash, double timeTotal)
rng.GenerateBlock(buf, BUF_SIZE);
clock_t start = clock();
- unsigned long i=0, length=BUF_SIZE;
+ unsigned long i=0, blocks=1;
double timeTaken;
do
{
- length *= 2;
- for (; i<length; i+=BUF_SIZE)
+ blocks *= 2;
+ for (; i<blocks; i++)
hash.Update(buf, BUF_SIZE);
timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND;
}
while (timeTaken < 2.0/3*timeTotal);
- OutputResultBytes(name, length, timeTaken);
+ OutputResultBytes(name, double(blocks) * BUF_SIZE, timeTaken);
}
void BenchMark(const char *name, BufferedTransformation &bt, double timeTotal)
@@ -184,18 +184,18 @@ void BenchMark(const char *name, BufferedTransformation &bt, double timeTotal)
rng.GenerateBlock(buf, BUF_SIZE);
clock_t start = clock();
- unsigned long i=0, length=BUF_SIZE;
+ unsigned long i=0, blocks=1;
double timeTaken;
do
{
- length *= 2;
- for (; i<length; i+=BUF_SIZE)
+ blocks *= 2;
+ for (; i<blocks; i++)
bt.Put(buf, BUF_SIZE);
timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND;
}
while (timeTaken < 2.0/3*timeTotal);
- OutputResultBytes(name, length, timeTaken);
+ OutputResultBytes(name, double(blocks) * BUF_SIZE, timeTaken);
}
void BenchMarkEncryption(const char *name, PK_Encryptor &key, double timeTotal, bool pc=false)
@@ -434,7 +434,7 @@ void BenchMarkAll(double t)
logcount = 0;
cout << "<TABLE border=1><COLGROUP><COL align=left><COL align=right><COL align=right><COL align=right>" << endl;
- cout << "<THEAD><TR><TH>Algorithm<TH>Bytes Processed<TH>Time Taken<TH>Megabytes(2^20 bytes)/Second\n<TBODY>" << endl;
+ cout << "<THEAD><TR><TH>Algorithm<TH>Megabytes(2^20 bytes) Processed<TH>Time Taken<TH>MB/Second\n<TBODY>" << endl;
BenchMarkKeyless<CRC32>("CRC-32", t);
BenchMarkKeyless<Adler32>("Adler-32", t);
diff --git a/cryptdll.dsp b/cryptdll.dsp
index 21bb06b..abdb906 100644
--- a/cryptdll.dsp
+++ b/cryptdll.dsp
@@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CRYPTDLL_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /G5 /Gz /MT /W3 /GX /Zi /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CRYPTOPP_EXPORTS" /D CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2=1 /D "USE_PRECOMPILED_HEADERS" /Yu"pch.h" /FD /Zm200 /c
+# ADD CPP /nologo /G5 /Gz /MT /W3 /GX /Zi /O1 /Ob2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CRYPTOPP_EXPORTS" /D CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2=1 /D "USE_PRECOMPILED_HEADERS" /Yu"pch.h" /FD /Zm200 /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
@@ -53,7 +53,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 advapi32.lib /nologo /base:"0x42900000" /dll /debug /machine:I386 /out:"DLL_Release/cryptopp.dll" /opt:ref /export:CryptoPP_Malloc=malloc /export:CryptoPP_Free=free
+# ADD LINK32 advapi32.lib /nologo /base:"0x42900000" /dll /map /debug /machine:I386 /out:"DLL_Release/cryptopp.dll" /opt:ref /export:CryptoPP_Malloc=malloc /export:CryptoPP_Free=free
# SUBTRACT LINK32 /pdb:none
# Begin Custom Build
OutDir=.\DLL_Release
diff --git a/cryptest.dsp b/cryptest.dsp
index 86e75e3..3a07817 100644
--- a/cryptest.dsp
+++ b/cryptest.dsp
@@ -45,7 +45,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G5 /Gz /MT /W3 /GX /Zi /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /Zm200 /c
-# ADD CPP /nologo /G5 /Gz /MD /W3 /GX /Zi /O2 /D "NDEBUG" /D "CRYPTOPP_IMPORTS" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /Zm400 /c
+# ADD CPP /nologo /G5 /Gz /MT /W3 /GX /Zi /O2 /D "NDEBUG" /D "CRYPTOPP_IMPORTS" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /Zm400 /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
@@ -75,7 +75,7 @@ PreLink_Cmds=echo This configuration requires cryptopp.dll. echo You can build i
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /Zm200 /c
-# ADD CPP /nologo /G5 /Gz /MDd /W3 /GX /ZI /Od /D "_DEBUG" /D "CRYPTOPP_IMPORTS" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /Zm400 /c
+# ADD CPP /nologo /G5 /Gz /MTd /W3 /GX /ZI /Od /D "_DEBUG" /D "CRYPTOPP_IMPORTS" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /Zm400 /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
@@ -103,7 +103,7 @@ PreLink_Cmds=echo This configuration requires cryptopp.dll. echo You can build i
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "WIN32" /YX /FD /Zm400 /c
+# ADD CPP /nologo /MT /W3 /GX /Zi /O1 /Ob2 /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "WIN32" /YX /FD /Zm400 /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
@@ -111,7 +111,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /OPT:NOWIN98 /OPT:REF /OPT:ICF
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /map /debug /machine:I386 /OPT:NOWIN98 /OPT:REF /OPT:ICF
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "cryptest - Win32 Debug"
diff --git a/cryptlib.cpp b/cryptlib.cpp
index f3b3fde..cc1e3ce 100644
--- a/cryptlib.cpp
+++ b/cryptlib.cpp
@@ -359,12 +359,12 @@ unsigned int BufferedTransformation::TransferMessagesTo2(BufferedTransformation
for (messageCount=0; messageCount < maxMessages && AnyMessages(); messageCount++)
{
unsigned int blockedBytes;
- unsigned long transferedBytes;
+ unsigned long transferredBytes;
while (AnyRetrievable())
{
- transferedBytes = ULONG_MAX;
- blockedBytes = TransferTo2(target, transferedBytes, channel, blocking);
+ transferredBytes = ULONG_MAX;
+ blockedBytes = TransferTo2(target, transferredBytes, channel, blocking);
if (blockedBytes > 0)
return blockedBytes;
}
diff --git a/cryptlib.dsp b/cryptlib.dsp
index 30f703e..c5a5dea 100644
--- a/cryptlib.dsp
+++ b/cryptlib.dsp
@@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "FIPS_140_Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G5 /Gz /MT /W3 /GX /Zi /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /Yu"pch.h" /FD /c
-# ADD CPP /nologo /G5 /Gz /MD /W3 /GX /Zi /O2 /D "NDEBUG" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /D "WIN32" /D "CRYPTOPP_IMPORTS" /Yu"pch.h" /Fd"FIPS_140_Release/cryptopp" /FD /c
+# ADD CPP /nologo /G5 /Gz /MT /W3 /GX /Zi /O2 /D "NDEBUG" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /D "WIN32" /D "CRYPTOPP_IMPORTS" /Yu"pch.h" /Fd"FIPS_140_Release/cryptopp" /FD /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
@@ -66,7 +66,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "FIPS_140_Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /Yu"pch.h" /FD /c
-# ADD CPP /nologo /G5 /Gz /MDd /W3 /GX /ZI /Od /D "_DEBUG" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /D "WIN32" /D "CRYPTOPP_IMPORTS" /Yu"pch.h" /Fd"FIPS_140_Debug/cryptopp" /FD /c
+# ADD CPP /nologo /G5 /Gz /MTd /W3 /GX /ZI /Od /D "_DEBUG" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /D "WIN32" /D "CRYPTOPP_IMPORTS" /Yu"pch.h" /Fd"FIPS_140_Debug/cryptopp" /FD /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
@@ -89,7 +89,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /D "NDEBUG" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /D "WIN32" /Yu"pch.h" /FD /c
+# ADD CPP /nologo /MT /W3 /GX /Zi /O1 /Ob2 /D "NDEBUG" /D "_WINDOWS" /D "USE_PRECOMPILED_HEADERS" /D "WIN32" /Yu"pch.h" /FD /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
@@ -210,6 +210,10 @@ SOURCE=.\asn.cpp
# End Source File
# Begin Source File
+SOURCE=.\base32.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\base64.cpp
# End Source File
# Begin Source File
@@ -680,6 +684,10 @@ SOURCE=.\asn.h
# End Source File
# Begin Source File
+SOURCE=.\base32.h
+# End Source File
+# Begin Source File
+
SOURCE=.\base64.h
# End Source File
# Begin Source File
diff --git a/cryptlib.h b/cryptlib.h
index 69526a4..f2479e8 100644
--- a/cryptlib.h
+++ b/cryptlib.h
@@ -206,9 +206,11 @@ struct CRYPTOPP_DLL DecodingResult
};
//! interface for retrieving values given their names
-/*! This class is used to safely pass a variable number of arbitrarily typed arguments to functions
+/*! \note This class is used to safely pass a variable number of arbitrarily typed arguments to functions
and to read values from keys and crypto parameters.
- To get a value, you need to know the name and the type of the value.
+ \note To obtain an object that implements NameValuePairs for the purpose of parameter
+ passing, use the MakeParameters() function.
+ \note To get a value from NameValuePairs, you need to know the name and the type of the value.
Call GetValueNames() on a NameValuePairs object to obtain a list of value names that it supports.
Then look at the Name namespace documentation to see what the type of each value is, or
alternatively, call GetIntValue() with the value name, and if the type is not int, a
@@ -779,7 +781,7 @@ public:
/*! There should be a MessageEnd immediately before MessageSeriesEnd. */
virtual bool MessageSeriesEnd(int propagation=-1, bool blocking=true);
- //! set propagation of automatically generated and transfered signals
+ //! set propagation of automatically generated and transferred signals
/*! propagation == 0 means do not automaticly generate signals */
virtual void SetAutoSignalPropagation(int propagation) {}
diff --git a/datatest.cpp b/datatest.cpp
index 1307760..a104ae5 100644
--- a/datatest.cpp
+++ b/datatest.cpp
@@ -24,7 +24,7 @@ public:
static const TestData *s_currentTestData = NULL;
-void OutputTestData(const TestData &v)
+static void OutputTestData(const TestData &v)
{
for (TestData::const_iterator i = v.begin(); i != v.end(); ++i)
{
@@ -32,13 +32,13 @@ void OutputTestData(const TestData &v)
}
}
-void SignalTestFailure()
+static void SignalTestFailure()
{
OutputTestData(*s_currentTestData);
throw TestFailure();
}
-void SignalTestError()
+static void SignalTestError()
{
OutputTestData(*s_currentTestData);
throw Exception(Exception::OTHER_ERROR, "Unexpected error during validation test");
diff --git a/dlltest.dsp b/dlltest.dsp
index 7a71a59..0d82a11 100644
--- a/dlltest.dsp
+++ b/dlltest.dsp
@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /Gz /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "CRYPTOPP_DLL_ONLY" /YX /FD /c
+# ADD CPP /nologo /Gz /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "CRYPTOPP_DLL_ONLY" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
@@ -50,7 +50,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /out:"DLL_Release/dlltest.exe" /libpath:"DLL_Release"
+# ADD LINK32 /nologo /subsystem:console /map /debug /machine:I386 /out:"DLL_Release/dlltest.exe" /libpath:"DLL_Release"
!ELSEIF "$(CFG)" == "dlltest - Win32 Debug"
@@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "CRYPTOPP_DLL_ONLY" /YX /FD /GZ /c
+# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "CRYPTOPP_DLL_ONLY" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
diff --git a/hex.cpp b/hex.cpp
index 5ac6e8c..3156167 100644
--- a/hex.cpp
+++ b/hex.cpp
@@ -13,13 +13,20 @@ static const byte s_vecLower[] = "0123456789abcdef";
void HexEncoder::IsolatedInitialize(const NameValuePairs &parameters)
{
- bool uppercase = parameters.GetValueWithDefault("Uppercase", true);
+ bool uppercase = parameters.GetValueWithDefault(Name::Uppercase(), true);
m_filter->Initialize(CombinedNameValuePairs(
parameters,
- MakeParameters("EncodingLookupArray", uppercase ? &s_vecUpper[0] : &s_vecLower[0])("Log2Base", 4)));
+ MakeParameters(Name::EncodingLookupArray(), uppercase ? &s_vecUpper[0] : &s_vecLower[0], false)(Name::Log2Base(), 4, true)));
}
-const int *HexDecoder::GetDecodingLookupArray()
+void HexDecoder::IsolatedInitialize(const NameValuePairs &parameters)
+{
+ BaseN_Decoder::Initialize(CombinedNameValuePairs(
+ parameters,
+ MakeParameters(Name::DecodingLookupArray(), GetDefaultDecodingLookupArray(), false)(Name::Log2Base(), 4, true)));
+}
+
+const int *HexDecoder::GetDefaultDecodingLookupArray()
{
static bool s_initialized = false;
static int s_array[256];
diff --git a/hex.h b/hex.h
index ec8c91c..74302f2 100644
--- a/hex.h
+++ b/hex.h
@@ -12,7 +12,7 @@ public:
HexEncoder(BufferedTransformation *attachment = NULL, bool uppercase = true, int outputGroupSize = 0, const std::string &separator = ":", const std::string &terminator = "")
: SimpleProxyFilter(new BaseN_Encoder(new Grouper), attachment)
{
- IsolatedInitialize(MakeParameters("Uppercase", uppercase)("GroupSize", outputGroupSize)("Separator", ConstByteArrayParameter(separator)));
+ IsolatedInitialize(MakeParameters(Name::Uppercase(), uppercase)(Name::GroupSize(), outputGroupSize)(Name::Separator(), ConstByteArrayParameter(separator)));
}
void IsolatedInitialize(const NameValuePairs &parameters);
@@ -23,12 +23,12 @@ class CRYPTOPP_DLL HexDecoder : public BaseN_Decoder
{
public:
HexDecoder(BufferedTransformation *attachment = NULL)
- : BaseN_Decoder(GetDecodingLookupArray(), 4, attachment) {}
+ : BaseN_Decoder(GetDefaultDecodingLookupArray(), 4, attachment) {}
- void IsolatedInitialize(const NameValuePairs &parameters) {}
+ void IsolatedInitialize(const NameValuePairs &parameters);
private:
- static const int *GetDecodingLookupArray();
+ static const int *GetDefaultDecodingLookupArray();
};
NAMESPACE_END
diff --git a/modes.h b/modes.h
index e6b30e0..34dd21a 100644
--- a/modes.h
+++ b/modes.h
@@ -275,19 +275,26 @@ template <class BASE>
class CipherModeFinalTemplate_ExternalCipher : public BASE
{
public:
- CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher);
-
- CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher, const byte *iv, int feedbackSize = 0);
+ CipherModeFinalTemplate_ExternalCipher() {}
+ CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher)
+ {SetCipher(cipher);}
+ CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher, const byte *iv, int feedbackSize = 0)
+ {SetCipherWithIV(cipher, iv, feedbackSize);}
+
+ void SetCipher(BlockCipher &cipher);
+ void SetCipherWithIV(BlockCipher &cipher, const byte *iv, int feedbackSize = 0);
};
-template <class BASE> CipherModeFinalTemplate_ExternalCipher<BASE>::CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher)
+template <class BASE>
+void CipherModeFinalTemplate_ExternalCipher<BASE>::SetCipher(BlockCipher &cipher)
{
ThrowIfResynchronizable();
m_cipher = &cipher;
ResizeBuffers();
}
-template <class BASE> CipherModeFinalTemplate_ExternalCipher<BASE>::CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher, const byte *iv, int feedbackSize)
+template <class BASE>
+void CipherModeFinalTemplate_ExternalCipher<BASE>::SetCipherWithIV(BlockCipher &cipher, const byte *iv, int feedbackSize)
{
ThrowIfInvalidIV(iv);
m_cipher = &cipher;
diff --git a/network.h b/network.h
index a02e9ed..b4c79ac 100644
--- a/network.h
+++ b/network.h
@@ -137,12 +137,14 @@ public:
unsigned int TimedFlush(unsigned long maxTime, unsigned int targetSize = 0);
- void SetMaxBufferSize(unsigned int maxBufferSize) {m_maxBufferSize = maxBufferSize;}
+ void SetMaxBufferSize(unsigned int maxBufferSize) {m_maxBufferSize = maxBufferSize; m_buffer.SetNodeSize(STDMIN(16U*1024U+256, maxBufferSize));}
void SetAutoFlushBound(unsigned int bound) {m_autoFlushBound = bound;}
unsigned int GetMaxBufferSize() const {return m_maxBufferSize;}
unsigned int GetCurrentBufferSize() const {return m_buffer.CurrentSize();}
+ void ClearBuffer() {m_buffer.Clear();}
+
//! compute the current speed of this sink in bytes per second
float ComputeCurrentSpeed();
//! get the maximum observed speed of this sink in bytes per second
diff --git a/oaep.cpp b/oaep.cpp
index ddd846d..fd2d97a 100644
--- a/oaep.cpp
+++ b/oaep.cpp
@@ -1,8 +1,10 @@
// oaep.cpp - written and placed in the public domain by Wei Dai
#include "pch.h"
-#include "oaep.h"
+#ifndef CRYPTOPP_IMPORTS
+
+#include "oaep.h"
#include <functional>
NAMESPACE_BEGIN(CryptoPP)
@@ -91,3 +93,5 @@ DecodingResult OAEP_Base::Unpad(const byte *oaepBlock, unsigned int oaepBlockLen
}
NAMESPACE_END
+
+#endif
diff --git a/rsa.cpp b/rsa.cpp
index 1e00a6c..eb68a67 100644
--- a/rsa.cpp
+++ b/rsa.cpp
@@ -12,11 +12,7 @@
#if !defined(NDEBUG) && !defined(CRYPTOPP_IS_DLL)
#include "pssr.h"
-#endif
-
NAMESPACE_BEGIN(CryptoPP)
-
-#if !defined(NDEBUG) && !defined(CRYPTOPP_IS_DLL)
void RSA_TestInstantiations()
{
RSASS<PKCS1v15, SHA>::Verifier x1(1, 1);
@@ -37,10 +33,13 @@ void RSA_TestInstantiations()
x4 = x2.GetKey();
}
+NAMESPACE_END
#endif
#ifndef CRYPTOPP_IMPORTS
+NAMESPACE_BEGIN(CryptoPP)
+
OID RSAFunction::GetAlgorithmID() const
{
return ASN1::rsaEncryption();
@@ -276,6 +275,6 @@ void InvertibleRSAFunction::AssignFrom(const NameValuePairs &source)
;
}
-#endif
-
NAMESPACE_END
+
+#endif
diff --git a/stdcpp.h b/stdcpp.h
index de1ea9e..30fa9a9 100644
--- a/stdcpp.h
+++ b/stdcpp.h
@@ -15,8 +15,6 @@
#include <algorithm>
#include <map>
#include <vector>
-#include <iostream>
-#include <fstream>
#include <locale>
// re-disable this
diff --git a/test.cpp b/test.cpp
index 063e6dd..e371652 100644
--- a/test.cpp
+++ b/test.cpp
@@ -51,6 +51,8 @@ bool RSAVerifyFile(const char *pubFilename, const char *messageFilename, const c
void DigestFile(const char *file);
void HmacFile(const char *hexKey, const char *file);
+void AES_CTR_Encrypt(const char *hexKey, const char *hexIV, const char *infile, const char *outfile);
+
string EncryptString(const char *plaintext, const char *passPhrase);
string DecryptString(const char *ciphertext, const char *passPhrase);
@@ -66,10 +68,10 @@ void InformationRecoverFile(int threshold, const char *outFilename, char *const
void GzipFile(const char *in, const char *out, int deflate_level);
void GunzipFile(const char *in, const char *out);
-void Base64Encode(const char *in, const char *out);
-void Base64Decode(const char *in, const char *out);
-void HexEncode(const char *in, const char *out);
-void HexDecode(const char *in, const char *out);
+void Base64Encode(const char *infile, const char *outfile);
+void Base64Decode(const char *infile, const char *outfile);
+void HexEncode(const char *infile, const char *outfile);
+void HexDecode(const char *infile, const char *outfile);
void ForwardTcpPort(const char *sourcePort, const char *destinationHost, const char *destinationPort);
@@ -291,6 +293,8 @@ int CRYPTOPP_CDECL main(int argc, char *argv[])
}
else if (command == "hmac")
HmacFile(argv[2], argv[3]);
+ else if (command == "ae")
+ AES_CTR_Encrypt(argv[2], argv[3], argv[4], argv[5]);
else if (command == "h")
{
FileSource usage("usage.dat", true, new FileSink(cout));
@@ -298,7 +302,7 @@ int CRYPTOPP_CDECL main(int argc, char *argv[])
}
else
{
- cerr << "Unrecognized command.\n";
+ cerr << "Unrecognized command. Run \"cryptest h\" to obtain usage information.\n";
return 1;
}
return 0;
@@ -329,6 +333,14 @@ void FIPS140_GenerateRandomFiles()
#endif
}
+SecByteBlock HexDecodeString(const char *hex)
+{
+ StringSource ss(hex, true, new HexDecoder);
+ SecByteBlock result(ss.MaxRetrievable());
+ ss.Get(result, result.size());
+ return result;
+}
+
RandomPool & GlobalRNG()
{
static RandomPool randomPool;
@@ -442,6 +454,14 @@ void HmacFile(const char *hexKey, const char *file)
FileSource(file, true, new HashFilter(*mac, new HexEncoder(new FileSink(cout))));
}
+void AES_CTR_Encrypt(const char *hexKey, const char *hexIV, const char *infile, const char *outfile)
+{
+ SecByteBlock key = HexDecodeString(hexKey);
+ SecByteBlock iv = HexDecodeString(hexIV);
+ CTR_Mode<AES>::Encryption aes(key, key.size(), iv);
+ FileSource(infile, true, new StreamTransformationFilter(aes, new FileSink(outfile)));
+}
+
string EncryptString(const char *instr, const char *passPhrase)
{
string outstr;
diff --git a/usage.dat b/usage.dat
index eb92a43..0761529 100644
--- a/usage.dat
+++ b/usage.dat
@@ -41,6 +41,9 @@ Test Driver for Crypto++(TM) Library, a C++ Class Library of Cryptographic Schem
- To gunzip a file
cryptest u input output
+- To encrypt a file with AES in CTR mode
+ cryptest ae input output
+
- To base64 encode a file
cryptest e64 input output
diff --git a/validat1.cpp b/validat1.cpp
index ed3f26a..4edaada 100644
--- a/validat1.cpp
+++ b/validat1.cpp
@@ -4,6 +4,7 @@
#include "files.h"
#include "hex.h"
+#include "base32.h"
#include "base64.h"
#include "modes.h"
#include "cbcmac.h"
@@ -1279,6 +1280,13 @@ bool ValidateBaseCode()
"A0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7"
"C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF"
"F0F1F2F3F4F5F6F7F8F9FAFBFCFDFE";
+ const char *base32Encoded =
+"AAASEA2EAWDAQCAJBIFS2DIQB6IBCESVCSKTNF22DEPBYHA7D2RUAIJCENUCKJTHFAWUWK3NFWZC8NBT"
+"GI3VIPJYG66DUQT5HS8V6R4AIFBEGTCFI3DWSUKKJPGE4VURKBIXEW4WKXMFQYC3MJPX2ZK8M7SGC2VD"
+"NTUYN35IPFXGY5DPP3ZZA6MUQP4HK7VZRB6ZW856RX9H9AEBSKB2JBNGS8EIVCWMTUG27D6SUGJJHFEX"
+"U4M3TGN4VQQJ5HW9WCS4FI7EWYVKRKFJXKX43MPQX82MDNXVYU45PP72ZG7MZRF7Z496BSQC2RCNMTYH"
+"3DE6XU8N3ZHN9WGT4MJ7JXQY49NPVYY55VQ77Z9A6HTQH3HF65V8T4RK7RYQ55ZR8D29F69W8Z5RR8H3"
+"9M7939R8";
const char *base64AndHexEncoded =
"41414543417751464267634943516F4C4441304F4478415245684D554652595847426B6147787764"
"486838674953496A4A43556D4A7967704B6973734C5334764D4445794D7A51310A4E6A63344F546F"
@@ -1290,7 +1298,7 @@ bool ValidateBaseCode()
"39445230745055316462580A324E6E6132397A6433742F6734654C6A354F586D352B6A7036757673"
"3765377638504879382F5431397666342B6672372F50332B0A";
- cout << "\nBase64 and hex coding validation suite running...\n\n";
+ cout << "\nBase64, base32 and hex coding validation suite running...\n\n";
fail = !TestFilter(HexEncoder().Ref(), data, 255, (const byte *)hexEncoded, strlen(hexEncoded));
cout << (fail ? "FAILED " : "passed ");
@@ -1302,6 +1310,16 @@ bool ValidateBaseCode()
cout << "Hex Decoding\n";
pass = pass && !fail;
+ fail = !TestFilter(Base32Encoder().Ref(), data, 255, (const byte *)base32Encoded, strlen(base32Encoded));
+ cout << (fail ? "FAILED " : "passed ");
+ cout << "Base32 Encoding\n";
+ pass = pass && !fail;
+
+ fail = !TestFilter(Base32Decoder().Ref(), (const byte *)base32Encoded, strlen(base32Encoded), data, 255);
+ cout << (fail ? "FAILED " : "passed ");
+ cout << "Base32 Decoding\n";
+ pass = pass && !fail;
+
fail = !TestFilter(Base64Encoder(new HexEncoder).Ref(), data, 255, (const byte *)base64AndHexEncoded, strlen(base64AndHexEncoded));
cout << (fail ? "FAILED " : "passed ");
cout << "Base64 Encoding\n";