tech-crypto archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Patch: cprng_fast performance - please review.
tls@ wrote:
> @@ -160,6 +160,7 @@ include "crypto/cast128/files.cast128"
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ crypto/hc128/hc128.c 17 Apr 2014 03:17:18 -0000
:
> +static inline uint32_t
> +pack_littleendian(const uint8_t *v)
> +{
> +#ifdef LITTLE_ENDIAN
> + return *((const uint32_t*)v);
> +#else
> + return (uint32_t)v[3] << 24
> + | (uint32_t)v[2] << 16
> + | (uint32_t)v[1] << 8
> + | (uint32_t)v[0];
> +#endif
> +}
LITTLE_ENDIAN != x86
This should simply be le32dec(9) otherwise
it will cause unaligned trap on arm and mips etc.
> +static inline void
> +unpack_littleendian(uint32_t value, uint8_t *v)
> +{
> +#if BYTE_ORDER == LITTLE_ENDIAN
> + *((uint32_t*)v) = value;
> +#else
> + int i;
> + for(i = 0; i < 4; ++i) {
> + v[i] = value >> (i * 8);
> + }
> +#endif
> +}
This should also be le32enc(9), if the byteswap is really necessary.
---
Izumi Tsutsui
Home |
Main Index |
Thread Index |
Old Index