Skip to content
This repository has been archived by the owner on Mar 2, 2018. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:simsong/AFFLIBv3
Browse files Browse the repository at this point in the history
  • Loading branch information
simsong committed Oct 28, 2013
2 parents 58c2812 + c7e5e47 commit 18b473e
Show file tree
Hide file tree
Showing 22 changed files with 325 additions and 38 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,7 @@ lib/version.h
makefile
encrypted.aff
affconfig.h
*.trs
*.dirstamp
lib/aftest
afflib-?.?.?
11 changes: 2 additions & 9 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ release:
make prerelease
make distcheck
make the_release
make distribute_release

prerelease:
@echo Making sure SVN is up to date
Expand All @@ -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 \
Expand All @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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],[[email protected]])
AC_INIT([AFFLIB],[3.7.2],[[email protected]])
AM_INIT_AUTOMAKE
AM_MAINTAINER_MODE

Expand Down
2 changes: 2 additions & 0 deletions lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/afflib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions lib/afflib_pages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 *)&sectorsize)==0){
af->badflag_set = 1;
}
Expand Down
14 changes: 9 additions & 5 deletions lib/aftest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;i<sizeof(buf);i++){
if(buf[i]!=0) err(1,"data error; buf[%d]=%d\n",i,buf[i]);
if(r==0){
printf("sparse test produces a read of 0 bytes. I guess this is the new behavior\n");
} else {
if(r!=sizeof(buf)){
errx(1,"Tried to read %zd bytes at mult/2; got %zd bytes\n",sizeof(buf),r);
}
for(u_int i=0;i<sizeof(buf);i++){
if(buf[i]!=0) err(1,"data error; buf[%d]=%d\n",i,buf[i]);
}
}

/* Now try to read the last page in the file */
Expand Down
55 changes: 55 additions & 0 deletions lzma443/C/7zip/Archive/7z_C/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
PROG = 7zDec.exe

!IFNDEF O
!IFDEF CPU
O=$(CPU)
!ELSE
O=O
!ENDIF
!ENDIF

CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ -GS-
CFLAGS_O1 = $(CFLAGS) -O1
CFLAGS_O2 = $(CFLAGS) -O2

LFLAGS = $(LFLAGS) -nologo -OPT:NOWIN98

PROGPATH = $O\$(PROG)

COMPL_O1 = $(CPP) $(CFLAGS_O1) $**
COMPL_O2 = $(CPP) $(CFLAGS_O2) $**
COMPL = $(CPP) $(CFLAGS_O1) $**


7Z_OBJS = \
$O\7zAlloc.obj \
$O\7zBuffer.obj \
$O\7zCrc.obj \
$O\7zDecode.obj \
$O\7zExtract.obj \
$O\7zHeader.obj \
$O\7zIn.obj \
$O\7zItem.obj \
$O\7zMain.obj \
$O\7zMethodID.obj \

OBJS = \
$(7Z_OBJS) \
$O\LzmaDecode.obj \

all: $(PROGPATH)

clean:
-del /Q $(PROGPATH) $O\*.exe $O\*.dll $O\*.obj $O\*.lib $O\*.exp $O\*.res $O\*.pch

$O:
if not exist "$O" mkdir "$O"

$(PROGPATH): $O $(OBJS)
link $(LFLAGS) -out:$(PROGPATH) $(OBJS) $(LIBS)


$(7Z_OBJS): $(*B).c
$(COMPL)
$O\LzmaDecode.obj: ../../Compress/LZMA_C/$(*B).c
$(COMPL_O2)
100 changes: 100 additions & 0 deletions lzma443/C/7zip/Compress/LZMA_Alone/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
PROG = lzma.exe
CFLAGS = $(CFLAGS) -I ../../../
LIBS = $(LIBS) oleaut32.lib user32.lib

!IFNDEF O
!IFDEF CPU
O=$(CPU)
!ELSE
O=O
!ENDIF
!ENDIF

CFLAGS = $(CFLAGS) -nologo -EHsc -c -Fo$O/ -GS-
CFLAGS_O1 = $(CFLAGS) -O1
CFLAGS_O2 = $(CFLAGS) -O2

LFLAGS = $(LFLAGS) -nologo -OPT:NOWIN98

PROGPATH = $O\$(PROG)

COMPL_O1 = $(CPP) $(CFLAGS_O1) $**
COMPL_O2 = $(CPP) $(CFLAGS_O2) $**
COMPL = $(CPP) $(CFLAGS_O1) $**


LZMA_OBJS = \
$O\LzmaAlone.obj \
$O\LzmaBench.obj \
$O\LzmaRam.obj \

LZMA_OPT_OBJS = \
$O\LZMADecoder.obj \
$O\LZMAEncoder.obj \

COMMON_OBJS = \
$O\Alloc.obj \
$O\CRC.obj \
$O\CommandLineParser.obj \
$O\String.obj \
$O\StringConvert.obj \
$O\StringToInt.obj \
$O\Vector.obj

7ZIP_COMMON_OBJS = \
$O\InBuffer.obj \
$O\OutBuffer.obj \
$O\StreamUtils.obj \

LZ_OBJS = \
$O\LZInWindow.obj \
$O\LZOutWindow.obj \


OBJS = \
$(LZMA_OBJS) \
$(LZMA_OPT_OBJS) \
$(COMMON_OBJS) \
$(7ZIP_COMMON_OBJS) \
$(LZ_OBJS) \
$O\LzmaRamDecode.obj \
$O\LzmaDecode.obj \
$O\FileStreams.obj \
$O\FileIO.obj \
$O\RangeCoderBit.obj \
$O\BranchX86.obj \

all: $(PROGPATH)

clean:
-del /Q $(PROGPATH) $O\*.exe $O\*.dll $O\*.obj $O\*.lib $O\*.exp $O\*.res $O\*.pch

$O:
if not exist "$O" mkdir "$O"

$(PROGPATH): $O $(OBJS)
link $(LFLAGS) -out:$(PROGPATH) $(OBJS) $(LIBS)


$(LZMA_OBJS): $(*B).cpp
$(COMPL)
$(LZMA_OPT_OBJS): ../LZMA/$(*B).cpp
$(COMPL_O2)
$(COMMON_OBJS): ../../../Common/$(*B).cpp
$(COMPL)
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
$(COMPL)
$(LZ_OBJS): ../LZ/$(*B).cpp
$(COMPL)
$O\RangeCoderBit.obj: ../RangeCoder/$(*B).cpp
$(COMPL)
$O\LzmaRamDecode.obj: LzmaRamDecode.c
$(COMPL_O1)
$O\LzmaDecode.obj: ../LZMA_C/LzmaDecode.c
$(COMPL_O2)
$O\BranchX86.obj: ../Branch/BranchX86.c
$(COMPL_O2)
$O\FileStreams.obj: ../../Common/FileStreams.cpp
$(COMPL)
$O\FileIO.obj: ../../../Windows/FileIO.cpp
$(COMPL)
43 changes: 43 additions & 0 deletions lzma443/C/7zip/Compress/LZMA_C/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
PROG = lzmaDec.exe

!IFNDEF O
!IFDEF CPU
O=$(CPU)
!ELSE
O=O
!ENDIF
!ENDIF

CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ -GS-
CFLAGS_O1 = $(CFLAGS) -O1
CFLAGS_O2 = $(CFLAGS) -O2

LFLAGS = $(LFLAGS) -nologo -OPT:NOWIN98

PROGPATH = $O\$(PROG)

COMPL_O1 = $(CPP) $(CFLAGS_O1) $**
COMPL_O2 = $(CPP) $(CFLAGS_O2) $**
COMPL = $(CPP) $(CFLAGS_O1) $**


OBJS = \
$O\LzmaTest.obj \
$O\LzmaDecode.obj \

all: $(PROGPATH)

clean:
-del /Q $(PROGPATH) $O\*.exe $O\*.dll $O\*.obj $O\*.lib $O\*.exp $O\*.res $O\*.pch

$O:
if not exist "$O" mkdir "$O"

$(PROGPATH): $O $(OBJS)
link $(LFLAGS) -out:$(PROGPATH) $(OBJS) $(LIBS)


$O\LzmaTest.obj: $(*B).c
$(COMPL)
$O\LzmaDecode.obj: ../../Compress/LZMA_C/$(*B).c
$(COMPL_O2)
2 changes: 1 addition & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TESTS = test_decryption.sh
EXTRA_DIST = makeimage.cpp speedtests.py verify.py encrypted.aff encrypted.iso test_decryption.sh
EXTRA_DIST = makeimage.cpp speedtests.py verify.py encrypted.aff encrypted.raw test_decryption.sh


Binary file added tests/encrypted.aff
Binary file not shown.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/test_decryption.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions tools/test_afsegment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@

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!
else
echo affsegment does not work properly
exit 1
fi
/bin/rm -f $BLANK_AFF
/bin/rm -f $BLANK_RAW $BLANK_AFF

2 changes: 1 addition & 1 deletion tools/test_crypto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tools/test_fatty.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tools/test_passphrase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
Loading

0 comments on commit 18b473e

Please sign in to comment.