Commit 5cc019f9 authored by Niels Möller's avatar Niels Möller

Changed memxor functions to take void * arguments.

parent 759bbb3e
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.
......
......@@ -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;
......
......@@ -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
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment