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:
Juliusz Sosinowicz
2023-07-21 14:48:28 +02:00
parent d3202600a4
commit 56fc5bbf87
3 changed files with 17 additions and 13 deletions

View File

@@ -274,13 +274,7 @@ static int Dtls13GetRnMask(WOLFSSL* ssl, const byte* ciphertext, byte* mask,
if (c->chacha == NULL)
return BAD_STATE_E;
/* assuming CIPHER[0..3] should be interpreted as little endian 32-bits
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 */
ato32le(ciphertext, &counter);
ret = wc_Chacha_SetIV(c->chacha, &ciphertext[4], counter);
if (ret != 0)