mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
Dtls13GetRnMask: Correctly get chacha counter on BE systems
The issue was that BIG_ENDIAN is defined in endian.h (on linux). Our define is BIG_ENDIAN_ORDER.
This commit is contained in:
@@ -274,13 +274,7 @@ static int Dtls13GetRnMask(WOLFSSL* ssl, const byte* ciphertext, byte* mask,
|
|||||||
if (c->chacha == NULL)
|
if (c->chacha == NULL)
|
||||||
return BAD_STATE_E;
|
return BAD_STATE_E;
|
||||||
|
|
||||||
/* assuming CIPHER[0..3] should be interpreted as little endian 32-bits
|
ato32le(ciphertext, &counter);
|
||||||
integer. The draft rfc isn't really clear on that. See sec 4.2.3 of
|
|
||||||
the draft. See also Section 2.3 of the Chacha RFC. */
|
|
||||||
XMEMCPY(&counter, ciphertext, sizeof(counter));
|
|
||||||
#ifdef BIG_ENDIAN
|
|
||||||
counter = ByteReverseWord32(counter);
|
|
||||||
#endif /* BIG_ENDIAN */
|
|
||||||
|
|
||||||
ret = wc_Chacha_SetIV(c->chacha, &ciphertext[4], counter);
|
ret = wc_Chacha_SetIV(c->chacha, &ciphertext[4], counter);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
|
@@ -472,6 +472,15 @@ WC_MISC_STATIC WC_INLINE void ato32(const byte* c, word32* wc_u32)
|
|||||||
(word32)c[3];
|
(word32)c[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* convert opaque to 32 bit integer. Interpret as little endian. */
|
||||||
|
WC_MISC_STATIC WC_INLINE void ato32le(const byte* c, word32* wc_u32)
|
||||||
|
{
|
||||||
|
*wc_u32 = (word32)c[0] |
|
||||||
|
((word32)c[1] << 8) |
|
||||||
|
((word32)c[2] << 16) |
|
||||||
|
((word32)c[3] << 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
WC_MISC_STATIC WC_INLINE word32 btoi(byte b)
|
WC_MISC_STATIC WC_INLINE word32 btoi(byte b)
|
||||||
{
|
{
|
||||||
|
@@ -102,12 +102,13 @@ void ByteReverseWords64(word64* out, const word64* in, word32 byteCount);
|
|||||||
|
|
||||||
|
|
||||||
void c32to24(word32 in, word24 out);
|
void c32to24(word32 in, word24 out);
|
||||||
void c16toa(word16 u16, byte* c);
|
void c16toa(word16 wc_u16, byte* c);
|
||||||
void c32toa(word32 u32, byte* c);
|
void c32toa(word32 wc_u32, byte* c);
|
||||||
void c24to32(const word24 u24, word32* u32);
|
void c24to32(const word24 wc_u24, word32* wc_u32);
|
||||||
void ato16(const byte* c, word16* u16);
|
void ato16(const byte* c, word16* wc_u16);
|
||||||
void ato24(const byte* c, word32* u24);
|
void ato24(const byte* c, word32* wc_u24);
|
||||||
void ato32(const byte* c, word32* u32);
|
void ato32(const byte* c, word32* wc_u32);
|
||||||
|
void ato32le(const byte* c, word32* wc_u32);
|
||||||
word32 btoi(byte b);
|
word32 btoi(byte b);
|
||||||
|
|
||||||
WOLFSSL_LOCAL signed char HexCharToByte(char ch);
|
WOLFSSL_LOCAL signed char HexCharToByte(char ch);
|
||||||
|
Reference in New Issue
Block a user