Browse Source

Quick quirk to support unaligned input for aes256estream.

next
Frank Denis 11 years ago
parent
commit
05d6defd77
  1. 21
      src/libsodium/crypto_stream/aes256estream/hongjun/aes256-ctr.c
  2. 2
      src/libsodium/crypto_stream/aes256estream/hongjun/aes256.h

21
src/libsodium/crypto_stream/aes256estream/hongjun/aes256-ctr.c

@ -117,6 +117,27 @@ partial_precompute_tworounds(ECRYPT_ctx* ctx)
/* ------------------------------------------------------------------------- */
#if defined(CPU_X86) || defined(CPU_X86_64) || defined(CPU_PPC) || defined(CPU_Z390)
# undef CPU_ALIGNED_ACCESS_REQUIRED
#else
# define CPU_ALIGNED_ACCESS_REQUIRED
#endif
#ifndef CPU_ALIGNED_ACCESS_REQUIRED
# define UNALIGNED_U32_READ(P, I) (((const u32 *)(const void *) (P))[(I)])
#else
static inline uint32_t
UNALIGNED_U32_READ(const u8 * const p, const size_t i)
{
uint32_t t;
(void) sizeof(int[sizeof(*p) == sizeof(char) ? 1 : -1]);
memcpy(&t, p + i * (sizeof t / sizeof *p), sizeof t);
return t;
}
#endif
/* ------------------------------------------------------------------------- */
static void
ECRYPT_process_bytes(int action, ECRYPT_ctx* ctx, const u8* input, u8* output,
u32 msglen)

2
src/libsodium/crypto_stream/aes256estream/hongjun/aes256.h

@ -156,5 +156,3 @@
round(ctx,j0,j1,j2,j3,k0,k1,k2,k3,13);\
last_round(ctx,k0,k1,k2,k3,(output),14);\
}
#define UNALIGNED_U32_READ(P, I) (((const u32 *)(const void *) (P))[(I)])

Loading…
Cancel
Save