[Forensics-changes] [SCM] debian-forensics/afflib branch, debian, updated. debian/3.5.10+dfsg-1-14-gf304d20

Christophe Monniez christophe.monniez at fccu.be
Tue May 4 12:05:00 UTC 2010


The following commit has been merged in the debian branch:
commit 37cb92db19e4d90cd708fc86309ea36dcc56d90b
Author: Christophe Monniez <christophe.monniez at fccu.be>
Date:   Tue May 4 13:22:32 2010 +0200

    Merging upstream version 3.5.12+dfsg.

diff --git a/ChangeLog b/ChangeLog
index a798c1f..69d7ff7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,57 @@
+2010-04-25  Simson L. Garfinkel  <simsong at imac2.local>
+
+	* configure.ac: version increased to 3.5.12
+
+	* Makefile.am (EXTRA_DIST): misc expat distribution removed.
+
+2010-04-25  Simson Garfinkel  <simsong at Silver-Surfer.local>
+
+	* configure.ac: version increased to 3.5.11
+
+2010-04-18  Simson Garfinkel  <simsong at Silver-Surfer.local>
+
+	* substantial modifications to compile under mingw
+	
+	* tools/afcrypto.cpp (check_file): replaced index() with strchr()
+	for WIN32
+
+	* lzma443/C/Common/Alloc.cpp: removed MidAlloc(), MidFree(),
+	SetLargePageSize(), BigAlloc() and BigFree() when compiling under mingw
+
+2010-04-17  Simson Garfinkel  <simsong at 96.sub-75-226-243.myvzw.com>
+
+	* configure.ac: patched for conditional inclusion of the win32
+	directory.
+
+2010-04-14  Simson Garfinkel  <simsong at Silver-Surfer.local>
+
+	* debian/ directory removed at the request of the debian project.
+
+2010-04-12  Ryan Mayer  <mrsolo at mayer-precision>
+
+	* lib/aftest.cpp (xmltest): now compiles without threaded_hash.h
+	(simson apparently forgot to add threaded_hash.h to the subversion repository....)
+
+	* tools/afinfo.cpp (print_info): now checks to see if fwrite() doesn't
+	write all the characters.
+
+	* tools/afcat.cpp (afcat): now checks to see if fwrite() doesn't
+	write all the characters.
+
+	* tools/afcrypto.cpp (usage): changed -d (debug) to -D. Added -e
+	option (decrypt.)
+
+2010-04-10  Simson Garfinkel  <simsong at Silver-Surfer.local>
+
+	* applied 03-bashism.patch, fixes a so-called bashism in a test script.
+	* applied 04-fix-afdiskprint.patch, fixes a grave bug which prevents
+	afdiskprint from starting at all.
+
+
+2010-04-09  Simson Garfinkel  <simsong at Silver-Surfer.local>
+
+	* tools/affuse.c (main): added explicit instructions to install fuse-devl
+
 2010-03-19  Simson L. Garfinkel  <simsong at Silver-SSD.local>
 
 	* configure.ac: updated version to 3.5.10
@@ -6,6 +60,8 @@
 
 	* tools/aff_bom.cpp: removed non-PD terms in copyright statement.
 
+	* tools/aff_bom.cpp: corrected spelling of postgraduate
+
 2010-03-14  Simson Garfinkel  <simsong at Silver-Surfer.local>
 
 	* configure.ac: increased version number to 3.5.9
diff --git a/Makefile.am b/Makefile.am
index d24125e..0ca68e3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = lib tools lzma443 win32 tests doc pyaff man
+SUBDIRS = lib tools lzma443 tests doc pyaff man
 
 pkgconfigdir = $(libdir)/pkgconfig
 
@@ -55,43 +55,6 @@ distribute_release:
 	ssh $(RELEASE_HOST) 'echo $(RELEASE).tar.gz > $(RELEASE_PATH)'
 	@echo Release $(RELEASE) uploaded to server
 
-DEBIAN_FILES = \
-        debian/afflib.install \
-        debian/afflib.dirs \
-        debian/afflib.docs \
-        debian/afflib.postinst.debhelper \
-        debian/afflib.postrm.debhelper \
-        debian/afflib-default.ex \
-        debian/afflib-dev.dirs \
-        debian/afflib-dev.docs \
-        debian/afflib-dev.install \
-        debian/afflib-tools.dirs \
-        debian/afflib-tools.docs \
-        debian/afflib-tools.install \
-        debian/afflib.doc-base.EX \
-        debian/changelog \
-        debian/changelog.in \
-        debian/compat \
-        debian/control \
-        debian/copyright \
-        debian/cron.d.ex \
-        debian/emacsen-install.ex \
-        debian/emacsen-startup.ex \
-        debian/emacsen-remove.ex \
-        debian/init.d.ex \
-        debian/manpage.1.ex \
-        debian/manpage.sgml.ex \
-        debian/manpage.xml.ex \
-        debian/menu.ex \
-        debian/rules \
-        debian/postinst.ex \
-        debian/postrm.ex \
-        debian/preinst.ex \
-        debian/prerm.ex \
-        debian/shlibs.local.ex \
-        debian/shlibs.local.ex.in \
-        debian/watch.ex
-
 DOCS = BUGLIST.txt README_Linux.txt README_Win32.txt \
 	doc/crypto_doc.txt \
 	doc/crypto_design.txt \
@@ -100,15 +63,22 @@ DOCS = BUGLIST.txt README_Linux.txt README_Win32.txt \
 	doc/announce_2.2.txt
 
 EXTRA_DIST = $(DOCS) \
-	$(DEBIAN_FILES) \
-	acx_pthread.m4 \
+	bootstrap.sh \
+	bootstrap_mingw.sh \
+	m4/acx_pthread.m4 \
 	afflib.spec.in \
 	afflib.spec \
 	afflib.pc.in \
 	afflib.pubkey.asc \
-	misc/expat-2.0.1.tar.gz \
 	tests/encrypted.iso \
-	tests/encrypted.aff
+	tests/encrypted.aff \
+	win32/Changes.txt \
+	win32/Makefile.am.old \
+	win32/README_MSVC++.txt \
+	win32/affconfig.h \
+	win32/afflib.mak \
+	win32/make.bat
+
 
 #
 # Note: don't forget to run autoreconf when significant changes are made
diff --git a/Makefile.in b/Makefile.in
index 9ffff5e..e90a111 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -38,21 +38,19 @@ DIST_COMMON = README $(am__configure_deps) $(include_HEADERS) \
 	$(pkginclude_HEADERS) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(srcdir)/affconfig.h.in \
 	$(srcdir)/afflib.pc.in $(srcdir)/afflib.spec.in \
