mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2024-11-23 01:49:41 +00:00
Use std namespace for memset, memcpy, memcmp (#1204)
This commit is contained in:
parent
358d0cfecd
commit
f5f63850f9
@ -27,12 +27,9 @@ NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
void CallNewHandler()
|
||||
{
|
||||
using std::new_handler;
|
||||
using std::set_new_handler;
|
||||
|
||||
new_handler newHandler = set_new_handler(NULLPTR);
|
||||
std::new_handler newHandler = std::set_new_handler(NULLPTR);
|
||||
if (newHandler)
|
||||
set_new_handler(newHandler);
|
||||
std::set_new_handler(newHandler);
|
||||
|
||||
if (newHandler)
|
||||
newHandler();
|
||||
|
@ -22,7 +22,7 @@ void AuthenticatedSymmetricCipherBase::AuthenticateData(const byte *input, size_
|
||||
{
|
||||
if (num+len >= blockSize)
|
||||
{
|
||||
memcpy(data+num, input, blockSize-num);
|
||||
std::memcpy(data+num, input, blockSize-num);
|
||||
AuthenticateBlocks(data, blockSize);
|
||||
input += (blockSize-num);
|
||||
len -= (blockSize-num);
|
||||
@ -31,7 +31,7 @@ void AuthenticatedSymmetricCipherBase::AuthenticateData(const byte *input, size_
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(data+num, input, len);
|
||||
std::memcpy(data+num, input, len);
|
||||
num += (unsigned int)len;
|
||||
return;
|
||||
}
|
||||
@ -46,7 +46,7 @@ void AuthenticatedSymmetricCipherBase::AuthenticateData(const byte *input, size_
|
||||
}
|
||||
|
||||
if (data && len)
|
||||
memcpy(data, input, len);
|
||||
std::memcpy(data, input, len);
|
||||
num = (unsigned int)len;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ size_t BaseN_Encoder::Put2(const byte *begin, size_t length, int messageEnd, boo
|
||||
while (m_inputPosition < length)
|
||||
{
|
||||
if (m_bytePos == 0)
|
||||
memset(m_outBuf, 0, m_outputBlockSize);
|
||||
std::memset(m_outBuf, 0, m_outputBlockSize);
|
||||
|
||||
{
|
||||
unsigned int b = begin[m_inputPosition++], bitsLeftInSource = 8;
|
||||
@ -103,7 +103,7 @@ size_t BaseN_Encoder::Put2(const byte *begin, size_t length, int messageEnd, boo
|
||||
|
||||
if (m_padding != -1 && m_bytePos > 0)
|
||||
{
|
||||
memset(m_outBuf+m_bytePos, m_padding, m_outputBlockSize-m_bytePos);
|
||||
std::memset(m_outBuf+m_bytePos, m_padding, m_outputBlockSize-m_bytePos);
|
||||
m_bytePos = m_outputBlockSize;
|
||||
}
|
||||
FILTER_OUTPUT(2, m_outBuf, m_bytePos, messageEnd);
|
||||
@ -141,7 +141,7 @@ size_t BaseN_Decoder::Put2(const byte *begin, size_t length, int messageEnd, boo
|
||||
continue;
|
||||
|
||||
if (m_bytePos == 0 && m_bitPos == 0)
|
||||
memset(m_outBuf, 0, m_outputBlockSize);
|
||||
std::memset(m_outBuf, 0, m_outputBlockSize);
|
||||
|
||||
{
|
||||
int newBitPos = m_bitPos + m_bitsPerChar;
|
||||
|
@ -13,8 +13,8 @@ void Blowfish::Base::UncheckedSetKey(const byte *key_string, unsigned int keylen
|
||||
unsigned i, j=0, k;
|
||||
word32 data, dspace[2] = {0, 0};
|
||||
|
||||
memcpy(pbox, p_init, sizeof(p_init));
|
||||
memcpy(sbox, s_init, sizeof(s_init));
|
||||
std::memcpy(pbox, p_init, sizeof(p_init));
|
||||
std::memcpy(sbox, s_init, sizeof(s_init));
|
||||
|
||||
// Xor key string into encryption key vector
|
||||
for (i=0 ; i<ROUNDS+2 ; ++i)
|
||||
|
@ -47,8 +47,8 @@ void CBC_MAC_Base::TruncatedFinal(byte *mac, size_t size)
|
||||
if (m_counter)
|
||||
ProcessBuf();
|
||||
|
||||
memcpy(mac, m_reg, size);
|
||||
memset(m_reg, 0, AccessCipher().BlockSize());
|
||||
std::memcpy(mac, m_reg, size);
|
||||
std::memset(m_reg, 0, AccessCipher().BlockSize());
|
||||
}
|
||||
|
||||
void CBC_MAC_Base::ProcessBuf()
|
||||
|
6
ccm.cpp
6
ccm.cpp
@ -34,8 +34,8 @@ void CCM_Base::Resync(const byte *iv, size_t len)
|
||||
m_L = 8;
|
||||
|
||||
m_buffer[0] = byte(m_L-1); // flag
|
||||
memcpy(m_buffer+1, iv, len);
|
||||
memset(m_buffer+1+len, 0, REQUIRED_BLOCKSIZE-1-len);
|
||||
std::memcpy(m_buffer+1, iv, len);
|
||||
std::memset(m_buffer+1+len, 0, REQUIRED_BLOCKSIZE-1-len);
|
||||
|
||||
if (m_state >= State_IVSet)
|
||||
m_ctr.Resynchronize(m_buffer, REQUIRED_BLOCKSIZE);
|
||||
@ -60,7 +60,7 @@ void CCM_Base::UncheckedSpecifyDataLengths(lword headerLength, lword messageLeng
|
||||
|
||||
cbcBuffer[0] = byte(64*(headerLength>0) + 8*((m_digestSize-2)/2) + (m_L-1)); // flag
|
||||
PutWord<word64>(true, BIG_ENDIAN_ORDER, cbcBuffer+REQUIRED_BLOCKSIZE-8, m_messageLength);
|
||||
memcpy(cbcBuffer+1, m_buffer+1, REQUIRED_BLOCKSIZE-1-m_L);
|
||||
std::memcpy(cbcBuffer+1, m_buffer+1, REQUIRED_BLOCKSIZE-1-m_L);
|
||||
cipher.ProcessBlock(cbcBuffer);
|
||||
|
||||
if (headerLength>0)
|
||||
|
6
cmac.cpp
6
cmac.cpp
@ -87,7 +87,7 @@ void CMAC_Base::UncheckedSetKey(const byte *key, unsigned int length, const Name
|
||||
|
||||
cipher.ProcessBlock(m_reg, m_reg+blockSize);
|
||||
MulU(m_reg+blockSize, blockSize);
|
||||
memcpy(m_reg+2*blockSize, m_reg+blockSize, blockSize);
|
||||
std::memcpy(m_reg+2*blockSize, m_reg+blockSize, blockSize);
|
||||
MulU(m_reg+2*blockSize, blockSize);
|
||||
}
|
||||
|
||||
@ -153,10 +153,10 @@ void CMAC_Base::TruncatedFinal(byte *mac, size_t size)
|
||||
|
||||
// UBsan finding
|
||||
if (mac)
|
||||
memcpy(mac, m_reg, size);
|
||||
std::memcpy(mac, m_reg, size);
|
||||
|
||||
m_counter = 0;
|
||||
memset(m_reg, 0, blockSize);
|
||||
std::memset(m_reg, 0, blockSize);
|
||||
}
|
||||
|
||||
NAMESPACE_END
|
||||
|
12
default.cpp
12
default.cpp
@ -48,7 +48,7 @@ static void Mash(const byte *in, size_t inLen, byte *out, size_t outLen, int ite
|
||||
|
||||
while (iterations-- > 1)
|
||||
{
|
||||
memcpy(buf, outBuf, bufSize);
|
||||
std::memcpy(buf, outBuf, bufSize);
|
||||
for (i=0; i<bufSize; i+=H::DIGESTSIZE)
|
||||
{
|
||||
b[0] = (byte) (i >> 8);
|
||||
@ -59,7 +59,7 @@ static void Mash(const byte *in, size_t inLen, byte *out, size_t outLen, int ite
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(out, outBuf, outLen);
|
||||
std::memcpy(out, outBuf, outLen);
|
||||
}
|
||||
|
||||
template <class BC, class H, class Info>
|
||||
@ -68,15 +68,15 @@ static void GenerateKeyIV(const byte *passphrase, size_t passphraseLength, const
|
||||
// UBsan. User supplied params, may be NULL
|
||||
SecByteBlock temp(passphraseLength+saltLength);
|
||||
if (passphrase != NULLPTR)
|
||||
memcpy(temp, passphrase, passphraseLength);
|
||||
std::memcpy(temp, passphrase, passphraseLength);
|
||||
if (salt != NULLPTR)
|
||||
memcpy(temp+passphraseLength, salt, saltLength);
|
||||
std::memcpy(temp+passphraseLength, salt, saltLength);
|
||||
|
||||
// OK. Derived params, cannot be NULL
|
||||
SecByteBlock keyIV(EnumToInt(Info::KEYLENGTH)+EnumToInt(+Info::BLOCKSIZE));
|
||||
Mash<H>(temp, passphraseLength + saltLength, keyIV, EnumToInt(Info::KEYLENGTH)+EnumToInt(+Info::BLOCKSIZE), iterations);
|
||||
memcpy(key, keyIV, Info::KEYLENGTH);
|
||||
memcpy(IV, keyIV+Info::KEYLENGTH, Info::BLOCKSIZE);
|
||||
std::memcpy(key, keyIV, Info::KEYLENGTH);
|
||||
std::memcpy(IV, keyIV+Info::KEYLENGTH, Info::BLOCKSIZE);
|
||||
}
|
||||
|
||||
// ********************************************************
|
||||
|
6
des.cpp
6
des.cpp
@ -304,7 +304,7 @@ void RawDES::RawSetKey(CipherDir dir, const byte *key)
|
||||
? 1 : 0; /* and store 1-bit result */
|
||||
}
|
||||
for (i=0; i<16; i++) { /* key chunk for each iteration */
|
||||
memset(ks,0,8); /* Clear key schedule */
|
||||
std::memset(ks,0,8); /* Clear key schedule */
|
||||
for (j=0; j<56; j++) /* rotate pc1 the right amount */
|
||||
pcr[j] = pc1m[(l=j+totrot[i])<(j<28? 28 : 56) ? l: l-28];
|
||||
/* rotate left and right halves independently */
|
||||
@ -450,9 +450,9 @@ void DES_XEX3::Base::UncheckedSetKey(const byte *key, unsigned int length, const
|
||||
if (!m_des.get())
|
||||
m_des.reset(new DES::Encryption);
|
||||
|
||||
memcpy(m_x1, key + (IsForwardTransformation() ? 0 : 16), BLOCKSIZE);
|
||||
std::memcpy(m_x1, key + (IsForwardTransformation() ? 0 : 16), BLOCKSIZE);
|
||||
m_des->RawSetKey(GetCipherDirection(), key + 8);
|
||||
memcpy(m_x3, key + (IsForwardTransformation() ? 16 : 0), BLOCKSIZE);
|
||||
std::memcpy(m_x3, key + (IsForwardTransformation() ? 16 : 0), BLOCKSIZE);
|
||||
}
|
||||
|
||||
void DES_XEX3::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
|
||||
|
2
dll.cpp
2
dll.cpp
@ -66,7 +66,7 @@ NAMESPACE_END
|
||||
|
||||
USING_NAMESPACE(CryptoPP)
|
||||
|
||||
using std::set_new_handler;
|
||||
using set_new_handler;
|
||||
|
||||
static PNew s_pNew = NULLPTR;
|
||||
static PDelete s_pDelete = NULLPTR;
|
||||
|
@ -73,7 +73,7 @@ void FIPS140_SampleApplication()
|
||||
decryption_DES_EDE3_CFB.SetKeyWithIV(key, sizeof(key), iv);
|
||||
decryption_DES_EDE3_CFB.ProcessString(decrypted, ciphertext, 24);
|
||||
|
||||
if (memcmp(plaintext, decrypted, 24) != 0)
|
||||
if (std::memcmp(plaintext, decrypted, 24) != 0)
|
||||
{
|
||||
std::cerr << "DES-EDE3-CFB Encryption/decryption failed.\n";
|
||||
abort();
|
||||
@ -89,7 +89,7 @@ void FIPS140_SampleApplication()
|
||||
sha.Update(message, 3);
|
||||
sha.Final(digest);
|
||||
|
||||
if (memcmp(digest, expectedDigest, 20) != 0)
|
||||
if (std::memcmp(digest, expectedDigest, 20) != 0)
|
||||
{
|
||||
std::cerr << "SHA-1 hash failed.\n";
|
||||
abort();
|
||||
|
4
dmac.h
4
dmac.h
@ -90,7 +90,7 @@ void DMAC_Base<T>::TruncatedFinal(byte *mac, size_t size)
|
||||
|
||||
byte pad[T::BLOCKSIZE];
|
||||
byte padByte = byte(T::BLOCKSIZE-m_counter);
|
||||
memset(pad, padByte, padByte);
|
||||
std::memset(pad, padByte, padByte);
|
||||
m_mac1.Update(pad, padByte);
|
||||
m_mac1.TruncatedFinal(mac, size);
|
||||
m_f2.ProcessBlock(mac);
|
||||
@ -102,7 +102,7 @@ template <class T>
|
||||
byte *DMAC_Base<T>::GenerateSubKeys(const byte *key, size_t keylength)
|
||||
{
|
||||
typename T::Encryption cipher(key, keylength);
|
||||
memset(m_subkeys, 0, m_subkeys.size());
|
||||
std::memset(m_subkeys, 0, m_subkeys.size());
|
||||
cipher.ProcessBlock(m_subkeys);
|
||||
m_subkeys[m_subkeys.size()/2 + T::BLOCKSIZE - 1] = 1;
|
||||
cipher.ProcessBlock(m_subkeys+m_subkeys.size()/2);
|
||||
|
@ -1286,7 +1286,7 @@ expand256_modm(bignum256modm out, const byte *in, size_t len) {
|
||||
bignum256modm_element_t x[16];
|
||||
bignum256modm q1;
|
||||
|
||||
memcpy(work, in, len);
|
||||
std::memcpy(work, in, len);
|
||||
x[0] = U8TO32_LE(work + 0);
|
||||
x[1] = U8TO32_LE(work + 4);
|
||||
x[2] = U8TO32_LE(work + 8);
|
||||
@ -1700,7 +1700,7 @@ ge25519_double_scalarmult_vartime(ge25519 *r, const ge25519 *p1, const bignum256
|
||||
ge25519_pnielsadd(&pre1[i+1], &d1, &pre1[i]);
|
||||
|
||||
/* set neutral */
|
||||
memset(r, 0, sizeof(ge25519));
|
||||
std::memset(r, 0, sizeof(ge25519));
|
||||
r->y[0] = 1;
|
||||
r->z[0] = 1;
|
||||
|
||||
@ -1773,7 +1773,7 @@ ge25519_scalarmult_base_niels(ge25519 *r, const byte basepoint_table[256][96], c
|
||||
ge25519_scalarmult_base_choose_niels(&t, basepoint_table, 0, b[1]);
|
||||
curve25519_sub_reduce(r->x, t.xaddy, t.ysubx);
|
||||
curve25519_add_reduce(r->y, t.xaddy, t.ysubx);
|
||||
memset(r->z, 0, sizeof(bignum25519));
|
||||
std::memset(r->z, 0, sizeof(bignum25519));
|
||||
curve25519_copy(r->t, t.t2d);
|
||||
r->z[0] = 2;
|
||||
for (i = 3; i < 64; i += 2) {
|
||||
|
@ -978,7 +978,7 @@ expand256_modm(bignum256modm out, const byte *in, size_t len) {
|
||||
bignum256modm_element_t x[16];
|
||||
bignum256modm q1;
|
||||
|
||||
memcpy(work, in, len);
|
||||
std::memcpy(work, in, len);
|
||||
x[0] = U8TO64_LE(work + 0);
|
||||
x[1] = U8TO64_LE(work + 8);
|
||||
x[2] = U8TO64_LE(work + 16);
|
||||
@ -1415,7 +1415,7 @@ ge25519_double_scalarmult_vartime(ge25519 *r, const ge25519 *p1, const bignum256
|
||||
ge25519_pnielsadd(&pre1[i+1], &d1, &pre1[i]);
|
||||
|
||||
/* set neutral */
|
||||
memset(r, 0, sizeof(ge25519));
|
||||
std::memset(r, 0, sizeof(ge25519));
|
||||
r->y[0] = 1;
|
||||
r->z[0] = 1;
|
||||
|
||||
@ -1488,7 +1488,7 @@ ge25519_scalarmult_base_niels(ge25519 *r, const byte basepoint_table[256][96], c
|
||||
ge25519_scalarmult_base_choose_niels(&t, basepoint_table, 0, b[1]);
|
||||
curve25519_sub_reduce(r->x, t.xaddy, t.ysubx);
|
||||
curve25519_add_reduce(r->y, t.xaddy, t.ysubx);
|
||||
memset(r->z, 0, sizeof(bignum25519));
|
||||
std::memset(r->z, 0, sizeof(bignum25519));
|
||||
curve25519_copy(r->t, t.t2d);
|
||||
r->z[0] = 2;
|
||||
for (i = 3; i < 64; i += 2) {
|
||||
|
2
drbg.h
2
drbg.h
@ -654,7 +654,7 @@ void HMAC_DRBG<HASH, STRENGTH, SEEDLENGTH>::HMAC_Generate(const byte* additional
|
||||
m_hmac.TruncatedFinal(m_v, m_v.size());
|
||||
|
||||
size_t count = STDMIN(size, (size_t)HASH::DIGESTSIZE);
|
||||
memcpy(output, m_v, count);
|
||||
std::memcpy(output, m_v, count);
|
||||
size -= count; output += count;
|
||||
}
|
||||
|
||||
|
4
eax.cpp
4
eax.cpp
@ -16,7 +16,7 @@ void EAX_Base::Resync(const byte *iv, size_t len)
|
||||
MessageAuthenticationCode &mac = AccessMAC();
|
||||
unsigned int blockSize = mac.TagSize();
|
||||
|
||||
memset(m_buffer, 0, blockSize);
|
||||
std::memset(m_buffer, 0, blockSize);
|
||||
mac.Update(m_buffer, blockSize);
|
||||
mac.CalculateDigest(m_buffer+blockSize, iv, len);
|
||||
|
||||
@ -41,7 +41,7 @@ void EAX_Base::AuthenticateLastHeaderBlock()
|
||||
mac.Final(m_buffer);
|
||||
xorbuf(m_buffer+blockSize, m_buffer, blockSize);
|
||||
|
||||
memset(m_buffer, 0, blockSize);
|
||||
std::memset(m_buffer, 0, blockSize);
|
||||
m_buffer[blockSize-1] = 2;
|
||||
mac.Update(m_buffer, blockSize);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
|
||||
SecByteBlock block(modulusLen-1);
|
||||
rng.GenerateBlock(block, modulusLen-2-plainTextLength);
|
||||
memcpy(block+modulusLen-2-plainTextLength, plainText, plainTextLength);
|
||||
std::memcpy(block+modulusLen-2-plainTextLength, plainText, plainTextLength);
|
||||
block[modulusLen-2] = (byte)plainTextLength;
|
||||
|
||||
a_times_b_mod_c(Integer(key, modulusLen), Integer(block, modulusLen-1), p).Encode(cipherText, modulusLen);
|
||||
|
@ -31,7 +31,7 @@ void EMSA2Pad::ComputeMessageRepresentative(RandomNumberGenerator& /*rng*/,
|
||||
size_t representativeByteLength = BitsToBytes(representativeBitLength);
|
||||
|
||||
representative[0] = messageEmpty ? 0x4b : 0x6b;
|
||||
memset(representative+1, 0xbb, representativeByteLength-digestSize-4); // pad with 0xbb
|
||||
std::memset(representative+1, 0xbb, representativeByteLength-digestSize-4); // pad with 0xbb
|
||||
byte *afterP2 = representative+representativeByteLength-digestSize-3;
|
||||
afterP2[0] = 0xba;
|
||||
hash.Final(afterP2+1);
|
||||
|
14
esign.cpp
14
esign.cpp
@ -112,7 +112,7 @@ void InvertibleESIGNFunction::GenerateRandom(RandomNumberGenerator &rng, const N
|
||||
if (param.GetValue("Seed", seedParam))
|
||||
{
|
||||
seed.resize(seedParam.size() + 4);
|
||||
memcpy(seed + 4, seedParam.begin(), seedParam.size());
|
||||
std::memcpy(seed + 4, seedParam.begin(), seedParam.size());
|
||||
|
||||
PutWord(false, BIG_ENDIAN_ORDER, seed, (word32)0);
|
||||
m_p.GenerateRandom(rng, CombinedNameValuePairs(primeParam, MakeParameters("Seed", ConstByteArrayParameter(seed))));
|
||||
@ -177,17 +177,7 @@ Integer InvertibleESIGNFunction::CalculateRandomizedInverse(RandomNumberGenerato
|
||||
Integer t = modp.Divide(w0 * r % m_p, m_e * re % m_p);
|
||||
Integer s = r + t*pq;
|
||||
CRYPTOPP_ASSERT(s < m_n);
|
||||
#if 0
|
||||
using namespace std;
|
||||
cout << "f = " << x << endl;
|
||||
cout << "r = " << r << endl;
|
||||
cout << "z = " << z << endl;
|
||||
cout << "a = " << a << endl;
|
||||
cout << "w0 = " << w0 << endl;
|
||||
cout << "w1 = " << w1 << endl;
|
||||
cout << "t = " << t << endl;
|
||||
cout << "s = " << s << endl;
|
||||
#endif
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
2
fhmqv.h
2
fhmqv.h
@ -214,7 +214,7 @@ public:
|
||||
void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
|
||||
{
|
||||
CRYPTOPP_UNUSED(rng);
|
||||
memcpy(publicKey, privateKey+StaticPrivateKeyLength(), EphemeralPublicKeyLength());
|
||||
std::memcpy(publicKey, privateKey+StaticPrivateKeyLength(), EphemeralPublicKeyLength());
|
||||
}
|
||||
|
||||
/// \brief Derive agreed value or shared secret
|
||||
|
28
filters.cpp
28
filters.cpp
@ -292,8 +292,8 @@ size_t FilterWithBufferedInput::BlockQueue::GetAll(byte *outString)
|
||||
size_t size = m_size;
|
||||
size_t numberOfBytes = m_maxBlocks*m_blockSize;
|
||||
const byte *ptr = GetContigousBlocks(numberOfBytes);
|
||||
memcpy(outString, ptr, numberOfBytes);
|
||||
memcpy(PtrAdd(outString, numberOfBytes), m_begin, m_size);
|
||||
std::memcpy(outString, ptr, numberOfBytes);
|
||||
std::memcpy(PtrAdd(outString, numberOfBytes), m_begin, m_size);
|
||||
m_size = 0;
|
||||
return size;
|
||||
}
|
||||
@ -307,9 +307,9 @@ void FilterWithBufferedInput::BlockQueue::Put(const byte *inString, size_t lengt
|
||||
byte *end = (m_size < static_cast<size_t>(PtrDiff(m_buffer.end(), m_begin)) ?
|
||||
PtrAdd(m_begin, m_size) : PtrAdd(m_begin, m_size - m_buffer.size()));
|
||||
size_t len = STDMIN(length, size_t(m_buffer.end()-end));
|
||||
memcpy(end, inString, len);
|
||||
std::memcpy(end, inString, len);
|
||||
if (len < length)
|
||||
memcpy(m_buffer, PtrAdd(inString, len), length-len);
|
||||
std::memcpy(m_buffer, PtrAdd(inString, len), length-len);
|
||||
m_size += length;
|
||||
}
|
||||
|
||||
@ -536,13 +536,13 @@ size_t ArraySink::Put2(const byte *begin, size_t length, int messageEnd, bool bl
|
||||
{
|
||||
CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking);
|
||||
|
||||
// Avoid passing NULL pointer to memcpy. Using memmove due to
|
||||
// Avoid passing NULL pointer to memcpy. Using std::memmove due to
|
||||
// Valgrind finding on overlapping buffers.
|
||||
size_t copied = 0;
|
||||
if (m_buf && begin)
|
||||
{
|
||||
copied = STDMIN(length, SaturatingSubtract(m_size, m_total));
|
||||
memmove(PtrAdd(m_buf, m_total), begin, copied);
|
||||
std::memmove(PtrAdd(m_buf, m_total), begin, copied);
|
||||
}
|
||||
m_total += copied;
|
||||
return length - copied;
|
||||
@ -762,8 +762,8 @@ void StreamTransformationFilter::LastPut(const byte *inString, size_t length)
|
||||
// do padding
|
||||
size_t blockSize = STDMAX(minLastBlockSize, (size_t)m_mandatoryBlockSize);
|
||||
byte* space = HelpCreatePutSpace(*AttachedTransformation(), DEFAULT_CHANNEL, blockSize);
|
||||
if (inString) {memcpy(space, inString, length);}
|
||||
memset(PtrAdd(space, length), 0, blockSize - length);
|
||||
if (inString) {std::memcpy(space, inString, length);}
|
||||
std::memset(PtrAdd(space, length), 0, blockSize - length);
|
||||
size_t used = m_cipher.ProcessLastBlock(space, blockSize, space, blockSize);
|
||||
AttachedTransformation()->Put(space, used);
|
||||
}
|
||||
@ -795,23 +795,23 @@ void StreamTransformationFilter::LastPut(const byte *inString, size_t length)
|
||||
if (m_cipher.IsForwardTransformation())
|
||||
{
|
||||
CRYPTOPP_ASSERT(length < s);
|
||||
if (inString) {memcpy(space, inString, length);}
|
||||
if (inString) {std::memcpy(space, inString, length);}
|
||||
if (m_padding == PKCS_PADDING)
|
||||
{
|
||||
CRYPTOPP_ASSERT(s < 256);
|
||||
byte pad = static_cast<byte>(s-length);
|
||||
memset(PtrAdd(space, length), pad, s-length);
|
||||
std::memset(PtrAdd(space, length), pad, s-length);
|
||||
}
|
||||
else if (m_padding == W3C_PADDING)
|
||||
{
|
||||
CRYPTOPP_ASSERT(s < 256);
|
||||
memset(PtrAdd(space, length), 0, s-length-1);
|
||||
std::memset(PtrAdd(space, length), 0, s-length-1);
|
||||
space[s-1] = static_cast<byte>(s-length);
|
||||
}
|
||||
else
|
||||
{
|
||||
space[length] = 0x80;
|
||||
memset(PtrAdd(space, length+1), 0, s-length-1);
|
||||
std::memset(PtrAdd(space, length+1), 0, s-length-1);
|
||||
}
|
||||
m_cipher.ProcessData(space, space, s);
|
||||
AttachedTransformation()->Put(space, s);
|
||||
@ -915,7 +915,7 @@ void HashVerificationFilter::FirstPut(const byte *inString)
|
||||
if (m_flags & HASH_AT_BEGIN)
|
||||
{
|
||||
m_expectedHash.New(m_digestSize);
|
||||
if (inString) {memcpy(m_expectedHash, inString, m_expectedHash.size());}
|
||||
if (inString) {std::memcpy(m_expectedHash, inString, m_expectedHash.size());}
|
||||
if (m_flags & PUT_HASH)
|
||||
AttachedTransformation()->Put(inString, m_expectedHash.size());
|
||||
}
|
||||
@ -1116,7 +1116,7 @@ void SignatureVerificationFilter::FirstPut(const byte *inString)
|
||||
else
|
||||
{
|
||||
m_signature.New(m_verifier.SignatureLength());
|
||||
if (inString) {memcpy(m_signature, inString, m_signature.size());}
|
||||
if (inString) {std::memcpy(m_signature, inString, m_signature.size());}
|
||||
}
|
||||
|
||||
if (m_flags & PUT_SIGNATURE)
|
||||
|
10
fipsalgt.cpp
10
fipsalgt.cpp
@ -274,7 +274,7 @@ protected:
|
||||
for (int k=0; k<keySize;)
|
||||
{
|
||||
int pos = innerCount * blockSize - keySize + k;
|
||||
memcpy(x + k, text[pos / blockSize] + pos % blockSize, blockSize - pos % blockSize);
|
||||
std::memcpy(x + k, text[pos / blockSize] + pos % blockSize, blockSize - pos % blockSize);
|
||||
k += blockSize - pos % blockSize;
|
||||
}
|
||||
|
||||
@ -918,8 +918,8 @@ protected:
|
||||
Xor(CT[j], CT[j], PT[j]);
|
||||
AssignLeftMostBits(PT[j+1], IB[j], K);
|
||||
IB[j+1].resize(blockSize);
|
||||
memcpy(IB[j+1], IB[j]+K/8, blockSize-K/8);
|
||||
memcpy(IB[j+1]+blockSize-K/8, CT[j], K/8);
|
||||
std::memcpy(IB[j+1], IB[j]+K/8, blockSize-K/8);
|
||||
std::memcpy(IB[j+1]+blockSize-K/8, CT[j], K/8);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -928,8 +928,8 @@ protected:
|
||||
AssignLeftMostBits(PT[j], OB[j], K);
|
||||
Xor(PT[j], PT[j], CT[j]);
|
||||
IB[j+1].resize(blockSize);
|
||||
memcpy(IB[j+1], IB[j]+K/8, blockSize-K/8);
|
||||
memcpy(IB[j+1]+blockSize-K/8, CT[j], K/8);
|
||||
std::memcpy(IB[j+1], IB[j]+K/8, blockSize-K/8);
|
||||
std::memcpy(IB[j+1]+blockSize-K/8, CT[j], K/8);
|
||||
AssignLeftMostBits(CT[j+1], OB[j], K);
|
||||
}
|
||||
}
|
||||
|
22
gcm.cpp
22
gcm.cpp
@ -155,7 +155,7 @@ void GCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const
|
||||
m_buffer.resize(3*blockSize + tableSize);
|
||||
byte *mulTable = MulTable();
|
||||
byte *hashKey = HashKey();
|
||||
memset(hashKey, 0, REQUIRED_BLOCKSIZE);
|
||||
std::memset(hashKey, 0, REQUIRED_BLOCKSIZE);
|
||||
blockCipher.ProcessBlock(hashKey);
|
||||
|
||||
#if CRYPTOPP_CLMUL_AVAILABLE
|
||||
@ -196,7 +196,7 @@ void GCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const
|
||||
|
||||
for (i=0; i<16; i++)
|
||||
{
|
||||
memset(mulTable+i*256*16, 0, 16);
|
||||
std::memset(mulTable+i*256*16, 0, 16);
|
||||
#if CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE
|
||||
if (HasSSE2())
|
||||
for (j=2; j<=0x80; j*=2)
|
||||
@ -253,8 +253,8 @@ void GCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const
|
||||
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
memset(mulTable+i*256, 0, 16);
|
||||
memset(mulTable+1024+i*256, 0, 16);
|
||||
std::memset(mulTable+i*256, 0, 16);
|
||||
std::memset(mulTable+1024+i*256, 0, 16);
|
||||
#if CRYPTOPP_SSE2_INTRIN_AVAILABLE || CRYPTOPP_SSE2_ASM_AVAILABLE
|
||||
if (HasSSE2())
|
||||
for (j=2; j<=8; j*=2)
|
||||
@ -320,14 +320,14 @@ void GCM_Base::Resync(const byte *iv, size_t len)
|
||||
|
||||
if (len == 12)
|
||||
{
|
||||
memcpy(hashBuffer, iv, len);
|
||||
memset(hashBuffer+len, 0, 3);
|
||||
std::memcpy(hashBuffer, iv, len);
|
||||
std::memset(hashBuffer+len, 0, 3);
|
||||
hashBuffer[len+3] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t origLen = len;
|
||||
memset(hashBuffer, 0, HASH_BLOCKSIZE);
|
||||
std::memset(hashBuffer, 0, HASH_BLOCKSIZE);
|
||||
|
||||
if (len >= HASH_BLOCKSIZE)
|
||||
{
|
||||
@ -337,8 +337,8 @@ void GCM_Base::Resync(const byte *iv, size_t len)
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
memcpy(m_buffer, iv, len);
|
||||
memset(m_buffer+len, 0, HASH_BLOCKSIZE-len);
|
||||
std::memcpy(m_buffer, iv, len);
|
||||
std::memset(m_buffer+len, 0, HASH_BLOCKSIZE-len);
|
||||
GCM_Base::AuthenticateBlocks(m_buffer, HASH_BLOCKSIZE);
|
||||
}
|
||||
|
||||
@ -355,7 +355,7 @@ void GCM_Base::Resync(const byte *iv, size_t len)
|
||||
|
||||
m_ctr.Seek(HASH_BLOCKSIZE);
|
||||
|
||||
memset(hashBuffer, 0, HASH_BLOCKSIZE);
|
||||
std::memset(hashBuffer, 0, HASH_BLOCKSIZE);
|
||||
}
|
||||
|
||||
unsigned int GCM_Base::OptimalDataAlignment() const
|
||||
@ -830,7 +830,7 @@ void GCM_Base::AuthenticateLastHeaderBlock()
|
||||
{
|
||||
if (m_bufferedDataLength > 0)
|
||||
{
|
||||
memset(m_buffer+m_bufferedDataLength, 0, HASH_BLOCKSIZE-m_bufferedDataLength);
|
||||
std::memset(m_buffer+m_bufferedDataLength, 0, HASH_BLOCKSIZE-m_bufferedDataLength);
|
||||
m_bufferedDataLength = 0;
|
||||
GCM_Base::AuthenticateBlocks(m_buffer, HASH_BLOCKSIZE);
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ void DL_SignatureMessageEncodingMethod_DSA::ComputeMessageRepresentative(RandomN
|
||||
const size_t digestSize = hash.DigestSize();
|
||||
const size_t paddingLength = SaturatingSubtract(representativeByteLength, digestSize);
|
||||
|
||||
memset(representative, 0, paddingLength);
|
||||
std::memset(representative, 0, paddingLength);
|
||||
hash.TruncatedFinal(representative+paddingLength, STDMIN(representativeByteLength, digestSize));
|
||||
|
||||
if (digestSize*8 > representativeBitLength)
|
||||
@ -119,7 +119,7 @@ void DL_SignatureMessageEncodingMethod_NR::ComputeMessageRepresentative(RandomNu
|
||||
const size_t digestSize = hash.DigestSize();
|
||||
const size_t paddingLength = SaturatingSubtract(representativeByteLength, digestSize);
|
||||
|
||||
memset(representative, 0, paddingLength);
|
||||
std::memset(representative, 0, paddingLength);
|
||||
hash.TruncatedFinal(representative+paddingLength, STDMIN(representativeByteLength, digestSize));
|
||||
|
||||
if (digestSize*8 >= representativeBitLength)
|
||||
|
@ -472,7 +472,7 @@ protected:
|
||||
else // block.size() < rlen
|
||||
{
|
||||
size_t offset = rlen - block.size();
|
||||
memset(t, '\x00', offset);
|
||||
std::memset(t, '\x00', offset);
|
||||
std::memcpy(t + offset, block, rlen - offset);
|
||||
}
|
||||
|
||||
|
4
hmac.cpp
4
hmac.cpp
@ -26,7 +26,7 @@ void HMAC_Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, con
|
||||
{
|
||||
// hmac.cpp:26:9: runtime error: null pointer passed as argument 2
|
||||
if (AccessIpad() && userKey && keylength)
|
||||
memcpy(AccessIpad(), userKey, keylength);
|
||||
std::memcpy(AccessIpad(), userKey, keylength);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -35,7 +35,7 @@ void HMAC_Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, con
|
||||
}
|
||||
|
||||
CRYPTOPP_ASSERT(keylength <= blockSize);
|
||||
memset(AccessIpad()+keylength, 0, blockSize-keylength);
|
||||
std::memset(AccessIpad()+keylength, 0, blockSize-keylength);
|
||||
|
||||
for (unsigned int i=0; i<blockSize; i++)
|
||||
{
|
||||
|
2
hmqv.h
2
hmqv.h
@ -213,7 +213,7 @@ public:
|
||||
void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
|
||||
{
|
||||
CRYPTOPP_UNUSED(rng);
|
||||
memcpy(publicKey, privateKey+StaticPrivateKeyLength(), EphemeralPublicKeyLength());
|
||||
std::memcpy(publicKey, privateKey+StaticPrivateKeyLength(), EphemeralPublicKeyLength());
|
||||
}
|
||||
|
||||
/// \brief Derive agreed value or shared secret
|
||||
|
14
integer.cpp
14
integer.cpp
@ -303,10 +303,10 @@ public:
|
||||
#if defined(CRYPTOPP_NATIVE_DWORD_AVAILABLE)
|
||||
# if (CRYPTOPP_LITTLE_ENDIAN)
|
||||
const word t[2] = {low,high};
|
||||
memcpy(&m_whole, t, sizeof(m_whole));
|
||||
std::memcpy(&m_whole, t, sizeof(m_whole));
|
||||
# else
|
||||
const word t[2] = {high,low};
|
||||
memcpy(&m_whole, t, sizeof(m_whole));
|
||||
std::memcpy(&m_whole, t, sizeof(m_whole));
|
||||
# endif
|
||||
#else
|
||||
m_halfs.low = low;
|
||||
@ -2562,7 +2562,7 @@ void MontgomeryReduce(word *R, word *T, word *X, const word *M, const word *U, s
|
||||
while (!Subtract(X+N, X+N, M, N)) {}
|
||||
}
|
||||
|
||||
memcpy(R, X+N, N*WORD_SIZE);
|
||||
std::memcpy(R, X+N, N*WORD_SIZE);
|
||||
#else
|
||||
__m64 u = _mm_cvtsi32_si64(0-U[0]), p;
|
||||
for (size_t i=0; i<N; i++)
|
||||
@ -2588,7 +2588,7 @@ void MontgomeryReduce(word *R, word *T, word *X, const word *M, const word *U, s
|
||||
while (!Subtract(X+N, X+N, M, N)) {}
|
||||
}
|
||||
|
||||
memcpy(R, X+N, N*WORD_SIZE);
|
||||
std::memcpy(R, X+N, N*WORD_SIZE);
|
||||
_mm_empty();
|
||||
#endif
|
||||
}
|
||||
@ -2721,7 +2721,7 @@ static inline void AtomicDivide(word *Q, const word *A, const word *B)
|
||||
word P[4];
|
||||
LowLevel::Multiply2(P, Q, B);
|
||||
Add(P, P, T, 4);
|
||||
CRYPTOPP_ASSERT(memcmp(P, A, 4*WORD_SIZE)==0);
|
||||
CRYPTOPP_ASSERT(std::memcmp(P, A, 4*WORD_SIZE)==0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -2742,7 +2742,7 @@ static inline void AtomicDivide(word *Q, const word *A, const word *B)
|
||||
word P[4];
|
||||
s_pMul[0](P, Q, B);
|
||||
Add(P, P, T, 4);
|
||||
CRYPTOPP_ASSERT(memcmp(P, A, 4*WORD_SIZE)==0);
|
||||
CRYPTOPP_ASSERT(std::memcmp(P, A, 4*WORD_SIZE)==0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -3556,7 +3556,7 @@ public:
|
||||
KDF2_RNG(const byte *seed, size_t seedSize)
|
||||
: m_counter(0), m_counterAndSeed(ClampSize(seedSize) + 4)
|
||||
{
|
||||
memcpy(m_counterAndSeed + 4, seed, ClampSize(seedSize));
|
||||
std::memcpy(m_counterAndSeed + 4, seed, ClampSize(seedSize));
|
||||
}
|
||||
|
||||
void GenerateBlock(byte *output, size_t size)
|
||||
|
@ -706,7 +706,7 @@ public:
|
||||
/// \param out reference to a std::ostream
|
||||
/// \param a a constant reference to an Integer
|
||||
/// \return reference to a std::ostream reference
|
||||
/// \details The output integer responds to std::hex, std::oct, std::hex, std::upper and
|
||||
/// \details The output integer responds to hex, std::oct, std::hex, std::upper and
|
||||
/// std::lower. The output includes the suffix \a h (for hex), \a . (\a dot, for dec)
|
||||
/// and \a o (for octal). There is currently no way to suppress the suffix.
|
||||
/// \details If you want to print an Integer without the suffix or using an arbitrary base, then
|
||||
|
@ -147,12 +147,12 @@ template <class T, class BASE> void IteratedHashBase<T, BASE>::PadLastBlock(unsi
|
||||
|
||||
data[num++] = padFirst;
|
||||
if (num <= lastBlockSize)
|
||||
memset(data+num, 0, lastBlockSize-num);
|
||||
std::memset(data+num, 0, lastBlockSize-num);
|
||||
else
|
||||
{
|
||||
memset(data+num, 0, blockSize-num);
|
||||
std::memset(data+num, 0, blockSize-num);
|
||||
HashBlock(dataBuf);
|
||||
memset(data, 0, lastBlockSize);
|
||||
std::memset(data, 0, lastBlockSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
32
kalyna.cpp
32
kalyna.cpp
@ -79,8 +79,8 @@ inline void MakeOddKey(const word64 evenkey[NB], word64 oddkey[NB])
|
||||
const byte* even = reinterpret_cast<const byte*>(evenkey);
|
||||
byte* odd = reinterpret_cast<byte*>(oddkey);
|
||||
|
||||
memcpy(odd, even + V, U - V);
|
||||
memcpy(odd + U - V, even, V);
|
||||
std::memcpy(odd, even + V, U - V);
|
||||
std::memcpy(odd + U - V, even, V);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -421,7 +421,7 @@ void Kalyna128::Base::SetKey_22(const word64 key[2])
|
||||
word64 *ks = m_wspace+0, *ksc = m_wspace+2, *t1 = m_wspace+4;
|
||||
word64 *t2 = m_wspace+6, *k = m_wspace+8, *kswapped = m_wspace+10;
|
||||
|
||||
memset(t1, 0, 2*8);
|
||||
std::memset(t1, 0, 2*8);
|
||||
t1[0] = (128 + 128 + 64) / 64;
|
||||
|
||||
AddKey<2>(t1, t2, key);
|
||||
@ -432,7 +432,7 @@ void Kalyna128::Base::SetKey_22(const word64 key[2])
|
||||
word64 constant = W64LIT(0x0001000100010001);
|
||||
|
||||
// round 0
|
||||
memcpy(k, key, 16);
|
||||
std::memcpy(k, key, 16);
|
||||
kswapped[1] = k[0];
|
||||
kswapped[0] = k[1];
|
||||
|
||||
@ -496,10 +496,10 @@ void Kalyna128::Base::SetKey_24(const word64 key[4])
|
||||
word64 *ks = m_wspace+0, *ksc = m_wspace+2, *t1 = m_wspace+4, *t2 = m_wspace+6;
|
||||
word64 *k = m_wspace+8, *ka = m_wspace+12, *ko = m_wspace+14;
|
||||
|
||||
memset(t1, 0, 2*8);
|
||||
std::memset(t1, 0, 2*8);
|
||||
t1[0] = (128 + 256 + 64) / 64;
|
||||
memcpy(ka, key, 16);
|
||||
memcpy(ko, key + 2, 16);
|
||||
std::memcpy(ka, key, 16);
|
||||
std::memcpy(ko, key + 2, 16);
|
||||
|
||||
AddKey<2>(t1, t2, ka);
|
||||
G128(t2, t1, ko);
|
||||
@ -509,7 +509,7 @@ void Kalyna128::Base::SetKey_24(const word64 key[4])
|
||||
word64 constant = W64LIT(0x0001000100010001);
|
||||
|
||||
// round 0
|
||||
memcpy(k, key, 256 / 8);
|
||||
std::memcpy(k, key, 256 / 8);
|
||||
AddConstant<2>(ks, ksc, constant);
|
||||
AddKey<2>(k, t2, ksc);
|
||||
G128(t2, t1, ksc);
|
||||
@ -597,7 +597,7 @@ void Kalyna256::Base::SetKey_44(const word64 key[4])
|
||||
word64 *ks = m_wspace+0, *ksc = m_wspace+4, *t1 = m_wspace+8;
|
||||
word64 *t2 = m_wspace+12, *k = m_wspace+16;
|
||||
|
||||
memset(t1, 0, 32);
|
||||
std::memset(t1, 0, 32);
|
||||
t1[0] = (256 + 256 + 64) / 64;
|
||||
|
||||
AddKey<4>(t1, t2, key);
|
||||
@ -608,7 +608,7 @@ void Kalyna256::Base::SetKey_44(const word64 key[4])
|
||||
word64 constant = W64LIT(0x0001000100010001);
|
||||
|
||||
// round 0
|
||||
memcpy(k, key, 32);
|
||||
std::memcpy(k, key, 32);
|
||||
AddConstant<4>(ks, ksc, constant);
|
||||
AddKey<4>(k, t2, ksc);
|
||||
G256(t2, t1, ksc);
|
||||
@ -700,10 +700,10 @@ void Kalyna256::Base::SetKey_48(const word64 key[8])
|
||||
word64 *ks = m_wspace+0, *ksc = m_wspace+4, *t1 = m_wspace+8, *t2 = m_wspace+12;
|
||||
word64 *k = m_wspace+16, *ka = m_wspace+24, *ko = m_wspace+28;
|
||||
|
||||
memset(t1, 0, 4*8);
|
||||
std::memset(t1, 0, 4*8);
|
||||
t1[0] = (512 + 256 + 64) / 64;
|
||||
memcpy(ka, key, 32);
|
||||
memcpy(ko, key+4, 32);
|
||||
std::memcpy(ka, key, 32);
|
||||
std::memcpy(ko, key+4, 32);
|
||||
|
||||
AddKey<4>(t1, t2, ka);
|
||||
G256(t2, t1, ko);
|
||||
@ -713,7 +713,7 @@ void Kalyna256::Base::SetKey_48(const word64 key[8])
|
||||
word64 constant = W64LIT(0x0001000100010001);
|
||||
|
||||
// round 0
|
||||
memcpy(k, key, 512 / 8);
|
||||
std::memcpy(k, key, 512 / 8);
|
||||
AddConstant<4>(ks, ksc, constant);
|
||||
AddKey<4>(k, t2, ksc);
|
||||
G256(t2, t1, ksc);
|
||||
@ -822,7 +822,7 @@ void Kalyna512::Base::SetKey_88(const word64 key[8])
|
||||
word64 *ks = m_wspace+0, *ksc = m_wspace+8, *t1 = m_wspace+16;
|
||||
word64 *t2 = m_wspace+24, *k = m_wspace+32;
|
||||
|
||||
memset(t1, 0, 8*8);
|
||||
std::memset(t1, 0, 8*8);
|
||||
t1[0] = (512 + 512 + 64) / 64;
|
||||
|
||||
AddKey<8>(t1, t2, key);
|
||||
@ -833,7 +833,7 @@ void Kalyna512::Base::SetKey_88(const word64 key[8])
|
||||
word64 constant = W64LIT(0x0001000100010001);
|
||||
|
||||
// round 0
|
||||
memcpy(k, key, 512 / 8);
|
||||
std::memcpy(k, key, 512 / 8);
|
||||
AddConstant<8>(ks, ksc, constant);
|
||||
AddKey<8>(k, t2, ksc);
|
||||
G512(t2, t1, ksc);
|
||||
|
@ -48,7 +48,7 @@ void Keccak::Update(const byte *input, size_t length)
|
||||
|
||||
void Keccak::Restart()
|
||||
{
|
||||
memset(m_state, 0, m_state.SizeInBytes());
|
||||
std::memset(m_state, 0, m_state.SizeInBytes());
|
||||
m_counter = 0;
|
||||
}
|
||||
|
||||
|
18
lsh256.cpp
18
lsh256.cpp
@ -482,8 +482,8 @@ inline void load_iv(lsh_u32 cv_l[8], lsh_u32 cv_r[8], const lsh_u32 iv[16])
|
||||
|
||||
inline void zero_iv(lsh_u32 cv_l[8], lsh_u32 cv_r[8])
|
||||
{
|
||||
memset(cv_l, 0x00, 8*sizeof(lsh_u32));
|
||||
memset(cv_r, 0x00, 8*sizeof(lsh_u32));
|
||||
std::memset(cv_l, 0x00, 8*sizeof(lsh_u32));
|
||||
std::memset(cv_r, 0x00, 8*sizeof(lsh_u32));
|
||||
}
|
||||
|
||||
inline void zero_submsgs(LSH256_Context* ctx)
|
||||
@ -491,7 +491,7 @@ inline void zero_submsgs(LSH256_Context* ctx)
|
||||
CRYPTOPP_ASSERT(ctx != NULLPTR);
|
||||
|
||||
lsh_u32* sub_msgs = ctx->sub_msgs;
|
||||
memset(sub_msgs, 0x00, 32*sizeof(lsh_u32));
|
||||
std::memset(sub_msgs, 0x00, 32*sizeof(lsh_u32));
|
||||
}
|
||||
|
||||
inline void init224(LSH256_Context* ctx)
|
||||
@ -534,7 +534,7 @@ inline void get_hash(LSH256_Context* ctx, lsh_u8* pbHashVal)
|
||||
lsh_uint hash_val_bit_len = LSH_GET_SMALL_HASHBIT(alg_type);
|
||||
|
||||
// Multiplying by looks odd...
|
||||
memcpy(pbHashVal, ctx->cv_l, hash_val_byte_len);
|
||||
std::memcpy(pbHashVal, ctx->cv_l, hash_val_byte_len);
|
||||
if (hash_val_bit_len){
|
||||
pbHashVal[hash_val_byte_len-1] &= (((lsh_u8)0xff) << hash_val_bit_len);
|
||||
}
|
||||
@ -614,7 +614,7 @@ lsh_err lsh256_update(LSH256_Context* ctx, const lsh_u8* data, size_t databitlen
|
||||
|
||||
if (databytelen + remain_msg_byte < LSH256_MSG_BLK_BYTE_LEN)
|
||||
{
|
||||
memcpy(ctx->last_block + remain_msg_byte, data, databytelen);
|
||||
std::memcpy(ctx->last_block + remain_msg_byte, data, databytelen);
|
||||
ctx->remain_databitlen += (lsh_uint)databitlen;
|
||||
remain_msg_byte += (lsh_uint)databytelen;
|
||||
if (pos2){
|
||||
@ -625,7 +625,7 @@ lsh_err lsh256_update(LSH256_Context* ctx, const lsh_u8* data, size_t databitlen
|
||||
|
||||
if (remain_msg_byte > 0){
|
||||
size_t more_byte = LSH256_MSG_BLK_BYTE_LEN - remain_msg_byte;
|
||||
memcpy(ctx->last_block + remain_msg_byte, data, more_byte);
|
||||
std::memcpy(ctx->last_block + remain_msg_byte, data, more_byte);
|
||||
compress(ctx, ctx->last_block);
|
||||
data += more_byte;
|
||||
databytelen -= more_byte;
|
||||
@ -644,7 +644,7 @@ lsh_err lsh256_update(LSH256_Context* ctx, const lsh_u8* data, size_t databitlen
|
||||
}
|
||||
|
||||
if (databytelen > 0){
|
||||
memcpy(ctx->last_block, data, databytelen);
|
||||
std::memcpy(ctx->last_block, data, databytelen);
|
||||
ctx->remain_databitlen = (lsh_uint)(databytelen << 3);
|
||||
}
|
||||
|
||||
@ -676,7 +676,7 @@ lsh_err lsh256_final(LSH256_Context* ctx, lsh_u8* hashval)
|
||||
else{
|
||||
ctx->last_block[remain_msg_byte] = 0x80;
|
||||
}
|
||||
memset(ctx->last_block + remain_msg_byte + 1, 0, LSH256_MSG_BLK_BYTE_LEN - remain_msg_byte - 1);
|
||||
std::memset(ctx->last_block + remain_msg_byte + 1, 0, LSH256_MSG_BLK_BYTE_LEN - remain_msg_byte - 1);
|
||||
|
||||
compress(ctx, ctx->last_block);
|
||||
|
||||
@ -809,7 +809,7 @@ void LSH256_Base::TruncatedFinal(byte *hash, size_t size)
|
||||
LSH256_Base_TruncatedFinal_CXX(m_state, copyOut ? fullHash : hash, size);
|
||||
|
||||
if (copyOut)
|
||||
memcpy(hash, fullHash, size);
|
||||
std::memcpy(hash, fullHash, size);
|
||||
|
||||
Restart();
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ inline void get_hash(LSH256_AVX2_Context* ctx, lsh_u8* pbHashVal)
|
||||
lsh_uint hash_val_bit_len = LSH_GET_SMALL_HASHBIT(alg_type);
|
||||
|
||||
// Multiplying by looks odd...
|
||||
memcpy(pbHashVal, ctx->cv_l, hash_val_byte_len);
|
||||
std::memcpy(pbHashVal, ctx->cv_l, hash_val_byte_len);
|
||||
if (hash_val_bit_len){
|
||||
pbHashVal[hash_val_byte_len-1] &= (((lsh_u8)0xff) << hash_val_bit_len);
|
||||
}
|
||||
@ -536,7 +536,7 @@ lsh_err lsh256_update_avx2(LSH256_AVX2_Context* ctx, const lsh_u8* data, size_t
|
||||
|
||||
if (databytelen + remain_msg_byte < LSH256_MSG_BLK_BYTE_LEN)
|
||||
{
|
||||
memcpy(ctx->last_block + remain_msg_byte, data, databytelen);
|
||||
std::memcpy(ctx->last_block + remain_msg_byte, data, databytelen);
|
||||
ctx->remain_databitlen += (lsh_uint)databitlen;
|
||||
remain_msg_byte += (lsh_uint)databytelen;
|
||||
if (pos2){
|
||||
@ -547,7 +547,7 @@ lsh_err lsh256_update_avx2(LSH256_AVX2_Context* ctx, const lsh_u8* data, size_t
|
||||
|
||||
if (remain_msg_byte > 0){
|
||||
size_t more_byte = LSH256_MSG_BLK_BYTE_LEN - remain_msg_byte;
|
||||
memcpy(ctx->last_block + remain_msg_byte, data, more_byte);
|
||||
std::memcpy(ctx->last_block + remain_msg_byte, data, more_byte);
|
||||
compress(ctx, ctx->last_block);
|
||||
data += more_byte;
|
||||
databytelen -= more_byte;
|
||||
@ -566,7 +566,7 @@ lsh_err lsh256_update_avx2(LSH256_AVX2_Context* ctx, const lsh_u8* data, size_t
|
||||
}
|
||||
|
||||
if (databytelen > 0){
|
||||
memcpy(ctx->last_block, data, databytelen);
|
||||
std::memcpy(ctx->last_block, data, databytelen);
|
||||
ctx->remain_databitlen = (lsh_uint)(databytelen << 3);
|
||||
}
|
||||
|
||||
@ -601,7 +601,7 @@ lsh_err lsh256_final_avx2(LSH256_AVX2_Context* ctx, lsh_u8* hashval)
|
||||
else{
|
||||
ctx->last_block[remain_msg_byte] = 0x80;
|
||||
}
|
||||
memset(ctx->last_block + remain_msg_byte + 1, 0, LSH256_MSG_BLK_BYTE_LEN - remain_msg_byte - 1);
|
||||
std::memset(ctx->last_block + remain_msg_byte + 1, 0, LSH256_MSG_BLK_BYTE_LEN - remain_msg_byte - 1);
|
||||
|
||||
compress(ctx, ctx->last_block);
|
||||
|
||||
|
@ -521,7 +521,7 @@ inline void get_hash(LSH256_SSSE3_Context* ctx, lsh_u8* pbHashVal)
|
||||
lsh_uint hash_val_bit_len = LSH_GET_SMALL_HASHBIT(alg_type);
|
||||
|
||||
// Multiplying by sizeof(lsh_u8) looks odd...
|
||||
memcpy(pbHashVal, ctx->cv_l, hash_val_byte_len);
|
||||
std::memcpy(pbHashVal, ctx->cv_l, hash_val_byte_len);
|
||||
if (hash_val_bit_len){
|
||||
pbHashVal[hash_val_byte_len-1] &= (((lsh_u8)0xff) << hash_val_bit_len);
|
||||
}
|
||||
@ -601,7 +601,7 @@ lsh_err lsh256_ssse3_update(LSH256_SSSE3_Context* ctx, const lsh_u8* data, size_
|
||||
|
||||
if (databytelen + remain_msg_byte < LSH256_MSG_BLK_BYTE_LEN)
|
||||
{
|
||||
memcpy(ctx->last_block + remain_msg_byte, data, databytelen);
|
||||
std::memcpy(ctx->last_block + remain_msg_byte, data, databytelen);
|
||||
ctx->remain_databitlen += (lsh_uint)databitlen;
|
||||
remain_msg_byte += (lsh_uint)databytelen;
|
||||
if (pos2){
|
||||
@ -612,7 +612,7 @@ lsh_err lsh256_ssse3_update(LSH256_SSSE3_Context* ctx, const lsh_u8* data, size_
|
||||
|
||||
if (remain_msg_byte > 0){
|
||||
size_t more_byte = LSH256_MSG_BLK_BYTE_LEN - remain_msg_byte;
|
||||
memcpy(ctx->last_block + remain_msg_byte, data, more_byte);
|
||||
std::memcpy(ctx->last_block + remain_msg_byte, data, more_byte);
|
||||
compress(ctx, ctx->last_block);
|
||||
data += more_byte;
|
||||
databytelen -= more_byte;
|
||||
@ -631,7 +631,7 @@ lsh_err lsh256_ssse3_update(LSH256_SSSE3_Context* ctx, const lsh_u8* data, size_
|
||||
}
|
||||
|
||||
if (databytelen > 0){
|
||||
memcpy(ctx->last_block, data, databytelen);
|
||||
std::memcpy(ctx->last_block, data, databytelen);
|
||||
ctx->remain_databitlen = (lsh_uint)(databytelen << 3);
|
||||
}
|
||||
|
||||
@ -663,7 +663,7 @@ lsh_err lsh256_ssse3_final(LSH256_SSSE3_Context* ctx, lsh_u8* hashval)
|
||||
else{
|
||||
ctx->last_block[remain_msg_byte] = 0x80;
|
||||
}
|
||||
memset(ctx->last_block + remain_msg_byte + 1, 0, LSH256_MSG_BLK_BYTE_LEN - remain_msg_byte - 1);
|
||||
std::memset(ctx->last_block + remain_msg_byte + 1, 0, LSH256_MSG_BLK_BYTE_LEN - remain_msg_byte - 1);
|
||||
|
||||
compress(ctx, ctx->last_block);
|
||||
|
||||
|
18
lsh512.cpp
18
lsh512.cpp
@ -539,15 +539,15 @@ inline void load_iv(lsh_u64 cv_l[8], lsh_u64 cv_r[8], const lsh_u64 iv[16])
|
||||
|
||||
inline void zero_iv(lsh_u64 cv_l[8], lsh_u64 cv_r[8])
|
||||
{
|
||||
memset(cv_l, 0, 8*sizeof(lsh_u64));
|
||||
memset(cv_r, 0, 8*sizeof(lsh_u64));
|
||||
std::memset(cv_l, 0, 8*sizeof(lsh_u64));
|
||||
std::memset(cv_r, 0, 8*sizeof(lsh_u64));
|
||||
}
|
||||
|
||||
inline void zero_submsgs(LSH512_Context* ctx)
|
||||
{
|
||||
lsh_u64* sub_msgs = ctx->sub_msgs;
|
||||
|
||||
memset(sub_msgs, 0x00, 32*sizeof(lsh_u64));
|
||||
std::memset(sub_msgs, 0x00, 32*sizeof(lsh_u64));
|
||||
}
|
||||
|
||||
inline void init224(LSH512_Context* ctx)
|
||||
@ -606,7 +606,7 @@ inline void get_hash(LSH512_Context* ctx, lsh_u8* pbHashVal)
|
||||
lsh_uint hash_val_bit_len = LSH_GET_SMALL_HASHBIT(alg_type);
|
||||
|
||||
// Multiplying by looks odd...
|
||||
memcpy(pbHashVal, ctx->cv_l, hash_val_byte_len);
|
||||
std::memcpy(pbHashVal, ctx->cv_l, hash_val_byte_len);
|
||||
if (hash_val_bit_len){
|
||||
pbHashVal[hash_val_byte_len-1] &= (((lsh_u8)0xff) << hash_val_bit_len);
|
||||
}
|
||||
@ -690,7 +690,7 @@ lsh_err lsh512_update(LSH512_Context* ctx, const lsh_u8* data, size_t databitlen
|
||||
}
|
||||
|
||||
if (databytelen + remain_msg_byte < LSH512_MSG_BLK_BYTE_LEN){
|
||||
memcpy(ctx->last_block + remain_msg_byte, data, databytelen);
|
||||
std::memcpy(ctx->last_block + remain_msg_byte, data, databytelen);
|
||||
ctx->remain_databitlen += (lsh_uint)databitlen;
|
||||
remain_msg_byte += (lsh_uint)databytelen;
|
||||
if (pos2){
|
||||
@ -701,7 +701,7 @@ lsh_err lsh512_update(LSH512_Context* ctx, const lsh_u8* data, size_t databitlen
|
||||
|
||||
if (remain_msg_byte > 0){
|
||||
size_t more_byte = LSH512_MSG_BLK_BYTE_LEN - remain_msg_byte;
|
||||
memcpy(ctx->last_block + remain_msg_byte, data, more_byte);
|
||||
std::memcpy(ctx->last_block + remain_msg_byte, data, more_byte);
|
||||
compress(ctx, ctx->last_block);
|
||||
data += more_byte;
|
||||
databytelen -= more_byte;
|
||||
@ -720,7 +720,7 @@ lsh_err lsh512_update(LSH512_Context* ctx, const lsh_u8* data, size_t databitlen
|
||||
}
|
||||
|
||||
if (databytelen > 0){
|
||||
memcpy(ctx->last_block, data, databytelen);
|
||||
std::memcpy(ctx->last_block, data, databytelen);
|
||||
ctx->remain_databitlen = (lsh_uint)(databytelen << 3);
|
||||
}
|
||||
|
||||
@ -751,7 +751,7 @@ lsh_err lsh512_final(LSH512_Context* ctx, lsh_u8* hashval)
|
||||
else{
|
||||
ctx->last_block[remain_msg_byte] = 0x80;
|
||||
}
|
||||
memset(ctx->last_block + remain_msg_byte + 1, 0, LSH512_MSG_BLK_BYTE_LEN - remain_msg_byte - 1);
|
||||
std::memset(ctx->last_block + remain_msg_byte + 1, 0, LSH512_MSG_BLK_BYTE_LEN - remain_msg_byte - 1);
|
||||
|
||||
compress(ctx, ctx->last_block);
|
||||
|
||||
@ -885,7 +885,7 @@ void LSH512_Base::TruncatedFinal(byte *hash, size_t size)
|
||||
LSH512_Base_TruncatedFinal_CXX(m_state, copyOut ? fullHash : hash, size);
|
||||
|
||||
if (copyOut)
|
||||
memcpy(hash, fullHash, size);
|
||||
std::memcpy(hash, fullHash, size);
|
||||
|
||||
Restart();
|
||||
}
|
||||
|
@ -559,7 +559,7 @@ inline void get_hash(LSH512_AVX2_Context* ctx, lsh_u8* pbHashVal)
|
||||
lsh_uint hash_val_bit_len = LSH_GET_SMALL_HASHBIT(alg_type);
|
||||
|
||||
// Multiplying by sizeof(lsh_u8) looks odd...
|
||||
memcpy(pbHashVal, ctx->cv_l, hash_val_byte_len);
|
||||
std::memcpy(pbHashVal, ctx->cv_l, hash_val_byte_len);
|
||||
if (hash_val_bit_len){
|
||||
pbHashVal[hash_val_byte_len-1] &= (((lsh_u8)0xff) << hash_val_bit_len);
|
||||
}
|
||||
@ -649,7 +649,7 @@ lsh_err lsh512_update_avx2(LSH512_AVX2_Context* ctx, const lsh_u8* data, size_t
|
||||
}
|
||||
|
||||
if (databytelen + remain_msg_byte < LSH512_MSG_BLK_BYTE_LEN){
|
||||
memcpy(ctx->last_block + remain_msg_byte, data, databytelen);
|
||||
std::memcpy(ctx->last_block + remain_msg_byte, data, databytelen);
|
||||
ctx->remain_databitlen += (lsh_uint)databitlen;
|
||||
remain_msg_byte += (lsh_uint)databytelen;
|
||||
if (pos2){
|
||||
@ -660,7 +660,7 @@ lsh_err lsh512_update_avx2(LSH512_AVX2_Context* ctx, const lsh_u8* data, size_t
|
||||
|
||||
if (remain_msg_byte > 0){
|
||||
size_t more_byte = LSH512_MSG_BLK_BYTE_LEN - remain_msg_byte;
|
||||
memcpy(ctx->last_block + remain_msg_byte, data, more_byte);
|
||||
std::memcpy(ctx->last_block + remain_msg_byte, data, more_byte);
|
||||
compress(ctx, ctx->last_block);
|
||||
data += more_byte;
|
||||
databytelen -= more_byte;
|
||||
@ -679,7 +679,7 @@ lsh_err lsh512_update_avx2(LSH512_AVX2_Context* ctx, const lsh_u8* data, size_t
|
||||
}
|
||||
|
||||
if (databytelen > 0){
|
||||
memcpy(ctx->last_block, data, databytelen);
|
||||
std::memcpy(ctx->last_block, data, databytelen);
|
||||
ctx->remain_databitlen = (lsh_uint)(databytelen << 3);
|
||||
}
|
||||
|
||||
@ -713,7 +713,7 @@ lsh_err lsh512_final_avx2(LSH512_AVX2_Context* ctx, lsh_u8* hashval)
|
||||
else{
|
||||
ctx->last_block[remain_msg_byte] = 0x80;
|
||||
}
|
||||
memset(ctx->last_block + remain_msg_byte + 1, 0, LSH512_MSG_BLK_BYTE_LEN - remain_msg_byte - 1);
|
||||
std::memset(ctx->last_block + remain_msg_byte + 1, 0, LSH512_MSG_BLK_BYTE_LEN - remain_msg_byte - 1);
|
||||
|
||||
compress(ctx, ctx->last_block);
|
||||
|
||||
|
@ -746,7 +746,7 @@ inline void get_hash(LSH512_SSSE3_Context* ctx, lsh_u8* pbHashVal)
|
||||
lsh_uint hash_val_bit_len = LSH_GET_SMALL_HASHBIT(alg_type);
|
||||
|
||||
// Multiplying by sizeof(lsh_u8) looks odd...
|
||||
memcpy(pbHashVal, ctx->cv_l, hash_val_byte_len);
|
||||
std::memcpy(pbHashVal, ctx->cv_l, hash_val_byte_len);
|
||||
if (hash_val_bit_len){
|
||||
pbHashVal[hash_val_byte_len-1] &= (((lsh_u8)0xff) << hash_val_bit_len);
|
||||
}
|
||||
@ -830,7 +830,7 @@ lsh_err lsh512_update_ssse3(LSH512_SSSE3_Context* ctx, const lsh_u8* data, size_
|
||||
}
|
||||
|
||||
if (databytelen + remain_msg_byte < LSH512_MSG_BLK_BYTE_LEN){
|
||||
memcpy(ctx->last_block + remain_msg_byte, data, databytelen);
|
||||
std::memcpy(ctx->last_block + remain_msg_byte, data, databytelen);
|
||||
ctx->remain_databitlen += (lsh_uint)databitlen;
|
||||
remain_msg_byte += (lsh_uint)databytelen;
|
||||
if (pos2){
|
||||
@ -841,7 +841,7 @@ lsh_err lsh512_update_ssse3(LSH512_SSSE3_Context* ctx, const lsh_u8* data, size_
|
||||
|
||||
if (remain_msg_byte > 0){
|
||||
size_t more_byte = LSH512_MSG_BLK_BYTE_LEN - remain_msg_byte;
|
||||
memcpy(ctx->last_block + remain_msg_byte, data, more_byte);
|
||||
std::memcpy(ctx->last_block + remain_msg_byte, data, more_byte);
|
||||
compress(ctx, ctx->last_block);
|
||||
data += more_byte;
|
||||
databytelen -= more_byte;
|
||||
@ -860,7 +860,7 @@ lsh_err lsh512_update_ssse3(LSH512_SSSE3_Context* ctx, const lsh_u8* data, size_
|
||||
}
|
||||
|
||||
if (databytelen > 0){
|
||||
memcpy(ctx->last_block, data, databytelen);
|
||||
std::memcpy(ctx->last_block, data, databytelen);
|
||||
ctx->remain_databitlen = (lsh_uint)(databytelen << 3);
|
||||
}
|
||||
|
||||
@ -891,7 +891,7 @@ lsh_err lsh512_final_ssse3(LSH512_SSSE3_Context* ctx, lsh_u8* hashval)
|
||||
else{
|
||||
ctx->last_block[remain_msg_byte] = 0x80;
|
||||
}
|
||||
memset(ctx->last_block + remain_msg_byte + 1, 0, LSH512_MSG_BLK_BYTE_LEN - remain_msg_byte - 1);
|
||||
std::memset(ctx->last_block + remain_msg_byte + 1, 0, LSH512_MSG_BLK_BYTE_LEN - remain_msg_byte - 1);
|
||||
|
||||
compress(ctx, ctx->last_block);
|
||||
|
||||
|
@ -115,7 +115,7 @@ class LR : public LR_Info<T>, public BlockCipherDocumentation
|
||||
if (xorBlock)
|
||||
xorbuf(outBlock, xorBlock, this->buffer, 2*this->S);
|
||||
else
|
||||
memcpy(outBlock, this->buffer, 2*this->S);
|
||||
std::memcpy(outBlock, this->buffer, 2*this->S);
|
||||
}
|
||||
#undef KL
|
||||
#undef KR
|
||||
|
12
md2.cpp
12
md2.cpp
@ -29,9 +29,9 @@ MD2::MD2()
|
||||
|
||||
void MD2::Init()
|
||||
{
|
||||
memset(m_X, 0, 48);
|
||||
memset(m_C, 0, 16);
|
||||
memset(m_buf, 0, 16);
|
||||
std::memset(m_X, 0, 48);
|
||||
std::memset(m_C, 0, 16);
|
||||
std::memset(m_buf, 0, 16);
|
||||
m_count = 0;
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ void MD2::Update(const byte *buf, size_t len)
|
||||
while (len)
|
||||
{
|
||||
unsigned int L = UnsignedMin(16U-m_count, len);
|
||||
memcpy(m_buf+m_count, buf, L);
|
||||
std::memcpy(m_buf+m_count, buf, L);
|
||||
m_count+=L;
|
||||
buf+=L;
|
||||
len-=L;
|
||||
@ -71,7 +71,7 @@ void MD2::Update(const byte *buf, size_t len)
|
||||
int i,j;
|
||||
|
||||
m_count=0;
|
||||
memcpy(m_X+16, m_buf, 16);
|
||||
std::memcpy(m_X+16, m_buf, 16);
|
||||
t=m_C[15];
|
||||
for(i=0; i<16; i++)
|
||||
{
|
||||
@ -111,7 +111,7 @@ void MD2::TruncatedFinal(byte *hash, size_t size)
|
||||
for(i=0; i<padlen; i++) padding[i]=(byte)padlen;
|
||||
Update(padding, padlen);
|
||||
Update(m_C, 16);
|
||||
memcpy(hash, m_X, size);
|
||||
std::memcpy(hash, m_X, size);
|
||||
|
||||
Init();
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
for (size_t i=0; i < size/4; i++, output += 4)
|
||||
{
|
||||
temp[0] = NextMersenneWord();
|
||||
memcpy(output, temp+0, 4);
|
||||
std::memcpy(output, temp+0, 4);
|
||||
}
|
||||
|
||||
// No tail bytes
|
||||
|
20
misc.cpp
20
misc.cpp
@ -112,11 +112,11 @@ void xorbuf(byte *buf, const byte *mask, size_t count)
|
||||
while (count >= 16)
|
||||
{
|
||||
word64 r[2], b[2], m[2];
|
||||
memcpy(&b, buf, 16); memcpy(&m, mask, 16);
|
||||
std::memcpy(&b, buf, 16); std::memcpy(&m, mask, 16);
|
||||
|
||||
r[0] = b[0] ^ m[0];
|
||||
r[1] = b[1] ^ m[1];
|
||||
memcpy(buf, &r, 16);
|
||||
std::memcpy(buf, &r, 16);
|
||||
|
||||
buf += 16; mask += 16; count -= 16;
|
||||
}
|
||||
@ -128,10 +128,10 @@ void xorbuf(byte *buf, const byte *mask, size_t count)
|
||||
while (count >= 4)
|
||||
{
|
||||
word32 r, b, m;
|
||||
memcpy(&b, buf, 4); memcpy(&m, mask, 4);
|
||||
std::memcpy(&b, buf, 4); std::memcpy(&m, mask, 4);
|
||||
|
||||
r = b ^ m;
|
||||
memcpy(buf, &r, 4);
|
||||
std::memcpy(buf, &r, 4);
|
||||
|
||||
buf += 4; mask += 4; count -= 4;
|
||||
}
|
||||
@ -186,11 +186,11 @@ void xorbuf(byte *output, const byte *input, const byte *mask, size_t count)
|
||||
while (count >= 16)
|
||||
{
|
||||
word64 b[2], m[2], r[2];
|
||||
memcpy(&b, input, 16); memcpy(&m, mask, 16);
|
||||
std::memcpy(&b, input, 16); std::memcpy(&m, mask, 16);
|
||||
|
||||
r[0] = b[0] ^ m[0];
|
||||
r[1] = b[1] ^ m[1];
|
||||
memcpy(output, &r, 16);
|
||||
std::memcpy(output, &r, 16);
|
||||
|
||||
output += 16; input += 16; mask += 16; count -= 16;
|
||||
}
|
||||
@ -202,10 +202,10 @@ void xorbuf(byte *output, const byte *input, const byte *mask, size_t count)
|
||||
while (count >= 4)
|
||||
{
|
||||
word32 b, m, r;
|
||||
memcpy(&b, input, 4); memcpy(&m, mask, 4);
|
||||
std::memcpy(&b, input, 4); std::memcpy(&m, mask, 4);
|
||||
|
||||
r = b ^ m;
|
||||
memcpy(output, &r, 4);
|
||||
std::memcpy(output, &r, 4);
|
||||
|
||||
output += 4; input += 4; mask += 4; count -= 4;
|
||||
}
|
||||
@ -226,7 +226,7 @@ bool VerifyBufsEqual(const byte *buf, const byte *mask, size_t count)
|
||||
while (count >= 8)
|
||||
{
|
||||
word64 b, m;
|
||||
memcpy(&b, buf, 8); memcpy(&m, mask, 8);
|
||||
std::memcpy(&b, buf, 8); std::memcpy(&m, mask, 8);
|
||||
acc64 |= b ^ m;
|
||||
|
||||
buf += 8; mask += 8; count -= 8;
|
||||
@ -240,7 +240,7 @@ bool VerifyBufsEqual(const byte *buf, const byte *mask, size_t count)
|
||||
while (count >= 4)
|
||||
{
|
||||
word32 b, m;
|
||||
memcpy(&b, buf, 4); memcpy(&m, mask, 4);
|
||||
std::memcpy(&b, buf, 4); std::memcpy(&m, mask, 4);
|
||||
acc32 |= b ^ m;
|
||||
|
||||
buf += 4; mask += 4; count -= 4;
|
||||
|
12
misc.h
12
misc.h
@ -504,14 +504,14 @@ constexpr int EnumToInt(T v) {
|
||||
|
||||
#if (!__STDC_WANT_SECURE_LIB__ && !defined(_MEMORY_S_DEFINED)) || defined(CRYPTOPP_WANT_SECURE_LIB)
|
||||
|
||||
/// \brief Bounds checking replacement for memcpy()
|
||||
/// \brief Bounds checking replacement for std::memcpy()
|
||||
/// \param dest pointer to the destination memory block
|
||||
/// \param sizeInBytes size of the destination memory block, in bytes
|
||||
/// \param src pointer to the source memory block
|
||||
/// \param count the number of bytes to copy
|
||||
/// \throw InvalidArgument
|
||||
/// \details ISO/IEC TR-24772 provides bounds checking interfaces for potentially
|
||||
/// unsafe functions like memcpy(), strcpy() and memmove(). However,
|
||||
/// unsafe functions like std::memcpy(), strcpy() and std::memmove(). However,
|
||||
/// not all standard libraries provides them, like Glibc. The library's
|
||||
/// memcpy_s() is a near-drop in replacement. Its only a near-replacement
|
||||
/// because the library's version throws an InvalidArgument on a bounds violation.
|
||||
@ -550,14 +550,14 @@ inline void memcpy_s(void *dest, size_t sizeInBytes, const void *src, size_t cou
|
||||
#endif
|
||||
}
|
||||
|
||||
/// \brief Bounds checking replacement for memmove()
|
||||
/// \brief Bounds checking replacement for std::memmove()
|
||||
/// \param dest pointer to the destination memory block
|
||||
/// \param sizeInBytes size of the destination memory block, in bytes
|
||||
/// \param src pointer to the source memory block
|
||||
/// \param count the number of bytes to copy
|
||||
/// \throw InvalidArgument
|
||||
/// \details ISO/IEC TR-24772 provides bounds checking interfaces for potentially
|
||||
/// unsafe functions like memcpy(), strcpy() and memmove(). However,
|
||||
/// unsafe functions like std::memcpy(), strcpy() and std::memmove(). However,
|
||||
/// not all standard libraries provides them, like Glibc. The library's
|
||||
/// memmove_s() is a near-drop in replacement. Its only a near-replacement
|
||||
/// because the library's version throws an InvalidArgument on a bounds violation.
|
||||
@ -595,7 +595,7 @@ inline void memmove_s(void *dest, size_t sizeInBytes, const void *src, size_t co
|
||||
}
|
||||
|
||||
#if __BORLANDC__ >= 0x620
|
||||
// C++Builder 2010 workaround: can't use std::memcpy_s
|
||||
// C++Builder 2010 workaround: can't use memcpy_s
|
||||
// because it doesn't allow 0 lengths
|
||||
# define memcpy_s CryptoPP::memcpy_s
|
||||
# define memmove_s CryptoPP::memmove_s
|
||||
@ -630,7 +630,7 @@ inline void vec_swap(T& a, T& b)
|
||||
/// \param ptr pointer to the memory block being written
|
||||
/// \param val the integer value to write for each byte
|
||||
/// \param num the size of the source memory block, in bytes
|
||||
/// \details Internally the function calls memset with the value <tt>val</tt>.
|
||||
/// \details Internally the function calls std::memset with the value <tt>val</tt>.
|
||||
/// memset_z can be used to initialize a freshly allocated memory block.
|
||||
/// To zeroize a memory block on destruction use <tt>SecureWipeBuffer</tt>.
|
||||
/// \return the pointer to the memory block
|
||||
|
26
modes.cpp
26
modes.cpp
@ -44,16 +44,16 @@ void CFB_ModePolicy::Iterate(byte *output, const byte *input, CipherDir dir, siz
|
||||
m_cipher->ProcessAndXorBlock(m_register, input, output);
|
||||
if (iterationCount > 1)
|
||||
m_cipher->AdvancedProcessBlocks(output, PtrAdd(input,s), PtrAdd(output,s), (iterationCount-1)*s, 0);
|
||||
memcpy(m_register, PtrAdd(output,(iterationCount-1)*s), s);
|
||||
std::memcpy(m_register, PtrAdd(output,(iterationCount-1)*s), s);
|
||||
}
|
||||
else
|
||||
{
|
||||
// make copy first in case of in-place decryption
|
||||
memcpy(m_temp, PtrAdd(input,(iterationCount-1)*s), s);
|
||||
std::memcpy(m_temp, PtrAdd(input,(iterationCount-1)*s), s);
|
||||
if (iterationCount > 1)
|
||||
m_cipher->AdvancedProcessBlocks(input, PtrAdd(input,s), PtrAdd(output,s), (iterationCount-1)*s, BlockTransformation::BT_ReverseDirection);
|
||||
m_cipher->ProcessAndXorBlock(m_register, input, output);
|
||||
memcpy(m_register, m_temp, s);
|
||||
std::memcpy(m_register, m_temp, s);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ void OFB_ModePolicy::WriteKeystream(byte *keystreamBuffer, size_t iterationCount
|
||||
m_cipher->ProcessBlock(m_register, keystreamBuffer);
|
||||
if (iterationCount > 1)
|
||||
m_cipher->AdvancedProcessBlocks(keystreamBuffer, NULLPTR, PtrAdd(keystreamBuffer, s), s*(iterationCount-1), 0);
|
||||
memcpy(m_register, PtrAdd(keystreamBuffer, (iterationCount-1)*s), s);
|
||||
std::memcpy(m_register, PtrAdd(keystreamBuffer, (iterationCount-1)*s), s);
|
||||
}
|
||||
|
||||
void OFB_ModePolicy::CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length)
|
||||
@ -204,7 +204,7 @@ void CBC_Encryption::ProcessData(byte *outString, const byte *inString, size_t l
|
||||
m_cipher->AdvancedProcessBlocks(inString, m_register, outString, blockSize, BlockTransformation::BT_XorInput);
|
||||
if (length > blockSize)
|
||||
m_cipher->AdvancedProcessBlocks(PtrAdd(inString,blockSize), outString, PtrAdd(outString,blockSize), length-blockSize, BlockTransformation::BT_XorInput);
|
||||
memcpy(m_register, PtrAdd(outString, length - blockSize), blockSize);
|
||||
std::memcpy(m_register, PtrAdd(outString, length - blockSize), blockSize);
|
||||
}
|
||||
|
||||
size_t CBC_CTS_Encryption::ProcessLastBlock(byte *outString, size_t outLength, const byte *inString, size_t inLength)
|
||||
@ -219,7 +219,7 @@ size_t CBC_CTS_Encryption::ProcessLastBlock(byte *outString, size_t outLength, c
|
||||
throw InvalidArgument("CBC_Encryption: message is too short for ciphertext stealing");
|
||||
|
||||
// steal from IV
|
||||
memcpy(outString, m_register, inLength);
|
||||
std::memcpy(outString, m_register, inLength);
|
||||
outString = m_stolenIV;
|
||||
}
|
||||
else
|
||||
@ -229,13 +229,13 @@ size_t CBC_CTS_Encryption::ProcessLastBlock(byte *outString, size_t outLength, c
|
||||
m_cipher->ProcessBlock(m_register);
|
||||
inString = PtrAdd(inString, blockSize);
|
||||
inLength -= blockSize;
|
||||
memcpy(PtrAdd(outString, blockSize), m_register, inLength);
|
||||
std::memcpy(PtrAdd(outString, blockSize), m_register, inLength);
|
||||
}
|
||||
|
||||
// output last full ciphertext block
|
||||
xorbuf(m_register, inString, inLength);
|
||||
m_cipher->ProcessBlock(m_register);
|
||||
memcpy(outString, m_register, blockSize);
|
||||
std::memcpy(outString, m_register, blockSize);
|
||||
|
||||
return used;
|
||||
}
|
||||
@ -253,7 +253,7 @@ void CBC_Decryption::ProcessData(byte *outString, const byte *inString, size_t l
|
||||
|
||||
// save copy now in case of in-place decryption
|
||||
const unsigned int blockSize = BlockSize();
|
||||
memcpy(m_temp, PtrAdd(inString, length-blockSize), blockSize);
|
||||
std::memcpy(m_temp, PtrAdd(inString, length-blockSize), blockSize);
|
||||
if (length > blockSize)
|
||||
m_cipher->AdvancedProcessBlocks(PtrAdd(inString,blockSize), inString, PtrAdd(outString,blockSize), length-blockSize, BlockTransformation::BT_ReverseDirection|BlockTransformation::BT_AllowParallel);
|
||||
m_cipher->ProcessAndXorBlock(inString, m_register, outString);
|
||||
@ -281,19 +281,19 @@ size_t CBC_CTS_Decryption::ProcessLastBlock(byte *outString, size_t outLength, c
|
||||
}
|
||||
|
||||
// decrypt last partial plaintext block
|
||||
memcpy(m_temp, pn2, blockSize);
|
||||
std::memcpy(m_temp, pn2, blockSize);
|
||||
m_cipher->ProcessBlock(m_temp);
|
||||
xorbuf(m_temp, pn1, inLength);
|
||||
|
||||
if (stealIV)
|
||||
{
|
||||
memcpy(outString, m_temp, inLength);
|
||||
std::memcpy(outString, m_temp, inLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(PtrAdd(outString, blockSize), m_temp, inLength);
|
||||
std::memcpy(PtrAdd(outString, blockSize), m_temp, inLength);
|
||||
// decrypt next to last plaintext block
|
||||
memcpy(m_temp, pn1, inLength);
|
||||
std::memcpy(m_temp, pn1, inLength);
|
||||
m_cipher->ProcessBlock(m_temp);
|
||||
xorbuf(outString, m_temp, m_register, blockSize);
|
||||
}
|
||||
|
2
modes.h
2
modes.h
@ -201,7 +201,7 @@ inline void CopyOrZero(void *dest, size_t dsize, const void *src, size_t ssize)
|
||||
if (src != NULLPTR)
|
||||
memcpy_s(dest, dsize, src, ssize);
|
||||
else
|
||||
memset(dest, 0, dsize);
|
||||
std::memset(dest, 0, dsize);
|
||||
}
|
||||
|
||||
/// \brief OFB block cipher mode of operation
|
||||
|
@ -104,7 +104,7 @@ size_t EqualityComparisonFilter::ChannelPut2(const std::string &channel, const b
|
||||
size_t len = length;
|
||||
const byte *data = q2.Spy(len);
|
||||
len = STDMIN(len, length);
|
||||
if (memcmp(inString, data, len) != 0)
|
||||
if (std::memcmp(inString, data, len) != 0)
|
||||
goto mismatch;
|
||||
inString += len;
|
||||
length -= len;
|
||||
|
2
mqv.h
2
mqv.h
@ -176,7 +176,7 @@ public:
|
||||
void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
|
||||
{
|
||||
CRYPTOPP_UNUSED(rng);
|
||||
memcpy(publicKey, privateKey+StaticPrivateKeyLength(), EphemeralPublicKeyLength());
|
||||
std::memcpy(publicKey, privateKey+StaticPrivateKeyLength(), EphemeralPublicKeyLength());
|
||||
}
|
||||
|
||||
/// \brief Derive agreed value or shared secret
|
||||
|
6
oaep.cpp
6
oaep.cpp
@ -40,9 +40,9 @@ void OAEP_Base::Pad(RandomNumberGenerator &rng, const byte *input, size_t inputL
|
||||
|
||||
// DB = pHash || 00 ... || 01 || M
|
||||
pHash->CalculateDigest(maskedDB, encodingParameters.begin(), encodingParameters.size());
|
||||
memset(maskedDB+hLen, 0, dbLen-hLen-inputLength-1);
|
||||
std::memset(maskedDB+hLen, 0, dbLen-hLen-inputLength-1);
|
||||
maskedDB[dbLen-inputLength-1] = 0x01;
|
||||
memcpy(maskedDB+dbLen-inputLength, input, inputLength);
|
||||
std::memcpy(maskedDB+dbLen-inputLength, input, inputLength);
|
||||
|
||||
rng.GenerateBlock(maskedSeed, seedLen);
|
||||
member_ptr<MaskGeneratingFunction> pMGF(NewMGF());
|
||||
@ -89,7 +89,7 @@ DecodingResult OAEP_Base::Unpad(const byte *oaepBlock, size_t oaepBlockLen, byte
|
||||
return DecodingResult();
|
||||
|
||||
M++;
|
||||
memcpy(output, M, maskedDB+dbLen-M);
|
||||
std::memcpy(output, M, maskedDB+dbLen-M);
|
||||
return DecodingResult(maskedDB+dbLen-M);
|
||||
}
|
||||
|
||||
|
2
osrng.h
2
osrng.h
@ -265,7 +265,7 @@ void AutoSeededX917RNG<BLOCK_CIPHER>::Reseed(bool blocking, const byte *input, s
|
||||
|
||||
key = seed + BlockSize;
|
||||
} // check that seed and key don't have same value
|
||||
while (memcmp(key, seed, STDMIN((size_t)BlockSize, (size_t)KeyLength)) == 0);
|
||||
while (std::memcmp(key, seed, STDMIN((size_t)BlockSize, (size_t)KeyLength)) == 0);
|
||||
|
||||
Reseed(key, KeyLength, seed, NULLPTR);
|
||||
}
|
||||
|
10
panama.cpp
10
panama.cpp
@ -35,7 +35,7 @@ std::string Panama<B>::AlgorithmProvider() const
|
||||
template <class B>
|
||||
void Panama<B>::Reset()
|
||||
{
|
||||
memset(m_state, 0, m_state.SizeInBytes());
|
||||
std::memset(m_state, 0, m_state.SizeInBytes());
|
||||
#if CRYPTOPP_SSSE3_ASM_AVAILABLE && !defined(CRYPTOPP_DISABLE_PANAMA_ASM)
|
||||
m_state[17] = HasSSSE3();
|
||||
#endif
|
||||
@ -449,7 +449,7 @@ void PanamaHash<B>::TruncatedFinal(byte *hash, size_t size)
|
||||
|
||||
this->Iterate(1, NULLPTR, m_buf.BytePtr(), NULLPTR);
|
||||
|
||||
memcpy(hash, m_buf, size);
|
||||
std::memcpy(hash, m_buf, size);
|
||||
|
||||
this->Restart(); // reinit for next use
|
||||
}
|
||||
@ -460,7 +460,7 @@ void PanamaCipherPolicy<B>::CipherSetKey(const NameValuePairs ¶ms, const byt
|
||||
{
|
||||
CRYPTOPP_UNUSED(params); CRYPTOPP_UNUSED(length);
|
||||
CRYPTOPP_ASSERT(length==32);
|
||||
memcpy(m_key, key, 32);
|
||||
std::memcpy(m_key, key, 32);
|
||||
}
|
||||
|
||||
template <class B>
|
||||
@ -476,9 +476,9 @@ void PanamaCipherPolicy<B>::CipherResynchronize(byte *keystreamBuffer, const byt
|
||||
else
|
||||
{
|
||||
if (iv)
|
||||
memcpy(m_buf, iv, 32);
|
||||
std::memcpy(m_buf, iv, 32);
|
||||
else
|
||||
memset(m_buf, 0, 32);
|
||||
std::memset(m_buf, 0, 32);
|
||||
this->Iterate(1, m_buf);
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ void PKCS_EncryptionPaddingScheme::Pad(RandomNumberGenerator& rng, const byte *i
|
||||
pkcsBlock[i] = (byte)rng.GenerateWord32(1, 0xff);
|
||||
|
||||
pkcsBlock[pkcsBlockLen-inputLen-1] = 0; // separator
|
||||
memcpy(pkcsBlock+pkcsBlockLen-inputLen, input, inputLen);
|
||||
std::memcpy(pkcsBlock+pkcsBlockLen-inputLen, input, inputLen);
|
||||
}
|
||||
|
||||
DecodingResult PKCS_EncryptionPaddingScheme::Unpad(const byte *pkcsBlock, size_t pkcsBlockLen, byte *output, const NameValuePairs& parameters) const
|
||||
@ -112,7 +112,7 @@ DecodingResult PKCS_EncryptionPaddingScheme::Unpad(const byte *pkcsBlock, size_t
|
||||
if (invalid)
|
||||
return DecodingResult();
|
||||
|
||||
memcpy (output, pkcsBlock+i, outputLen);
|
||||
std::memcpy (output, pkcsBlock+i, outputLen);
|
||||
return DecodingResult(outputLen);
|
||||
}
|
||||
|
||||
@ -147,9 +147,9 @@ void PKCS1v15_SignatureMessageEncodingMethod::ComputeMessageRepresentative(Rando
|
||||
byte *pSeparator = pHashId - 1;
|
||||
|
||||
// pad with 0xff
|
||||
memset(pPadding, 0xff, pSeparator-pPadding);
|
||||
std::memset(pPadding, 0xff, pSeparator-pPadding);
|
||||
*pSeparator = 0;
|
||||
memcpy(pHashId, hashIdentifier.first, hashIdentifier.second);
|
||||
std::memcpy(pHashId, hashIdentifier.first, hashIdentifier.second);
|
||||
hash.Final(pDigest);
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ void Poly1305_Base<T>::Update(const byte *input, size_t length)
|
||||
}
|
||||
|
||||
if (rem)
|
||||
memcpy(m_acc, input, rem);
|
||||
std::memcpy(m_acc, input, rem);
|
||||
|
||||
m_idx = rem;
|
||||
}
|
||||
@ -366,7 +366,7 @@ void Poly1305TLS_Base::Update(const byte *input, size_t length)
|
||||
}
|
||||
|
||||
if (rem)
|
||||
memcpy(m_acc, input, rem);
|
||||
std::memcpy(m_acc, input, rem);
|
||||
|
||||
m_idx = rem;
|
||||
}
|
||||
|
4
pssr.cpp
4
pssr.cpp
@ -84,7 +84,7 @@ void PSSR_MEM_Base::ComputeMessageRepresentative(RandomNumberGenerator &rng,
|
||||
xorbuf(xorStart + 1 + recoverableMessageLength, salt, salt.size());
|
||||
if (hashIdentifier.first && hashIdentifier.second)
|
||||
{
|
||||
memcpy(representative + representativeByteLength - u, hashIdentifier.first, hashIdentifier.second);
|
||||
std::memcpy(representative + representativeByteLength - u, hashIdentifier.first, hashIdentifier.second);
|
||||
representative[representativeByteLength - 1] = 0xcc;
|
||||
}
|
||||
else
|
||||
@ -134,7 +134,7 @@ DecodingResult PSSR_MEM_Base::RecoverMessageFromRepresentative(
|
||||
recoverableMessageLength <= MaxRecoverableLength(representativeBitLength, hashIdentifier.second, digestSize))
|
||||
{
|
||||
if (recoverableMessage)
|
||||
memcpy(recoverableMessage, M+1, recoverableMessageLength);
|
||||
std::memcpy(recoverableMessage, M+1, recoverableMessageLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
if (!begin || !length) return length;
|
||||
size_t l = STDMIN(length, MaxSize()-m_tail);
|
||||
if (m_buf+m_tail != begin)
|
||||
memcpy(m_buf+m_tail, begin, l);
|
||||
std::memcpy(m_buf+m_tail, begin, l);
|
||||
m_tail += l;
|
||||
return l;
|
||||
}
|
||||
@ -67,7 +67,7 @@ public:
|
||||
inline size_t Peek(byte *target, size_t copyMax) const
|
||||
{
|
||||
size_t len = STDMIN(copyMax, m_tail-m_head);
|
||||
memcpy(target, m_buf+m_head, len);
|
||||
std::memcpy(target, m_buf+m_head, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
@ -410,7 +410,7 @@ void ByteQueue::Unget(const byte *inString, size_t length)
|
||||
size_t len = STDMIN(length, m_head->m_head);
|
||||
length -= len;
|
||||
m_head->m_head = m_head->m_head - len;
|
||||
memcpy(m_head->m_buf + m_head->m_head, inString + length, len);
|
||||
std::memcpy(m_head->m_buf + m_head->m_head, inString + length, len);
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
|
2
rc2.cpp
2
rc2.cpp
@ -34,7 +34,7 @@ void RC2::Base::UncheckedSetKey(const byte *key, unsigned int keyLen, const Name
|
||||
197,243,219, 71,229,165,156,119, 10,166, 32,104,254,127,193,173};
|
||||
|
||||
SecByteBlock L(128);
|
||||
memcpy(L, key, keyLen);
|
||||
std::memcpy(L, key, keyLen);
|
||||
|
||||
int i;
|
||||
for (i=keyLen; i<128; i++)
|
||||
|
8
rng.cpp
8
rng.cpp
@ -69,8 +69,8 @@ X917RNG::X917RNG(BlockTransformation *c, const byte *seed, const byte *determini
|
||||
// Garbage in the tail creates a non-conforming X9.17 or X9.31 generator.
|
||||
if (m_size > 8)
|
||||
{
|
||||
memset(m_datetime, 0x00, m_size);
|
||||
memset(m_lastBlock, 0x00, m_size);
|
||||
std::memset(m_datetime, 0x00, m_size);
|
||||
std::memset(m_lastBlock, 0x00, m_size);
|
||||
}
|
||||
|
||||
if (!deterministicTimeVector)
|
||||
@ -115,7 +115,7 @@ void X917RNG::GenerateIntoBufferedTransformation(BufferedTransformation &target,
|
||||
|
||||
// generate a new block of random bytes
|
||||
m_cipher->ProcessBlock(m_randseed);
|
||||
if (memcmp(m_lastBlock, m_randseed, m_size) == 0)
|
||||
if (std::memcmp(m_lastBlock, m_randseed, m_size) == 0)
|
||||
throw SelfTestFailure("X917RNG: Continuous random number generator test failed.");
|
||||
|
||||
// output random bytes
|
||||
@ -124,7 +124,7 @@ void X917RNG::GenerateIntoBufferedTransformation(BufferedTransformation &target,
|
||||
size -= len;
|
||||
|
||||
// compute new seed vector
|
||||
memcpy(m_lastBlock, m_randseed, m_size);
|
||||
std::memcpy(m_lastBlock, m_randseed, m_size);
|
||||
xorbuf(m_randseed, m_datetime, m_size);
|
||||
m_cipher->ProcessBlock(m_randseed);
|
||||
}
|
||||
|
@ -713,7 +713,7 @@ void XSalsa20_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key
|
||||
|
||||
GetUserKey(LITTLE_ENDIAN_ORDER, m_key.begin(), m_key.size(), key, length);
|
||||
if (length == 16)
|
||||
memcpy(m_key.begin()+4, m_key.begin(), 16);
|
||||
std::memcpy(m_key.begin()+4, m_key.begin(), 16);
|
||||
|
||||
// "expand 32-byte k"
|
||||
m_state[0] = 0x61707865;
|
||||
|
4
seal.cpp
4
seal.cpp
@ -24,7 +24,7 @@ struct SEAL_Gamma
|
||||
: H(5), Z(5), D(16), lastIndex(0xffffffff)
|
||||
{
|
||||
GetUserKey(BIG_ENDIAN_ORDER, H.begin(), 5, key, 20);
|
||||
memset(D, 0, 64);
|
||||
std::memset(D, 0, 64);
|
||||
}
|
||||
|
||||
word32 Apply(word32 i);
|
||||
@ -38,7 +38,7 @@ word32 SEAL_Gamma::Apply(word32 i)
|
||||
word32 shaIndex = i/5;
|
||||
if (shaIndex != lastIndex)
|
||||
{
|
||||
memcpy(Z, H, 20);
|
||||
std::memcpy(Z, H, 20);
|
||||
D[0] = shaIndex;
|
||||
SHA1::Transform(Z, D);
|
||||
lastIndex = shaIndex;
|
||||
|
@ -792,7 +792,7 @@ public:
|
||||
if (m_ptr && ptr)
|
||||
memcpy_s(m_ptr, m_size*sizeof(T), ptr, len*sizeof(T));
|
||||
else if (m_ptr && m_size)
|
||||
memset(m_ptr, 0, m_size*sizeof(T));
|
||||
std::memset(m_ptr, 0, m_size*sizeof(T));
|
||||
}
|
||||
|
||||
~SecBlock()
|
||||
@ -888,7 +888,7 @@ public:
|
||||
/// \param ptr a pointer to an array of T
|
||||
/// \param len the number of elements in the memory block
|
||||
/// \details The array pointed to by <tt>ptr</tt> must be distinct
|
||||
/// from this SecBlock because Assign() calls New() and then memcpy().
|
||||
/// from this SecBlock because Assign() calls New() and then std::memcpy().
|
||||
/// The call to New() will invalidate all pointers and iterators, like
|
||||
/// the pointer returned from data().
|
||||
/// \details If the memory block is reduced in size, then the reclaimed
|
||||
@ -941,7 +941,7 @@ public:
|
||||
/// \param len the number of elements in the memory block
|
||||
/// \throw InvalidArgument if resulting size would overflow
|
||||
/// \details The array pointed to by <tt>ptr</tt> must be distinct
|
||||
/// from this SecBlock because Append() calls Grow() and then memcpy().
|
||||
/// from this SecBlock because Append() calls Grow() and then std::memcpy().
|
||||
/// The call to Grow() will invalidate all pointers and iterators, like
|
||||
/// the pointer returned from data().
|
||||
/// \details Append() may be less efficient than a ByteQueue because
|
||||
|
10
sha.cpp
10
sha.cpp
@ -421,7 +421,7 @@ void SHA256_HashBlock_CXX(word32 *state, const word32 *data)
|
||||
{
|
||||
word32 W[16]={0}, T[8];
|
||||
/* Copy context->state[] to working vars */
|
||||
memcpy(T, state, sizeof(T));
|
||||
std::memcpy(T, state, sizeof(T));
|
||||
/* 64 operations, partially loop unrolled */
|
||||
for (unsigned int j=0; j<64; j+=16)
|
||||
{
|
||||
@ -503,7 +503,7 @@ void SHA224::InitState(HashWordType *state)
|
||||
static const word32 s[8] = {
|
||||
0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
|
||||
0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4};
|
||||
memcpy(state, s, sizeof(s));
|
||||
std::memcpy(state, s, sizeof(s));
|
||||
}
|
||||
|
||||
void SHA256::InitState(HashWordType *state)
|
||||
@ -511,7 +511,7 @@ void SHA256::InitState(HashWordType *state)
|
||||
static const word32 s[8] = {
|
||||
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
|
||||
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
|
||||
memcpy(state, s, sizeof(s));
|
||||
std::memcpy(state, s, sizeof(s));
|
||||
}
|
||||
#endif // Not CRYPTOPP_GENERATE_X64_MASM
|
||||
|
||||
@ -1096,7 +1096,7 @@ void SHA384::InitState(HashWordType *state)
|
||||
W64LIT(0x9159015a3070dd17), W64LIT(0x152fecd8f70e5939),
|
||||
W64LIT(0x67332667ffc00b31), W64LIT(0x8eb44a8768581511),
|
||||
W64LIT(0xdb0c2e0d64f98fa7), W64LIT(0x47b5481dbefa4fa4)};
|
||||
memcpy(state, s, sizeof(s));
|
||||
std::memcpy(state, s, sizeof(s));
|
||||
}
|
||||
|
||||
void SHA512::InitState(HashWordType *state)
|
||||
@ -1106,7 +1106,7 @@ void SHA512::InitState(HashWordType *state)
|
||||
W64LIT(0x3c6ef372fe94f82b), W64LIT(0xa54ff53a5f1d36f1),
|
||||
W64LIT(0x510e527fade682d1), W64LIT(0x9b05688c2b3e6c1f),
|
||||
W64LIT(0x1f83d9abfb41bd6b), W64LIT(0x5be0cd19137e2179)};
|
||||
memcpy(state, s, sizeof(s));
|
||||
std::memcpy(state, s, sizeof(s));
|
||||
}
|
||||
|
||||
#if CRYPTOPP_SSE2_ASM_AVAILABLE && (CRYPTOPP_BOOL_X86)
|
||||
|
2
sha3.cpp
2
sha3.cpp
@ -52,7 +52,7 @@ void SHA3::Update(const byte *input, size_t length)
|
||||
|
||||
void SHA3::Restart()
|
||||
{
|
||||
memset(m_state, 0, m_state.SizeInBytes());
|
||||
std::memset(m_state, 0, m_state.SizeInBytes());
|
||||
m_counter = 0;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ void SHAKE::Update(const byte *input, size_t length)
|
||||
|
||||
void SHAKE::Restart()
|
||||
{
|
||||
memset(m_state, 0, m_state.SizeInBytes());
|
||||
std::memset(m_state, 0, m_state.SizeInBytes());
|
||||
m_counter = 0;
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ void SipHash_Base<C,D,T_128bit>::Update(const byte *input, size_t length)
|
||||
if (m_idx)
|
||||
{
|
||||
size_t head = STDMIN(size_t(8U-m_idx), length);
|
||||
memcpy(m_acc+m_idx, input, head);
|
||||
std::memcpy(m_acc+m_idx, input, head);
|
||||
m_idx += head; input += head; length -= head;
|
||||
|
||||
if (m_idx == 8)
|
||||
@ -197,7 +197,7 @@ void SipHash_Base<C,D,T_128bit>::Update(const byte *input, size_t length)
|
||||
size_t tail = length % 8;
|
||||
if (tail)
|
||||
{
|
||||
memcpy(m_acc+m_idx, input, tail);
|
||||
std::memcpy(m_acc+m_idx, input, tail);
|
||||
m_idx += tail;
|
||||
}
|
||||
}
|
||||
|
2
stdcpp.h
2
stdcpp.h
@ -95,7 +95,7 @@ namespace std {
|
||||
// C++Builder's standard library (Dinkumware) do not have C's global log() function
|
||||
// https://github.com/weidai11/cryptopp/issues/520
|
||||
#ifdef __BORLANDC__
|
||||
using std::log;
|
||||
using log;
|
||||
#endif
|
||||
|
||||
#endif // CRYPTOPP_STDCPP_H
|
||||
|
@ -46,7 +46,7 @@ void Tiger::TruncatedFinal(byte *digest, size_t digestSize)
|
||||
|
||||
Transform(m_state, m_data);
|
||||
CorrectEndianess(m_state, m_state, DigestSize());
|
||||
memcpy(digest, m_state, digestSize);
|
||||
std::memcpy(digest, m_state, digestSize);
|
||||
|
||||
Restart(); // reinit for next use
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ void TTMAC_Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, co
|
||||
{
|
||||
AssertValidKeyLength(keylength);
|
||||
|
||||
memcpy(m_key, userKey, KEYLENGTH);
|
||||
std::memcpy(m_key, userKey, KEYLENGTH);
|
||||
CorrectEndianess(m_key, m_key, KEYLENGTH);
|
||||
|
||||
Init();
|
||||
@ -105,7 +105,7 @@ void TTMAC_Base::TruncatedFinal(byte *hash, size_t size)
|
||||
}
|
||||
|
||||
CorrectEndianess(m_digest, m_digest, size);
|
||||
memcpy(hash, m_digest, size);
|
||||
std::memcpy(hash, m_digest, size);
|
||||
|
||||
Restart(); // reinit for next use
|
||||
}
|
||||
|
@ -846,7 +846,7 @@ bool TestSecBlock()
|
||||
{
|
||||
static const unsigned int SIZE = 8;
|
||||
SecBlockWithHint<byte, SIZE> block(SIZE);
|
||||
memset(block, 0xaa, block.SizeInBytes());
|
||||
std::memset(block, 0xaa, block.SizeInBytes());
|
||||
|
||||
temp = true;
|
||||
block.CleanGrow(SIZE*2);
|
||||
@ -883,7 +883,7 @@ bool TestSecBlock()
|
||||
{
|
||||
static const unsigned int SIZE = 8;
|
||||
SecBlockWithHint<word32, SIZE> block(SIZE);
|
||||
memset(block, 0xaa, block.SizeInBytes());
|
||||
std::memset(block, 0xaa, block.SizeInBytes());
|
||||
|
||||
temp = true;
|
||||
block.CleanGrow(SIZE*2);
|
||||
@ -921,7 +921,7 @@ bool TestSecBlock()
|
||||
{
|
||||
static const unsigned int SIZE = 8;
|
||||
SecBlockWithHint<word64, SIZE> block(SIZE);
|
||||
memset(block, 0xaa, block.SizeInBytes());
|
||||
std::memset(block, 0xaa, block.SizeInBytes());
|
||||
|
||||
temp = true;
|
||||
block.CleanGrow(SIZE*2);
|
||||
@ -960,7 +960,7 @@ bool TestSecBlock()
|
||||
{
|
||||
static const unsigned int SIZE = 8;
|
||||
SecBlock<word128, AllocatorWithCleanup<word128, true> > block(SIZE);
|
||||
memset(block, 0xaa, block.SizeInBytes());
|
||||
std::memset(block, 0xaa, block.SizeInBytes());
|
||||
|
||||
temp = true;
|
||||
block.CleanGrow(SIZE*2);
|
||||
|
24
validat3.cpp
24
validat3.cpp
@ -997,7 +997,7 @@ bool ValidateHashDRBG()
|
||||
"\xBD\x0F\x05\xF2\x5A\x69\x88\xC1\x74\x36\x39\x62\x27\x18\x4A\xF8\x4A\x56\x43\x35"
|
||||
"\x65\x8E\x2F\x85\x72\xBE\xA3\x33\xEE\xE2\xAB\xFF\x22\xFF\xA6\xDE\x3E\x22\xAC\xA2";
|
||||
|
||||
fail = !!memcmp(result, expected, 640/8);
|
||||
fail = !!std::memcmp(result, expected, 640/8);
|
||||
pass = !fail && pass;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA1/128/440 (COUNT=0, E=16, N=8)\n";
|
||||
@ -1022,7 +1022,7 @@ bool ValidateHashDRBG()
|
||||
"\x80\x2E\x68\x05\x4A\xAB\xA8\x7C\xD6\x3A\xD3\xE5\xC9\x7C\x06\xE7\xA3\x9F\xF6\xF9"
|
||||
"\x8E\xB3\xD9\x72\xD4\x11\x35\xE5\xE7\x46\x1B\x49\x9C\x56\x45\x6A\xBE\x7F\x77\xD4";
|
||||
|
||||
fail = !!memcmp(result, expected, 640/8);
|
||||
fail = !!std::memcmp(result, expected, 640/8);
|
||||
pass = !fail && pass;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA1/128/440 (COUNT=1, E=16, N=8)\n";
|
||||
@ -1050,7 +1050,7 @@ bool ValidateHashDRBG()
|
||||
"\x58\x70\xB3\x39\x46\x8C\xDD\x8D\x6F\xAF\x8C\x56\x16\x3A\x70\x0A\x75\xB2\x3E\x59"
|
||||
"\x9B\x5A\xEC\xF1\x6F\x3B\xAF\x6D\x5F\x24\x19\x97\x1F\x24\xF4\x46\x72\x0F\xEA\xBE";
|
||||
|
||||
fail = !!memcmp(result, expected, 640/8);
|
||||
fail = !!std::memcmp(result, expected, 640/8);
|
||||
pass = !fail && pass;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA1/128/440 (C0UNT=0, E=16, N=8, A=16)\n";
|
||||
@ -1078,7 +1078,7 @@ bool ValidateHashDRBG()
|
||||
"\x06\x94\x41\xD6\xB5\xC5\x44\x60\x54\x07\xE8\xE7\xDC\x1C\xD8\xE4\x70\xAD\x84\x77"
|
||||
"\x5A\x65\x31\xBE\xE0\xFC\x81\x36\xE2\x8F\x0B\xFE\xEB\xE1\x98\x62\x7E\x98\xE0\xC1";
|
||||
|
||||
fail = !!memcmp(result, expected, 640/8);
|
||||
fail = !!std::memcmp(result, expected, 640/8);
|
||||
pass = !fail && pass;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA1/128/440 (C0UNT=1, E=16, N=8, A=16)\n";
|
||||
@ -1104,7 +1104,7 @@ bool ValidateHashDRBG()
|
||||
"\xB6\xC5\x68\xD8\x40\x6E\x2B\xD4\x3D\x23\xEB\x0F\x10\xBA\x5F\x24\x9C\xC9\xE9\x4A"
|
||||
"\xD3\xA5\xF1\xDF\xA4\xF2\xB4\x80\x40\x91\xED\x8C\xD6\x6D\xE7\xB7\x53\xB2\x09\xD5";
|
||||
|
||||
fail = !!memcmp(result, expected, 640/8);
|
||||
fail = !!std::memcmp(result, expected, 640/8);
|
||||
pass = !fail && pass;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA1/128/440 (C0UNT=0, E=16, N=8, A=0, P=16)\n";
|
||||
@ -1130,7 +1130,7 @@ bool ValidateHashDRBG()
|
||||
"\xDC\x16\xBC\x5F\x69\xE5\xBB\x05\xD1\x43\x8F\x80\xAB\xC5\x8F\x9C\x3F\x75\x57\xEB"
|
||||
"\x44\x0D\xF5\x0C\xF4\x95\x23\x94\x67\x11\x55\x98\x14\x43\xFF\x13\x14\x85\x5A\xBC";
|
||||
|
||||
fail = !!memcmp(result, expected, 640/8);
|
||||
fail = !!std::memcmp(result, expected, 640/8);
|
||||
pass = !fail && pass;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA1/128/440 (C0UNT=1, E=16, N=8, A=0, P=16)\n";
|
||||
@ -1159,7 +1159,7 @@ bool ValidateHashDRBG()
|
||||
"\xDD\x92\x33\x78\x6D\x5D\x41\xFF\xFA\xE9\x80\x59\x04\x85\x21\xE2\x52\x84\xBC\x6F"
|
||||
"\xDB\x97\xF3\x4E\x6A\x12\x7A\xCD\x41\x0F\x50\x68\x28\x46\xBE\x56\x9E\x9A\x6B\xC8";
|
||||
|
||||
fail = !!memcmp(result, expected, 640/8);
|
||||
fail = !!std::memcmp(result, expected, 640/8);
|
||||
pass = !fail && pass;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA1/128/440 (C0UNT=0, E=16, N=8, A=16, P=16)\n";
|
||||
@ -1188,7 +1188,7 @@ bool ValidateHashDRBG()
|
||||
"\x73\x91\x27\xE9\x31\xC0\x55\x55\x11\xE8\xB6\x57\x02\x0D\xCE\x90\xAC\x31\xB9\x00"
|
||||
"\x31\xC1\xD4\x4F\xE7\x12\x3B\xCC\x85\x16\x2F\x12\x8F\xB2\xDF\x84\x4E\xF7\x06\xBE";
|
||||
|
||||
fail = !!memcmp(result, expected, 640/8);
|
||||
fail = !!std::memcmp(result, expected, 640/8);
|
||||
pass = !fail && pass;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA1/128/440 (C0UNT=1, E=16, N=8, A=16, P=16)\n";
|
||||
@ -1220,7 +1220,7 @@ bool ValidateHashDRBG()
|
||||
"\xE1\x03\x3A\x76\x54\xFF\xD7\x24\x70\x5E\x8C\xB2\x41\x7D\x92\x0A\x2F\x4F\x27\xB8"
|
||||
"\x45\x13\x7F\xFB\x87\x90\xA9\x49";
|
||||
|
||||
fail = !!memcmp(result, expected, 1024/8);
|
||||
fail = !!std::memcmp(result, expected, 1024/8);
|
||||
pass = !fail && pass;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA256/128/440 (C0UNT=0, E=32, N=16, A=32, P=32)\n";
|
||||
@ -1252,7 +1252,7 @@ bool ValidateHashDRBG()
|
||||
"\xDB\xB1\xED\x94\x12\x6A\x2F\x03\x98\x4A\xD4\xD1\x72\xF3\x7A\x66\x74\x7E\x2A\x5B"
|
||||
"\xDE\xEF\x43\xBC\xB9\x8C\x49\x01";
|
||||
|
||||
fail = !!memcmp(result, expected, 1024/8);
|
||||
fail = !!std::memcmp(result, expected, 1024/8);
|
||||
pass = !fail && pass;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA256/128/440 (C0UNT=1, E=32, N=16, A=32, P=32)\n";
|
||||
@ -1290,7 +1290,7 @@ bool ValidateHashDRBG()
|
||||
"\xF2\x86\xE4\xED\x74\xF2\x5D\x8B\x6C\x4D\xB8\xDE\xD8\x4A\xD6\x5E\xD6\x6D\xAE\xB1"
|
||||
"\x1B\xA2\x94\x52\x54\xAD\x3C\x3D\x25\xBD\x12\x46\x3C\xA0\x45\x9D";
|
||||
|
||||
fail = !!memcmp(result, expected, 2048/8);
|
||||
fail = !!std::memcmp(result, expected, 2048/8);
|
||||
pass = !fail && pass;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA512/256/888 (C0UNT=0, E=32, N=16, A=32, P=32)\n";
|
||||
@ -1328,7 +1328,7 @@ bool ValidateHashDRBG()
|
||||
"\x7D\x21\x14\x34\xA5\x87\x43\xA4\x0A\x96\x77\x00\xCC\xCA\xB1\xDA\xC4\x39\xE0\x66"
|
||||
"\x37\x05\x6E\xAC\xF2\xE6\xC6\xC5\x4F\x79\xD3\xE5\x6A\x3D\x36\x3F";
|
||||
|
||||
fail = !!memcmp(result, expected, 2048/8);
|
||||
fail = !!std::memcmp(result, expected, 2048/8);
|
||||
pass = !fail && pass;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ") << "Hash_DRBG SHA512/256/888 (C0UNT=1, E=32, N=16, A=32, P=32)\n";
|
||||
|
32
validat4.cpp
32
validat4.cpp
@ -97,7 +97,7 @@ bool ValidateHmacDRBG()
|
||||
"\x94\xf1\xc1\xa5\xcf\x73\x22\xec\x1a\xe0\x96\x4e\xd4\xbf\x12\x27\x46\xe0\x87\xfd"
|
||||
"\xb5\xb3\xe9\x1b\x34\x93\xd5\xbb\x98\xfa\xed\x49\xe8\x5f\x13\x0f\xc8\xa4\x59\xb7";
|
||||
|
||||
fail = !!memcmp(result, expected, 640/8);
|
||||
fail = !!std::memcmp(result, expected, 640/8);
|
||||
pass = !fail && pass;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ") << "HMAC_DRBG SHA1/128/440 (COUNT=0, E=16, N=8)\n";
|
||||
@ -122,7 +122,7 @@ bool ValidateHmacDRBG()
|
||||
"\xf5\x90\xf6\xc9\xb3\x8b\x46\x5b\x78\x3e\xcf\xf1\x3a\x77\x50\x20\x1f\x7e\xcf\x1b"
|
||||
"\x8a\xb3\x93\x60\x4c\x73\xb2\x38\x93\x36\x60\x9a\xf3\x44\x0c\xde\x43\x29\x8b\x84";
|
||||
|
||||
fail = !!memcmp(result, expected, 640/8);
|
||||
fail = !!std::memcmp(result, expected, 640/8);
|
||||
pass = !fail && pass;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ") << "HMAC_DRBG SHA1/128/440 (COUNT=1, E=16, N=8)\n";
|
||||
@ -152,7 +152,7 @@ bool ValidateHmacDRBG()
|
||||
"\x9d\xc3\x36\x52\xab\x58\xec\xb7\x65\x0e\xd8\x04\x67\xf7\x6a\x84\x9f\xb1\xcf\xc1"
|
||||
"\xed\x0a\x09\xf7\x15\x50\x86\x06\x4d\xb3\x24\xb1\xe1\x24\xf3\xfc\x9e\x61\x4f\xcb";
|
||||
|
||||
fail = !!memcmp(result, expected, 640/8);
|
||||
fail = !!std::memcmp(result, expected, 640/8);
|
||||
pass = !fail && pass;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ") << "HMAC_DRBG SHA1/128/440 (COUNT=0, E=16, N=8, A=16)\n";
|
||||
@ -180,7 +180,7 @@ bool ValidateHmacDRBG()
|
||||
"\xdb\x7a\x6e\x8e\x7a\xb9\x4c\x05\x50\x0b\x4d\x1e\x35\x7d\xf8\xe9\x57\xac\x89\x37"
|
||||
"\xb0\x5f\xb3\xd0\x80\xa0\xf9\x06\x74\xd4\x4d\xe1\xbd\x6f\x94\xd2\x95\xc4\x51\x9d";
|
||||
|
||||
fail = !!memcmp(result, expected, 640/8);
|
||||
fail = !!std::memcmp(result, expected, 640/8);
|
||||
pass = !fail && pass;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ") << "HMAC_DRBG SHA1/128/440 (COUNT=1, E=16, N=8, A=16)\n";
|
||||
@ -249,11 +249,11 @@ bool BlockTransformationTest(const CipherFactory &cg, BufferedTransformation &va
|
||||
|
||||
member_ptr<BlockTransformation> transE(cg.NewEncryption(key));
|
||||
transE->ProcessBlock(plain, out);
|
||||
fail = memcmp(out, cipher, cg.BlockSize()) != 0;
|
||||
fail = std::memcmp(out, cipher, cg.BlockSize()) != 0;
|
||||
|
||||
member_ptr<BlockTransformation> transD(cg.NewDecryption(key));
|
||||
transD->ProcessBlock(out, outplain);
|
||||
fail=fail || memcmp(outplain, plain, cg.BlockSize());
|
||||
fail=fail || std::memcmp(outplain, plain, cg.BlockSize());
|
||||
|
||||
pass = pass && !fail;
|
||||
|
||||
@ -522,7 +522,7 @@ bool ValidateCipherModes()
|
||||
modeE.SetStolenIV(stolenIV);
|
||||
fail = !TestFilter(StreamTransformationFilter(modeE).Ref(),
|
||||
plain, 3, encrypted, sizeof(encrypted));
|
||||
fail = memcmp(stolenIV, decryptionIV, 8) != 0 || fail;
|
||||
fail = std::memcmp(stolenIV, decryptionIV, 8) != 0 || fail;
|
||||
pass = pass && !fail;
|
||||
std::cout << (fail ? "FAILED " : "passed ") << "CBC encryption with ciphertext and IV stealing" << std::endl;
|
||||
|
||||
@ -690,11 +690,11 @@ bool ValidateRC2()
|
||||
|
||||
member_ptr<BlockTransformation> transE(new RC2Encryption(key, keyLen, effectiveLen));
|
||||
transE->ProcessBlock(plain, out);
|
||||
fail = memcmp(out, cipher, RC2Encryption::BLOCKSIZE) != 0;
|
||||
fail = std::memcmp(out, cipher, RC2Encryption::BLOCKSIZE) != 0;
|
||||
|
||||
member_ptr<BlockTransformation> transD(new RC2Decryption(key, keyLen, effectiveLen));
|
||||
transD->ProcessBlock(out, outplain);
|
||||
fail=fail || memcmp(outplain, plain, RC2Encryption::BLOCKSIZE);
|
||||
fail=fail || std::memcmp(outplain, plain, RC2Encryption::BLOCKSIZE);
|
||||
|
||||
pass = pass && !fail;
|
||||
|
||||
@ -843,13 +843,13 @@ bool ValidateARC4()
|
||||
|
||||
arc4.reset(new Weak::ARC4(Key0, sizeof(Key0)));
|
||||
arc4->ProcessString(Input0, sizeof(Input0));
|
||||
fail = memcmp(Input0, Output0, sizeof(Input0)) != 0;
|
||||
fail = std::memcmp(Input0, Output0, sizeof(Input0)) != 0;
|
||||
std::cout << (fail ? "FAILED" : "passed") << " Test 0" << std::endl;
|
||||
pass = pass && !fail;
|
||||
|
||||
arc4.reset(new Weak::ARC4(Key1, sizeof(Key1)));
|
||||
arc4->ProcessString(Key1, Input1, sizeof(Key1));
|
||||
fail = memcmp(Output1, Key1, sizeof(Key1)) != 0;
|
||||
fail = std::memcmp(Output1, Key1, sizeof(Key1)) != 0;
|
||||
std::cout << (fail ? "FAILED" : "passed") << " Test 1" << std::endl;
|
||||
pass = pass && !fail;
|
||||
|
||||
@ -1107,11 +1107,11 @@ bool ValidateBlowfish()
|
||||
{
|
||||
ECB_Mode<Blowfish>::Encryption enc2((byte *)key[i], strlen(key[i]));
|
||||
enc2.ProcessData(out, plain[i], 8);
|
||||
fail = memcmp(out, cipher[i], 8) != 0;
|
||||
fail = std::memcmp(out, cipher[i], 8) != 0;
|
||||
|
||||
ECB_Mode<Blowfish>::Decryption dec2((byte *)key[i], strlen(key[i]));
|
||||
dec2.ProcessData(outplain, cipher[i], 8);
|
||||
fail = fail || memcmp(outplain, plain[i], 8);
|
||||
fail = fail || std::memcmp(outplain, plain[i], 8);
|
||||
pass3 = pass3 && !fail;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ");
|
||||
@ -1320,7 +1320,7 @@ bool ValidateSEAL()
|
||||
unsigned int size = sizeof(input);
|
||||
bool pass = true;
|
||||
|
||||
memset(output, 1, size);
|
||||
std::memset(output, 1, size);
|
||||
seal.ProcessString(output, input, size);
|
||||
for (unsigned int i=0; i<size; i++)
|
||||
if (output[i] != 0)
|
||||
@ -1329,7 +1329,7 @@ bool ValidateSEAL()
|
||||
seal.Seek(1);
|
||||
output[1] = seal.ProcessByte(output[1]);
|
||||
seal.ProcessString(output+2, size-2);
|
||||
pass = pass && memcmp(output+1, input+1, size-1) == 0;
|
||||
pass = pass && std::memcmp(output+1, input+1, size-1) == 0;
|
||||
|
||||
std::cout << (pass ? "passed" : "FAILED") << std::endl;
|
||||
return pass;
|
||||
@ -1461,7 +1461,7 @@ void MyEncoder::IsolatedInitialize(const NameValuePairs ¶meters)
|
||||
const char *lineBreak = insertLineBreaks ? "\n" : "";
|
||||
|
||||
char stars[64];
|
||||
memset(stars, '*', 64);
|
||||
std::memset(stars, '*', 64);
|
||||
|
||||
m_filter->Initialize(CombinedNameValuePairs(
|
||||
parameters,
|
||||
|
117
validat5.cpp
117
validat5.cpp
@ -65,24 +65,23 @@ struct HashTestTuple
|
||||
: input((byte *)input), output((byte *)output), inputLen(inputLen), repeatTimes(repeatTimes) {}
|
||||
|
||||
const byte *input, *output;
|
||||
size_t inputLen;
|
||||
unsigned int repeatTimes;
|
||||
size_t inputLen, repeatTimes;
|
||||
};
|
||||
|
||||
bool HashModuleTest(HashTransformation &md, const HashTestTuple *testSet, unsigned int testSetSize)
|
||||
bool HashModuleTest(HashTransformation &md, const HashTestTuple *testSet, size_t testSetSize)
|
||||
{
|
||||
bool pass=true, fail;
|
||||
std::ostringstream oss;
|
||||
|
||||
SecByteBlock digest(md.DigestSize());
|
||||
for (unsigned int i=0; i<testSetSize; i++)
|
||||
for (size_t i=0; i<testSetSize; i++)
|
||||
{
|
||||
unsigned j;
|
||||
size_t j;
|
||||
|
||||
for (j=0; j<testSet[i].repeatTimes; j++)
|
||||
md.Update(testSet[i].input, testSet[i].inputLen);
|
||||
md.Final(digest);
|
||||
fail = memcmp(digest, testSet[i].output, md.DigestSize()) != 0;
|
||||
fail = std::memcmp(digest, testSet[i].output, md.DigestSize()) != 0;
|
||||
pass = pass && !fail;
|
||||
|
||||
oss << (fail ? "FAILED " : "passed ");
|
||||
@ -100,7 +99,7 @@ bool HashModuleTest(HashTransformation &md, const HashTestTuple *testSet, unsign
|
||||
|
||||
bool ValidateCRC32()
|
||||
{
|
||||
HashTestTuple testSet[] =
|
||||
const HashTestTuple testSet[] =
|
||||
{
|
||||
HashTestTuple("", "\x00\x00\x00\x00"),
|
||||
HashTestTuple("a", "\x43\xbe\xb7\xe8"),
|
||||
@ -120,7 +119,7 @@ bool ValidateCRC32()
|
||||
|
||||
bool ValidateCRC32C()
|
||||
{
|
||||
HashTestTuple testSet[] =
|
||||
const HashTestTuple testSet[] =
|
||||
{
|
||||
HashTestTuple("", "\x00\x00\x00\x00"),
|
||||
HashTestTuple("a", "\x30\x43\xd0\xc1"),
|
||||
@ -140,7 +139,7 @@ bool ValidateCRC32C()
|
||||
|
||||
bool ValidateAdler32()
|
||||
{
|
||||
HashTestTuple testSet[] =
|
||||
const HashTestTuple testSet[] =
|
||||
{
|
||||
HashTestTuple("", "\x00\x00\x00\x01"),
|
||||
HashTestTuple("a", "\x00\x62\x00\x62"),
|
||||
@ -159,7 +158,7 @@ bool ValidateAdler32()
|
||||
|
||||
bool ValidateMD2()
|
||||
{
|
||||
HashTestTuple testSet[] =
|
||||
const HashTestTuple testSet[] =
|
||||
{
|
||||
HashTestTuple("", "\x83\x50\xe5\xa3\xe2\x4c\x15\x3d\xf2\x27\x5c\x9f\x80\x69\x27\x73"),
|
||||
HashTestTuple("a", "\x32\xec\x01\xec\x4a\x6d\xac\x72\xc0\xab\x96\xfb\x34\xc0\xb5\xd1"),
|
||||
@ -178,7 +177,7 @@ bool ValidateMD2()
|
||||
|
||||
bool ValidateMD4()
|
||||
{
|
||||
HashTestTuple testSet[] =
|
||||
const HashTestTuple testSet[] =
|
||||
{
|
||||
HashTestTuple("", "\x31\xd6\xcf\xe0\xd1\x6a\xe9\x31\xb7\x3c\x59\xd7\xe0\xc0\x89\xc0"),
|
||||
HashTestTuple("a", "\xbd\xe5\x2c\xb3\x1d\xe3\x3e\x46\x24\x5e\x05\xfb\xdb\xd6\xfb\x24"),
|
||||
@ -197,7 +196,7 @@ bool ValidateMD4()
|
||||
|
||||
bool ValidateMD5()
|
||||
{
|
||||
HashTestTuple testSet[] =
|
||||
const HashTestTuple testSet[] =
|
||||
{
|
||||
HashTestTuple("", "\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04\xe9\x80\x09\x98\xec\xf8\x42\x7e"),
|
||||
HashTestTuple("a", "\x0c\xc1\x75\xb9\xc0\xf1\xb6\xa8\x31\xc3\x99\xe2\x69\x77\x26\x61"),
|
||||
@ -372,7 +371,7 @@ bool ValidateTiger()
|
||||
{
|
||||
std::cout << "\nTiger validation suite running...\n\n";
|
||||
|
||||
HashTestTuple testSet[] =
|
||||
const HashTestTuple testSet[] =
|
||||
{
|
||||
HashTestTuple("", "\x32\x93\xac\x63\x0c\x13\xf0\x24\x5f\x92\xbb\xb1\x76\x6e\x16\x16\x7a\x4e\x58\x49\x2d\xde\x73\xf3"),
|
||||
HashTestTuple("a", "\x77\xBE\xFB\xEF\x2E\x7E\xF8\xAB\x2E\xC8\xF9\x3B\xF5\x87\xA7\xFC\x61\x3E\x24\x7F\x5F\x24\x78\x09"),
|
||||
@ -395,7 +394,7 @@ bool ValidateTiger()
|
||||
|
||||
bool ValidateRIPEMD()
|
||||
{
|
||||
HashTestTuple testSet128[] =
|
||||
const HashTestTuple testSet128[] =
|
||||
{
|
||||
HashTestTuple("", "\xcd\xf2\x62\x13\xa1\x50\xdc\x3e\xcb\x61\x0f\x18\xf6\xb3\x8b\x46"),
|
||||
HashTestTuple("a", "\x86\xbe\x7a\xfa\x33\x9d\x0f\xc7\xcf\xc7\x85\xe7\x2f\x57\x8d\x33"),
|
||||
@ -408,7 +407,7 @@ bool ValidateRIPEMD()
|
||||
HashTestTuple("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "\x4a\x7f\x57\x23\xf9\x54\xeb\xa1\x21\x6c\x9d\x8f\x63\x20\x43\x1f", 15625)
|
||||
};
|
||||
|
||||
HashTestTuple testSet160[] =
|
||||
const HashTestTuple testSet160[] =
|
||||
{
|
||||
HashTestTuple("", "\x9c\x11\x85\xa5\xc5\xe9\xfc\x54\x61\x28\x08\x97\x7e\xe8\xf5\x48\xb2\x25\x8d\x31"),
|
||||
HashTestTuple("a", "\x0b\xdc\x9d\x2d\x25\x6b\x3e\xe9\xda\xae\x34\x7b\xe6\xf4\xdc\x83\x5a\x46\x7f\xfe"),
|
||||
@ -421,7 +420,7 @@ bool ValidateRIPEMD()
|
||||
HashTestTuple("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "\x52\x78\x32\x43\xc1\x69\x7b\xdb\xe1\x6d\x37\xf9\x7f\x68\xf0\x83\x25\xdc\x15\x28", 15625)
|
||||
};
|
||||
|
||||
HashTestTuple testSet256[] =
|
||||
const HashTestTuple testSet256[] =
|
||||
{
|
||||
HashTestTuple("", "\x02\xba\x4c\x4e\x5f\x8e\xcd\x18\x77\xfc\x52\xd6\x4d\x30\xe3\x7a\x2d\x97\x74\xfb\x1e\x5d\x02\x63\x80\xae\x01\x68\xe3\xc5\x52\x2d"),
|
||||
HashTestTuple("a", "\xf9\x33\x3e\x45\xd8\x57\xf5\xd9\x0a\x91\xba\xb7\x0a\x1e\xba\x0c\xfb\x1b\xe4\xb0\x78\x3c\x9a\xcf\xcd\x88\x3a\x91\x34\x69\x29\x25"),
|
||||
@ -434,7 +433,7 @@ bool ValidateRIPEMD()
|
||||
HashTestTuple("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "\xac\x95\x37\x44\xe1\x0e\x31\x51\x4c\x15\x0d\x4d\x8d\x7b\x67\x73\x42\xe3\x33\x99\x78\x82\x96\xe4\x3a\xe4\x85\x0c\xe4\xf9\x79\x78", 15625)
|
||||
};
|
||||
|
||||
HashTestTuple testSet320[] =
|
||||
const HashTestTuple testSet320[] =
|
||||
{
|
||||
HashTestTuple("", "\x22\xd6\x5d\x56\x61\x53\x6c\xdc\x75\xc1\xfd\xf5\xc6\xde\x7b\x41\xb9\xf2\x73\x25\xeb\xc6\x1e\x85\x57\x17\x7d\x70\x5a\x0e\xc8\x80\x15\x1c\x3a\x32\xa0\x08\x99\xb8"),
|
||||
HashTestTuple("a", "\xce\x78\x85\x06\x38\xf9\x26\x58\xa5\xa5\x85\x09\x75\x79\x92\x6d\xda\x66\x7a\x57\x16\x56\x2c\xfc\xf6\xfb\xe7\x7f\x63\x54\x2f\x99\xb0\x47\x05\xd6\x97\x0d\xff\x5d"),
|
||||
@ -471,7 +470,7 @@ bool ValidateRIPEMD()
|
||||
#ifdef CRYPTOPP_REMOVED
|
||||
bool ValidateHAVAL()
|
||||
{
|
||||
HashTestTuple testSet[] =
|
||||
const HashTestTuple testSet[] =
|
||||
{
|
||||
HashTestTuple("", "\xC6\x8F\x39\x91\x3F\x90\x1F\x3D\xDF\x44\xC7\x07\x35\x7A\x7D\x70"),
|
||||
HashTestTuple("a", "\x4D\xA0\x8F\x51\x4A\x72\x75\xDB\xC4\xCE\xCE\x4A\x34\x73\x85\x98\x39\x83\xA8\x30"),
|
||||
@ -580,7 +579,7 @@ bool ValidateMD5MAC()
|
||||
{
|
||||
mac.Update((byte *)TestVals[i], strlen(TestVals[i]));
|
||||
mac.Final(digest);
|
||||
fail = memcmp(digest, output[k][i], MD5MAC::DIGESTSIZE) != 0
|
||||
fail = std::memcmp(digest, output[k][i], MD5MAC::DIGESTSIZE) != 0
|
||||
|| !mac.VerifyDigest(output[k][i], (byte *)TestVals[i], strlen(TestVals[i]));
|
||||
pass = pass && !fail;
|
||||
oss << (fail ? "FAILED " : "passed ");
|
||||
@ -655,7 +654,7 @@ bool ValidateXMACC()
|
||||
{
|
||||
mac.Update((byte *)TestVals[i], strlen(TestVals[i]));
|
||||
mac.Final(digest);
|
||||
fail = memcmp(digest, output[k][i], XMACC_MD5::DIGESTSIZE) != 0
|
||||
fail = std::memcmp(digest, output[k][i], XMACC_MD5::DIGESTSIZE) != 0
|
||||
|| !mac.VerifyDigest(output[k][i], (byte *)TestVals[i], strlen(TestVals[i]));
|
||||
pass = pass && !fail;
|
||||
std::cout << (fail ? "FAILED " : "passed ");
|
||||
@ -706,7 +705,7 @@ bool ValidateTTMAC()
|
||||
{
|
||||
mac.Update((byte *)TestVals[k], strlen(TestVals[k]));
|
||||
mac.Final(digest);
|
||||
fail = memcmp(digest, output[k], TTMAC::DIGESTSIZE) != 0
|
||||
fail = std::memcmp(digest, output[k], TTMAC::DIGESTSIZE) != 0
|
||||
|| !mac.VerifyDigest(output[k], (byte *)TestVals[k], strlen(TestVals[k]));
|
||||
pass = pass && !fail;
|
||||
oss << (fail ? "FAILED " : "passed ");
|
||||
@ -726,11 +725,11 @@ struct PBKDF_TestTuple
|
||||
const char *hexPassword, *hexSalt, *hexDerivedKey;
|
||||
};
|
||||
|
||||
bool TestPBKDF(KeyDerivationFunction &pbkdf, const PBKDF_TestTuple *testSet, unsigned int testSetSize)
|
||||
bool TestPBKDF(KeyDerivationFunction &pbkdf, const PBKDF_TestTuple *testSet, size_t testSetSize)
|
||||
{
|
||||
bool pass = true;
|
||||
|
||||
for (unsigned int i=0; i<testSetSize; i++)
|
||||
for (size_t i=0; i<testSetSize; i++)
|
||||
{
|
||||
const PBKDF_TestTuple &tuple = testSet[i];
|
||||
|
||||
@ -746,7 +745,7 @@ bool TestPBKDF(KeyDerivationFunction &pbkdf, const PBKDF_TestTuple *testSet, uns
|
||||
|
||||
SecByteBlock derived(derivedKey.size());
|
||||
pbkdf.DeriveKey(derived, derived.size(), ConstBytePtr(password), BytePtrSize(password), params);
|
||||
bool fail = memcmp(derived, derivedKey.data(), derived.size()) != 0;
|
||||
bool fail = std::memcmp(derived, derivedKey.data(), derived.size()) != 0;
|
||||
pass = pass && !fail;
|
||||
|
||||
HexEncoder enc(new FileSink(std::cout));
|
||||
@ -810,11 +809,11 @@ struct HKDF_TestTuple
|
||||
size_t len;
|
||||
};
|
||||
|
||||
bool TestHKDF(KeyDerivationFunction &kdf, const HKDF_TestTuple *testSet, unsigned int testSetSize)
|
||||
bool TestHKDF(KeyDerivationFunction &kdf, const HKDF_TestTuple *testSet, size_t testSetSize)
|
||||
{
|
||||
bool pass = true;
|
||||
|
||||
for (unsigned int i=0; i<testSetSize; i++)
|
||||
for (size_t i=0; i<testSetSize; i++)
|
||||
{
|
||||
const HKDF_TestTuple &tuple = testSet[i];
|
||||
|
||||
@ -945,11 +944,11 @@ struct Scrypt_TestTuple
|
||||
const char * expect;
|
||||
};
|
||||
|
||||
bool TestScrypt(KeyDerivationFunction &pbkdf, const Scrypt_TestTuple *testSet, unsigned int testSetSize)
|
||||
bool TestScrypt(KeyDerivationFunction &pbkdf, const Scrypt_TestTuple *testSet, size_t testSetSize)
|
||||
{
|
||||
bool pass = true;
|
||||
|
||||
for (unsigned int i=0; i<testSetSize; i++)
|
||||
for (size_t i=0; i<testSetSize; i++)
|
||||
{
|
||||
const Scrypt_TestTuple &tuple = testSet[i];
|
||||
|
||||
@ -962,7 +961,7 @@ bool TestScrypt(KeyDerivationFunction &pbkdf, const Scrypt_TestTuple *testSet, u
|
||||
|
||||
SecByteBlock derived(expect.size());
|
||||
pbkdf.DeriveKey(derived, derived.size(), ConstBytePtr(password), BytePtrSize(password), params);
|
||||
bool fail = memcmp(derived, expect.data(), expect.size()) != 0;
|
||||
bool fail = std::memcmp(derived, expect.data(), expect.size()) != 0;
|
||||
pass = pass && !fail;
|
||||
|
||||
if (password.empty()) {password="\"\"";}
|
||||
@ -1070,14 +1069,14 @@ bool ValidatePoly1305()
|
||||
byte digest[Poly1305<AES>::DIGESTSIZE];
|
||||
|
||||
// Positive tests
|
||||
for (unsigned int i=0; i<COUNTOF(tests); ++i)
|
||||
for (size_t i=0; i<COUNTOF(tests); ++i)
|
||||
{
|
||||
Poly1305<AES> poly1305((const byte*)tests[i].key, tests[i].klen);
|
||||
poly1305.Resynchronize((const byte*)tests[i].nonce, (int)tests[i].nlen);
|
||||
poly1305.Update((const byte*)tests[i].message, tests[i].mlen);
|
||||
poly1305.Final(digest);
|
||||
|
||||
fail = memcmp(digest, tests[i].digest, tests[i].dlen) != 0;
|
||||
fail = std::memcmp(digest, tests[i].digest, tests[i].dlen) != 0;
|
||||
if (fail)
|
||||
{
|
||||
std::cout << "FAILED " << "Poly1305 test set " << count << std::endl;
|
||||
@ -1088,13 +1087,13 @@ bool ValidatePoly1305()
|
||||
}
|
||||
|
||||
// Positive tests
|
||||
for (unsigned int i=0; i<COUNTOF(tests); ++i)
|
||||
for (size_t i=0; i<COUNTOF(tests); ++i)
|
||||
{
|
||||
Poly1305<AES> poly1305((const byte*)tests[i].key, tests[i].klen,(const byte*)tests[i].nonce, (int)tests[i].nlen);
|
||||
poly1305.Update((const byte*)tests[i].message, tests[i].mlen);
|
||||
poly1305.Final(digest);
|
||||
|
||||
fail = memcmp(digest, tests[i].digest, tests[i].dlen) != 0;
|
||||
fail = std::memcmp(digest, tests[i].digest, tests[i].dlen) != 0;
|
||||
if (fail)
|
||||
{
|
||||
std::cout << "FAILED " << "Poly1305 test set " << count << std::endl;
|
||||
@ -1105,7 +1104,7 @@ bool ValidatePoly1305()
|
||||
}
|
||||
|
||||
// Negative tests
|
||||
for (unsigned int i=0; i<COUNTOF(tests); ++i)
|
||||
for (size_t i=0; i<COUNTOF(tests); ++i)
|
||||
{
|
||||
Poly1305<AES> poly1305((const byte*)tests[i].key, tests[i].klen);
|
||||
poly1305.Resynchronize((const byte*)tests[i].nonce, (int)tests[i].nlen);
|
||||
@ -1113,7 +1112,7 @@ bool ValidatePoly1305()
|
||||
poly1305.Final(digest);
|
||||
|
||||
unsigned int next = (i+1) % COUNTOF(tests);
|
||||
fail = memcmp(digest, tests[next].digest, tests[next].dlen) == 0;
|
||||
fail = std::memcmp(digest, tests[next].digest, tests[next].dlen) == 0;
|
||||
if (fail)
|
||||
{
|
||||
std::cout << "FAILED " << "Poly1305 test set " << count << std::endl;
|
||||
@ -1167,27 +1166,27 @@ bool ValidateSipHash()
|
||||
|
||||
hash.Update((const byte*)"", 0);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\x31\x0E\x0E\xDD\x47\xDB\x6F\x72", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\x31\x0E\x0E\xDD\x47\xDB\x6F\x72", digest, COUNTOF(digest)) != 0;
|
||||
pass1 = !fail && pass1;
|
||||
|
||||
hash.Update((const byte*)"\x00", 1);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\xFD\x67\xDC\x93\xC5\x39\xF8\x74", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\xFD\x67\xDC\x93\xC5\x39\xF8\x74", digest, COUNTOF(digest)) != 0;
|
||||
pass1 = !fail && pass1;
|
||||
|
||||
hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06", 7);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\x37\xD1\x01\x8B\xF5\x00\x02\xAB", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\x37\xD1\x01\x8B\xF5\x00\x02\xAB", digest, COUNTOF(digest)) != 0;
|
||||
pass1 = !fail && pass1;
|
||||
|
||||
hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07", 8);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\x62\x24\x93\x9A\x79\xF5\xF5\x93", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\x62\x24\x93\x9A\x79\xF5\xF5\x93", digest, COUNTOF(digest)) != 0;
|
||||
pass1 = !fail && pass1;
|
||||
|
||||
hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07\x08", 9);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\xB0\xE4\xA9\x0B\xDF\x82\x00\x9E", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\xB0\xE4\xA9\x0B\xDF\x82\x00\x9E", digest, COUNTOF(digest)) != 0;
|
||||
pass1 = !fail && pass1;
|
||||
|
||||
std::cout << (pass1 ? "passed " : "FAILED ") << "SipHash-2-4 64-bit MAC\n";
|
||||
@ -1202,27 +1201,27 @@ bool ValidateSipHash()
|
||||
|
||||
hash.Update((const byte*)"", 0);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\xA3\x81\x7F\x04\xBA\x25\xA8\xE6\x6D\xF6\x72\x14\xC7\x55\x02\x93", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\xA3\x81\x7F\x04\xBA\x25\xA8\xE6\x6D\xF6\x72\x14\xC7\x55\x02\x93", digest, COUNTOF(digest)) != 0;
|
||||
pass3 = !fail && pass3;
|
||||
|
||||
hash.Update((const byte*)"\x00", 1);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\xDA\x87\xC1\xD8\x6B\x99\xAF\x44\x34\x76\x59\x11\x9B\x22\xFC\x45", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\xDA\x87\xC1\xD8\x6B\x99\xAF\x44\x34\x76\x59\x11\x9B\x22\xFC\x45", digest, COUNTOF(digest)) != 0;
|
||||
pass3 = !fail && pass3;
|
||||
|
||||
hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06", 7);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\xA1\xF1\xEB\xBE\xD8\xDB\xC1\x53\xC0\xB8\x4A\xA6\x1F\xF0\x82\x39", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\xA1\xF1\xEB\xBE\xD8\xDB\xC1\x53\xC0\xB8\x4A\xA6\x1F\xF0\x82\x39", digest, COUNTOF(digest)) != 0;
|
||||
pass3 = !fail && pass3;
|
||||
|
||||
hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07", 8);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\x3B\x62\xA9\xBA\x62\x58\xF5\x61\x0F\x83\xE2\x64\xF3\x14\x97\xB4", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\x3B\x62\xA9\xBA\x62\x58\xF5\x61\x0F\x83\xE2\x64\xF3\x14\x97\xB4", digest, COUNTOF(digest)) != 0;
|
||||
pass3 = !fail && pass3;
|
||||
|
||||
hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07\x08", 9);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\x26\x44\x99\x06\x0A\xD9\xBA\xAB\xC4\x7F\x8B\x02\xBB\x6D\x71\xED", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\x26\x44\x99\x06\x0A\xD9\xBA\xAB\xC4\x7F\x8B\x02\xBB\x6D\x71\xED", digest, COUNTOF(digest)) != 0;
|
||||
pass3 = !fail && pass3;
|
||||
|
||||
std::cout << (pass3 ? "passed " : "FAILED ") << "SipHash-2-4 128-bit MAC\n";
|
||||
@ -1237,27 +1236,27 @@ bool ValidateSipHash()
|
||||
|
||||
hash.Update((const byte*)"", 0);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\x41\xDA\x38\x99\x2B\x05\x79\xC8", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\x41\xDA\x38\x99\x2B\x05\x79\xC8", digest, COUNTOF(digest)) != 0;
|
||||
pass2 = !fail && pass2;
|
||||
|
||||
hash.Update((const byte*)"\x00", 1);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\x51\xB8\x95\x52\xF9\x14\x59\xC8", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\x51\xB8\x95\x52\xF9\x14\x59\xC8", digest, COUNTOF(digest)) != 0;
|
||||
pass2 = !fail && pass2;
|
||||
|
||||
hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06", 7);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\x47\xD7\x3F\x71\x5A\xBE\xFD\x4E", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\x47\xD7\x3F\x71\x5A\xBE\xFD\x4E", digest, COUNTOF(digest)) != 0;
|
||||
pass2 = !fail && pass2;
|
||||
|
||||
hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07", 8);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\x20\xB5\x8B\x9C\x07\x2F\xDB\x50", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\x20\xB5\x8B\x9C\x07\x2F\xDB\x50", digest, COUNTOF(digest)) != 0;
|
||||
pass2 = !fail && pass2;
|
||||
|
||||
hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07\x08", 9);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\x36\x31\x9A\xF3\x5E\xE1\x12\x53", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\x36\x31\x9A\xF3\x5E\xE1\x12\x53", digest, COUNTOF(digest)) != 0;
|
||||
pass2 = !fail && pass2;
|
||||
|
||||
std::cout << (pass2 ? "passed " : "FAILED ") << "SipHash-4-8 64-bit MAC\n";
|
||||
@ -1272,27 +1271,27 @@ bool ValidateSipHash()
|
||||
|
||||
hash.Update((const byte*)"", 0);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\x1F\x64\xCE\x58\x6D\xA9\x04\xE9\xCF\xEC\xE8\x54\x83\xA7\x0A\x6C", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\x1F\x64\xCE\x58\x6D\xA9\x04\xE9\xCF\xEC\xE8\x54\x83\xA7\x0A\x6C", digest, COUNTOF(digest)) != 0;
|
||||
pass4 = !fail && pass4;
|
||||
|
||||
hash.Update((const byte*)"\x00", 1);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\x47\x34\x5D\xA8\xEF\x4C\x79\x47\x6A\xF2\x7C\xA7\x91\xC7\xA2\x80", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\x47\x34\x5D\xA8\xEF\x4C\x79\x47\x6A\xF2\x7C\xA7\x91\xC7\xA2\x80", digest, COUNTOF(digest)) != 0;
|
||||
pass4 = !fail && pass4;
|
||||
|
||||
hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06", 7);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\xED\x00\xE1\x3B\x18\x4B\xF1\xC2\x72\x6B\x8B\x54\xFF\xD2\xEE\xE0", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\xED\x00\xE1\x3B\x18\x4B\xF1\xC2\x72\x6B\x8B\x54\xFF\xD2\xEE\xE0", digest, COUNTOF(digest)) != 0;
|
||||
pass4 = !fail && pass4;
|
||||
|
||||
hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07", 8);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\xA7\xD9\x46\x13\x8F\xF9\xED\xF5\x36\x4A\x5A\x23\xAF\xCA\xE0\x63", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\xA7\xD9\x46\x13\x8F\xF9\xED\xF5\x36\x4A\x5A\x23\xAF\xCA\xE0\x63", digest, COUNTOF(digest)) != 0;
|
||||
pass4 = !fail && pass4;
|
||||
|
||||
hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07\x08", 9);
|
||||
hash.Final(digest);
|
||||
fail = memcmp("\x9E\x73\x14\xB7\x54\x5C\xEC\xA3\x8B\x9A\x55\x49\xE4\xFB\x0B\xE8", digest, COUNTOF(digest)) != 0;
|
||||
fail = std::memcmp("\x9E\x73\x14\xB7\x54\x5C\xEC\xA3\x8B\x9A\x55\x49\xE4\xFB\x0B\xE8", digest, COUNTOF(digest)) != 0;
|
||||
pass4 = !fail && pass4;
|
||||
|
||||
std::cout << (pass4 ? "passed " : "FAILED ") << "SipHash-4-8 128-bit MAC\n";
|
||||
@ -1708,7 +1707,7 @@ bool ValidateBLAKE2s()
|
||||
|
||||
{
|
||||
byte digest[BLAKE2s::DIGESTSIZE];
|
||||
for (unsigned int i=0; i<COUNTOF(tests); ++i)
|
||||
for (size_t i=0; i<COUNTOF(tests); ++i)
|
||||
{
|
||||
// the condition is written in a way which for non-default digest sizes
|
||||
// tests the BLAKE2_Base(bool treeMode, unsigned int digestSize) constructor.
|
||||
@ -1726,7 +1725,7 @@ bool ValidateBLAKE2s()
|
||||
blake2s.Final(digest);
|
||||
}
|
||||
|
||||
fail = memcmp(digest, tests[i].digest, tests[i].dlen) != 0;
|
||||
fail = std::memcmp(digest, tests[i].digest, tests[i].dlen) != 0;
|
||||
if (fail)
|
||||
{
|
||||
std::cout << "FAILED " << "BLAKE2s test set " << i << std::endl;
|
||||
@ -2162,7 +2161,7 @@ bool ValidateBLAKE2b()
|
||||
|
||||
{
|
||||
byte digest[BLAKE2b::DIGESTSIZE];
|
||||
for (unsigned int i=0; i<COUNTOF(tests); ++i)
|
||||
for (size_t i=0; i<COUNTOF(tests); ++i)
|
||||
{
|
||||
// the condition is written in a way which for non-default digest sizes
|
||||
// tests the BLAKE2_Base(bool treeMode, unsigned int digestSize) constructor.
|
||||
@ -2180,7 +2179,7 @@ bool ValidateBLAKE2b()
|
||||
blake2b.Final(digest);
|
||||
}
|
||||
|
||||
fail = memcmp(digest, tests[i].digest, tests[i].dlen) != 0;
|
||||
fail = std::memcmp(digest, tests[i].digest, tests[i].dlen) != 0;
|
||||
if (fail)
|
||||
{
|
||||
std::cout << "FAILED " << "BLAKE2b test set " << i << std::endl;
|
||||
|
28
validat6.cpp
28
validat6.cpp
@ -48,7 +48,7 @@ bool CryptoSystemValidate(PK_Decryptor &priv, PK_Encryptor &pub, bool thorough)
|
||||
|
||||
pub.Encrypt(GlobalRNG(), message, messageLen, ciphertext);
|
||||
fail = priv.Decrypt(GlobalRNG(), ciphertext, priv.CiphertextLength(messageLen), plaintext) != DecodingResult(messageLen);
|
||||
fail = fail || memcmp(message, plaintext, messageLen);
|
||||
fail = fail || std::memcmp(message, plaintext, messageLen);
|
||||
pass = pass && !fail;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ");
|
||||
@ -74,8 +74,8 @@ bool SimpleKeyAgreementValidate(SimpleKeyAgreementDomain &d)
|
||||
d.GenerateKeyPair(GlobalRNG(), priv1, pub1);
|
||||
d.GenerateKeyPair(GlobalRNG(), priv2, pub2);
|
||||
|
||||
memset(val1.begin(), 0x10, val1.size());
|
||||
memset(val2.begin(), 0x11, val2.size());
|
||||
std::memset(val1.begin(), 0x10, val1.size());
|
||||
std::memset(val2.begin(), 0x11, val2.size());
|
||||
|
||||
if (!(d.Agree(val1, priv1, pub2) && d.Agree(val2, priv2, pub1)))
|
||||
{
|
||||
@ -83,7 +83,7 @@ bool SimpleKeyAgreementValidate(SimpleKeyAgreementDomain &d)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (memcmp(val1.begin(), val2.begin(), d.AgreedValueLength()))
|
||||
if (std::memcmp(val1.begin(), val2.begin(), d.AgreedValueLength()))
|
||||
{
|
||||
std::cout << "FAILED simple agreed values not equal" << std::endl;
|
||||
return false;
|
||||
@ -114,8 +114,8 @@ bool AuthenticatedKeyAgreementValidate(AuthenticatedKeyAgreementDomain &d)
|
||||
d.GenerateEphemeralKeyPair(GlobalRNG(), epriv1, epub1);
|
||||
d.GenerateEphemeralKeyPair(GlobalRNG(), epriv2, epub2);
|
||||
|
||||
memset(val1.begin(), 0x10, val1.size());
|
||||
memset(val2.begin(), 0x11, val2.size());
|
||||
std::memset(val1.begin(), 0x10, val1.size());
|
||||
std::memset(val2.begin(), 0x11, val2.size());
|
||||
|
||||
if (d.Agree(val1, spriv1, epriv1, spub2, epub2) && d.Agree(val2, spriv2, epriv2, spub1, epub1))
|
||||
{
|
||||
@ -127,7 +127,7 @@ bool AuthenticatedKeyAgreementValidate(AuthenticatedKeyAgreementDomain &d)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (memcmp(val1.begin(), val2.begin(), d.AgreedValueLength()))
|
||||
if (std::memcmp(val1.begin(), val2.begin(), d.AgreedValueLength()))
|
||||
{
|
||||
std::cout << "FAILED authenticated agreed values not equal" << std::endl;
|
||||
return false;
|
||||
@ -180,8 +180,8 @@ bool AuthenticatedKeyAgreementWithRolesValidate(AuthenticatedKeyAgreementDomain
|
||||
initiator.GenerateEphemeralKeyPair(GlobalRNG(), epriv1, epub1);
|
||||
recipient.GenerateEphemeralKeyPair(GlobalRNG(), epriv2, epub2);
|
||||
|
||||
memset(val1.begin(), 0x10, val1.size());
|
||||
memset(val2.begin(), 0x11, val2.size());
|
||||
std::memset(val1.begin(), 0x10, val1.size());
|
||||
std::memset(val2.begin(), 0x11, val2.size());
|
||||
|
||||
if (initiator.Agree(val1, spriv1, epriv1, spub2, epub2) && recipient.Agree(val2, spriv2, epriv2, spub1, epub1))
|
||||
{
|
||||
@ -193,7 +193,7 @@ bool AuthenticatedKeyAgreementWithRolesValidate(AuthenticatedKeyAgreementDomain
|
||||
return false;
|
||||
}
|
||||
|
||||
if (memcmp(val1.begin(), val2.begin(), initiator.AgreedValueLength()))
|
||||
if (std::memcmp(val1.begin(), val2.begin(), initiator.AgreedValueLength()))
|
||||
{
|
||||
std::cout << "FAILED authenticated agreed values not equal" << std::endl;
|
||||
return false;
|
||||
@ -236,7 +236,7 @@ bool SignatureValidate(PK_Signer &priv, PK_Verifier &pub, bool thorough)
|
||||
signatureLength = priv.SignMessageWithRecovery(GlobalRNG(), message, messageLen, NULLPTR, 0, signature);
|
||||
SecByteBlock recovered(priv.MaxRecoverableLengthFromSignatureLength(signatureLength));
|
||||
DecodingResult result = pub.RecoverMessage(recovered, NULLPTR, 0, signature, signatureLength);
|
||||
fail = !(result.isValidCoding && result.messageLength == messageLen && memcmp(recovered, message, messageLen) == 0);
|
||||
fail = !(result.isValidCoding && result.messageLength == messageLen && std::memcmp(recovered, message, messageLen) == 0);
|
||||
pass = pass && !fail;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ");
|
||||
@ -276,7 +276,7 @@ bool ValidateBBS()
|
||||
std::ostringstream oss;
|
||||
|
||||
bbs.GenerateBlock(buf, 20);
|
||||
fail = memcmp(output1, buf, 20) != 0;
|
||||
fail = std::memcmp(output1, buf, 20) != 0;
|
||||
pass = pass && !fail;
|
||||
|
||||
oss << (fail ? "FAILED " : "passed ");
|
||||
@ -286,7 +286,7 @@ bool ValidateBBS()
|
||||
|
||||
bbs.Seek(10);
|
||||
bbs.GenerateBlock(buf, 10);
|
||||
fail = memcmp(output1+10, buf, 10) != 0;
|
||||
fail = std::memcmp(output1+10, buf, 10) != 0;
|
||||
pass = pass && !fail;
|
||||
|
||||
oss << (fail ? "FAILED " : "passed ");
|
||||
@ -296,7 +296,7 @@ bool ValidateBBS()
|
||||
|
||||
bbs.Seek(1234567);
|
||||
bbs.GenerateBlock(buf, 20);
|
||||
fail = memcmp(output2, buf, 20) != 0;
|
||||
fail = std::memcmp(output2, buf, 20) != 0;
|
||||
pass = pass && !fail;
|
||||
|
||||
oss << (fail ? "FAILED " : "passed ");
|
||||
|
@ -204,11 +204,11 @@ bool ValidateRSA_Encrypt()
|
||||
rsaPriv.AccessKey().BERDecodePrivateKey(privFile, false, 0);
|
||||
RSAES_OAEP_SHA_Encryptor rsaPub(pubFile);
|
||||
|
||||
memset(out, 0, 50);
|
||||
memset(outPlain, 0, 8);
|
||||
std::memset(out, 0, 50);
|
||||
std::memset(outPlain, 0, 8);
|
||||
rsaPub.Encrypt(rng, plain, 8, out);
|
||||
DecodingResult result = rsaPriv.FixedLengthDecrypt(GlobalRNG(), encrypted, outPlain);
|
||||
fail = !result.isValidCoding || (result.messageLength!=8) || memcmp(out, encrypted, 50) || memcmp(plain, outPlain, 8);
|
||||
fail = !result.isValidCoding || (result.messageLength!=8) || std::memcmp(out, encrypted, 50) || std::memcmp(plain, outPlain, 8);
|
||||
pass = pass && !fail;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ");
|
||||
|
@ -73,7 +73,7 @@ bool ValidateRSA_Sign()
|
||||
|
||||
size_t signatureLength = rsaPriv.SignMessage(GlobalRNG(), (byte *)plain, strlen(plain), out);
|
||||
CRYPTOPP_ASSERT(signatureLength <= sizeof(out));
|
||||
fail = memcmp(signature, out, signatureLength) != 0;
|
||||
fail = std::memcmp(signature, out, signatureLength) != 0;
|
||||
pass = pass && !fail;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ");
|
||||
@ -116,7 +116,7 @@ bool ValidateRSA_Sign()
|
||||
|
||||
size_t signatureLength = rsaPriv.SignMessage(GlobalRNG(), (byte *)plain, strlen(plain), out);
|
||||
CRYPTOPP_ASSERT(signatureLength <= sizeof(out));
|
||||
fail = memcmp(signature, out, signatureLength) != 0;
|
||||
fail = std::memcmp(signature, out, signatureLength) != 0;
|
||||
pass = pass && !fail;
|
||||
|
||||
std::cout << (fail ? "FAILED " : "passed ");
|
||||
@ -259,8 +259,8 @@ bool ValidateECDSA()
|
||||
|
||||
// from Sample Test Vectors for P1363
|
||||
GF2NT gf2n(191, 9, 0);
|
||||
byte a[]="\x28\x66\x53\x7B\x67\x67\x52\x63\x6A\x68\xF5\x65\x54\xE1\x26\x40\x27\x6B\x64\x9E\xF7\x52\x62\x67";
|
||||
byte b[]="\x2E\x45\xEF\x57\x1F\x00\x78\x6F\x67\xB0\x08\x1B\x94\x95\xA3\xD9\x54\x62\xF5\xDE\x0A\xA1\x85\xEC";
|
||||
const byte a[]="\x28\x66\x53\x7B\x67\x67\x52\x63\x6A\x68\xF5\x65\x54\xE1\x26\x40\x27\x6B\x64\x9E\xF7\x52\x62\x67";
|
||||
const byte b[]="\x2E\x45\xEF\x57\x1F\x00\x78\x6F\x67\xB0\x08\x1B\x94\x95\xA3\xD9\x54\x62\xF5\xDE\x0A\xA1\x85\xEC";
|
||||
EC2N ec(gf2n, PolynomialMod2(a,24), PolynomialMod2(b,24));
|
||||
|
||||
EC2N::Point P;
|
||||
|
14
vmac.cpp
14
vmac.cpp
@ -133,8 +133,8 @@ void VMAC_Base::Resynchronize(const byte *nonce, int len)
|
||||
|
||||
if (m_is128)
|
||||
{
|
||||
memset(storedNonce, 0, s-length);
|
||||
memcpy(storedNonce+s-length, nonce, length);
|
||||
std::memset(storedNonce, 0, s-length);
|
||||
std::memcpy(storedNonce+s-length, nonce, length);
|
||||
AccessCipher().ProcessBlock(storedNonce, m_pad());
|
||||
}
|
||||
else
|
||||
@ -147,8 +147,8 @@ void VMAC_Base::Resynchronize(const byte *nonce, int len)
|
||||
}
|
||||
if (!m_padCached)
|
||||
{
|
||||
memset(storedNonce, 0, s-length);
|
||||
memcpy(storedNonce+s-length, nonce, length-1);
|
||||
std::memset(storedNonce, 0, s-length);
|
||||
std::memcpy(storedNonce+s-length, nonce, length-1);
|
||||
storedNonce[s-1] = nonce[length-1] & 0xfe;
|
||||
AccessCipher().ProcessBlock(storedNonce, m_pad());
|
||||
m_padCached = true;
|
||||
@ -844,7 +844,7 @@ void VMAC_Base::TruncatedFinal(byte *mac, size_t size)
|
||||
|
||||
if (len)
|
||||
{
|
||||
memset(m_data()+len, 0, (0-len)%16);
|
||||
std::memset(m_data()+len, 0, (0-len)%16);
|
||||
VHASH_Update(DataBuf(), ((len+15)/16)*2);
|
||||
len *= 8; // convert to bits
|
||||
}
|
||||
@ -874,7 +874,7 @@ void VMAC_Base::TruncatedFinal(byte *mac, size_t size)
|
||||
{
|
||||
t[0] = ConditionalByteReverse(BIG_ENDIAN_ORDER, t[0]);
|
||||
t[1] = ConditionalByteReverse(BIG_ENDIAN_ORDER, t[1]);
|
||||
memcpy(mac, t, size);
|
||||
std::memcpy(mac, t, size);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -886,7 +886,7 @@ void VMAC_Base::TruncatedFinal(byte *mac, size_t size)
|
||||
else
|
||||
{
|
||||
t = ConditionalByteReverse(BIG_ENDIAN_ORDER, t);
|
||||
memcpy(mac, &t, size);
|
||||
std::memcpy(mac, &t, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ std::string Whirlpool::AlgorithmProvider() const
|
||||
|
||||
void Whirlpool::InitState(HashWordType *state)
|
||||
{
|
||||
memset(state, 0, 8*sizeof(state[0]));
|
||||
std::memset(state, 0, 8*sizeof(state[0]));
|
||||
}
|
||||
|
||||
void Whirlpool::TruncatedFinal(byte *hash, size_t size)
|
||||
@ -118,7 +118,7 @@ void Whirlpool::TruncatedFinal(byte *hash, size_t size)
|
||||
|
||||
Transform(m_state, m_data);
|
||||
CorrectEndianess(m_state, m_state, DigestSize());
|
||||
memcpy(hash, m_state, size);
|
||||
std::memcpy(hash, m_state, size);
|
||||
|
||||
Restart(); // reinit for next use
|
||||
}
|
||||
|
2
words.h
2
words.h
@ -51,7 +51,7 @@ inline void CopyWords(word *r, const word *a, size_t n)
|
||||
#if CRYPTOPP_MSC_VERSION
|
||||
memcpy_s(r, n*WORD_SIZE, a, n*WORD_SIZE);
|
||||
#else
|
||||
memcpy(r, a, n*WORD_SIZE);
|
||||
std::memcpy(r, a, n*WORD_SIZE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -352,7 +352,7 @@ unsigned int Deflator::FillWindow(const byte *str, size_t length)
|
||||
if (m_blockStart < DSIZE)
|
||||
EndBlock(false);
|
||||
|
||||
memcpy(m_byteBuffer, m_byteBuffer + DSIZE, DSIZE);
|
||||
std::memcpy(m_byteBuffer, m_byteBuffer + DSIZE, DSIZE);
|
||||
|
||||
m_dictionaryEnd = m_dictionaryEnd < DSIZE ? 0 : m_dictionaryEnd-DSIZE;
|
||||
CRYPTOPP_ASSERT(m_stringStart >= DSIZE);
|
||||
@ -377,7 +377,7 @@ unsigned int Deflator::FillWindow(const byte *str, size_t length)
|
||||
CRYPTOPP_ASSERT(maxBlockSize > m_stringStart+m_lookahead);
|
||||
unsigned int accepted = UnsignedMin(maxBlockSize-(m_stringStart+m_lookahead), length);
|
||||
CRYPTOPP_ASSERT(accepted > 0);
|
||||
memcpy(m_byteBuffer + m_stringStart + m_lookahead, str, accepted);
|
||||
std::memcpy(m_byteBuffer + m_stringStart + m_lookahead, str, accepted);
|
||||
m_lookahead += accepted;
|
||||
return accepted;
|
||||
}
|
||||
@ -689,8 +689,8 @@ void Deflator::EncodeBlock(bool eof, unsigned int blockType)
|
||||
unsigned int hdist = (unsigned int)(FindIfNot(RevIt(distanceCodeLengths.end()), RevIt(distanceCodeLengths.begin()+1), 0).base() - (distanceCodeLengths.begin()+1));
|
||||
|
||||
SecBlockWithHint<unsigned int, 286+30> combinedLengths(hlit+257+hdist+1);
|
||||
memcpy(combinedLengths, literalCodeLengths, (hlit+257)*sizeof(unsigned int));
|
||||
memcpy(combinedLengths+hlit+257, distanceCodeLengths, (hdist+1)*sizeof(unsigned int));
|
||||
std::memcpy(combinedLengths, literalCodeLengths, (hlit+257)*sizeof(unsigned int));
|
||||
std::memcpy(combinedLengths+hlit+257, distanceCodeLengths, (hdist+1)*sizeof(unsigned int));
|
||||
|
||||
FixedSizeSecBlock<unsigned int, 19> codeLengthCodeCounts, codeLengthCodeLengths;
|
||||
std::fill(codeLengthCodeCounts.begin(), codeLengthCodeCounts.end(), 0);
|
||||
|
@ -255,7 +255,7 @@ void Inflator::OutputString(const byte *string, size_t length)
|
||||
while (length)
|
||||
{
|
||||
size_t len = UnsignedMin(length, m_window.size() - m_current);
|
||||
memcpy(m_window + m_current, string, len);
|
||||
std::memcpy(m_window + m_current, string, len);
|
||||
m_current += len;
|
||||
if (m_current == m_window.size())
|
||||
{
|
||||
@ -293,7 +293,7 @@ void Inflator::OutputPast(unsigned int length, unsigned int distance)
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(m_window + m_current, m_window + start, length);
|
||||
std::memcpy(m_window + m_current, m_window + start, length);
|
||||
m_current += length;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user