Add OpenAFS build machinery for libhcrypto
authorSimon Wilkinson <sxw@your-file-system.com>
Wed, 7 Apr 2010 20:45:39 +0000 (21:45 +0100)
committerDerrick Brashear <shadow@dementia.org>
Thu, 19 Aug 2010 16:23:26 +0000 (09:23 -0700)
Add an OpenAFS build environment for the symmetric algorithms in
libhcrypto.

Change-Id: I0d971433fe0130854a7c50cd9107af02893b1d58
Reviewed-on: http://gerrit.openafs.org/2575
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

15 files changed:
Makefile.in
acinclude.m4
configure.ac
src/cf/retsigtype.m4 [new file with mode: 0644]
src/config/Makefile.config.in
src/crypto/hcrypto/.gitignore [new file with mode: 0644]
src/crypto/hcrypto/Makefile.in [new file with mode: 0644]
src/crypto/hcrypto/config.h [new file with mode: 0644]
src/crypto/hcrypto/engine.c [new file with mode: 0644]
src/crypto/hcrypto/engine.h [new file with mode: 0644]
src/crypto/hcrypto/getarg.h [new file with mode: 0644]
src/crypto/hcrypto/heim_threads.h [new file with mode: 0644]
src/crypto/hcrypto/krb5-types.h [new file with mode: 0644]
src/crypto/hcrypto/libafshcrypto.map [new file with mode: 0644]
src/crypto/hcrypto/roken.h [new file with mode: 0644]

index bac6755..33a4436 100644 (file)
@@ -109,7 +109,7 @@ packages: dest
                echo Not building packages for ${SYS_NAME} ;; \
        esac
 
-${TOP_INCDIR}/afs ${TOP_INCDIR}/rx ${TOP_INCDIR}/des ${TOP_LIBDIR} ${TOP_JLIBDIR}:
+${TOP_INCDIR}/afs ${TOP_INCDIR}/rx ${TOP_INCDIR}/des ${TOP_INCDIR}/hcrypto ${TOP_LIBDIR} ${TOP_JLIBDIR}:
        mkdir -p $@
 
 install_dirs: force
@@ -135,7 +135,7 @@ dest_dirs: force
        mkdir -p ${DEST}/root.server/etc
        mkdir -p ${DEST}/root.server/usr/afs/bin
 
-prelude: ${TOP_INCDIR}/afs ${TOP_INCDIR}/rx ${TOP_INCDIR}/des ${TOP_LIBDIR}
+prelude: ${TOP_INCDIR}/afs ${TOP_INCDIR}/rx ${TOP_INCDIR}/des ${TOP_INCDIR}/hcrypto ${TOP_LIBDIR}
 
 project: cmd comerr 
 
@@ -165,6 +165,9 @@ cmd: comerr
                ${COMPILE_PART1} cmd ${COMPILE_PART2} ;; \
        esac
 
+hcrypto:
+       +${COMPILE_PART1} crypto/hcrypto ${COMPILE_PART2}
+
 lwp: util lwp_depinstall
        +${COMPILE_PART1} lwp ${COMPILE_PART2}
 
@@ -648,7 +651,7 @@ build_tools: config des comerr rxgen
 finale: project cmd comerr afsd butc tbutc tbudb @ENABLE_KERNEL_MODULE@ libuafs audit kauth log \
        ptserver tptserver scout bu_utils ubik uss bozo @VFSCK@ volser tvolser tsalvaged \
        dviced dvolser \
-       venus update xstat afsmonitor rxdebug libafsrpc \
+       venus update xstat afsmonitor rxdebug libafsrpc hcrypto \
        libafsauthent shlibafsrpc shlibafsauthent libadmin man-pages \
        platform kopenafs authtools
        +${COMPILE_PART1} finale ${COMPILE_PART2}
@@ -656,7 +659,7 @@ finale: project cmd comerr afsd butc tbutc tbudb @ENABLE_KERNEL_MODULE@ libuafs
 finale_nolibafs: project cmd comerr afsd butc tbutc tbudb libuafs audit kauth log \
        ptserver tptserver scout bu_utils ubik tubik uss bozo @VFSCK@ volser tvolser tsalvaged \
        dviced dvolser \