-	$(top_srcdir)/configure $(top_srcdir)/debian/changelog.in \
-	$(top_srcdir)/debian/shlibs.local.ex.in AUTHORS COPYING \
-	ChangeLog INSTALL NEWS compile config.guess config.sub depcomp \
-	install-sh ltmain.sh missing
+	$(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
+	compile config.guess config.sub depcomp install-sh ltmain.sh \
+	missing
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/acx_pthread.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \
+	$(top_srcdir)/m4/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno config.status.lineno
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = affconfig.h
-CONFIG_CLEAN_FILES = debian/changelog debian/shlibs.local.ex \
-	afflib.spec afflib.pc
+CONFIG_CLEAN_FILES = afflib.spec afflib.pc
 SOURCES =
 DIST_SOURCES =
 RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
@@ -230,7 +228,7 @@ sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-SUBDIRS = lib tools lzma443 win32 tests doc pyaff man
+SUBDIRS = lib tools lzma443 tests doc pyaff man
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = afflib.pc
 include_HEADERS = 
@@ -247,43 +245,6 @@ RELEASE_SSH = $(RELEASE_USER)$(RELEASE_HOST):$(RELEASE_LOC)
 RELEASE = $(PACKAGE)-$(VERSION)
 AM_CFLAGS = -Wall
 AM_CPPFLAGS = -Wall
-DEBIAN_FILES = \
-        debian/afflib.install \
-        debian/afflib.dirs \
-        debian/afflib.docs \
-        debian/afflib.postinst.debhelper \
-        debian/afflib.postrm.debhelper \
-        debian/afflib-default.ex \
-        debian/afflib-dev.dirs \
-        debian/afflib-dev.docs \
-        debian/afflib-dev.install \
-        debian/afflib-tools.dirs \
-        debian/afflib-tools.docs \
-        debian/afflib-tools.install \
-        debian/afflib.doc-base.EX \
-        debian/changelog \
-        debian/changelog.in \
-        debian/compat \
-        debian/control \
-        debian/copyright \
-        debian/cron.d.ex \
-        debian/emacsen-install.ex \
-        debian/emacsen-startup.ex \
-        debian/emacsen-remove.ex \
-        debian/init.d.ex \
-        debian/manpage.1.ex \
-        debian/manpage.sgml.ex \
-        debian/manpage.xml.ex \
-        debian/menu.ex \
-        debian/rules \
-        debian/postinst.ex \
-        debian/postrm.ex \
-        debian/preinst.ex \
-        debian/prerm.ex \
-        debian/shlibs.local.ex \
-        debian/shlibs.local.ex.in \
-        debian/watch.ex
-
 DOCS = BUGLIST.txt README_Linux.txt README_Win32.txt \
 	doc/crypto_doc.txt \
 	doc/crypto_design.txt \
@@ -292,15 +253,21 @@ DOCS = BUGLIST.txt README_Linux.txt README_Win32.txt \
 	doc/announce_2.2.txt
 
 EXTRA_DIST = $(DOCS) \
-	$(DEBIAN_FILES) \
-	acx_pthread.m4 \
+	bootstrap.sh \
+	bootstrap_mingw.sh \
+	m4/acx_pthread.m4 \
 	afflib.spec.in \
 	afflib.spec \
 	afflib.pc.in \
 	afflib.pubkey.asc \
-	misc/expat-2.0.1.tar.gz \
 	tests/encrypted.iso \
-	tests/encrypted.aff
+	tests/encrypted.aff \
+	win32/Changes.txt \
+	win32/Makefile.am.old \
+	win32/README_MSVC++.txt \
+	win32/affconfig.h \
+	win32/afflib.mak \
+	win32/make.bat
 
 all: affconfig.h
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
@@ -356,10 +323,6 @@ $(srcdir)/affconfig.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
 
 distclean-hdr:
 	-rm -f affconfig.h stamp-h1
-debian/changelog: $(top_builddir)/config.status $(top_srcdir)/debian/changelog.in
-	cd $(top_builddir) && $(SHELL) ./config.status $@
-debian/shlibs.local.ex: $(top_builddir)/config.status $(top_srcdir)/debian/shlibs.local.ex.in
-	cd $(top_builddir) && $(SHELL) ./config.status $@
 afflib.spec: $(top_builddir)/config.status $(srcdir)/afflib.spec.in
 	cd $(top_builddir) && $(SHELL) ./config.status $@
 afflib.pc: $(top_builddir)/config.status $(srcdir)/afflib.pc.in
diff --git a/NEWS b/NEWS
index 8a6c953..c9d5947 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,21 @@
+April 18, 2010
+Version 3.6.0 
+
+I am pleased to announce the release of AFFLIB 3.6.0.
+
+With this release, AFFLIB now compiles under "mingw" allowing us to
+directly produce statically linked executables on Windows. The AFFLIB
+release has been significantly shurnk as it no longer needs to include
+libewf, openssl, and zlib.
+
+You can now create your own AFFLIB Windows release on a Macintosh using
+mingw and the script in bootstrap_mingw.sh. Or you can download our 
+precompiled Windows version from http://afflib.org/download/afflib_windows.zip
+ 
+
+
+
+
 September 30, 2009
 Version 3.5.0 Released.
 Major features:
diff --git a/affconfig.h.in b/affconfig.h.in
index 4675ef2..4fd4a7b 100644
--- a/affconfig.h.in
+++ b/affconfig.h.in
@@ -256,6 +256,9 @@
 /* Define to 1 if you have the `regcomp' function. */
 #undef HAVE_REGCOMP
 
+/* Define to 1 if you have the <regex.h> header file. */
+#undef HAVE_REGEX_H
+
 /* Define to 1 if you have the `setupterm' function. */
 #undef HAVE_SETUPTERM
 
@@ -395,6 +398,9 @@
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
+/* Define to 1 if you have the `unsetenv' function. */
+#undef HAVE_UNSETENV
+
 /* Define to 1 if you have the `utimes' function. */
 #undef HAVE_UTIMES
 
diff --git a/afflib.spec b/afflib.spec
index 59ae9b1..181145d 100644
--- a/afflib.spec
+++ b/afflib.spec
@@ -1,5 +1,5 @@
 Name: afflib
-Version: 3.5.10
+Version: 3.5.12
 Release: 1
 Summary: Library to support the Advanced Forensic Format
 Group: System Environment/Libraries
diff --git a/bootstrap.sh b/bootstrap.sh
new file mode 100755
index 0000000..a2a98fb
--- /dev/null
+++ b/bootstrap.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+echo Bootstrap script to create configure script using autoconf
+echo
+# use the installed ones first, not matter what the path says.
+export PATH=/usr/bin:/usr/sbin:/bin:$PATH
+touch NEWS README AUTHORS ChangeLog stamp-h
+aclocal
+libtoolize -f   || glibtoolize -f
+autoheader -f
+autoconf -f
+automake --add-missing -c
+echo "Ready to run configure!"
+if [ $1"x" != "x" ]; then
+  ./configure "$@"
+fi
+
diff --git a/bootstrap_mingw.sh b/bootstrap_mingw.sh
new file mode 100644
index 0000000..c9816f8
--- /dev/null
+++ b/bootstrap_mingw.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+# From http://wagner.pp.ru/~vitus/articles/openssl-mingw.html
+# With modifications
+# Download openssl and unpack.
+#  Open Configure script with a text editor, find this line:
+#    $IsMK1MF=1 if ($target eq "mingw" && $^O ne "cygwin" && !is_msys());
+# and comment it out.
+# 
+# $ perl Configure mingw
+# $ make CC=i386-mingw32-gcc RANLIB=i386-mingw32-ranlib
+
+export CC=/opt/local/bin/i386-mingw32-gcc
+export CXX=/opt/local/bin/i386-mingw32-g++
+export RANLIB=/opt/local/bin/i386-mingw32-ranlib
+export MINGWFLAGS="-mwin32 -mconsole -march=pentium4 "
+export CFLAGS="$MINGWFLAGS"
+export CXXFLAGS="$MINGWFLAGS"
+autoreconf -f
+./configure CC=$CC CXX=$CXX RANLIB=$RANLIB --target=i586-mingw32msvc --host=i586
+make CC=$CC CXX=$CXX RANLIB=$RANLIB CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS"
+zip afflib_windows.zip tools/*.exe
+
diff --git a/configure b/configure
index cac11fa..680cf05 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for AFFLIB 3.5.10.
+# Generated by GNU Autoconf 2.61 for AFFLIB 3.5.12.
 #
 # Report bugs to <bugs at afflib.org>.
 #
@@ -723,8 +723,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # Identity of this package.
 PACKAGE_NAME='AFFLIB'
 PACKAGE_TARNAME='afflib'
-PACKAGE_VERSION='3.5.10'
-PACKAGE_STRING='AFFLIB 3.5.10'
+PACKAGE_VERSION='3.5.12'
+PACKAGE_STRING='AFFLIB 3.5.12'
 PACKAGE_BUGREPORT='bugs at afflib.org'
 
 # Factoring default headers for most tests.
@@ -1427,7 +1427,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures AFFLIB 3.5.10 to adapt to many kinds of systems.
+\`configure' configures AFFLIB 3.5.12 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1497,7 +1497,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of AFFLIB 3.5.10:";;
+     short | recursive ) echo "Configuration of AFFLIB 3.5.12:";;
    esac
   cat <<\_ACEOF
 
@@ -1616,7 +1616,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-AFFLIB configure 3.5.10
+AFFLIB configure 3.5.12
 generated by GNU Autoconf 2.61
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1630,7 +1630,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by AFFLIB $as_me 3.5.10, which was
+It was created by AFFLIB $as_me 3.5.12, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   $ $0 $@
@@ -2320,7 +2320,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='afflib'
- VERSION='3.5.10'
+ VERSION='3.5.12'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -11829,28 +11829,29 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-# AC_PROG_RANLIB not needed if you are using AC_PROG_LIBTOOL
-# AC_PROG_RANLIB
-ac_config_files="$ac_config_files Makefile lib/Makefile tools/Makefile lzma443/Makefile win32/Makefile tests/Makefile doc/Makefile pyaff/Makefile man/Makefile lib/version.h"
-
-ac_config_files="$ac_config_files debian/changelog"
-
-ac_config_files="$ac_config_files debian/shlibs.local.ex"
-
-ac_config_files="$ac_config_files afflib.spec"
-
-ac_config_headers="$ac_config_headers affconfig.h"
-
-
-# Bring additional directories where things might be found into our
-# search path. I don't know why autoconf doesn't do this by default
-for spfx in /usr/local /opt/local /sw ${prefix} ; do
-    echo checking ${spfx}/include
+if test x"${cross_compiling}" = "xno" ; then
+  # Bring additional directories where things might be found into our
+  # search path. I don't know why autoconf doesn't do this by default
+  for spfx in /usr/local /opt/local /sw ${prefix} ; do
+    { echo "$as_me:$LINENO: checking ${spfx}/include" >&5
+echo "$as_me: checking ${spfx}/include" >&6;}
     if test -d ${spfx}/include; then
         CPPFLAGS="-I${spfx}/include $CPPFLAGS"
         LDFLAGS="-L${spfx}/lib $LDFLAGS"
+        { echo "$as_me:$LINENO:  *** ADDING ${spfx}/include to CPPFLAGS *** " >&5
+echo "$as_me:  *** ADDING ${spfx}/include to CPPFLAGS *** " >&6;}
+        { echo "$as_me:$LINENO:  *** ADDING ${spfx}/lib to LDFLAGS *** " >&5
+echo "$as_me:  *** ADDING ${spfx}/lib to LDFLAGS *** " >&6;}
     fi
-done
+  done
+  { echo "$as_me:$LINENO:  CPPFLAGS = ${CPPFLAGS} " >&5
+echo "$as_me:  CPPFLAGS = ${CPPFLAGS} " >&6;}
+  { echo "$as_me:$LINENO:  LDFLAGS = ${LDFLAGS} " >&5
+echo "$as_me:  LDFLAGS = ${LDFLAGS} " >&6;}
+else
+  { echo "$as_me:$LINENO: Cross Compiling --- will not update CPPFALGS or LDFLAGS with /usr/local, /opt/local or /sw" >&5
+echo "$as_me: Cross Compiling --- will not update CPPFALGS or LDFLAGS with /usr/local, /opt/local or /sw" >&6;}
+fi
 
 
 
@@ -13977,7 +13978,8 @@ fi
 
 
 
-for ac_header in arpa/inet.h assert.h ctype.h dmalloc.h err.h errno.h fcntl.h getopt.h inttypes.h linux/fs.h malloc.h ncurses/term.h netinet/in.h signal.h stdio.h stdlib.h string.h sys/cdefs.h sys/disk.h sys/file.h sys/ioctl.h sys/ioctl.h sys/param.h sys/param.h sys/socket.h sys/signal.h sys/stat.h sys/time.h sys/types.h sys/vfs.h sysexits.h term.h time.h unistd.h zlib.h
+
+for ac_header in arpa/inet.h assert.h ctype.h dmalloc.h err.h errno.h fcntl.h getopt.h inttypes.h linux/fs.h malloc.h ncurses/term.h netinet/in.h regex.h signal.h stdio.h stdlib.h string.h sys/cdefs.h sys/disk.h sys/file.h sys/ioctl.h sys/ioctl.h sys/param.h sys/param.h sys/socket.h sys/signal.h sys/stat.h sys/time.h sys/types.h sys/vfs.h sysexits.h term.h time.h unistd.h zlib.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
@@ -14266,7 +14268,8 @@ fi
 
 
 
-for ac_func in getprogname strlcpy strlcat err_set_exit srandom srandomdev flock fstatfs valloc isdigit isalnum isalphanum isatty popen ftruncate memset mkdir putenv regcomp srandomdev strcasecmp strchr strdup strerror strrchr err errx warn warnx utimes
+
+for ac_func in getprogname strlcpy strlcat err_set_exit srandom srandomdev flock fstatfs valloc isdigit isalnum isalphanum isatty popen ftruncate memset mkdir putenv regcomp srandomdev strcasecmp strchr strdup strerror strrchr err errx warn warnx utimes unsetenv
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 { echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -17337,11 +17340,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:17340: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:17343: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:17344: \$? = $ac_status" >&5
+   echo "$as_me:17347: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -17436,11 +17439,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:17439: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:17442: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:17443: \$? = $ac_status" >&5
+   echo "$as_me:17446: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -17488,11 +17491,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:17491: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:17494: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:17495: \$? = $ac_status" >&5
+   echo "$as_me:17498: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -20384,13 +20387,6 @@ if test "${with_curl+set}" = set; then
   withval=$with_curl; CURL_CONFIG="${with_curl}/bin/curl-config"
 fi
 
-  if test -f "${CURL_CONFIG}"; then
-      LDFLAGS="`${CURL_CONFIG} --libs` $LDFLAGS"
-      CPPFLAGS="`${CURL_CONFIG} --cflags` $CPPFLAGS"
-  else
-      { echo "$as_me:$LINENO: WARNING: curl-config not found, guessing at libcurl build settings" >&5
-echo "$as_me: WARNING: curl-config not found, guessing at libcurl build settings" >&2;}
-  fi
   if test "${ac_cv_header_curl_curl_h+set}" = set; then
   { echo "$as_me:$LINENO: checking for curl/curl.h" >&5
 echo $ECHO_N "checking for curl/curl.h... $ECHO_C" >&6; }
@@ -20639,6 +20635,12 @@ fi
 echo "disable_qemu: " ${disable_qemu}
 echo "enable_qemu: " ${enable_qemu}
 
+if test x"${cross_compiling}" = "xyes" ; then
+  { echo "$as_me:$LINENO: cross-compiling: Disabling QEMU" >&5
+echo "$as_me: cross-compiling: Disabling QEMU" >&6;}
+  enable_qemu="no";
+fi
+
 if test "x${enable_qemu}" = "xno" ; then
    enable_qemu="no"
 
@@ -21288,21 +21290,29 @@ else
 fi
 
 
+
+
 ##
 ################################################################
 ################################################################
 ## Crypto (must follow S3)
 ###
 
+# If we are cross-compiling, then add the specail libs that OpenSSL requires
 
+if test x"${cross_compiling}" == "xyes" ; then
+  LIBS="$LIBS -lws2_32 -lgdi32"
+fi
 
-{ echo "$as_me:$LINENO: checking for ssl3_new in -lssl" >&5
-echo $ECHO_N "checking for ssl3_new in -lssl... $ECHO_C" >&6; }
-if test "${ac_cv_lib_ssl_ssl3_new+set}" = set; then
+
+
+{ echo "$as_me:$LINENO: checking for MD5_Update in -lcrypto" >&5
+echo $ECHO_N "checking for MD5_Update in -lcrypto... $ECHO_C" >&6; }
+if test "${ac_cv_lib_crypto_MD5_Update+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lssl  $LIBS"
+LIBS="-lcrypto  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -21316,11 +21326,11 @@ cat >>conftest.$ac_ext <<_ACEOF
 #ifdef __cplusplus
 extern "C"
 #endif
-char ssl3_new ();
+char MD5_Update ();
 int
 main ()
 {
-return ssl3_new ();
+return MD5_Update ();
   ;
   return 0;
 }
@@ -21343,41 +21353,42 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_ssl_ssl3_new=yes
+  ac_cv_lib_crypto_MD5_Update=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_cv_lib_ssl_ssl3_new=no
+	ac_cv_lib_crypto_MD5_Update=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_ssl_ssl3_new" >&5
-echo "${ECHO_T}$ac_cv_lib_ssl_ssl3_new" >&6; }
-if test $ac_cv_lib_ssl_ssl3_new = yes; then
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_crypto_MD5_Update" >&5
+echo "${ECHO_T}$ac_cv_lib_crypto_MD5_Update" >&6; }
+if test $ac_cv_lib_crypto_MD5_Update = yes; then
   cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBSSL 1
+#define HAVE_LIBCRYPTO 1
 _ACEOF
 
-  LIBS="-lssl $LIBS"
+  LIBS="-lcrypto $LIBS"
 
 else
-  { { echo "$as_me:$LINENO: error: OpenSSL developer library 'libssl-dev' or 'openssl-devel' not installed; cannot continue." >&5
-echo "$as_me: error: OpenSSL developer library 'libssl-dev' or 'openssl-devel' not installed; cannot continue." >&2;}
+  { { echo "$as_me:$LINENO: error: OpenSSL developer library 'libcrypto' not installed; cannot continue." >&5
+echo "$as_me: error: OpenSSL developer library 'libcrypto' not installed; cannot continue." >&2;}
    { (exit 1); exit 1; }; }
 fi
 
 
-{ echo "$as_me:$LINENO: checking for MD5_Update in -lcrypto" >&5
-echo $ECHO_N "checking for MD5_Update in -lcrypto... $ECHO_C" >&6; }
-if test "${ac_cv_lib_crypto_MD5_Update+set}" = set; then
+
+{ echo "$as_me:$LINENO: checking for ssl3_new in -lssl" >&5
+echo $ECHO_N "checking for ssl3_new in -lssl... $ECHO_C" >&6; }
+if test "${ac_cv_lib_ssl_ssl3_new+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcrypto  $LIBS"
+LIBS="-lssl  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -21391,11 +21402,11 @@ cat >>conftest.$ac_ext <<_ACEOF
 #ifdef __cplusplus
 extern "C"
 #endif
-char MD5_Update ();
+char ssl3_new ();
 int
 main ()
 {
-return MD5_Update ();
+return ssl3_new ();
   ;
   return 0;
 }
@@ -21418,30 +21429,30 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_crypto_MD5_Update=yes
+  ac_cv_lib_ssl_ssl3_new=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_cv_lib_crypto_MD5_Update=no
+	ac_cv_lib_ssl_ssl3_new=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_crypto_MD5_Update" >&5
-echo "${ECHO_T}$ac_cv_lib_crypto_MD5_Update" >&6; }
-if test $ac_cv_lib_crypto_MD5_Update = yes; then
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_ssl_ssl3_new" >&5
+echo "${ECHO_T}$ac_cv_lib_ssl_ssl3_new" >&6; }
+if test $ac_cv_lib_ssl_ssl3_new = yes; then
   cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBCRYPTO 1
+#define HAVE_LIBSSL 1
 _ACEOF
 
-  LIBS="-lcrypto $LIBS"
+  LIBS="-lssl $LIBS"
 
 else
-  { { echo "$as_me:$LINENO: error: OpenSSL developer library 'libcrypto' not installed; cannot continue." >&5
-echo "$as_me: error: OpenSSL developer library 'libcrypto' not installed; cannot continue." >&2;}
+  { { echo "$as_me:$LINENO: error: OpenSSL developer library 'libssl-dev' or 'openssl-devel' not installed; cannot continue." >&5
+echo "$as_me: error: OpenSSL developer library 'libssl-dev' or 'openssl-devel' not installed; cannot continue." >&2;}
    { (exit 1); exit 1; }; }
 fi
 
@@ -21456,6 +21467,7 @@ fi
 
 
 
+
 for ac_header in openssl/aes.h openssl/bio.h openssl/evp.h openssl/hmac.h openssl/md5.h openssl/rand.h openssl/rsa.h openssl/sha.h openssl/pem.h openssl/x509.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
@@ -22245,6 +22257,16 @@ echo "$as_me: LDFLAGS:    ${LDFLAGS}" >&6;}
 echo "$as_me: *****************************************" >&6;}
 { echo "$as_me:$LINENO: " >&5
 echo "$as_me: " >&6;}
+
+# AC_PROG_RANLIB not needed if you are using AC_PROG_LIBTOOL
+# AC_PROG_RANLIB
+ac_config_files="$ac_config_files Makefile lib/Makefile tools/Makefile lzma443/Makefile tests/Makefile doc/Makefile pyaff/Makefile man/Makefile lib/version.h"
+
+ac_config_files="$ac_config_files afflib.spec"
+
+ac_config_headers="$ac_config_headers affconfig.h"
+
+
 ac_config_files="$ac_config_files afflib.pc"
 
 cat >confcache <<\_ACEOF
@@ -22706,7 +22728,7 @@ exec 6>&1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by AFFLIB $as_me 3.5.10, which was
+This file was extended by AFFLIB $as_me 3.5.12, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -22759,7 +22781,7 @@ Report bugs to <bug-autoconf at gnu.org>."
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-AFFLIB config.status 3.5.10
+AFFLIB config.status 3.5.12
 configured by $0, generated by GNU Autoconf 2.61,
   with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 
@@ -23228,14 +23250,11 @@ do
     "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;;
     "tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;;
     "lzma443/Makefile") CONFIG_FILES="$CONFIG_FILES lzma443/Makefile" ;;
-    "win32/Makefile") CONFIG_FILES="$CONFIG_FILES win32/Makefile" ;;
     "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
     "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
     "pyaff/Makefile") CONFIG_FILES="$CONFIG_FILES pyaff/Makefile" ;;
     "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;;
     "lib/version.h") CONFIG_FILES="$CONFIG_FILES lib/version.h" ;;
-    "debian/changelog") CONFIG_FILES="$CONFIG_FILES debian/changelog" ;;
-    "debian/shlibs.local.ex") CONFIG_FILES="$CONFIG_FILES debian/shlibs.local.ex" ;;
     "afflib.spec") CONFIG_FILES="$CONFIG_FILES afflib.spec" ;;
     "affconfig.h") CONFIG_HEADERS="$CONFIG_HEADERS affconfig.h" ;;
     "afflib.pc") CONFIG_FILES="$CONFIG_FILES afflib.pc" ;;
diff --git a/configure.ac b/configure.ac
index cfa7498..8710078 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,7 +5,7 @@
 # and http://www.openismus.com/documents/linux/automake/automake.shtml
 
 
-AC_INIT([AFFLIB],[3.5.10],[bugs at afflib.org])
+AC_INIT([AFFLIB],[3.5.12],[bugs at afflib.org])
 AM_INIT_AUTOMAKE
 AM_MAINTAINER_MODE
 
@@ -23,31 +23,28 @@ AC_PROG_LIBTOOL
 AC_CONFIG_MACRO_DIR([m4])
 
 # We are now threading
-m4_include([acx_pthread.m4])
-m4_include([acinclude.m4])
+m4_include([m4/acx_pthread.m4])
+m4_include([m4/acinclude.m4])
 ACX_PTHREAD()
 
 
-# AC_PROG_RANLIB not needed if you are using AC_PROG_LIBTOOL
-# AC_PROG_RANLIB
-AC_CONFIG_FILES([Makefile lib/Makefile tools/Makefile lzma443/Makefile win32/Makefile 
-			  tests/Makefile doc/Makefile pyaff/Makefile man/Makefile lib/version.h])
-dnl Have configure make distribution specific files
-AC_CONFIG_FILES([debian/changelog])
-AC_CONFIG_FILES([debian/shlibs.local.ex])
-AC_CONFIG_FILES([afflib.spec])
-dnl Have configure write its configuration
-AM_CONFIG_HEADER([affconfig.h])
-
-# Bring additional directories where things might be found into our
-# search path. I don't know why autoconf doesn't do this by default
-for spfx in /usr/local /opt/local /sw ${prefix} ; do
-    echo checking ${spfx}/include
+if test x"${cross_compiling}" = "xno" ; then
+  # Bring additional directories where things might be found into our
+  # search path. I don't know why autoconf doesn't do this by default
+  for spfx in /usr/local /opt/local /sw ${prefix} ; do
+    AC_MSG_NOTICE([checking ${spfx}/include])
     if test -d ${spfx}/include; then
         CPPFLAGS="-I${spfx}/include $CPPFLAGS"
         LDFLAGS="-L${spfx}/lib $LDFLAGS"
+        AC_MSG_NOTICE([ *** ADDING ${spfx}/include to CPPFLAGS *** ])
+        AC_MSG_NOTICE([ *** ADDING ${spfx}/lib to LDFLAGS *** ])
     fi
-done
+  done
+  AC_MSG_NOTICE([ CPPFLAGS = ${CPPFLAGS} ])        
+  AC_MSG_NOTICE([ LDFLAGS = ${LDFLAGS} ])        
+else
+  AC_MSG_NOTICE([Cross Compiling --- will not update CPPFALGS or LDFLAGS with /usr/local, /opt/local or /sw])
+fi
         
 
 AC_DEFINE([IN_AFFLIB],1,[Defined if we are inside AFFLIB])
@@ -73,7 +70,7 @@ AC_STRUCT_ST_RDEV
 
 
 # Specific headers that I plan to use
-AC_CHECK_HEADERS([arpa/inet.h assert.h ctype.h dmalloc.h err.h errno.h fcntl.h getopt.h inttypes.h linux/fs.h malloc.h ncurses/term.h netinet/in.h signal.h stdio.h stdlib.h string.h sys/cdefs.h sys/disk.h sys/file.h sys/ioctl.h sys/ioctl.h sys/param.h sys/param.h sys/socket.h sys/signal.h sys/stat.h sys/time.h sys/types.h sys/vfs.h sysexits.h term.h time.h unistd.h zlib.h])
+AC_CHECK_HEADERS([arpa/inet.h assert.h ctype.h dmalloc.h err.h errno.h fcntl.h getopt.h inttypes.h linux/fs.h malloc.h ncurses/term.h netinet/in.h regex.h signal.h stdio.h stdlib.h string.h sys/cdefs.h sys/disk.h sys/file.h sys/ioctl.h sys/ioctl.h sys/param.h sys/param.h sys/socket.h sys/signal.h sys/stat.h sys/time.h sys/types.h sys/vfs.h sysexits.h term.h time.h unistd.h zlib.h])
 
 AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
 		[ AC_DEFINE(HAVE_SOCKADDR_SIN_LEN, 1, [Do we have sockaddr.sin_len?]) ],
@@ -86,7 +83,7 @@ AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
 
 
 # Specific functions that we want to know about
-AC_CHECK_FUNCS([getprogname strlcpy strlcat err_set_exit srandom srandomdev flock fstatfs valloc isdigit isalnum isalphanum isatty popen ftruncate memset mkdir putenv regcomp srandomdev strcasecmp strchr strdup strerror strrchr err errx warn warnx utimes])
+AC_CHECK_FUNCS([getprogname strlcpy strlcat err_set_exit srandom srandomdev flock fstatfs valloc isdigit isalnum isalphanum isatty popen ftruncate memset mkdir putenv regcomp srandomdev strcasecmp strchr strdup strerror strrchr err errx warn warnx utimes unsetenv])
 
 # Special features that can be enabled or disabled
 AC_ARG_WITH([noopt], AC_HELP_STRING([--with-noopt],[Drop -O C flags]))
@@ -251,12 +248,6 @@ if test "x${enable_s3}" = "xyes" ; then
   AC_ARG_WITH(curl,
             AC_HELP_STRING([--with-curl=PATH], [where libcurl is installed; required for S3]),
             [CURL_CONFIG="${with_curl}/bin/curl-config"])
-  if test -f "${CURL_CONFIG}"; then
-      LDFLAGS="`${CURL_CONFIG} --libs` $LDFLAGS"
-      CPPFLAGS="`${CURL_CONFIG} --cflags` $CPPFLAGS"
-  else
-      AC_MSG_WARN([curl-config not found, guessing at libcurl build settings])
-  fi
   AC_CHECK_HEADER([curl/curl.h],,
     AC_MSG_WARN([curl/curl.h not found; Disabling S3 Support.])
     enable_s3=no)
@@ -282,6 +273,11 @@ AC_ARG_ENABLE([qemu])
 echo "disable_qemu: " ${disable_qemu}
 echo "enable_qemu: " ${enable_qemu}
 
+if test x"${cross_compiling}" = "xyes" ; then
+  AC_MSG_NOTICE([cross-compiling: Disabling QEMU])
+  enable_qemu="no";
+fi
+
 if test "x${enable_qemu}" = "xno" ; then
    enable_qemu="no"
    AC_DEFINE([DISABLE_QEMU],1,[User has disabled QEMU support])
@@ -308,18 +304,28 @@ fi
 
 AM_CONDITIONAL(HAVE_PYTHON, test "$enable_python" = yes)
 
+
+
 ##
 ################################################################
 ################################################################
 ## Crypto (must follow S3)
 ###
 
+# If we are cross-compiling, then add the specail libs that OpenSSL requires
+
+if test x"${cross_compiling}" == "xyes" ; then
+  LIBS="$LIBS -lws2_32 -lgdi32"
+fi
+
 
-AC_CHECK_LIB([ssl],[ssl3_new],,
-	AC_MSG_ERROR([OpenSSL developer library 'libssl-dev' or 'openssl-devel' not installed; cannot continue.]))
 AC_CHECK_LIB([crypto],[MD5_Update],,
 	AC_MSG_ERROR([OpenSSL developer library 'libcrypto' not installed; cannot continue.]))	
 
+AC_CHECK_LIB([ssl],[ssl3_new],,
+	AC_MSG_ERROR([OpenSSL developer library 'libssl-dev' or 'openssl-devel' not installed; cannot continue.]))
+
+
 AC_CHECK_HEADERS([openssl/aes.h openssl/bio.h openssl/evp.h openssl/hmac.h openssl/md5.h openssl/rand.h openssl/rsa.h openssl/sha.h openssl/pem.h openssl/x509.h])
 
 AC_CHECK_FUNCS([MD5 SHA1 AES_encrypt RAND_pseudo_bytes des_read_pw_string EVP_read_pw_string EVP_MD_size])
@@ -404,6 +410,16 @@ AC_MSG_NOTICE([LIBS:       ${LIBS}])
 AC_MSG_NOTICE([LDFLAGS:    ${LDFLAGS}])
 AC_MSG_NOTICE([*****************************************])
 AC_MSG_NOTICE([])
+
+# AC_PROG_RANLIB not needed if you are using AC_PROG_LIBTOOL
+# AC_PROG_RANLIB
+AC_CONFIG_FILES([Makefile lib/Makefile tools/Makefile lzma443/Makefile 
+			  tests/Makefile doc/Makefile pyaff/Makefile man/Makefile lib/version.h])
+dnl Have configure make distribution specific files
+AC_CONFIG_FILES([afflib.spec])
+dnl Have configure write its configuration
+AM_CONFIG_HEADER([affconfig.h])
+
 AC_OUTPUT([afflib.pc])
 
 
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 1292a94..1e154bd 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -34,8 +34,8 @@ host_triplet = @host@
 subdir = doc
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/acx_pthread.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \
+	$(top_srcdir)/m4/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
diff --git a/lib/Makefile.in b/lib/Makefile.in
index e05d751..d5646e9 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -42,8 +42,8 @@ subdir = lib
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
 	$(srcdir)/version.h.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/acx_pthread.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \
+	$(top_srcdir)/m4/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
diff --git a/lib/afflib.cpp b/lib/afflib.cpp
index 832fb4b..9c0d9a1 100644
--- a/lib/afflib.cpp
+++ b/lib/afflib.cpp
@@ -850,8 +850,7 @@ int af_update_segf(AFFILE *af, const char *segname,
 #ifdef HAVE_AES_ENCRYPT
     const char *oldname = 0;
     unsigned char *newdata = 0;
-    if(AF_SEALING(af)
-       && ((flag & AF_SIGFLAG_NOSEAL)==0)){
+    if(AF_SEALING(af) && ((flag & AF_SIGFLAG_NOSEAL)==0) && af->crypto->auto_encrypt){
 	/* Create an IV */
 	unsigned char iv[AES_BLOCK_SIZE];
 	memset(iv,0,sizeof(iv));
@@ -878,7 +877,7 @@ int af_update_segf(AFFILE *af, const char *segname,
 	datalen += pad + extra;
     }
 #endif
-    int r = (*af->v->update_seg)(af,segname,arg,data,datalen);
+    int r = (*af->v->update_seg)(af,segname,arg,data,datalen); // actually update the segment
     if(r==0) af->bytes_written += datalen;
 #ifdef HAVE_AES_ENCRYPT
     /* if we encrypted, make sure the unencrypted segment is deleted */
@@ -888,6 +887,15 @@ int af_update_segf(AFFILE *af, const char *segname,
 	newdata = 0;
     }
 #endif
+    /* If we wrote out an unencrypted segment, make sure that the corresopnding encrypted
+     * segment is deleted.
+     */
+    char encrypted_name[AF_MAX_NAME_LEN];
+    strlcpy(encrypted_name,segname,sizeof(encrypted_name));
+    strlcat(encrypted_name,AF_AES256_SUFFIX,sizeof(encrypted_name));
+    if(*af->v->del_seg) (*af->v->del_seg)(af,encrypted_name); // no need to check error return
+
+
     /* Sign the segment if:
      * - there is a signing private key
      * - the data structure and flag not set
diff --git a/lib/afflib.h b/lib/afflib.h
index 537a73e..c9fc012 100644
--- a/lib/afflib.h
+++ b/lib/afflib.h
@@ -31,38 +31,46 @@
 #include <inttypes.h>
 #endif
 
-/* WIN32 is defined by the NMAKE makefile for Visual C++ under Windows */
+/** WIN32 is defined by the NMAKE makefile for Visual C++ under Windows and by mingw **/
 #ifdef WIN32                            
 #include <io.h>				// gets isatty
 typedef unsigned int uint;
 typedef unsigned int u_int;
 typedef unsigned long ulong;
 typedef unsigned long u_long;
-typedef unsigned _int64 uint64;		/* 64-bit types Types */
-typedef          _int64 int64;
+typedef unsigned __int64 uint64;		/* 64-bit types Types */
+typedef          __int64 int64;
 typedef unsigned char u_char;
+
 #ifndef _UINT64_T_DECLARED
-typedef unsigned _int64 uint64_t;	/* 64-bit types Types */
+typedef unsigned __int64 uint64_t;	/* 64-bit types Types */
 #define _UINT64_T_DECLARED
+#endif
+
+#ifndef _INT64_T_DECLARED
+typedef         __int64 int64_t;
+#define _INT64_T_DECLARED
+#endif
 
 #ifndef PRId64
 #define PRId64 "I64d"
 #endif
+
 #ifndef PRIi64
 #define PRIi64 "I64i"
 #endif
+
 #ifndef PRIu64
 #define PRIu64 "I64u"
 #endif
-#endif
 
-#ifndef _INT64_T_DECLARED
-typedef          _int64 int64_t;
-#define _INT64_T_DECLARED
-#endif
-int64   ftello(FILE *stream);	 /* Functions that Microsoft forgot */
-int     fseeko(FILE *stream,int64 offset,int whence);
+//int64   ftello(FILE *stream);	 /* Functions that Microsoft forgot */
+//int     fseeko(FILE *stream,int64 offset,int whence);
+#define ftello ftello64
+#define fseeko fseeko64
 #endif
+/** END OF WIN32 DEFINES **/
+
 
 #define I64d PRIi64
 #define I64u PRIu64
diff --git a/lib/afflib_i.h b/lib/afflib_i.h
index 4966733..97c81b4 100644
--- a/lib/afflib_i.h
+++ b/lib/afflib_i.h
@@ -127,16 +127,26 @@
 #define random() rand()
 #define access _access
 #define strdup _strdup
-typedef int mode_t;
+
+#ifndef _MODE_T_
+#define _MODE_T_
+typedef unsigned short mode_t;
+typedef unsigned short _mode_t;
+#endif
+
 typedef unsigned int uint32_t ;
 
 #ifndef S_ISDIR
 #define S_ISDIR(m)(((m) & 0170000) == 0040000)
 #endif
 
+#if !defined(__MINGW_H)
 #define ftruncate(fd,size) _chsize_s(fd,size)
 #define MAXPATHLEN 1024
 #endif
+#endif
+/** END OF WIN32 DEFINES **/
+
 
 #ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
@@ -213,7 +223,7 @@ void	warnx(const char *fmt, ...);
 #endif
 
 
-#ifdef WIN32
+#if defined(WIN32) && !defined(__MINGW_H)
 /****************************************************************
  *** Windows emulation of opendir()/readdir()
  *** From php
diff --git a/lib/afflib_os.cpp b/lib/afflib_os.cpp
index 931cb13..01f051a 100644
--- a/lib/afflib_os.cpp
+++ b/lib/afflib_os.cpp
@@ -20,7 +20,6 @@
 #include <sys/disk.h>
 #endif
 
-
 #ifdef HAVE_LINUX_FS_H
 #include <linux/fs.h>
 #endif
@@ -33,7 +32,7 @@
  *** Extra code for Windows...
  ****************************************************************/
 
-#ifdef WIN32
+#if defined(WIN32) and !defined(__MINGW_H)
 #pragma warning(disable: 4996)
 int64 ftello(FILE *stream)
 {
@@ -46,8 +45,6 @@ int64 ftello(FILE *stream)
 
 int fseeko(FILE *stream,int64 offset,int whence)
 {
-    
-
     switch(whence){
     case SEEK_SET:
 	break;				// jump down to fsetpos()
@@ -62,7 +59,6 @@ int fseeko(FILE *stream,int64 offset,int whence)
 	return -1;
     }
     return fsetpos(stream,&offset);
-	
 }
 #endif
 
diff --git a/lib/afflib_stream.cpp b/lib/afflib_stream.cpp
index ff9933c..70d3a18 100644
--- a/lib/afflib_stream.cpp
+++ b/lib/afflib_stream.cpp
@@ -316,7 +316,7 @@ int af_write(AFFILE *af,unsigned char *buf,size_t count)
 	}
 
 	/* If we have written more than the image size, update the image size */
-	if((u_int64_t)offset > af->image_size) af->image_size = offset;
+	if((uint64_t)offset > af->image_size) af->image_size = offset;
     }
     /* We have copied all of the user's requested data, so return */
     AF_UNLOCK(af);
diff --git a/lib/aftest.cpp b/lib/aftest.cpp
index d35c656..c7e7ada 100644
--- a/lib/aftest.cpp
+++ b/lib/aftest.cpp
@@ -8,7 +8,10 @@
 #include "afflib_i.h"
 #include "base64.h"
 #include "aftimer.h"
+
+#ifdef HAVE_THREADED_HASH_H
 #include "threaded_hash.h"
+#endif
 
 #ifdef HAVE_GETOPT_H
 #include <getopt.h>
@@ -364,7 +367,7 @@ void sparse_test()
     af_set_pagesize(af,1024*1024*16);
 
     for(u_int i=0;i<10;i++){
-	u_int64_t pos = mult*i;
+	uint64_t pos = mult*i;
 	memset(buf,0,sizeof(buf));
 	snprintf(buf,sizeof(buf),"This is at location=%"I64u"\n",pos);
 	af_seek(af,pos,SEEK_SET);
@@ -373,8 +376,8 @@ void sparse_test()
 
     /* Now verify */
     for(u_int i=0;i<10;i++){
-	u_int64_t pos = mult*i;
-	u_int64_t q;
+	uint64_t pos = mult*i;
+	uint64_t q;
 	af_seek(af,pos,SEEK_SET);
 	af_read(af,(unsigned char *)buf,sizeof(buf));
 	char *cc = strchr(buf,'=');
@@ -681,7 +684,8 @@ void readfile_test(const char *fname)
 
     int r = af_read(af,buf,sizeof(buf));
     printf("af_read(af,buf,1024)=%d  errno=%d\n",r,errno);
-    fwrite(buf,1,512,stdout);
+    r = fwrite(buf,1,512,stdout);
+    assert(r==512);
     af_close(af);
     exit(0);
 }
@@ -716,6 +720,7 @@ void xmltest(const char *fn);
 
 void time_test()
 {
+#ifdef HAVE_THREADED_HASH_H
     int size = 1024*1024*256;
     unsigned char *buf1 = (u_char *)calloc(size,1);
     int threaded=0;
@@ -752,6 +757,7 @@ void time_test()
 	    printf("==============================\n");
 	}
     }
