From c7e5e4739f83ef0e67da3cd7552b9e79be667aaa Mon Sep 17 00:00:00 2001 From: "Simson L. Garfinkel" Date: Wed, 24 Jul 2013 10:58:49 -0400 Subject: [PATCH] update to next AFF --- .gitignore | 4 + Makefile.am | 11 +-- configure.ac | 2 +- lib/Makefile.am | 4 +- lib/afflib.cpp | 4 +- lib/afflib_pages.cpp | 7 +- lib/aftest.cpp | 14 ++- lzma443/C/7zip/Archive/7z_C/makefile | 55 +++++++++++ lzma443/C/7zip/Compress/LZMA_Alone/makefile | 100 ++++++++++++++++++++ lzma443/C/7zip/Compress/LZMA_C/makefile | 43 +++++++++ tests/Makefile.am | 2 +- tests/encrypted.aff | Bin 0 -> 880 bytes tests/{encrypted.iso => encrypted.raw} | 0 tests/test_decryption.sh | 4 +- tools/Makefile.am | 2 +- tools/test_afsegment.sh | 7 +- tools/test_crypto.sh | 2 +- tools/test_fatty.sh | 2 +- tools/test_passphrase.sh | 2 +- tools/test_recovery.sh | 4 +- tools/test_sealing.sh | 2 +- tools/test_signing.sh | 28 ++++-- win32/affconfig.h | 68 +++++++++++++ 23 files changed, 327 insertions(+), 40 deletions(-) create mode 100755 lzma443/C/7zip/Archive/7z_C/makefile create mode 100755 lzma443/C/7zip/Compress/LZMA_Alone/makefile create mode 100755 lzma443/C/7zip/Compress/LZMA_C/makefile create mode 100644 tests/encrypted.aff rename tests/{encrypted.iso => encrypted.raw} (100%) create mode 100755 win32/affconfig.h diff --git a/.gitignore b/.gitignore index c93ce4c..988c01c 100644 --- a/.gitignore +++ b/.gitignore @@ -101,3 +101,7 @@ lib/version.h makefile encrypted.aff affconfig.h +*.trs +*.dirstamp +lib/aftest +afflib-?.?.? diff --git a/Makefile.am b/Makefile.am index 19be4e6..237c995 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,7 +30,6 @@ release: make prerelease make distcheck make the_release - make distribute_release prerelease: @echo Making sure SVN is up to date @@ -55,15 +54,9 @@ getrelease: tar xfz $(PACKAGE).tar.gz (cd afflib-*;./configure;make;make test_crypto) -the_release: +the_release: $(RELEASE).tar.gz gpg --detach-sign $(RELEASE).tar.gz -distribute_release: - scp $(RELEASE).tar.gz{,.sig} $(RELEASE_SSH) - ssh $(RELEASE_HOST) 'cd $(RELEASE_LOC);/bin/rm $(PACKAGE).tar.gz;ln -s $(RELEASE).tar.gz $(PACKAGE).tar.gz' - ssh $(RELEASE_HOST) 'echo $(RELEASE).tar.gz > $(RELEASE_PATH)' - @echo Release $(RELEASE) uploaded to server - DOCS = BUGLIST.txt README_Linux.txt README_Win32.txt \ doc/crypto_doc.txt \ doc/crypto_design.txt \ @@ -79,7 +72,7 @@ EXTRA_DIST = $(DOCS) \ afflib.spec \ afflib.pc.in \ afflib.pubkey.asc \ - tests/encrypted.iso \ + tests/encrypted.raw \ tests/encrypted.aff \ win32/Changes.txt \ win32/README_MSVC++.txt \ diff --git a/configure.ac b/configure.ac index a838f85..647e426 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ # See http://autotoolset.sourceforge.net/tutorial.html # and http://www.openismus.com/documents/linux/automake/automake.shtml -AC_INIT([AFFLIB],[3.7.1],[bugs@afflib.org]) +AC_INIT([AFFLIB],[3.7.2],[bugs@afflib.org]) AM_INIT_AUTOMAKE AM_MAINTAINER_MODE diff --git a/lib/Makefile.am b/lib/Makefile.am index 84d7233..d168397 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -3,6 +3,8 @@ TESTS = aftest CLEANFILES = aftest +AUTOMAKE_OPTIONS = subdir-objects + aftest_SOURCES = aftest.cpp aftest_LDADD = libafflib.la aftest_LDFLAGS = $(PTHREAD_CFLAGS) -static # easier debugging @@ -81,7 +83,7 @@ install-exec-hook: EXTRA_DIST = -INCLUDES = \ +AM_CPPFLAGS = \ -I@top_srcdir@/lzma443/C \ -I@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone diff --git a/lib/afflib.cpp b/lib/afflib.cpp index e89ed9f..48ada9b 100644 --- a/lib/afflib.cpp +++ b/lib/afflib.cpp @@ -238,7 +238,6 @@ AFFILE *af_open_with(const char *url,int flags,int mode, struct af_vnode *v) af->openmode = mode; af->image_sectorsize = 512; // default size af->error_reporter = warnx; - af->badflag = (unsigned char *)malloc(af->image_sectorsize); /* Decode URL */ af_parse_url(url,&af->protocol,&af->hostname,&af->username,&af->password, @@ -593,6 +592,9 @@ int64_t af_get_imagesize(AFFILE *af) */ int af_make_badflag(AFFILE *af) { + if(af->badflag!=0) free(af->badflag); + af->badflag = (unsigned char *)malloc(af->image_sectorsize); // current sector size + #ifdef HAVE_RAND_pseudo_bytes /* Use a good random number generator if we have it */ RAND_pseudo_bytes(af->badflag,af->image_sectorsize); diff --git a/lib/afflib_pages.cpp b/lib/afflib_pages.cpp index e2c470f..df57229 100644 --- a/lib/afflib_pages.cpp +++ b/lib/afflib_pages.cpp @@ -20,9 +20,12 @@ void af_read_sizes(AFFILE *af) af_get_seg(af,AF_SEGSIZE_D,&af->image_pagesize,0,0); // try old name } - /* Read the badflag if it is present */ + /* Read the badflag if it is present. + * Be sure to adjust badflag size to current sector size (which may have changed). + */ + if(af->badflag!=0) free(af->badflag); + af->badflag = (unsigned char *)malloc(af->image_sectorsize); size_t sectorsize = af->image_sectorsize; - if(af->badflag==0) af->badflag = (unsigned char *)malloc(sectorsize); if(af_get_seg(af,AF_BADFLAG,0,af->badflag,(size_t *)§orsize)==0){ af->badflag_set = 1; } diff --git a/lib/aftest.cpp b/lib/aftest.cpp index 3ec5695..efa64f0 100644 --- a/lib/aftest.cpp +++ b/lib/aftest.cpp @@ -397,11 +397,15 @@ void sparse_test() memset(buf,'g',sizeof(buf)); af_seek(af,mult/2,SEEK_SET); ssize_t r = af_read(af,(unsigned char *)buf,sizeof(buf)); - if(r!=sizeof(buf)){ - err(1,"Tried to read %zd bytes at mult/2; got %zd bytes\n",sizeof(buf),r); - } - for(u_int i=0;iCb2BvHzO!X{J{&cl{Hmjk5EXEEIfl@m0iH_TIU(qH;5JwXXgME$Vr-I?K2EI#*oBtKKZW_hmIruW`*b=txKQ=k0`cR9IK z^XAIeBFCh!8Z%cfS(&oXq9&Jf)mBkA-^%g4_t&G8A5`1Wz;6Q|d!=ZXBicj0dS zE1_RkN|z_hH51&CFLk@a5_?; zb(kX7n;xu=y3@0kD{6-Cw~yuT|F8JC+4ZF7?tgtrtJMGHY@G7wVC-6PL-&90Bq9x8 ze%qP0;z|^A(V|>~kDl*hM0GVL$o_FYUvPi_@9zu~p41iTS>?PoIMAD-zo%#ZYRNP#ar2{E9~4^ZS}8x>T$l$lF|Mw zFlB|z;UBE}Tb@se_&Imy897di{MkFMT)D>8$oF(v=+`*m+5Z+yJ%0YhuKiZ|kKQ^w&@)IhQ-Uhjhbrd&^q}dx(4Pq7H3wa>O+i&DpQ9l;{mEr0AjE*1E?C+-aut$BfSL^cvZG< ck6_xZUSQVkboS-NN~73wb@xk7Ld|di04x+&lmGw# literal 0 HcmV?d00001 diff --git a/tests/encrypted.iso b/tests/encrypted.raw similarity index 100% rename from tests/encrypted.iso rename to tests/encrypted.raw diff --git a/tests/test_decryption.sh b/tests/test_decryption.sh index 17e90f4..967a7be 100755 --- a/tests/test_decryption.sh +++ b/tests/test_decryption.sh @@ -10,7 +10,7 @@ if test "x$srcdir" = x; then srcdir=. fi -if ( ../tools/affcompare file://:password@/$srcdir/encrypted.aff $srcdir/encrypted.iso ) ; then +if ( ../tools/affcompare file://:password@/$srcdir/encrypted.aff $srcdir/encrypted.raw ) ; then echo Verifies with correct decryption passphrase. else echo Does not verify with correct decryption passphrase. @@ -19,7 +19,7 @@ fi echo This next affcompare should generate an error: -if ( ../tools/affcompare file://:wrongphrase@/$srcdir/encrypted.aff $srcdir/encrypted.iso ) ; then +if ( ../tools/affcompare file://:wrongphrase@/$srcdir/encrypted.aff $srcdir/encrypted.raw ) ; then echo Does not verify with correct decryption passphrase. exit 1 else diff --git a/tools/Makefile.am b/tools/Makefile.am index 09ab831..e5b68ba 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -27,7 +27,7 @@ affstats_SOURCES = affstats.cpp affverify_SOURCES = affverify.cpp aff_bom.h aff_bom.cpp affxml_SOURCES = affxml.cpp unix4win32.h -INCLUDES = -I@top_srcdir@/lib/ +AM_CPPFLAGS = -I@top_srcdir@/lib/ LDADD = @top_builddir@/lib/libafflib.la affuse_CFLAGS = @FUSE_CFLAGS@ diff --git a/tools/test_afsegment.sh b/tools/test_afsegment.sh index ca1edb4..0793b81 100755 --- a/tools/test_afsegment.sh +++ b/tools/test_afsegment.sh @@ -6,13 +6,16 @@ export PATH=$srcdir:../tools:../../tools:.:$PATH BLANK_BASE=`mktemp -t blankXXXXX` +BLANK_RAW=$BLANK_BASE.raw BLANK_AFF=$BLANK_BASE.aff unset AFFLIB_PASSPHRASE echo === Putting a new metadata segment into blank.aff === /bin/rm -f $BLANK_AFF -affcopy /dev/null $BLANK_AFF + +cp /dev/null $BLANK_RAW +affcopy $BLANK_RAW $BLANK_AFF affsegment -ssegname=testseg1 $BLANK_AFF if [ x"testseg1" = x`affsegment -p segname $BLANK_AFF` ] ; then echo affsegment worked! @@ -20,5 +23,5 @@ else echo affsegment does not work properly exit 1 fi -/bin/rm -f $BLANK_AFF +/bin/rm -f $BLANK_RAW $BLANK_AFF diff --git a/tools/test_crypto.sh b/tools/test_crypto.sh index 2e636ce..20db900 100755 --- a/tools/test_crypto.sh +++ b/tools/test_crypto.sh @@ -12,7 +12,7 @@ export PATH=$srcdir:../tools:../../tools:.:$PATH BASE=`mktemp -t encryptedXXXXXX` ENCRYPTED_AFF=$BASE.aff ENCRYPTED_AFD=$BASE.afd -PLAINTEXT_ISO=$BASE.iso +PLAINTEXT_ISO=$BASE.raw echo Making encrypted AFF from stored value diff --git a/tools/test_fatty.sh b/tools/test_fatty.sh index 7a6ce06..90d572b 100644 --- a/tools/test_fatty.sh +++ b/tools/test_fatty.sh @@ -1,3 +1,3 @@ # This file is a work of a US government employee and as such is in the Public domain. # Simson L. Garfinkel, March 12, 2012 -./affconvert -o file://:password@/fatty.afd fatty.iso +./affconvert -o file://:password@/fatty.afd fatty.raw diff --git a/tools/test_passphrase.sh b/tools/test_passphrase.sh index 7bdebb7..cb9fdec 100755 --- a/tools/test_passphrase.sh +++ b/tools/test_passphrase.sh @@ -12,7 +12,7 @@ unset AFFLIB_PASSPHRASE BLANK_BASE=`mktemp -t blankXXXXX` BLANK_AFF=$BLANK_BASE.aff -BLANK_ISO=$BLANK_BASE.iso +BLANK_ISO=$BLANK_BASE.raw BLANK_ENCRYPTED_AFF=${BLANK_BASE}_encrypted.aff WORDS=`mktemp -t wordsXXXX` diff --git a/tools/test_recovery.sh b/tools/test_recovery.sh index 24ca517..71be9e6 100755 --- a/tools/test_recovery.sh +++ b/tools/test_recovery.sh @@ -10,7 +10,7 @@ export PATH=$srcdir:../tools:../../tools:.:$PATH RECOVERY_BASE=`mktemp -t recoveryXXXX` RECOVERY_KEY=$RECOVERY_BASE.key RECOVERY_BAK=$RECOVERY_BASE.bak -RECOVERY_ISO=$RECOVERY_BASE.iso +RECOVERY_ISO=$RECOVERY_BASE.raw RECOVERY_AFM=$RECOVERY_BASE.afm RECOVERY_PEM=$RECOVERY_BASE.pem @@ -44,7 +44,7 @@ echo =========== echo Step 2: VERIFYING SIGNATURE if ! affverify $RECOVERY_AFM ; then exit 1 ; fi echo =========== -echo Step 3: CORRUPTING FILE recovery.iso +echo Step 3: CORRUPTING FILE recovery.raw dd if=/dev/random of=$RECOVERY_ISO count=1 skip=1 conv=notrunc echo =========== echo Step 4: ATTEMPTING RECOVERY diff --git a/tools/test_sealing.sh b/tools/test_sealing.sh index d2a38b7..77d1257 100755 --- a/tools/test_sealing.sh +++ b/tools/test_sealing.sh @@ -8,7 +8,7 @@ BASE=`mktemp -t testfileXXXX` SEALING_KEY=$BASE.sealing.key SEALING_PEM=$BASE.sealing.pem -EVIDENCE_ISO=$BASE.evidence.iso +EVIDENCE_ISO=$BASE.evidence.raw EVIDENCE_AFF=$BASE.evidence.aff /bin/rm -f $SEALING_KEY $SEALING_PEM $EVIDENCE_ISO $EVIDENCE_AFF diff --git a/tools/test_signing.sh b/tools/test_signing.sh index e7debd9..424a554 100755 --- a/tools/test_signing.sh +++ b/tools/test_signing.sh @@ -22,8 +22,12 @@ echo TEST $0 echo === MAKING THE TEST FILES === export PATH=$srcdir:../tools:../../tools:.:$PATH -test_make_random_iso.sh rawevidence.iso +test_make_random_iso.sh rawevidence.raw +if [ ! -r rawevidence.raw ]; then + echo rawevidence.raw not made + exit 1 +fi echo ==== AFSIGN TEST === echo Making X.509 keys @@ -35,8 +39,14 @@ openssl req -x509 -newkey rsa:1024 -keyout $ARCHIVES_PEM -out $ARCHIVES_PEM -nod echo Making an AFF file to sign rm -f $EVIDENCE evidence?.aff -affconvert -o $EVIDENCE rawevidence.iso -echo Initial AFF file +ls -l rawevidence.raw +# echo affconvert -o $EVIDENCE rawevidence.raw +# pwd +# which affconvert +# affconvert -o junk.aff rawevidence.raw +affconvert -o $EVIDENCE rawevidence.raw +echo Initial AFF file made: +ls -l $EVIDENCE if ! affinfo -a $EVIDENCE ; then exit 1 ; fi echo Signing AFF file... @@ -51,11 +61,11 @@ echo Signature test 1 passed echo Testing chain-of-custody signatures echo Step 10: Copying original raw file to evidence1.aff -if ! affcopy -k $AGENT_PEM rawevidence.iso evidence1.aff ; then exit 1; fi +if ! affcopy -k $AGENT_PEM rawevidence.raw evidence1.aff ; then exit 1; fi echo Step 11: Running affinfo on evidence1.aff if ! affinfo -a evidence1.aff ; then exit 1 ; fi -echo Step 12: Comparing rawevidence.iso to evidence1.aff -if ! affcompare rawevidence.iso evidence1.aff ; then exit 1 ; fi +echo Step 12: Comparing rawevidence.raw to evidence1.aff +if ! affcompare rawevidence.raw evidence1.aff ; then exit 1 ; fi echo Step 13: Verifying evidence1 if ! affverify evidence1.aff ; then exit 1 ; fi @@ -63,18 +73,18 @@ echo echo Making the second generation copy echo "This copy was made by the analyst" | affcopy -z -k $ANALYST_PEM -n evidence1.aff $EVIDENCE2 if ! affinfo -a $EVIDENCE2 ; then exit 1 ; fi -if ! affcompare rawevidence.iso $EVIDENCE2 ; then exit 1 ; fi +if ! affcompare rawevidence.raw $EVIDENCE2 ; then exit 1 ; fi if ! affverify $EVIDENCE2 ; then exit 1 ; fi echo echo Making the third generation copy echo "This copy was made by the archives" | affcopy -z -k $ARCHIVES_PEM -n $EVIDENCE2 $EVIDENCE3 if ! affinfo -a $EVIDENCE3 ; then exit 1 ; fi -if ! affcompare rawevidence.iso $EVIDENCE3 ; then exit 1 ; fi +if ! affcompare rawevidence.raw $EVIDENCE3 ; then exit 1 ; fi if ! affverify $EVIDENCE3 ; then exit 1 ; fi echo All tests passed successfully echo Erasing temporary files. -rm -f $AGENT_PEM $ARCHIVES_PEM $ANALYST_PEM $EVIDENCE evidence.afm rawevidence.iso cevidence.iso $EVIDENCE2 $EVIDENCE3 $EVIDENCE +rm -f $AGENT_PEM $ARCHIVES_PEM $ANALYST_PEM $EVIDENCE evidence.afm rawevidence.raw cevidence.raw $EVIDENCE2 $EVIDENCE3 $EVIDENCE exit 0 diff --git a/win32/affconfig.h b/win32/affconfig.h new file mode 100755 index 0000000..620f1f0 --- /dev/null +++ b/win32/affconfig.h @@ -0,0 +1,68 @@ +#include "../affconfig.h" +#undef C_ALLOCA +#undef DISABLE_QEMU +#undef HAVE_ALLOCA_H +#undef HAVE_CTYPE_H +#undef HAVE_CURSES_H +#undef HAVE_DIRENT_H +#undef HAVE_ERR +#undef HAVE_ERRX +#undef HAVE_ERR_H +#undef HAVE_GETPROGNAME +#undef HAVE_INTTYPES_H +#undef HAVE_LINUX_FS_H +#undef HAVE_MALLOC_H +#undef HAVE_NCURSES_TERM_H +#undef HAVE_NDIR_H +#undef HAVE_OPENSSL_FIPS_SHA_H +#undef HAVE_POPEN +#undef HAVE_SETUPTERM +#undef HAVE_SHA256_H +#undef HAVE_STRINGS_H +#undef HAVE_STRLCAT +#undef HAVE_STRLCPY +#undef HAVE_SYS_CDEFS_H +#undef HAVE_SYS_DIR_H +#undef HAVE_SYS_DISK_H +#undef HAVE_SYS_IOCTL_H +#undef HAVE_SYS_NDIR_H +#undef HAVE_SYS_PARAM_H +#undef HAVE_SYS_SOCKET_H +#undef HAVE_SYS_TIME_H +#undef HAVE_SYS_VFS_H +#undef HAVE_TERMCAP_H +#undef HAVE_TERM_H +#undef HAVE_UNISTD_H +#undef HAVE_VALLOC +#undef HAVE_WARN +#undef HAVE_WARNX +#undef TM_IN_SYS_TIME +#undef USE_S3 +#undef USE_QEMU +#undef USE_SPARSEIMAGE +#undef HAVE_STDINT_H +#undef HAVE_INTTYPES_H +#undef HAVE_LIBNCUSES +#undef HAVE_PUTENV +#undef HAVE_READLINE_READLINE_H +#undef HAVE_LIBREADLINE +#undef HAVE_ARPA_INET_H +#undef HAVE_SYS_FILE_H +#undef HAVE_FLOCK +#undef HAVE_INTTYPES_H + +#define HAVE_LIBEWF 1 +/* Define to 1 if you have the libewf_get_bytes_per_sector function. */ +#define HAVE_LIBEWF_GET_BYTES_PER_SECTOR 1 +/* Define to 1 if libewf_get_bytes_per_sector takes value as an argument. */ +#define HAVE_LIBEWF_GET_BYTES_PER_SECTOR_ARGUMENT_VALUE 1 +/* Define to 1 if you have the libewf_get_chunk_size function. */ +#define HAVE_LIBEWF_GET_CHUNK_SIZE 1 +/* Define to 1 if libewf_get_chunk_size takes value as an argument. */ +#define HAVE_LIBEWF_GET_CHUNK_SIZE_ARGUMENT_VALUE 1 +/* Define to 1 if you have the libewf_get_media_size function. */ +#define HAVE_LIBEWF_GET_MEDIA_SIZE 1 +/* Define to 1 if libewf_get_media_size takes value as an argument. */ +#define HAVE_LIBEWF_GET_MEDIA_SIZE_ARGUMENT_VALUE 1 +/* Define to 1 if you have the header file. */ +#define HAVE_LIBEWF_H 1