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.
#include "memxor.h"
+/* For uintptr_t */
+#include "nettle-types.h"
+
typedef unsigned long int word_t;
#if SIZEOF_LONG & (SIZEOF_LONG - 1)
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;
/* 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)
{
for (; n > 0; n--)
*dst++ ^= *src++;
- return orig_dst;
+ return dst_in;
}
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;
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;
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)
{
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;
#define NETTLE_MEMXOR_H_INCLUDED
#include <stdlib.h>
-#include "nettle-types.h"
#ifdef __cplusplus
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
}