-       venus update xstat afsmonitor rxdebug libafsrpc \
+       venus update xstat afsmonitor rxdebug libafsrpc hcrypto \
        libafsauthent shlibafsrpc shlibafsauthent libadmin man-pages \
        platform kopenafs authtools
        +${COMPILE_PART1} finale ${COMPILE_PART2}
@@ -772,6 +775,7 @@ clean2:
        -${COMPILE_PART1} libafs ${COMPILE_CLEAN}
        -${COMPILE_PART1} libuafs ${COMPILE_CLEAN}
        -${COMPILE_PART1} tests ${COMPILE_CLEAN}
+       -${COMPILE_PART1} crypto/hcrypto ${COMPILE_CLEAN}
        -(cd src/libafs; /bin/rm -rf afs afsint config rx)
        -(cd src/libuafs; /bin/rm -rf afs afsint config rx des)
        -/bin/rm -rf ${TOP_INCDIR} ${TOP_LIBDIR} ${TOP_JLIBDIR}
@@ -812,6 +816,7 @@ distclean: clean
        src/config/Makefile.version-NOCML \
        src/config/shlib-build \
        src/config/shlib-install \
+       src/crypto/hcrypto/Makefile \
        src/des/Makefile \
        src/des/test/Makefile \
        src/dir/Makefile \
index 5478a22..865e855 100644 (file)
@@ -1201,7 +1201,7 @@ AC_CHECK_HEADERS(stdlib.h string.h unistd.h fcntl.h sys/time.h sys/file.h grp.h)
 AC_CHECK_HEADERS(netinet/in.h netdb.h sys/fcntl.h sys/mnttab.h sys/mntent.h)
 AC_CHECK_HEADERS(mntent.h sys/vfs.h sys/param.h sys/fs_types.h sys/fstyp.h)
 AC_CHECK_HEADERS(sys/mount.h strings.h termios.h signal.h sys/pag.h)
