Commit 4a3f5d80 authored by hybrid's avatar hybrid

Remove unused files.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2992 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 97d4c2f7
......@@ -1201,7 +1201,6 @@
<Unit filename="aesGladman/aeskey.cpp" />
<Unit filename="aesGladman/aesopt.h" />
<Unit filename="aesGladman/aestab.cpp" />
<Unit filename="aesGladman/bzlib.h" />
<Unit filename="aesGladman/fileenc.cpp" />
<Unit filename="aesGladman/fileenc.h" />
<Unit filename="aesGladman/hmac.cpp" />
......
......@@ -9,7 +9,7 @@ CppCompiler=-D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS -D_USRDLL -DIR
Includes=..\..\include;zlib
Linker=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lwinmm -lopengl32_@@_
Libs=
UnitCount=647
UnitCount=646
Folders=doc,include,include/core,include/gui,include/io,include/scene,include/video,Irrlicht,Irrlicht/extern,Irrlicht/extern/jpeglib,Irrlicht/extern/libpng,Irrlicht/extern/zlib,Irrlicht/extern/aesGladman,Irrlicht/gui,Irrlicht/io,Irrlicht/io/archive,Irrlicht/io/attributes,Irrlicht/io/file,Irrlicht/io/xml,Irrlicht/irr,Irrlicht/irr/IrrlichtDevice,Irrlicht/scene,Irrlicht/scene/animators,Irrlicht/scene/collision,Irrlicht/scene/mesh,Irrlicht/scene/mesh/loaders,Irrlicht/scene/mesh/writers,Irrlicht/scene/nodes,Irrlicht/scene/nodes/particles,Irrlicht/video,"Irrlicht/video/Burning Video",Irrlicht/video/DirectX8,Irrlicht/video/DirectX9,Irrlicht/video/Null,Irrlicht/video/Null/Loader,Irrlicht/video/Null/Writer,Irrlicht/video/OpenGL,Irrlicht/video/Software
ObjFiles=
PrivateResource=
......@@ -6389,7 +6389,7 @@ OverrideBuildCmd=0
BuildCmd=
[Unit635]
FileName=aesGladman\bzlib.h
FileName=aesGladman\sha2.h
Folder=Irrlicht/extern/aesGladman
Compile=1
CompileCpp=0
......@@ -6508,13 +6508,3 @@ Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit647]
FileName=aesGladman\sha2.h
Folder=Irrlicht/extern/aesGladman
Compile=1
CompileCpp=0
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
......@@ -2393,9 +2393,6 @@
<File
RelativePath=".\aesGladman\aestab.cpp">
</File>
<File
RelativePath=".\aesGladman\bzlib.h">
</File>
<File
RelativePath=".\aesGladman\fileenc.cpp">
</File>
......
......@@ -3324,10 +3324,6 @@
RelativePath=".\aesGladman\aestab.cpp"
>
</File>
<File
RelativePath=".\aesGladman\bzlib.h"
>
</File>
<File
RelativePath=".\aesGladman\fileenc.cpp"
>
......
......@@ -3033,10 +3033,6 @@
RelativePath=".\aesGladman\aestab.cpp"
>
</File>
<File
RelativePath=".\aesGladman\bzlib.h"
>
</File>
<File
RelativePath=".\aesGladman\fileenc.cpp"
>
......
......@@ -2963,10 +2963,6 @@
RelativePath=".\aesGladman\aestab.cpp"
>
</File>
<File
RelativePath=".\aesGladman\bzlib.h"
>
</File>
<File
RelativePath=".\aesGladman\fileenc.cpp"
>
......
/*-------------------------------------------------------------*/
/*--- Public header file for the library. ---*/
/*--- bzlib.h ---*/
/*-------------------------------------------------------------*/
/*--
This file is a part of bzip2 and/or libbzip2, a program and
library for lossless, block-sorting data compression.
Copyright (C) 1996-2002 Julian R Seward. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Cambridge, UK.
jseward@acm.org
bzip2/libbzip2 version 1.0 of 21 March 2000
This program is based on (at least) the work of:
Mike Burrows
David Wheeler
Peter Fenwick
Alistair Moffat
Radford Neal
Ian H. Witten
Robert Sedgewick
Jon L. Bentley
For more information on these sources, see the manual.
--*/
#ifndef _BZLIB_H
#define _BZLIB_H
#define BZ_RUN 0
#define BZ_FLUSH 1
#define BZ_FINISH 2
#define BZ_OK 0
#define BZ_RUN_OK 1
#define BZ_FLUSH_OK 2
#define BZ_FINISH_OK 3
#define BZ_STREAM_END 4
#define BZ_SEQUENCE_ERROR (-1)
#define BZ_PARAM_ERROR (-2)
#define BZ_MEM_ERROR (-3)
#define BZ_DATA_ERROR (-4)
#define BZ_DATA_ERROR_MAGIC (-5)
#define BZ_IO_ERROR (-6)
#define BZ_UNEXPECTED_EOF (-7)
#define BZ_OUTBUFF_FULL (-8)
#define BZ_CONFIG_ERROR (-9)
typedef
struct {
char *next_in;
unsigned int avail_in;
unsigned int total_in_lo32;
unsigned int total_in_hi32;
char *next_out;
unsigned int avail_out;
unsigned int total_out_lo32;
unsigned int total_out_hi32;
void *state;
void *(*bzalloc)(void *,int,int);
void (*bzfree)(void *,void *);
void *opaque;
}
bz_stream;
#ifndef BZ_IMPORT
#define BZ_EXPORT
#endif
/* Need a definitition for FILE */
#include <stdio.h>
#ifdef _WIN32
# include <windows.h>
# ifdef small
/* windows.h define small to char */
# undef small
# endif
# ifdef BZ_EXPORT
# define BZ_API(func) WINAPI func
# define BZ_EXTERN extern
# else
/* import windows dll dynamically */
# define BZ_API(func) (WINAPI * func)
# define BZ_EXTERN
# endif
#else
# define BZ_API(func) func
# define BZ_EXTERN extern
#endif
/*-- Core (low-level) library functions --*/
BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
bz_stream* strm,
int blockSize100k,
int verbosity,
int workFactor
);
BZ_EXTERN int BZ_API(BZ2_bzCompress) (
bz_stream* strm,
int action
);
BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
bz_stream* strm
);
BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
bz_stream *strm,
int verbosity,
int small
);
BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
bz_stream* strm
);
BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
bz_stream *strm
);
/*-- High(er) level library functions --*/
#ifndef BZ_NO_STDIO
#define BZ_MAX_UNUSED 5000
typedef void BZFILE;
BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
int* bzerror,
FILE* f,
int verbosity,
int small,
void* unused,
int nUnused
);
BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
int* bzerror,
BZFILE* b
);
BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
int* bzerror,
BZFILE* b,
void** unused,
int* nUnused
);
BZ_EXTERN int BZ_API(BZ2_bzRead) (
int* bzerror,
BZFILE* b,
void* buf,
int len
);
BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
int* bzerror,
FILE* f,
int blockSize100k,
int verbosity,
int workFactor
);
BZ_EXTERN void BZ_API(BZ2_bzWrite) (
int* bzerror,
BZFILE* b,
void* buf,
int len
);
BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
int* bzerror,
BZFILE* b,
int abandon,
unsigned int* nbytes_in,
unsigned int* nbytes_out
);
BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
int* bzerror,
BZFILE* b,
int abandon,
unsigned int* nbytes_in_lo32,
unsigned int* nbytes_in_hi32,
unsigned int* nbytes_out_lo32,
unsigned int* nbytes_out_hi32
);
#endif
/*-- Utility functions --*/
BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
char* dest,
unsigned int* destLen,
char* source,
unsigned int sourceLen,
int blockSize100k,
int verbosity,
int workFactor
);
BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
char* dest,
unsigned int* destLen,
char* source,
unsigned int sourceLen,
int small,
int verbosity
);
/*--
Code contributed by Yoshioka Tsuneo
(QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
to support better zlib compatibility.
This code is not _officially_ part of libbzip2 (yet);
I haven't tested it, documented it, or considered the
threading-safeness of it.
If this code breaks, please contact both Yoshioka and me.
--*/
BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
void
);
#ifndef BZ_NO_STDIO
BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
const char *path,
const char *mode
);
BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
int fd,
const char *mode
);
BZ_EXTERN int BZ_API(BZ2_bzread) (
BZFILE* b,
void* buf,
int len
);
BZ_EXTERN int BZ_API(BZ2_bzwrite) (
BZFILE* b,
void* buf,
int len
);
BZ_EXTERN int BZ_API(BZ2_bzflush) (
BZFILE* b
);
BZ_EXTERN void BZ_API(BZ2_bzclose) (
BZFILE* b
);
BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
BZFILE *b,
int *errnum
);
#endif
#endif
/*
---------------------------------------------------------------------------
Copyright (c) 2002, Dr Brian Gladman < >, Worcester, UK.
All rights reserved.
LICENSE TERMS
The free distribution and use of this software in both source and binary
form is allowed (with or without changes) provided that:
1. distributions of this source code include the above copyright
notice, this list of conditions and the following disclaimer;
2. distributions in binary form include the above copyright
notice, this list of conditions and the following disclaimer
in the documentation and/or other associated materials;
3. the copyright holder's name is not used to endorse products
built using this software without specific written permission.
ALTERNATIVELY, provided that this notice is retained in full, this product
may be distributed under the terms of the GNU General Public License (GPL),
in which case the provisions of the GPL apply INSTEAD OF those given above.
DISCLAIMER
This software is provided 'as is' with no explicit or implied warranties
in respect of its properties, including, but not limited to, correctness
and/or fitness for purpose.
---------------------------------------------------------------------------
Issue Date: 18th November 2008
A simple file encryption application based on
a. RFC2898 for key derivation (using HMAC-SHA1)
b. AES in CTR mode for encryption
c. HMAC-SHA1 for authentication
d. A Random Data Pool based on Peter Gutmann's ideas
e. compression using BZIP2
The command line is:
encfile password infile
If the last file name extension is ".enc", the file is assumed to be an
encrypted file and an attempt is made to decrypt it with the given password,
writing the output to a file with the same name except for the ".enc" on the
end. Otherwise the file is encrypted with the given password and the output
is written to a file with the same name except that ".enc" is added on the
end.
*/
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <windows.h>
#include "bzlib.h"
#include "fileenc.h"
#include "prng.h"
/* local error values */
#define ERROR_USAGE 1
#define ERROR_PASSWORD_LENGTH 2
#define ERROR_OUT_OF_MEMORY 3
#define ERROR_INPUT_FILE 4
#define ERROR_OUTPUT_FILE 5
#define ERROR_BAD_PASSWORD 6
#define ERROR_BAD_AUTHENTICATION 7
/* these values are for reporting BZIP2 errors (7 - bzip2_error_value) */
#define ERROR_BZ_SEQUENCE 8
#define ERROR_BZ_PARAM 9
#define ERROR_BZ_MEM 10
#define ERROR_BZ_DATA 11
#define ERROR_BZ_DATA_MAGIC 12
#define ERROR_BZ_IO 13
#define ERROR_BZ_UNEXPECTED_EOF 14
#define ERROR_BZ_OUTBUFF_FULL 15
#define ERROR_BZ_CONFIG_ERROR 16
/* the size of the local buffers for file handling */
#define FILE_BUF_SIZE 1024
/* error messages for user output */
char *err_string[] =
{
"\nusage: encfile password infile outfile\n",
"\npassword is too short\n",
"\nmemory allocation has failed\n",
"\ncannot open the input file (%s)\n",
"\ncannot open the output file (%s)\n",
"\nbad password\n",
"\ndamaged file or incorrect password\n",
"\nBZIP2 sequence error\n",
"\nBZIP2 parameter error\n",
"\nBZIP2 memory error\n",
"\nBZIP2 data error\n",
"\nBZIP2 magic data error\n",
"\nBZIP2 input/output error\n",
"\nBZIP2 unexpected end of file error\n",
"\nBZIP2 full output buffer error\n",
"\nBZIP2 configuration error\n"
};
/* simple entropy collection function that uses the fast timer */
/* since we are not using the random pool for generating secret */
/* keys we don't need to be too worried about the entropy quality */
/* Modified in 2008 to add revised entropy generation courtesy of */
/* WinZip Inc. This code now performs the following sequence of */
/* entropy generation operations on sequential calls: */
/* */
/* - the current 8-byte Windows performance counter value */
/* - an 8-byte representation of the current date/time */
/* - an 8-byte value built from the current process ID */
/* and thread ID */
/* - all subsequent calls return the then-current 8-byte */
/* performance counter value */
int entropy_fun(unsigned char buf[], unsigned int len)
{ unsigned __int64 pentium_tsc[1];
unsigned int i;
static unsigned int num = 0;
switch(num)
{
/* use a value that is unlikely to repeat across system reboots */
case 1:
++num;
GetSystemTimeAsFileTime((FILETIME *)pentium_tsc);
break;
/* use a value that distinguishes between different instances of this */
/* code that might be running on different processors at the same time */
case 2:
++num;
{ unsigned __int32 processtest = GetCurrentProcessId();
unsigned __int32 threadtest = GetCurrentThreadId();
pentium_tsc[0] = processtest;
pentium_tsc[0] = (pentium_tsc[0] << 32) + threadtest;
}
break;
/* use a rapidly-changing value -- check QueryPerformanceFrequency() */
/* to ensure that QueryPerformanceCounter() will work */
case 0:
++num;
default:
QueryPerformanceCounter((LARGE_INTEGER *)pentium_tsc);
break;
}
for(i = 0; i < 8 && i < len; ++i)
buf[i] = ((unsigned char*)pentium_tsc)[i];
return i;
}
/* this is the main file encryption/decryption routine code */
int main(int argc, char *argv[])
{ FILE *inf, *outf;
unsigned char buf[FILE_BUF_SIZE], buf2[FILE_BUF_SIZE];
unsigned char tmp_buf1[16], tmp_buf2[16], salt[16], *fname = 0, *cp;
fcrypt_ctx zcx[1];
bz_stream bz_ctx[1]; /* the bzip2 compression context */
int len, flen, err = 0;
unsigned char mode;
if(argc != 3) /* the command line is bad */
{
err = ERROR_USAGE; goto error_0;
}
len = (int)strlen(argv[1]);
if(len < 8) /* password is too short */
{
err = ERROR_PASSWORD_LENGTH; goto error_0;
}
/* set the key length based on password length assuming that there */
/* are about 4 bits of entropy per password character (optimistic!) */
/* (the key length and other mode dependent parameter values are */
/* set using macros defined in fileenc.h) */
mode = (len < 32 ? 1 : len < 48 ? 2 : 3);
/* save input file name to a temporary memory area with extra space */
/* for the extension ".enc" to be added */
fname = (unsigned char*)malloc(strlen(argv[2]) + 5);
if(fname == NULL)
{
err = ERROR_OUT_OF_MEMORY; goto error_0;
}
/* open the input file for binary input */
strcpy(fname, argv[2]);
if((inf = fopen(fname, "rb")) == NULL)
{
err = ERROR_INPUT_FILE; goto error_1;
}
/* if the file name extension is ".enc" assume this is an encrypted */
/* file */
if((cp = strrchr(fname, '.')) && strcmp(cp, ".enc") == 0)
{
*cp = 0;
mode |= 4; /* hence signal decryption */
}
else /* otherwise add ".enc" to file name to */
strcat(fname, ".enc"); /* mark the file as an encrypted one */
/* open the output file for binary output */
if((outf = fopen(fname, "wb")) == NULL)
{
err = ERROR_OUTPUT_FILE; goto error_2;
}
/* use BZIP2's default memory allocation */
bz_ctx->bzalloc = NULL;
bz_ctx->bzfree = NULL;
bz_ctx->opaque = NULL;
if(!(mode & 4)) /* perfrom an encryption operation */
{
prng_ctx rng[1]; /* the context for the random number pool */
prng_init(entropy_fun, rng); /* initialise RNG, */
prng_rand(salt, SALT_LENGTH(mode), rng); /* the salt and */
err = BZ2_bzCompressInit(bz_ctx, 5, 0, 0); /* compression */
if(err != BZ_OK)
{
err = 7 - err; goto error_2;
}
/* write the salt value to the output file */
fwrite(salt, sizeof(unsigned char), SALT_LENGTH(mode), outf);
/* initialise encryption and authentication */
#ifdef PASSWORD_VERIFIER
fcrypt_init(mode, argv[1], (unsigned int)strlen(argv[1]), salt, tmp_buf1, zcx);
/* write the password verifier (if used) */
fwrite(tmp_buf1, sizeof(unsigned char), PWD_VER_LENGTH, outf);
#else
fcrypt_init(mode, argv[1], (unsigned int)strlen(argv[1]), salt, zcx);
#endif
/* compress, encrypt and authenticate file */
while(len = (int)fread(buf, sizeof(unsigned char), FILE_BUF_SIZE, inf))
{
bz_ctx->next_in = buf; /* compress from buf to buf2 */
bz_ctx->avail_in = len;
while(bz_ctx->avail_in > 0)
{ /* pass all input to compressor */
bz_ctx->next_out = buf2;
bz_ctx->avail_out = FILE_BUF_SIZE;
err = BZ2_bzCompress(bz_ctx, BZ_RUN);
if(err != BZ_RUN_OK) /* check for errors */
{
err = 7 - err; goto error_2;
}
/* if there is output, encrypt, authenticate and */
/* write it to the output file */
if(len = bz_ctx->next_out - buf2)
{
fcrypt_encrypt(buf2, len, zcx);
len = fwrite(buf2, sizeof(unsigned char), len, outf);
}
}
}
/* finish the compression operation */
bz_ctx->next_in = NULL;
bz_ctx->avail_in = 0;
do
{ /* load output buffer from compressor */
bz_ctx->next_out = buf2;
bz_ctx->avail_out = FILE_BUF_SIZE;
err = BZ2_bzCompress(bz_ctx, BZ_FINISH);
if(err != BZ_FINISH_OK && err != BZ_STREAM_END)
{
err = 7 - err; goto error_2;
}
/* encrypt, authenticate amd write any */
/* output to output file */
if(len = bz_ctx->next_out - buf2)
{
fcrypt_encrypt(buf2, len, zcx);
len = fwrite(buf2, sizeof(unsigned char), len, outf);
}
}
while /* until the compressor end signal */
(err != BZ_STREAM_END);
if(BZ2_bzCompressEnd(bz_ctx) != BZ_OK)
{
err = 7 - err; goto error_2;
}
else
err = 0;
/* write the MAC */
fcrypt_end(tmp_buf1, zcx);
fwrite(tmp_buf1, sizeof(unsigned char), MAC_LENGTH(mode), outf);
/* and close random pool */
prng_end(rng);
}
else /* perfrom a decryption operation */
{
/* we need to know the file length to avoid reading the MAC */
fseek(inf, 0, SEEK_END);
flen = ftell(inf);
fseek(inf, 0, SEEK_SET);
mode &= 3;
/* initialise decryption, authentication and decompression */
err = BZ2_bzDecompressInit(bz_ctx, 0, 0); /* decompression */
if(err != BZ_OK)
{
err = 7 - err; goto error_2;
}
/* recover the password salt */
fread(salt, sizeof(unsigned char), SALT_LENGTH(mode), inf); flen -= SALT_LENGTH(mode);
#ifdef PASSWORD_VERIFIER
fcrypt_init(mode, argv[1], (unsigned int)strlen(argv[1]), salt, tmp_buf2, zcx);
/* recover the password verifier (if used) */
fread(tmp_buf1, sizeof(unsigned char), PWD_VER_LENGTH, inf); flen -= PWD_VER_LENGTH;
/* check password verifier */
if(memcmp(tmp_buf1, tmp_buf2, PWD_VER_LENGTH))
{
err = ERROR_BAD_PASSWORD; fclose(outf); goto error_2;
}
#else
fcrypt_init(mode, argv[1], (unsigned int)strlen(argv[1]), salt, zcx);
#endif
flen -= MAC_LENGTH(mode); /* avoid reading the MAC */
len = (flen < FILE_BUF_SIZE ? flen : FILE_BUF_SIZE);
/* decrypt the file */
while(len = (int)fread(buf, sizeof(unsigned char), len, inf))
{
/* decrypt a block */
flen -= len;
fcrypt_decrypt(buf, len, zcx);
bz_ctx->next_in = buf;
bz_ctx->avail_in = len;
while(bz_ctx->avail_in > 0)
{ /* pass all input to compressor */
bz_ctx->next_out = buf2;
bz_ctx->avail_out = FILE_BUF_SIZE;
err = BZ2_bzDecompress(bz_ctx);
if(err != BZ_OK && err != BZ_STREAM_END)
{
err = 7 - err; goto error_2;
}
/* write any output from decompressor */
if(len = bz_ctx->next_out - buf2)
fwrite(buf2, sizeof(unsigned char), len, outf);
}
len = (flen < FILE_BUF_SIZE ? flen : FILE_BUF_SIZE);
}
/* complete the decompression operation and write any */
/* output that results */
bz_ctx->next_in = NULL;
bz_ctx->avail_in = 0;
while(err != BZ_STREAM_END)
{
bz_ctx->next_out = buf2;
bz_ctx->avail_out = FILE_BUF_SIZE;
err = BZ2_bzDecompress(bz_ctx);
if(err != BZ_OK && err != BZ_STREAM_END)
{
err = 7 - err; goto error_2;
}
if(len = bz_ctx->next_out - buf2)
fwrite(buf2, sizeof(unsigned char), len, outf);
}
if(BZ2_bzDecompressEnd(bz_ctx) != BZ_OK)
{
err = 7 - err; goto error_2;
}
else
err = 0;
/* calculate the MAC value */
fcrypt_end(tmp_buf2, zcx);
/* now read the stored MAC value */
fread(tmp_buf1, sizeof(unsigned char), MAC_LENGTH(mode), inf);
/* compare the stored and calculated MAC values */
if(memcmp(tmp_buf1, tmp_buf2, MAC_LENGTH(mode)))
{ /* authentication failed */
err = ERROR_BAD_AUTHENTICATION;
fclose(outf);
/* delete the (bad) output file */
remove(fname);
goto error_2;
}
}
fclose(outf);
error_2:
fclose(inf);
error_1:
error_0:
if(err)
printf(err_string[err - 1], fname);
if(fname != 0)
free(fname);
return -err;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment