mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2025-01-19 07:42:15 +00:00
Clear clang-tidy warnings
This commit is contained in:
parent
675575d960
commit
01136e2c7b
@ -7,8 +7,8 @@
|
||||
#define CRYPTOPP_ALGEBRA_H
|
||||
|
||||
#include "config.h"
|
||||
#include "misc.h"
|
||||
#include "integer.h"
|
||||
#include "misc.h"
|
||||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
|
7
aria.cpp
7
aria.cpp
@ -111,6 +111,9 @@ void ARIA::Base::UncheckedSetKey(const byte *key, unsigned int keylen, const Nam
|
||||
{
|
||||
CRYPTOPP_UNUSED(params);
|
||||
|
||||
m_rk.New(16*17); // round keys
|
||||
m_w.New(4*7); // w0, w1, w2, w3, t and u
|
||||
|
||||
const byte *mk = key;
|
||||
byte *rk = m_rk.data();
|
||||
int Q, q, R, r;
|
||||
@ -236,6 +239,10 @@ void ARIA::Base::UncheckedSetKey(const byte *key, unsigned int keylen, const Nam
|
||||
ARIA_MM(t[0],t[1],t[2],t[3]); ARIA_P(t[0],t[1],t[2],t[3]); ARIA_MM(t[0],t[1],t[2],t[3]);
|
||||
::memcpy(z, t, 16);
|
||||
}
|
||||
|
||||
// Silence warnings
|
||||
CRYPTOPP_UNUSED(Q); CRYPTOPP_UNUSED(R);
|
||||
CRYPTOPP_UNUSED(q); CRYPTOPP_UNUSED(r);
|
||||
}
|
||||
|
||||
void ARIA::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
|
||||
|
7
aria.h
7
aria.h
@ -50,8 +50,11 @@ public:
|
||||
|
||||
private:
|
||||
// Reference implementation allocates a table of 17 round keys.
|
||||
FixedSizeAlignedSecBlock<byte, 16*17> m_rk; // round keys
|
||||
FixedSizeAlignedSecBlock<word32, 4*7> m_w; // w0, w1, w2, w3, t and u
|
||||
typedef SecBlock<byte, AllocatorWithCleanup<byte, true> > AlignedByteBlock;
|
||||
typedef SecBlock<word32, AllocatorWithCleanup<word32, true> > AlignedWordBlock;
|
||||
|
||||
AlignedByteBlock m_rk; // round keys
|
||||
AlignedWordBlock m_w; // w0, w1, w2, w3, t and u
|
||||
unsigned int m_rounds;
|
||||
};
|
||||
|
||||
|
93
bench2.cpp
93
bench2.cpp
@ -31,6 +31,7 @@
|
||||
#include "oids.h"
|
||||
#include "randpool.h"
|
||||
#include "stdcpp.h"
|
||||
#include "hrtimer.h"
|
||||
|
||||
#if CRYPTOPP_MSC_VERSION
|
||||
# pragma warning(disable: 4505 4355)
|
||||
@ -45,12 +46,18 @@ void BenchMarkEncryption(const char *name, PK_Encryptor &key, double timeTotal,
|
||||
SecByteBlock plaintext(len), ciphertext(key.CiphertextLength(len));
|
||||
Test::GlobalRNG().GenerateBlock(plaintext, len);
|
||||
|
||||
unsigned int i;
|
||||
unsigned int i = 0;
|
||||
double timeTaken;
|
||||
|
||||
const clock_t start = ::clock();
|
||||
for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND, i++)
|
||||
ThreadUserTimer timer;
|
||||
timer.StartTimer();
|
||||
|
||||
do
|
||||
{
|
||||
key.Encrypt(Test::GlobalRNG(), plaintext, len, ciphertext);
|
||||
++i; timeTaken = timer.ElapsedTimeAsDouble();
|
||||
}
|
||||
while (timeTaken < timeTotal);
|
||||
|
||||
OutputResultOperations(name, "Encryption", pc, i, timeTaken);
|
||||
|
||||
@ -69,12 +76,18 @@ void BenchMarkDecryption(const char *name, PK_Decryptor &priv, PK_Encryptor &pub
|
||||
Test::GlobalRNG().GenerateBlock(plaintext, len);
|
||||
pub.Encrypt(Test::GlobalRNG(), plaintext, len, ciphertext);
|
||||
|
||||
unsigned int i;
|
||||
unsigned int i = 0;
|
||||
double timeTaken;
|
||||
|
||||
const clock_t start = ::clock();
|
||||
for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND, i++)
|
||||
ThreadUserTimer timer;
|
||||
timer.StartTimer();
|
||||
|
||||
do
|
||||
{
|
||||
priv.Decrypt(Test::GlobalRNG(), ciphertext, ciphertext.size(), plaintext);
|
||||
++i; timeTaken = timer.ElapsedTimeAsDouble();
|
||||
}
|
||||
while (timeTaken < timeTotal);
|
||||
|
||||
OutputResultOperations(name, "Decryption", false, i, timeTaken);
|
||||
}
|
||||
@ -85,12 +98,18 @@ void BenchMarkSigning(const char *name, PK_Signer &key, double timeTotal, bool p
|
||||
AlignedSecByteBlock message(len), signature(key.SignatureLength());
|
||||
Test::GlobalRNG().GenerateBlock(message, len);
|
||||
|
||||
unsigned int i;
|
||||
unsigned int i = 0;
|
||||
double timeTaken;
|
||||
|
||||
const clock_t start = ::clock();
|
||||
for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND, i++)
|
||||
ThreadUserTimer timer;
|
||||
timer.StartTimer();
|
||||
|
||||
do
|
||||
{
|
||||
(void)key.SignMessage(Test::GlobalRNG(), message, len, signature);
|
||||
++i; timeTaken = timer.ElapsedTimeAsDouble();
|
||||
}
|
||||
while (timeTaken < timeTotal);
|
||||
|
||||
OutputResultOperations(name, "Signature", pc, i, timeTaken);
|
||||
|
||||
@ -108,12 +127,18 @@ void BenchMarkVerification(const char *name, const PK_Signer &priv, PK_Verifier
|
||||
Test::GlobalRNG().GenerateBlock(message, len);
|
||||
priv.SignMessage(Test::GlobalRNG(), message, len, signature);
|
||||
|
||||
unsigned int i;
|
||||
unsigned int i = 0;
|
||||
double timeTaken;
|
||||
|
||||
const clock_t start = ::clock();
|
||||
for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND, i++)
|
||||
ThreadUserTimer timer;
|
||||
timer.StartTimer();
|
||||
|
||||
do
|
||||
{
|
||||
(void)pub.VerifyMessage(message, len, signature, signature.size());
|
||||
++i; timeTaken = timer.ElapsedTimeAsDouble();
|
||||
}
|
||||
while (timeTaken < timeTotal);
|
||||
|
||||
OutputResultOperations(name, "Verification", pc, i, timeTaken);
|
||||
|
||||
@ -128,12 +153,18 @@ void BenchMarkKeyGen(const char *name, SimpleKeyAgreementDomain &d, double timeT
|
||||
{
|
||||
SecByteBlock priv(d.PrivateKeyLength()), pub(d.PublicKeyLength());
|
||||
|
||||
unsigned int i;
|
||||
unsigned int i = 0;
|
||||
double timeTaken;
|
||||
|
||||
const clock_t start = ::clock();
|
||||
for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND, i++)
|
||||
ThreadUserTimer timer;
|
||||
timer.StartTimer();
|
||||
|
||||
do
|
||||
{
|
||||
d.GenerateKeyPair(Test::GlobalRNG(), priv, pub);
|
||||
++i; timeTaken = timer.ElapsedTimeAsDouble();
|
||||
}
|
||||
while (timeTaken < timeTotal);
|
||||
|
||||
OutputResultOperations(name, "Key-Pair Generation", pc, i, timeTaken);
|
||||
|
||||
@ -148,12 +179,18 @@ void BenchMarkKeyGen(const char *name, AuthenticatedKeyAgreementDomain &d, doubl
|
||||
{
|
||||
SecByteBlock priv(d.EphemeralPrivateKeyLength()), pub(d.EphemeralPublicKeyLength());
|
||||
|
||||
unsigned int i;
|
||||
unsigned int i = 0;
|
||||
double timeTaken;
|
||||
|
||||
const clock_t start = ::clock();
|
||||
for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND, i++)
|
||||
ThreadUserTimer timer;
|
||||
timer.StartTimer();
|
||||
|
||||
do
|
||||
{
|
||||
d.GenerateEphemeralKeyPair(Test::GlobalRNG(), priv, pub);
|
||||
++i; timeTaken = timer.ElapsedTimeAsDouble();
|
||||
}
|
||||
while (timeTaken < timeTotal);
|
||||
|
||||
OutputResultOperations(name, "Key-Pair Generation", pc, i, timeTaken);
|
||||
|
||||
@ -172,15 +209,19 @@ void BenchMarkAgreement(const char *name, SimpleKeyAgreementDomain &d, double ti
|
||||
d.GenerateKeyPair(Test::GlobalRNG(), priv2, pub2);
|
||||
SecByteBlock val(d.AgreedValueLength());
|
||||
|
||||
unsigned int i;
|
||||
unsigned int i = 0;
|
||||
double timeTaken;
|
||||
|
||||
const clock_t start = ::clock();
|
||||
for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND, i+=2)
|
||||
ThreadUserTimer timer;
|
||||
timer.StartTimer();
|
||||
|
||||
do
|
||||
{
|
||||
d.Agree(val, priv1, pub2);
|
||||
d.Agree(val, priv2, pub1);
|
||||
i+=2; timeTaken = timer.ElapsedTimeAsDouble();
|
||||
}
|
||||
while (timeTaken < timeTotal);
|
||||
|
||||
OutputResultOperations(name, "Key Agreement", pc, i, timeTaken);
|
||||
}
|
||||
@ -197,15 +238,19 @@ void BenchMarkAgreement(const char *name, AuthenticatedKeyAgreementDomain &d, do
|
||||
d.GenerateEphemeralKeyPair(Test::GlobalRNG(), epriv2, epub2);
|
||||
SecByteBlock val(d.AgreedValueLength());
|
||||
|
||||
unsigned int i;
|
||||
unsigned int i = 0;
|
||||
double timeTaken;
|
||||
|
||||
const clock_t start = ::clock();
|
||||
for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(::clock() - start) / CLOCK_TICKS_PER_SECOND, i+=2)
|
||||
ThreadUserTimer timer;
|
||||
timer.StartTimer();
|
||||
|
||||
do
|
||||
{
|
||||
d.Agree(val, spriv1, epriv1, spub2, epub2);
|
||||
d.Agree(val, spriv2, epriv2, spub1, epub1);
|
||||
i+=2; timeTaken = timer.ElapsedTimeAsDouble();
|
||||
}
|
||||
while (timeTaken < timeTotal);
|
||||
|
||||
OutputResultOperations(name, "Key Agreement", pc, i, timeTaken);
|
||||
}
|
||||
|
@ -248,15 +248,9 @@ void BLAKE2_Base<W, T_64bit>::UncheckedSetKey(const byte *key, unsigned int leng
|
||||
m_key.resize(0);
|
||||
}
|
||||
|
||||
#if defined(__COVERITY__)
|
||||
// Avoid Coverity finding SIZEOF_MISMATCH/suspicious_sizeof
|
||||
ParameterBlock& block = *m_block.data();
|
||||
memset(m_block.data(), 0x00, sizeof(ParameterBlock));
|
||||
#else
|
||||
// Set Head bytes; Tail bytes are set below
|
||||
ParameterBlock& block = *m_block.data();
|
||||
memset(m_block.data(), 0x00, T_64bit ? 32 : 16);
|
||||
#endif
|
||||
|
||||
block.keyLength = (byte)length;
|
||||
block.digestLength = (byte)params.GetIntValueWithDefault(Name::DigestSize(), DIGESTSIZE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user