[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
memxor
From: |
Simon Josefsson |
Subject: |
memxor |
Date: |
Wed, 05 Oct 2005 14:10:14 +0200 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) |
Hi. This is a helper module needed by the hmac-md5 crypto module that
I'll post after this. What do you think? Ok to install?
I am not sure about the prototype. Should it use 'char*'? 'int*'?
The implementation XOR the data buffers char by char, but there is no
inherent requirement that it is done that way, so I thought the API
should use 'void*' similar to memcpy.
Thanks.
Index: m4/memxor.m4
===================================================================
RCS file: m4/memxor.m4
diff -N m4/memxor.m4
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ m4/memxor.m4 5 Oct 2005 12:07:36 -0000
@@ -0,0 +1,11 @@
+# memxor.m4 serial 1
+dnl Copyright (C) 2005 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_MEMXOR],
+[
+ AC_LIBSOURCES([memxor.h, memxor.c])
+ AC_LIBOBJ([memxor])
+])
Index: lib/memxor.h
===================================================================
RCS file: lib/memxor.h
diff -N lib/memxor.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/memxor.h 5 Oct 2005 12:07:36 -0000
@@ -0,0 +1,28 @@
+/* memxor.h -- perform binary exclusive OR operation on memory blocks.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Simon Josefsson. The interface was inspired by memxor
+ in Niels Möller's Nettle. */
+
+#ifndef MEMXOR_H
+# define MEMXOR_H
+
+#include <stddef.h>
+
+void *memxor (void *dest, const void *src, size_t n);
+
+#endif /* MEMXOR_H */
Index: lib/memxor.c
===================================================================
RCS file: lib/memxor.c
diff -N lib/memxor.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/memxor.c 5 Oct 2005 12:07:36 -0000
@@ -0,0 +1,38 @@
+/* memxor.c -- perform binary exclusive OR operation of two memory blocks.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Simon Josefsson. The interface was inspired by memxor
+ in Niels Möller's Nettle. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "memxor.h"
+
+void *
+memxor (void *dest, const void *src, size_t n)
+{
+ const char *s = src;
+ char *d = dest;
+ size_t i;
+
+ for (i = 0; i < n; i++)
+ d[i] ^= s[i];
+
+ return dest;
+}
Index: modules/memxor
===================================================================
RCS file: modules/memxor
diff -N modules/memxor
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/memxor 5 Oct 2005 12:07:36 -0000
@@ -0,0 +1,23 @@
+Description:
+memxor() function: binary exclusive or operation on two memory blocks
+
+Files:
+lib/memxor.h
+lib/memxor.c
+m4/memxor.m4
+
+Depends-on:
+
+configure.ac:
+gl_MEMXOR
+
+Makefile.am:
+
+Include:
+"memxor.h"
+
+License:
+LGPL
+
+Maintainer:
+Simon Josefsson
- memxor,
Simon Josefsson <=