diff --git a/ChangeLog b/ChangeLog index cd6583a37c35bf2b698adbbab6f89ffc38eb365e..15ae263398a01da2e37278cc552e88e3eb5bbddf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2013-04-24 Niels Möller <nisse@lysator.liu.se> + * memxor.h: Updated prototypes. Drop include of nettle-types.h. + + * memxor.c: Include nettle-types.h, for uintptr_t. Replace all + internal uses of uint8_t by plain char. + (memxor): Use void * rather than uint8_t * for + arguments. + (memxor3): Likewise. + * x86_64/memxor.asm: Added nettle_ prefix to symbols. * arm/memxor.asm: Likewise. diff --git a/memxor.c b/memxor.c index f2feff04fa31fd7a8d54ac27114bcb66485c429d..a91ec2155711dbc5dfdf1f8f7d64a377e189ebc8 100644 --- a/memxor.c +++ b/memxor.c @@ -35,6 +35,9 @@ #include "memxor.h" +/* For uintptr_t */ +#include "nettle-types.h" + typedef unsigned long int word_t; #if SIZEOF_LONG & (SIZEOF_LONG - 1) @@ -75,7 +78,7 @@ memxor_common_alignment (word_t *dst, const word_t *src, size_t n) words, not bytes. Assumes we can read complete words at the start and end of the src operand. */ static void -memxor_different_alignment (word_t *dst, const uint8_t *src, size_t n) +memxor_different_alignment (word_t *dst, const char *src, size_t n) { size_t i; int shl, shr; @@ -111,10 +114,11 @@ memxor_different_alignment (word_t *dst, const uint8_t *src, size_t n) /* XOR LEN bytes starting at SRCADDR onto DESTADDR. Result undefined if the source overlaps with the destination. Return DESTADDR. */ -uint8_t * -memxor(uint8_t *dst, const uint8_t *src, size_t n) +void * +memxor(void *dst_in, const void *src_in, size_t n) { - uint8_t *orig_dst = dst; + char *dst = dst_in; + const char *src = src_in; if (n >= WORD_T_THRESH) { @@ -137,7 +141,7 @@ memxor(uint8_t *dst, const uint8_t *src, size_t n) for (; n > 0; n--) *dst++ ^= *src++; - return orig_dst; + return dst_in; } @@ -153,7 +157,7 @@ memxor3_common_alignment (word_t *dst, static void memxor3_different_alignment_b (word_t *dst, - const word_t *a, const uint8_t *b, unsigned offset, size_t n) + const word_t *a, const char *b, unsigned offset, size_t n) { int shl, shr; const word_t *b_word; @@ -187,7 +191,7 @@ memxor3_different_alignment_b (word_t *dst, static void memxor3_different_alignment_ab (word_t *dst, - const uint8_t *a, const uint8_t *b, + const char *a, const char *b, unsigned offset, size_t n) { int shl, shr; @@ -224,7 +228,7 @@ memxor3_different_alignment_ab (word_t *dst, static void memxor3_different_alignment_all (word_t *dst, - const uint8_t *a, const uint8_t *b, + const char *a, const char *b, unsigned a_offset, unsigned b_offset, size_t n) { @@ -271,9 +275,13 @@ memxor3_different_alignment_all (word_t *dst, the start of the destination area. This feature is used only internally by cbc decrypt, and it is not advertised or documented to nettle users. */ -uint8_t * -memxor3(uint8_t *dst, const uint8_t *a, const uint8_t *b, size_t n) +void * +memxor3(void *dst_in, const void *a_in, const void *b_in, size_t n) { + char *dst = dst_in; + const char *a = a_in; + const char *b = b_in; + if (n >= WORD_T_THRESH) { unsigned i; diff --git a/memxor.h b/memxor.h index 2a6545cef79598c03b3a270785b65a27daa9033a..b7bef09eecc8792116c6dd97b358831d5ca7f309 100644 --- a/memxor.h +++ b/memxor.h @@ -6,7 +6,6 @@ #define NETTLE_MEMXOR_H_INCLUDED #include <stdlib.h> -#include "nettle-types.h" #ifdef __cplusplus extern "C" { @@ -16,8 +15,8 @@ extern "C" { #define memxor nettle_memxor #define memxor3 nettle_memxor3 -uint8_t *memxor(uint8_t *dst, const uint8_t *src, size_t n); -uint8_t *memxor3(uint8_t *dst, const uint8_t *a, const uint8_t *b, size_t n); +void *memxor(void *dst, const void *src, size_t n); +void *memxor3(void *dst, const void *a, const void *b, size_t n); #ifdef __cplusplus }