bcrypt-1.1.orig/0040700000550600055060000000000007540312627012677 5ustar tonontononbcrypt-1.1.orig/LICENSE0100644000550600055060000000327507537516276013736 0ustar tonontonon/* ==================================================================== * Copyright (c) 2002 Johnny Shelley * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. Neither the name of the author nor any contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESSED 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. * ==================================================================== */ bcrypt-1.1.orig/Makefile0100644000550600055060000000170507540057450014351 0ustar tonontononDEFAULTS = Makefile includes.h blowfish.h functions.h config.h CC = gcc CFLAGS = -O2 -Wall COMPILE = ${CC} ${CFLAGS} OBJS = main.o blowfish.o rwfile.o keys.o wrapbf.o endian.o wrapzl.o LDFLAGS = -L/usr/local/lib -lz PREFIX = /usr/local bcrypt: ${OBJS} Makefile ${COMPILE} -o bcrypt ${OBJS} ${LDFLAGS} install: bcrypt Makefile mkdir -p ${PREFIX}/bin;\ mkdir -p ${PREFIX}/man/man1;\ cp bcrypt ${PREFIX}/bin;\ cp bcrypt.1 ${PREFIX}/man/man1;\ chmod 755 ${PREFIX}/bin/bcrypt;\ chmod 644 ${PREFIX}/man/man1/bcrypt.1 main.o: main.c ${DEFAULTS} ${COMPILE} -c main.c blowfish.o: blowfish.c ${DEFAULTS} ${COMPILE} -c blowfish.c rwfile.o: rwfile.c ${DEFAULTS} ${COMPILE} -c rwfile.c keys.o: keys.c ${DEFAULTS} ${COMPILE} -c keys.c wrapbf.o: wrapbf.c ${DEFAULTS} ${COMPILE} -c wrapbf.c wrapzl.o: wrapzl.c ${DEFAULTS} ${COMPILE} -c wrapzl.c endian.o: endian.c ${DEFAULTS} ${COMPILE} -c endian.c clean: rm -rf *.o bcrypt bcrypt.core core bcrypt.tgz bcrypt-1.1.orig/README0100644000550600055060000001007007537773027013577 0ustar tonontononABOUT -- Bcrypt is a cross platform file encryption utility. Encrypted files are portable across all supported operating systems and processors. Passphrases are between 8 and 56 characters and are hashed internally to a 448 bit key. However, all characters supplied are significant. The stronger your passphrase, the more secure your data. Bcrypt uses the blowfish encryption algorithm published by Bruce Schneier in 1993. More information on the algorithm can be found at: http://www.counterpane.com/blowfish.html Specifically, bcrypt uses Paul Kocher's implementation of the algorithm. The source distributed with bcrypt has been slightly altered from the original. Original source code can be obtained from: http://www.counterpane.com/bfsh-koc.zip SUPPORTED PLATFORMS -- Bcrypt has been successfully tested on the following platforms: x86 FreeBSD, OpenBSD, Linux, Cygwin, Win32 Sparc R220 Solaris 2.7, 2.8 Sparc Ultra60 Linux 2.4 Alpha Linux 2.4 PPC G4 MacOS X 10.1 SERVER PPC RS/6000 Linux 2.4 No other operating systems have been tested, but most should work with minimal modifications. If you get bcrypt to compile without errors on any other platform / architecture, I'd like to know about it. If patches are necessary to get bcrypt work on your OS, I will try to incorporate them into the main distribution. If you have a machine not listed above that is incapable of compiling bcrypt and are willing to give me access to the machine, I will make an attempt to port it to your OS. SYSTEM REQUIREMENTS -- zlib - http://www.gzip.org/zlib/ INSTALLATION -- If you're so inclined, edit config.h and change the defaults to whatever you think is appropriate for your needs. If you choose not to have bcrypt remove input files after processing, or set SECUREDELETE to 0, you are likely to have data on your hard drive that can be recovered even after deletion. All of these options can be set on the command line as well. When you're satisfied with the default settings, simply type: make then su and type: make install It would be wise to test the installation on a few unimportant files before encrypting anything you value and removing the only copy. USAGE -- bcrypt [-orc][-sN] file ... Encrypted files will be saved with an extension of .bfe. Any files ending in .bfe will be assumed to be encrypted with bcrypt and will attempt to decrypt them. Any other input files will be encrypted. If more than one type of file is given, bcrypt will process all files which are the same as the first filetype given. By default, bcrypt will compress input files before encryption, remove input files after they are processed (assuming they are processed successfully) and overwrite input files with random data to prevent data recovery. Passphrases may be between 8 and 56 characters. Regardless of the passphrase size, the key is hashed internally to 448 bits - the largest keysize supported by the blowfish algorithm. However, it is still wise to use a strong passphrase. OPTIONS -o print output to standard out. Implies -r. -c DO NOT compress files before encryption. -r DO NOT remove input files after processing -sN How many times to overwrite input files with random data before processing. The default number of overwrites is 3. Use -s0 to disable this feature. No effect if -r is supplied. The options o,c and r each have the opposite effects if the appropriate settings are altered from the default in config.h. To determine what effect each of these have, run bcrypt without any options. Encrypted files should be compatible between most systems. Binary compatibility has been tested for all systems listed above. /* ==================================================================== * Copyright (c) 2002 Johnny Shelley. All rights reserved. * * Bcrypt is licensed under the BSD software license. See the file * called 'LICENSE' that you should have received with this software * for details * ==================================================================== */ bcrypt-1.1.orig/bcrypt.10100644000550600055060000000465107537753573014320 0ustar tonontonon.TH bcrypt 1 "10 September 2002" "version 1.1" .SH NAME bcrypt - blowfish file encryption .SH SYNOPSIS .BR bcrypt " ["-orc] "["-s "N] .I file ... .SH DESCRIPTION .B bcrypt encrypts and decrypts files using the .I blowfish algorithm. .PP Encrypted files will be saved with an extension of .BR .bfe ". Any files ending in .B .bfe will be assumed to be encrypted with .BR bcrypt " and will attempt to decrypt them. Any other input files will be encrypted. If more than one type of file is given, .B bcrypt will process all files which are the same as the first filetype given. .PP By default, .B bcrypt will compress input files before encryption, remove input files after they are processed (assuming they are processed successfully) and overwrite input files with random data to prevent data recovery. .PP Passphrases may be between 8 and 56 characters. Regardless of the passphrase size, the key is hashed internally to 448 bits - the largest keysize supported by the .IR blowfish " algorithm. However, it is still wise to use a strong passphrase. .SH OPTIONS .TP .B -o print output to standard out. Implies -r. .TP .B -c DO NOT compress files before encryption. .TP .B -r DO NOT remove input files after processing .TP .BI -s "N How many times to overwrite input files with random data before deleting. The default number of overwrites is 3. Use -s0 to disable this feature. No effect if -r is supplied. .SH NOTES .BR ""The " -o ", "-r " ,and " -c " options each have the opposite effects if the appropriate settings are altered from the defaults in config.h. To determine what effect each of these have on your system, run .B bcrypt without any options. .PP Encrypted files should be compatible between most systems. Binary compatibility has been tested on all supported systems. There is a list of supported systems in the README file that was included with this software. .SH BUGS Probably. If you find that it will not compile and run on your system, or that encrypted files are not compatible with other platforms, its probably because I don't have access to the platform in question. Patches or access to an unsupported machine are welcome. .SH AUTHOR .TP johnny shelley , .SH DISTRIBUTION .B bcrypt includes Paul Kocher's implementation of the .IR blowfish " algorithm. The version distributed with .BR bcrypt " has been altered. Original sources are available from http://www.counterpane.com/bfsh-koc.zip bcrypt-1.1.orig/blowfish.c0100644000550600055060000004307207537521003014671 0ustar tonontonon/* * Author : Paul Kocher * E-mail : pck@netcom.com * Date : 1997 * Description: C implementation of the Blowfish algorithm. */ #include "includes.h" #include "defines.h" #include "blowfish.h" #define N 16 static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x); static const uInt32 ORIG_P[16 + 2] = { 0x243F6A88L, 0x85A308D3L, 0x13198A2EL, 0x03707344L, 0xA4093822L, 0x299F31D0L, 0x082EFA98L, 0xEC4E6C89L, 0x452821E6L, 0x38D01377L, 0xBE5466CFL, 0x34E90C6CL, 0xC0AC29B7L, 0xC97C50DDL, 0x3F84D5B5L, 0xB5470917L, 0x9216D5D9L, 0x8979FB1BL }; static const uInt32 ORIG_S[4][256] = { { 0xD1310BA6L, 0x98DFB5ACL, 0x2FFD72DBL, 0xD01ADFB7L, 0xB8E1AFEDL, 0x6A267E96L, 0xBA7C9045L, 0xF12C7F99L, 0x24A19947L, 0xB3916CF7L, 0x0801F2E2L, 0x858EFC16L, 0x636920D8L, 0x71574E69L, 0xA458FEA3L, 0xF4933D7EL, 0x0D95748FL, 0x728EB658L, 0x718BCD58L, 0x82154AEEL, 0x7B54A41DL, 0xC25A59B5L, 0x9C30D539L, 0x2AF26013L, 0xC5D1B023L, 0x286085F0L, 0xCA417918L, 0xB8DB38EFL, 0x8E79DCB0L, 0x603A180EL, 0x6C9E0E8BL, 0xB01E8A3EL, 0xD71577C1L, 0xBD314B27L, 0x78AF2FDAL, 0x55605C60L, 0xE65525F3L, 0xAA55AB94L, 0x57489862L, 0x63E81440L, 0x55CA396AL, 0x2AAB10B6L, 0xB4CC5C34L, 0x1141E8CEL, 0xA15486AFL, 0x7C72E993L, 0xB3EE1411L, 0x636FBC2AL, 0x2BA9C55DL, 0x741831F6L, 0xCE5C3E16L, 0x9B87931EL, 0xAFD6BA33L, 0x6C24CF5CL, 0x7A325381L, 0x28958677L, 0x3B8F4898L, 0x6B4BB9AFL, 0xC4BFE81BL, 0x66282193L, 0x61D809CCL, 0xFB21A991L, 0x487CAC60L, 0x5DEC8032L, 0xEF845D5DL, 0xE98575B1L, 0xDC262302L, 0xEB651B88L, 0x23893E81L, 0xD396ACC5L, 0x0F6D6FF3L, 0x83F44239L, 0x2E0B4482L, 0xA4842004L, 0x69C8F04AL, 0x9E1F9B5EL, 0x21C66842L, 0xF6E96C9AL, 0x670C9C61L, 0xABD388F0L, 0x6A51A0D2L, 0xD8542F68L, 0x960FA728L, 0xAB5133A3L, 0x6EEF0B6CL, 0x137A3BE4L, 0xBA3BF050L, 0x7EFB2A98L, 0xA1F1651DL, 0x39AF0176L, 0x66CA593EL, 0x82430E88L, 0x8CEE8619L, 0x456F9FB4L, 0x7D84A5C3L, 0x3B8B5EBEL, 0xE06F75D8L, 0x85C12073L, 0x401A449FL, 0x56C16AA6L, 0x4ED3AA62L, 0x363F7706L, 0x1BFEDF72L, 0x429B023DL, 0x37D0D724L, 0xD00A1248L, 0xDB0FEAD3L, 0x49F1C09BL, 0x075372C9L, 0x80991B7BL, 0x25D479D8L, 0xF6E8DEF7L, 0xE3FE501AL, 0xB6794C3BL, 0x976CE0BDL, 0x04C006BAL, 0xC1A94FB6L, 0x409F60C4L, 0x5E5C9EC2L, 0x196A2463L, 0x68FB6FAFL, 0x3E6C53B5L, 0x1339B2EBL, 0x3B52EC6FL, 0x6DFC511FL, 0x9B30952CL, 0xCC814544L, 0xAF5EBD09L, 0xBEE3D004L, 0xDE334AFDL, 0x660F2807L, 0x192E4BB3L, 0xC0CBA857L, 0x45C8740FL, 0xD20B5F39L, 0xB9D3FBDBL, 0x5579C0BDL, 0x1A60320AL, 0xD6A100C6L, 0x402C7279L, 0x679F25FEL, 0xFB1FA3CCL, 0x8EA5E9F8L, 0xDB3222F8L, 0x3C7516DFL, 0xFD616B15L, 0x2F501EC8L, 0xAD0552ABL, 0x323DB5FAL, 0xFD238760L, 0x53317B48L, 0x3E00DF82L, 0x9E5C57BBL, 0xCA6F8CA0L, 0x1A87562EL, 0xDF1769DBL, 0xD542A8F6L, 0x287EFFC3L, 0xAC6732C6L, 0x8C4F5573L, 0x695B27B0L, 0xBBCA58C8L, 0xE1FFA35DL, 0xB8F011A0L, 0x10FA3D98L, 0xFD2183B8L, 0x4AFCB56CL, 0x2DD1D35BL, 0x9A53E479L, 0xB6F84565L, 0xD28E49BCL, 0x4BFB9790L, 0xE1DDF2DAL, 0xA4CB7E33L, 0x62FB1341L, 0xCEE4C6E8L, 0xEF20CADAL, 0x36774C01L, 0xD07E9EFEL, 0x2BF11FB4L, 0x95DBDA4DL, 0xAE909198L, 0xEAAD8E71L, 0x6B93D5A0L, 0xD08ED1D0L, 0xAFC725E0L, 0x8E3C5B2FL, 0x8E7594B7L, 0x8FF6E2FBL, 0xF2122B64L, 0x8888B812L, 0x900DF01CL, 0x4FAD5EA0L, 0x688FC31CL, 0xD1CFF191L, 0xB3A8C1ADL, 0x2F2F2218L, 0xBE0E1777L, 0xEA752DFEL, 0x8B021FA1L, 0xE5A0CC0FL, 0xB56F74E8L, 0x18ACF3D6L, 0xCE89E299L, 0xB4A84FE0L, 0xFD13E0B7L, 0x7CC43B81L, 0xD2ADA8D9L, 0x165FA266L, 0x80957705L, 0x93CC7314L, 0x211A1477L, 0xE6AD2065L, 0x77B5FA86L, 0xC75442F5L, 0xFB9D35CFL, 0xEBCDAF0CL, 0x7B3E89A0L, 0xD6411BD3L, 0xAE1E7E49L, 0x00250E2DL, 0x2071B35EL, 0x226800BBL, 0x57B8E0AFL, 0x2464369BL, 0xF009B91EL, 0x5563911DL, 0x59DFA6AAL, 0x78C14389L, 0xD95A537FL, 0x207D5BA2L, 0x02E5B9C5L, 0x83260376L, 0x6295CFA9L, 0x11C81968L, 0x4E734A41L, 0xB3472DCAL, 0x7B14A94AL, 0x1B510052L, 0x9A532915L, 0xD60F573FL, 0xBC9BC6E4L, 0x2B60A476L, 0x81E67400L, 0x08BA6FB5L, 0x571BE91FL, 0xF296EC6BL, 0x2A0DD915L, 0xB6636521L, 0xE7B9F9B6L, 0xFF34052EL, 0xC5855664L, 0x53B02D5DL, 0xA99F8FA1L, 0x08BA4799L, 0x6E85076AL }, { 0x4B7A70E9L, 0xB5B32944L, 0xDB75092EL, 0xC4192623L, 0xAD6EA6B0L, 0x49A7DF7DL, 0x9CEE60B8L, 0x8FEDB266L, 0xECAA8C71L, 0x699A17FFL, 0x5664526CL, 0xC2B19EE1L, 0x193602A5L, 0x75094C29L, 0xA0591340L, 0xE4183A3EL, 0x3F54989AL, 0x5B429D65L, 0x6B8FE4D6L, 0x99F73FD6L, 0xA1D29C07L, 0xEFE830F5L, 0x4D2D38E6L, 0xF0255DC1L, 0x4CDD2086L, 0x8470EB26L, 0x6382E9C6L, 0x021ECC5EL, 0x09686B3FL, 0x3EBAEFC9L, 0x3C971814L, 0x6B6A70A1L, 0x687F3584L, 0x52A0E286L, 0xB79C5305L, 0xAA500737L, 0x3E07841CL, 0x7FDEAE5CL, 0x8E7D44ECL, 0x5716F2B8L, 0xB03ADA37L, 0xF0500C0DL, 0xF01C1F04L, 0x0200B3FFL, 0xAE0CF51AL, 0x3CB574B2L, 0x25837A58L, 0xDC0921BDL, 0xD19113F9L, 0x7CA92FF6L, 0x94324773L, 0x22F54701L, 0x3AE5E581L, 0x37C2DADCL, 0xC8B57634L, 0x9AF3DDA7L, 0xA9446146L, 0x0FD0030EL, 0xECC8C73EL, 0xA4751E41L, 0xE238CD99L, 0x3BEA0E2FL, 0x3280BBA1L, 0x183EB331L, 0x4E548B38L, 0x4F6DB908L, 0x6F420D03L, 0xF60A04BFL, 0x2CB81290L, 0x24977C79L, 0x5679B072L, 0xBCAF89AFL, 0xDE9A771FL, 0xD9930810L, 0xB38BAE12L, 0xDCCF3F2EL, 0x5512721FL, 0x2E6B7124L, 0x501ADDE6L, 0x9F84CD87L, 0x7A584718L, 0x7408DA17L, 0xBC9F9ABCL, 0xE94B7D8CL, 0xEC7AEC3AL, 0xDB851DFAL, 0x63094366L, 0xC464C3D2L, 0xEF1C1847L, 0x3215D908L, 0xDD433B37L, 0x24C2BA16L, 0x12A14D43L, 0x2A65C451L, 0x50940002L, 0x133AE4DDL, 0x71DFF89EL, 0x10314E55L, 0x81AC77D6L, 0x5F11199BL, 0x043556F1L, 0xD7A3C76BL, 0x3C11183BL, 0x5924A509L, 0xF28FE6EDL, 0x97F1FBFAL, 0x9EBABF2CL, 0x1E153C6EL, 0x86E34570L, 0xEAE96FB1L, 0x860E5E0AL, 0x5A3E2AB3L, 0x771FE71CL, 0x4E3D06FAL, 0x2965DCB9L, 0x99E71D0FL, 0x803E89D6L, 0x5266C825L, 0x2E4CC978L, 0x9C10B36AL, 0xC6150EBAL, 0x94E2EA78L, 0xA5FC3C53L, 0x1E0A2DF4L, 0xF2F74EA7L, 0x361D2B3DL, 0x1939260FL, 0x19C27960L, 0x5223A708L, 0xF71312B6L, 0xEBADFE6EL, 0xEAC31F66L, 0xE3BC4595L, 0xA67BC883L, 0xB17F37D1L, 0x018CFF28L, 0xC332DDEFL, 0xBE6C5AA5L, 0x65582185L, 0x68AB9802L, 0xEECEA50FL, 0xDB2F953BL, 0x2AEF7DADL, 0x5B6E2F84L, 0x1521B628L, 0x29076170L, 0xECDD4775L, 0x619F1510L, 0x13CCA830L, 0xEB61BD96L, 0x0334FE1EL, 0xAA0363CFL, 0xB5735C90L, 0x4C70A239L, 0xD59E9E0BL, 0xCBAADE14L, 0xEECC86BCL, 0x60622CA7L, 0x9CAB5CABL, 0xB2F3846EL, 0x648B1EAFL, 0x19BDF0CAL, 0xA02369B9L, 0x655ABB50L, 0x40685A32L, 0x3C2AB4B3L, 0x319EE9D5L, 0xC021B8F7L, 0x9B540B19L, 0x875FA099L, 0x95F7997EL, 0x623D7DA8L, 0xF837889AL, 0x97E32D77L, 0x11ED935FL, 0x16681281L, 0x0E358829L, 0xC7E61FD6L, 0x96DEDFA1L, 0x7858BA99L, 0x57F584A5L, 0x1B227263L, 0x9B83C3FFL, 0x1AC24696L, 0xCDB30AEBL, 0x532E3054L, 0x8FD948E4L, 0x6DBC3128L, 0x58EBF2EFL, 0x34C6FFEAL, 0xFE28ED61L, 0xEE7C3C73L, 0x5D4A14D9L, 0xE864B7E3L, 0x42105D14L, 0x203E13E0L, 0x45EEE2B6L, 0xA3AAABEAL, 0xDB6C4F15L, 0xFACB4FD0L, 0xC742F442L, 0xEF6ABBB5L, 0x654F3B1DL, 0x41CD2105L, 0xD81E799EL, 0x86854DC7L, 0xE44B476AL, 0x3D816250L, 0xCF62A1F2L, 0x5B8D2646L, 0xFC8883A0L, 0xC1C7B6A3L, 0x7F1524C3L, 0x69CB7492L, 0x47848A0BL, 0x5692B285L, 0x095BBF00L, 0xAD19489DL, 0x1462B174L, 0x23820E00L, 0x58428D2AL, 0x0C55F5EAL, 0x1DADF43EL, 0x233F7061L, 0x3372F092L, 0x8D937E41L, 0xD65FECF1L, 0x6C223BDBL, 0x7CDE3759L, 0xCBEE7460L, 0x4085F2A7L, 0xCE77326EL, 0xA6078084L, 0x19F8509EL, 0xE8EFD855L, 0x61D99735L, 0xA969A7AAL, 0xC50C06C2L, 0x5A04ABFCL, 0x800BCADCL, 0x9E447A2EL, 0xC3453484L, 0xFDD56705L, 0x0E1E9EC9L, 0xDB73DBD3L, 0x105588CDL, 0x675FDA79L, 0xE3674340L, 0xC5C43465L, 0x713E38D8L, 0x3D28F89EL, 0xF16DFF20L, 0x153E21E7L, 0x8FB03D4AL, 0xE6E39F2BL, 0xDB83ADF7L }, { 0xE93D5A68L, 0x948140F7L, 0xF64C261CL, 0x94692934L, 0x411520F7L, 0x7602D4F7L, 0xBCF46B2EL, 0xD4A20068L, 0xD4082471L, 0x3320F46AL, 0x43B7D4B7L, 0x500061AFL, 0x1E39F62EL, 0x97244546L, 0x14214F74L, 0xBF8B8840L, 0x4D95FC1DL, 0x96B591AFL, 0x70F4DDD3L, 0x66A02F45L, 0xBFBC09ECL, 0x03BD9785L, 0x7FAC6DD0L, 0x31CB8504L, 0x96EB27B3L, 0x55FD3941L, 0xDA2547E6L, 0xABCA0A9AL, 0x28507825L, 0x530429F4L, 0x0A2C86DAL, 0xE9B66DFBL, 0x68DC1462L, 0xD7486900L, 0x680EC0A4L, 0x27A18DEEL, 0x4F3FFEA2L, 0xE887AD8CL, 0xB58CE006L, 0x7AF4D6B6L, 0xAACE1E7CL, 0xD3375FECL, 0xCE78A399L, 0x406B2A42L, 0x20FE9E35L, 0xD9F385B9L, 0xEE39D7ABL, 0x3B124E8BL, 0x1DC9FAF7L, 0x4B6D1856L, 0x26A36631L, 0xEAE397B2L, 0x3A6EFA74L, 0xDD5B4332L, 0x6841E7F7L, 0xCA7820FBL, 0xFB0AF54EL, 0xD8FEB397L, 0x454056ACL, 0xBA489527L, 0x55533A3AL, 0x20838D87L, 0xFE6BA9B7L, 0xD096954BL, 0x55A867BCL, 0xA1159A58L, 0xCCA92963L, 0x99E1DB33L, 0xA62A4A56L, 0x3F3125F9L, 0x5EF47E1CL, 0x9029317CL, 0xFDF8E802L, 0x04272F70L, 0x80BB155CL, 0x05282CE3L, 0x95C11548L, 0xE4C66D22L, 0x48C1133FL, 0xC70F86DCL, 0x07F9C9EEL, 0x41041F0FL, 0x404779A4L, 0x5D886E17L, 0x325F51EBL, 0xD59BC0D1L, 0xF2BCC18FL, 0x41113564L, 0x257B7834L, 0x602A9C60L, 0xDFF8E8A3L, 0x1F636C1BL, 0x0E12B4C2L, 0x02E1329EL, 0xAF664FD1L, 0xCAD18115L, 0x6B2395E0L, 0x333E92E1L, 0x3B240B62L, 0xEEBEB922L, 0x85B2A20EL, 0xE6BA0D99L, 0xDE720C8CL, 0x2DA2F728L, 0xD0127845L, 0x95B794FDL, 0x647D0862L, 0xE7CCF5F0L, 0x5449A36FL, 0x877D48FAL, 0xC39DFD27L, 0xF33E8D1EL, 0x0A476341L, 0x992EFF74L, 0x3A6F6EABL, 0xF4F8FD37L, 0xA812DC60L, 0xA1EBDDF8L, 0x991BE14CL, 0xDB6E6B0DL, 0xC67B5510L, 0x6D672C37L, 0x2765D43BL, 0xDCD0E804L, 0xF1290DC7L, 0xCC00FFA3L, 0xB5390F92L, 0x690FED0BL, 0x667B9FFBL, 0xCEDB7D9CL, 0xA091CF0BL, 0xD9155EA3L, 0xBB132F88L, 0x515BAD24L, 0x7B9479BFL, 0x763BD6EBL, 0x37392EB3L, 0xCC115979L, 0x8026E297L, 0xF42E312DL, 0x6842ADA7L, 0xC66A2B3BL, 0x12754CCCL, 0x782EF11CL, 0x6A124237L, 0xB79251E7L, 0x06A1BBE6L, 0x4BFB6350L, 0x1A6B1018L, 0x11CAEDFAL, 0x3D25BDD8L, 0xE2E1C3C9L, 0x44421659L, 0x0A121386L, 0xD90CEC6EL, 0xD5ABEA2AL, 0x64AF674EL, 0xDA86A85FL, 0xBEBFE988L, 0x64E4C3FEL, 0x9DBC8057L, 0xF0F7C086L, 0x60787BF8L, 0x6003604DL, 0xD1FD8346L, 0xF6381FB0L, 0x7745AE04L, 0xD736FCCCL, 0x83426B33L, 0xF01EAB71L, 0xB0804187L, 0x3C005E5FL, 0x77A057BEL, 0xBDE8AE24L, 0x55464299L, 0xBF582E61L, 0x4E58F48FL, 0xF2DDFDA2L, 0xF474EF38L, 0x8789BDC2L, 0x5366F9C3L, 0xC8B38E74L, 0xB475F255L, 0x46FCD9B9L, 0x7AEB2661L, 0x8B1DDF84L, 0x846A0E79L, 0x915F95E2L, 0x466E598EL, 0x20B45770L, 0x8CD55591L, 0xC902DE4CL, 0xB90BACE1L, 0xBB8205D0L, 0x11A86248L, 0x7574A99EL, 0xB77F19B6L, 0xE0A9DC09L, 0x662D09A1L, 0xC4324633L, 0xE85A1F02L, 0x09F0BE8CL, 0x4A99A025L, 0x1D6EFE10L, 0x1AB93D1DL, 0x0BA5A4DFL, 0xA186F20FL, 0x2868F169L, 0xDCB7DA83L, 0x573906FEL, 0xA1E2CE9BL, 0x4FCD7F52L, 0x50115E01L, 0xA70683FAL, 0xA002B5C4L, 0x0DE6D027L, 0x9AF88C27L, 0x773F8641L, 0xC3604C06L, 0x61A806B5L, 0xF0177A28L, 0xC0F586E0L, 0x006058AAL, 0x30DC7D62L, 0x11E69ED7L, 0x2338EA63L, 0x53C2DD94L, 0xC2C21634L, 0xBBCBEE56L, 0x90BCB6DEL, 0xEBFC7DA1L, 0xCE591D76L, 0x6F05E409L, 0x4B7C0188L, 0x39720A3DL, 0x7C927C24L, 0x86E3725FL, 0x724D9DB9L, 0x1AC15BB4L, 0xD39EB8FCL, 0xED545578L, 0x08FCA5B5L, 0xD83D7CD3L, 0x4DAD0FC4L, 0x1E50EF5EL, 0xB161E6F8L, 0xA28514D9L, 0x6C51133CL, 0x6FD5C7E7L, 0x56E14EC4L, 0x362ABFCEL, 0xDDC6C837L, 0xD79A3234L, 0x92638212L, 0x670EFA8EL, 0x406000E0L }, { 0x3A39CE37L, 0xD3FAF5CFL, 0xABC27737L, 0x5AC52D1BL, 0x5CB0679EL, 0x4FA33742L, 0xD3822740L, 0x99BC9BBEL, 0xD5118E9DL, 0xBF0F7315L, 0xD62D1C7EL, 0xC700C47BL, 0xB78C1B6BL, 0x21A19045L, 0xB26EB1BEL, 0x6A366EB4L, 0x5748AB2FL, 0xBC946E79L, 0xC6A376D2L, 0x6549C2C8L, 0x530FF8EEL, 0x468DDE7DL, 0xD5730A1DL, 0x4CD04DC6L, 0x2939BBDBL, 0xA9BA4650L, 0xAC9526E8L, 0xBE5EE304L, 0xA1FAD5F0L, 0x6A2D519AL, 0x63EF8CE2L, 0x9A86EE22L, 0xC089C2B8L, 0x43242EF6L, 0xA51E03AAL, 0x9CF2D0A4L, 0x83C061BAL, 0x9BE96A4DL, 0x8FE51550L, 0xBA645BD6L, 0x2826A2F9L, 0xA73A3AE1L, 0x4BA99586L, 0xEF5562E9L, 0xC72FEFD3L, 0xF752F7DAL, 0x3F046F69L, 0x77FA0A59L, 0x80E4A915L, 0x87B08601L, 0x9B09E6ADL, 0x3B3EE593L, 0xE990FD5AL, 0x9E34D797L, 0x2CF0B7D9L, 0x022B8B51L, 0x96D5AC3AL, 0x017DA67DL, 0xD1CF3ED6L, 0x7C7D2D28L, 0x1F9F25CFL, 0xADF2B89BL, 0x5AD6B472L, 0x5A88F54CL, 0xE029AC71L, 0xE019A5E6L, 0x47B0ACFDL, 0xED93FA9BL, 0xE8D3C48DL, 0x283B57CCL, 0xF8D56629L, 0x79132E28L, 0x785F0191L, 0xED756055L, 0xF7960E44L, 0xE3D35E8CL, 0x15056DD4L, 0x88F46DBAL, 0x03A16125L, 0x0564F0BDL, 0xC3EB9E15L, 0x3C9057A2L, 0x97271AECL, 0xA93A072AL, 0x1B3F6D9BL, 0x1E6321F5L, 0xF59C66FBL, 0x26DCF319L, 0x7533D928L, 0xB155FDF5L, 0x03563482L, 0x8ABA3CBBL, 0x28517711L, 0xC20AD9F8L, 0xABCC5167L, 0xCCAD925FL, 0x4DE81751L, 0x3830DC8EL, 0x379D5862L, 0x9320F991L, 0xEA7A90C2L, 0xFB3E7BCEL, 0x5121CE64L, 0x774FBE32L, 0xA8B6E37EL, 0xC3293D46L, 0x48DE5369L, 0x6413E680L, 0xA2AE0810L, 0xDD6DB224L, 0x69852DFDL, 0x09072166L, 0xB39A460AL, 0x6445C0DDL, 0x586CDECFL, 0x1C20C8AEL, 0x5BBEF7DDL, 0x1B588D40L, 0xCCD2017FL, 0x6BB4E3BBL, 0xDDA26A7EL, 0x3A59FF45L, 0x3E350A44L, 0xBCB4CDD5L, 0x72EACEA8L, 0xFA6484BBL, 0x8D6612AEL, 0xBF3C6F47L, 0xD29BE463L, 0x542F5D9EL, 0xAEC2771BL, 0xF64E6370L, 0x740E0D8DL, 0xE75B1357L, 0xF8721671L, 0xAF537D5DL, 0x4040CB08L, 0x4EB4E2CCL, 0x34D2466AL, 0x0115AF84L, 0xE1B00428L, 0x95983A1DL, 0x06B89FB4L, 0xCE6EA048L, 0x6F3F3B82L, 0x3520AB82L, 0x011A1D4BL, 0x277227F8L, 0x611560B1L, 0xE7933FDCL, 0xBB3A792BL, 0x344525BDL, 0xA08839E1L, 0x51CE794BL, 0x2F32C9B7L, 0xA01FBAC9L, 0xE01CC87EL, 0xBCC7D1F6L, 0xCF0111C3L, 0xA1E8AAC7L, 0x1A908749L, 0xD44FBD9AL, 0xD0DADECBL, 0xD50ADA38L, 0x0339C32AL, 0xC6913667L, 0x8DF9317CL, 0xE0B12B4FL, 0xF79E59B7L, 0x43F5BB3AL, 0xF2D519FFL, 0x27D9459CL, 0xBF97222CL, 0x15E6FC2AL, 0x0F91FC71L, 0x9B941525L, 0xFAE59361L, 0xCEB69CEBL, 0xC2A86459L, 0x12BAA8D1L, 0xB6C1075EL, 0xE3056A0CL, 0x10D25065L, 0xCB03A442L, 0xE0EC6E0EL, 0x1698DB3BL, 0x4C98A0BEL, 0x3278E964L, 0x9F1F9532L, 0xE0D392DFL, 0xD3A0342BL, 0x8971F21EL, 0x1B0A7441L, 0x4BA3348CL, 0xC5BE7120L, 0xC37632D8L, 0xDF359F8DL, 0x9B992F2EL, 0xE60B6F47L, 0x0FE3F11DL, 0xE54CDA54L, 0x1EDAD891L, 0xCE6279CFL, 0xCD3E7E6FL, 0x1618B166L, 0xFD2C1D05L, 0x848FD2C5L, 0xF6FB2299L, 0xF523F357L, 0xA6327623L, 0x93A83531L, 0x56CCCD02L, 0xACF08162L, 0x5A75EBB5L, 0x6E163697L, 0x88D273CCL, 0xDE966292L, 0x81B949D0L, 0x4C50901BL, 0x71C65614L, 0xE6C6C7BDL, 0x327A140AL, 0x45E1D006L, 0xC3F27B9AL, 0xC9AA53FDL, 0x62A80F00L, 0xBB25BFE2L, 0x35BDD2F6L, 0x71126905L, 0xB2040222L, 0xB6CBCF7CL, 0xCD769C2BL, 0x53113EC0L, 0x1640E3D3L, 0x38ABBD60L, 0x2547ADF0L, 0xBA38209CL, 0xF746CE76L, 0x77AFA1C5L, 0x20756060L, 0x85CBFE4EL, 0x8AE88DD8L, 0x7AAAF9B0L, 0x4CF9AA7EL, 0x1948C25CL, 0x02FB8A8CL, 0x01C36AE4L, 0xD6EBE1F9L, 0x90D4F869L, 0xA65CDEA0L, 0x3F09252DL, 0xC208E69FL, 0xB74E6132L, 0xCE77E25BL, 0x578FDFE3L, 0x3AC372E6L } }; uInt32 F(BLOWFISH_CTX *ctx, uInt32 x) { unsigned short a, b, c, d; uInt32 y; d = x & 0x00FF; x >>= 8; c = x & 0x00FF; x >>= 8; b = x & 0x00FF; x >>= 8; a = x & 0x00FF; y = ctx->S[0][a] + ctx->S[1][b]; y = y ^ ctx->S[2][c]; y = y + ctx->S[3][d]; return y; } void Blowfish_Encrypt(BLOWFISH_CTX *ctx, uInt32 *xl, uInt32 *xr) { uInt32 Xl; uInt32 Xr; uInt32 temp; short i; Xl = *xl; Xr = *xr; for (i = 0; i < N; ++i) { Xl = Xl ^ ctx->P[i]; Xr = F(ctx, Xl) ^ Xr; temp = Xl; Xl = Xr; Xr = temp; } temp = Xl; Xl = Xr; Xr = temp; Xr = Xr ^ ctx->P[N]; Xl = Xl ^ ctx->P[N + 1]; *xl = Xl; *xr = Xr; } void Blowfish_Decrypt(BLOWFISH_CTX *ctx, uInt32 *xl, uInt32 *xr) { uInt32 Xl; uInt32 Xr; uInt32 temp; short i; Xl = *xl; Xr = *xr; for (i = N + 1; i > 1; --i) { Xl = Xl ^ ctx->P[i]; Xr = F(ctx, Xl) ^ Xr; /* Exchange Xl and Xr */ temp = Xl; Xl = Xr; Xr = temp; } /* Exchange Xl and Xr */ temp = Xl; Xl = Xr; Xr = temp; Xr = Xr ^ ctx->P[1]; Xl = Xl ^ ctx->P[0]; *xl = Xl; *xr = Xr; } void Blowfish_Init(BLOWFISH_CTX *ctx, unsigned char *key, int keyLen) { int i, j, k; uInt32 data, datal, datar; for (i = 0; i < 4; i++) { for (j = 0; j < 256; j++) ctx->S[i][j] = ORIG_S[i][j]; } j = 0; for (i = 0; i < N + 2; ++i) { data = 0x00000000; for (k = 0; k < 4; ++k) { data = (data << 8) | key[j]; j = j + 1; if (j >= keyLen) j = 0; } ctx->P[i] = ORIG_P[i] ^ data; } datal = 0x00000000; datar = 0x00000000; for (i = 0; i < N + 2; i += 2) { Blowfish_Encrypt(ctx, &datal, &datar); ctx->P[i] = datal; ctx->P[i + 1] = datar; } for (i = 0; i < 4; ++i) { for (j = 0; j < 256; j += 2) { Blowfish_Encrypt(ctx, &datal, &datar); ctx->S[i][j] = datal; ctx->S[i][j + 1] = datar; } } } bcrypt-1.1.orig/blowfish.h0100644000550600055060000000073707537521003014677 0ustar tonontonon/* * Author : Paul Kocher * E-mail : pck@netcom.com * Date : 1997 * Description: C implementation of the Blowfish algorithm. */ #define MAXKEYBYTES 56 /* 448 bits */ typedef struct { uInt32 P[16 + 2]; uInt32 S[4][256]; } BLOWFISH_CTX; void Blowfish_Init(BLOWFISH_CTX *ctx, unsigned char *key, int keyLen); void Blowfish_Encrypt(BLOWFISH_CTX *ctx, uInt32 *xl, uInt32 *xr); void Blowfish_Decrypt(BLOWFISH_CTX *ctx, uInt32 *xl, uInt32 *xr); bcrypt-1.1.orig/config.h0100644000550600055060000000145207536430713014330 0ustar tonontonon/* ==================================================================== * Copyright (c) 2002 Johnny Shelley. All rights reserved. * * Bcrypt is licensed under the BSD software license. See the file * called 'LICENSE' that you should have received with this software * for details * ==================================================================== */ /* All options are either 1 for true or 0 for false w/ the exception */ /* of SECUREDELETE which may be anything from 0 to 127. */ /* All options may be overridden on the command line. */ /* whether or not to compress files */ #define COMPRESS 1 /* send output to stdout */ #define STANDARDOUT 0 /* remove input files after processing */ #define REMOVE 1 /* how many times to overwrite input files before deleting */ #define SECUREDELETE 3 bcrypt-1.1.orig/defines.h0100644000550600055060000000106707540310201014462 0ustar tonontonontypedef struct _BCoptions { unsigned char remove; unsigned char standardout; unsigned char compression; unsigned char type; uLong origsize; unsigned char securedelete; } BCoptions; #define ENCRYPT 0 #define DECRYPT 1 #define endianBig ((unsigned char) 0x45) #define endianLittle ((unsigned char) 0x54) typedef unsigned int uInt32; #ifdef WIN32 /* Win32 doesn't have random() or lstat */ #define random() rand() #define initstate(x,y,z) srand(x) #define lstat(x,y) stat(x,y) #endif #ifndef S_ISREG #define S_ISREG(x) ( ((x)&S_IFMT)==S_IFREG ) #endif bcrypt-1.1.orig/endian.c0100644000550600055060000000304107537521004014303 0ustar tonontonon/* ==================================================================== * Copyright (c) 2002 Johnny Shelley. All rights reserved. * * Bcrypt is licensed under the BSD software license. See the file * called 'LICENSE' that you should have received with this software * for details * ==================================================================== */ #include "includes.h" #include "defines.h" #include "functions.h" void getEndian(unsigned char **e) { short i = 0x4321; int bigE = (*(char*) &i); if ((*e = realloc(*e, sizeof(char) + 1)) == NULL) memerror(); memset(*e, 0, sizeof(char) + 1); if (bigE == 0x43) memset(*e, endianBig, 1); else if (bigE == 0x21) memset(*e, endianLittle, 1); } uInt32 swapEndian(uInt32 value) { unsigned int b1, b2, b3, b4; uInt32 swapped; b4 = (value>>24) & 0xff; b3 = (value>>16) & 0xff; b2 = (value>>8) & 0xff; b1 = value & 0xff; swapped = (b1<<24) | (b2<<16) | (b3<<8) | b4; return(swapped); } int testEndian(char *input) { unsigned char *myEndian = NULL, *yourEndian = NULL; getEndian(&myEndian); if ((yourEndian = malloc(2)) == NULL) memerror(); memset(yourEndian, 0, 2); memcpy(yourEndian, input, 1); if (memcmp(myEndian, yourEndian, 1) == 0) return(0); return(1); } int swapCompressed(char **input, uLong sz) { char c; unsigned int j, swap; memcpy(&c, *input+1, 1); if (c == 0) return(0); j = sizeof(uInt32); memcpy(&swap, *input+(sz - j), j); swap = swapEndian(swap); memcpy(*input+(sz - j), &swap, j); return(1); } bcrypt-1.1.orig/functions.h0100644000550600055060000000322507540054722015070 0ustar tonontonon/* ==================================================================== * Copyright (c) 2002 Johnny Shelley. All rights reserved. * * Bcrypt is licensed under the BSD software license. See the file * called 'LICENSE' that you should have received with this software * for details * ==================================================================== */ #include "includes.h" #include "blowfish.h" /* from wrapbf.c */ uLong BFEncrypt(char **input, char *key, uLong sz, BCoptions *options); uLong BFDecrypt(char **input, char *key, char *key2, uLong sz, BCoptions *options); /* from keys.c */ char * getkey(int type); void mutateKey(char **key, char **key2); /* from rwfile.c */ int getremain(uLong sz, int dv); uLong padInput(char **input, uLong sz); uLong attachKey(char **input, char *key, uLong sz); uLong readfile(char *infile, char **input, int type, char *key, struct stat statbuf); uLong writefile(char *outfile, char *output, uLong sz, BCoptions options, struct stat statbuf); int deletefile(char *file, BCoptions options, char *key, struct stat statbuf); /* from wrapzl.c */ uLong docompress(char **input, uLong sz); uLong douncompress(char **input, uLong sz, BCoptions options); /* from main.c */ BCoptions initoptions(BCoptions options); int usage(char *name); int memerror(); int parseArgs(int *argc, char **argv, BCoptions *options); int assignFiles(char *arg, char **infile, char **outfile, struct stat *statbuf, BCoptions *options, char *key); int main(int argc, char *argv[]); /* from endian.c */ void getEndian(unsigned char **e); uInt32 swapEndian(uInt32 value); int testEndian(char *input); int swapCompressed(char **input, uLong sz); bcrypt-1.1.orig/includes.h0100644000550600055060000000115007540310201014644 0ustar tonontonon/* ==================================================================== * Copyright (c) 2002 Johnny Shelley. All rights reserved. * * Bcrypt is licensed under the BSD software license. See the file * called 'LICENSE' that you should have received with this software * for details * ==================================================================== */ #include #include #include #ifndef WIN32 /* These libraries don't exist on Win32 */ #include #include #include #endif #include #include #include bcrypt-1.1.orig/keys.c0100644000550600055060000000616407540310201014016 0ustar tonontonon/* ==================================================================== * Copyright (c) 2002 Johnny Shelley. All rights reserved. * * Bcrypt is licensed under the BSD software license. See the file * called 'LICENSE' that you should have received with this software * for details * ==================================================================== */ #include "includes.h" #include "defines.h" #include "functions.h" char * getkey(int type){ char *key, *key2, overflow[2], *ch; #ifndef WIN32 /* Win32 doesn't have termios.h */ struct termios term, termsave; tcgetattr(fileno(stdin), &termsave); term = termsave; term.c_lflag &= ~ (ECHO | ECHOE | ECHOK | ECHONL); tcsetattr(fileno(stdin), TCSANOW, &term); #endif if ((key = malloc(MAXKEYBYTES + 2)) == NULL) memerror(); memset(key, 0, MAXKEYBYTES + 2); fprintf(stderr, "Encryption key:"); fgets(key, MAXKEYBYTES + 1, stdin); /* blowfish requires 32 bits, I want 64. deal w/ it */ while (strlen(key) < 9 && type == ENCRYPT) { /* \n is still tacked on */ fprintf(stderr, "Key must be at least 8 characters\n"); memset(key, 0, MAXKEYBYTES + 2); fprintf(stderr, "Encryption key:"); fgets(key, MAXKEYBYTES + 1, stdin); } if (memchr(key, (char) 10, MAXKEYBYTES + 1) == NULL) { while (fread(overflow, 1, 1, stdin) > 0) { if (memcmp(overflow, "\n", 1) == 0) break; } } if (type == ENCRYPT) { if ((key2 = malloc(MAXKEYBYTES + 2)) == NULL) memerror(); memset(key2, 0, MAXKEYBYTES + 2); fprintf(stderr, "\nAgain:"); fgets(key2, MAXKEYBYTES + 1, stdin); if (strcmp(key, key2)) { fprintf(stderr, "\nKeys don't match!\n"); #ifndef WIN32 /* Win32 doesn't have termios.h */ tcsetattr(fileno(stdin), TCSANOW, &termsave); #endif exit(1); } memset(key2, 0, strlen(key2)); free(key2); } if ((ch = memchr(key, (char) 10, strlen(key))) != NULL) memset(ch, 0, 1); #ifndef WIN32 /* Win32 doesn't have termios.h */ tcsetattr(fileno(stdin), TCSANOW, &termsave); #endif fprintf(stderr, "\n"); return(key); } void mutateKey(char **key, char **key2) { uInt32 L, R, l, r; BLOWFISH_CTX ctx; char *newkey, *newkey2; int i, j; j = sizeof(uInt32); Blowfish_Init(&ctx, *key, strlen(*key)); memcpy(&L, *key, j); memcpy(&R, *key+j, j); memset(*key, 0, MAXKEYBYTES + 1); l = L; r = R; if ((*key2 = malloc(MAXKEYBYTES + 1)) == NULL) memerror(); if ((newkey = malloc(MAXKEYBYTES + 1)) == NULL) memerror(); if ((newkey2 = malloc(MAXKEYBYTES + 1)) == NULL) memerror(); memset(*key2, 0, MAXKEYBYTES + 1); memset(newkey, 0, MAXKEYBYTES + 1); memset(newkey2, 0, MAXKEYBYTES + 1); for (i=0; i < MAXKEYBYTES; i+=(j*2)) { Blowfish_Encrypt(&ctx, &L, &R); memcpy(newkey+i, &L, j); memcpy(newkey+i+j, &R, j); } for (i=0; i < MAXKEYBYTES; i+=(j*2)) { l = swapEndian(l); r = swapEndian(r); Blowfish_Encrypt(&ctx, &l, &r); l = swapEndian(l); r = swapEndian(r); memcpy(newkey2+i, &l, j); memcpy(newkey2+i+j, &r, j); } memcpy(*key, newkey, MAXKEYBYTES); memcpy(*key2, newkey2, MAXKEYBYTES); free(newkey); } bcrypt-1.1.orig/main.c0100644000550600055060000001253107540061524013775 0ustar tonontonon/* ==================================================================== * Copyright (c) 2002 Johnny Shelley. All rights reserved. * * Bcrypt is licensed under the BSD software license. See the file * called 'LICENSE' that you should have received with this software * for details * ==================================================================== */ #include "includes.h" #include "defines.h" #include "functions.h" #include "config.h" extern char *optarg; extern int optind, optreset, opterr; BCoptions initoptions(BCoptions options) { options.remove = REMOVE; options.standardout = STANDARDOUT; options.compression = COMPRESS; /* leave this on by default */ options.type = 127; options.origsize = 0; options.securedelete = SECUREDELETE; return(options); } int usage(char *name) { fprintf(stderr, "Usage is: %s -[orc][-sN] file1 file2..\n", name); if (STANDARDOUT == 0) fprintf(stderr, " -o Write output to standard out\n"); else fprintf(stderr, " -o Don't write output to standard out\n"); if (REMOVE == 1) fprintf(stderr, " -r Do NOT remove input files after processing\n"); else fprintf(stderr, " -r Remove input files after processing\n"); if (COMPRESS == 1) fprintf(stderr, " -c Do NOT compress files before encryption\n"); else fprintf(stderr, " -c Compress files before encryption\n"); fprintf(stderr, " -sN How many times to overwrite input files with random\ data\n"); exit(1); } int memerror() { fprintf(stderr, "Can't allocate enough memory. Bailing out\n"); exit(1); } int parseArgs(int *argc, char **argv, BCoptions *options) { signed char ch; char *progname; if ((progname = malloc(strlen(argv[0]) + 1)) == NULL) memerror(); memcpy(progname, argv[0], strlen(argv[0]) + 1); *options = initoptions(*options); while ((ch = getopt(*argc, argv, "rocs:")) != -1) { switch(ch) { case 'r': /* remove files after write (default on) */ if (options->remove == 1) options->remove = 0; else options->remove = 1; break; case 'o': /* write to stdout */ if (options->standardout == 0) options->standardout = 1; else options->standardout = 0; options->remove = 0; break; case 'c': /* compress files (default on) */ if (options->compression == 1) options->compression = 0; else options->compression = 1; break; case 's': /* how many times to overwrite data (default 3) */ options->securedelete = atoi(optarg); break; default: /* dump the usage message */ usage(progname); } } *argc -= optind; if (*argc < 1) { usage(progname); } return(optind); } int assignFiles(char *arg, char **infile, char **outfile, struct stat *statbuf, BCoptions *options, char *key) { if (lstat(arg, statbuf) < 0) return(1); if (!S_ISREG(statbuf->st_mode)) return(1); if ((*infile = realloc(*infile, strlen(arg) + 1)) == NULL) memerror(); memset(*infile, 0, strlen(arg) + 1); strcpy(*infile, arg); if ((*outfile = realloc(*outfile, strlen(arg) + 5)) == NULL) memerror(); memset(*outfile, 0, strlen(arg) + 5); strcpy(*outfile, *infile); if (strlen(*infile) > 4) { if ((memcmp(*infile+(strlen(*infile) - 4), ".bfe", 4) == 0) && ((!key) || (options->type == DECRYPT))){ memset(*outfile+(strlen(*infile) - 4), 0, 4); options->type = DECRYPT; } else if ((!key) || (options->type == ENCRYPT)){ if (memcmp(*infile+(strlen(*infile) - 4), ".bfe", 4) == 0) return(1); strcat(*outfile, ".bfe"); options->type = ENCRYPT; } else return(1); } else if ((!key) || (options->type == ENCRYPT)) { strcat(*outfile, ".bfe"); options->type = ENCRYPT; } else return(1); return(0); } int main(int argc, char *argv[]) { uLong sz = 0; char *input = NULL, *key = NULL, *key2 = NULL; char *infile = NULL, *outfile = NULL; struct stat statbuf; BCoptions options; argv += parseArgs(&argc, argv, &options); for (; argc > 0; argc--, argv++) { if (assignFiles(argv[0], &infile, &outfile, &statbuf, &options, key)) continue; if (!key) { key = getkey(options.type); mutateKey(&key, &key2); } sz = readfile(infile, &input, options.type, key, statbuf); if ((options.type == DECRYPT) && (testEndian(input))) swapCompressed(&input, sz); if ((options.compression == 1) && (options.type == ENCRYPT)) { options.origsize = sz; sz = docompress(&input, sz); } if (options.type == ENCRYPT) { sz = attachKey(&input, key, sz); sz = padInput(&input, sz); } if (options.type == ENCRYPT) sz = BFEncrypt(&input, key, sz, &options); else if (options.type == DECRYPT) if ((sz = BFDecrypt(&input, key, key2, sz, &options)) == 0) { fprintf(stderr, "Invalid encryption key for file: %s\n", infile); exit(1); } if ((options.compression == 1) && (options.type == DECRYPT)) sz = douncompress(&input, sz, options); writefile(outfile, input, sz, options, statbuf); if ((input = realloc(input, sizeof(char *))) == NULL) memerror(); if (options.remove == 1) deletefile(infile, options, key, statbuf); if (input != NULL) free(input); } if(!sz) fprintf(stderr, "No valid files found\n"); return(0); } bcrypt-1.1.orig/rwfile.c0100644000550600055060000000565507540225465014360 0ustar tonontonon/* ==================================================================== * Copyright (c) 2002 Johnny Shelley. All rights reserved. * * Bcrypt is licensed under the BSD software license. See the file * called 'LICENSE' that you should have received with this software * for details * ==================================================================== */ #include "includes.h" #include "defines.h" #include "functions.h" int getremain(uLong sz, int dv) { int r; r = sz / dv; r++; r = r * dv; r = r - sz; return(r); } uLong padInput(char **input, uLong sz) { int r, j; j = sizeof(uInt32) * 2; if (sz >= j) r = getremain(sz, j); else r = j - sz; if ( r < j) { if ((*input = realloc(*input, sz + r + 1)) == NULL) memerror(); memset(*input+sz, 0, r + 1); sz+=r; } return(sz); } uLong attachKey(char **input, char *key, uLong sz) { /* +3 so we have room for info tags at the beginning of the file */ if ((*input = realloc(*input, sz + MAXKEYBYTES + 3)) == NULL) memerror(); memcpy(*input+sz, key, MAXKEYBYTES); sz += MAXKEYBYTES; return(sz); } uLong readfile(char *infile, char **input, int type, char *key, struct stat statbuf) { FILE *fd; int readsize; uLong sz = 0; readsize = statbuf.st_size + 1; fd = fopen(infile, "rb"); if (!fd) { fprintf(stderr, "Unable to open file %s\n", infile); return(-1); } if ((*input = malloc(readsize + sz + 1)) == NULL) memerror(); memset(*input+sz, 0, readsize); sz += fread(*input+sz, 1, readsize - 1, fd); fclose(fd); return(sz); } uLong writefile(char *outfile, char *output, uLong sz, BCoptions options, struct stat statbuf) { FILE *fd; if (options.standardout == 1) fd = stdout; else fd = fopen(outfile, "wb"); if (!fd) { fprintf(stderr, "Unable to create file %s\n", outfile); exit(1); } if (fwrite(output, 1, sz, fd) != sz) { fprintf(stderr, "Out of space while writing file %s\n", outfile); exit(1); } if (!options.standardout) { fclose(fd); chmod(outfile, statbuf.st_mode); } return(0); } int deletefile(char *file, BCoptions options, char *key, struct stat statbuf) { int lsize; long g; uLong j = 0, k = 0; signed char i; char *state, *garbage; FILE *fd; if (options.securedelete > 0) { lsize = sizeof(long); k = (statbuf.st_size / lsize) + 1; if ((state = malloc(257)) == NULL) memerror(); initstate((unsigned long) key, state, 256); if ((garbage = malloc(lsize + 1)) == NULL) memerror(); fd = fopen(file, "r+b"); for (i = options.securedelete; i > 0; i--) { fseek(fd, 0, SEEK_SET); for (j = 0; j < k; j += lsize) { g = random(); memcpy(garbage, &g, lsize); fwrite(garbage, lsize, 1, fd); } fflush(fd); } fclose(fd); } if (unlink(file)) { fprintf(stderr, "Error deleting file %s\n", file); return(1); } return(0); } bcrypt-1.1.orig/wrapbf.c0100644000550600055060000000527607540305710014340 0ustar tonontonon/* ==================================================================== * Copyright (c) 2002 Johnny Shelley. All rights reserved. * * Bcrypt is licensed under the BSD software license. See the file * called 'LICENSE' that you should have received with this software * for details * ==================================================================== */ #include "includes.h" #include "defines.h" #include "functions.h" uLong BFEncrypt(char **input, char *key, uLong sz, BCoptions *options) { uInt32 L, R; uLong i; BLOWFISH_CTX ctx; int j; unsigned char *myEndian = NULL; j = sizeof(uInt32); getEndian(&myEndian); memmove(*input+2, *input, sz); memcpy(*input, myEndian, 1); memcpy(*input+1, &options->compression, 1); sz += 2; /* add room for endian and compress flags */ Blowfish_Init (&ctx, key, MAXKEYBYTES); for (i = 2; i < sz; i+=(j*2)) { /* start just after tags */ memcpy(&L, *input+i, j); memcpy(&R, *input+i+j, j); Blowfish_Encrypt(&ctx, &L, &R); memcpy(*input+i, &L, j); memcpy(*input+i+j, &R, j); } if (options->compression == 1) { if ((*input = realloc(*input, sz + j + 1)) == NULL) memerror(); memset(*input+sz, 0, j + 1); memcpy(*input+sz, &options->origsize, j); sz += j; /* make room for the original size */ } free(myEndian); return(sz); } uLong BFDecrypt(char **input, char *key, char *key2, uLong sz, BCoptions *options) { uInt32 L, R; uLong i; BLOWFISH_CTX ctx; int j, swap = 0; unsigned char *myEndian = NULL; char *mykey = NULL; j = sizeof(uInt32); if ((mykey = malloc(MAXKEYBYTES + 1)) == NULL) memerror(); memset(mykey, 0, MAXKEYBYTES + 1); if ((swap = testEndian(*input)) == 1) memcpy(mykey, key2, MAXKEYBYTES); else memcpy(mykey, key, MAXKEYBYTES); memcpy(&options->compression, *input+1, 1); if (options->compression == 1) { memcpy(&options->origsize, *input+(sz - j), j); sz -= j; /* dump the size tag */ } sz -= 2; /* now dump endian and compress flags */ Blowfish_Init (&ctx, mykey, MAXKEYBYTES); for (i = 0; i < sz; i+=(j*2)) { memcpy(&L, *input+i+2, j); memcpy(&R, *input+i+j+2, j); if (swap == 1) { L = swapEndian(L); R = swapEndian(R); } Blowfish_Decrypt(&ctx, &L, &R); if (swap == 1) { L = swapEndian(L); R = swapEndian(R); } memcpy(*input+i, &L, j); memcpy(*input+i+j, &R, j); } while (memcmp(*input+(sz-1), "\0", 1) == 0) /* strip excess nulls */ sz--; /* from decrypted files */ sz -= MAXKEYBYTES; if (memcmp(*input+sz, mykey, MAXKEYBYTES) != 0) return(0); free(mykey); free(myEndian); return(sz); } bcrypt-1.1.orig/wrapzl.c0100644000550600055060000000243207540054722014371 0ustar tonontonon/* ==================================================================== * Copyright (c) 2002 Johnny Shelley. All rights reserved. * * Bcrypt is licensed under the BSD software license. See the file * called 'LICENSE' that you should have received with this software * for details * ==================================================================== */ #include "includes.h" #include "defines.h" #include "functions.h" uLong docompress(char **input, uLong sz) { uLong newsz; char *output; newsz = sz + (sz *.1) + 13; if ((output = malloc(newsz + 1)) == NULL) memerror(); memset(output, 0, newsz + 1); compress((Bytef *) output, &newsz, (const Bytef *) *input, sz); free(*input); if ((*input = malloc(newsz)) == NULL) memerror(); memcpy(*input, output, newsz); free(output); return(newsz); } uLong douncompress(char **input, uLong sz, BCoptions options) { char *output; if ((output = malloc(options.origsize + 1)) == NULL) memerror(); memset(output, 0, options.origsize + 1); uncompress((Bytef *) output, (uLong *) &options.origsize, (const Bytef *) *input, sz); free(*input); if ((*input = malloc(options.origsize)) == NULL) memerror(); memcpy(*input, output, options.origsize); free(output); return(options.origsize); } bcrypt-1.1.orig/win32console/0040700000550600055060000000000007540312465015224 5ustar tonontononbcrypt-1.1.orig/win32console/CVS/0040700000550600055060000000000007540312465015657 5ustar tonontononbcrypt-1.1.orig/win32console/CVS/Root0100600000550600055060000000001207540312465016515 0ustar tonontonon/home/cvs bcrypt-1.1.orig/win32console/CVS/Repository0100600000550600055060000000002407540312465017754 0ustar tonontononbcrypt/win32console bcrypt-1.1.orig/win32console/CVS/Entries0100600000550600055060000000055207540312465017214 0ustar tonontonon/Script1.rc/1.1/Fri Sep 13 07:33:27 2002// /bcrypt.dsp/1.1/Fri Sep 13 07:06:00 2002// /bcrypt.dsw/1.1/Fri Sep 13 07:11:13 2002/-kb/ /getopt.c/1.1/Fri Sep 13 07:08:05 2002// /getopt.h/1.1/Fri Sep 13 07:08:05 2002// /icon1.ico/1.1/Fri Sep 13 07:11:13 2002/-kb/ /readme-win32.txt/1.1/Fri Sep 13 07:08:05 2002// /resource.h/1.1/Fri Sep 13 07:08:05 2002// D/DLLs//// bcrypt-1.1.orig/win32console/Script1.rc0100644000550600055060000000325607540312307017107 0ustar tonontonon//Microsoft Developer Studio generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // // Icon // // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. IDI_ICON1 ICON DISCARDABLE "icon1.ico" #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE DISCARDABLE BEGIN "resource.h\0" END 2 TEXTINCLUDE DISCARDABLE BEGIN "#include ""afxres.h""\r\n" "\0" END 3 TEXTINCLUDE DISCARDABLE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED bcrypt-1.1.orig/win32console/bcrypt.dsp0100644000550600055060000001235407540307130017244 0ustar tonontonon# Microsoft Developer Studio Project File - Name="bcrypt" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=bcrypt - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "bcrypt.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "bcrypt.mak" CFG="bcrypt - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "bcrypt - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "bcrypt - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "bcrypt - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I "..\\" /I ".\DLLs" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\\" /libpath:".\DLLs" !ELSEIF "$(CFG)" == "bcrypt - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\\" /I ".\DLLs" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\\" /libpath:".\DLLs" !ENDIF # Begin Target # Name "bcrypt - Win32 Release" # Name "bcrypt - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\blowfish.c # End Source File # Begin Source File SOURCE=..\endian.c # End Source File # Begin Source File SOURCE=.\getopt.c # End Source File # Begin Source File SOURCE=..\keys.c # End Source File # Begin Source File SOURCE=..\main.c # End Source File # Begin Source File SOURCE=..\rwfile.c # End Source File # Begin Source File SOURCE=..\wrapbf.c # End Source File # Begin Source File SOURCE=..\wrapzl.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\blowfish.h # End Source File # Begin Source File SOURCE=..\config.h # End Source File # Begin Source File SOURCE=..\defines.h # End Source File # Begin Source File SOURCE=..\functions.h # End Source File # Begin Source File SOURCE=.\getopt.h # End Source File # Begin Source File SOURCE=..\includes.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # Begin Source File SOURCE=.\icon1.ico # End Source File # Begin Source File SOURCE=.\Script1.rc # End Source File # Begin Source File SOURCE=.\DLLs\libz.lib # End Source File # End Group # Begin Source File SOURCE=..\License # End Source File # Begin Source File SOURCE=..\Readme # End Source File # Begin Source File SOURCE=".\readme-win32.txt" # End Source File # End Target # End Project bcrypt-1.1.orig/win32console/bcrypt.dsw0100644000550600055060000000102707540307621017253 0ustar tonontononMicrosoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "bcrypt"=.\bcrypt.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### bcrypt-1.1.orig/win32console/getopt.c0100644000550600055060000002060207540307325016700 0ustar tonontonon//GETOPT.C /***************************************************************************** * * MODULE NAME : GETOPT.C * * COPYRIGHTS: * This module contains code made available by IBM * Corporation on an AS IS basis. Any one receiving the * module is considered to be licensed under IBM copyrights * to use the IBM-provided source code in any way he or she * deems fit, including copying it, compiling it, modifying * it, and redistributing it, with or without * modifications. No license under any IBM patents or * patent applications is to be implied from this copyright * license. * * A user of the module should understand that IBM cannot * provide technical support for the module and will not be * responsible for any consequences of use of the program. * * Any notices, including this one, are not to be removed * from the module without the prior written consent of * IBM. * * AUTHOR: Original author: * G. R. Blair (BOBBLAIR at AUSVM1) * Internet: bobblair@bobblair.austin.ibm.com * * Extensively revised by: * John Q. Walker II, Ph.D. (JOHHQ at RALVM6) * Internet: johnq@ralvm6.vnet.ibm.com * *****************************************************************************/ /****************************************************************************** * getopt() * * The getopt() function is a command line parser. It returns the next * option character in argv that matches an option character in opstring. * * The argv argument points to an array of argc+1 elements containing argc * pointers to character strings followed by a null pointer. * * The opstring argument points to a string of option characters; if an * option character is followed by a colon, the option is expected to have * an argument that may or may not be separated from it by white space. * The external variable optarg is set to point to the start of the option * argument on return from getopt(). * * The getopt() function places in optind the argv index of the next argument * to be processed. The system initializes the external variable optind to * 1 before the first call to getopt(). * * When all options have been processed (that is, up to the first nonoption * argument), getopt() returns EOF. The special option "--" may be used to * delimit the end of the options; EOF will be returned, and "--" will be * skipped. * * The getopt() function returns a question mark (?) when it encounters an * option character not included in opstring. This error message can be * disabled by setting opterr to zero. Otherwise, it returns the option * character that was detected. * * If the special option "--" is detected, or all options have been * processed, EOF is returned. * * Options are marked by either a minus sign (-) or a slash (/). * * No errors are defined. *****************************************************************************/ #include /* for EOF */ #include /* for strchr() */ /* static (global) variables that are specified as exported by getopt() */ char *optarg = NULL; /* pointer to the start of the option argument */ int optind = 1; /* number of the next argv[] to be evaluated */ int opterr = 1; /* non-zero if a question mark should be returned when a non-valid option character is detected */ /* handle possible future character set concerns by putting this in a macro */ #define _next_char(string) (char)(*(string+1)) int getopt(int argc, char *argv[], char *opstring) { static char *pIndexPosition = NULL; /* place inside current argv string */ char *pArgString = NULL; /* where to start from next */ char *pOptString; /* the string in our program */ if (pIndexPosition != NULL) { /* we last left off inside an argv string */ if (*(++pIndexPosition)) { /* there is more to come in the most recent argv */ pArgString = pIndexPosition; } } if (pArgString == NULL) { /* we didn't leave off in the middle of an argv string */ if (optind >= argc) { /* more command-line arguments than the argument count */ pIndexPosition = NULL; /* not in the middle of anything */ return EOF; /* used up all command-line arguments */ } /*--------------------------------------------------------------------- * If the next argv[] is not an option, there can be no more options. *-------------------------------------------------------------------*/ pArgString = argv[optind++]; /* set this to the next argument ptr */ if (('/' != *pArgString) && /* doesn't start with a slash or a dash? */ ('-' != *pArgString)) { --optind; /* point to current arg once we're done */ optarg = NULL; /* no argument follows the option */ pIndexPosition = NULL; /* not in the middle of anything */ return EOF; /* used up all the command-line flags */ } /* check for special end-of-flags markers */ if ((strcmp(pArgString, "-") == 0) || (strcmp(pArgString, "--") == 0)) { optarg = NULL; /* no argument follows the option */ pIndexPosition = NULL; /* not in the middle of anything */ return EOF; /* encountered the special flag */ } pArgString++; /* look past the / or - */ } if (':' == *pArgString) { /* is it a colon? */ /*--------------------------------------------------------------------- * Rare case: if opterr is non-zero, return a question mark; * otherwise, just return the colon we're on. *-------------------------------------------------------------------*/ return (opterr ? (int)'?' : (int)':'); } else if ((pOptString = strchr(opstring, *pArgString)) == 0) { /*--------------------------------------------------------------------- * The letter on the command-line wasn't any good. *-------------------------------------------------------------------*/ optarg = NULL; /* no argument follows the option */ pIndexPosition = NULL; /* not in the middle of anything */ return (opterr ? (int)'?' : (int)*pArgString); } else { /*--------------------------------------------------------------------- * The letter on the command-line matches one we expect to see *-------------------------------------------------------------------*/ if (':' == _next_char(pOptString)) { /* is the next letter a colon? */ /* It is a colon. Look for an argument string. */ if ('\0' != _next_char(pArgString)) { /* argument in this argv? */ optarg = &pArgString[1]; /* Yes, it is */ } else { /*------------------------------------------------------------- * The argument string must be in the next argv. * But, what if there is none (bad input from the user)? * In that case, return the letter, and optarg as NULL. *-----------------------------------------------------------*/ if (optind < argc) optarg = argv[optind++]; else { optarg = NULL; return (opterr ? (int)'?' : (int)*pArgString); } } pIndexPosition = NULL; /* not in the middle of anything */ } else { /* it's not a colon, so just return the letter */ optarg = NULL; /* no argument follows the option */ pIndexPosition = pArgString; /* point to the letter we're on */ } return (int)*pArgString; /* return the letter that matched */ } } bcrypt-1.1.orig/win32console/getopt.h0100644000550600055060000000315107540307325016705 0ustar tonontonon/***************************************************************************** * * MODULE NAME : GETOPT.H * * COPYRIGHTS: * This module contains code made available by IBM * Corporation on an AS IS basis. Any one receiving the * module is considered to be licensed under IBM copyrights * to use the IBM-provided source code in any way he or she * deems fit, including copying it, compiling it, modifying * it, and redistributing it, with or without * modifications. No license under any IBM patents or * patent applications is to be implied from this copyright * license. * * A user of the module should understand that IBM cannot * provide technical support for the module and will not be * responsible for any consequences of use of the program. * * Any notices, including this one, are not to be removed * from the module without the prior written consent of * IBM. * * AUTHOR: Original author: * G. R. Blair (BOBBLAIR at AUSVM1) * Internet: bobblair@bobblair.austin.ibm.com * * Extensively revised by: * John Q. Walker II, Ph.D. (JOHHQ at RALVM6) * Internet: johnq@ralvm6.vnet.ibm.com * *****************************************************************************/ extern char * optarg; extern int optind; int getopt ( int argc, char **argv, char *optstring); bcrypt-1.1.orig/win32console/icon1.ico0100644000550600055060000000137607540307621016745 0ustar tonontonon è( @€€€€€€€€€ÀÀÀ€€€ÿÿÿÿÿÿÿÿÿÿÿÿ@PP€wà0Ý@UP€î0ÐÐPPˆpÐÐ@ˆwà0Ý Ð0àî p€Ð0àà p€ Ð3à Àw€f Ð3àî Àw€ˆ3pDÌwp@@ ˆP3p@@ÌpˆP3pDÌ@ˆ0pPÌ Ðî@ˆ0fpPÌ ˆ0fpPÀÐî@ˆ0pPÌ Ðî À` àˆ@îÀU` à@àà U`À0ˆ@àà À` Àî0ˆ@îÿÿÿÿÿÿÿÿÿÿÿÿ•f&OÑbâWµ*j×›&&Oÿÿÿÿÿÿÿÿ–KdïÖ[do’i%O’I$ïÿÿÿÿÿÿÿÿš’Í3ˆšé[ª’IS’M3ÿÿÿÿÿÿÿÿ’i$“ÓI´»²I%Ó’i$“ÿÿÿÿÿÿÿÿšKl“ÒKnÕ²M¤•šI$“ÿÿÿÿbcrypt-1.1.orig/win32console/readme-win32.txt0100644000550600055060000000142707540307325020174 0ustar tonontononTo run the program, make sure the bcrypt.exe and zlib.dll files are in the same directory. It will also work if zlib.dll is located elsewhere, but still in the path. The win32 native version behaves slightly differently, in that it doesn't hide the passphrase as you type it in. Otherwise, it's functionally identical to Un*x native code. ZLib for Win32 obtained from the GnuWin32 project at: http://sourceforge.net/project/showfiles.php?group_id=23617 Download zlib-1.1.4-bin.zip to get the .dll. If you plan on compiling from source, download zlib-1.1.4-bin.zip to get the .dll, and zlib-1.1.4-lib.zip to get the include files. Place the .dll file in the win32console directory, and everything should work perfectly from within the Visual Studio environment. bcrypt-1.1.orig/win32console/resource.h0100644000550600055060000000071007540307325017230 0ustar tonontonon//{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. // Used by Script1.rc // #define IDI_ICON1 101 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 102 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif bcrypt-1.1.orig/win32console/DLLs/0040700000550600055060000000000007540312465016022 5ustar tonontononbcrypt-1.1.orig/win32console/DLLs/CVS/0040700000550600055060000000000007540312465016455 5ustar tonontononbcrypt-1.1.orig/win32console/DLLs/CVS/Root0100600000550600055060000000001207540312465017313 0ustar tonontonon/home/cvs bcrypt-1.1.orig/win32console/DLLs/CVS/Repository0100600000550600055060000000003107540312465020550 0ustar tonontononbcrypt/win32console/DLLs bcrypt-1.1.orig/win32console/DLLs/CVS/Entries0100600000550600055060000000017207540312465020010 0ustar tonontonon/libz.def/1.1/Fri Sep 13 07:08:10 2002// /zconf.h/1.1/Fri Sep 13 07:08:10 2002// /zlib.h/1.1/Fri Sep 13 07:08:10 2002// D bcrypt-1.1.orig/win32console/DLLs/libz.def0100644000550600055060000000333707540307332017454 0ustar tonontonon; i:\MINGW\BIN\dlltool.exe -Cn -a -z libz.def --export-all-symbols adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o EXPORTS gzseek @ 1 ; _length_code @ 2 DATA ; _tr_align @ 3 ; _tr_flush_block @ 4 ; _tr_init @ 5 ; _tr_stored_block @ 6 ; _tr_tally @ 7 ; adler32 @ 8 ; compress @ 9 ; compress2 @ 10 ; crc32 @ 11 ; deflate @ 12 ; deflateCopy @ 13 ; deflateEnd @ 14 ; deflateInit2_ @ 15 ; deflateInit_ @ 16 ; deflateParams @ 17 ; deflateReset @ 18 ; deflateSetDictionary @ 19 ; deflate_copyright @ 20 DATA ; get_crc_table @ 21 ; gzclose @ 22 ; gzdopen @ 23 ; gzeof @ 24 ; gzerror @ 25 ; gzflush @ 26 ; gzgetc @ 27 ; gzgets @ 28 ; gzopen @ 29 ; gzprintf @ 30 ; gzputc @ 31 ; gzputs @ 32 ; gzread @ 33 ; gzrewind @ 34 ; _dist_code @ 35 DATA ; gzsetparams @ 36 ; gztell @ 37 ; gzwrite @ 38 ; inflate @ 39 ; inflateEnd @ 40 ; inflateInit2_ @ 41 ; inflateInit_ @ 42 ; inflateReset @ 43 ; inflateSetDictionary @ 44 ; inflateSync @ 45 ; inflateSyncPoint @ 46 ; inflate_blocks @ 47 ; inflate_blocks_free @ 48 ; inflate_blocks_new @ 49 ; inflate_blocks_reset @ 50 ; inflate_blocks_sync_point @ 51 ; inflate_codes @ 52 ; inflate_codes_free @ 53 ; inflate_codes_new @ 54 ; inflate_copyright @ 55 DATA ; inflate_fast @ 56 ; inflate_flush @ 57 ; inflate_mask @ 58 DATA ; inflate_set_dictionary @ 59 ; inflate_trees_bits @ 60 ; inflate_trees_dynamic @ 61 ; inflate_trees_fixed @ 62 ; uncompress @ 63 ; zError @ 64 ; z_errmsg @ 65 DATA ; zcalloc @ 66 ; zcfree @ 67 ; zlibVersion @ 68 ; bcrypt-1.1.orig/win32console/DLLs/zconf.h0100644000550600055060000001726107540307332017325 0ustar tonontonon/* zconf.h -- configuration of the zlib compression library * Copyright (C) 1995-2002 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id: zconf.h,v 1.1 2002/09/13 07:08:10 syntax Exp $ */ #ifndef _ZCONF_H #define _ZCONF_H /* * If you *really* need a unique prefix for all types and library functions, * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. */ #ifdef Z_PREFIX # define deflateInit_ z_deflateInit_ # define deflate z_deflate # define deflateEnd z_deflateEnd # define inflateInit_ z_inflateInit_ # define inflate z_inflate # define inflateEnd z_inflateEnd # define deflateInit2_ z_deflateInit2_ # define deflateSetDictionary z_deflateSetDictionary # define deflateCopy z_deflateCopy # define deflateReset z_deflateReset # define deflateParams z_deflateParams # define inflateInit2_ z_inflateInit2_ # define inflateSetDictionary z_inflateSetDictionary # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateReset z_inflateReset # define compress z_compress # define compress2 z_compress2 # define uncompress z_uncompress # define adler32 z_adler32 # define crc32 z_crc32 # define get_crc_table z_get_crc_table # define Byte z_Byte # define uInt z_uInt # define uLong z_uLong # define Bytef z_Bytef # define charf z_charf # define intf z_intf # define uIntf z_uIntf # define uLongf z_uLongf # define voidpf z_voidpf # define voidp z_voidp #endif #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) # define WIN32 #endif #if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) # ifndef __32BIT__ # define __32BIT__ # endif #endif #if defined(__MSDOS__) && !defined(MSDOS) # define MSDOS #endif /* * Compile with -DMAXSEG_64K if the alloc function cannot allocate more * than 64k bytes at a time (needed on systems with 16-bit int). */ #if defined(MSDOS) && !defined(__32BIT__) # define MAXSEG_64K #endif #ifdef MSDOS # define UNALIGNED_OK #endif #if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) # define STDC #endif #if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) # ifndef STDC # define STDC # endif #endif #ifndef STDC # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ # define const # endif #endif /* Some Mac compilers merge all .h files incorrectly: */ #if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) # define NO_DUMMY_DECL #endif /* Old Borland C incorrectly complains about missing returns: */ #if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) # define NEED_DUMMY_RETURN #endif /* Maximum value for memLevel in deflateInit2 */ #ifndef MAX_MEM_LEVEL # ifdef MAXSEG_64K # define MAX_MEM_LEVEL 8 # else # define MAX_MEM_LEVEL 9 # endif #endif /* Maximum value for windowBits in deflateInit2 and inflateInit2. * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files * created by gzip. (Files created by minigzip can still be extracted by * gzip.) */ #ifndef MAX_WBITS # define MAX_WBITS 15 /* 32K LZ77 window */ #endif /* The memory requirements for deflate are (in bytes): (1 << (windowBits+2)) + (1 << (memLevel+9)) that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) plus a few kilobytes for small objects. For example, if you want to reduce the default memory requirements from 256K to 128K, compile with make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" Of course this will generally degrade compression (there's no free lunch). The memory requirements for inflate are (in bytes) 1 << windowBits that is, 32K for windowBits=15 (default value) plus a few kilobytes for small objects. */ /* Type declarations */ #ifndef OF /* function prototypes */ # ifdef STDC # define OF(args) args # else # define OF(args) () # endif #endif /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, * just define FAR to be empty. */ #if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) /* MSC small or medium model */ # define SMALL_MEDIUM # ifdef _MSC_VER # define FAR _far # else # define FAR far # endif #endif #if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) # ifndef __32BIT__ # define SMALL_MEDIUM # define FAR _far # endif #endif /* Compile with -DZLIB_DLL for Windows DLL support */ #if defined(ZLIB_DLL) # if defined(_WINDOWS) || defined(WINDOWS) # ifdef FAR # undef FAR # endif # include # define ZEXPORT WINAPI # ifdef WIN32 # define ZEXPORTVA WINAPIV # else # define ZEXPORTVA FAR _cdecl _export # endif # endif # if defined (__BORLANDC__) # if (__BORLANDC__ >= 0x0500) && defined (WIN32) # include # define ZEXPORT __declspec(dllexport) WINAPI # define ZEXPORTRVA __declspec(dllexport) WINAPIV # else # if defined (_Windows) && defined (__DLL__) # define ZEXPORT _export # define ZEXPORTVA _export # endif # endif # endif #endif #if defined (__BEOS__) # if defined (ZLIB_DLL) # define ZEXTERN extern __declspec(dllexport) # else # define ZEXTERN extern __declspec(dllimport) # endif #endif #ifndef ZEXPORT # define ZEXPORT #endif #ifndef ZEXPORTVA # define ZEXPORTVA #endif #ifndef ZEXTERN # define ZEXTERN extern #endif #ifndef FAR # define FAR #endif #if !defined(MACOS) && !defined(TARGET_OS_MAC) typedef unsigned char Byte; /* 8 bits */ #endif typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned long uLong; /* 32 bits or more */ #ifdef SMALL_MEDIUM /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ # define Bytef Byte FAR #else typedef Byte FAR Bytef; #endif typedef char FAR charf; typedef int FAR intf; typedef uInt FAR uIntf; typedef uLong FAR uLongf; #ifdef STDC typedef void FAR *voidpf; typedef void *voidp; #else typedef Byte FAR *voidpf; typedef Byte *voidp; #endif #ifdef HAVE_UNISTD_H # include /* for off_t */ # include /* for SEEK_* and off_t */ # define z_off_t off_t #endif #ifndef SEEK_SET # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif #ifndef z_off_t # define z_off_t long #endif /* MVS linker does not support external names larger than 8 bytes */ #if defined(__MVS__) # pragma map(deflateInit_,"DEIN") # pragma map(deflateInit2_,"DEIN2") # pragma map(deflateEnd,"DEEND") # pragma map(inflateInit_,"ININ") # pragma map(inflateInit2_,"ININ2") # pragma map(inflateEnd,"INEND") # pragma map(inflateSync,"INSY") # pragma map(inflateSetDictionary,"INSEDI") # pragma map(inflate_blocks,"INBL") # pragma map(inflate_blocks_new,"INBLNE") # pragma map(inflate_blocks_free,"INBLFR") # pragma map(inflate_blocks_reset,"INBLRE") # pragma map(inflate_codes_free,"INCOFR") # pragma map(inflate_codes,"INCO") # pragma map(inflate_fast,"INFA") # pragma map(inflate_flush,"INFLU") # pragma map(inflate_mask,"INMA") # pragma map(inflate_set_dictionary,"INSEDI2") # pragma map(inflate_copyright,"INCOPY") # pragma map(inflate_trees_bits,"INTRBI") # pragma map(inflate_trees_dynamic,"INTRDY") # pragma map(inflate_trees_fixed,"INTRFI") # pragma map(inflate_trees_free,"INTRFR") #endif #endif /* _ZCONF_H */ bcrypt-1.1.orig/win32console/DLLs/zlib.h0100644000550600055060000011770407540307332017151 0ustar tonontonon/* zlib.h -- interface of the 'zlib' general purpose compression library version 1.1.4, March 11th, 2002 Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. 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. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Jean-loup Gailly Mark Adler jloup@gzip.org madler@alumni.caltech.edu The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). */ #ifndef _ZLIB_H #define _ZLIB_H #include "zconf.h" #ifdef __cplusplus extern "C" { #endif #define ZLIB_VERSION "1.1.4" /* The 'zlib' compression library provides in-memory compression and decompression functions, including integrity checks of the uncompressed data. This version of the library supports only one compression method (deflation) but other algorithms will be added later and will have the same stream interface. Compression can be done in a single step if the buffers are large enough (for example if an input file is mmap'ed), or can be done by repeated calls of the compression function. In the latter case, the application must provide more input and/or consume the output (providing more output space) before each call. The library also supports reading and writing files in gzip (.gz) format with an interface similar to that of stdio. The library does not install any signal handler. The decoder checks the consistency of the compressed data, so the library should never crash even in case of corrupted input. */ typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); typedef void (*free_func) OF((voidpf opaque, voidpf address)); struct internal_state; typedef struct z_stream_s { Bytef *next_in; /* next input byte */ uInt avail_in; /* number of bytes available at next_in */ uLong total_in; /* total nb of input bytes read so far */ Bytef *next_out; /* next output byte should be put there */ uInt avail_out; /* remaining free space at next_out */ uLong total_out; /* total nb of bytes output so far */ char *msg; /* last error message, NULL if no error */ struct internal_state FAR *state; /* not visible by applications */ alloc_func zalloc; /* used to allocate the internal state */ free_func zfree; /* used to free the internal state */ voidpf opaque; /* private data object passed to zalloc and zfree */ int data_type; /* best guess about the data type: ascii or binary */ uLong adler; /* adler32 value of the uncompressed data */ uLong reserved; /* reserved for future use */ } z_stream; typedef z_stream FAR *z_streamp; /* The application must update next_in and avail_in when avail_in has dropped to zero. It must update next_out and avail_out when avail_out has dropped to zero. The application must initialize zalloc, zfree and opaque before calling the init function. All other fields are set by the compression library and must not be updated by the application. The opaque value provided by the application will be passed as the first parameter for calls of zalloc and zfree. This can be useful for custom memory management. The compression library attaches no meaning to the opaque value. zalloc must return Z_NULL if there is not enough memory for the object. If zlib is used in a multi-threaded application, zalloc and zfree must be thread safe. On 16-bit systems, the functions zalloc and zfree must be able to allocate exactly 65536 bytes, but will not be required to allocate more than this if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers returned by zalloc for objects of exactly 65536 bytes *must* have their offset normalized to zero. The default allocation function provided by this library ensures this (see zutil.c). To reduce memory requirements and avoid any allocation of 64K objects, at the expense of compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). The fields total_in and total_out can be used for statistics or progress reports. After compression, total_in holds the total size of the uncompressed data and may be saved for use in the decompressor (particularly if the decompressor wants to decompress everything in a single step). */ /* constants */ #define Z_NO_FLUSH 0 #define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ #define Z_SYNC_FLUSH 2 #define Z_FULL_FLUSH 3 #define Z_FINISH 4 /* Allowed flush values; see deflate() below for details */ #define Z_OK 0 #define Z_STREAM_END 1 #define Z_NEED_DICT 2 #define Z_ERRNO (-1) #define Z_STREAM_ERROR (-2) #define Z_DATA_ERROR (-3) #define Z_MEM_ERROR (-4) #define Z_BUF_ERROR (-5) #define Z_VERSION_ERROR (-6) /* Return codes for the compression/decompression functions. Negative * values are errors, positive values are used for special but normal events. */ #define Z_NO_COMPRESSION 0 #define Z_BEST_SPEED 1 #define Z_BEST_COMPRESSION 9 #define Z_DEFAULT_COMPRESSION (-1) /* compression levels */ #define Z_FILTERED 1 #define Z_HUFFMAN_ONLY 2 #define Z_DEFAULT_STRATEGY 0 /* compression strategy; see deflateInit2() below for details */ #define Z_BINARY 0 #define Z_ASCII 1 #define Z_UNKNOWN 2 /* Possible values of the data_type field */ #define Z_DEFLATED 8 /* The deflate compression method (the only one supported in this version) */ #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ #define zlib_version zlibVersion() /* for compatibility with versions < 1.0.2 */ /* basic functions */ ZEXTERN const char * ZEXPORT zlibVersion OF((void)); /* The application can compare zlibVersion and ZLIB_VERSION for consistency. If the first character differs, the library code actually used is not compatible with the zlib.h header file used by the application. This check is automatically made by deflateInit and inflateInit. */ /* ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); Initializes the internal stream state for compression. The fields zalloc, zfree and opaque must be initialized before by the caller. If zalloc and zfree are set to Z_NULL, deflateInit updates them to use default allocation functions. The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: 1 gives best speed, 9 gives best compression, 0 gives no compression at all (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION requests a default compromise between speed and compression (currently equivalent to level 6). deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if level is not a valid compression level, Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible with the version assumed by the caller (ZLIB_VERSION). msg is set to null if there is no error message. deflateInit does not perform any compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); /* deflate compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce some output latency (reading input without producing any output) except when forced to flush. The detailed semantics are as follows. deflate performs one or both of the following actions: - Compress more input starting at next_in and update next_in and avail_in accordingly. If not all input can be processed (because there is not enough room in the output buffer), next_in and avail_in are updated and processing will resume at this point for the next call of deflate(). - Provide more output starting at next_out and update next_out and avail_out accordingly. This action is forced if the parameter flush is non zero. Forcing flush frequently degrades the compression ratio, so this parameter should be set only when necessary (in interactive applications). Some output may be provided even if flush is not set. Before the call of deflate(), the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more output, and updating avail_in or avail_out accordingly; avail_out should never be zero before the call. The application can consume the compressed output when it wants, for example when the output buffer is full (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK and with zero avail_out, it must be called again after making room in the output buffer because there might be more output pending. If the parameter flush is set to Z_SYNC_FLUSH, all pending output is flushed to the output buffer and the output is aligned on a byte boundary, so that the decompressor can get all input data available so far. (In particular avail_in is zero after the call if enough output space has been provided before the call.) Flushing may degrade compression for some compression algorithms and so it should be used only when necessary. If flush is set to Z_FULL_FLUSH, all output is flushed as with Z_SYNC_FLUSH, and the compression state is reset so that decompression can restart from this point if previous compressed data has been damaged or if random access is desired. Using Z_FULL_FLUSH too often can seriously degrade the compression. If deflate returns with avail_out == 0, this function must be called again with the same value of the flush parameter and more output space (updated avail_out), until the flush is complete (deflate returns with non-zero avail_out). If the parameter flush is set to Z_FINISH, pending input is processed, pending output is flushed and deflate returns with Z_STREAM_END if there was enough output space; if deflate returns with Z_OK, this function must be called again with Z_FINISH and more output space (updated avail_out) but no more input data, until it returns with Z_STREAM_END or an error. After deflate has returned Z_STREAM_END, the only possible operations on the stream are deflateReset or deflateEnd. Z_FINISH can be used immediately after deflateInit if all the compression is to be done in a single step. In this case, avail_out must be at least 0.1% larger than avail_in plus 12 bytes. If deflate does not return Z_STREAM_END, then it must be called again as described above. deflate() sets strm->adler to the adler32 checksum of all input read so far (that is, total_in bytes). deflate() may update data_type if it can make a good guess about the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered binary. This field is only for information purposes and does not affect the compression algorithm in any manner. deflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if all input has been consumed and all output has been produced (only when flush is set to Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible (for example avail_in or avail_out was zero). */ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending output. deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state was inconsistent, Z_DATA_ERROR if the stream was freed prematurely (some input or output was discarded). In the error case, msg may be set but then points to a static string (which must not be deallocated). */ /* ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); Initializes the internal stream state for decompression. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by the caller. If next_in is not Z_NULL and avail_in is large enough (the exact value depends on the compression method), inflateInit determines the compression method from the zlib header and allocates all data structures accordingly; otherwise the allocation will be deferred to the first call of inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to use default allocation functions. inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the version assumed by the caller. msg is set to null if there is no error message. inflateInit does not perform any decompression apart from reading the zlib header if present: this will be done by inflate(). (So next_in and avail_in may be modified, but next_out and avail_out are unchanged.) */ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); /* inflate decompresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may some introduce some output latency (reading input without producing any output) except when forced to flush. The detailed semantics are as follows. inflate performs one or both of the following actions: - Decompress more input starting at next_in and update next_in and avail_in accordingly. If not all input can be processed (because there is not enough room in the output buffer), next_in is updated and processing will resume at this point for the next call of inflate(). - Provide more output starting at next_out and update next_out and avail_out accordingly. inflate() provides as much output as possible, until there is no more input data or no more space in the output buffer (see below about the flush parameter). Before the call of inflate(), the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more output, and updating the next_* and avail_* values accordingly. The application can consume the uncompressed output when it wants, for example when the output buffer is full (avail_out == 0), or after each call of inflate(). If inflate returns Z_OK and with zero avail_out, it must be called again after making room in the output buffer because there might be more output pending. If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much output as possible to the output buffer. The flushing behavior of inflate is not specified for values of the flush parameter other than Z_SYNC_FLUSH and Z_FINISH, but the current implementation actually flushes as much output as possible anyway. inflate() should normally be called until it returns Z_STREAM_END or an error. However if all decompression is to be performed in a single step (a single call of inflate), the parameter flush should be set to Z_FINISH. In this case all pending input is processed and all pending output is flushed; avail_out must be large enough to hold all the uncompressed data. (The size of the uncompressed data may have been saved by the compressor for this purpose.) The next operation on this stream must be inflateEnd to deallocate the decompression state. The use of Z_FINISH is never required, but can be used to inform inflate that a faster routine may be used for the single inflate() call. If a preset dictionary is needed at this point (see inflateSetDictionary below), inflate sets strm-adler to the adler32 checksum of the dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise it sets strm->adler to the adler32 checksum of all output produced so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described below. At the end of the stream, inflate() checks that its computed adler32 checksum is equal to that saved by the compressor and returns Z_STREAM_END only if the checksum is correct. inflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if the end of the compressed data has been reached and all uncompressed output has been produced, Z_NEED_DICT if a preset dictionary is needed at this point, Z_DATA_ERROR if the input data was corrupted (input stream not conforming to the zlib format or incorrect adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if no progress is possible or if there was not enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR case, the application may then call inflateSync to look for a good compression block. */ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending output. inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state was inconsistent. In the error case, msg may be set but then points to a static string (which must not be deallocated). */ /* Advanced functions */ /* The following functions are needed only in some special applications. */ /* ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy)); This is another version of deflateInit with more compression options. The fields next_in, zalloc, zfree and opaque must be initialized before by the caller. The method parameter is the compression method. It must be Z_DEFLATED in this version of the library. The windowBits parameter is the base two logarithm of the window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. Larger values of this parameter result in better compression at the expense of memory usage. The default value is 15 if deflateInit is used instead. The memLevel parameter specifies how much memory should be allocated for the internal compression state. memLevel=1 uses minimum memory but is slow and reduces compression ratio; memLevel=9 uses maximum memory for optimal speed. The default value is 8. See zconf.h for total memory usage as a function of windowBits and memLevel. The strategy parameter is used to tune the compression algorithm. Use the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no string match). Filtered data consists mostly of small values with a somewhat random distribution. In this case, the compression algorithm is tuned to compress them better. The effect of Z_FILTERED is to force more Huffman coding and less string matching; it is somewhat intermediate between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately. deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid method). msg is set to null if there is no error message. deflateInit2 does not perform any compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, const Bytef *dictionary, uInt dictLength)); /* Initializes the compression dictionary from the given byte sequence without producing any compressed output. This function must be called immediately after deflateInit, deflateInit2 or deflateReset, before any call of deflate. The compressor and decompressor must use exactly the same dictionary (see inflateSetDictionary). The dictionary should consist of strings (byte sequences) that are likely to be encountered later in the data to be compressed, with the most commonly used strings preferably put towards the end of the dictionary. Using a dictionary is most useful when the data to be compressed is short and can be predicted with good accuracy; the data can then be compressed better than with the default empty dictionary. Depending on the size of the compression data structures selected by deflateInit or deflateInit2, a part of the dictionary may in effect be discarded, for example if the dictionary is larger than the window size in deflate or deflate2. Thus the strings most likely to be useful should be put at the end of the dictionary, not at the front. Upon return of this function, strm->adler is set to the Adler32 value of the dictionary; the decompressor may later use this value to determine which dictionary has been used by the compressor. (The Adler32 value applies to the whole dictionary even if only a subset of the dictionary is actually used by the compressor.) deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a parameter is invalid (such as NULL dictionary) or the stream state is inconsistent (for example if deflate has already been called for this stream or if the compression method is bsort). deflateSetDictionary does not perform any compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, z_streamp source)); /* Sets the destination stream as a complete copy of the source stream. This function can be useful when several compression strategies will be tried, for example when there are several ways of pre-processing the input data with a filter. The streams that will be discarded should then be freed by calling deflateEnd. Note that deflateCopy duplicates the internal compression state which can be quite large, so this strategy is slow and can consume lots of memory. deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc being NULL). msg is left unchanged in both source and destination. */ ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); /* This function is equivalent to deflateEnd followed by deflateInit, but does not free and reallocate all the internal compression state. The stream will keep the same compression level and any other attributes that may have been set by deflateInit2. deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being NULL). */ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, int level, int strategy)); /* Dynamically update the compression level and compression strategy. The interpretation of level and strategy is as in deflateInit2. This can be used to switch between compression and straight copy of the input data, or to switch to a different kind of input data requiring a different strategy. If the compression level is changed, the input available so far is compressed with the old level (and may be flushed); the new level will take effect only at the next call of deflate(). Before the call of deflateParams, the stream state must be set as for a call of deflate(), since the currently available input may have to be compressed and flushed. In particular, strm->avail_out must be non-zero. deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if strm->avail_out was zero. */ /* ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, int windowBits)); This is another version of inflateInit with an extra parameter. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by the caller. The windowBits parameter is the base two logarithm of the maximum window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. The default value is 15 if inflateInit is used instead. If a compressed stream with a larger window size is given as input, inflate() will return with the error code Z_DATA_ERROR instead of trying to allocate a larger window. inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative memLevel). msg is set to null if there is no error message. inflateInit2 does not perform any decompression apart from reading the zlib header if present: this will be done by inflate(). (So next_in and avail_in may be modified, but next_out and avail_out are unchanged.) */ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, const Bytef *dictionary, uInt dictLength)); /* Initializes the decompression dictionary from the given uncompressed byte sequence. This function must be called immediately after a call of inflate if this call returned Z_NEED_DICT. The dictionary chosen by the compressor can be determined from the Adler32 value returned by this call of inflate. The compressor and decompressor must use exactly the same dictionary (see deflateSetDictionary). inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a parameter is invalid (such as NULL dictionary) or the stream state is inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the expected one (incorrect Adler32 value). inflateSetDictionary does not perform any decompression: this will be done by subsequent calls of inflate(). */ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); /* Skips invalid compressed data until a full flush point (see above the description of deflate with Z_FULL_FLUSH) can be found, or until all available input is skipped. No output is provided. inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the success case, the application may save the current current value of total_in which indicates where valid compressed data was found. In the error case, the application may repeatedly call inflateSync, providing more input each time, until success or end of the input data. */ ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); /* This function is equivalent to inflateEnd followed by inflateInit, but does not free and reallocate all the internal decompression state. The stream will keep attributes that may have been set by inflateInit2. inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being NULL). */ /* utility functions */ /* The following utility functions are implemented on top of the basic stream-oriented functions. To simplify the interface, some default options are assumed (compression level and memory usage, standard memory allocation functions). The source code of these utility functions can easily be modified if you need special options. */ ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)); /* Compresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least 0.1% larger than sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. This function can be used to compress a whole file at once if the input file is mmap'ed. compress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer. */ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)); /* Compresses the source buffer into the destination buffer. The level parameter has the same meaning as in deflateInit. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least 0.1% larger than sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, Z_STREAM_ERROR if the level parameter is invalid. */ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)); /* Decompresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be large enough to hold the entire uncompressed data. (The size of the uncompressed data must have been saved previously by the compressor and transmitted to the decompressor by some mechanism outside the scope of this compression library.) Upon exit, destLen is the actual size of the compressed buffer. This function can be used to decompress a whole file at once if the input file is mmap'ed. uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, or Z_DATA_ERROR if the input data was corrupted. */ typedef voidp gzFile; ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); /* Opens a gzip (.gz) file for reading or writing. The mode parameter is as in fopen ("rb" or "wb") but can also include a compression level ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman only compression as in "wb1h". (See the description of deflateInit2 for more information about the strategy parameter.) gzopen can be used to read a file which is not in gzip format; in this case gzread will directly read from the file without decompression. gzopen returns NULL if the file could not be opened or if there was insufficient memory to allocate the (de)compression state; errno can be checked to distinguish the two cases (if errno is zero, the zlib error is Z_MEM_ERROR). */ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); /* gzdopen() associates a gzFile with the file descriptor fd. File descriptors are obtained from calls like open, dup, creat, pipe or fileno (in the file has been previously opened with fopen). The mode parameter is as in gzopen. The next call of gzclose on the returned gzFile will also close the file descriptor fd, just like fclose(fdopen(fd), mode) closes the file descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). gzdopen returns NULL if there was insufficient memory to allocate the (de)compression state. */ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); /* Dynamically update the compression level or strategy. See the description of deflateInit2 for the meaning of these parameters. gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not opened for writing. */ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); /* Reads the given number of uncompressed bytes from the compressed file. If the input file was not in gzip format, gzread copies the given number of bytes into the buffer. gzread returns the number of uncompressed bytes actually read (0 for end of file, -1 for error). */ ZEXTERN int ZEXPORT gzwrite OF((gzFile file, const voidp buf, unsigned len)); /* Writes the given number of uncompressed bytes into the compressed file. gzwrite returns the number of uncompressed bytes actually written (0 in case of error). */ ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); /* Converts, formats, and writes the args to the compressed file under control of the format string, as in fprintf. gzprintf returns the number of uncompressed bytes actually written (0 in case of error). */ ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); /* Writes the given null-terminated string to the compressed file, excluding the terminating null character. gzputs returns the number of characters written, or -1 in case of error. */ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); /* Reads bytes from the compressed file until len-1 characters are read, or a newline character is read and transferred to buf, or an end-of-file condition is encountered. The string is then terminated with a null character. gzgets returns buf, or Z_NULL in case of error. */ ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); /* Writes c, converted to an unsigned char, into the compressed file. gzputc returns the value that was written, or -1 in case of error. */ ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); /* Reads one byte from the compressed file. gzgetc returns this byte or -1 in case of end of file or error. */ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); /* Flushes all pending output into the compressed file. The parameter flush is as in the deflate() function. The return value is the zlib error number (see function gzerror below). gzflush returns Z_OK if the flush parameter is Z_FINISH and all output could be flushed. gzflush should be called only when strictly necessary because it can degrade compression. */ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, z_off_t offset, int whence)); /* Sets the starting position for the next gzread or gzwrite on the given compressed file. The offset represents a number of bytes in the uncompressed data stream. The whence parameter is defined as in lseek(2); the value SEEK_END is not supported. If the file is opened for reading, this function is emulated but can be extremely slow. If the file is opened for writing, only forward seeks are supported; gzseek then compresses a sequence of zeroes up to the new starting position. gzseek returns the resulting offset location as measured in bytes from the beginning of the uncompressed stream, or -1 in case of error, in particular if the file is opened for writing and the new starting position would be before the current position. */ ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); /* Rewinds the given file. This function is supported only for reading. gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) */ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); /* Returns the starting position for the next gzread or gzwrite on the given compressed file. This position represents a number of bytes in the uncompressed data stream. gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) */ ZEXTERN int ZEXPORT gzeof OF((gzFile file)); /* Returns 1 when EOF has previously been detected reading the given input stream, otherwise zero. */ ZEXTERN int ZEXPORT gzclose OF((gzFile file)); /* Flushes all pending output if necessary, closes the compressed file and deallocates all the (de)compression state. The return value is the zlib error number (see function gzerror below). */ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); /* Returns the error message for the last error which occurred on the given compressed file. errnum is set to zlib error number. If an error occurred in the file system and not in the compression library, errnum is set to Z_ERRNO and the application may consult errno to get the exact error code. */ /* checksum functions */ /* These functions are not related to compression but are exported anyway because they might be useful in applications using the compression library. */ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); /* Update a running Adler-32 checksum with the bytes buf[0..len-1] and return the updated checksum. If buf is NULL, this function returns the required initial value for the checksum. An Adler-32 checksum is almost as reliable as a CRC32 but can be computed much faster. Usage example: uLong adler = adler32(0L, Z_NULL, 0); while (read_buffer(buffer, length) != EOF) { adler = adler32(adler, buffer, length); } if (adler != original_adler) error(); */ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); /* Update a running crc with the bytes buf[0..len-1] and return the updated crc. If buf is NULL, this function returns the required initial value for the crc. Pre- and post-conditioning (one's complement) is performed within this function so it shouldn't be done by the application. Usage example: uLong crc = crc32(0L, Z_NULL, 0); while (read_buffer(buffer, length) != EOF) { crc = crc32(crc, buffer, length); } if (crc != original_crc) error(); */ /* various hacks, don't look :) */ /* deflateInit and inflateInit are macros to allow checking the zlib version * and the compiler's view of z_stream: */ ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, const char *version, int stream_size)); ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, const char *version, int stream_size)); ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size)); ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, const char *version, int stream_size)); #define deflateInit(strm, level) \ deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) #define inflateInit(strm) \ inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ (strategy), ZLIB_VERSION, sizeof(z_stream)) #define inflateInit2(strm, windowBits) \ inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) #if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL) struct internal_state {int dummy;}; /* hack for buggy compilers */ #endif ZEXTERN const char * ZEXPORT zError OF((int err)); ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); #ifdef __cplusplus } #endif #endif /* _ZLIB_H */