summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog21
-rw-r--r--Makefile.am4
-rw-r--r--NEWS2
-rw-r--r--TODO2
-rwxr-xr-xautogen.sh42
-rw-r--r--compat/Makefile.am50
-rw-r--r--compat/clock.c36
-rw-r--r--compat/compat.c36
-rw-r--r--compat/getpid.c29
-rw-r--r--compat/libcompat.h37
-rw-r--r--configure.ac22
-rw-r--r--ltmain.sh16
-rw-r--r--m4/ltversion.m410
-rw-r--r--random/ChangeLog7
-rw-r--r--random/random-csprng.c3
-rw-r--r--random/rndw32.c39
-rw-r--r--src/ChangeLog17
-rw-r--r--src/Makefile.am31
-rw-r--r--src/dumpsexp.c5
-rw-r--r--src/g10lib.h3
-rw-r--r--src/global.c16
-rw-r--r--src/hmac256.c11
-rw-r--r--src/secmem.c19
-rw-r--r--tests/ChangeLog6
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/benchmark.c13
26 files changed, 421 insertions, 58 deletions
diff --git a/ChangeLog b/ChangeLog
index 80717c52..f40a615b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2010-01-21 Werner Koch <wk@g10code.com>
+
+ * compat/Makefile.am: New.
+ * compat/compat.c: New.
+ * compat/libcompat.h: New.
+ * compat/getpid.c, compat/clock.c: New.
+
+ * configure.ac: Require libgpg-error 1.8.
+ (HAVE_W32CE_SYSTEM): New am_defines and am_conditionals.
+ (getpid): Check for replacement function.
+ (AC_CONFIG_LIBOBJ_DIR): New.
+ (AC_TYPE_PID_T): New.
+ (AM_INIT_AUTOMAKE): Use modern variant.
+ (AC_CONFIG_FILES): Add compat/Makfile.
+ * autogen.sh: Support W32CE.
+ * ltmain.sh: Update to 2.2.6b
+ (wrappers_required): Don't set for mingw32ce.
+ * Makefile.am (DIST_SUBDIRS, SUBDIRS): Add compat.
+
2009-12-10 Werner Koch <wk@g10code.com>
* configure.ac: Add option --disable-O-flag-munging.
@@ -29,7 +48,7 @@
2009-01-22 Werner Koch <wk@g10code.com>
Release 1.4.4.
-
+
* configure.ac: Bump LT version to C16/A5/R2.
2008-10-30 Werner Koch <wk@g10code.com>
diff --git a/Makefile.am b/Makefile.am
index 61ae90e0..2e0224c4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,8 +22,8 @@ AUTOMAKE_OPTIONS = dist-bzip2
DISTCHECK_CONFIGURE_FLAGS = --enable-random-daemon \
--enable-ciphers=arcfour:blowfish:cast5:des:aes:twofish:serpent:rfc2268:seed:camellia
-DIST_SUBDIRS = m4 mpi cipher random src doc tests
-SUBDIRS = mpi cipher random src doc tests
+DIST_SUBDIRS = m4 compat mpi cipher random src doc tests
+SUBDIRS = compat mpi cipher random src doc tests
EXTRA_DIST = autogen.sh README.SVN
DISTCLEANFILES =
diff --git a/NEWS b/NEWS
index 9e981237..3f48d241 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,8 @@ Noteworthy changes in version 1.5.x (unreleased)
* Boosted SHA-512 performance by 30% on ia32 boxes and gcc 4.3;
SHA-256 went up by 25%.
+ * Support for WindowsCE.
+
* Interface changes relative to the 1.4.2 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GCRY_CIPHER_MODE_AESWRAP NEW.
diff --git a/TODO b/TODO
index 74468e31..596912a6 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-What's left to do -*- outline -*-
+# What's left to do -*- org -*-
* Next API break:
** gcry_ac_io_t
diff --git a/autogen.sh b/autogen.sh
index 3f2db4f7..5e8767c8 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -36,9 +36,28 @@ if test x"$1" = x"--force"; then
shift
fi
+# Convenience option to use certain configure options for some hosts.
+myhost=""
+myhostsub=""
+case "$1" in
+ --build-w32)
+ myhost="w32"
+ ;;
+ --build-w32ce)
+ myhost="w32"
+ myhostsub="ce"
+ ;;
+ --build-amd64)
+ myhost="amd64"
+ ;;
+ *)
+ ;;
+esac
+
+
# ***** W32 build script *******
# Used to cross-compile for Windows.
-if test "$1" = "--build-w32"; then
+if [ "$myhost" = "w32" ]; then
tmp=`dirname $0`
tsdir=`cd "$tmp"; pwd`
shift
@@ -48,12 +67,21 @@ if test "$1" = "--build-w32"; then
fi
build=`$tsdir/config.guess`
- [ -z "$w32root" ] && w32root="$HOME/w32root"
+ case $myhostsub in
+ ce)
+ [ -z "$w32root" ] && w32root="$HOME/w32ce_root"
+ toolprefixes="arm-mingw32ce"
+ ;;
+ *)
+ [ -z "$w32root" ] && w32root="$HOME/w32root"
+ toolprefixes="i586-mingw32msvc i386-mingw32msvc"
+ ;;
+ esac
echo "Using $w32root as standard install directory" >&2
# Locate the cross compiler
crossbindir=
- for host in i586-mingw32msvc i386-mingw32msvc; do
+ for host in $toolprefixes; do
if ${host}-gcc --version >/dev/null 2>&1 ; then
crossbindir=/usr/${host}/bin
conf_CC="CC=${host}-gcc"
@@ -62,8 +90,10 @@ if test "$1" = "--build-w32"; then
done
if [ -z "$crossbindir" ]; then
echo "Cross compiler kit not installed" >&2
- echo "Under Debian GNU/Linux, you may install it using" >&2
- echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2
+ if [ -z "$sub" ]; then
+ echo "Under Debian GNU/Linux, you may install it using" >&2
+ echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2
+ fi
echo "Stop." >&2
exit 1
fi
@@ -85,7 +115,7 @@ fi
# ***** AMD64 cross build script *******
# Used to cross-compile for AMD64 (for testing)
-if test "$1" = "--build-amd64"; then
+if [ "$myhost" = "amd64" ]; then
tmp=`dirname $0`
tsdir=`cd "$tmp"; pwd`
shift
diff --git a/compat/Makefile.am b/compat/Makefile.am
new file mode 100644
index 00000000..0e0c54a4
--- /dev/null
+++ b/compat/Makefile.am
@@ -0,0 +1,50 @@
+# Makefile for compat directory
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This file is part of Libgcrypt.
+#
+# Libgcrypt is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# Libgcrypt 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+# Process this file with automake to produce Makefile.in
+
+# We use this libcompat to work around problems with LIBOBJ stuff.
+# For example, we need some of the compat files also in tests/ but the
+# suggested way to do this (using the automake option subdir-objects)
+# leads to problems with "make distclean": The distclean target in
+# tests is run before the one src and it removes the deps files of the
+# libobj files which are in src. Now when it comes to run make in src
+# the icnluded files are gone - bummer. Instead of try to fix this
+# issue it seems better not to use subdir-objects but build them all
+# into a compat library and always link against that library. This
+# also avoids the problem that a dependency on LTLIBOBJ is not setup
+# if -- disable-static was used.
+
+# Need to include ../src in addition to top_srcdir because gcrypt.h is
+# a built header.
+AM_CPPFLAGS = -I../src -I$(top_srcdir)/src $(GPG_ERROR_CFLAGS)
+
+noinst_LTLIBRARIES = libcompat.la
+
+# We only need one file so that the library is guaranteed to have at
+# least one member.
+libcompat_la_SOURCES = compat.c libcompat.h
+libcompat_la_DEPENDENCIES = @LTLIBOBJS@
+libcompat_la_LIBADD = @LTLIBOBJS@
+
+# AC_LIBOBJ files are:
+# getpid.c
+# clock.c
+#
+
+
diff --git a/compat/clock.c b/compat/clock.c
new file mode 100644
index 00000000..0d1a1671
--- /dev/null
+++ b/compat/clock.c
@@ -0,0 +1,36 @@
+/* clock.c - Replacement for WindowsCE
+ Copyright (C) 2010 Free Software Foundation, Inc.
+
+ This file is free software; as a special exception the author gives
+ unlimited permission to copy and/or distribute it, with or without
+ modifications, as long as this notice is preserved.
+
+ This file is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, to the extent permitted by law; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_W32CE_SYSTEM
+#include <windows.h>
+#include <time.h>
+#include <assert.h>
+
+clock_t
+_gcry_clock (void)
+{
+ assert (CLOCKS_PER_SEC == 1000);
+#warning Replace by a correct implementaion.
+ /* It seems that GetProcessTimes is available in the kernel but
+ without a declaration. If that fails we would need to walk over
+ all threads and tally up the GetThreadTimes. */
+
+ return GetTickCount ();
+}
+
+#else
+# error No replacement function for clock known
+#endif
diff --git a/compat/compat.c b/compat/compat.c
new file mode 100644
index 00000000..8f1d9c86
--- /dev/null
+++ b/compat/compat.c
@@ -0,0 +1,36 @@
+/* compat.c - Dummy file to avoid an empty library.
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include "../src/g10lib.h"
+
+
+const char *
+_gcry_compat_identification (void)
+{
+ static const char blurb[] =
+ "\n\n"
+ "This is Libgcrypt - The GNU Crypto Library\n"
+ "Copyright 2000, 2002, 2003, 2004, 2007, 2008, 2009,\n"
+ " 2010 Free Software Foundation, Inc.\n"
+ "\n\n";
+ return blurb;
+}
+
diff --git a/compat/getpid.c b/compat/getpid.c
new file mode 100644
index 00000000..b93d057f
--- /dev/null
+++ b/compat/getpid.c
@@ -0,0 +1,29 @@
+/* getpid.c - Replacement for WindowsCE
+ Copyright (C) 2010 Free Software Foundation, Inc.
+
+ This file is free software; as a special exception the author gives
+ unlimited permission to copy and/or distribute it, with or without
+ modifications, as long as this notice is preserved.
+
+ This file is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, to the extent permitted by law; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_W32CE_SYSTEM
+#include <windows.h>
+#include <sys/types.h>
+
+pid_t
+_gcry_getpid (void)
+{
+ return GetCurrentProcessId ();
+}
+
+#else
+# error No replacement function for getpid known
+#endif
diff --git a/compat/libcompat.h b/compat/libcompat.h
new file mode 100644
index 00000000..b5a76491
--- /dev/null
+++ b/compat/libcompat.h
@@ -0,0 +1,37 @@
+/* libcomapt.h - Prototypes for AC_REPLACE_FUNCtions.
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser general Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GCRY_LIBCOMPAT_H
+#define GCRY_LIBCOMPAT_H
+
+const char *_gcry_compat_identification (void);
+
+
+#ifndef HAVE_GETPID
+pid_t _gcry_getpid (void);
+#define getpid() _gcry_getpid ()
+#endif
+
+#ifndef HAVE_CLOCK
+clock_t _gcry_clock (void);
+#define clock() _gcry_clock ()
+#endif
+
+
+#endif /*GCRY_LIBCOMPAT_H*/
diff --git a/configure.ac b/configure.ac
index be2fd32e..0022c291 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,7 +47,7 @@ LIBGCRYPT_LT_REVISION=0
# If the API is changed in an incompatible way: increment the next counter.
LIBGCRYPT_CONFIG_API_VERSION=1
-NEED_GPG_ERROR_VERSION=1.4
+NEED_GPG_ERROR_VERSION=1.8
is_development_version=my_issvn
BUILD_REVISION=svn_revision
@@ -55,9 +55,10 @@ PACKAGE=$PACKAGE_NAME
VERSION=$PACKAGE_VERSION
AC_CONFIG_SRCDIR([src/libgcrypt.vers])
-AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
+AM_INIT_AUTOMAKE([])
AM_CONFIG_HEADER(config.h)
AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_LIBOBJ_DIR([compat])
AC_CANONICAL_HOST
AM_MAINTAINER_MODE
@@ -170,6 +171,7 @@ LIBGCRYPT_THREAD_MODULES=""
# Other definitions.
print_egd_notice=no
have_w32_system=no
+have_w32ce_system=no
# Setup some stuff depending on host.
case "${host}" in
@@ -177,6 +179,7 @@ case "${host}" in
available_random_modules="w32"
ac_cv_have_dev_random=no
have_w32_system=yes
+ case "${host}" in *-mingw32ce*) have_w32ce_system=yes ;; esac
AC_DEFINE(USE_ONLY_8DOT3,1,
[set this to limit filenames to the 8.3 format])
AC_DEFINE(HAVE_DRIVE_LETTERS,1,
@@ -227,13 +230,21 @@ esac
if test "$have_w32_system" = yes; then
AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
+ if test "$have_w32ce_system" = yes; then
+ AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE])
+ fi
fi
AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
+AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
# A printable OS Name is sometimes useful.
case "${host}" in
+ *-*-mingw32ce*)
+ PRINTABLE_OS_NAME="MingW32CE"
+ ;;
+
*-*-mingw32*)
PRINTABLE_OS_NAME="MingW32"
;;
@@ -595,6 +606,7 @@ AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_SIGNAL
AC_DECL_SYS_SIGLIST
+AC_TYPE_PID_T
GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
@@ -718,6 +730,11 @@ AC_CHECK_FUNCS(fcntl ftruncate)
GNUPG_CHECK_MLOCK
+#
+# Replacement functions.
+#
+AC_REPLACE_FUNCS([getpid clock])
+
#
# Check wether it is necessary to link against libdl.
@@ -1128,6 +1145,7 @@ AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
AC_CONFIG_FILES([
Makefile
m4/Makefile
+compat/Makefile
mpi/Makefile
cipher/Makefile
random/Makefile
diff --git a/ltmain.sh b/ltmain.sh
index 3506ead3..ce149f1d 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -1,6 +1,6 @@
# Generated from ltmain.m4sh.
-# ltmain.sh (GNU libtool) 2.2.6
+# ltmain.sh (GNU libtool) 2.2.6b
# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
@@ -65,7 +65,7 @@
# compiler: $LTCC
# compiler flags: $LTCFLAGS
# linker: $LD (gnu? $with_gnu_ld)
-# $progname: (GNU libtool) 2.2.6 Debian-2.2.6a-4
+# $progname: (GNU libtool) 2.2.6b Debian-2.2.6b-2
# automake: $automake_version
# autoconf: $autoconf_version
#
@@ -73,9 +73,9 @@
PROGRAM=ltmain.sh
PACKAGE=libtool
-VERSION="2.2.6 Debian-2.2.6a-4"
+VERSION="2.2.6b Debian-2.2.6b-2"
TIMESTAMP=""
-package_revision=1.3012
+package_revision=1.3017
# Be Bourne compatible
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
@@ -7681,15 +7681,15 @@ EOF
wrappers_required=yes
case $host in
+ *cegcc | *mingw32ce* )
+ # Disable wrappers for cegcc, we are cross compiling anyway.
+ wrappers_required=no
+ ;;
*cygwin* | *mingw* )
if test "$build_libtool_libs" != yes; then
wrappers_required=no
fi
;;
- *cegcc)
- # Disable wrappers for cegcc, we are cross compiling anyway.
- wrappers_required=no
- ;;
*)
if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
wrappers_required=no
diff --git a/m4/ltversion.m4 b/m4/ltversion.m4
index b8e154fe..f3c53098 100644
--- a/m4/ltversion.m4
+++ b/m4/ltversion.m4
@@ -9,15 +9,15 @@
# Generated from ltversion.in.
-# serial 3012 ltversion.m4
+# serial 3017 ltversion.m4
# This file is part of GNU Libtool
-m4_define([LT_PACKAGE_VERSION], [2.2.6])
-m4_define([LT_PACKAGE_REVISION], [1.3012])
+m4_define([LT_PACKAGE_VERSION], [2.2.6b])
+m4_define([LT_PACKAGE_REVISION], [1.3017])
AC_DEFUN([LTVERSION_VERSION],
-[macro_version='2.2.6'
-macro_revision='1.3012'
+[macro_version='2.2.6b'
+macro_revision='1.3017'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0)
])
diff --git a/random/ChangeLog b/random/ChangeLog
index 31208b6e..76fa5ec7 100644
--- a/random/ChangeLog
+++ b/random/ChangeLog
@@ -1,3 +1,10 @@
+2010-01-21 Werner Koch <wk@g10code.com>
+
+ * rndw32.c (read_mbm_data) [W32CE]: Do not build.
+ (slow_gatherer) [W32CE]: Do not call read_mbm_data.
+ (_gcry_rndw32_gather_random_fast) [W32CE]: Exclude some calls.
+ (_gcry_rndw32_gather_random): Adjust version test for WindowsCE.
+
2009-12-10 Werner Koch <wk@g10code.com>
* rndw32.c (system_is_w2000): New.
diff --git a/random/random-csprng.c b/random/random-csprng.c
index aca977e8..fbc4230e 100644
--- a/random/random-csprng.c
+++ b/random/random-csprng.c
@@ -682,6 +682,7 @@ _gcry_rngcsprng_set_seed_file (const char *name)
static int
lock_seed_file (int fd, const char *fname, int for_write)
{
+#warning Check whether we can lock on Windows.
#if LOCK_SEED_FILE
struct flock lck;
struct timeval tv;
@@ -709,7 +710,7 @@ lock_seed_file (int fd, const char *fname, int for_write)
if (backoff < 10)
backoff++ ;
}
-#endif /*LOCK_SEED_FILE*/
+#endif /*!LOCK_SEED_FILE*/
return 0;
}
diff --git a/random/rndw32.c b/random/rndw32.c
index d250c061..4511ceeb 100644
--- a/random/rndw32.c
+++ b/random/rndw32.c
@@ -1,5 +1,6 @@
/* rndw32.c - W32 entropy gatherer
- * Copyright (C) 1999, 2000, 2002, 2003, 2007 Free Software Foundation, Inc.
+ * Copyright (C) 1999, 2000, 2002, 2003, 2007,
+ * 2010 Free Software Foundation, Inc.
* Copyright Peter Gutmann, Matt Thomlinson and Blake Coverett 1996-2006
*
* This file is part of Libgcrypt.
@@ -328,6 +329,7 @@ read_system_rng (void (*add)(const void*, size_t, enum random_origins),
/* Read data from MBM. This communicates via shared memory, so all we
need to do is map a file and read the data out. */
+#ifndef HAVE_W32CE_SYSTEM
static void
read_mbm_data (void (*add)(const void*, size_t, enum random_origins),
enum random_origins requester)
@@ -350,6 +352,7 @@ read_mbm_data (void (*add)(const void*, size_t, enum random_origins),
CloseHandle (hMBMData);
}
}
+#endif /*!HAVE_W32CE_SYSTEM*/
/* Fallback method using the registry to poll the statistics. */
@@ -556,8 +559,10 @@ slow_gatherer ( void (*add)(const void*, size_t, enum random_origins),
}
read_system_rng ( add, requester );
+#ifndef HAVE_W32CE_SYSTEM
read_mbm_data ( add, requester );
-
+#endif
+
/* Get network statistics. Note: Both NT Workstation and NT Server by
default will be running both the workstation and server services. The
heuristic below is probably useful though on the assumption that the
@@ -774,8 +779,13 @@ _gcry_rndw32_gather_random (void (*add)(const void*, size_t,
OSVERSIONINFO osvi = { sizeof( osvi ) };
GetVersionEx( &osvi );
- if ( osvi.dwPlatformId != VER_PLATFORM_WIN32_NT)
+#ifdef HAVE_W32CE_SYSTEM
+ if (osvi.dwPlatformId != VER_PLATFORM_WIN32_CE)
+ log_fatal ("can only run on a Windows CE platform\n" );
+#else
+ if (osvi.dwPlatformId != VER_PLATFORM_WIN32_NT)
log_fatal ("can only run on a Windows NT platform\n" );
+#endif
system_is_w2000 = (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0);
init_system_rng ();
is_initialized = 1;
@@ -821,23 +831,28 @@ _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t,
memcpy (bufptr, &along, sizeof (along) ); \
bufptr += sizeof (along); \
} while (0)
+#ifdef HAVE_W32CE_SYSTEM
+# define ADD_NO_CE(f)
+#else
+# define ADD_NO_CE(f) ADD(f)
+#endif
ADD ( GetActiveWindow ());
ADD ( GetCapture ());
ADD ( GetClipboardOwner ());
- ADD ( GetClipboardViewer ());
+ ADD_NO_CE ( GetClipboardViewer ());
ADD ( GetCurrentProcess ());
ADD ( GetCurrentProcessId ());
ADD ( GetCurrentThread ());
ADD ( GetCurrentThreadId ());
ADD ( GetDesktopWindow ());
ADD ( GetFocus ());
- ADD ( GetInputState ());
+ ADD_NO_CE ( GetInputState ());
ADD ( GetMessagePos ());
- ADD ( GetMessageTime ());
+ ADD_NO_CE ( GetMessageTime ());
ADD ( GetOpenClipboardWindow ());
ADD ( GetProcessHeap ());
- ADD ( GetProcessWindowStation ());
+ ADD_NO_CE ( GetProcessWindowStation ());
ADD ( GetQueueStatus (QS_ALLEVENTS));
ADD ( GetTickCount ());
@@ -883,9 +898,15 @@ _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t,
(*add) ( &kernelTime, sizeof (kernelTime), origin );
(*add) ( &userTime, sizeof (userTime), origin );
+#ifdef HAVE_W32CE_SYSTEM
+ handle = GetCurrentThread ();
+ GetThreadTimes (handle, &creationTime, &exitTime,
+ &kernelTime, &userTime);
+#else
handle = GetCurrentProcess ();
GetProcessTimes (handle, &creationTime, &exitTime,
&kernelTime, &userTime);
+#endif
(*add) ( &creationTime, sizeof (creationTime), origin );
(*add) ( &exitTime, sizeof (exitTime), origin );
(*add) ( &kernelTime, sizeof (kernelTime), origin );
@@ -893,17 +914,20 @@ _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t,
/* Get the minimum and maximum working set size for the current
process. */
+#ifndef HAVE_W32CE_SYSTEM
GetProcessWorkingSetSize (handle, &minimumWorkingSetSize,
&maximumWorkingSetSize);
(*add) ( &minimumWorkingSetSize,
sizeof (minimumWorkingSetSize), origin );
(*add) ( &maximumWorkingSetSize,
sizeof (maximumWorkingSetSize), origin );
+#endif /*!HAVE_W32CE_SYSTEM*/
}
/* The following are fixed for the lifetime of the process so we only
* add them once */
+#ifndef HAVE_W32CE_SYSTEM
if (!addedFixedItems)
{
STARTUPINFO startupInfo;
@@ -916,6 +940,7 @@ _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t,
(*add) ( &startupInfo, sizeof (STARTUPINFO), origin );
addedFixedItems = 1;
}
+#endif /*!HAVE_W32CE_SYSTEM*/
/* The performance of QPC varies depending on the architecture it's
running on and on the OS, the MS documentation is vague about the
diff --git a/src/ChangeLog b/src/ChangeLog
index 9f7c7e8c..fe541dd6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,20 @@
+2010-01-21 Werner Koch <wk@g10code.com>
+
+ * Makefile.am (arch_gpg_error_cflags, arch_gpg_error_libs): New.
+ (dumpsexp_CFLAGS): New.
+ (dumpsexp_LDADD): Add arch_gpg_error_libs.
+ (hmac256_CFLAGS, hmac256_LDADD): Add the arch variables.
+ (libgcrypt_la_DEPENDENCIES): Add libcompat.
+ * secmem.c (lock_pool): Mark unused args.
+ * global.c (do_malloc, gcry_realloc, gcry_free, gcry_calloc)
+ (gcry_calloc_secure, gcry_xcalloc, gcry_xcalloc_secure): Use
+ gpg_err_set_errno.
+ (_gcry_vcontrol): Call _gcry_compat_identification.
+ * hmac256.c [__MINGW32CE__]: Include gpg-error.h.
+ (_gcry_hmac256_file): Use gpg_err_set_errno.
+ (gpg_err_set_errno) [!GPG_ERR_INLINE]: Add macro.
+ * g10lib.h: Include libcompat.h.
+
2010-01-05 Werner Koch <wk@g10code.com>
* gcrypt.h.in (GCRY_PK_ECDH): New.
diff --git a/src/Makefile.am b/src/Makefile.am
index 08e6a04d..8ceed983 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,14 +14,15 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+
## Process this file with automake to produce Makefile.in
EXTRA_DIST = Manifest libgcrypt-config.in libgcrypt.m4 libgcrypt.vers \
gcrypt.h.in libgcrypt.def
+
bin_SCRIPTS = libgcrypt-config
m4datadir = $(datadir)/aclocal
m4data_DATA = libgcrypt.m4
@@ -34,6 +35,15 @@ sbin_PROGRAMS = gcryptrnd
bin_PROGRAMS += getrandom
endif USE_RANDOM_DAEMON
+# Depending on the architecture some targets require libgpg-error.
+if HAVE_W32CE_SYSTEM
+arch_gpg_error_cflags = $(GPG_ERROR_CFLAGS)
+arch_gpg_error_libs = $(GPG_ERROR_LIBS)
+else
+arch_gpg_error_cflags =
+arch_gpg_error_libs =
+endif
+
if HAVE_LD_VERSION_SCRIPT
libgcrypt_version_script_cmd = -Wl,--version-script=$(srcdir)/libgcrypt.vers
@@ -41,7 +51,7 @@ else
libgcrypt_version_script_cmd =
endif
-libgcrypt_la_CFLAGS = @GPG_ERROR_CFLAGS@
+libgcrypt_la_CFLAGS = $(GPG_ERROR_CFLAGS)
libgcrypt_la_SOURCES = g10lib.h visibility.c visibility.h types.h \
cipher.h cipher-proto.h \
misc.c global.c sexp.c hwfeatures.c \
@@ -94,19 +104,22 @@ libgcrypt_la_DEPENDENCIES = \
../cipher/libcipher.la \
../random/librandom.la \
../mpi/libmpi.la \
- $(srcdir)/libgcrypt.vers $(gcrypt_deps)
+ ../compat/libcompat.la \
+ $(srcdir)/libgcrypt.vers $(gcrypt_deps)
libgcrypt_la_LIBADD = $(gcrypt_res) \
../cipher/libcipher.la \
../random/librandom.la \
- ../mpi/libmpi.la @LTLIBOBJS@ @GPG_ERROR_LIBS@
+ ../mpi/libmpi.la \
+ ../compat/libcompat.la $(GPG_ERROR_LIBS)
dumpsexp_SOURCES = dumpsexp.c
-dumpsexp_LDADD =
+dumpsexp_CFLAGS = $(arch_gpg_error_cflags)
+dumpsexp_LDADD = $(arch_gpg_error_libs)
hmac256_SOURCES = hmac256.c
-hmac256_CFLAGS = -DSTANDALONE
-hmac256_LDADD =
+hmac256_CFLAGS = -DSTANDALONE $(arch_gpg_error_cflags)
+hmac256_LDADD = $(arch_gpg_error_libs)
if USE_RANDOM_DAEMON
gcryptrnd_SOURCES = gcryptrnd.c
diff --git a/src/dumpsexp.c b/src/dumpsexp.c
index 0e64c8b5..920c0485 100644
--- a/src/dumpsexp.c
+++ b/src/dumpsexp.c
@@ -22,6 +22,11 @@
#include <assert.h>
#include <stdarg.h>
#include <errno.h>
+/* For a native WindowsCE binary we need to include gpg-error.h to
+ provide a replacement for strerror. */
+#ifdef __MINGW32CE__
+# include <gpg-error.h>
+#endif
#define PGM "dumpsexp"
#define MYVERSION_LINE PGM " (Libgcrypt) " VERSION
diff --git a/src/g10lib.h b/src/g10lib.h
index 7deb90c4..a7d2e011 100644
--- a/src/g10lib.h
+++ b/src/g10lib.h
@@ -201,6 +201,9 @@ char *stpcpy (char *a, const char *b);
int strcasecmp (const char *a, const char *b) _GCRY_GCC_ATTR_PURE;
#endif
+#include "../compat/libcompat.h"
+
+
/* Macros used to rename missing functions. */
#ifndef HAVE_STRTOUL
#define strtoul(a,b,c) ((unsigned long)strtol((a),(b),(c)))
diff --git a/src/global.c b/src/global.c
index a69513e7..6b8a4d4e 100644
--- a/src/global.c
+++ b/src/global.c
@@ -566,6 +566,8 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr)
default:
+ /* A call to make sure that the dummy code is linked in. */
+ _gcry_compat_identification ();
err = GPG_ERR_INV_OP;
}
@@ -742,7 +744,7 @@ do_malloc (size_t n, unsigned int flags, void **mem)
/* Make sure that ERRNO has been set in case a user supplied
memory handler didn't it correctly. */
if (!errno)
- errno = ENOMEM;
+ gpg_err_set_errno (ENOMEM);
err = gpg_err_code_from_errno (errno);
}
else
@@ -805,7 +807,7 @@ gcry_realloc (void *a, size_t n)
else
p = _gcry_private_realloc (a, n);
if (!p && !errno)
- errno = ENOMEM;
+ gpg_err_set_errno (ENOMEM);
return p;
}
@@ -827,7 +829,7 @@ gcry_free (void *p)
_gcry_private_free (p);
if (save_errno)
- errno = save_errno;
+ gpg_err_set_errno (save_errno);
}
void *
@@ -840,7 +842,7 @@ gcry_calloc (size_t n, size_t m)
defined. */
if (m && bytes / m != n)
{
- errno = ENOMEM;
+ gpg_err_set_errno (ENOMEM);
return NULL;
}
@@ -860,7 +862,7 @@ gcry_calloc_secure (size_t n, size_t m)
defined. */
if (m && bytes / m != n)
{
- errno = ENOMEM;
+ gpg_err_set_errno (ENOMEM);
return NULL;
}
@@ -958,7 +960,7 @@ gcry_xcalloc( size_t n, size_t m )
nbytes = n * m;
if (m && nbytes / m != n)
{
- errno = ENOMEM;
+ gpg_err_set_errno (ENOMEM);
_gcry_fatal_error(gpg_err_code_from_errno (errno), NULL );
}
@@ -976,7 +978,7 @@ gcry_xcalloc_secure( size_t n, size_t m )
nbytes = n * m;
if (m && nbytes / m != n)
{
- errno = ENOMEM;
+ gpg_err_set_errno (ENOMEM);
_gcry_fatal_error(gpg_err_code_from_errno (errno), NULL );
}
diff --git a/src/hmac256.c b/src/hmac256.c
index b2f83dd0..a1383738 100644
--- a/src/hmac256.c
+++ b/src/hmac256.c
@@ -56,6 +56,15 @@
# include <fcntl.h> /* We need setmode(). */
#endif
+/* For a native WindowsCE binary we need to include gpg-error.h to
+ provide a replacement for strerror. In other cases we need a
+ replacement macro for gpg_err_set_errno. */
+#ifdef __MINGW32CE__
+# include <gpg-error.h>
+#else
+# define gpg_err_set_errno(a) (errno = (a))
+#endif
+
#include "hmac256.h"
@@ -502,7 +511,7 @@ _gcry_hmac256_file (void *result, size_t resultsize, const char *filename,
if (digestlen > resultsize)
{
_gcry_hmac256_release (hd);
- errno = EINVAL;
+ gpg_err_set_errno (EINVAL);
return -1;
}
memcpy (result, digest, digestlen);
diff --git a/src/secmem.c b/src/secmem.c
index a12af58a..48150d5f 100644
--- a/src/secmem.c
+++ b/src/secmem.c
@@ -319,18 +319,23 @@ lock_pool (void *p, size_t n)
/* QNX does not page at all, so the whole secure memory stuff does
* not make much sense. However it is still of use because it
* wipes out the memory on a free().
- * Therefore it is sufficient to suppress the warning
- */
+ * Therefore it is sufficient to suppress the warning. */
+ (void)p;
+ (void)n;
#elif defined (HAVE_DOSISH_SYSTEM) || defined (__CYGWIN__)
/* It does not make sense to print such a warning, given the fact that
- * this whole Windows !@#$% and their user base are inherently insecure
- */
+ * this whole Windows !@#$% and their user base are inherently insecure. */
+ (void)p;
+ (void)n;
#elif defined (__riscos__)
- /* no virtual memory on RISC OS, so no pages are swapped to disc,
+ /* No virtual memory on RISC OS, so no pages are swapped to disc,
* besides we don't have mmap, so we don't use it! ;-)
- * But don't complain, as explained above.
- */
+ * But don't complain, as explained above. */
+ (void)p;
+ (void)n;
#else
+ (void)p;
+ (void)n;
log_info ("Please note that you don't have secure memory on this system\n");
#endif
}
diff --git a/tests/ChangeLog b/tests/ChangeLog
index e4776cfd..09397f99 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2010-01-21 Werner Koch <wk@g10code.com>
+
+ * benchmark.c [_GCRYPT_IN_LIBGCRYPT]: Include libcompat.h.
+ (start_timer, stop_timer) [__MINGW32CE__]: Use GetThreadTimes.
+ * Makefile.am (LDADD): Add libcompat.
+
2009-12-10 Werner Koch <wk@g10code.com>
* basic.c (check_ctr_cipher): Add some return code checks.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b2c12398..8e05befd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -36,7 +36,7 @@ TESTS += benchmark
AM_CPPFLAGS = -I../src -I$(top_srcdir)/src
AM_CFLAGS = $(GPG_ERROR_CFLAGS)
-LDADD = ../src/libgcrypt.la $(DL_LIBS)
+LDADD = ../src/libgcrypt.la $(DL_LIBS) ../compat/libcompat.la
EXTRA_PROGRAMS = testapi pkbench
noinst_PROGRAMS = $(TESTS) fipsdrv rsacvt
diff --git a/tests/benchmark.c b/tests/benchmark.c
index f3a110bb..ab2aeb29 100644
--- a/tests/benchmark.c
+++ b/tests/benchmark.c
@@ -32,6 +32,7 @@
#ifdef _GCRYPT_IN_LIBGCRYPT
# include "../src/gcrypt.h"
+# include "../compat/libcompat.h"
#else
# include <gcrypt.h>
#endif
@@ -290,9 +291,15 @@ static void
start_timer (void)
{
#ifdef _WIN32
+#ifdef __MINGW32CE__
+ GetThreadTimes (GetCurrentThread (),
+ &started_at.creation_time, &started_at.exit_time,
+ &started_at.kernel_time, &started_at.user_time);
+#else
GetProcessTimes (GetCurrentProcess (),
&started_at.creation_time, &started_at.exit_time,
&started_at.kernel_time, &started_at.user_time);
+#endif
stopped_at = started_at;
#else
struct tms tmp;
@@ -306,9 +313,15 @@ static void
stop_timer (void)
{
#ifdef _WIN32
+#ifdef __MINGW32CE__
+ GetThreadTimes (GetCurrentThread (),
+ &stopped_at.creation_time, &stopped_at.exit_time,
+ &stopped_at.kernel_time, &stopped_at.user_time);
+#else
GetProcessTimes (GetCurrentProcess (),
&stopped_at.creation_time, &stopped_at.exit_time,
&stopped_at.kernel_time, &stopped_at.user_time);
+#endif
#else
struct tms tmp;