Removed USING_NAMESPACE(std). Changed cout → std::cout, cerr → std::cerr, ...
parent
2799132fd7
commit
22c3e41133
1
asn.cpp
1
asn.cpp
|
|
@ -11,7 +11,6 @@
|
|||
#include <time.h>
|
||||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
USING_NAMESPACE(std)
|
||||
|
||||
/// DER Length
|
||||
size_t DERLengthEncode(BufferedTransformation &bt, lword length)
|
||||
|
|
|
|||
57
bench.cpp
57
bench.cpp
|
|
@ -18,7 +18,6 @@
|
|||
#include <iomanip>
|
||||
|
||||
USING_NAMESPACE(CryptoPP)
|
||||
USING_NAMESPACE(std)
|
||||
|
||||
#ifdef CLOCKS_PER_SEC
|
||||
const double CLOCK_TICKS_PER_SECOND = (double)CLOCKS_PER_SEC;
|
||||
|
|
@ -36,35 +35,35 @@ static const byte *const key=(byte *)"0123456789abcdefghijklmnopqrstuvwxyzABCDEF
|
|||
void OutputResultBytes(const char *name, double length, double timeTaken)
|
||||
{
|
||||
double mbs = length / timeTaken / (1024*1024);
|
||||
cout << "\n<TR><TH>" << name;
|
||||
// cout << "<TD>" << setprecision(3) << length / (1024*1024);
|
||||
cout << setiosflags(ios::fixed);
|
||||
// cout << "<TD>" << setprecision(3) << timeTaken;
|
||||
cout << "<TD>" << setprecision(0) << setiosflags(ios::fixed) << mbs;
|
||||
std::cout << "\n<TR><TH>" << name;
|
||||
// std::cout << "<TD>" << std::setprecision(3) << length / (1024*1024);
|
||||
std::cout << std::setiosflags(std::ios::fixed);
|
||||
// std::cout << "<TD>" << std::setprecision(3) << timeTaken;
|
||||
std::cout << "<TD>" << std::setprecision(0) << std::setiosflags(std::ios::fixed) << mbs;
|
||||
if (g_hertz)
|
||||
cout << "<TD>" << setprecision(1) << setiosflags(ios::fixed) << timeTaken * g_hertz / length;
|
||||
cout << resetiosflags(ios::fixed);
|
||||
std::cout << "<TD>" << std::setprecision(1) << std::setiosflags(std::ios::fixed) << timeTaken * g_hertz / length;
|
||||
std::cout << std::setiosflags(std::ios::fixed);
|
||||
logtotal += log(mbs);
|
||||
logcount++;
|
||||
}
|
||||
|
||||
void OutputResultKeying(double iterations, double timeTaken)
|
||||
{
|
||||
cout << "<TD>" << setprecision(3) << setiosflags(ios::fixed) << (1000*1000*timeTaken/iterations);
|
||||
std::cout << "<TD>" << std::setprecision(3) << std::setiosflags(std::ios::fixed) << (1000*1000*timeTaken/iterations);
|
||||
if (g_hertz)
|
||||
cout << "<TD>" << setprecision(0) << setiosflags(ios::fixed) << timeTaken * g_hertz / iterations;
|
||||
std::cout << "<TD>" << std::setprecision(0) << std::setiosflags(std::ios::fixed) << timeTaken * g_hertz / iterations;
|
||||
}
|
||||
|
||||
void OutputResultOperations(const char *name, const char *operation, bool pc, unsigned long iterations, double timeTaken)
|
||||
{
|
||||
cout << "\n<TR><TH>" << name << " " << operation << (pc ? " with precomputation" : "");
|
||||
// cout << "<TD>" << iterations;
|
||||
// cout << setiosflags(ios::fixed);
|
||||
// cout << "<TD>" << setprecision(3) << timeTaken;
|
||||
cout << "<TD>" << setprecision(2) << setiosflags(ios::fixed) << (1000*timeTaken/iterations);
|
||||
std::cout << "\n<TR><TH>" << name << " " << operation << (pc ? " with precomputation" : "");
|
||||
// std::cout << "<TD>" << iterations;
|
||||
// std::cout << std::setiosflags(std::ios::fixed);
|
||||
// std::cout << "<TD>" << std::setprecision(3) << timeTaken;
|
||||
std::cout << "<TD>" << std::setprecision(2) << std::setiosflags(std::ios::fixed) << (1000*timeTaken/iterations);
|
||||
if (g_hertz)
|
||||
cout << "<TD>" << setprecision(2) << setiosflags(ios::fixed) << timeTaken * g_hertz / iterations / 1000000;
|
||||
cout << resetiosflags(ios::fixed);
|
||||
std::cout << "<TD>" << std::setprecision(2) << std::setiosflags(std::ios::fixed) << timeTaken * g_hertz / iterations / 1000000;
|
||||
std::cout << std::setiosflags(std::ios::fixed);
|
||||
|
||||
logtotal += log(iterations/timeTaken);
|
||||
logcount++;
|
||||
|
|
@ -231,18 +230,18 @@ void BenchmarkAll(double t, double hertz)
|
|||
{
|
||||
cpb = "<TH>Cycles Per Byte";
|
||||
cpk = "<TH>Cycles to<br>Setup Key and IV";
|
||||
cout << "CPU frequency of the test platform is " << g_hertz << " Hz.\n";
|
||||
std::cout << "CPU frequency of the test platform is " << g_hertz << " Hz.\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
cpb = cpk = "";
|
||||
cout << "CPU frequency of the test platform was not provided.\n";
|
||||
std::cout << "CPU frequency of the test platform was not provided.\n";
|
||||
}
|
||||
|
||||
cout << "<TABLE border=1><COLGROUP><COL align=left><COL align=right><COL align=right><COL align=right><COL align=right>" << endl;
|
||||
cout << "<THEAD><TR><TH>Algorithm<TH>MiB/Second" << cpb << "<TH>Microseconds to<br>Setup Key and IV" << cpk << endl;
|
||||
std::cout << "<TABLE border=1><COLGROUP><COL align=left><COL align=right><COL align=right><COL align=right><COL align=right>" << std::endl;
|
||||
std::cout << "<THEAD><TR><TH>Algorithm<TH>MiB/Second" << cpb << "<TH>Microseconds to<br>Setup Key and IV" << cpk << std::endl;
|
||||
|
||||
cout << "\n<TBODY style=\"background: yellow\">";
|
||||
std::cout << "\n<TBODY style=\"background: yellow\">";
|
||||
#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
|
||||
if (HasCLMUL())
|
||||
BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>("AES/GCM", 0, "AES/GCM");
|
||||
|
|
@ -255,7 +254,7 @@ void BenchmarkAll(double t, double hertz)
|
|||
BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>("AES/CCM");
|
||||
BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>("AES/EAX");
|
||||
|
||||
cout << "\n<TBODY style=\"background: white\">";
|
||||
std::cout << "\n<TBODY style=\"background: white\">";
|
||||
#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
|
||||
if (HasCLMUL())
|
||||
BenchMarkByName2<AuthenticatedSymmetricCipher, MessageAuthenticationCode>("AES/GCM", 0, "GMAC(AES)");
|
||||
|
|
@ -272,7 +271,7 @@ void BenchmarkAll(double t, double hertz)
|
|||
BenchMarkByName<MessageAuthenticationCode>("CMAC(AES)");
|
||||
BenchMarkByName<MessageAuthenticationCode>("DMAC(AES)");
|
||||
|
||||
cout << "\n<TBODY style=\"background: yellow\">";
|
||||
std::cout << "\n<TBODY style=\"background: yellow\">";
|
||||
BenchMarkByNameKeyLess<HashTransformation>("CRC32");
|
||||
BenchMarkByNameKeyLess<HashTransformation>("Adler32");
|
||||
BenchMarkByNameKeyLess<HashTransformation>("MD5");
|
||||
|
|
@ -290,7 +289,7 @@ void BenchmarkAll(double t, double hertz)
|
|||
BenchMarkByNameKeyLess<HashTransformation>("RIPEMD-128");
|
||||
BenchMarkByNameKeyLess<HashTransformation>("RIPEMD-256");
|
||||
|
||||
cout << "\n<TBODY style=\"background: white\">";
|
||||
std::cout << "\n<TBODY style=\"background: white\">";
|
||||
BenchMarkByName<SymmetricCipher>("Panama-LE");
|
||||
BenchMarkByName<SymmetricCipher>("Panama-BE");
|
||||
BenchMarkByName<SymmetricCipher>("Salsa20");
|
||||
|
|
@ -301,7 +300,7 @@ void BenchmarkAll(double t, double hertz)
|
|||
BenchMarkByName<SymmetricCipher>("SEAL-3.0-LE");
|
||||
BenchMarkByName<SymmetricCipher>("WAKE-OFB-LE");
|
||||
|
||||
cout << "\n<TBODY style=\"background: yellow\">";
|
||||
std::cout << "\n<TBODY style=\"background: yellow\">";
|
||||
BenchMarkByName<SymmetricCipher>("AES/CTR", 16);
|
||||
BenchMarkByName<SymmetricCipher>("AES/CTR", 24);
|
||||
BenchMarkByName<SymmetricCipher>("AES/CTR", 32);
|
||||
|
|
@ -331,13 +330,13 @@ void BenchmarkAll(double t, double hertz)
|
|||
BenchMarkByName<SymmetricCipher>("CAST-128/CTR");
|
||||
BenchMarkByName<SymmetricCipher>("SKIPJACK/CTR");
|
||||
BenchMarkByName<SymmetricCipher>("SEED/CTR", 0, "SEED/CTR (1/2 K table)");
|
||||
cout << "</TABLE>" << endl;
|
||||
std::cout << "</TABLE>" << std::endl;
|
||||
|
||||
BenchmarkAll2(t, hertz);
|
||||
|
||||
cout << "Throughput Geometric Average: " << setiosflags(ios::fixed) << exp(logtotal/logcount) << endl;
|
||||
std::cout << "Throughput Geometric Average: " << std::setiosflags(std::ios::fixed) << exp(logtotal/logcount) << std::endl;
|
||||
|
||||
time_t endTime = time(NULL);
|
||||
cout << "\nTest ended at " << asctime(localtime(&endTime));
|
||||
std::cout << "\nTest ended at " << asctime(localtime(&endTime));
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
21
bench2.cpp
21
bench2.cpp
|
|
@ -28,7 +28,6 @@
|
|||
#include <iomanip>
|
||||
|
||||
USING_NAMESPACE(CryptoPP)
|
||||
USING_NAMESPACE(std)
|
||||
|
||||
void OutputResultOperations(const char *name, const char *operation, bool pc, unsigned long iterations, double timeTaken);
|
||||
|
||||
|
|
@ -233,22 +232,22 @@ void BenchmarkAll2(double t, double hertz)
|
|||
{
|
||||
g_hertz = hertz;
|
||||
|
||||
cout << "<TABLE border=1><COLGROUP><COL align=left><COL align=right><COL align=right>" << endl;
|
||||
cout << "<THEAD><TR><TH>Operation<TH>Milliseconds/Operation" << (g_hertz ? "<TH>Megacycles/Operation" : "") << endl;
|
||||
std::cout << "<TABLE border=1><COLGROUP><COL align=left><COL align=right><COL align=right>" << std::endl;
|
||||
std::cout << "<THEAD><TR><TH>Operation<TH>Milliseconds/Operation" << (g_hertz ? "<TH>Megacycles/Operation" : "") << std::endl;
|
||||
|
||||
cout << "\n<TBODY style=\"background: yellow\">";
|
||||
std::cout << "\n<TBODY style=\"background: yellow\">";
|
||||
BenchMarkCrypto<RSAES<OAEP<SHA> > >("TestData/rsa1024.dat", "RSA 1024", t);
|
||||
BenchMarkCrypto<LUCES<OAEP<SHA> > >("TestData/luc1024.dat", "LUC 1024", t);
|
||||
BenchMarkCrypto<DLIES<> >("TestData/dlie1024.dat", "DLIES 1024", t);
|
||||
BenchMarkCrypto<LUC_IES<> >("TestData/lucc512.dat", "LUCELG 512", t);
|
||||
|
||||
cout << "\n<TBODY style=\"background: white\">";
|
||||
std::cout << "\n<TBODY style=\"background: white\">";
|
||||
BenchMarkCrypto<RSAES<OAEP<SHA> > >("TestData/rsa2048.dat", "RSA 2048", t);
|
||||
BenchMarkCrypto<LUCES<OAEP<SHA> > >("TestData/luc2048.dat", "LUC 2048", t);
|
||||
BenchMarkCrypto<DLIES<> >("TestData/dlie2048.dat", "DLIES 2048", t);
|
||||
BenchMarkCrypto<LUC_IES<> >("TestData/lucc1024.dat", "LUCELG 1024", t);
|
||||
|
||||
cout << "\n<TBODY style=\"background: yellow\">";
|
||||
std::cout << "\n<TBODY style=\"background: yellow\">";
|
||||
BenchMarkSignature<RSASS<PSSR, SHA> >("TestData/rsa1024.dat", "RSA 1024", t);
|
||||
BenchMarkSignature<RWSS<PSSR, SHA> >("TestData/rw1024.dat", "RW 1024", t);
|
||||
BenchMarkSignature<LUCSS<PSSR, SHA> >("TestData/luc1024.dat", "LUC 1024", t);
|
||||
|
|
@ -258,7 +257,7 @@ void BenchmarkAll2(double t, double hertz)
|
|||
BenchMarkSignature<ESIGN<SHA> >("TestData/esig1023.dat", "ESIGN 1023", t);
|
||||
BenchMarkSignature<ESIGN<SHA> >("TestData/esig1536.dat", "ESIGN 1536", t);
|
||||
|
||||
cout << "\n<TBODY style=\"background: white\">";
|
||||
std::cout << "\n<TBODY style=\"background: white\">";
|
||||
BenchMarkSignature<RSASS<PSSR, SHA> >("TestData/rsa2048.dat", "RSA 2048", t);
|
||||
BenchMarkSignature<RWSS<PSSR, SHA> >("TestData/rw2048.dat", "RW 2048", t);
|
||||
BenchMarkSignature<LUCSS<PSSR, SHA> >("TestData/luc2048.dat", "LUC 2048", t);
|
||||
|
|
@ -266,7 +265,7 @@ void BenchmarkAll2(double t, double hertz)
|
|||
BenchMarkSignature<LUC_HMP<SHA> >("TestData/lucs1024.dat", "LUC-HMP 1024", t);
|
||||
BenchMarkSignature<ESIGN<SHA> >("TestData/esig2046.dat", "ESIGN 2046", t);
|
||||
|
||||
cout << "\n<TBODY style=\"background: yellow\">";
|
||||
std::cout << "\n<TBODY style=\"background: yellow\">";
|
||||
BenchMarkKeyAgreement<XTR_DH>("TestData/xtrdh171.dat", "XTR-DH 171", t);
|
||||
BenchMarkKeyAgreement<XTR_DH>("TestData/xtrdh342.dat", "XTR-DH 342", t);
|
||||
BenchMarkKeyAgreement<DH>("TestData/dh1024.dat", "DH 1024", t);
|
||||
|
|
@ -276,7 +275,7 @@ void BenchmarkAll2(double t, double hertz)
|
|||
BenchMarkKeyAgreement<MQV>("TestData/mqv1024.dat", "MQV 1024", t);
|
||||
BenchMarkKeyAgreement<MQV>("TestData/mqv2048.dat", "MQV 2048", t);
|
||||
|
||||
cout << "\n<TBODY style=\"background: white\">";
|
||||
std::cout << "\n<TBODY style=\"background: white\">";
|
||||
{
|
||||
ECIES<ECP>::Decryptor cpriv(GlobalRNG(), ASN1::secp256k1());
|
||||
ECIES<ECP>::Encryptor cpub(cpriv);
|
||||
|
|
@ -295,7 +294,7 @@ void BenchmarkAll2(double t, double hertz)
|
|||
BenchMarkAgreement("ECMQVC over GF(p) 256", ecmqvc, t);
|
||||
}
|
||||
|
||||
cout << "<TBODY style=\"background: yellow\">" << endl;
|
||||
std::cout << "<TBODY style=\"background: yellow\">" << std::endl;
|
||||
{
|
||||
ECIES<EC2N>::Decryptor cpriv(GlobalRNG(), ASN1::sect233r1());
|
||||
ECIES<EC2N>::Encryptor cpub(cpriv);
|
||||
|
|
@ -313,5 +312,5 @@ void BenchmarkAll2(double t, double hertz)
|
|||
BenchMarkKeyGen("ECMQVC over GF(2^n) 233", ecmqvc, t);
|
||||
BenchMarkAgreement("ECMQVC over GF(2^n) 233", ecmqvc, t);
|
||||
}
|
||||
cout << "</TABLE>" << endl;
|
||||
std::cout << "</TABLE>" << std::endl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
#include "channels.h"
|
||||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
USING_NAMESPACE(std)
|
||||
|
||||
#if 0
|
||||
void MessageSwitch::AddDefaultRoute(BufferedTransformation &destination, const std::string &channel)
|
||||
|
|
@ -36,7 +35,7 @@ public:
|
|||
MessageRouteIterator(MessageSwitch &ms, const std::string &channel)
|
||||
: m_channel(channel)
|
||||
{
|
||||
pair<MapIterator, MapIterator> range = cs.m_routeMap.equal_range(channel);
|
||||
std::pair<MapIterator, MapIterator> range = cs.m_routeMap.equal_range(channel);
|
||||
if (range.first == range.second)
|
||||
{
|
||||
m_useDefault = true;
|
||||
|
|
@ -96,7 +95,7 @@ void MessageSwitch::MessageSeriesEnd(int propagation=-1);
|
|||
void ChannelRouteIterator::Reset(const std::string &channel)
|
||||
{
|
||||
m_channel = channel;
|
||||
pair<MapIterator, MapIterator> range = m_cs.m_routeMap.equal_range(channel);
|
||||
std::pair<MapIterator, MapIterator> range = m_cs.m_routeMap.equal_range(channel);
|
||||
if (range.first == range.second)
|
||||
{
|
||||
m_useDefault = true;
|
||||
|
|
@ -294,7 +293,7 @@ void ChannelSwitch::AddRoute(const std::string &inChannel, BufferedTransformatio
|
|||
void ChannelSwitch::RemoveRoute(const std::string &inChannel, BufferedTransformation &destination, const std::string &outChannel)
|
||||
{
|
||||
typedef ChannelSwitch::RouteMap::iterator MapIterator;
|
||||
pair<MapIterator, MapIterator> range = m_routeMap.equal_range(inChannel);
|
||||
std::pair<MapIterator, MapIterator> range = m_routeMap.equal_range(inChannel);
|
||||
|
||||
for (MapIterator it = range.first; it != range.second; ++it)
|
||||
if (it->second.first == &destination && it->second.second == outChannel)
|
||||
|
|
|
|||
28
cryptlib.h
28
cryptlib.h
|
|
@ -127,7 +127,7 @@ public:
|
|||
NOT_IMPLEMENTED,
|
||||
//! invalid function argument
|
||||
INVALID_ARGUMENT,
|
||||
//! BufferedTransformation received a Flush(true) signal but can't flush buffers
|
||||
//! BufferedTransformation received a Flush(true) signal but can't std::flush buffers
|
||||
CANNOT_FLUSH,
|
||||
//! data integerity check (such as CRC or MAC) failed
|
||||
DATA_INTEGRITY_CHECK_FAILED,
|
||||
|
|
@ -180,7 +180,7 @@ public:
|
|||
explicit NotImplemented(const std::string &s) : Exception(NOT_IMPLEMENTED, s) {}
|
||||
};
|
||||
|
||||
//! exception thrown by a class when Flush(true) is called but it can't completely flush its buffers
|
||||
//! exception thrown by a class when Flush(true) is called but it can't completely std::flush its buffers
|
||||
class CRYPTOPP_DLL CannotFlush : public Exception
|
||||
{
|
||||
public:
|
||||
|
|
@ -375,7 +375,7 @@ public:
|
|||
virtual std::string AlgorithmName() const {return "unknown";}
|
||||
};
|
||||
|
||||
//! keying interface for crypto algorithms that take byte strings as keys
|
||||
//! keying interface for crypto algorithms that take byte std::strings as keys
|
||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE SimpleKeyingInterface
|
||||
{
|
||||
public:
|
||||
|
|
@ -768,7 +768,7 @@ public:
|
|||
bool Wait(unsigned long milliseconds, CallStack const& callStack);
|
||||
};
|
||||
|
||||
//! the default channel for BufferedTransformation, equal to the empty string
|
||||
//! the default channel for BufferedTransformation, equal to the empty std::string
|
||||
extern CRYPTOPP_DLL const std::string DEFAULT_CHANNEL;
|
||||
|
||||
//! channel for additional authenticated data, equal to "AAD"
|
||||
|
|
@ -868,14 +868,14 @@ public:
|
|||
|
||||
//! initialize or reinitialize this object
|
||||
virtual void Initialize(const NameValuePairs ¶meters=g_nullNameValuePairs, int propagation=-1);
|
||||
//! flush buffered input and/or output
|
||||
/*! \param hardFlush is used to indicate whether all data should be flushed
|
||||
\note Hard flushes must be used with care. It means try to process and output everything, even if
|
||||
there may not be enough data to complete the action. For example, hard flushing a HexDecoder would
|
||||
//! std::flush buffered input and/or output
|
||||
/*! \param hardFlush is used to indicate whether all data should be std::flushed
|
||||
\note Hard std::flushes must be used with care. It means try to process and output everything, even if
|
||||
there may not be enough data to complete the action. For example, hard std::flushing a HexDecoder would
|
||||
cause an error if you do it after inputing an odd number of hex encoded characters.
|
||||
For some types of filters, for example ZlibDecompressor, hard flushes can only
|
||||
For some types of filters, for example ZlibDecompressor, hard std::flushes can only
|
||||
be done at "synchronization points". These synchronization points are positions in the data
|
||||
stream that are created by hard flushes on the corresponding reverse filters, in this
|
||||
stream that are created by hard std::flushes on the corresponding reverse filters, in this
|
||||
example ZlibCompressor. This is useful when zlib compressed data is moved across a
|
||||
network in packets and compression state is preserved across packets, as in the ssh2 protocol.
|
||||
*/
|
||||
|
|
@ -1263,7 +1263,7 @@ public:
|
|||
InvalidPlaintextLength() : Exception(OTHER_ERROR, "PK_Encryptor: invalid plaintext length") {}
|
||||
};
|
||||
|
||||
//! encrypt a byte string
|
||||
//! encrypt a byte std::string
|
||||
/*! \pre CiphertextLength(plaintextLength) != 0 (i.e., plaintext isn't too long)
|
||||
\pre size of ciphertext == CiphertextLength(plaintextLength)
|
||||
*/
|
||||
|
|
@ -1284,7 +1284,7 @@ public:
|
|||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_Decryptor : public PK_CryptoSystem, public PrivateKeyAlgorithm
|
||||
{
|
||||
public:
|
||||
//! decrypt a byte string, and return the length of plaintext
|
||||
//! decrypt a byte std::string, and return the length of plaintext
|
||||
/*! \pre size of plaintext == MaxPlaintextLength(ciphertextLength) bytes.
|
||||
\return the actual length of the plaintext, indication that decryption failed.
|
||||
*/
|
||||
|
|
@ -1478,7 +1478,7 @@ public:
|
|||
//! generate private/public key pair
|
||||
/*! \note equivalent to calling GeneratePrivateKey() and then GeneratePublicKey() */
|
||||
virtual void GenerateKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const;
|
||||
//! derive agreed value from your private key and couterparty's public key, return false in case of failure
|
||||
//! derive agreed value from your private key and std::couterparty's public key, return false in case of failure
|
||||
/*! \note If you have previously validated the public key, use validateOtherPublicKey=false to save time.
|
||||
\pre size of agreedValue == AgreedValueLength()
|
||||
\pre length of privateKey == PrivateKeyLength()
|
||||
|
|
@ -1532,7 +1532,7 @@ public:
|
|||
/*! \note equivalent to calling GenerateEphemeralPrivateKey() and then GenerateEphemeralPublicKey() */
|
||||
virtual void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const;
|
||||
|
||||
//! derive agreed value from your private keys and couterparty's public keys, return false in case of failure
|
||||
//! derive agreed value from your private keys and std::couterparty's public keys, return false in case of failure
|
||||
/*! \note The ephemeral public key will always be validated.
|
||||
If you have previously validated the static public key, use validateStaticOtherPublicKey=false to save time.
|
||||
\pre size of agreedValue == AgreedValueLength()
|
||||
|
|
|
|||
37
datatest.cpp
37
datatest.cpp
|
|
@ -15,7 +15,6 @@
|
|||
#include <iostream>
|
||||
|
||||
USING_NAMESPACE(CryptoPP)
|
||||
USING_NAMESPACE(std)
|
||||
|
||||
typedef std::map<std::string, std::string> TestData;
|
||||
static bool s_thorough;
|
||||
|
|
@ -32,7 +31,7 @@ static void OutputTestData(const TestData &v)
|
|||
{
|
||||
for (TestData::const_iterator i = v.begin(); i != v.end(); ++i)
|
||||
{
|
||||
cerr << i->first << ": " << i->second << endl;
|
||||
std::cerr << i->first << ": " << i->second << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -260,7 +259,7 @@ void TestSignatureScheme(TestData &v)
|
|||
}
|
||||
else if (test == "Sign")
|
||||
{
|
||||
SignerFilter f(GlobalRNG(), *signer, new HexEncoder(new FileSink(cout)));
|
||||
SignerFilter f(GlobalRNG(), *signer, new HexEncoder(new FileSink(std::cout)));
|
||||
StringSource ss(GetDecodedDatum(v, "Message"), true, new Redirector(f));
|
||||
SignalTestFailure();
|
||||
}
|
||||
|
|
@ -594,7 +593,7 @@ bool GetField(std::istream &is, std::string &name, std::string &value)
|
|||
if (name[name.size()-1] != ':')
|
||||
{
|
||||
char c;
|
||||
is >> skipws >> c;
|
||||
is >> std::skipws >> c;
|
||||
if (c != ':')
|
||||
SignalTestError();
|
||||
}
|
||||
|
|
@ -645,25 +644,25 @@ void OutputPair(const NameValuePairs &v, const char *name)
|
|||
Integer x;
|
||||
bool b = v.GetValue(name, x);
|
||||
CRYPTOPP_ASSERT(b); CRYPTOPP_UNUSED(b);
|
||||
cout << name << ": \\\n ";
|
||||
x.Encode(HexEncoder(new FileSink(cout), false, 64, "\\\n ").Ref(), x.MinEncodedSize());
|
||||
cout << endl;
|
||||
std::cout << name << ": \\\n ";
|
||||
x.Encode(HexEncoder(new FileSink(std::cout), false, 64, "\\\n ").Ref(), x.MinEncodedSize());
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
void OutputNameValuePairs(const NameValuePairs &v)
|
||||
{
|
||||
std::string names = v.GetValueNames();
|
||||
string::size_type i = 0;
|
||||
std::string::size_type i = 0;
|
||||
while (i < names.size())
|
||||
{
|
||||
string::size_type j = names.find_first_of (';', i);
|
||||
std::string::size_type j = names.find_first_of (';', i);
|
||||
|
||||
if (j == string::npos)
|
||||
if (j == std::string::npos)
|
||||
return;
|
||||
else
|
||||
{
|
||||
std::string name = names.substr(i, j-i);
|
||||
if (name.find(':') == string::npos)
|
||||
if (name.find(':') == std::string::npos)
|
||||
OutputPair(v, name.c_str());
|
||||
}
|
||||
|
||||
|
|
@ -700,7 +699,7 @@ void TestDataFile(const std::string &filename, const NameValuePairs &overridePar
|
|||
if (lastAlgName != GetRequiredDatum(v, "Name"))
|
||||
{
|
||||
lastAlgName = GetRequiredDatum(v, "Name");
|
||||
cout << "\nTesting " << algType.c_str() << " algorithm " << lastAlgName.c_str() << ".\n";
|
||||
std::cout << "\nTesting " << algType.c_str() << " algorithm " << lastAlgName.c_str() << ".\n";
|
||||
}
|
||||
|
||||
try
|
||||
|
|
@ -725,24 +724,24 @@ void TestDataFile(const std::string &filename, const NameValuePairs &overridePar
|
|||
}
|
||||
catch (TestFailure &)
|
||||
{
|
||||
cout << "\nTest failed.\n";
|
||||
std::cout << "\nTest failed.\n";
|
||||
}
|
||||
catch (CryptoPP::Exception &e)
|
||||
{
|
||||
cout << "\nCryptoPP::Exception caught: " << e.what() << endl;
|
||||
std::cout << "\nCryptoPP::Exception caught: " << e.what() << std::endl;
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
cout << "\nstd::exception caught: " << e.what() << endl;
|
||||
std::cout << "\nstd::exception caught: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
if (failed)
|
||||
{
|
||||
cout << "Skipping to next test.\n";
|
||||
std::cout << "Skipping to next test.\n";
|
||||
failedTests++;
|
||||
}
|
||||
else
|
||||
cout << "." << flush;
|
||||
std::cout << "." << std::flush;
|
||||
|
||||
totalTests++;
|
||||
}
|
||||
|
|
@ -754,8 +753,8 @@ bool RunTestDataFile(const char *filename, const NameValuePairs &overrideParamet
|
|||
s_thorough = thorough;
|
||||
unsigned int totalTests = 0, failedTests = 0;
|
||||
TestDataFile(filename, overrideParameters, totalTests, failedTests);
|
||||
cout << dec << "\nTests complete. Total tests = " << totalTests << ". Failed tests = " << failedTests << ".\n";
|
||||
std::cout << std::dec << "\nTests complete. Total tests = " << totalTests << ". Failed tests = " << failedTests << ".\n";
|
||||
if (failedTests != 0)
|
||||
cout << "SOME TESTS FAILED!\n";
|
||||
std::cout << "SOME TESTS FAILED!\n";
|
||||
return failedTests == 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ static const unsigned int BLOCKSIZE = Default_BlockCipher::Encryption::BLOCKSIZE
|
|||
static const unsigned int KEYLENGTH = Default_BlockCipher::Encryption::DEFAULT_KEYLENGTH;
|
||||
|
||||
// The purpose of this function Mash() is to take an arbitrary length input
|
||||
// string and *deterministicly* produce an arbitrary length output string such
|
||||
// std::string and *deterministicly* produce an arbitrary length output std::string such
|
||||
// that (1) it looks random, (2) no information about the input is
|
||||
// deducible from it, and (3) it contains as much entropy as it can hold, or
|
||||
// the amount of entropy in the input string, whichever is smaller.
|
||||
// the amount of entropy in the input std::string, whichever is smaller.
|
||||
|
||||
static void Mash(const byte *in, size_t inLen, byte *out, size_t outLen, int iterations)
|
||||
{
|
||||
|
|
|
|||
49
dlltest.cpp
49
dlltest.cpp
|
|
@ -6,23 +6,22 @@
|
|||
#include "trap.h"
|
||||
|
||||
USING_NAMESPACE(CryptoPP)
|
||||
USING_NAMESPACE(std)
|
||||
|
||||
void FIPS140_SampleApplication()
|
||||
{
|
||||
if (!FIPS_140_2_ComplianceEnabled())
|
||||
{
|
||||
cerr << "FIPS 140-2 compliance was turned off at compile time.\n";
|
||||
std::cerr << "FIPS 140-2 compliance was turned off at compile time.\n";
|
||||
abort();
|
||||
}
|
||||
|
||||
// check self test status
|
||||
if (GetPowerUpSelfTestStatus() != POWER_UP_SELF_TEST_PASSED)
|
||||
{
|
||||
cerr << "Automatic power-up self test failed.\n";
|
||||
std::cerr << "Automatic power-up self test failed.\n";
|
||||
abort();
|
||||
}
|
||||
cout << "0. Automatic power-up self test passed.\n";
|
||||
std::cout << "0. Automatic power-up self test passed.\n";
|
||||
|
||||
// simulate a power-up self test error
|
||||
SimulatePowerUpSelfTestFailure();
|
||||
|
|
@ -32,23 +31,23 @@ void FIPS140_SampleApplication()
|
|||
AES::Encryption aes;
|
||||
|
||||
// should not be here
|
||||
cerr << "Use of AES failed to cause an exception after power-up self test error.\n";
|
||||
std::cerr << "Use of AES failed to cause an exception after power-up self test error.\n";
|
||||
abort();
|
||||
}
|
||||
catch (SelfTestFailure &e)
|
||||
{
|
||||
cout << "1. Caught expected exception when simulating self test failure. Exception message follows: ";
|
||||
cout << e.what() << endl;
|
||||
std::cout << "1. Caught expected exception when simulating self test failure. Exception message follows: ";
|
||||
std::cout << e.what() << std::endl;
|
||||
}
|
||||
|
||||
// clear the self test error state and redo power-up self test
|
||||
DoDllPowerUpSelfTest();
|
||||
if (GetPowerUpSelfTestStatus() != POWER_UP_SELF_TEST_PASSED)
|
||||
{
|
||||
cerr << "Re-do power-up self test failed.\n";
|
||||
std::cerr << "Re-do power-up self test failed.\n";
|
||||
abort();
|
||||
}
|
||||
cout << "2. Re-do power-up self test passed.\n";
|
||||
std::cout << "2. Re-do power-up self test passed.\n";
|
||||
|
||||
// encrypt and decrypt
|
||||
const byte key[] = {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
|
||||
|
|
@ -70,10 +69,10 @@ void FIPS140_SampleApplication()
|
|||
|
||||
if (memcmp(plaintext, decrypted, 24) != 0)
|
||||
{
|
||||
cerr << "DES-EDE3-CFB Encryption/decryption failed.\n";
|
||||
std::cerr << "DES-EDE3-CFB Encryption/decryption failed.\n";
|
||||
abort();
|
||||
}
|
||||
cout << "3. DES-EDE3-CFB Encryption/decryption succeeded.\n";
|
||||
std::cout << "3. DES-EDE3-CFB Encryption/decryption succeeded.\n";
|
||||
|
||||
// hash
|
||||
const byte message[] = {'a', 'b', 'c'};
|
||||
|
|
@ -86,10 +85,10 @@ void FIPS140_SampleApplication()
|
|||
|
||||
if (memcmp(digest, expectedDigest, 20) != 0)
|
||||
{
|
||||
cerr << "SHA-1 hash failed.\n";
|
||||
std::cerr << "SHA-1 hash failed.\n";
|
||||
abort();
|
||||
}
|
||||
cout << "4. SHA-1 hash succeeded.\n";
|
||||
std::cout << "4. SHA-1 hash succeeded.\n";
|
||||
|
||||
// create auto-seeded X9.17 RNG object, if available
|
||||
#ifdef OS_RNG_AVAILABLE
|
||||
|
|
@ -106,10 +105,10 @@ void FIPS140_SampleApplication()
|
|||
dsaPublicKey.AssignFrom(dsaPrivateKey);
|
||||
if (!dsaPrivateKey.Validate(rng, 3) || !dsaPublicKey.Validate(rng, 3))
|
||||
{
|
||||
cerr << "DSA key generation failed.\n";
|
||||
std::cerr << "DSA key generation failed.\n";
|
||||
abort();
|
||||
}
|
||||
cout << "5. DSA key generation succeeded.\n";
|
||||
std::cout << "5. DSA key generation succeeded.\n";
|
||||
|
||||
// encode DSA key
|
||||
std::string encodedDsaPublicKey, encodedDsaPrivateKey;
|
||||
|
|
@ -124,10 +123,10 @@ void FIPS140_SampleApplication()
|
|||
|
||||
if (!decodedDsaPrivateKey.Validate(rng, 3) || !decodedDsaPublicKey.Validate(rng, 3))
|
||||
{
|
||||
cerr << "DSA key encode/decode failed.\n";
|
||||
std::cerr << "DSA key encode/decode failed.\n";
|
||||
abort();
|
||||
}
|
||||
cout << "6. DSA key encode/decode succeeded.\n";
|
||||
std::cout << "6. DSA key encode/decode succeeded.\n";
|
||||
|
||||
// sign and verify
|
||||
byte signature[40];
|
||||
|
|
@ -138,20 +137,20 @@ void FIPS140_SampleApplication()
|
|||
DSA::Verifier verifier(dsaPublicKey);
|
||||
if (!verifier.VerifyMessage(message, 3, signature, sizeof(signature)))
|
||||
{
|
||||
cerr << "DSA signature and verification failed.\n";
|
||||
std::cerr << "DSA signature and verification failed.\n";
|
||||
abort();
|
||||
}
|
||||
cout << "7. DSA signature and verification succeeded.\n";
|
||||
std::cout << "7. DSA signature and verification succeeded.\n";
|
||||
|
||||
|
||||
// try to verify an invalid signature
|
||||
signature[0] ^= 1;
|
||||
if (verifier.VerifyMessage(message, 3, signature, sizeof(signature)))
|
||||
{
|
||||
cerr << "DSA signature verification failed to detect bad signature.\n";
|
||||
std::cerr << "DSA signature verification failed to detect bad signature.\n";
|
||||
abort();
|
||||
}
|
||||
cout << "8. DSA signature verification successfully detected bad signature.\n";
|
||||
std::cout << "8. DSA signature verification successfully detected bad signature.\n";
|
||||
|
||||
// try to use an invalid key length
|
||||
try
|
||||
|
|
@ -160,16 +159,16 @@ void FIPS140_SampleApplication()
|
|||
encryption_DES_EDE3_ECB.SetKey(key, 5);
|
||||
|
||||
// should not be here
|
||||
cerr << "DES-EDE3 implementation did not detect use of invalid key length.\n";
|
||||
std::cerr << "DES-EDE3 implementation did not detect use of invalid key length.\n";
|
||||
abort();
|
||||
}
|
||||
catch (InvalidArgument &e)
|
||||
{
|
||||
cout << "9. Caught expected exception when using invalid key length. Exception message follows: ";
|
||||
cout << e.what() << endl;
|
||||
std::cout << "9. Caught expected exception when using invalid key length. Exception message follows: ";
|
||||
std::cout << e.what() << std::endl;
|
||||
}
|
||||
|
||||
cout << "\nFIPS 140-2 Sample Application completed normally.\n";
|
||||
std::cout << "\nFIPS 140-2 Sample Application completed normally.\n";
|
||||
}
|
||||
|
||||
#ifdef CRYPTOPP_IMPORTS
|
||||
|
|
|
|||
18
files.cpp
18
files.cpp
|
|
@ -38,7 +38,7 @@ void FileStore::StoreInitialize(const NameValuePairs ¶meters)
|
|||
return;
|
||||
}
|
||||
|
||||
ios::openmode binary = parameters.GetValueWithDefault(Name::InputBinaryMode(), true) ? ios::binary : ios::openmode(0);
|
||||
std::ios::openmode binary = parameters.GetValueWithDefault(Name::InputBinaryMode(), true) ? std::ios::binary : std::ios::openmode(0);
|
||||
m_file.reset(new std::ifstream);
|
||||
#ifdef CRYPTOPP_UNIX_AVAILABLE
|
||||
std::string narrowed;
|
||||
|
|
@ -48,14 +48,14 @@ void FileStore::StoreInitialize(const NameValuePairs ¶meters)
|
|||
#if _MSC_VER >= 1400
|
||||
if (fileNameWide)
|
||||
{
|
||||
m_file->open(fileNameWide, ios::in | binary);
|
||||
m_file->open(fileNameWide, std::ios::in | binary);
|
||||
if (!*m_file)
|
||||
throw OpenErr(StringNarrow(fileNameWide, false));
|
||||
}
|
||||
#endif
|
||||
if (fileName)
|
||||
{
|
||||
m_file->open(fileName, ios::in | binary);
|
||||
m_file->open(fileName, std::ios::in | binary);
|
||||
if (!*m_file)
|
||||
throw OpenErr(fileName);
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ lword FileStore::MaxRetrievable() const
|
|||
return 0;
|
||||
|
||||
streampos current = m_stream->tellg();
|
||||
streampos end = m_stream->seekg(0, ios::end).tellg();
|
||||
streampos end = m_stream->seekg(0, std::ios::end).tellg();
|
||||
m_stream->seekg(current);
|
||||
return end-current;
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ size_t FileStore::CopyRangeTo2(BufferedTransformation &target, lword &begin, lwo
|
|||
|
||||
// TODO: figure out what happens on cin
|
||||
streampos current = m_stream->tellg();
|
||||
streampos endPosition = m_stream->seekg(0, ios::end).tellg();
|
||||
streampos endPosition = m_stream->seekg(0, std::ios::end).tellg();
|
||||
streampos newPosition = current + (streamoff)begin;
|
||||
|
||||
if (newPosition >= endPosition)
|
||||
|
|
@ -174,7 +174,7 @@ lword FileStore::Skip(lword skipMax)
|
|||
std::istream::off_type offset;
|
||||
if (!SafeConvert(skipMax, offset))
|
||||
throw InvalidArgument("FileStore: maximum seek offset exceeded");
|
||||
m_stream->seekg(offset, ios::cur);
|
||||
m_stream->seekg(offset, std::ios::cur);
|
||||
return (lword)m_stream->tellg() - oldPos;
|
||||
}
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ void FileSink::IsolatedInitialize(const NameValuePairs ¶meters)
|
|||
return;
|
||||
}
|
||||
|
||||
ios::openmode binary = parameters.GetValueWithDefault(Name::OutputBinaryMode(), true) ? ios::binary : ios::openmode(0);
|
||||
std::ios::openmode binary = parameters.GetValueWithDefault(Name::OutputBinaryMode(), true) ? std::ios::binary : std::ios::openmode(0);
|
||||
m_file.reset(new std::ofstream);
|
||||
#ifdef CRYPTOPP_UNIX_AVAILABLE
|
||||
std::string narrowed;
|
||||
|
|
@ -204,14 +204,14 @@ void FileSink::IsolatedInitialize(const NameValuePairs ¶meters)
|
|||
#if _MSC_VER >= 1400
|
||||
if (fileNameWide)
|
||||
{
|
||||
m_file->open(fileNameWide, ios::out | ios::trunc | binary);
|
||||
m_file->open(fileNameWide, std::ios::out | std::ios::trunc | binary);
|
||||
if (!*m_file)
|
||||
throw OpenErr(StringNarrow(fileNameWide, false));
|
||||
}
|
||||
#endif
|
||||
if (fileName)
|
||||
{
|
||||
m_file->open(fileName, ios::out | ios::trunc | binary);
|
||||
m_file->open(fileName, std::ios::out | std::ios::trunc | binary);
|
||||
if (!*m_file)
|
||||
throw OpenErr(fileName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -582,7 +582,7 @@ public:
|
|||
: SimpleProxyFilter(decryptor.CreateDecryptionFilter(rng), attachment) {}
|
||||
};
|
||||
|
||||
//! Append input to a string object
|
||||
//! Append input to a std::string object
|
||||
template <class T>
|
||||
class StringSinkTemplate : public Bufferless<Sink>
|
||||
{
|
||||
|
|
@ -664,7 +664,7 @@ public:
|
|||
byte * CreatePutSpace(size_t &size) {return BufferedTransformation::CreatePutSpace(size);}
|
||||
};
|
||||
|
||||
//! string-based implementation of Store interface
|
||||
//! std::string-based implementation of Store interface
|
||||
class StringStore : public Store
|
||||
{
|
||||
public:
|
||||
|
|
@ -778,13 +778,13 @@ protected:
|
|||
T m_store;
|
||||
};
|
||||
|
||||
//! string-based implementation of Source interface
|
||||
//! std::string-based implementation of Source interface
|
||||
class CRYPTOPP_DLL StringSource : public SourceTemplate<StringStore>
|
||||
{
|
||||
public:
|
||||
StringSource(BufferedTransformation *attachment = NULL)
|
||||
: SourceTemplate<StringStore>(attachment) {}
|
||||
//! zero terminated string as source
|
||||
//! zero terminated std::string as source
|
||||
StringSource(const char *string, bool pumpAll, BufferedTransformation *attachment = NULL)
|
||||
: SourceTemplate<StringStore>(attachment) {SourceInitialize(pumpAll, MakeParameters("InputBuffer", ConstByteArrayParameter(string)));}
|
||||
//! binary byte array as source
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
#include "trap.h"
|
||||
|
||||
USING_NAMESPACE(CryptoPP)
|
||||
USING_NAMESPACE(std)
|
||||
|
||||
class LineBreakParser : public AutoSignaling<Bufferless<Filter> >
|
||||
{
|
||||
|
|
@ -787,7 +786,7 @@ protected:
|
|||
else if (m_bracketString == "L=64")
|
||||
pMAC.reset(new HMAC<SHA512>);
|
||||
else
|
||||
throw Exception(Exception::OTHER_ERROR, "TestDataParser: unexpected HMAC bracket string: " + m_bracketString);
|
||||
throw Exception(Exception::OTHER_ERROR, "TestDataParser: unexpected HMAC bracket std::string: " + m_bracketString);
|
||||
|
||||
pMAC->SetKey(key, key.size());
|
||||
int Tlen = atol(m_data["Tlen"].c_str());
|
||||
|
|
@ -1221,7 +1220,7 @@ int FIPS_140_AlgorithmTest(int argc, char **argv)
|
|||
|
||||
if (algorithm == "auto")
|
||||
{
|
||||
string algTable[] = {"AES", "ECDSA", "DSA", "HMAC", "RNG", "RSA", "TDES", "SKIPJACK", "SHA"}; // order is important here
|
||||
std::string algTable[] = {"AES", "ECDSA", "DSA", "HMAC", "RNG", "RSA", "TDES", "SKIPJACK", "SHA"}; // order is important here
|
||||
for (i=0; i<COUNTOF(algTable); i++)
|
||||
{
|
||||
if (dirname.find(algTable[i]) != std::string::npos)
|
||||
|
|
@ -1277,13 +1276,13 @@ int FIPS_140_AlgorithmTest(int argc, char **argv)
|
|||
pSink = new FileSink(outPathname.c_str(), false);
|
||||
}
|
||||
else
|
||||
pSink = new FileSink(cout);
|
||||
pSink = new FileSink(std::cout);
|
||||
|
||||
FileSource(pathname.c_str(), true, new LineBreakParser(new TestDataParser(algorithm, test, mode, feedbackSize, encrypt, pSink)), false);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
cout << "file: " << filename << endl;
|
||||
std::cout << "file: " << filename << std::endl;
|
||||
throw;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ extern PowerUpSelfTestStatus g_powerUpSelfTestStatus;
|
|||
SecByteBlock g_actualMac;
|
||||
unsigned long g_macFileLocation = 0;
|
||||
|
||||
// use a random dummy string here, to be searched/replaced later with the real MAC
|
||||
// use a random dummy std::string here, to be searched/replaced later with the real MAC
|
||||
static const byte s_moduleMac[CryptoPP::HMAC<CryptoPP::SHA1>::DIGESTSIZE] = CRYPTOPP_DUMMY_DLL_MAC;
|
||||
CRYPTOPP_COMPILE_ASSERT(sizeof(s_moduleMac) == CryptoPP::SHA1::DIGESTSIZE);
|
||||
|
||||
|
|
|
|||
4
gf2n.h
4
gf2n.h
|
|
@ -91,9 +91,9 @@ public:
|
|||
//* Precondition: bt.MaxRetrievable() >= inputLen
|
||||
void Decode(BufferedTransformation &bt, size_t inputLen);
|
||||
|
||||
//! encode value as big-endian octet string
|
||||
//! encode value as big-endian octet std::string
|
||||
void DEREncodeAsOctetString(BufferedTransformation &bt, size_t length) const;
|
||||
//! decode value as big-endian octet string
|
||||
//! decode value as big-endian octet std::string
|
||||
void BERDecodeAsOctetString(BufferedTransformation &bt, size_t length);
|
||||
//@}
|
||||
|
||||
|
|
|
|||
|
|
@ -4222,7 +4222,7 @@ const Integer& MontgomeryRepresentation::MultiplicativeInverse(const Integer &a)
|
|||
MontgomeryReduce(R, T+2*N, T, m_modulus.reg, m_u.reg, N);
|
||||
unsigned k = AlmostInverse(R, T, R, N, m_modulus.reg, N);
|
||||
|
||||
// cout << "k=" << k << " N*32=" << 32*N << endl;
|
||||
// std::cout << "k=" << k << " N*32=" << 32*N << std::endl;
|
||||
|
||||
if (k>N*WORD_BITS)
|
||||
DivideByPower2Mod(R, R, k-N*WORD_BITS, m_modulus.reg, N);
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public:
|
|||
//! convert from two words
|
||||
Integer(Sign s, word highWord, word lowWord);
|
||||
|
||||
//! convert from string
|
||||
//! convert from std::string
|
||||
/*! str can be in base 2, 8, 10, or 16. Base is determined by a
|
||||
case insensitive suffix of 'h', 'o', or 'b'. No suffix means base 10.
|
||||
*/
|
||||
|
|
@ -138,7 +138,7 @@ public:
|
|||
//! encode using Distinguished Encoding Rules, put result into a BufferedTransformation object
|
||||
void DEREncode(BufferedTransformation &bt) const;
|
||||
|
||||
//! encode absolute value as big-endian octet string
|
||||
//! encode absolute value as big-endian octet std::string
|
||||
void DEREncodeAsOctetString(BufferedTransformation &bt, size_t length) const;
|
||||
|
||||
//! encode absolute value in OpenPGP format, return length of output
|
||||
|
|
@ -157,7 +157,7 @@ public:
|
|||
//!
|
||||
void BERDecode(BufferedTransformation &bt);
|
||||
|
||||
//! decode nonnegative value as big-endian octet string
|
||||
//! decode nonnegative value as big-endian octet std::string
|
||||
void BERDecodeAsOctetString(BufferedTransformation &bt, size_t length);
|
||||
|
||||
class OpenPGPDecodeErr : public Exception
|
||||
|
|
|
|||
10
nbtheory.cpp
10
nbtheory.cpp
|
|
@ -562,15 +562,15 @@ Integer CRT(const Integer &xp, const Integer &p, const Integer &xq, const Intege
|
|||
return p * (u * (xq-xp) % q) + xp;
|
||||
/*
|
||||
Integer t1 = xq-xp;
|
||||
cout << hex << t1 << endl;
|
||||
std::cout << hex << t1 << std::endl;
|
||||
Integer t2 = u * t1;
|
||||
cout << hex << t2 << endl;
|
||||
std::cout << hex << t2 << std::endl;
|
||||
Integer t3 = t2 % q;
|
||||
cout << hex << t3 << endl;
|
||||
std::cout << hex << t3 << std::endl;
|
||||
Integer t4 = p * t3;
|
||||
cout << hex << t4 << endl;
|
||||
std::cout << hex << t4 << std::endl;
|
||||
Integer t5 = t4 + xp;
|
||||
cout << hex << t5 << endl;
|
||||
std::cout << hex << t5 << std::endl;
|
||||
return t5;
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
16
network.h
16
network.h
|
|
@ -115,7 +115,7 @@ public:
|
|||
virtual float GetMaxObservedSpeed() const =0;
|
||||
};
|
||||
|
||||
//! a Sink class that queues input and can flush to a device for a specified amount of time.
|
||||
//! a Sink class that queues input and can std::flush to a device for a specified amount of time.
|
||||
class CRYPTOPP_NO_VTABLE NonblockingSink : public Sink, public NonblockingSinkInfo, public LimitedBandwidth
|
||||
{
|
||||
public:
|
||||
|
|
@ -123,20 +123,20 @@ public:
|
|||
|
||||
bool IsolatedFlush(bool hardFlush, bool blocking);
|
||||
|
||||
//! flush to device for no more than maxTime milliseconds
|
||||
/*! This function will repeatedly attempt to flush data to some device, until
|
||||
//! std::flush to device for no more than maxTime milliseconds
|
||||
/*! This function will repeatedly attempt to std::flush data to some device, until
|
||||
the queue is empty, or a total of maxTime milliseconds have elapsed.
|
||||
If maxTime == 0, at least one attempt will be made to flush some data, but
|
||||
it is likely that not all queued data will be flushed, even if the device
|
||||
is ready to receive more data without waiting. If you want to flush as much data
|
||||
If maxTime == 0, at least one attempt will be made to std::flush some data, but
|
||||
it is likely that not all queued data will be std::flushed, even if the device
|
||||
is ready to receive more data without waiting. If you want to std::flush as much data
|
||||
as possible without waiting for the device, call this function in a loop.
|
||||
For example: while (sink.TimedFlush(0) > 0) {}
|
||||
\return number of bytes flushed
|
||||
\return number of bytes std::flushed
|
||||
*/
|
||||
lword TimedFlush(unsigned long maxTime, size_t targetSize = 0);
|
||||
|
||||
virtual void SetMaxBufferSize(size_t maxBufferSize) =0;
|
||||
//! set a bound which will cause sink to flush if exceeded by GetCurrentBufferSize()
|
||||
//! set a bound which will cause sink to std::flush if exceeded by GetCurrentBufferSize()
|
||||
virtual void SetAutoFlushBound(size_t bound) =0;
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ void PolynomialOver<T>::FromStr(const char *str, const Ring &ring)
|
|||
positive = false;
|
||||
break;
|
||||
default:
|
||||
return; // something's wrong with the input string
|
||||
return; // something's wrong with the input std::string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public:
|
|||
template <typename Iterator> PolynomialOver(Iterator begin, Iterator end)
|
||||
: m_coefficients(begin, end) {}
|
||||
|
||||
//! convert from string
|
||||
//! convert from std::string
|
||||
PolynomialOver(const char *str, const Ring &ring) {FromStr(str, ring);}
|
||||
|
||||
//! convert from big-endian byte array
|
||||
|
|
@ -184,7 +184,7 @@ public:
|
|||
template <typename Iterator> PolynomialOverFixedRing(Iterator first, Iterator last)
|
||||
: B(first, last) {}
|
||||
|
||||
//! convert from string
|
||||
//! convert from std::string
|
||||
explicit PolynomialOverFixedRing(const char *str) : B(str, ms_fixedRing) {}
|
||||
|
||||
//! convert from big-endian byte array
|
||||
|
|
|
|||
2
simple.h
2
simple.h
|
|
@ -72,7 +72,7 @@ public:
|
|||
bool ChannelFlush(const std::string &channel, bool hardFlush, int propagation=-1, bool blocking=true)
|
||||
{
|
||||
if (hardFlush && !InputBufferIsEmpty())
|
||||
throw CannotFlush("Unflushable<T>: this object has buffered input that cannot be flushed");
|
||||
throw CannotFlush("Unflushable<T>: this object has buffered input that cannot be std::flushed");
|
||||
else
|
||||
{
|
||||
BufferedTransformation *attached = this->AttachedTransformation();
|
||||
|
|
|
|||
81
test.cpp
81
test.cpp
|
|
@ -55,7 +55,6 @@
|
|||
#endif
|
||||
|
||||
USING_NAMESPACE(CryptoPP)
|
||||
USING_NAMESPACE(std)
|
||||
|
||||
const int MAX_PHRASE_LENGTH=250;
|
||||
|
||||
|
|
@ -66,8 +65,8 @@ const int MAX_PHRASE_LENGTH=250;
|
|||
void RegisterFactories();
|
||||
|
||||
void GenerateRSAKey(unsigned int keyLength, const char *privFilename, const char *pubFilename, const char *seed);
|
||||
string RSAEncryptString(const char *pubFilename, const char *seed, const char *message);
|
||||
string RSADecryptString(const char *privFilename, const char *ciphertext);
|
||||
std::string RSAEncryptString(const char *pubFilename, const char *seed, const char *message);
|
||||
std::string RSADecryptString(const char *privFilename, const char *ciphertext);
|
||||
void RSASignFile(const char *privFilename, const char *messageFilename, const char *signatureFilename);
|
||||
bool RSAVerifyFile(const char *pubFilename, const char *messageFilename, const char *signatureFilename);
|
||||
|
||||
|
|
@ -76,8 +75,8 @@ 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);
|
||||
std::string EncryptString(const char *plaintext, const char *passPhrase);
|
||||
std::string DecryptString(const char *ciphertext, const char *passPhrase);
|
||||
|
||||
void EncryptFile(const char *in, const char *out, const char *passPhrase);
|
||||
void DecryptFile(const char *in, const char *out, const char *passPhrase);
|
||||
|
|
@ -194,17 +193,17 @@ int CRYPTOPP_API main(int argc, char *argv[])
|
|||
unsigned int keyLength;
|
||||
|
||||
std::cout << "Key length in bits: ";
|
||||
cin >> keyLength;
|
||||
std::cin >> keyLength;
|
||||
|
||||
std::cout << "\nSave private key to file: ";
|
||||
cin >> privFilename;
|
||||
std::cin >> privFilename;
|
||||
|
||||
std::cout << "\nSave public key to file: ";
|
||||
cin >> pubFilename;
|
||||
std::cin >> pubFilename;
|
||||
|
||||
std::cout << "\nRandom Seed: ";
|
||||
ws(cin);
|
||||
cin.getline(seed, 1024);
|
||||
ws(std::cin);
|
||||
std::cin.getline(seed, 1024);
|
||||
|
||||
GenerateRSAKey(keyLength, privFilename, pubFilename, seed);
|
||||
}
|
||||
|
|
@ -221,22 +220,22 @@ int CRYPTOPP_API main(int argc, char *argv[])
|
|||
char seed[1024], message[1024];
|
||||
|
||||
std::cout << "Private key file: ";
|
||||
cin >> privFilename;
|
||||
std::cin >> privFilename;
|
||||
|
||||
std::cout << "\nPublic key file: ";
|
||||
cin >> pubFilename;
|
||||
std::cin >> pubFilename;
|
||||
|
||||
std::cout << "\nRandom Seed: ";
|
||||
ws(cin);
|
||||
cin.getline(seed, 1024);
|
||||
ws(std::cin);
|
||||
std::cin.getline(seed, 1024);
|
||||
|
||||
std::cout << "\nMessage: ";
|
||||
cin.getline(message, 1024);
|
||||
std::cin.getline(message, 1024);
|
||||
|
||||
string ciphertext = RSAEncryptString(pubFilename, seed, message);
|
||||
std::string ciphertext = RSAEncryptString(pubFilename, seed, message);
|
||||
std::cout << "\nCiphertext: " << ciphertext << std::endl;
|
||||
|
||||
string decrypted = RSADecryptString(privFilename, ciphertext.c_str());
|
||||
std::string decrypted = RSADecryptString(privFilename, ciphertext.c_str());
|
||||
std::cout << "\nDecrypted: " << decrypted << std::endl;
|
||||
}
|
||||
else if (command == "mt")
|
||||
|
|
@ -249,7 +248,7 @@ int CRYPTOPP_API main(int argc, char *argv[])
|
|||
else if (command == "mac_dll")
|
||||
{
|
||||
// sanity check on file size
|
||||
std::fstream dllFile(argv[2], ios::in | ios::out | ios::binary);
|
||||
std::fstream dllFile(argv[2], std::ios::in | std::ios::out | std::ios::binary);
|
||||
std::ifstream::pos_type fileEnd = dllFile.seekg(0, std::ios_base::end).tellg();
|
||||
if (fileEnd > 20*1000*1000)
|
||||
{
|
||||
|
|
@ -319,15 +318,15 @@ int CRYPTOPP_API main(int argc, char *argv[])
|
|||
char passPhrase[MAX_PHRASE_LENGTH], plaintext[1024];
|
||||
|
||||
std::cout << "Passphrase: ";
|
||||
cin.getline(passPhrase, MAX_PHRASE_LENGTH);
|
||||
std::cin.getline(passPhrase, MAX_PHRASE_LENGTH);
|
||||
|
||||
std::cout << "\nPlaintext: ";
|
||||
cin.getline(plaintext, 1024);
|
||||
std::cin.getline(plaintext, 1024);
|
||||
|
||||
string ciphertext = EncryptString(plaintext, passPhrase);
|
||||
std::string ciphertext = EncryptString(plaintext, passPhrase);
|
||||
std::cout << "\nCiphertext: " << ciphertext << std::endl;
|
||||
|
||||
string decrypted = DecryptString(ciphertext.c_str(), passPhrase);
|
||||
std::string decrypted = DecryptString(ciphertext.c_str(), passPhrase);
|
||||
std::cout << "\nDecrypted: " << decrypted << std::endl;
|
||||
|
||||
return 0;
|
||||
|
|
@ -344,7 +343,7 @@ int CRYPTOPP_API main(int argc, char *argv[])
|
|||
{
|
||||
char passPhrase[MAX_PHRASE_LENGTH];
|
||||
std::cout << "Passphrase: ";
|
||||
cin.getline(passPhrase, MAX_PHRASE_LENGTH);
|
||||
std::cin.getline(passPhrase, MAX_PHRASE_LENGTH);
|
||||
if (command == "e")
|
||||
EncryptFile(argv[2], argv[3], passPhrase);
|
||||
else
|
||||
|
|
@ -354,8 +353,8 @@ int CRYPTOPP_API main(int argc, char *argv[])
|
|||
{
|
||||
char seed[1024];
|
||||
std::cout << "\nRandom Seed: ";
|
||||
ws(cin);
|
||||
cin.getline(seed, 1024);
|
||||
ws(std::cin);
|
||||
std::cin.getline(seed, 1024);
|
||||
SecretShareFile(atoi(argv[2]), atoi(argv[3]), argv[4], seed);
|
||||
}
|
||||
else if (command == "sr")
|
||||
|
|
@ -460,7 +459,7 @@ void GenerateRSAKey(unsigned int keyLength, const char *privFilename, const char
|
|||
pubFile.MessageEnd();
|
||||
}
|
||||
|
||||
string RSAEncryptString(const char *pubFilename, const char *seed, const char *message)
|
||||
std::string RSAEncryptString(const char *pubFilename, const char *seed, const char *message)
|
||||
{
|
||||
FileSource pubFile(pubFilename, true, new HexDecoder);
|
||||
RSAES_OAEP_SHA_Encryptor pub(pubFile);
|
||||
|
|
@ -468,17 +467,17 @@ string RSAEncryptString(const char *pubFilename, const char *seed, const char *m
|
|||
RandomPool randPool;
|
||||
randPool.IncorporateEntropy((byte *)seed, strlen(seed));
|
||||
|
||||
string result;
|
||||
std::string result;
|
||||
StringSource(message, true, new PK_EncryptorFilter(randPool, pub, new HexEncoder(new StringSink(result))));
|
||||
return result;
|
||||
}
|
||||
|
||||
string RSADecryptString(const char *privFilename, const char *ciphertext)
|
||||
std::string RSADecryptString(const char *privFilename, const char *ciphertext)
|
||||
{
|
||||
FileSource privFile(privFilename, true, new HexDecoder);
|
||||
RSAES_OAEP_SHA_Decryptor priv(privFile);
|
||||
|
||||
string result;
|
||||
std::string result;
|
||||
StringSource(ciphertext, true, new HexDecoder(new PK_DecryptorFilter(GlobalRNG(), priv, new StringSink(result))));
|
||||
return result;
|
||||
}
|
||||
|
|
@ -566,9 +565,9 @@ void AES_CTR_Encrypt(const char *hexKey, const char *hexIV, const char *infile,
|
|||
FileSource(infile, true, new StreamTransformationFilter(aes, new FileSink(outfile)));
|
||||
}
|
||||
|
||||
string EncryptString(const char *instr, const char *passPhrase)
|
||||
std::string EncryptString(const char *instr, const char *passPhrase)
|
||||
{
|
||||
string outstr;
|
||||
std::string outstr;
|
||||
|
||||
DefaultEncryptorWithMAC encryptor(passPhrase, new HexEncoder(new StringSink(outstr)));
|
||||
encryptor.Put((byte *)instr, strlen(instr));
|
||||
|
|
@ -577,9 +576,9 @@ string EncryptString(const char *instr, const char *passPhrase)
|
|||
return outstr;
|
||||
}
|
||||
|
||||
string DecryptString(const char *instr, const char *passPhrase)
|
||||
std::string DecryptString(const char *instr, const char *passPhrase)
|
||||
{
|
||||
string outstr;
|
||||
std::string outstr;
|
||||
|
||||
HexDecoder decryptor(new DefaultDecryptorWithMAC(passPhrase, new StringSink(outstr)));
|
||||
decryptor.Put((byte *)instr, strlen(instr));
|
||||
|
|
@ -609,14 +608,14 @@ void SecretShareFile(int threshold, int nShares, const char *filename, const cha
|
|||
FileSource source(filename, false, new SecretSharing(rng, threshold, nShares, channelSwitch = new ChannelSwitch));
|
||||
|
||||
vector_member_ptrs<FileSink> fileSinks(nShares);
|
||||
string channel;
|
||||
std::string channel;
|
||||
for (int i=0; i<nShares; i++)
|
||||
{
|
||||
char extension[5] = ".000";
|
||||
extension[1]='0'+byte(i/100);
|
||||
extension[2]='0'+byte((i/10)%10);
|
||||
extension[3]='0'+byte(i%10);
|
||||
fileSinks[i].reset(new FileSink((string(filename)+extension).c_str()));
|
||||
fileSinks[i].reset(new FileSink((std::string(filename)+extension).c_str()));
|
||||
|
||||
channel = WordToString<word32>(i);
|
||||
fileSinks[i]->Put((byte *)channel.data(), 4);
|
||||
|
|
@ -640,7 +639,7 @@ void SecretRecoverFile(int threshold, const char *outFilename, char *const *inFi
|
|||
fileSources[i].reset(new FileSource(inFilenames[i], false));
|
||||
fileSources[i]->Pump(4);
|
||||
fileSources[i]->Get(channel, 4);
|
||||
fileSources[i]->Attach(new ChannelSwitch(recovery, string((char *)channel.begin(), 4)));
|
||||
fileSources[i]->Attach(new ChannelSwitch(recovery, std::string((char *)channel.begin(), 4)));
|
||||
}
|
||||
|
||||
while (fileSources[0]->Pump(256))
|
||||
|
|
@ -659,14 +658,14 @@ void InformationDisperseFile(int threshold, int nShares, const char *filename)
|
|||
FileSource source(filename, false, new InformationDispersal(threshold, nShares, channelSwitch = new ChannelSwitch));
|
||||
|
||||
vector_member_ptrs<FileSink> fileSinks(nShares);
|
||||
string channel;
|
||||
std::string channel;
|
||||
for (int i=0; i<nShares; i++)
|
||||
{
|
||||
char extension[5] = ".000";
|
||||
extension[1]='0'+byte(i/100);
|
||||
extension[2]='0'+byte((i/10)%10);
|
||||
extension[3]='0'+byte(i%10);
|
||||
fileSinks[i].reset(new FileSink((string(filename)+extension).c_str()));
|
||||
fileSinks[i].reset(new FileSink((std::string(filename)+extension).c_str()));
|
||||
|
||||
channel = WordToString<word32>(i);
|
||||
fileSinks[i]->Put((byte *)channel.data(), 4);
|
||||
|
|
@ -690,7 +689,7 @@ void InformationRecoverFile(int threshold, const char *outFilename, char *const
|
|||
fileSources[i].reset(new FileSource(inFilenames[i], false));
|
||||
fileSources[i]->Pump(4);
|
||||
fileSources[i]->Get(channel, 4);
|
||||
fileSources[i]->Attach(new ChannelSwitch(recovery, string((char *)channel.begin(), 4)));
|
||||
fileSources[i]->Attach(new ChannelSwitch(recovery, std::string((char *)channel.begin(), 4)));
|
||||
}
|
||||
|
||||
while (fileSources[0]->Pump(256))
|
||||
|
|
@ -801,7 +800,7 @@ void ForwardTcpPort(const char *sourcePortName, const char *destinationHost, con
|
|||
|
||||
if (!out.SourceExhausted())
|
||||
{
|
||||
std::cout << "o" << flush;
|
||||
std::cout << "o" << std::flush;
|
||||
out.PumpAll2(false);
|
||||
if (out.SourceExhausted())
|
||||
std::cout << "EOF received on source socket.\n";
|
||||
|
|
@ -809,7 +808,7 @@ void ForwardTcpPort(const char *sourcePortName, const char *destinationHost, con
|
|||
|
||||
if (!in.SourceExhausted())
|
||||
{
|
||||
std::cout << "i" << flush;
|
||||
std::cout << "i" << std::flush;
|
||||
in.PumpAll2(false);
|
||||
if (in.SourceExhausted())
|
||||
std::cout << "EOF received on destination socket.\n";
|
||||
|
|
|
|||
2
vmac.cpp
2
vmac.cpp
|
|
@ -793,7 +793,7 @@ void VMAC_Base::TruncatedFinal(byte *mac, size_t size)
|
|||
}
|
||||
else if (m_isFirstBlock)
|
||||
{
|
||||
// special case for empty string
|
||||
// special case for empty std::string
|
||||
m_polyState()[0] = m_polyState()[2];
|
||||
m_polyState()[1] = m_polyState()[3];
|
||||
if (m_is128)
|
||||
|
|
|
|||
4
wait.h
4
wait.h
|
|
@ -102,7 +102,7 @@ protected:
|
|||
|
||||
The advantage of this approach is that it is easy to use and should be very efficient,
|
||||
involving no allocation from the heap, just a linked list of stack objects containing
|
||||
pointers to static ASCIIZ strings (or possibly additional but simple data if derived). */
|
||||
pointers to static ASCIIZ std::strings (or possibly additional but simple data if derived). */
|
||||
class CallStack
|
||||
{
|
||||
public:
|
||||
|
|
@ -126,7 +126,7 @@ protected:
|
|||
word32 m_nr;
|
||||
};
|
||||
|
||||
/*! An extended CallStack entry type with an additional string parameter. */
|
||||
/*! An extended CallStack entry type with an additional std::string parameter. */
|
||||
class CallStackWithStr : public CallStack
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
Loading…
Reference in New Issue