mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2024-11-23 09:59:42 +00:00
Whitespace check-in
This commit is contained in:
parent
180b39facc
commit
3063c6e1d9
33
misc.h
33
misc.h
@ -1213,11 +1213,13 @@ inline void ConditionalSwapPointers(bool c, T &a, T &b)
|
|||||||
/// \tparam T class or type
|
/// \tparam T class or type
|
||||||
/// \param buf an array of elements
|
/// \param buf an array of elements
|
||||||
/// \param n the number of elements in the array
|
/// \param n the number of elements in the array
|
||||||
/// \details The operation performs a wipe or zeroization. The function attempts to survive optimizations and dead code removal
|
/// \details The operation performs a wipe or zeroization. The function
|
||||||
|
/// attempts to survive optimizations and dead code removal.
|
||||||
template <class T>
|
template <class T>
|
||||||
void SecureWipeBuffer(T *buf, size_t n)
|
void SecureWipeBuffer(T *buf, size_t n)
|
||||||
{
|
{
|
||||||
// GCC 4.3.2 on Cygwin optimizes away the first store if this loop is done in the forward direction
|
// GCC 4.3.2 on Cygwin optimizes away the first store if this
|
||||||
|
// loop is done in the forward direction
|
||||||
volatile T *p = buf+n;
|
volatile T *p = buf+n;
|
||||||
while (n--)
|
while (n--)
|
||||||
*(--p) = 0;
|
*(--p) = 0;
|
||||||
@ -1230,7 +1232,8 @@ void SecureWipeBuffer(T *buf, size_t n)
|
|||||||
/// \brief Sets each byte of an array to 0
|
/// \brief Sets each byte of an array to 0
|
||||||
/// \param buf an array of bytes
|
/// \param buf an array of bytes
|
||||||
/// \param n the number of elements in the array
|
/// \param n the number of elements in the array
|
||||||
/// \details The operation performs a wipe or zeroization. The function attempts to survive optimizations and dead code removal.
|
/// \details The operation performs a wipe or zeroization. The function
|
||||||
|
/// attempts to survive optimizations and dead code removal.
|
||||||
template<> inline void SecureWipeBuffer(byte *buf, size_t n)
|
template<> inline void SecureWipeBuffer(byte *buf, size_t n)
|
||||||
{
|
{
|
||||||
volatile byte *p = buf;
|
volatile byte *p = buf;
|
||||||
@ -1244,7 +1247,8 @@ template<> inline void SecureWipeBuffer(byte *buf, size_t n)
|
|||||||
/// \brief Sets each 16-bit element of an array to 0
|
/// \brief Sets each 16-bit element of an array to 0
|
||||||
/// \param buf an array of 16-bit words
|
/// \param buf an array of 16-bit words
|
||||||
/// \param n the number of elements in the array
|
/// \param n the number of elements in the array
|
||||||
/// \details The operation performs a wipe or zeroization. The function attempts to survive optimizations and dead code removal.
|
/// \details The operation performs a wipe or zeroization. The function
|
||||||
|
/// attempts to survive optimizations and dead code removal.
|
||||||
template<> inline void SecureWipeBuffer(word16 *buf, size_t n)
|
template<> inline void SecureWipeBuffer(word16 *buf, size_t n)
|
||||||
{
|
{
|
||||||
volatile word16 *p = buf;
|
volatile word16 *p = buf;
|
||||||
@ -1258,7 +1262,8 @@ template<> inline void SecureWipeBuffer(word16 *buf, size_t n)
|
|||||||
/// \brief Sets each 32-bit element of an array to 0
|
/// \brief Sets each 32-bit element of an array to 0
|
||||||
/// \param buf an array of 32-bit words
|
/// \param buf an array of 32-bit words
|
||||||
/// \param n the number of elements in the array
|
/// \param n the number of elements in the array
|
||||||
/// \details The operation performs a wipe or zeroization. The function attempts to survive optimizations and dead code removal.
|
/// \details The operation performs a wipe or zeroization. The function
|
||||||
|
/// attempts to survive optimizations and dead code removal.
|
||||||
template<> inline void SecureWipeBuffer(word32 *buf, size_t n)
|
template<> inline void SecureWipeBuffer(word32 *buf, size_t n)
|
||||||
{
|
{
|
||||||
volatile word32 *p = buf;
|
volatile word32 *p = buf;
|
||||||
@ -1272,24 +1277,25 @@ template<> inline void SecureWipeBuffer(word32 *buf, size_t n)
|
|||||||
/// \brief Sets each 64-bit element of an array to 0
|
/// \brief Sets each 64-bit element of an array to 0
|
||||||
/// \param buf an array of 64-bit words
|
/// \param buf an array of 64-bit words
|
||||||
/// \param n the number of elements in the array
|
/// \param n the number of elements in the array
|
||||||
/// \details The operation performs a wipe or zeroization. The function attempts to survive optimizations and dead code removal.
|
/// \details The operation performs a wipe or zeroization. The function
|
||||||
|
/// attempts to survive optimizations and dead code removal.
|
||||||
template<> inline void SecureWipeBuffer(word64 *buf, size_t n)
|
template<> inline void SecureWipeBuffer(word64 *buf, size_t n)
|
||||||
{
|
{
|
||||||
#if CRYPTOPP_BOOL_X64
|
#if CRYPTOPP_BOOL_X64
|
||||||
volatile word64 *p = buf;
|
volatile word64 *p = buf;
|
||||||
#ifdef __GNUC__
|
# ifdef __GNUC__
|
||||||
asm volatile("rep stosq" : "+c"(n), "+D"(p) : "a"(0) : "memory");
|
asm volatile("rep stosq" : "+c"(n), "+D"(p) : "a"(0) : "memory");
|
||||||
#else
|
# else
|
||||||
__stosq(reinterpret_cast<word64 *>(reinterpret_cast<size_t>(p)), 0, n);
|
__stosq(reinterpret_cast<word64 *>(reinterpret_cast<size_t>(p)), 0, n);
|
||||||
#endif
|
# endif
|
||||||
#else
|
#else
|
||||||
SecureWipeBuffer(reinterpret_cast<word32 *>(buf), 2*n);
|
SecureWipeBuffer(reinterpret_cast<word32 *>(buf), 2*n);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #if (_MSC_VER >= 1400 || defined(__GNUC__)) && (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86)
|
#endif // CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86
|
||||||
|
|
||||||
#if (_MSC_VER >= 1700) && defined(_M_ARM)
|
#if !defined(CRYPTOPP_DISABLE_ASM) && (_MSC_VER >= 1700) && defined(_M_ARM)
|
||||||
template<> inline void SecureWipeBuffer(byte *buf, size_t n)
|
template<> inline void SecureWipeBuffer(byte *buf, size_t n)
|
||||||
{
|
{
|
||||||
char *p = reinterpret_cast<char*>(buf+n);
|
char *p = reinterpret_cast<char*>(buf+n);
|
||||||
@ -1323,7 +1329,8 @@ template<> inline void SecureWipeBuffer(word64 *buf, size_t n)
|
|||||||
/// \tparam T class or type
|
/// \tparam T class or type
|
||||||
/// \param buf an array of elements
|
/// \param buf an array of elements
|
||||||
/// \param n the number of elements in the array
|
/// \param n the number of elements in the array
|
||||||
/// \details The operation performs a wipe or zeroization. The function attempts to survive optimizations and dead code removal.
|
/// \details The operation performs a wipe or zeroization. The function
|
||||||
|
/// attempts to survive optimizations and dead code removal.
|
||||||
template <class T>
|
template <class T>
|
||||||
inline void SecureWipeArray(T *buf, size_t n)
|
inline void SecureWipeArray(T *buf, size_t n)
|
||||||
{
|
{
|
||||||
@ -1868,7 +1875,7 @@ template<> inline word32 rotrMod<word32>(word32 x, unsigned int y)
|
|||||||
return (__rlwnm(x,32-y,0,31));
|
return (__rlwnm(x,32-y,0,31));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #if (defined(__MWERKS__) && TARGET_CPU_PPC)
|
#endif // __MWERKS__ && TARGET_CPU_PPC
|
||||||
|
|
||||||
// ************** endian reversal ***************
|
// ************** endian reversal ***************
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user