-AC_CHECK_HEADERS(windows.h direct.h sys/ipc.h sys/resource.h)
+AC_CHECK_HEADERS(windows.h direct.h sys/ipc.h sys/resource.h sys/un.h)
 AC_CHECK_HEADERS(security/pam_modules.h ucontext.h regex.h sys/statvfs.h sys/statfs.h sys/bitypes.h)
 AC_CHECK_HEADERS(linux/errqueue.h,,,[#include <linux/types.h>])
 AC_CHECK_HEADERS(et/com_err.h)
@@ -1248,6 +1248,7 @@ AC_CHECK_FUNCS(setprogname getprogname sigaction mkstemp vsnprintf strerror strc
 AC_CHECK_FUNCS(setvbuf vsyslog getcwd)
 AC_CHECK_FUNCS(regcomp regexec regerror)
 AC_CHECK_FUNCS(fseeko64 ftello64)
+AC_CHECK_FUNCS(setitimer issetugidi getuid geteuid getgid getegid)
 AC_MSG_CHECKING([for POSIX regex library])
 if test "$ac_cv_header_regex_h" = "yes" && \
        test "$ac_cv_func_regcomp" = "yes" && \
@@ -1260,6 +1261,7 @@ else
 fi
 
 AC_TYPE_SIGNAL
+OPENAFS_RETSIGTYPE
 AC_CHECK_SIZEOF(void *)
 AC_CHECK_SIZEOF(unsigned long long)
 AC_CHECK_SIZEOF(unsigned long)
@@ -1386,7 +1388,6 @@ AC_SUBST(HELPER_SPLINTCFG)
 
 mkdir -p ${TOP_OBJDIR}/src/JAVA/libjafs
 
-
 dnl Check to see if crypt lives in a different library
 AC_CHECK_LIB(crypt, crypt, LIB_crypt="-lcrypt")
 AC_SUBST(LIB_crypt)
@@ -1408,4 +1409,7 @@ struct labeltest struct_labeltest = {
 [AC_MSG_RESULT(no)
 ])
 
+dnl Eventually, this will look for the system one, or for OpenSSL
+LIB_hcrypto="-lafshcrypto"
+AC_SUBST(LIB_hcrypto)
 ])
index ebfacdc..7f8e0ce 100644 (file)
@@ -131,6 +131,7 @@ src/config/Makefile.version-CML \
 src/config/Makefile.version-NOCML \
 src/config/shlib-build \
 src/config/shlib-install \
+src/crypto/hcrypto/Makefile \
 src/des/Makefile \
 src/des/test/Makefile \
 src/dir/Makefile \
diff --git a/src/cf/retsigtype.m4 b/src/cf/retsigtype.m4
new file mode 100644 (file)
index 0000000..ab8577b
--- /dev/null
@@ -0,0 +1,18 @@
+dnl
+dnl $Id$
+dnl
+dnl Figure out return type of signal handlers, and define SIGRETURN macro
+dnl that can be used to return from one
+dnl
+AC_DEFUN([OPENAFS_RETSIGTYPE],[
+AC_TYPE_SIGNAL
+if test "$ac_cv_type_signal" = "void" ; then
+       AC_DEFINE(VOID_RETSIGTYPE, 1, [Define if signal handlers return void.])
+fi
+
+AH_BOTTOM([#ifdef VOID_RETSIGTYPE
+#define SIGRETURN(x) return
+#else
+#define SIGRETURN(x) return (RETSIGTYPE)(x)
+#endif])
+])
index 24e16fd..4199b5a 100644 (file)
@@ -51,6 +51,7 @@ LD = @LD@
 LEX = @LEX@
 LIB_AFSDB = @LIB_AFSDB@
 LIB_crypt = @LIB_crypt@
+LIB_hcrypto = @LIB_hcrypto@
 LIBS = @LIBS@
 LIB_LIBINTL = @LIB_libintl@
 LINUX_KERNEL_PATH = @LINUX_KERNEL_PATH@
diff --git a/src/crypto/hcrypto/.gitignore b/src/crypto/hcrypto/.gitignore
new file mode 100644 (file)
index 0000000..b6d8a68
--- /dev/null
@@ -0,0 +1,2 @@
+/test_cipher
+/libafshcrypto.exp
diff --git a/src/crypto/hcrypto/Makefile.in b/src/crypto/hcrypto/Makefile.in
new file mode 100644 (file)
index 0000000..10a2aea
--- /dev/null
@@ -0,0 +1,265 @@
+# Copyright 2010, Your File System Inc
+# All rights reserved
+#
+# This software has been released under the terms of the BSD License
+# For details, see the LICENSE file in the top level source directory
+
+# API version. Must be incremented whenever something changes.
+LIBMAJOR=1
+LIBMINOR=1
+
+srcdir=@srcdir@
+include @TOP_OBJDIR@/src/config/Makefile.config
+
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+
+CC=${MT_CC}
+CFLAGS=${COMMON_CFLAGS} ${MT_CFLAGS} ${SHLIB_CFLAGS}
+
+HEADERS= ${TOP_INCDIR}/hcrypto/aes.h \
+        ${TOP_INCDIR}/hcrypto/des.h \
+        ${TOP_INCDIR}/hcrypto/engine.h \
+        ${TOP_INCDIR}/hcrypto/evp.h \
+        ${TOP_INCDIR}/hcrypto/evp-hcrypto.h \
+        ${TOP_INCDIR}/hcrypto/evp-cc.h \
+        ${TOP_INCDIR}/hcrypto/hmac.h \
+        ${TOP_INCDIR}/hcrypto/md2.h \
+        ${TOP_INCDIR}/hcrypto/md4.h \
+        ${TOP_INCDIR}/hcrypto/md5.h \
+        ${TOP_INCDIR}/hcrypto/rand.h \
+        ${TOP_INCDIR}/hcrypto/rc2.h \
+        ${TOP_INCDIR}/hcrypto/rc4.h \
+        ${TOP_INCDIR}/hcrypto/sha.h \
+        ${TOP_INCDIR}/hcrypto/ui.h
+
+SHLIBOBJ= libafshcrypto.${SHLIB_SUFFIX}.${LIBMAJOR}.${LIBMINOR}
+
+all: ${HEADERS} ${TOP_LIBDIR}/${SHLIBOBJ} ${TOP_LIBDIR}/libafshcrypto.a
+
+install: libafshcrypto.a ${SHLIBOBJ}
+       ${TOP_OBJDIR}/src/config/shlib-install -d ${DESTDIR}${libdir} \
+               -l libafshcrypto -M ${LIBMAJOR} -m ${LIBMINOR}
+       ${INSTALL_DATA} libafshcrypto.a ${DESTDIR}${libdir}/libafshcrypto.a
+
+dest: libafshcrypto.a ${SHLIBOBJ}
+       ${TOP_OBJDIR}/src/config/shlib-install -d ${DEST}/lib \
+               -l libafshcrypto -M ${LIBMAJOR} -m ${LIBMINOR}
+       ${INSTALL_DATA} libafshcrypto.a ${DEST}/lib/libafshcrypto.a
+
+clean:
+       $(RM) -f ${OBJECTS} ${SHLIBOBJ} libafshcrypto.a libafshcrypto.exp \
+                test_cipher test_cipher.o hex.o
+
+# Ignore for now : rand-egd.o
+
+OBJECTS= aes.o camellia.o camellia-ntt.o des.o engine.o evp.o \
+        evp-hcrypto.o evp-cc.o hmac.o md2.o md4.o md5.o pkcs5.o \
+        rand-egd.o rand-fortuna.o rand-timer.o rand-unix.o rand.o \
+        rc2.o rc4.o rijndael-alg-fst.o rnd_keys.o sha.o sha256.o ui.o \
+        cloexec.o ct.o issuid.o net_read.o net_write.o strlcpy.o
+
+UPSTREAM= ${TOP_SRCDIR}/external/heimdal
+
+CCRULE = ${CC} -I${TOP_INCDIR}/hcrypto ${CFLAGS} -I${UPSTREAM}/hcrypto -c $?
+
+${TOP_LIBDIR}/${SHLIBOBJ}: ${SHLIBOBJ}
+       ${TOP_OBJDIR}/src/config/shlib-install -d ${TOP_LIBDIR} \
+               -l libafshcrypto -M ${LIBMAJOR} -m ${LIBMINOR}
+
+${SHLIBOBJ}: ${OBJECTS} libafshcrypto.map
+       ${TOP_OBJDIR}/src/config/shlib-build -d $(srcdir) -l libafshcrypto \
+               -M ${LIBMAJOR} -m ${LIBMINOR} -- \
+               ${OBJECTS} ${MT_LIBS}
+
+libafshcrypto.a: ${OBJECTS}
+       $(RM) -f $@
+       $(AR) crv $@ ${OBJECTS}
+       $(RANLIB) $@
+
+test_cipher: test_cipher.o hex.o libafshcrypto.a
+       ${CC} ${LDFLAGS} -o test_cipher test_cipher.o hex.o libafshcrypto.a
+
+${TOP_INCDIR}/hcrypto/aes.h: ${UPSTREAM}/hcrypto/aes.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/bn.h: ${UPSTREAM}/hcrypto/bn.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/des.h: ${UPSTREAM}/hcrypto/des.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/dh.h: ${UPSTREAM}/hcrypto/dh.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/dsa.h: ${UPSTREAM}/hcrypto/dsa.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/engine.h: engine.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/evp.h: ${UPSTREAM}/hcrypto/evp.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/evp-hcrypto.h: ${UPSTREAM}/hcrypto/evp-hcrypto.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/evp-cc.h: ${UPSTREAM}/hcrypto/evp-cc.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/hmac.h: ${UPSTREAM}/hcrypto/hmac.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/md2.h: ${UPSTREAM}/hcrypto/md2.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/md4.h: ${UPSTREAM}/hcrypto/md4.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/md5.h: ${UPSTREAM}/hcrypto/md5.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/pkcs12.h: ${UPSTREAM}/hcrypto/pkcs12.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/rand.h: ${UPSTREAM}/hcrypto/rand.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/rc2.h: ${UPSTREAM}/hcrypto/rc2.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/rc4.h: ${UPSTREAM}/hcrypto/rc4.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/rsa.h: ${UPSTREAM}/hcrypto/rsa.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/sha.h: ${UPSTREAM}/hcrypto/sha.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/hcrypto/ui.h: ${UPSTREAM}/hcrypto/ui.h
+       ${INSTALL_DATA} $? $@
+
+${TOP_LIBDIR}/libafshcrypto.a: libafshcrypto.a
+       ${INSTALL_DATA} $? $@
+
+aes.o: ${UPSTREAM}/hcrypto/aes.c
+       ${CCRULE}
+
+bn.o: ${UPSTREAM}/hcrypto/bn.c
+       ${CCRULE}
+
+camellia.o: ${UPSTREAM}/hcrypto/camellia.c
+       ${CCRULE}
+
+camellia-ntt.o: ${UPSTREAM}/hcrypto/camellia-ntt.c
+       ${CCRULE}
+
+des.o: ${UPSTREAM}/hcrypto/des.c
+       ${CCRULE}
+
+dh-imath.o: ${UPSTREAM}/hcrypto/dh-imath.c
+       ${CCRULE}
+
+dsa.o: ${UPSTREAM}/hcrypto/dsa.c
+       ${CCRULE}
+
+evp.o: ${UPSTREAM}/hcrypto/evp.c
+       ${CCRULE}
+
+evp-hcrypto.o: ${UPSTREAM}/hcrypto/evp-hcrypto.c
+       ${CCRULE}
+
+evp-cc.o: ${UPSTREAM}/hcrypto/evp-cc.c
+       ${CCRULE}
+
+engine.o: engine.c
+       ${CCRULE}
+
+hmac.o: ${UPSTREAM}/hcrypto/hmac.c
+       ${CCRULE}
+
+md2.o: ${UPSTREAM}/hcrypto/md2.c
+       ${CCRULE}
+
+md4.o: ${UPSTREAM}/hcrypto/md4.c
+       ${CCRULE}
+
+md5.o: ${UPSTREAM}/hcrypto/md5.c
+       ${CCRULE}
+
+pkcs5.o: ${UPSTREAM}/hcrypto/pkcs5.c
+       ${CCRULE}
+
+pkcs12.o: ${UPSTREAM}/hcrypto/pkcs12.c
+       ${CCRULE}
+
+rand-egd.o: ${UPSTREAM}/hcrypto/rand-egd.c
+       ${CCRULE}
+
+rand-fortuna.o: ${UPSTREAM}/hcrypto/rand-fortuna.c
+       ${CCRULE}
+
+rand-timer.o: ${UPSTREAM}/hcrypto/rand-timer.c
+       ${CCRULE}
+
+# The upstream code has a const pointer warning, which we need to suppress */
+rand-unix.o: ${UPSTREAM}/hcrypto/rand-unix.c
+       ${CCRULE} @CFLAGS_NOERROR@
+
+rand.o: ${UPSTREAM}/hcrypto/rand.c
+       ${CCRULE}
+
+rc2.o: ${UPSTREAM}/hcrypto/rc2.c
+       ${CCRULE}
+
+rc4.o: ${UPSTREAM}/hcrypto/rc4.c
+       ${CCRULE}
+
+rijndael-alg-fst.o: ${UPSTREAM}/hcrypto/rijndael-alg-fst.c
+       ${CCRULE}
+
+rnd_keys.o: ${UPSTREAM}/hcrypto/rnd_keys.c
+       ${CCRULE}
+
+rsa.o: ${UPSTREAM}/hcrypto/rsa.c
+       ${CCRULE}
+
+rsa-gmp.o: ${UPSTREAM}/hcrypto/rsa-gmp.c
+       ${CCRULE}
+
+rsa-imath.o: ${UPSTREAM}/hcrypto/rsa-imath.c
+       ${CCRULE}
+
+sha.o: ${UPSTREAM}/hcrypto/sha.c
+       ${CCRULE}
+
+sha256.o: ${UPSTREAM}/hcrypto/sha256.c
+       ${CCRULE}
+
+ui.o: ${UPSTREAM}/hcrypto/ui.c
+       ${CCRULE}
+
+test_cipher.o: ${UPSTREAM}/hcrypto/test_cipher.c
+       ${CCRULE} -I${UPSTREAM}/roken/
+
+cloexec.o: ${UPSTREAM}/roken/cloexec.c
+       ${CCRULE}
+
+ct.o: ${UPSTREAM}/roken/ct.c
+       ${CCRULE}
+
+hex.o: ${UPSTREAM}/roken/hex.c
+       ${CCRULE}
+
+issuid.o: ${UPSTREAM}/roken/issuid.c
+       ${CCRULE}
+
+net_read.o: ${UPSTREAM}/roken/net_read.c
+       ${CCRULE}
+
+net_write.o: ${UPSTREAM}/roken/net_write.c
+       ${CCRULE}
+
+strlcpy.o: ${UPSTREAM}/roken/strlcpy.c
+       ${CCRULE}
diff --git a/src/crypto/hcrypto/config.h b/src/crypto/hcrypto/config.h
new file mode 100644 (file)
index 0000000..8e06e48
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2010 Your File System Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <afsconfig.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <time.h>
+#include <fcntl.h>
+#include <signal.h>
+
+#ifndef AFS_NT40_ENV
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <inttypes.h>
+#include <sys/time.h>
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_TERMIOS_H
+#include <termios.h>
+#endif
+
+#ifdef HAVE_DIRENT_H
+#include <dirent.h>
+#endif
+
+#if defined(AFS_NT40_ENV)
+# define inline __inline
+#elif defined(AFS_HPUX_ENV) || defined(AFS_USR_HPUX_ENV)
+# define inline
+#elif defined(AFS_AIX_ENV) || defined(AFS_USR_AIX_ENV)
+# define inline
+#elif defined(AFS_SGI_ENV) || defined(AFS_USR_SGI_ENV)
+# define inline
+#elif defined(AFS_NBSD_ENV)
+# define inline __inline __attribute__((always_inline))
+#endif
+
diff --git a/src/crypto/hcrypto/engine.c b/src/crypto/hcrypto/engine.c
new file mode 100644 (file)
index 0000000..61c07ce
--- /dev/null
@@ -0,0 +1,23 @@
+/* Unpicking the public key portions of hcrypto (which we're not building
+ * in the OpenAFS version) from the ENGINE functionality would be complicated.
+ * So, for now, just disable all of the ENGINE code - we don't currently
+ * support it.
+ */
+
+#include <config.h>
+#include <engine.h>
+
+int
+ENGINE_finish(const ENGINE *dummy) {
+  return -1;
+}
+
+int
+ENGINE_up_ref(const ENGINE * dummy) {
+  return -1;
+}
+
+const RAND_METHOD *
+ENGINE_get_RAND(const ENGINE * dummy) {
+  return NULL;
+}
diff --git a/src/crypto/hcrypto/engine.h b/src/crypto/hcrypto/engine.h
new file mode 100644 (file)
index 0000000..e0d7291
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef OPENAFS_HCRYPTO_ENGINE_H
+#define OPENAFS_HCRYPTO_ENGINE_H
+
+typedef struct hc_engine ENGINE;
+
+#include <hcrypto/rand.h>
+
+
+int     ENGINE_finish(const ENGINE *);
+int     ENGINE_up_ref(const ENGINE *);
+const RAND_METHOD *     ENGINE_get_RAND(const ENGINE *);
+
+#endif
diff --git a/src/crypto/hcrypto/getarg.h b/src/crypto/hcrypto/getarg.h
new file mode 100644 (file)
index 0000000..011fac1
--- /dev/null
@@ -0,0 +1,37 @@
+/* Just disable the getarg functionality for now */
+
+struct getargs{
+    const char *long_name;
+    char short_name;
+    enum { arg_integer,
+           arg_string,
+           arg_flag,
+           arg_negative_flag,
+           arg_strings,
+           arg_double,
+           arg_collect,
+           arg_counter
+    } type;
+    void *value;
+    const char *help;
+    const char *arg_help;
+};
+
+static inline int
+getarg(struct getargs *args, size_t num_args,
+       int argc, char **argv, int *goptind) {
+  return 0;
+}
+
+static inline void
+arg_printusage (struct getargs *args,
+                size_t num_args,
+                const char *progname,
+                const char *extra_string) {
+  return;
+}
+
+static inline void
+print_version(const char *str) {
+  return;
+}
diff --git a/src/crypto/hcrypto/heim_threads.h b/src/crypto/hcrypto/heim_threads.h
new file mode 100644 (file)
index 0000000..9410897
--- /dev/null
@@ -0,0 +1,8 @@
+#include <pthread.h>
+
+#define HEIMDAL_MUTEX pthread_mutex_t
+#define HEIMDAL_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+#define HEIMDAL_MUTEX_init(m) pthread_mutex_init(m, NULL)
+#define HEIMDAL_MUTEX_lock(m) pthread_mutex_lock(m)
+#define HEIMDAL_MUTEX_unlock(m) pthread_mutex_unlock(m)
+#define HEIMDAL_MUTEX_destroy(m) pthread_mutex_destroy(m)
diff --git a/src/crypto/hcrypto/krb5-types.h b/src/crypto/hcrypto/krb5-types.h
new file mode 100644 (file)
index 0000000..d1ab56a
--- /dev/null
@@ -0,0 +1 @@
+/* This file intentionally left blank */
diff --git a/src/crypto/hcrypto/libafshcrypto.map b/src/crypto/hcrypto/libafshcrypto.map
new file mode 100644 (file)
index 0000000..00ab894
--- /dev/null
@@ -0,0 +1,27 @@
+# Copyright 2010 Your File System Inc
+# All Rights Reserved
+#
+# This software has been released under the terms of the BSD License. For
+# details, see the LICENSE file in the top level source directory.
+
+{
+    global:
+       hc_DES_cbc_encrypt;
+       hc_DES_cbc_cksum;
+       hc_DES_ecb_encrypt;
+       hc_DES_init_random_number_generator;
+       hc_DES_key_sched;
+       hc_DES_new_random_key;
+       hc_DES_pcbc_encrypt;
+       hc_DES_set_odd_parity;
+       hc_DES_string_to_key;
+       hc_MD4_Final;
+       hc_MD4_Init;
+       hc_MD4_Update;
+       hc_MD5_Final;
+       hc_MD5_Init;
+       hc_MD5_Update;
+       hc_UI_UTIL_read_pw_string;
+    local:
+       *;
+};
diff --git a/src/crypto/hcrypto/roken.h b/src/crypto/hcrypto/roken.h
new file mode 100644 (file)
index 0000000..93805b5
--- /dev/null
@@ -0,0 +1,41 @@
+#define rk_UNCONST(x) ((void *)(uintptr_t)(const void *)(x))
+
+#ifndef min
+#define min(a,b) (((a)<(b))?(a):(b))
+#endif
+
+#ifndef ROKEN_LIB_FUNCTION
+#ifdef _WIN32
+#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL     __cdecl
+#else
+#define ROKEN_LIB_FUNCTION
+#define ROKEN_LIB_CALL
+#endif
+#endif
+
+typedef int rk_socket_t;
+
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
+    ct_memcmp(const void *, const void *, size_t);
+
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL rk_cloexec(int);
+
+ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL rk_cloexec_file(FILE *);
+
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
+    net_write (rk_socket_t, const void *, size_t);
+
+ROKEN_LIB_FUNCTION ssize_t ROKEN_LIB_CALL
+    net_read (rk_socket_t, void *, size_t);
+
+ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL issuid(void);
+
+#ifndef HAVE_STRLCPY
+#define strlcpy rk_strlcpy
+ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL
+    strlcpy (char *, const char *, size_t);
+#endif
+
+/* This is a bodge, but it's only used by the tests */
+#define emalloc(x) malloc(x)