* umac.h (_UMAC_STATE): Use _NETTLE_ALIGN16 for the l1_key array.
+2025-06-02 Niels Möller <nisse@lysator.liu.se>
+
+ * ctr.c (ctr_fill16) [!WORDS_BIGENDIAN]: Use nettle_bswap64.
+ (ctr_crypt): For block size 16, always use _nettle_ctr_crypt16.
+
2025-05-13 Niels Möller <nisse@lysator.liu.se>
Reduce size of sha3 context size to 216 bytes.
#include "ctr.h"
+#include "bswap-internal.h"
#include "ctr-internal.h"
#include "macros.h"
#include "memxor.h"
return i;
}
-#if WORDS_BIGENDIAN
-# define USE_CTR_CRYPT16 1
static nettle_fill16_func ctr_fill16;
+
+#if WORDS_BIGENDIAN
static void
ctr_fill16(uint8_t *ctr, size_t blocks, union nettle_block16 *buffer)
{
WRITE_UINT64(ctr + 8, lo);
}
#else /* !WORDS_BIGENDIAN */
-# if HAVE_BUILTIN_BSWAP64
-# define USE_CTR_CRYPT16 1
-static nettle_fill16_func ctr_fill16;
static void
ctr_fill16(uint8_t *ctr, size_t blocks, union nettle_block16 *buffer)
{
for (i = 0; i < blocks; i++)
{
buffer[i].u64[0] = hi;
- buffer[i].u64[1] = __builtin_bswap64(lo);
+ buffer[i].u64[1] = nettle_bswap64(lo);
if (!++lo)
- hi = __builtin_bswap64(__builtin_bswap64(hi) + 1);
+ hi = nettle_bswap64(nettle_bswap64(hi) + 1);
}
LE_WRITE_UINT64(ctr, hi);
WRITE_UINT64(ctr + 8, lo);
}
-# else /* ! HAVE_BUILTIN_BSWAP64 */
-# define USE_CTR_CRYPT16 0
-# endif
#endif /* !WORDS_BIGENDIAN */
void
size_t length, uint8_t *dst,
const uint8_t *src)
{
-#if USE_CTR_CRYPT16
if (block_size == 16)
{
_nettle_ctr_crypt16(ctx, f, ctr_fill16, ctr, length, dst, src);
return;
}
-#endif
if(src != dst)
{