+#endif
     exit(0);
 }
 
@@ -842,8 +848,9 @@ void xmltest(const char *fn)
 	xmlseg(bp,af,segname);
     }
     char *buf=0;
-    size_t len = BIO_get_mem_data(bp,&buf);
-    fwrite(buf,1,len,stdout);
+    ssize_t len = BIO_get_mem_data(bp,&buf);
+    int r = fwrite(buf,1,len,stdout);
+    assert(r==len);
 }
 
 
diff --git a/lib/aftimer.h b/lib/aftimer.h
index fb6b69c..d500a9e 100644
--- a/lib/aftimer.h
+++ b/lib/aftimer.h
@@ -48,16 +48,26 @@ inline time_t aftimer::tstart()
     return t0.tv_sec;
 }
 
+inline void timestamp(struct timeval *t)
+{
+#ifdef WIN32
+    t->tv_sec = time(0);
+    t->tv_usec = 0;			/* need to fix */
+#else
+    gettimeofday(t,NULL);
+#endif    
+}
+
 inline void aftimer::start()
 {
-    gettimeofday(&t0,NULL);
+    timestamp(&t0);
     running = 1;
 }
 
 inline void aftimer::stop(){
     if(running){
 	struct timeval t;
-	gettimeofday(&t,NULL);
+	timestamp(&t);
 	total_sec  += t.tv_sec - t0.tv_sec;
 	total_usec += t.tv_usec - t0.tv_usec;
 	lap_time_   = (double)(t.tv_sec - t0.tv_sec)  + (double)(t.tv_usec - t0.tv_usec)/1000000.0;
@@ -75,7 +85,7 @@ inline double aftimer::elapsed_seconds()
     double ret = (double)total_sec + (double)total_usec/1000000.0;
     if(running){
 	struct timeval t;
-	gettimeofday(&t,NULL);
+	timestamp(&t);
 	ret += t.tv_sec - t0.tv_sec;
 	ret += (t.tv_usec - t0.tv_usec) / 1000000.0;
     }
diff --git a/lib/crypto.cpp b/lib/crypto.cpp
index 37af0a1..cc7c5a3 100644
--- a/lib/crypto.cpp
+++ b/lib/crypto.cpp
@@ -164,6 +164,7 @@ int af_set_aes_key(AFFILE *af,const unsigned char *userKey,const int bits)
     if(r) return r;
 
     af->crypto->sealing_key_set = 1;
+    af->crypto->auto_encrypt = 1;	// default
     af->crypto->auto_decrypt = 1;	// default
     af_invalidate_vni_cache(af);	// invalidate the cache, because now we can read encrypted values
     return 0;
@@ -781,15 +782,15 @@ int  af_set_seal_certificates(AFFILE *af,const char *certfiles[],int numcertfile
 	return AF_ERROR_NO_SHA256;			//
     }
 
-    char evp0[AF_MAX_NAME_LEN];
+    char evp0[AF_MAX_NAME_LEN];		// segment where we will store the encrypted session key
     snprintf(evp0,sizeof(evp0),AF_AFFKEY_EVP,0);
 
     /* If an affkey has not been created, create one if there is a public key(s)...
      * todo: this should probably see if there is ANY evp segment.
      */
-    if(af_get_seg(af,evp0,0,0,0)==0) return -1;
-    if(af_get_seg(af,AF_AFFKEY,0,0,0)==0) return -1;
-    if(certfiles==0 || numcertfiles==0) return -1;
+    if(af_get_seg(af,evp0,0,0,0)==0) return -1; // make sure no encrypted EVP exists
+    if(af_get_seg(af,AF_AFFKEY,0,0,0)==0) return -1; // make sure no passphrase exists
+    if(certfiles==0 || numcertfiles==0) return -1;   // make sure the user supplied a certificate
 
     /* First make the affkey */
     unsigned char affkey[32];
diff --git a/lib/vnode_afd.cpp b/lib/vnode_afd.cpp
index d6f8a92..5479b1e 100644
--- a/lib/vnode_afd.cpp
+++ b/lib/vnode_afd.cpp
@@ -19,7 +19,7 @@
 #endif
 
 
-#ifdef WIN32
+#if defined(WIN32) and !defined(__MINGW_H)
 /**********************************************************************
  * Implement dirent-style opendir/readdir/rewinddir/closedir on Win32
  *
diff --git a/lib/vnode_qemu.cpp b/lib/vnode_qemu.cpp
index 560893a..ae95468 100644
--- a/lib/vnode_qemu.cpp
+++ b/lib/vnode_qemu.cpp
@@ -92,7 +92,7 @@ static int qemu_get_seg(AFFILE *af,const char *name, unsigned long *arg,
 	/* Get the segment number */
 	if(data==0){
 	    /* Need to make sure that the segment exists */
-	    if(segnum*(af->image_pagesize+1) > (int64_t) af->image_size ){
+	    if(segnum * (af->image_pagesize+1) > (uint64_t) af->image_size ){
 		return -1; // this segment does not exist
 	    }
 	    if(datalen) *datalen =af->image_pagesize;	// just return the chunk size
@@ -176,7 +176,7 @@ static int qemu_get_next_seg(AFFILE *af,char *segname,size_t segname_len,unsigne
     }
 
  get_next_data_seg:
-    if(af->cur_page * af->image_pagesize >= (int64_t)af->image_size) return -1; // end of list
+    if(af->cur_page * af->image_pagesize >= (uint64_t)af->image_size) return -1; // end of list
     /* Make the segment name */
     char pagename[AF_MAX_NAME_LEN];		//
     memset(pagename,0,sizeof(pagename));
diff --git a/lib/vnode_raw.cpp b/lib/vnode_raw.cpp
index 3cc906f..eb057e9 100644
--- a/lib/vnode_raw.cpp
+++ b/lib/vnode_raw.cpp
@@ -257,7 +257,7 @@ static int raw_get_next_seg(AFFILE *af,char *segname,size_t segname_len,unsigned
 {
     
     /* See if we are at the end of the "virtual" segment list */
-    if((u_int64_t)af->cur_page * af->image_pagesize >= af->image_size) return -1;
+    if((uint64_t)af->cur_page * af->image_pagesize >= af->image_size) return -1;
 
     /* Make the segment name */
     char pagename[AF_MAX_NAME_LEN];		//
diff --git a/lzma443/C/Common/Alloc.cpp b/lzma443/C/Common/Alloc.cpp
index e2b8c3d..1f1c68b 100755
--- a/lzma443/C/Common/Alloc.cpp
+++ b/lzma443/C/Common/Alloc.cpp
@@ -39,7 +39,14 @@ void MyFree(void *address) throw()
   ::free(address);
 }
 
-#ifdef _WIN32
+#ifdef __MINGW_H
+void *MidAlloc(size_t size ) throw() { return MyAlloc(size);}
+void  MidFree(void *address) throw(){ return MyFree(address);}
+void *BigAlloc(size_t size ) throw() { return MyAlloc(size);}
+void  BigFree(void *address) throw(){ return MyFree(address);}
+#endif
+
+#if defined(_WIN32) && !defined(__MINGW_H)
 
 void *MidAlloc(size_t size) throw()
 {
diff --git a/lzma443/Makefile.in b/lzma443/Makefile.in
index 8cb3d0e..552ad42 100644
--- a/lzma443/Makefile.in
+++ b/lzma443/Makefile.in
@@ -37,8 +37,8 @@ host_triplet = @host@
 subdir = lzma443
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/acx_pthread.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \
+	$(top_srcdir)/m4/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
diff --git a/acinclude.m4 b/m4/acinclude.m4
similarity index 100%
rename from acinclude.m4
rename to m4/acinclude.m4
diff --git a/acx_pthread.m4 b/m4/acx_pthread.m4
similarity index 100%
rename from acx_pthread.m4
rename to m4/acx_pthread.m4
diff --git a/man/Makefile.in b/man/Makefile.in
index 2a79e2b..6c3479c 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -35,8 +35,8 @@ subdir = man
 DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/acx_pthread.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \
+	$(top_srcdir)/m4/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
diff --git a/pyaff/Makefile.in b/pyaff/Makefile.in
index a7bf82c..fffe2f4 100644
--- a/pyaff/Makefile.in
+++ b/pyaff/Makefile.in
@@ -35,8 +35,8 @@ host_triplet = @host@
 subdir = pyaff
 DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/acx_pthread.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \
+	$(top_srcdir)/m4/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
diff --git a/tests/Makefile.in b/tests/Makefile.in
index e69b3c7..c1b60e2 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -34,8 +34,8 @@ host_triplet = @host@
 subdir = tests
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/acx_pthread.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \
+	$(top_srcdir)/m4/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
diff --git a/tools/Makefile.in b/tools/Makefile.in
index b0746af..fdae2f4 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -40,8 +40,8 @@ bin_PROGRAMS = afcat$(EXEEXT) afcompare$(EXEEXT) afconvert$(EXEEXT) \
 subdir = tools
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/acx_pthread.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \
+	$(top_srcdir)/m4/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
diff --git a/tools/afcat.cpp b/tools/afcat.cpp
index 0e8a003..d49037e 100644
--- a/tools/afcat.cpp
+++ b/tools/afcat.cpp
@@ -157,7 +157,8 @@ int output_page(AFFILE *af,FILE *outfile,int64_t pagenum)
     }
 
     if(opt_debug) fprintf(stderr,"  outputing %d bytes\n",bytes);
-    fwrite(buf,1,bytes,outfile);	// send to the output
+    int count = fwrite(buf,1,bytes,outfile);	// send to the output
+    if(count!=bytes) fprintf(stderr,"fwrite(buf,1,%d,outfile) only wrote %d bytes\n",bytes,count);
     free(buf);
     return bytes;
 }
@@ -192,7 +193,10 @@ int afcat(AFFILE *af)
 		    af_filename(af),opt_segname);
 	    return -1;
 	}
-	fwrite(data,1,datalen,stdout);
+	int count = fwrite(data,1,datalen,stdout);
+	if(count!=(ssize_t)datalen){
+	    fprintf(stderr,"fwrite(buf,1,%zd,outfile) only wrote %d bytes\n",datalen,count);
+	}
 	free(data);
 	return 0;
     }
@@ -205,9 +209,13 @@ int afcat(AFFILE *af)
     if(opt_sector>=0){
 	unsigned char *buf = (unsigned char *)malloc(af->image_sectorsize);
 	af_seek(af,(uint64_t)opt_sector*af->image_sectorsize,SEEK_SET);
-	int r = af_read(af,buf,af->image_sectorsize);
-	if(r>0){
-	    fwrite(buf,1,r,stdout);
+	int bytes_read = af_read(af,buf,af->image_sectorsize);
+	if(bytes_read>0){
+	    int bytes_written =  fwrite(buf,1,bytes_read,stdout);
+	    if(bytes_read!=bytes_written){
+		fprintf(stderr,"fwrite(buf,1,%d,outfile) only wrote %d bytes\n",
+			bytes_read,bytes_written);
+	    }
 	}
 	free(buf);
 	return 0;
@@ -233,7 +241,11 @@ int afcat(AFFILE *af)
 	    af_seek(af,offset,SEEK_SET);
 	    int r= af_read(af,buf,count);
 	    if(r>0){
-		fwrite(buf,1,r,stdout);
+		int bytes_written = fwrite(buf,1,r,stdout);
+		if(bytes_written!=r) {
+		    fprintf(stderr,"fwrite(buf,1,%d,outfile) only wrote %d bytes\n",r,bytes_written);
+		}
+		
 	    }
 	}
 	free(buf);
diff --git a/tools/afcrypto.cpp b/tools/afcrypto.cpp
index 3dbd517..f8851a1 100644
--- a/tools/afcrypto.cpp
+++ b/tools/afcrypto.cpp
@@ -112,6 +112,7 @@ void usage()
 
     printf("\nData conversion options:\n");
     printf("    -e      --- encrypt the unencrypted non-signature segments\n");
+    printf("    -d      --- decrypt the encrypted non-signature segments\n");
     printf("    -r      --- change passphrase (take old and new from stdin)\n");
     printf("    -O old  --- specify old passphrase\n");
     printf("    -N new  --- specify new passphrase\n");
@@ -131,7 +132,7 @@ void usage()
 
     printf("\nDebugging:\n");
     printf("    -V      --- Just print the version number and exit.\n");
-    printf("    -d      --- debug; print out each key as it is tried\n");
+    printf("    -D      --- debug; print out each key as it is tried\n");
     printf("    -l      --- List the installed hash and encryption algorithms \n");
     printf("Note: This program ignores the environment variables:\n");
     puts(AFFLIB_PASSPHRASE);
@@ -151,7 +152,7 @@ char  *check_file(AFFILE *af,const char *passphrase_file)
     char buf[1024];
     memset(buf,0,sizeof(buf));
     while(fgets(buf,sizeof(buf)-1,f)){
-	char *cc = index(buf,'\n');
+	char *cc = strchr(buf,'\n');
 	if(cc) *cc = 0;
 	if(opt_debug){
 	    if(opt_debug) printf("checking with '%s' ... ",buf);
@@ -169,6 +170,81 @@ char  *check_file(AFFILE *af,const char *passphrase_file)
 }
 
 /**
+ * This will eventually decrypt non-signature segments that are
+ * encrypted
+ *
+ * @param af - the AFFILE to open
+ * @param count - The number of pages actually encrypted
+ */
+int af_decrypt_encrypted_segments(AFFILE *af, int *count, int mode)
+{
+    af_set_option(af,AF_OPTION_AUTO_ENCRYPT,0);
+    af_set_option(af,AF_OPTION_AUTO_DECRYPT,0); // turn off auto decryption
+    aff::seglist sl(af);	       // get the list of the segments
+    af_set_option(af,AF_OPTION_AUTO_DECRYPT,1); // turn auto decryption back on
+    for(aff::seglist::const_iterator si = sl.begin();si!=sl.end();si++){
+	if(opt_debug) printf(" checking segment %s",si->name.c_str());
+	if(af_is_encrypted_segment(si->name.c_str())){
+
+	    if(mode == O_RDONLY){	// if readonly, just tally
+		(*count) ++;
+		if(opt_debug) printf("  would decrypt segment\n");
+		continue;
+	    }
+
+	    /* Generate the name of the unencrypted segment */
+	    char segname[AF_MAX_NAME_LEN];
+	    strcpy(segname,si->name.c_str());
+	    char *cc = strstr(segname,AF_AES256_SUFFIX);
+	    if(!cc){
+		if(opt_debug) printf(" will not decrypt AFFKEY segments; will be deleted later.\n");
+		continue;		// something is wrong; can't find the /aes256
+	    }
+	    *cc = '\000';		// truncate off the /aes256
+
+	    /* Get the segment and put it, which will force the decryption to take place */
+	    if(opt_debug) printf("  decrypting segment\n");
+	    u_char *buf = (u_char *)malloc(si->len);
+	    if(!buf) warn("malloc(%zd) failed", si->len);
+	    else {
+		unsigned long arg;
+		size_t datalen = si->len;
+		if(af_get_seg(af,segname,&arg,buf,&datalen)){
+		    warn("Could not read segment '%s'",segname);
+		}
+		else{
+		    /* si->datalen >= datalen.
+		     * si->datalen is the length of the encrypted segment.
+		     * datalen is the length of the decrypted segment.
+		     */
+		    assert(si->len >= datalen);
+		    assert(si->arg==arg);
+		    if(af_update_seg(af,segname,arg,buf,datalen)){
+			warn("Could not decrypt segment '%s'",si->name.c_str());
+		    } else {
+			(*count) ++;
+		    }
+		}
+		free(buf);
+	    }
+	} else {
+	    if(opt_debug) printf("  not encrypted\n");
+	}
+    }
+    /* Delete the AF_AFFKEY segment */
+    if(af_get_seg(af,AF_AFFKEY,0,0,0)==0) af_del_seg(af,AF_AFFKEY);
+    /* Delete all of the EVP segments */
+    for(int i=0;;i++){
+	char segname[1024];
+	snprintf(segname,sizeof(segname),AF_AFFKEY_EVP,i);
+	if(af_get_seg(af,segname,0,0,0)!=0) break; // found the last segment
+	if(af_del_seg(af,segname)) warn("Cannot delete segment %s",segname);
+    }
+    return 0;
+}
+
+
+/**
  * Encrypts the non-signature segments that are not encrypted.
  * There is no reason to encrypt the signature segments.
  *
@@ -241,32 +317,41 @@ int main(int argc,char **argv)
     char *passphrase_file = 0;
     const char *progname = argv[0];
     int opt_encrypt = 0;
+    int opt_decrypt = 0;
     int opt_add_passphrase_to_public_key = 0;
     int opt_add_public_key_to_passphrase = 0;
     
     int mode = O_RDONLY;		// mode for opening AFF file
     const char **certificates = (const char **)malloc(0);
     int num_certificates = 0;
-
+    const char *envvars[] = {AFFLIB_PASSPHRASE,AFFLIB_PASSPHRASE_FILE,AFFLIB_PASSPHRASE_FD,
+		      AFFLIB_DECRYPTING_PRIVATE_KEYFILE,0};
+    for(int i=0;envvars[i];i++){
     /* Don't use auto-supplied passphrases */
-    unsetenv(AFFLIB_PASSPHRASE);
-    unsetenv(AFFLIB_PASSPHRASE_FILE);
-    unsetenv(AFFLIB_PASSPHRASE_FD);
-    unsetenv(AFFLIB_DECRYPTING_PRIVATE_KEYFILE);
-
+#ifdef HAVE_UNSETENV
+	unsetenv(envvars[i]);
+#else
+	if(getenv(envvars[i])){
+	    fprintf(stderr,"Please unset %s and restart\n",envvars[i]);
+	    exit(1);
+	}
+#endif
+    }
+    
     bflag = 0;
     int opt_change = 0;
     const char *home = getenv("HOME");
-    while ((ch = getopt(argc, argv, "reC:SAO:N:p:f:kdh?VK:vljJx")) != -1) {
-	switch (ch) {
 
+    while ((ch = getopt(argc, argv, "zreC:SAO:N:p:f:kdDh?VK:vljJx:")) != -1) {
+	switch (ch) {
 	case 'x': opt_xml = 1; break;
 	case 'j': opt_just_print_encrypted_count =1;break;
 	case 'J': opt_just_print_unencrypted_count =1;break;
 
 	    /* These options make the mode read-write */
-	case 'r': opt_change = 1; mode = O_RDWR; break;
+	case 'r': opt_change = 1;  mode = O_RDWR; break;
 	case 'e': opt_encrypt = 1; mode = O_RDWR; break;
+	case 'd': opt_decrypt = 1; mode = O_RDWR; break;
 	case 'S': opt_add_passphrase_to_public_key = 1; mode = O_RDWR; break;
 	case 'A': opt_add_public_key_to_passphrase = 1; mode = O_RDWR; break;
 	    /* These just set up variables */
@@ -287,7 +372,7 @@ int main(int argc,char **argv)
 	    strcat(passphrase_file,"/");
 	    strcat(passphrase_file,DEFAULT_PASSPHRASE_FILE);
 	    break;
-	case 'd': opt_debug = 1;break;
+	case 'D': opt_debug = 1;break;
 	case 'v': opt_verbose = 1;break;
 	case 'l': list_openssl_hashes(); exit(0);
 	case 'h':
@@ -303,6 +388,7 @@ int main(int argc,char **argv)
     argc -= optind;
     argv += optind;
     if(argc<1){
+	fprintf(stderr,"No image file specified\n");
 	usage();
     }
 
@@ -310,8 +396,8 @@ int main(int argc,char **argv)
 	errx(1,"Options -j and -J conflict\n");
     }
 
-    if(num_certificates>0 && (opt_encrypt==0 && opt_add_public_key_to_passphrase==0)){
-	errx(1,"Encryption certificates specified by -e option not set. "
+    if(num_certificates>0 && (opt_encrypt==0 && opt_decrypt==0 && opt_add_public_key_to_passphrase==0)){
+	errx(1,"Encryption certificates specified but neither -e nor -d option not set. "
 	     "What do you want me to do with these certificates? ");
     }
 	    
@@ -320,7 +406,8 @@ int main(int argc,char **argv)
     }
 
     if(opt_encrypt && (new_passphrase==0 && num_certificates==0) && mode!=O_RDONLY){
-	err(1,"Currently -e requires that the passphrase be specified on the command line or that one or more encryption certificates be provided\n");
+	err(1,"Currently -e requires that the passphrase be specified on the command line\n"
+	    "or that one or more encryption certificates be provided\n");
     }
 
     while(argc--){
@@ -358,6 +445,14 @@ int main(int argc,char **argv)
 	    }
         }
 
+	if(opt_decrypt && old_passphrase){
+	    int r = af_use_aes_passphrase(af, old_passphrase);
+	    switch(r){
+	    case 0: printf("Passphrase is good!\n"); break;
+	    case AF_ERROR_WRONG_PASSPHRASE: errx(1,"%s: wrong passphrase",fname);
+	    }
+	}
+
 	if (opt_add_public_key_to_passphrase){ 
 	  if(!num_certificates) errx(1,"You must specify a certificate with the -C option");
 	  if(!check_passphrase) errx(1,"You must specify a passphrase with the -p option");
@@ -386,6 +481,16 @@ int main(int argc,char **argv)
 		continue;
 	    }
 	}
+	if(opt_decrypt){
+	    int count = 0;
+	    if(af_decrypt_encrypted_segments(af, &count, mode)){
+	    }
+	    if(mode==O_RDONLY){
+		printf("%d\n",count);
+		af_close(af);
+		continue;
+	    }
+	}
 
 	if(opt_add_passphrase_to_public_key) {
 	    if(!new_passphrase) errx(1,"You must specify a new passphrase with the -N option");
@@ -450,6 +555,8 @@ int main(int argc,char **argv)
 	    printf("</afcrypto>\n");
 	}
 	else{
+	    /* re-run vstat because counts may have changed */
+	    if(af_vstat(af,&vni)) err(1,"%s: af_vstat failed: ",fname);
 	    printf("%s: %5d segments; %5d signed; %5d encrypted; %5d pages; %5d encrypted pages",
 		   fname,vni.segment_count_total,vni.segment_count_signed,vni.segment_count_encrypted,
 		   vni.page_count_total,vni.page_count_encrypted );
diff --git a/tools/aff_bom.cpp b/tools/aff_bom.cpp
index 18ba9ec..665ed88 100644
--- a/tools/aff_bom.cpp
+++ b/tools/aff_bom.cpp
@@ -3,7 +3,7 @@
  *
  * PUBLIC DOMAIN SOFTWARE.
  *
- * The software provided here is released by the Naval Postgradaute
+ * The software provided here is released by the Naval Postgraduate
  * School (NPS), an agency of the US Department of the Navy, USA.  The
  * software bears no warranty, either expressed or implied. NPS does
  * not assume legal liability nor responsibility for a User's use of
diff --git a/tools/aff_bom.h b/tools/aff_bom.h
index 64866b2..e795e90 100644
--- a/tools/aff_bom.h
+++ b/tools/aff_bom.h
@@ -3,7 +3,7 @@
  *
  * PUBLIC DOMAIN SOFTWARE.
  *
- * The software provided here is released by the Naval Postgradaute
+ * The software provided here is released by the Naval Postgraduate
  * School (NPS), an agency of the US Department of the Navy, USA.  The
  * software bears no warranty, either expressed or implied. NPS does
  * not assume legal liability nor responsibility for a User's use of
diff --git a/tools/affuse.c b/tools/affuse.c
index 856dce3..2adc13b 100644
--- a/tools/affuse.c
+++ b/tools/affuse.c
@@ -237,6 +237,7 @@ int main(int argc,char **argv)
 #else
     fprintf(stderr,"affuse was compiled on a Linux system that did not\n");
     fprintf(stderr,"have the FUSE developer libraries installed\n");
+    fprintf(stderr,"You need to install the fuse-devl package.\n");
 #endif
     exit(1);
 }
diff --git a/tools/afinfo.cpp b/tools/afinfo.cpp
index 5c21aba..b4d89ba 100644
--- a/tools/afinfo.cpp
+++ b/tools/afinfo.cpp
@@ -510,7 +510,8 @@ void print_info(AFFILE *af,const char *segname)
 		dots ? "..." : "");
 	/* Special code for SHA1 */
 	if(!opt_wide && strcmp(segname,AF_SHA1)==0){
-	    fwrite(output_line,1,82,stdout);
+	    int r = fwrite(output_line,1,82,stdout);
+	    if(r!=82) fprintf(stderr,"fwrite(output_line,1,82,stdout) returned %d\n",r);
 	    printf("\n%62s\n",output_line+82);
 	    goto done;
 	}
diff --git a/tools/afsegment.cpp b/tools/afsegment.cpp
index 19ad0fe..cc2768c 100644
--- a/tools/afsegment.cpp
+++ b/tools/afsegment.cpp
@@ -50,7 +50,10 @@
 #include "afflib_i.h"
 
 #include <limits.h>
+
+#ifdef HAVE_REGEX_H
 #include <regex.h>
+#endif
 
 #include <algorithm>
 #include <cstdlib>
@@ -77,6 +80,7 @@ int opt_x = 0;
 void usage()
 {
     printf("afsegment version %s\n",PACKAGE_VERSION);
+#ifdef REG_EXTENDED
     printf("usage: afsegment [options] file1.aff [file2.aff ...]\n");
     printf("options:\n");
     printf("    -c              Create AFF files if they do not exist\n");
@@ -106,9 +110,13 @@ void usage()
     printf("\n");
     printf("Note: All deletions are done first, then all updates. Don't specify the\n");
     printf("same segment twice on one command line.\n");
+#else
+    printf("afsegment requires a functioning regex package to be installed\n");
+#endif    
     exit(0);
 }
 
+#ifdef REG_EXTENDED
 int get_segment_from_file(AFFILE *af,const char *segname,unsigned long arg,FILE *in)
 {
     u_char *value = (u_char *)malloc(0);
@@ -252,7 +260,7 @@ void process(const char *fn)
 	if(opt_x) printf("\n");
     }
     else {
-	af_err(1,"af_open(%s) ",fn);
+	af_err(1,"af_open(%s) failed:",fn);
     }
 }
 
@@ -315,3 +323,10 @@ int main(int argc,char **argv)
     }
     exit(0);
 }
