Cleared -Wcast-align (Issue 122)
parent
be8ad11098
commit
1f1fecce88
16
misc.cpp
16
misc.cpp
|
|
@ -10,10 +10,6 @@
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
|
|
||||||
# pragma GCC diagnostic ignored "-Wcast-align"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CRYPTOPP_IMPORTS
|
#ifndef CRYPTOPP_IMPORTS
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
@ -41,7 +37,7 @@ void xorbuf(byte *buf, const byte *mask, size_t count)
|
||||||
if (!CRYPTOPP_BOOL_SLOW_WORD64 && IsAligned<word64>(buf) && IsAligned<word64>(mask))
|
if (!CRYPTOPP_BOOL_SLOW_WORD64 && IsAligned<word64>(buf) && IsAligned<word64>(mask))
|
||||||
{
|
{
|
||||||
for (i=0; i<count/8; i++)
|
for (i=0; i<count/8; i++)
|
||||||
((word64*)buf)[i] ^= ((word64*)mask)[i];
|
((word64*)(void*)buf)[i] ^= ((word64*)(void*)mask)[i];
|
||||||
count -= 8*i;
|
count -= 8*i;
|
||||||
if (!count)
|
if (!count)
|
||||||
return;
|
return;
|
||||||
|
|
@ -50,7 +46,7 @@ void xorbuf(byte *buf, const byte *mask, size_t count)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<count/4; i++)
|
for (i=0; i<count/4; i++)
|
||||||
((word32*)buf)[i] ^= ((word32*)mask)[i];
|
((word32*)(void*)buf)[i] ^= ((word32*)(void*)mask)[i];
|
||||||
count -= 4*i;
|
count -= 4*i;
|
||||||
if (!count)
|
if (!count)
|
||||||
return;
|
return;
|
||||||
|
|
@ -74,7 +70,7 @@ void xorbuf(byte *output, const byte *input, const byte *mask, size_t count)
|
||||||
if (!CRYPTOPP_BOOL_SLOW_WORD64 && IsAligned<word64>(output) && IsAligned<word64>(input) && IsAligned<word64>(mask))
|
if (!CRYPTOPP_BOOL_SLOW_WORD64 && IsAligned<word64>(output) && IsAligned<word64>(input) && IsAligned<word64>(mask))
|
||||||
{
|
{
|
||||||
for (i=0; i<count/8; i++)
|
for (i=0; i<count/8; i++)
|
||||||
((word64*)output)[i] = ((word64*)input)[i] ^ ((word64*)mask)[i];
|
((word64*)(void*)output)[i] = ((word64*)(void*)input)[i] ^ ((word64*)(void*)mask)[i];
|
||||||
count -= 8*i;
|
count -= 8*i;
|
||||||
if (!count)
|
if (!count)
|
||||||
return;
|
return;
|
||||||
|
|
@ -84,7 +80,7 @@ void xorbuf(byte *output, const byte *input, const byte *mask, size_t count)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<count/4; i++)
|
for (i=0; i<count/4; i++)
|
||||||
((word32*)output)[i] = ((word32*)input)[i] ^ ((word32*)mask)[i];
|
((word32*)(void*)output)[i] = ((word32*)(void*)input)[i] ^ ((word32*)(void*)mask)[i];
|
||||||
count -= 4*i;
|
count -= 4*i;
|
||||||
if (!count)
|
if (!count)
|
||||||
return;
|
return;
|
||||||
|
|
@ -113,7 +109,7 @@ bool VerifyBufsEqual(const byte *buf, const byte *mask, size_t count)
|
||||||
{
|
{
|
||||||
word64 acc64 = 0;
|
word64 acc64 = 0;
|
||||||
for (i=0; i<count/8; i++)
|
for (i=0; i<count/8; i++)
|
||||||
acc64 |= ((word64*)buf)[i] ^ ((word64*)mask)[i];
|
acc64 |= ((word64*)(void*)buf)[i] ^ ((word64*)(void*)mask)[i];
|
||||||
count -= 8*i;
|
count -= 8*i;
|
||||||
if (!count)
|
if (!count)
|
||||||
return acc64 == 0;
|
return acc64 == 0;
|
||||||
|
|
@ -123,7 +119,7 @@ bool VerifyBufsEqual(const byte *buf, const byte *mask, size_t count)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<count/4; i++)
|
for (i=0; i<count/4; i++)
|
||||||
acc32 |= ((word32*)buf)[i] ^ ((word32*)mask)[i];
|
acc32 |= ((word32*)(void*)buf)[i] ^ ((word32*)(void*)mask)[i];
|
||||||
count -= 4*i;
|
count -= 4*i;
|
||||||
if (!count)
|
if (!count)
|
||||||
return acc32 == 0;
|
return acc32 == 0;
|
||||||
|
|
|
||||||
33
misc.h
33
misc.h
|
|
@ -1047,23 +1047,14 @@ template<> inline void SecureWipeBuffer(word64 *buf, size_t n)
|
||||||
template <class T>
|
template <class T>
|
||||||
inline void SecureWipeArray(T *buf, size_t n)
|
inline void SecureWipeArray(T *buf, size_t n)
|
||||||
{
|
{
|
||||||
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
|
|
||||||
# pragma GCC diagnostic push
|
|
||||||
# pragma GCC diagnostic ignored "-Wcast-align"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (sizeof(T) % 8 == 0 && GetAlignmentOf<T>() % GetAlignmentOf<word64>() == 0)
|
if (sizeof(T) % 8 == 0 && GetAlignmentOf<T>() % GetAlignmentOf<word64>() == 0)
|
||||||
SecureWipeBuffer((word64 *)buf, n * (sizeof(T)/8));
|
SecureWipeBuffer((word64 *)(void *)buf, n * (sizeof(T)/8));
|
||||||
else if (sizeof(T) % 4 == 0 && GetAlignmentOf<T>() % GetAlignmentOf<word32>() == 0)
|
else if (sizeof(T) % 4 == 0 && GetAlignmentOf<T>() % GetAlignmentOf<word32>() == 0)
|
||||||
SecureWipeBuffer((word32 *)buf, n * (sizeof(T)/4));
|
SecureWipeBuffer((word32 *)(void *)buf, n * (sizeof(T)/4));
|
||||||
else if (sizeof(T) % 2 == 0 && GetAlignmentOf<T>() % GetAlignmentOf<word16>() == 0)
|
else if (sizeof(T) % 2 == 0 && GetAlignmentOf<T>() % GetAlignmentOf<word16>() == 0)
|
||||||
SecureWipeBuffer((word16 *)buf, n * (sizeof(T)/2));
|
SecureWipeBuffer((word16 *)(void *)buf, n * (sizeof(T)/2));
|
||||||
else
|
else
|
||||||
SecureWipeBuffer((byte *)buf, n * sizeof(T));
|
SecureWipeBuffer((byte *)(void *)buf, n * sizeof(T));
|
||||||
|
|
||||||
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
|
|
||||||
# pragma GCC diagnostic pop
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Converts a wide character C-string to a multibyte string
|
//! \brief Converts a wide character C-string to a multibyte string
|
||||||
|
|
@ -2105,14 +2096,14 @@ inline T SafeLeftShift(T value)
|
||||||
|
|
||||||
// ************** use one buffer for multiple data members ***************
|
// ************** use one buffer for multiple data members ***************
|
||||||
|
|
||||||
#define CRYPTOPP_BLOCK_1(n, t, s) t* m_##n() {return (t *)(m_aggregate+0);} size_t SS1() {return sizeof(t)*(s);} size_t m_##n##Size() {return (s);}
|
#define CRYPTOPP_BLOCK_1(n, t, s) t* m_##n() {return (t *)(void *)(m_aggregate+0);} size_t SS1() {return sizeof(t)*(s);} size_t m_##n##Size() {return (s);}
|
||||||
#define CRYPTOPP_BLOCK_2(n, t, s) t* m_##n() {return (t *)(m_aggregate+SS1());} size_t SS2() {return SS1()+sizeof(t)*(s);} size_t m_##n##Size() {return (s);}
|
#define CRYPTOPP_BLOCK_2(n, t, s) t* m_##n() {return (t *)(void *)(m_aggregate+SS1());} size_t SS2() {return SS1()+sizeof(t)*(s);} size_t m_##n##Size() {return (s);}
|
||||||
#define CRYPTOPP_BLOCK_3(n, t, s) t* m_##n() {return (t *)(m_aggregate+SS2());} size_t SS3() {return SS2()+sizeof(t)*(s);} size_t m_##n##Size() {return (s);}
|
#define CRYPTOPP_BLOCK_3(n, t, s) t* m_##n() {return (t *)(void *)(m_aggregate+SS2());} size_t SS3() {return SS2()+sizeof(t)*(s);} size_t m_##n##Size() {return (s);}
|
||||||
#define CRYPTOPP_BLOCK_4(n, t, s) t* m_##n() {return (t *)(m_aggregate+SS3());} size_t SS4() {return SS3()+sizeof(t)*(s);} size_t m_##n##Size() {return (s);}
|
#define CRYPTOPP_BLOCK_4(n, t, s) t* m_##n() {return (t *)(void *)(m_aggregate+SS3());} size_t SS4() {return SS3()+sizeof(t)*(s);} size_t m_##n##Size() {return (s);}
|
||||||
#define CRYPTOPP_BLOCK_5(n, t, s) t* m_##n() {return (t *)(m_aggregate+SS4());} size_t SS5() {return SS4()+sizeof(t)*(s);} size_t m_##n##Size() {return (s);}
|
#define CRYPTOPP_BLOCK_5(n, t, s) t* m_##n() {return (t *)(void *)(m_aggregate+SS4());} size_t SS5() {return SS4()+sizeof(t)*(s);} size_t m_##n##Size() {return (s);}
|
||||||
#define CRYPTOPP_BLOCK_6(n, t, s) t* m_##n() {return (t *)(m_aggregate+SS5());} size_t SS6() {return SS5()+sizeof(t)*(s);} size_t m_##n##Size() {return (s);}
|
#define CRYPTOPP_BLOCK_6(n, t, s) t* m_##n() {return (t *)(void *)(m_aggregate+SS5());} size_t SS6() {return SS5()+sizeof(t)*(s);} size_t m_##n##Size() {return (s);}
|
||||||
#define CRYPTOPP_BLOCK_7(n, t, s) t* m_##n() {return (t *)(m_aggregate+SS6());} size_t SS7() {return SS6()+sizeof(t)*(s);} size_t m_##n##Size() {return (s);}
|
#define CRYPTOPP_BLOCK_7(n, t, s) t* m_##n() {return (t *)(void *)(m_aggregate+SS6());} size_t SS7() {return SS6()+sizeof(t)*(s);} size_t m_##n##Size() {return (s);}
|
||||||
#define CRYPTOPP_BLOCK_8(n, t, s) t* m_##n() {return (t *)(m_aggregate+SS7());} size_t SS8() {return SS7()+sizeof(t)*(s);} size_t m_##n##Size() {return (s);}
|
#define CRYPTOPP_BLOCK_8(n, t, s) t* m_##n() {return (t *)(void *)(m_aggregate+SS7());} size_t SS8() {return SS7()+sizeof(t)*(s);} size_t m_##n##Size() {return (s);}
|
||||||
#define CRYPTOPP_BLOCKS_END(i) size_t SST() {return SS##i();} void AllocateBlocks() {m_aggregate.New(SST());} AlignedSecByteBlock m_aggregate;
|
#define CRYPTOPP_BLOCKS_END(i) size_t SST() {return SS##i();} void AllocateBlocks() {m_aggregate.New(SST());} AlignedSecByteBlock m_aggregate;
|
||||||
|
|
||||||
NAMESPACE_END
|
NAMESPACE_END
|
||||||
|
|
|
||||||
11
secblock.h
11
secblock.h
|
|
@ -409,23 +409,14 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
|
|
||||||
# pragma GCC diagnostic push
|
|
||||||
# pragma GCC diagnostic ignored "-Wcast-align"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
T* GetAlignedArray() {return m_array;}
|
T* GetAlignedArray() {return m_array;}
|
||||||
T m_array[S];
|
T m_array[S];
|
||||||
#else
|
#else
|
||||||
T* GetAlignedArray() {return (CRYPTOPP_BOOL_ALIGN16 && T_Align16) ? (T*)(((byte *)m_array) + (0-(size_t)m_array)%16) : m_array;}
|
T* GetAlignedArray() {return (CRYPTOPP_BOOL_ALIGN16 && T_Align16) ? (T*)(void *)(((byte *)m_array) + (0-(size_t)m_array)%16) : m_array;}
|
||||||
CRYPTOPP_ALIGN_DATA(8) T m_array[(CRYPTOPP_BOOL_ALIGN16 && T_Align16) ? S+8/sizeof(T) : S];
|
CRYPTOPP_ALIGN_DATA(8) T m_array[(CRYPTOPP_BOOL_ALIGN16 && T_Align16) ? S+8/sizeof(T) : S];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
|
|
||||||
# pragma GCC diagnostic pop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
A m_fallbackAllocator;
|
A m_fallbackAllocator;
|
||||||
bool m_allocated;
|
bool m_allocated;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue