mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2024-11-26 19:30:21 +00:00
Cleared -Wcast-align (Issue 122)
This commit is contained in:
parent
9a5dde9013
commit
bf3b80f25c
10
randpool.cpp
10
randpool.cpp
@ -39,18 +39,18 @@ void RandomPool::GenerateIntoBufferedTransformation(BufferedTransformation &targ
|
||||
if (!m_keySet)
|
||||
m_pCipher->SetKey(m_key, 32);
|
||||
|
||||
CRYPTOPP_COMPILE_ASSERT(sizeof(TimerWord) <= 16);
|
||||
CRYPTOPP_COMPILE_ASSERT(sizeof(time_t) <= 8);
|
||||
|
||||
Timer timer;
|
||||
TimerWord tw = timer.GetCurrentTimerValue();
|
||||
CRYPTOPP_COMPILE_ASSERT(sizeof(tw) <= 16);
|
||||
*(TimerWord *)m_seed.data() += tw;
|
||||
|
||||
*(TimerWord *)(void*)m_seed.data() += tw;
|
||||
time_t t = time(NULL);
|
||||
CRYPTOPP_COMPILE_ASSERT(sizeof(t) <= 8);
|
||||
|
||||
// UBsan finding: signed integer overflow: 1876017710 + 1446085457 cannot be represented in type 'long int'
|
||||
// *(time_t *)(m_seed.data()+8) += t;
|
||||
assert(m_seed.size() >= 16);
|
||||
word64 tt1, tt2 = (word64)t;
|
||||
word64 tt1 = 0, tt2 = (word64)t;
|
||||
memcpy(&tt1, m_seed.data()+8, 8);
|
||||
memcpy(m_seed.data()+8, &(tt2 += tt1), 8);
|
||||
|
||||
|
19
randpool.h
19
randpool.h
@ -1,3 +1,8 @@
|
||||
// randpool.h - written and placed in the public domain by Wei Dai
|
||||
|
||||
//! \file randpool.h
|
||||
//! \brief Class file for Randomness Pool
|
||||
|
||||
#ifndef CRYPTOPP_RANDPOOL_H
|
||||
#define CRYPTOPP_RANDPOOL_H
|
||||
|
||||
@ -9,12 +14,18 @@
|
||||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
//! Randomness Pool
|
||||
/*! This class can be used to generate cryptographic quality
|
||||
pseudorandom bytes after seeding the pool with IncorporateEntropy() */
|
||||
//! \brief Randomness Pool
|
||||
//! \details RandomPool can be used to generate cryptographic quality pseudorandom bytes
|
||||
//! after seeding the pool with IncorporateEntropy(). Internally, the generator uses
|
||||
//! AES-256 to produce the stream. Entropy is stirred in using SHA-256.
|
||||
//! \details RandomPool used to follow the design of randpool in PGP 2.6.x,
|
||||
//! but as of version 5.5 it has been redesigned to reduce the risk
|
||||
//! of reusing random numbers after state rollback (which may occur
|
||||
//! when running in a virtual machine like VMware).
|
||||
class CRYPTOPP_DLL RandomPool : public RandomNumberGenerator, public NotCopyable
|
||||
{
|
||||
public:
|
||||
//! \brief Construct a RandomPool
|
||||
RandomPool();
|
||||
|
||||
bool CanIncorporateEntropy() const {return true;}
|
||||
@ -25,8 +36,8 @@ public:
|
||||
void Put(const byte *input, size_t length) {IncorporateEntropy(input, length);}
|
||||
|
||||
private:
|
||||
FixedSizeAlignedSecBlock<byte, 16, true> m_seed;
|
||||
FixedSizeAlignedSecBlock<byte, 32> m_key;
|
||||
FixedSizeAlignedSecBlock<byte, 16> m_seed;
|
||||
member_ptr<BlockCipher> m_pCipher;
|
||||
bool m_keySet;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user