mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 03:34:39 +02:00
fix -Wcast-align
This commit is contained in:
@@ -161,7 +161,7 @@ void Md4Update(Md4* md4, const byte* data, word32 len)
|
|||||||
|
|
||||||
if (md4->buffLen == MD4_BLOCK_SIZE) {
|
if (md4->buffLen == MD4_BLOCK_SIZE) {
|
||||||
#ifdef BIG_ENDIAN_ORDER
|
#ifdef BIG_ENDIAN_ORDER
|
||||||
ByteReverseBytes(local, local, MD4_BLOCK_SIZE);
|
ByteReverseWords(md4->buffer, md4->buffer, MD4_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
Transform(md4);
|
Transform(md4);
|
||||||
AddLength(md4, MD4_BLOCK_SIZE);
|
AddLength(md4, MD4_BLOCK_SIZE);
|
||||||
@@ -185,7 +185,7 @@ void Md4Final(Md4* md4, byte* hash)
|
|||||||
md4->buffLen += MD4_BLOCK_SIZE - md4->buffLen;
|
md4->buffLen += MD4_BLOCK_SIZE - md4->buffLen;
|
||||||
|
|
||||||
#ifdef BIG_ENDIAN_ORDER
|
#ifdef BIG_ENDIAN_ORDER
|
||||||
ByteReverseBytes(local, local, MD4_BLOCK_SIZE);
|
ByteReverseWords(md4->buffer, md4->buffer, MD4_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
Transform(md4);
|
Transform(md4);
|
||||||
md4->buffLen = 0;
|
md4->buffLen = 0;
|
||||||
@@ -199,7 +199,7 @@ void Md4Final(Md4* md4, byte* hash)
|
|||||||
|
|
||||||
/* store lengths */
|
/* store lengths */
|
||||||
#ifdef BIG_ENDIAN_ORDER
|
#ifdef BIG_ENDIAN_ORDER
|
||||||
ByteReverseBytes(local, local, MD4_BLOCK_SIZE);
|
ByteReverseWords(md4->buffer, md4->buffer, MD4_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
/* ! length ordering dependent on digest endian type ! */
|
/* ! length ordering dependent on digest endian type ! */
|
||||||
XMEMCPY(&local[MD4_PAD_SIZE], &md4->loLen, sizeof(word32));
|
XMEMCPY(&local[MD4_PAD_SIZE], &md4->loLen, sizeof(word32));
|
||||||
|
@@ -300,7 +300,7 @@ void Md5Update(Md5* md5, const byte* data, word32 len)
|
|||||||
|
|
||||||
if (md5->buffLen == MD5_BLOCK_SIZE) {
|
if (md5->buffLen == MD5_BLOCK_SIZE) {
|
||||||
#if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
#if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||||
ByteReverseBytes(local, local, MD5_BLOCK_SIZE);
|
ByteReverseWords(md5->buffer, md5->buffer, MD5_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
XTRANSFORM(md5, local);
|
XTRANSFORM(md5, local);
|
||||||
AddLength(md5, MD5_BLOCK_SIZE);
|
AddLength(md5, MD5_BLOCK_SIZE);
|
||||||
@@ -324,7 +324,7 @@ void Md5Final(Md5* md5, byte* hash)
|
|||||||
md5->buffLen += MD5_BLOCK_SIZE - md5->buffLen;
|
md5->buffLen += MD5_BLOCK_SIZE - md5->buffLen;
|
||||||
|
|
||||||
#if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
#if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||||
ByteReverseBytes(local, local, MD5_BLOCK_SIZE);
|
ByteReverseWords(md5->buffer, md5->buffer, MD5_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
XTRANSFORM(md5, local);
|
XTRANSFORM(md5, local);
|
||||||
md5->buffLen = 0;
|
md5->buffLen = 0;
|
||||||
@@ -338,7 +338,7 @@ void Md5Final(Md5* md5, byte* hash)
|
|||||||
|
|
||||||
/* store lengths */
|
/* store lengths */
|
||||||
#if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
#if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||||
ByteReverseBytes(local, local, MD5_BLOCK_SIZE);
|
ByteReverseWords(md5->buffer, md5->buffer, MD5_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
/* ! length ordering dependent on digest endian type ! */
|
/* ! length ordering dependent on digest endian type ! */
|
||||||
XMEMCPY(&local[MD5_PAD_SIZE], &md5->loLen, sizeof(word32));
|
XMEMCPY(&local[MD5_PAD_SIZE], &md5->loLen, sizeof(word32));
|
||||||
|
@@ -146,15 +146,6 @@ STATIC INLINE void ByteReverseWords64(word64* out, const word64* in,
|
|||||||
#endif /* WORD64_AVAILABLE */
|
#endif /* WORD64_AVAILABLE */
|
||||||
|
|
||||||
|
|
||||||
STATIC INLINE void ByteReverseBytes(byte* out, const byte* in, word32 byteCount)
|
|
||||||
{
|
|
||||||
word32* op = (word32*)out;
|
|
||||||
const word32* ip = (const word32*)in;
|
|
||||||
|
|
||||||
ByteReverseWords(op, ip, byteCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
STATIC INLINE void XorWords(word* r, const word* a, word32 n)
|
STATIC INLINE void XorWords(word* r, const word* a, word32 n)
|
||||||
{
|
{
|
||||||
word32 i;
|
word32 i;
|
||||||
@@ -163,13 +154,16 @@ STATIC INLINE void XorWords(word* r, const word* a, word32 n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STATIC INLINE void xorbuf(byte* buf, const byte* mask, word32 count)
|
STATIC INLINE void xorbuf(void* buf, const void* mask, word32 count)
|
||||||
{
|
{
|
||||||
if (((word)buf | (word)mask | count) % CYASSL_WORD_SIZE == 0)
|
if (((word)buf | (word)mask | count) % CYASSL_WORD_SIZE == 0)
|
||||||
XorWords( (word*)buf, (const word*)mask, count / CYASSL_WORD_SIZE);
|
XorWords( (word*)buf, (const word*)mask, count / CYASSL_WORD_SIZE);
|
||||||
else {
|
else {
|
||||||
word32 i;
|
word32 i;
|
||||||
for (i = 0; i < count; i++) buf[i] ^= mask[i];
|
byte* b = (byte*)buf;
|
||||||
|
const byte* m = (const byte*)mask;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++) b[i] ^= m[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#undef STATIC
|
#undef STATIC
|
||||||
|
@@ -295,7 +295,8 @@ void RipeMdUpdate(RipeMd* ripemd, const byte* data, word32 len)
|
|||||||
|
|
||||||
if (ripemd->buffLen == RIPEMD_BLOCK_SIZE) {
|
if (ripemd->buffLen == RIPEMD_BLOCK_SIZE) {
|
||||||
#ifdef BIG_ENDIAN_ORDER
|
#ifdef BIG_ENDIAN_ORDER
|
||||||
ByteReverseBytes(local, local, RIPEMD_BLOCK_SIZE);
|
ByteReverseWords(ripemd->buffer, ripemd->buffer,
|
||||||
|
RIPEMD_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
Transform(ripemd);
|
Transform(ripemd);
|
||||||
AddLength(ripemd, RIPEMD_BLOCK_SIZE);
|
AddLength(ripemd, RIPEMD_BLOCK_SIZE);
|
||||||
@@ -319,7 +320,7 @@ void RipeMdFinal(RipeMd* ripemd, byte* hash)
|
|||||||
ripemd->buffLen += RIPEMD_BLOCK_SIZE - ripemd->buffLen;
|
ripemd->buffLen += RIPEMD_BLOCK_SIZE - ripemd->buffLen;
|
||||||
|
|
||||||
#ifdef BIG_ENDIAN_ORDER
|
#ifdef BIG_ENDIAN_ORDER
|
||||||
ByteReverseBytes(local, local, RIPEMD_BLOCK_SIZE);
|
ByteReverseWords(ripemd->buffer, ripemd->buffer, RIPEMD_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
Transform(ripemd);
|
Transform(ripemd);
|
||||||
ripemd->buffLen = 0;
|
ripemd->buffLen = 0;
|
||||||
@@ -333,7 +334,7 @@ void RipeMdFinal(RipeMd* ripemd, byte* hash)
|
|||||||
|
|
||||||
/* store lengths */
|
/* store lengths */
|
||||||
#ifdef BIG_ENDIAN_ORDER
|
#ifdef BIG_ENDIAN_ORDER
|
||||||
ByteReverseBytes(local, local, RIPEMD_BLOCK_SIZE);
|
ByteReverseWords(ripemd->buffer, ripemd->buffer, RIPEMD_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
/* ! length ordering dependent on digest endian type ! */
|
/* ! length ordering dependent on digest endian type ! */
|
||||||
XMEMCPY(&local[RIPEMD_PAD_SIZE], &ripemd->loLen, sizeof(word32));
|
XMEMCPY(&local[RIPEMD_PAD_SIZE], &ripemd->loLen, sizeof(word32));
|
||||||
|
@@ -311,7 +311,7 @@ void ShaUpdate(Sha* sha, const byte* data, word32 len)
|
|||||||
|
|
||||||
if (sha->buffLen == SHA_BLOCK_SIZE) {
|
if (sha->buffLen == SHA_BLOCK_SIZE) {
|
||||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||||
ByteReverseBytes(local, local, SHA_BLOCK_SIZE);
|
ByteReverseWords(sha->buffer, sha->buffer, SHA_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
XTRANSFORM(sha, local);
|
XTRANSFORM(sha, local);
|
||||||
AddLength(sha, SHA_BLOCK_SIZE);
|
AddLength(sha, SHA_BLOCK_SIZE);
|
||||||
@@ -335,7 +335,7 @@ void ShaFinal(Sha* sha, byte* hash)
|
|||||||
sha->buffLen += SHA_BLOCK_SIZE - sha->buffLen;
|
sha->buffLen += SHA_BLOCK_SIZE - sha->buffLen;
|
||||||
|
|
||||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||||
ByteReverseBytes(local, local, SHA_BLOCK_SIZE);
|
ByteReverseWords(sha->buffer, sha->buffer, SHA_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
XTRANSFORM(sha, local);
|
XTRANSFORM(sha, local);
|
||||||
sha->buffLen = 0;
|
sha->buffLen = 0;
|
||||||
@@ -349,7 +349,7 @@ void ShaFinal(Sha* sha, byte* hash)
|
|||||||
|
|
||||||
/* store lengths */
|
/* store lengths */
|
||||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||||
ByteReverseBytes(local, local, SHA_BLOCK_SIZE);
|
ByteReverseWords(sha->buffer, sha->buffer, SHA_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
/* ! length ordering dependent on digest endian type ! */
|
/* ! length ordering dependent on digest endian type ! */
|
||||||
XMEMCPY(&local[SHA_PAD_SIZE], &sha->hiLen, sizeof(word32));
|
XMEMCPY(&local[SHA_PAD_SIZE], &sha->hiLen, sizeof(word32));
|
||||||
@@ -357,8 +357,9 @@ void ShaFinal(Sha* sha, byte* hash)
|
|||||||
|
|
||||||
#ifdef FREESCALE_MMCAU
|
#ifdef FREESCALE_MMCAU
|
||||||
/* Kinetis requires only these bytes reversed */
|
/* Kinetis requires only these bytes reversed */
|
||||||
ByteReverseBytes(&local[SHA_PAD_SIZE], &local[SHA_PAD_SIZE],
|
ByteReverseWords(&sha->buffer[SHA_PAD_SIZE/sizeof(word32)],
|
||||||
2 * sizeof(word32));
|
&sha->buffer[SHA_PAD_SIZE/sizeof(word32)],
|
||||||
|
2 * sizeof(word32));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XTRANSFORM(sha, local);
|
XTRANSFORM(sha, local);
|
||||||
|
@@ -167,7 +167,8 @@ void Sha256Update(Sha256* sha256, const byte* data, word32 len)
|
|||||||
|
|
||||||
if (sha256->buffLen == SHA256_BLOCK_SIZE) {
|
if (sha256->buffLen == SHA256_BLOCK_SIZE) {
|
||||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||||
ByteReverseBytes(local, local, SHA256_BLOCK_SIZE);
|
ByteReverseWords(sha256->buffer, sha256->buffer,
|
||||||
|
SHA256_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
XTRANSFORM(sha256, local);
|
XTRANSFORM(sha256, local);
|
||||||
AddLength(sha256, SHA256_BLOCK_SIZE);
|
AddLength(sha256, SHA256_BLOCK_SIZE);
|
||||||
@@ -191,7 +192,7 @@ void Sha256Final(Sha256* sha256, byte* hash)
|
|||||||
sha256->buffLen += SHA256_BLOCK_SIZE - sha256->buffLen;
|
sha256->buffLen += SHA256_BLOCK_SIZE - sha256->buffLen;
|
||||||
|
|
||||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||||
ByteReverseBytes(local, local, SHA256_BLOCK_SIZE);
|
ByteReverseWords(sha256->buffer, sha256->buffer, SHA256_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
XTRANSFORM(sha256, local);
|
XTRANSFORM(sha256, local);
|
||||||
sha256->buffLen = 0;
|
sha256->buffLen = 0;
|
||||||
@@ -205,7 +206,7 @@ void Sha256Final(Sha256* sha256, byte* hash)
|
|||||||
|
|
||||||
/* store lengths */
|
/* store lengths */
|
||||||
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
#if defined(LITTLE_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
|
||||||
ByteReverseBytes(local, local, SHA256_BLOCK_SIZE);
|
ByteReverseWords(sha256->buffer, sha256->buffer, SHA256_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
/* ! length ordering dependent on digest endian type ! */
|
/* ! length ordering dependent on digest endian type ! */
|
||||||
XMEMCPY(&local[SHA256_PAD_SIZE], &sha256->hiLen, sizeof(word32));
|
XMEMCPY(&local[SHA256_PAD_SIZE], &sha256->hiLen, sizeof(word32));
|
||||||
@@ -214,8 +215,9 @@ void Sha256Final(Sha256* sha256, byte* hash)
|
|||||||
|
|
||||||
#ifdef FREESCALE_MMCAU
|
#ifdef FREESCALE_MMCAU
|
||||||
/* Kinetis requires only these bytes reversed */
|
/* Kinetis requires only these bytes reversed */
|
||||||
ByteReverseBytes(&local[SHA256_PAD_SIZE], &local[SHA256_PAD_SIZE],
|
ByteReverseWords(&sha256->buffer[SHA256_PAD_SIZE/sizeof(word32)],
|
||||||
2 * sizeof(word32));
|
&sha256->buffer[SHA256_PAD_SIZE/sizeof(word32)],
|
||||||
|
2 * sizeof(word32));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XTRANSFORM(sha256, local);
|
XTRANSFORM(sha256, local);
|
||||||
|
@@ -42,13 +42,11 @@ CYASSL_LOCAL
|
|||||||
word32 ByteReverseWord32(word32);
|
word32 ByteReverseWord32(word32);
|
||||||
CYASSL_LOCAL
|
CYASSL_LOCAL
|
||||||
void ByteReverseWords(word32*, const word32*, word32);
|
void ByteReverseWords(word32*, const word32*, word32);
|
||||||
CYASSL_LOCAL
|
|
||||||
void ByteReverseBytes(byte*, const byte*, word32);
|
|
||||||
|
|
||||||
CYASSL_LOCAL
|
CYASSL_LOCAL
|
||||||
void XorWords(word*, const word*, word32);
|
void XorWords(word*, const word*, word32);
|
||||||
CYASSL_LOCAL
|
CYASSL_LOCAL
|
||||||
void xorbuf(byte*, const byte*, word32);
|
void xorbuf(void*, const void*, word32);
|
||||||
|
|
||||||
#ifdef WORD64_AVAILABLE
|
#ifdef WORD64_AVAILABLE
|
||||||
CYASSL_LOCAL
|
CYASSL_LOCAL
|
||||||
|
@@ -1146,7 +1146,8 @@ static INLINE int CurrentDir(const char* str)
|
|||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mt = (memoryTrack*)((byte*)ptr - sizeof(memoryTrack));
|
mt = (memoryTrack*)ptr;
|
||||||
|
--mt; /* same as minus sizeof(memoryTrack), removes header */
|
||||||
|
|
||||||
#ifdef DO_MEM_STATS
|
#ifdef DO_MEM_STATS
|
||||||
ourMemStats.currentBytes -= mt->u.hint.thisSize;
|
ourMemStats.currentBytes -= mt->u.hint.thisSize;
|
||||||
@@ -1162,7 +1163,8 @@ static INLINE int CurrentDir(const char* str)
|
|||||||
|
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
/* if realloc is bigger, don't overread old ptr */
|
/* if realloc is bigger, don't overread old ptr */
|
||||||
memoryTrack* mt = (memoryTrack*)((byte*)ptr - sizeof(memoryTrack));
|
memoryTrack* mt = (memoryTrack*)ptr;
|
||||||
|
--mt; /* same as minus sizeof(memoryTrack), removes header */
|
||||||
|
|
||||||
if (mt->u.hint.thisSize < sz)
|
if (mt->u.hint.thisSize < sz)
|
||||||
sz = mt->u.hint.thisSize;
|
sz = mt->u.hint.thisSize;
|
||||||
|
Reference in New Issue
Block a user