+#else
+int main(int argc,char **argv)
+{
+    usage();
+    exit(1);
+}
+#endif
diff --git a/tools/test_afsegment.sh b/tools/test_afsegment.sh
index fd62b76..ea959c0 100755
--- a/tools/test_afsegment.sh
+++ b/tools/test_afsegment.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Test the afsegment command
 
-PATH=$PATH:../tools:../../tools:.:$srcdir
+export PATH=$srcdir:../tools:../../tools:.:$PATH
 BLANK_BASE=`mktemp -t blankXXXXX`
 BLANK_AFF=$BLANK_BASE.aff
 unset AFFLIB_PASSPHRASE
diff --git a/tools/test_crypto.sh b/tools/test_crypto.sh
index d22251e..917d047 100755
--- a/tools/test_crypto.sh
+++ b/tools/test_crypto.sh
@@ -5,7 +5,7 @@
 #
 
 unset AFFLIB_PASSPHRASE
-PATH=$PATH:../tools:../../tools:.:$srcdir
+export PATH=$srcdir:../tools:../../tools:.:$PATH
 
 BASE=`mktemp -t encryptedXXXXXX`
 ENCRYPTED_AFF=$BASE.aff
diff --git a/tools/test_make_random_iso.sh b/tools/test_make_random_iso.sh
index 7cf7236..05ec9c0 100755
--- a/tools/test_make_random_iso.sh
+++ b/tools/test_make_random_iso.sh
@@ -5,7 +5,7 @@
 
 unset AFFLIB_PASSPHRASE
 
-if [ x"" = x$1 ] ; 
+if test "x" = "x$1" ;
   then echo usage: $0 filename
   exit 1
 fi
diff --git a/tools/test_passphrase.sh b/tools/test_passphrase.sh
index 8769b20..5ea4876 100755
--- a/tools/test_passphrase.sh
+++ b/tools/test_passphrase.sh
@@ -2,8 +2,9 @@
 #
 # test the passphrase tools
 
-PATH=$PATH:../tools:../../tools:.:$srcdir
+export PATH=$srcdir:../tools:../../tools:.:$PATH
 
+echo === testing `afcrypto -V` ===
 echo === MAKING THE TEST FILES ==
 unset AFFLIB_PASSPHRASE
 
@@ -22,8 +23,8 @@ if [ ! -r $BLANK_ISO ]; then
   exit 0
 fi
 
-afconvert -o $BLANK_AFF $BLANK_ISO
-afconvert -o file://:passphrase@/$BLANK_ENCRYPTED_AFF $BLANK_ISO
+afconvert -o $BLANK_AFF $BLANK_ISO || exit 1
+afconvert -o file://:passphrase@/$BLANK_ENCRYPTED_AFF $BLANK_ISO || exit 1
 
 if [ ! -r $BLANK_ENCRYPTED_AFF ]; then
   echo CANNOT CREATE $BLANK_ENCRYPTED_AFF 
diff --git a/tools/test_recovery.sh b/tools/test_recovery.sh
index a7d72cb..3b6cd18 100755
--- a/tools/test_recovery.sh
+++ b/tools/test_recovery.sh
@@ -3,7 +3,7 @@
 # test the signing tools
 #
 
-PATH=$PATH:../tools:../../tools:.:$srcdir
+export PATH=$srcdir:../tools:../../tools:.:$PATH
 
 RECOVERY_BASE=`mktemp -t recoveryXXXX`
 RECOVERY_KEY=$RECOVERY_BASE.key
diff --git a/tools/test_signing.sh b/tools/test_signing.sh
index 5515b23..4175080 100755
--- a/tools/test_signing.sh
+++ b/tools/test_signing.sh
@@ -16,7 +16,7 @@ EVIDENCE3=$BASE.evidence3.aff
 
 echo === MAKING THE TEST FILES ===
 
-PATH=$PATH:../tools:../../tools:.:$srcdir
+export PATH=$srcdir:../tools:../../tools:.:$PATH
 test_make_random_iso.sh rawevidence.iso
 
 

-- 
debian-forensics/afflib



More information about the forensics-changes mailing list