sks-ecc-0.93/0000755000175000017500000000000010722042424011734 5ustar nachonachosks-ecc-0.93/LEEME.txt0000644000175000017500000001366510715702751013347 0ustar nachonacho S K S - C R I P T O G R A F Í A D E B O L S I L L O Consulta 'index.html', dentro de la carpeta 'doc', para acceder al manual completo. La última versión la puedes encontrar en: http://sks.merseine.nu Introducción ============ SKS es una herramienta de cifrado/autentificación de clave pública mediante línea de comandos, basada en la llamada criptografía de Grupo de Curva Elíptica (CGCE). Su diseño minimalista está orientado a la criptografía de bolsillo, esto es, una herramienta muy sencilla de usar, transportar (el ejecutable ocupa aprox. 100 Kb), multiplataforma (Linux-Unix y diversos Windows, por el momento), extremadamente rápida, libre de patentes y distribuída bajo licencia GPL. Todo ello sin comprometer un ápice la seguridad y ofreciendo por tanto una calidad de cifrado apta para los más exigentes. Sus elementos criptográficos son: * Módulo de clave pública: curva elíptica sobre GF (2^191) * Módulo de clave simétrica: AES con clave de 192 bits en modo CTR * Función resumen, para firmas y contraseñas: TIGER (192 bits) * Módulo pseudoaleatorio: /dev/urandom en Linux-Unix y CryptGenRandom en Windows Está basada -tanto en filosofía como en parte del código- en una aplicación llamada "pegwit", que nació a finales de los 90 como contrapartida a un cada vez más super-sofisticado PGP, lleno de funcionalidades superfluas y con un tamaño cada vez más creciente y aparatoso que hacía difícil la evaluación del código subyacente. Incluso con el desarrollo y popularización de GPG, una herramienta como SKS tiene su razón de ser: la CGCE proporciona claves y firmas más compactas que RSA o DH, para un mismo nivel de seguridad (la curva de SKS es igual de fuerte que una clave RSA de 1024 bits) y además es mucho más rápida. Además, GPG sigue siendo un programa muy sofisticado y pesado. SKS cabe en un diskete, no necesita instalación previa, no conserva claves privadas y su uso es inmediato. Instalación =========== SKS es una herramienta por línea de comandos que no precisa instalación. Las instrucciones de puesta en marcha que siguen son válidas para CPUs x86 en entornos Linux-Unix y Windows 2000, XP, NT. Para Windows 98/ME/95 hay unos consejos complementarios. Para otras arquitecturas conviene compilar las fuentes. Descomprime el correspondiente fichero (.zip para Windows o .bz2 para Linux-Unix); copia el ejecutable en cualquier directorio al que apunte la variable PATH (bajo Linux-Unix, es posible que tengas que dar este paso como administrador). Si no lo has hecho ya, tienes que abrir una consola de comandos (terminal) que bajo Windows suele estar en un icono llamado "Símbolo del sistema" o similar. Una vez allí cambia al directorio raíz de la instalación y teclea: sks -ki skspkr lo cual cargará las claves contenidas en el fichero 'skspkr' en tu anillo de claves. Este fichero contiene mi clave pública y tres claves públicas de prueba (sus contraseñas son visibles en las etiquetas identificadoras, enmarcadas por barras /contraseña/). Ahora puedes comprobar que el ejecutable proviene realmente del autor, mediante: sks -v sks sks.sig *** Linux-Unix *** sks -v sks.exe sks.sig *** Windows *** que emitirá el mensaje: [00e14ca8]: Manuel Pancorbo Castro SKS. Firma correcta realizada en: 2004-05-10, 13:34 la fecha puede variar, dependiendo del momento justo de generar la firma. A continuación puedes generar tu propia clave pública: sks -kg > miclave donde 'miclave' es el nombre de fichero que va a contener tu clave pública para su distribución. El programa te pedirá una descripción identificativa de la clave y, a continuación, la contraseña. La clave pública se queda instalada por defecto en tu anillo de claves. Para los usuarios de Windows 98/ME/95/3.1 y DOS ----------------------------------------------- Antes de arrancar el programa, tienes que definir la variable de entorno APPDATA: set APPDATA= donde es cualquier directorio del disco, que ya exista previamente, a tu elección y SIN la barra invertida final [ \ ]; por ejemplo: set APPDATA=C:\Cripto set APPDATA="C:\Mis Documentos" Dentro de éste se creará un subdirectorio \SKS donde se guardará el anillo de claves. Es conveniente que automatices el proceso, incluyendo la orden anterior en el fichero C:\AUTOEXEC.BAT o bien escribiendo un guión de comandos (.bat) que defina la variable y lance la aplicación. Bajo versiones antiguas de Windows, es posible que el programa vaya lento al calcular números aleatorios. Esto es porque la función CryptGenRandom no está disponible en estas versiones del sistema operativo y el programa elige un método alternativo, que cumple la norma ANSI, que es más lento. Compilar las fuentes ==================== Como todo programa de libre distribución, se adjuntan las fuentes, en lenguaje ANSI C. El compilador usado ha sido gcc; en Windows existe un conjunto de utilidades GNU llamado MinGW que incluye este compilador. Otros compiladores pueden necesitar la revisión del fichero Makefile que se adjunta. Procedimiento: make *** Linux-Unix *** make -f Makefile.w32 *** Windows *** Para instalarlo en el sistema (hay que tener privilegios de administrador): make install *** Linux-Unix *** make -f Makefile.w32 install *** Windows *** Se recomienda editar previamente el fichero Makefile (o Makefile.w32) y adaptarlo a las necesidades propias: directorio de instalación, idioma, uso de determinadas librerías, etc. Todas las variables que permiten personalizar la compilación se encuentran al principio del fichero. Licencia ======== SKS se distribuye bajo licencia GPL. Consulta 'gpl.txt' o 'gpl.html' en el directorio 'doc'. --------------------------------------------------------------------- Copyright (C) 2004-2005 Manuel Pancorbo Castro sks-ecc-0.93/Makefile0000755000175000017500000001144710715702751013416 0ustar nachonacho# Makefile for sks (linux) # gcc CFLAGS = -DLINUX VER=0.93 ES=0 EN=1 CC=gcc #CC=gcc-3.4 # ******************************* # ***** START build configuration area # ***** You may comment/uncomment definitions and flags # ***** Some defs/flags have mandatory alternative, some not # ****************************** CFLAGS += -s CFLAGS += -DVERSION='"$(VER)"' INST = /usr/local/bin #INST = $(HOME)/bin # ******* If you don't have 'libtommath' installed LTM = tfm # ******* If you don't have 'libtomcrypt' installed LTC = ltc # ******** If you don't have 'zlib' installed #GZ = zlib # specify architecture here #ARCH=i386 #ARCH=pentium4 ARCH=k8 CFLAGS += -march=$(ARCH) # specify language ES, EN or input as command-line option i.e.: 'make SLANG=0' SLANG=$(ES) CFLAGS += -DSKS_LANG=$(SLANG) # uses /dev/random or WinNT crypt-random CFLAGS += -DDEVRANDOM #warnings CFLAGS += -Wall #-Wsign-compare -W -Wno-unused -Wshadow -Werror # optimize for SPEED(don't include SIZE options) CFLAGS += -O3 -funroll-loops CFLAGS += -fomit-frame-pointer CFLAGS += -DFULLTABLES # optimize for SIZE (don't include SPEED options) #CFLAGS += -Os -DSMALL_CODE # ******************************* # ***** END build configuration area # ****************************** ifeq ($(SLANG),$(ES)) LANG=ES README=LEEME.txt else LANG=EN README=README.txt endif default: sks lang_test: echo $(SLANG); # ******** If you don't have 'zlib' installed ifdef GZ gz: $(GZ)/libz.a $(GZ)/libz.a: cd $(GZ); ./configure; make libz.a; ZLIB = $(GZ)/libz.a CFLAGS += -I$(GZ) else # ******** If you DO have 'zlib' installed: ZLIB = -lz endif # ******* If you don't have 'libtommath' installed ifdef LTM LTMLIB=$(LTM)/mpi.o CFLAGS += -I$(LTM) else # ******* If you DO have 'libtommath' installed: LTMLIB = -ltommath endif # ******* If you don't have 'libtocrypt' installed ifdef LTC LTCLIB=$(LTC)/aes.o $(LTC)/tiger.o CFLAGS += -I$(LTC) else # ******* If you DO have 'libtomcrypt' installed: LTCLIB = -ltomcrypt endif ECC_OBJS= gflib.o eclib.o eccrypt.o gflib.o: gflib.c gflib.h eclib.o: eclib.c eclib.h gflib.h eccrypt.o: eccrypt.c eccrypt.h eclib.h gflib.h util.o: util.c sks.h UTIL_OBJS=binasc.o util.o entropy.o hash.o symcrypt.o KEY_OBJS=keyring.o # *** Build the 'kernel' LIBS = $(UTIL_OBJS) $(ECC_OBJS) $(KEY_OBJS) $(LTMLIB) $(LTCLIB) $(ZLIB) sks.o: sks.c sks_msg_en.h sks_msg_es.h sks.h DEPLIST = $(UTIL_OBJS) $(KEY_OBJS) $(ECC_OBJS) sks.o ifdef LTM DEPLIST += $(LTMLIB) endif ifdef LTC DEPLIST += $(LTCLIB) endif ifdef GZ DEPLIST += gz endif sks: $(DEPLIST) $(CC) -o $@ $@.o $(LIBS) # *** Clean PIGS = *.o sks sks.sig skstest ifdef LTM PIGS += $(LTM)/mpi.o endif ifdef LTC PIGS += $(LTC)/aes.o $(LTC)/tiger.o endif ifdef GZ PIGS += $(GZ)/*.o $(GZ)/*.a endif clean: limpia limpia: rm -f $(PIGS) # Tests skstest.o: skstest.c skstest: skstest.o $(ECC_OBJS) $(UTIL_OBJS) $(KEY_OBJS) $(CC) $@.o $(UTIL_OBJS) $(ECC_OBJS) $(KEY_OBJS) $(LTCLIB) $(LTMLIB) $(ZLIB) -o $@ SNAME=sks-source-$(VER) source: #clean cd ..; rm -rf sks-$(VER); mkdir sks-$(VER); \ cp -R ./sks/*.c ./sks-$(VER)/; cp -R ./sks/*.h ./sks-$(VER)/; \ cp -R ./sks/skspkr ./sks-$(VER)/; \ cp -R ./sks/sks.1 ./sks-$(VER)/; \ cp -R ./sks/Makefile ./sks-$(VER)/; \ cp -R ./sks/Makefile.w32 ./sks-$(VER)/; \ cp -R ./sks/*.txt ./sks-$(VER); cp -R ./sks/doc ./sks-$(VER)/; \ rm -f ./sks/tfm/mpi.o; cp -R ./sks/tfm ./sks-$(VER)/; \ rm -f ./sks/ltc/*.o; cp -R ./sks/ltc ./sks-$(VER)/; \ rm -f ./sks/zlib/*.o ./sks/zlib/*.a; cp -R ./sks/zlib ./sks-$(VER)/; \ tar -c -h sks-$(VER)/* | bzip2 -9vvc > $(SNAME).tar.bz2; \ echo "md5 sum:" > $(SNAME).sum; \ md5sum $(SNAME).tar.bz2 >> $(SNAME).sum; \ echo "tiger sum:" >> $(SNAME).sum; \ sks -r $(SNAME).tar.bz2 >> $(SNAME).sum; \ zip -9 -r $(SNAME).zip sks-$(VER)/*; \ echo "md5 sum:" >> $(SNAME).sum; \ md5sum $(SNAME).zip >> $(SNAME).sum; \ echo "tiger sum:" >> $(SNAME).sum; \ sks -r $(SNAME).zip >> $(SNAME).sum; BNAME=sks-i386bin-$(LANG)-$(VER) binary: clean sks ifneq ($(ARCH),i386) @echo "Defined architecture is not portable. Define 'ARCH=i386'" else ./sks -s sks sks.sig ./sks -v sks sks.sig tar -c *.sig $(README) ./sks skspkr ./doc/* | bzip2 -9vvc > ../$(BNAME).tar.bz2 cd ..; \ echo "md5 sum:" > $(BNAME).sum; \ md5sum $(BNAME).tar.bz2 >> $(BNAME).sum; \ echo "tiger sum:" >> $(BNAME).sum; \ sks -r $(BNAME).tar.bz2 >> $(BNAME).sum; # zip -9 -r ../sks-i386bin-$(VER).zip *.s *.txt ./sks skspkr ./doc/* #Falta 'readme' endif WNAME=sks-w32-$(LANG)-$(VER) w32: # Makes the md5- and tiger-sums cp sks-$(LANG).exe sks.exe sks -s sks.exe sks.sig sks -v sks.exe sks.sig zip -9 -r ../$(WNAME).zip *.sig sks.exe skspkr *.txt ./doc/* echo "md5 sum:" > ../$(WNAME).sum md5sum ../$(WNAME).zip >> ../$(WNAME).sum echo "tiger sum:" >> ../$(WNAME).sum sks -r ../$(WNAME).zip >> ../$(WNAME).sum rm -f sks.exe install: sks cp sks $(INST) sks-ecc-0.93/Makefile.w320000755000175000017500000000577710715702751014041 0ustar nachonacho# Makefile for sks (win32) # gcc (Mingw32) CFLAGS = -DWIN32 WIN=1 VER =0.93 ES=0 EN=1 CC=gcc MAKE=mingw32-make # ******************************* # ***** START build configuration area # ***** You may comment/uncomment definitions and flags # ***** Some defs/flags have mandatory alternative, some not # ****************************** INST=C:\WINDOWS # ******* If you don't have 'libtommath' installed LTM = tfm # ******* If you don't have 'libtomcrypt' installed LTC = ltc # ******** If you don't have 'zlib' installed GZ = zlib # specify architecture here ARCH =i386 #ARCH=pentium4 # specify language ES, EN or input as command-line option i.e.: 'make SLANG=0' #SLANG=$(ES) CFLAGS += -s -march=$(ARCH) -DVERSION='"$(VER)"' -DSKS_LANG=$(SLANG) # uses /dev/random or WinNT crypt-random CFLAGS += -DDEVRANDOM #warnings CFLAGS += -Wall #-Wsign-compare -W -Wno-unused -Wshadow -Werror # optimize for SPEED (don't include SIZE options) #CFLAGS += -O3 -funroll-loops # add -fomit-frame-pointer. v3.2 is buggy for certain platforms! #CFLAGS += -fomit-frame-pointer -DFULLTABLES # optimize for SIZE (don't include SPEED options) CFLAGS += -Os -DSMALL_CODE # ******************************* # ***** END build configuration area # ****************************** # ******** If you don't have 'zlib' installed ifdef GZ default: gz sks gz: $(GZ)/libz.a $(GZ)/libz.a: $(MAKE) -C $(GZ) -f win32/Makefile.gcc libz.a ZLIB = $(GZ)/libz.a CFLAGS += -I$(GZ) else # ******** If you DO have 'zlib' installed default: sks ZLIB = -lz endif # ******* If you don't have 'libtommath' installed ifdef LTM LTMLIB = $(LTM)/mpi.o CFLAGS += -I$(LTM) else # ******* If you DO have 'libtommath' installed LTMLIB = -ltommath endif # ******* If you don't have 'libtocrypt' installed ifdef LTC LTCLIB=$(LTC)/aes.o $(LTC)/tiger.o CFLAGS += -I$(LTC) else # ******* If you DO have 'libtomcrypt' installed: LTCLIB = -ltomcrypt endif ECC_OBJS= gflib.o eclib.o eccrypt.o gflib.o: gflib.c gflib.h eclib.o: eclib.c eclib.h gflib.h eccrypt.o: eccrypt.c eccrypt.h eclib.h gflib.h util.o: util.c sks.h UTIL_OBJS=binasc.o util.o entropy.o hash.o symcrypt.o KEY_OBJS=keyring.o # *** Build the 'kernel' LIBS = $(UTIL_OBJS) $(ECC_OBJS) $(KEY_OBJS) $(LTMLIB) $(LTCLIB) $(ZLIB) sks.o: sks.c sks_msg_en.h sks_msg_es.h sks.h DEPLIST = $(UTIL_OBJS) $(KEY_OBJS) $(ECC_OBJS) sks.o ifdef LTM DEPLIST += $(LTMLIB) endif ifdef LTC DEPLIST += $(LTCLIB) endif ifdef GZ DEPLIST += gz endif lang_test: echo $(SLANG); sks: $(DEPLIST) $(CC) -o $@ $@.o $(LIBS) # *** Clean PIGS = *.o sks.exe sks.sig ifdef LTM PIGS += $(LTM)\mpi.o endif ifdef LTC PIGS += $(LTC)\aes.o $(LTC)\tiger.o endif ifdef GZ PIGS += $(GZ)\*.o $(GZ)\*.a endif clean: limpia limpia: del $(PIGS) # Tests skstest: skstest.o $(ECC_OBJS) $(UTIL_OBJS) $(KEY_OBJS) $(CC) $@.o $(UTIL_OBJS) $(ECC_OBJS) $(KEY_OBJS) $(LTCLIB) $(LTMLIB) $(ZLIB) -o $@ #skstest: skstest.o $(LTC_OBJS) $(ECC_OBJS) $(UTIL_OBJS) # $(CC) $@.o -I. $(LTC_OBJS) $(ECC_OBJS) $(UTIL_OBJS) $(LTMLIB) $(ZLIB) -o $@ install: sks copy sks.exe $(INST) sks-ecc-0.93/README.txt0000644000175000017500000000734510715702751013453 0ustar nachonacho S K S - P O C K E T C R Y P T O G R A F Y Web page: http://sks.merseine.nu Introduction ============ SKS is a public-key, command-line application for encryption/authentication, based on Elliptic Curve Cryptografy (ECC). Its minimalist design points to simple, light, fast, easy-to-use and multiplatform product, unencumbered by patents that is indeed distributed under GPL. All these features are given along with high quality cryptografy. Its cryptografic elements are: * Public-key module: elliptic curve over GF (2^191) * Simmetric-key module: AES 192-bits key, with CTR mode * Hash (for signatures, HMAC and passwords): TIGER (192 bits) * PRNG module: /dev/urandom in Linux-Unix and CryptGenRandom in Windows SKS can be ported/played on a diskette, doesn't need previous instalation and can be used inmediatly. Instalation =========== SKS is a command-line application without complex instalation. The following instructions are valid for x86-family CPU-based computers within *NIX or Windows (2000, XP, NT) operating systems. It is valid also in older Windows 98/ME/95 but some previous work must be done. Unzip the '.zip' or '.bz2' file in any temporal folder; copy executable on any folder pointed by 'PATH' enviroment variable. Go to temporal folder and do: sks -ki skspkr This will load the public keys contained on given file 'skspkr'. One of the keys is my personal key [00e14ca8]. Now you can test if binary comes from me: sks -v sks sks.sig *** Linux-Unix *** sks -v sks.exe sks.sig *** Windows *** which should say: [00e14ca8]: Manuel Pancorbo Castro SKS OK. signature made at: 2004-05-10, 13:34 (the date may change). Now you can create your own public key: sks -kg > mykey where 'mykey' is your public-key file, that can be distributed. The program asks for textual brief description of the key and then asks for your password. Public key is stored onto your keyring. For Windows 98/ME/95/3.1 and DOS users -------------------------------------- Before launching the program you *must* define the enviroment variable APPDATA: set APPDATA= where is any existing folder on the disk with write access for you. Do not put ending backslash [ \ ]; for example: set APPDATA=C:\Crypto set APPDATA="C:\My Documents" It is highly recommended to put this definition in AUTOEXEC.BAT file. Compilation =========== Source code has been compiled without problems with 'gcc' and 'gcc-mingw' under Windows. Other compilers may requiere 'makefile' revision. Simply do: make *** Linux-Unix *** make -f Makefile.w32 *** Windows *** If you want to install (first get superuser privileges): make install *** Linux-Unix *** make -f Makefile.w32 install *** Windows *** I recommend to edit the 'Makefile' (or Makefile.w32) in order to customize the compilation to your needs. All custom variables are at the beginning of the file. License ======= SKS is distributed under GPL. Please read 'gpl.txt' in 'doc' folder. Anyway, the author warns that unwise manipulation of code may yield a program which resulting ciphertexts and signatures will not be recognized by ortodox buildings. Manual ====== The full manual is given under 'doc'-folder in html files, but only in Spanish language. I apologize. A brief manual is obtained by typing 'sks' without parameters (or 'sks -k' or 'sks -f'). Moreover, the source code and makefiles are commented in English. --------------------------------------------------------------------- Copyright (C) 2004-2006 Manuel Pancorbo Castro sks-ecc-0.93/binasc.c0000755000175000017500000001777010604550752013365 0ustar nachonacho/* binasc.c ** ** BAS64 armour by Mr. Tines */ #include #include #include #include #include "binasc.h" #define LINE_LEN 60L /* binary bytes per armour line */ #define MAX_LINE_SIZE 82 /* expands to this plus \n\0 over*/ /* Working line size must be <= MAX_LINE_SIZE - 2 and must be 0 mod 4 Added: Manuel Pancorbo */ #define LINE_SIZE 64 static char err_decode_failed[] = "Out of range characters encountered in ASCII armouring.\n" "Terminating.\n"; /* Index this array by a 6 bit value to get the character corresponding * to that value. */ static unsigned char bintoasc[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /* Index this array by a 7 bit value to get the 6-bit binary field * corresponding to that value. Any illegal characters return high bit set. */ static unsigned char asctobin[] = { 0200,0200,0200,0200,0200,0200,0200,0200, 0200,0200,0200,0200,0200,0200,0200,0200, 0200,0200,0200,0200,0200,0200,0200,0200, 0200,0200,0200,0200,0200,0200,0200,0200, 0200,0200,0200,0200,0200,0200,0200,0200, 0200,0200,0200,0076,0200,0200,0200,0077, 0064,0065,0066,0067,0070,0071,0072,0073, 0074,0075,0200,0200,0200,0200,0200,0200, 0200,0000,0001,0002,0003,0004,0005,0006, 0007,0010,0011,0012,0013,0014,0015,0016, 0017,0020,0021,0022,0023,0024,0025,0026, 0027,0030,0031,0200,0200,0200,0200,0200, 0200,0032,0033,0034,0035,0036,0037,0040, 0041,0042,0043,0044,0045,0046,0047,0050, 0051,0052,0053,0054,0055,0056,0057,0060, 0061,0062,0063,0200,0200,0200,0200,0200 }; #define PAD '=' /* the armoured value corresponding to no bits set */ #define ZERO 'A' static char asciiBuffer[MAX_LINE_SIZE]; static char *writeHead=asciiBuffer; static int space = LINE_SIZE; static unsigned char bin[3]; static int inBin = 0; static int flushBuffer(FILE * stream) { if(asciiBuffer == writeHead )return 1; writeHead[0] = '\n'; writeHead[1] = '\0'; writeHead=asciiBuffer; space = LINE_SIZE; return fputs(asciiBuffer, stream) >= 0; } /* output one group of up to 3 bytes, pointed at by p, on file f. */ static void encode(unsigned char p[3], char buffer[4], int count) { if(count < 3) { p[count] = 0; /* some bits from this byte may be used */ buffer[2] = buffer[3] = PAD; } buffer[0] = bintoasc[p[0] >> 2]; buffer[1] = bintoasc[((p[0] << 4) & 0x30) | ((p[1] >> 4) & 0x0F)]; if(count > 1) { buffer[2] = bintoasc[((p[1] << 2) & 0x3C) | ((p[2] >> 6) & 0x03)]; if(count > 2) buffer[3] = bintoasc[p[2] & 0x3F]; } } static int push3bytes(FILE *stream) { /* is there space left on the buffer ?*/ if(space < 4) { int push = flushBuffer(stream); if(!push) return 0; } encode(bin, writeHead, inBin); inBin = 0; writeHead+=4; space -= 4; return 1; } /* flush any left-overs */ int flushArmour(FILE * stream) { int result = 1; if(inBin) result = push3bytes(stream); if(result) result = flushBuffer(stream); return result; } size_t fwritePlus(const void *ptr, size_t size, size_t n, FILE *stream, int binmode) { size_t result = 0; int bytesOver = 0; unsigned char *out = (unsigned char *)ptr; /* fprintf(stderr, "fwrite Plus writing %d bytes\n", n*size); { int i; for(i=0; i<4; ++i) { fprintf(stderr,"%x %x %x %x\n", out[0], out[1], out[2], out[3]); out+=4; } out = (unsigned char*)ptr; } */ /*if(stdout != stream) return fwrite(ptr, size, n, stream);*/ if(binmode) return fwrite(ptr, size, n, stream); while(result < n) { bin[inBin] = *out; ++inBin; ++out; ++bytesOver; if(3 == inBin) { if(!push3bytes(stream)) return result; inBin=0; } if(bytesOver==size) { ++result; bytesOver = 0; } } return n; } int fputcPlus(int c, FILE *stream, int binmode) { /*if(stdout != stream) return fputc(c, stream); */ if(binmode) return fputc(c, stream); bin[inBin] = (unsigned char)(c & 0xFF); ++inBin; if(3 == inBin) { if(!push3bytes(stream)) return EOF; inBin=0; } return c; } /*-------------- Input ASCII Armoured Cyphertext ------------------------*/ static int decodeBuffer(char *inbuf, unsigned char *outbuf, int *outlength) { unsigned char *bp; int length; unsigned int c1,c2,c3,c4; int hit_padding = 0; length = 0; bp = (unsigned char *)inbuf; /*fprintf(stderr, "decodeBuffer >%s<\n", inbuf);*/ /* FOUR input characters go into each THREE output charcters */ while(*bp != '\0' && !hit_padding) { /* check for padding */ if(bp[3] == PAD) { hit_padding = 1; /* allow for quoted printable = -> =3D */ if(bp[2] == PAD || !strcmp((char*)bp + 2, "=3D=3D")) { length += 1; bp[2] = ZERO; } else length += 2; bp[3] = ZERO; } else length += 3; /* unpadded */ if(bp[0] & 0x80 || (c1 = asctobin[bp[0]]) & 0x80 || bp[1] & 0x80 || (c2 = asctobin[bp[1]]) & 0x80 || bp[2] & 0x80 || (c3 = asctobin[bp[2]]) & 0x80 || bp[3] & 0x80 || (c4 = asctobin[bp[3]]) & 0x80) { fprintf(stderr, err_decode_failed); fprintf(stderr, inbuf); exit(1); } bp += 4; *outbuf++ = (unsigned char)((c1 << 2) | (c2 >> 4)); *outbuf++ = (unsigned char)((c2 << 4) | (c3 >> 2)); *outbuf++ = (unsigned char)((c3 << 6) | c4); } *outlength = length; return !hit_padding; } static unsigned char binaryBuffer[LINE_LEN]; static unsigned char *readHead = binaryBuffer; static int bytesLeft = 0; static int more = 1; /* Acts like fread if the stream is a file; from stdin, however ** it expects that the data have been Base64 encoded, so we */ size_t freadPlus(void *ptr, size_t size, size_t n, FILE *stream, int binmode) { size_t result = 0; int bytesOver = 0; unsigned char *out = ptr; char inBuf[MAX_LINE_SIZE]; /*if(stdin != stream) return fread(ptr, size, n, stream);*/ if(binmode) return fread(ptr, size, n, stream); while(result < n) { /* start by satisying bytes from the buffer */ if(bytesLeft >= size-bytesOver) { memcpy(out, readHead, size-bytesOver); bytesLeft -= (size-bytesOver); readHead += (size-bytesOver); out += (size-bytesOver); ++result; /* a chunk satsified, so increment count */ bytesOver = 0; /* and none left over */ } else { memcpy(out, readHead, bytesLeft); bytesOver += bytesLeft; out += bytesLeft; bytesLeft = 0; } if(result == n) break; /* on buffer exhaustion */ if(0==bytesLeft) { int l; /*fprintf(stderr, "result: %d\n", result);*/ memset(binaryBuffer, 0, (size_t) LINE_LEN); if(!more) break; /* hit the termination */ if(feof(stream)) break; /* end stop */ inBuf[0] = 0; /* Added by George Barwood, 22/4/97 */ fgets(inBuf, MAX_LINE_SIZE, stream); /* 64+\n\0 */ if('#' == inBuf[0]) break; l = strlen(inBuf); while(inBuf[l-1] < ' ' && l>0){--l; inBuf[l] = '\0';} more = decodeBuffer(inBuf, binaryBuffer, &bytesLeft); /*fprintf(stderr, "bytes left: %d\n", bytesLeft);*/ memset(inBuf, 0, MAX_LINE_SIZE); readHead = binaryBuffer; } } /*if(inBuf[0] != '#') fgets(inBuf, MAX_LINE_SIZE, stream);*/ /* fprintf(stderr, "freadPlus returning %d bytes\n", result*size); { int i; out = ptr; for(i=0; i<4; ++i) { fprintf(stderr,"%x %x %x %x\n", out[0], out[1], out[2], out[3]); out+=4; } } */ return result; } void burnBinasc(void) { memset( asciiBuffer, 0, sizeof(asciiBuffer) ); memset( bin, 0, sizeof(bin) ); inBin = 0; space = LINE_SIZE; writeHead=asciiBuffer; memset( binaryBuffer, 0, sizeof(binaryBuffer)); readHead = binaryBuffer; bytesLeft = 0; more = 1; } sks-ecc-0.93/binasc.h0000755000175000017500000000041510604550752013356 0ustar nachonachoint flushArmour(FILE * stream); size_t freadPlus(void *ptr, size_t size, size_t n, FILE *stream, int binmode); size_t fwritePlus(const void *ptr, size_t size, size_t n, FILE *stream, int binmode); int fputcPlus(int c, FILE *stream, int binmode); void burnBinasc(void); sks-ecc-0.93/doc/0000755000175000017500000000000010715702751012511 5ustar nachonachosks-ecc-0.93/doc/ecc-faq.html0000644000175000017500000005165310715702751014710 0ustar nachonacho### Elliptic curve cryptography FAQ v1.12 22nd December 1997

Elliptic curve cryptography FAQ v1.12 22nd December 1997

(1) What is an elliptic curve?

Well for a start, it is not the same as an ellipse!

But to be more positive: from school mathematics, you probably know the equation for a circle centred on the (a,b) of radius r, which is

(x-a)^2 + (y-b)^2 = r^2

where x, y, a, b and r are real numbers.

An elliptic curve is also defined by an equation, but it has the slightly more complicated form:

y^2 [ + x·y ] = x^3 + a·x^2 + b

Notation: · means multiplication, and ^ means raising to a power, so that y^2 means y·y and x^3 means x·x·x. The square brackets mean that the term is optional - sometimes it is there, sometimes it isn't!

Again x and y are variables, a and b are constants.

However, these quantities are not necessarily real numbers, instead they may be values from any field. For cryptographic purposes we always use a "finite" field - that is x, y, a and b are chosen from a finite set of distinct values.

[In fact the equation given here is not the most general possible, but it will serve for the purposes of this FAQ, and as far as I know for all cryptographic purposes.]

(2) What is a field?

The familiar examples of fields are real numbers, complex numbers, rational numbers (fractions) and integers modulo a prime number. The latter is an example of a "finite field". The requirements of a field are normal addition and multiplication, plus the existence of both additive and multiplicative inverses (except that 0 doesn't have a multiplicative inverse). To put it another way, a field has addition, subtraction, multiplication and division - and these operations always produce a result that is in the field, with the exception of division by zero, which is undefined.

Recall that complex numbers can be defined as b·i + a with the "reduction rule" i^2 + 1 => 0. To multiply complex numbers we treat i as an "unknown", collect up powers of i, and apply the reduction rule to simplify the result.

It turns out that this construction works for other "reduction rules" involving higher powers of i.

To avoid confusion, in what follows, t is used instead of i.

The coefficients of the powers of t can be from any field - but if we take the field to be the integers modulo p, we get a finite field with p^m elements, where m is the degree of the "reduction rule" - that is the exponent of the highest power of t.

For example, if we set p=2, m=4, and use the "reduction rule" t^4 + t + 1 => 0, we get a field with 2^4=16 distinct elements: 0, 1, t, t+1, t^2, t^2+1, t^2+t, t^2+t+1, t^3, t^3+1, t^3+t, t^3+t+1, t^3+t^2, t^3+t^2+1, t^3+t^2+t, t^3+t^2+t+1.

Not all "reduction rules" work, we need to use an "irreducible" polynomial - see (14). Note that when multiplying elements of the field there are actually two reduction rules working simultaneously - the rule for reducing coefficients modulo p, and the rule for reducing high powers of t.

This construction works for all p and m, as long as p is prime; in fact every finite field can be constructed in this way; moreover two finite fields with the same number of elements are always isomorphic - that is there is a 1-1 map between them which preserves the addition and multiplication rules.

In the light of these facts, we refer to "the" Galois field with p^m elements, using the notation GF(p^m). (Evariste Galois was a French mathematician who died in a duel in 1832 when he was just 20 years old.)

The prime p is called the "characteristic" of the field - I won't use this term, but sometimes it helps to know the jargon.

(3) How are elliptic curves used?

The crucial property of an elliptic curve is that we can define a rule for "adding" two points which are on the curve, to obtain a 3rd point which is also on the curve. This addition rule satisfies the normal properties of addition. In math jargon, the points and the addition law form a finite Abelian group.

The equations for the addition rule are given in (7) and (8).

For addition to be well defined for any two points, we need to include an extra 'zero' point O, which does not satisfy the elliptic curve equation. This 'zero' point is taken to be a fully paid up point of the curve. The order of the curve is the number of distinct points on the curve, including the zero point.

Having defined addition of two points, we can also define multiplication k*P where k is a positive integer and P is a point as the sum of k copies of P.

Thus 2*P = P+P
3*P = P+P+P
etc.

This is analagous to how we define "powers" in normal arithmetic, where
x^2 = x.x
x^3 = x.x.x
etc.

Now we are in a position to do some cryptography!

Alice, Bob, Cathy, David... agree on a (non-secret) elliptic curve and a (non-secret) fixed curve point F. Alice chooses a secret random integer Ak which is her secret key, and publishes the curve point AP = Ak*F as her public key. Bob, Cathy and David do the same.

Now suppose Alice wishes to send a message to Bob. One method is for Alice to simply compute Ak*BP and use the result as the secret key for a conventional symmetric block cipher (say DES).

Bob can compute the same number by calculating Bk * AP, since Bk*AP = Bk*(Ak*F) = (Bk*Ak)*F = Ak*(Bk*F) = Ak*BP.

The security of the scheme is based on the assumption that it is difficult to compute k given F and k*F.

(4) How is the elliptic curve chosen?

First of all, a finite field is chosen, see (9)

If the field is GF(p) where p is a large prime, the x·y term is omitted, leaving us with
y^2 = x^3 + a·x^2 + b
There is a requirement that 4·a^3 + 27·b^2 is non-zero.

If the field is GF(2^m) then we include the x·y term to get
y^2 + x·y = x^3 + a·x^2 + b
There is a requirement that b is non-zero.

Fields GF(p^m) with both p>2 and m>1 are not considered here.

(5) How is the fixed point chosen?

If we carry on computing P+P+P... for long enough, since the number of curve points is finite, we must eventually get a result of O. [We will certainly have a*P = b*P for some a, b with b>a; This implies that c*P = O where c = b-a.] The least c for which this is true is called the order of the point, and a little group theory tells us that c must divide the order of the curve.

For good security, the curve and fixed point are chosen so that the order of the fixed point F is a large prime number. This is quite easy to do once we know the order of the curve, provided it has a large prime factor. However finding the order of an arbitrary curve is tricky - it involves what is known as Schoof's algorithm - and getting this algorithm to run in a reasonable time takes a lot of tricks.

There are two alternative methods which instead construct curves of known order, one based on Complex Multiplication (which is also pretty difficult maths - but not as tricky as Schoof!) and the other based on "Weil's theorem", which is much quicker to code: see (12).

For good security the order of the fixed point should also satisfy the "MOV" condition to prevent certain possible attacks - see (15).

Remark: if the finite field on which a curve is based has q elements, then the order of the curve must be also different from q. Curves with this order are called anomalous, and are susceptible to a recently discovered attack.

As far as is known, with the above provisions, if the order of the fixed point F is an n-bit prime, then computing k from k*F and F takes roughly 2^(n/2) operations.

For example, if the order of F is a 240-bit prime, then an attack would be expected to need 2^120 operations.

This is what makes the use of elliptic curves attractive - it means that public keys and signatures can be much smaller than with RSA for the same predicted security.

(6) What about digital signatures?

Using the Nyberg-Rueppel scheme is one possibility. The DSA scheme is another. Pretty much any cryptographic scheme/protocol based on discrete logarithms can be easily converted to elliptic curve form. In most cases it is necessary for the fixed point F to have known prime order.

The Nyberg-Rueppel scheme works like this:

Let x(P) denote the x-coordinate of the elliptic curve point P converted to an integer.

Alice chooses a random number k, and computes (mod order(F))
r = x(k*F)+data
s = k - Ak*r
where data is a hash of the data being signed. The signature is the pair (r,s).

To verify the signature, Bob checks that (mod order(F))
data == r - x(s*F + r*AP)

A little bit of algebra shows why this works.

[ Note that IEEE P1363 recommends Alice avoiding r=0, and for Bob to check that r and s are in the expected range, although I don't see any good reason for this. ]

(7) What is the addition rule when the field is GF(p)?

In this case the addition rule has the form
(x1,y1) + (x2,y2) => (x3,y3)
where x3 = L^2 - x1 - x2
and y3 = L·(x1-x3) - y1
and L = (y1-y2)/(x2-x1)

If x1=x2 and y1=y2 we must use instead,
x3 = L^2 - 2·x1
y3 = L·(x1-x3) - y1
L = ( 3·x1^2 + a ) / ( 2·y1 )

There are some other special cases which must be considered first: if x1=x2 and y1=-y2 then the result is zero, and if either point is zero, the result is the other operand.

By doing some algebra, you can check that the usual laws for addition apply, e.g. P+Q=Q+P and (P+Q)+R = P+(Q+R), and that the result of adding two points is indeed another curve point.

(8) What is the addition rule for when the field is GF(2^m)?

In this case the addition rule has the form
(x1,y1) + (x2,y2) = (x3,y3)
where
x3 = L^2 + L + x1 + x2 + a
y3 = L·(x1+x3) + x3 + y1
L = (y1+y2)/(x1+x2)

If x1=x2 and y1=y2 we must use instead
x3 = L^2 + L + a
y3 = x1^2 + (L+1)·x3
L = x1 + y1/x1

Again, there are some other special cases which must be considered first: if x1=x2 and y2=x1+y1 then the result is zero, and if either point is zero, the result is the other operand.

(9) How is the finite field chosen?

The finite field needs to be chosen so that the prime order of the fixed point is sufficiently large, say 150-300 bits.

In the case of GF(2^m) some fields have representations which are particularly efficient.

(10) What are field representations?

A field representation defines what bit-patterns are used to represent the various field elements. The representation (and the field) is chosen to make the field arithmetic operations efficient.

An analogy is using different representations for integers - for example base 10 or base 2.

Depending on the field, various tricks are possible, especially for the case GF(2^m).

There are two main possibilities: polynomial and normal basis. Polynomial basis is probably easier to understand.

With a polynomial basis, field elements are represented as polynomials. Usually a vector with m+1 components is used to represent a polynomial of degree m. When multiplying, the remainder is taken after dividing the result polynomial by an "irreducible" polynomial [see (14)]

If m has factors, the basis can be over a sub-field other than GF(2). This is analagous to performing multi-precision arithmetic on words instead of bits.

For small fields such as GF(2^9) field multiplication and division can be performed by simple table lookup, by taking 'logarithms'. It is always possible to find a field element, called a generator, such that the whole finite field is generated by the powers of the generator. In fact we can arrange that the single term polynomial t is a generator by using a "primitive" polynomial - this makes calculating the log tables marginally faster.

(11) How are field representations chosen?

For polynomial basis, one looks for trinomial reduction polynomials to improve the speed of modular reduction. A trinomial is a polynomial with just three terms, for example x^29 + x^2 + 1.

For normal basis, one looks for an 'optimal' normal basis such that field multiplication is efficient.

For hardware, a normal basis over GF(2) may be attractive. For software, a polynomial basis, or a sub-field representation seems to be better (more efficient).

In principle, one may convert between different field representations, so looking for a field in which several different efficient representations are possible might be a good idea. One possible candidate is GF(2^261) which can be represented with an optimal normal basis, and also as a polynomials with coefficients in GF(2^9) using the trinomial x^29 + x^2 + 1 as the reduction polynomial.

(12) What is Weil's theorem and how can it be used?

The order E of an elliptic curve y^2 + x·y = x^3 + a·x^2 + b over GF(2^(L*K)) can be calculated using the magic formula:

2^(L*K) + 1 - lucas( 2^L-(e-1), 2^L, K )

where e is the order of the curve over GF(2^L), and the function lucas(p,Z,K) = V(K), is defined by the recursion
V(0) = 2; V(1) = p; V(K) = p·V(K-1) - Z·V(K-2)

Note that GF(2^L) is a sub-field of GF(2^(L*K)) - a and b need to be elements of this sub-field for the theorem to apply.

Moreover, E is divisible by e - this useful fact is not always mentioned.

If L is fairly small, we can find e by "brute force", and quite often it turns out that E/e is a (large) prime - if it is, we can choose the fixed point F by choosing an arbitrary point R and setting F = e*R (if this is zero, try again). F then has order E/e.

Note that K needs to be prime, as otherwise there will be an intermediate sub-curve of larg(ish) order, and E/e will not be prime.

To apply the theorem, we need to identify a sub-field of GF(2^L*K) of order 2^L - depending on the field representation used this can be trivial, or some work may be needed.

(13) What is point compression?

If we know the x-coordinate of a point, we can find the y-coordinate by solving the curve equation. Since it is a quadratic equation, there will be two possible results (or none), so we need an extra bit to choose the correct solution. This technique can also be used to choose random points on the curve (a retry will be needed if the quadratic equation has no solution).

Point compression is nice because it reduces the size of public keys from say 510 bits to 256 bits. Solving quadratic equations over finite fields is a reasonably cheap operation.

(14) What is an irreducible polynomial?

Simply one that has no factors in the field under consideration. Note that the field matters - x^2 + 1 is irreducible over the real numbers, but has a perfectly good factorisation (x+i)(x-i) over the field of complex numbers. There is an efficient algorithm for testing for irreducibility over GF(2):

int poly_irreducible( const vlong & x )
{
  unsigned d = x.bits()-1;
  vlong u = 2;
  for (unsigned i=1;i<d;i+=1)
  {
    u = poly_rem( poly_mul(u,u), x );
    vlong g = poly_gcd( u^2, x );
    if ( g != 1 ) return 0;
  }
  return 1;
}

Here poly_mul, poly_rem denote polynomial multiplication and remainder, and poly_gcd finds the greatest common factor of two polynomials (essentially Euclids algorithm). Note that the function is using a mixture of normal 2's complement arithmetic and polynomial routines in a slightly obscure way; x.bits() is 1+log2(x), and ^ is the 'C' exclusive-or operation not exponentiation.

Since irreducible polynomials are quite common (a bit like prime numbers) it is quite easy to find them using this test.

To see why a reduction polynomial G must not have factors, suppose for a moment that it did. Then we would have a*b = G for non-zero a,b; and after reduction, a*b = 0. But multiplying through by the inverse of b would give a=0, which is a contradiction.

(15) What is the MOV condition?

Suppose that the field is GF(q) and the fixed point is F. We check that the first T terms of the sequence
q, q^2, q^3 .....
are not equal to 1 modulo the (prime) order of F. A suitable value for T is log2(q)/8.

MOV stands for Menezes, Okamoto and Vanstone - they wrote a paper "Reducing elliptic curve logarithms to logarithms in a finite field" IEEETIT,39(5):1639-1646,1993.

(16) Suggestions for further reading

A Course in Number Theory and Cryptography (2nd edition)
by Neal Koblitz
Springer-Verlag (New York) 1994
ISBN 0-387-94293-9

Elliptic curve public key cryptosystem
by A.J. Menezes
Kluwer Academic Publications 1993

IEEE P1363: (draft) Standard for Public-Key Cryptography

(17) What patents are there?

There are various patents concerning normal basis. US patents 4587627 Omura-Massey (OMNET), 739220 Onyszchuk/Mullin/Vanstone.

US Patent 5272755 Miyaji-Tatebayashi (Matsushita) relates to curves over GF(p).

Richard Crandall of Next computers has patents concerning GF(p), where p is of the form 2^q - C for small C. US Patents 5463690,5271051,5159632

US Patent 5146500 Maura (Omnisec) concerns "elliptic curves over rings" (sic). I haven't any idea what this means, but it seems to only use integer arithmetic modulo a prime.

To summarise - using GF(2^m) with a polynomial basis seems to avoid any patent problems.

In addition, there are various schemes, such as signature and key agreement protocols, which may be subject to patents.

4,200,770 Diffie-Hellman expires Sept. 6, 1997, and 4,218,582 Hellman-Merkle expires Oct. 6, 1997. Hellman-Merkle is also patented outside the US. In many countries the patent will expire later than in the US, but the relevance of this patent is dubious.

The DSA signature scheme is now unencumbered in the U.S. after the owners lost a suit by the U.S. government (or settled out of court). It was patented, but now there are no royalties or licenses needed.

The Nyberg-Rueppel signature scheme may be subject to European patent 0639907 (I haven't seen this)

For information on US patents, consult the impressive IBM patent server at http://patent.womplex.ibm.com/ibm.html

Disclaimer: I cannot guarantee the accuracy or completeness of the this information (as if this wasn't obvious!).

(18) What software implementations are available?

Wei Dai's Crypto++ library has elliptic curve routines, but has a restricted choice of curves (AFAIK). If you are not U.S. resident you may have some trouble obtaining Crypto++ (but persevere and you will probably find it somewhere!)

Pegwit is a complete program in 'C' with PGP-like functionality using elliptic curves, and is available from http://ds.dial.pipex.com/george.barwood/v8/pegwit.htm

Equivalent C++ elliptic curve code, and the code used to calculate the curve parameters is at http://ds.dial.pipex.com/george.barwood/crypto.htm


The latest version of this FAQ can be found at http://ds.dial.pipex.com/george.barwood/ec_faq.txt

or in html form at http://ds.dial.pipex.com/george.barwood/ec_faq.htm

A German translation by Ulf Möller is at http://www.fitug.de/ulf/faq/ec_faq.html

Acknowledgments: Special thanks to Ulf Möller for many improvements, and also to Paulo Barreto, Glynne Casteel, Wei Dai, Michael Greene, Kris Van Hees, Bodo Möller, Paul Onions, Mike Rosing, Roger Schlafly and Don Taylor.

Please send comments, corrections and suggestions to: george.barwood@dial.pipex.com

George Barwood

### end pegwit v8 signed text 0356ff6c0ed8ebcc432895c7bb74976ee6cbc37058e9cd74607edc13e51a ff5f2fd5f5970a6b4f420e05150be4c46ad9d3bfa9925e4a4dd92316f156 sks-ecc-0.93/doc/recon.html0000644000175000017500000001361110715702751014507 0ustar nachonacho SKS, criptografía de bolsillo

SKS

criptografía de bolsillo

Reconocimientos

SKS se debe en su mayor parte a trabajo previo de otras personas. En esta sección deseo reconocer principalmente el trabajo de programación, ya que el "trabajo intelectual" subyacente a todas las ideas que aquí se usan es tan extenso, que no bastarían estos pocos Kb. para ponerlo de manifiesto.

Todo el código que se usado tiene licencia GPL o bien garantía de libertad para su uso y está disponible en los enlaces que se proporcionan. Gracias a todos por su "involuntaria" colaboración en SKS.

Pegwit

Ya se ha mencionado que la inspiración de SKS proviene de pegwit, un programa realizado por George Barwood. He conservado la parte de codificación con armadura en base 64, que se debe a Mr. Tines. El propio Barwood escribió una pequeña guía sobre curvas elípticas que he incluído en esta documentación (inglés).

No hay actualmente páginas activas sobre pegwit porque, como se dice en la introducción, presentaba serias debilidades en la implementación de la CGCE. La única referencia es un grupo de discusión que pretende rescatarlo del olvido, pero no es muy activo:

Rijndael

Los autores de Rijndael son dos programadores flamencos, Joan Daemen y Vincent Rijmen.

El código fuente está tomado de LibTomCrypt, una librería criptográfica de Tom St. Denis. El código ha sido modificado levemente para construir las tablas de sustitución sobre la marcha; para ello me he valido de la implementación de Rijndael de Christophe Devine.

TIGER

TIGER es un algoritmo de generación de resuménes (hash) de Ross Anderson y Eli Biham. En las páginas señaladas se puede encontrar la implementación de referencia y otro material de interés.

También he usado el módulo tiger.c de la librería mencionada LibTomCrypt, que he modificado para construir la tabla de sustitución sobre la marcha, tomando como guía la implementación de referencia del algoritmo.

Curva elíptica

Para encontrar la curva apropiada y sus parámetros, me he servido del programa schoof2, de Mike Scott, así como de ppsearch, de Scott Duplichan.

Librería numérica de alta precisión

Para los cálculos con números grandes se ha empleado la librería externa LibTomMath, de Tom St Denis. También se usa esta librería en las operaciones polinómicas más sencillas.

Desde la versión 0.93, SKS utiliza la libería TomFastMath (tfm). Es una mejora del autor de la anterior librería que busca mayor rapidez (no hay 'mallocs', hay operaciones en ensamblador para determinadas arquitecturas...) pero, sobre todo, aprovecha toda la longitud del registro (32 o 64 bits) como cifras binarias efectivas.

Compresión

SKS usa la librería zlib de Jean-loup Gailly y Mark Adler.

sks-ecc-0.93/doc/gpl.html0000644000175000017500000006510410715702751014167 0ustar nachonacho SKS, criptografía de bolsillo

SKS

criptografía de bolsillo

SKS se ofrece bajo licencia GPL. Sin embargo, el autor advierte que los cambios de código pueden afectar la interoperabilidad de distintas versiones. Si esto ocurriera, se ruega encarecidamente cambiar el nombre del producto resultante para que terceros no se vean afectados.

LICENCIA PÚBLICA GENERAL GNU

Traducida por Antonio Luque Estepa <aluque@bart.us.es> en mayo de 1998.

Esta es una traducción de la Licencia General Pública GNU al español. Esta traducción se distribuye con la intención de facilitar su entendimiento, pero no es oficial ni está legalmente aprobada.

La Free Software Foundation [Fundación para el Software Libre] no es la editora de esta traducción y no la ha aprobado como un sustituto legal para la auténtica Licencia Pública General GNU. La traducción NO ha sido revisada atentamente por abogados, y por tanto el traductor no puede estar seguro de que represente exactamente el sentido legal de la Licencia Pública General GNU. Si usted quiere estar seguro de si sus actuaciones previstas están permitidas por la Licencia Pública General GNU, por favor acuda a la versión original inglesa.

La Free Software Foundation recomienda fervientemente no usar esta traducción como los términos oficiales de distribución para sus programas; en su lugar, por favor use la versión inglesa original, tal y como está publicada por la Free Software Foundation.


This is a translation of the GNU General Public License into Spanish. This translation is distributed in the hope that it will facilitate understanding, but it is not an official or legally approved translation.

The Free Software Foundation is not the publisher of this translation and has not approved it as a legal substitute for the authentic GNU General Public License. The translation has not been reviewed carefully by lawyers, and therefore the translator cannot be sure that it exactly represents the legal meaning of the GNU General Public License. If you wish to be sure whether your planned activities are permitted by the GNU General Public License, please refer to the authentic English version.

The Free Software Foundation strongly urges you not to use this translation as the official distribution terms for your programs; instead, please use the authentic English version published by the Free Software Foundation.

Versión 2. Junio 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Se permite a todo el mundo copiar y distribuir copias literales de este
documento de licencia, pero no está permitido modificarlo.

Preámbulo

Las licencias para la mayoría del software está diseñadas para retirarle su libertad de compartirlo e intercambiarlo. En cambio, la Licencia Pública General GNU está pensada para garantizar su libertad de compartir e intercambiar el software libre--para asegurar que el software es libre para todos los usuarios. Esta Licencia Pública General se aplica a la mayoría del software de la Free Software Foundation, así como a cualquier otro programa cuyos autores accedan a usarla. (Alguna parte del software de la Free Software Foundation se ve cubierto en su lugar por la Licencia Pública General para Librerías GNU). Usted también la puede aplicar a sus programas.

Cuando hablamos de software libre, nos estamos refiriendo a la libertad, no al precio. Nuestras Licencias Públicas Generales están diseñadas para asegurar que usted tiene la libertad de distribuir copias de software libre (y cobrar por ello si lo desea), que usted recibe el código fuente o puede obtenerlo si lo desea, que usted puede alterar el software o usar porciones de él en nuevos programas libres; y que usted sabe que puede hacer estas cosas.

Para proteger sus derechos, necesitamos plantear restricciones que impidan a cualquiera negarle esos derechos o pedirle que renuncie a ellos. Estas restricciones se traducen a ciertas responsabilidades para usted, si usted distribuye copias del software, o si lo modifica.

Por ejemplo, si usted distribuye copias de un programa determinado, ya sea gratis o a cambio de un precio, debe dar a los receptores todos los derechos que usted tiene. Debe asegurarse de que ellos también reciben o pueden obtener el código fuente. Y usted debe mostrar esos términos, de forma que ellos sepan cuáles son sus derechos.

Nosotros protegemos sus derechos mediante dos actos: (1) tener copyright sobre el software, y (2) ofrecerle a usted esta licencia, que le da permiso legal para copiar, distribuir y/o modificar el software.

Asímismo, para la protección de cada autor y la nuestra propia, queremos asegurarnos que cada persona comprende que no existe garantía para este software libre. Si el software es modificado por alguien y distribuido, queremos que los receptores sepan que lo que tienen no es el original, de forma que cualquier problema introducido por un tercero no afecte a la reputación del autor original.

Finalmente, cualquier programa libre está constantemente amenazado por las patentes de software. Deseamos evitar el riesgo de que un distribuidor de un programa libre pueda obtener patentes de software, haciendo el programa propietario a todos los efectos. Para prevenir esto, hemos establecido claramente que cualquier patente debe ser concedida para el libre uso de todo el mundo, o no ser concedida en absoluto.

Los términos precisos para la copia, distribución y modificación se exponen a continuación.

LICENCIA PÚBLICA GENERAL GNU
TÉRMINOS Y CONDICIONES PARA LA COPIA, DISTRIBUCIÓN Y MODIFICACIÓN

0. Esta Licencia se aplica a cualquier programa u otra obra que contenga un aviso colocado por el propietario del copyright diciendo que puede ser distribuido bajo los términos de esta Licencia Pública General. En adelante, el "Programa" se refiere a cualquier programa u obra de esta clase, y "una obra basada en el Programa" significa bien el Programa o bien cualquier obra derivada bajo las leyes del copyright: es decir, una obra que contenga el Programa o una porción del mismo, ya sea literalmente o con modificaciones y/o traducido a otro idioma. (De aquí en adelante, la traducción se incluye sin límites en el término "modificación".) Cada propietario de una licencia es tratado como "usted".

Otras actividades aparte de la copia, distribución o modificación no son cubiertas por esta Licencia; quedan fuera de su alcance. El acto de ejecutar el programa no se encuentra restringido, y la salida del programa queda cubierta sólo si sus contenidos constituyen una obra basada en el Programa (independiente de haber sido producidos por la ejecución del Programa). La exactitud de lo anterior depende del modo de actuar del programa.

1. Usted puede copiar y distribuir copias literales del código fuente del Programa tal y como lo recibió, por cualquier medio, supuesto que usted publica apropiada y visiblemente en cada copia un aviso de copyright y una renuncia de garantía; mantiene intactos los avisos que se refieren a esta Licencia y a la ausencia de cualquier garantía; y da a cualquier otro receptor del Programa una copia de esta Licencia junto con el Programa.

Usted puede cobrar por el acto físico de la trasferencia de una copia, y puede a su elección ofrecer protección mediante garantía a cambio de un precio.

2. Usted puede modificar su copia o copias del Programa o cualquier porción de él, constituyendo así una obra basada en el Programa, y copiar y distribuir tales modificaciones u obra bajo los términos de la sección 1 precedente, siempre que usted cumpla todas las condiciones siguientes:

  1. Debe procurar que los ficheros modificados incluyan notificaciones destacadas manifestando que usted cambió los ficheros y la fecha de cualquier cambio.
  2. Debe procurar que cualquier obra que distribuya o publique, que en todo o en parte contenga a o sea derivada del programa, sea licenciada como un todo sin coste alguno para terceras partes bajo los términos de esta licencia.
  3. Si el programa modificado normalmente lee comandos interactivamente al ejecutarse, usted debe procurar que cuando empiece a ejecutarse en este modo interactivo de la forma más común en su uso muestre un anuncio que incluya un aviso de copyright apropiado y un aviso de que no existe garantía (o bien diciendo que usted proporciona garantía) y que los usuarios pueden redistribuir el programa bajo estas condiciones, y que diga al usuario como ver una copia de esta Licencia. (Excepción: si el Programa es en sí mismo interactivo pero no muestra normalmente un aviso tal como el descrito, su obra basada en el programa no está obligada a mostrar ningún aviso).

Estos requisitos se aplican a la obra modificada como un todo. Si algunas secciones claramente identificables de esa obra no están derivadas del Programa, y pueden ser razonablemente consideradas como independientes y trabajos separados por sí mismas, entonces esta Licencia y sus términos no se aplican a esas secciones cuando usted las distribuya como obras separadas. Pero cuando usted distribuya las mismas secciones como parte de un todo que es una obra basada en el programa, la distribución de ese todo debe cumplir los términos de esta Licencia, cuyos permisos para otros licenciados se extienden para el todo completo, y por tanto a todas y cada una de las partes independientemente de quien las haya escrito.

Por tanto, no es la intención de esta sección reclamar derechos u oponerse a sus derechos sobre una obra escrita enteramente por usted; sino que la intención es ejercer el derecho de controlar la distribución de trabajos derivados o colectivos basados en el Programa.

Además, la mera agregación de otras obras no basadas en el programa al Programa (o a una obra basada en el Programa) en un medio de almacenaje o distribución no incluye a la otra obra bajo el alcance de esta Licencia.

3. Usted puede copiar y distribuir el Programa (o una obra basada en él , bajo la Sección 2) en forma de código objeto o ejecutable bajo los términos de las Secciones 1 y 2 precedentes mientras cumpla una de las siguientes condiciones:

  1. Acompañarlo con el código completo correspondiente en formato legible para un ordenador. Este código debe ser distribuido bajo los términos de las secciones 1 y 2 en un medio apropiado para el intercambio de software; o bien
  2. Acompañarlo con un ofrecimiento escrito, válido durante al menos tres años, de dar a cualquier tercera parte, por un precio no mayor que su coste de físicamente realizar la distribución de código, una copia completa, legible por ordenador del código fuente correspondiente, que será distribuido bajo los términos de las Secciones 1 y 2 en un medio apropiado para el intercambio de software; o bien
  3. Acompañarlo con la información que usted recibió referida al ofrecimiento de distribuir el correspondiente código fuente. (Esta alternativa se permite sólo para una distribución no comercial y sólo si usted recibió el Programa en código objeto o formato ejecutable con un ofrecimiento de este tipo, de acuerdo con la Subsección b precedente.)

El código fuente de una obra significa la forma de esta obra preferida para hacerle modificaciones. Para una obra ejecutable, el código fuente completo significa todo el código fuente para todos los módulos que contiene, además de cualquier fichero de definición de interfaz asociado, además de los guiones usados para controlar la compilación e instalación del ejecutable. Sin embargo, como excepción especial, el código fuente distribuido no tiene que incluir necesariamente cualquier cosa que es normalmente distribuida (ya sea en formato fuente o binario) con los componentes fundamentales (compilador, núcleo, y similares) del sistema operativo en el que se ejecuta el Programa, a no ser que ese componente acompañe al ejecutable.

Si la distribución del ejecutable o código objeto es realizada ofreciendo acceso a una copia desde un lugar designado, entonces el ofrecimiento de un acceso equivalente al código fuente desde el mismo lugar, se considera como distribución del código fuente, incluso aunque terceras partes no sean obligadas a copiar el código fuente junto al código objeto,

4. Usted no puede copiar, modificar, sublicenciar o distribuir el Programa excepto tal y como está expresamente permitido en esta Licencia. Cualquier intento diferente de copiar, modificar, sublicenciar o distribuir el Programa es nulo, y cancelará automáticamente sus derechos bajo esta Licencia. Sin embargo, las partes que hayan recibido de usted copias o derechos bajo esta Licencia no verán sus Licencias canceladas, mientras esas partes sigan cumpliendo totalmente la Licencia.

5. Usted no está obligado a aceptar esta Licencia, puesto que no la ha firmado. Sin embargo, ninguna otra cosa le garantiza permiso para modificar o distribuir este Programa o sus derivados. Estas acciones están prohibidas por la ley si usted no acepta esta Licencia. Por lo tanto, al modificar o distribuir el Programa (o cualquier obra basada en el Programa), usted indica su acuerdo con esta Licencia para hacerlo, y con todos sus términos y condiciones para copiar, modificar, o distribuir el programas u obras basadas en él.

6. Cada vez que usted redistribuya el Programa (o cualquier obra basada en él), el receptor automáticamente recibe una licencia del licenciante original para copiar, distribuir o modificar el Programa, sujeta a estos términos y condiciones. Usted no puede imponer ninguna restricción más sobre los derechos del receptor que aquí quedan garantizados. Usted no es responsable de hacer cumplir esta Licencia a terceras partes.

7. Si, como consecuencia de una resolución judicial o alegato de infracción de patente, o por cualquier otra razón (no limitada a hechos relacionados con las patentes), se le imponen a usted condiciones (ya sea por imposición judicial, acuerdo, u otra circunstancia) que contradigan las condiciones de esta Licencia, estas condiciones no le excusan del cumplimiento de los términos de esta Licencia. Si usted no puede distribuir el Programa de manera tal que satisfaga simultáneamente sus obligaciones con esta Licencia y otras obligaciones pertinentes, entonces la consecuencia es que usted no podrá distribuir el Programa en absoluto. Por ejemplo, si una licencia de patente no permite la redistribución libre de cobros del Programa por parte de todos aquellos que recibieron copias directa o indirectamente de usted, entonces la única manera en que usted puede satisfacer a la vez esa licencia y esta Licencia sería abstenerse enteramente de la distribución del Programa

Si cualquier parte de esta sección se muestra como inválida o inobligable bajo cualesquiera circunstancias particulares, el resto de la sección se aplicará, y la sección al completo se aplicará en otras circunstancias.

No es el propósito de esta sección inducirle a violar ninguna patente, ni otras reclamaciones de derechos de propiedad, ni negar la validez de tales reclamaciones: esta sección tiene el único objetivo de proteger la integridad del sistema de distribución del software libre, el cual está implementado mediante las licencias públicas. Muchas personas han hecho generosas contribuciones al amplio rango de software distribuido por ese sistema como consecuencia de la aplicación coherente de ese sistema; es cuestión del autor/donador el decidir si él o ella quiere distribuir el software a través de cualquier otro sistema, y un licenciado no puede imponer esa decisión.

Esta sección está designada para clarificar lo que se piensa es una consecuencia del resto de esta Licencia.

8. Si la distribución y/o uso de software está restringido en ciertos países por patentes o por copyrights sobre interfaces, el poseedor del copyright original que sitúa el Programa bajo esta Licencia, puede añadir una limitación de distribución geográfica excluyendo estos países, de forma que la distribución esté permitida sólo dentro o entre los países no excluidos. En este caso, esta Licencia incorpora esta limitación, como si estuviese escrita en el cuerpo de esta Licencia.

9. La Free Software Foundation puede publicar versiones revisadas y/o nuevas de la Licencia Pública General en algún momento. Tales nuevas versiones serán similares en espíritu a la versión presente, pero pueden diferir en detalles para solucionar nuevos problemas o conflictos.

Cada versión se distingue por un número de versión. Si el programa especifica un número de versión de esta Licencia, que se aplica a ella y "a cualquier versión posterior", usted tiene la opción de seguir los términos y condiciones de esa versión o de cualquier versión posterior publicada por la Free Software Foundation. Si el Programa no especifica un número de versión de esta Licencia, usted puede escoger cualquier versión publicada en cualquier momento por la Free Software Foundation.

10. Si usted desea incorporar partes del Programa en otros programas libres cuyas condiciones de distribución son diferentes, escriba al autor para pedir permiso. Para software cuyo copyright posee la Free Software Foundation, escriba a la Free Software Foundation; algunas veces hacemos excepciones para esto. Nuestra decisión estará guiada por los dos objetivos de preservar el carácter libre de todos los derivados de nuestro software libre y de promocionar el compartimiento y reutilización del software en general.

SIN GARANTÍA

11. DEBIDO A QUE EL PROGRAMA SE LICENCIA SIN COSTE, NO EXISTE GARANTÍA PARA EL PROGRAMA, HASTA LO PERMITIDO POR LAS LEYES APLICABLES. EXCEPTO CUANDO SE ESTABLEZCA DE OTRA FORMA POR ESCRITO LOS POSEEDORES DEL COPYRIGHT Y/O OTRAS PARTES PROVEEN EL PROGRAMA "COMO ESTÁ" SIN GARANTÍA DE NINGUNA CLASES, YA SEA EXPRESA O IMPLÍCITA, INCLUYENDO, PERO NO LIMITÁNDOSE A, LA GARANTÍA IMPLÍCITA DE USABILIDAD Y UTILIDAD PARA UN PROPÓSITO PARTICULAR. EL RIESGO COMPLETO ACERCA DE LA CALIDAD Y EFICIENCIA DEL PROGRAMA ES SUYO. SI EL PROGRAMA SE MOSTRARA DEFECTUOSO, USTED ASUMIRÁ TODO EL COSTE DEL SERVICIO NECESARIO Y DE LA REPARACIÓN O CORRECCIÓN.

12. EN NINGÚN CASO, A NO SER QUE SE REQUIERA POR LAS LEYES APLICABLES O SE ACUERDE POR ESCRITO, PODRÁ NINGÚN POSEEDOR DE COPYRIGHT O CUALQUIER OTRA PARTE QUE HAYA MODIFICADO Y/O REDISTRIBUIDO EL PROGRAMA SER RESPONSABLE ANTE USTED POR DAÑOS O PERJUICIOS, INCLUYENDO CUALQUIER DAÑO GENERAL, ESPECIAL, INCIDENTAL, O CONSECUENTE QUE SE DERIVE DEL USO O INCAPACIDAD DE USO DE ESTE PROGRAMA (INCLUYENDO, PERO NO LIMITÁNDOSE A LA PÉRDIDA DE DATOS O PRODUCCIÓN DE DATOS INCORRECTOS O PÉRDIDAS SUFRIDAS POR USTED O UNA TERCERA PARTE, O UNA INCAPACIDAD DEL PROGRAMA PARA OPERAR JUNTO A OTROS PROGRAMAS), INCLUSO SI EL POSEEDOR DEL COPYRIGHT U OTRA PARTE HABÍA SIDO AVISADO DE LA POSIBILIDAD DE TALES DAÑOS.

FIN DE LOS TÉRMINOS Y CONDICIONES

Cómo aplicar estos términos a sus nuevos programas

Si usted desarrolla un nuevo programa, y quiere que sea de la máxima utilidad posible para el público, la mejor manera de conseguir esto es hacerlo software libre que cualquiera pueda redistribuir y cambiar bajo estos términos.

Para hacerlo, incluya los siguientes avisos en el programa. Es más seguro incluirlos al comienzo de cada fichero fuente para destacar claramente la exclusión de garantía; y cada fichero debe tener al menos la línea de copyright y una indicación de dónde se puede encontrar el aviso completo.

[una línea para dar el nombre del programa y una breve descripción]

Copyright (C) 19aa [nombre del autor]

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
    
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

En español:

Este programa es software libre; usted puede redistruirlo y/o 
modificarlo bajo los términos de la Licencia Pública General GNU,
tal y como está publicada por la Free Software Foundation; ya sea 
la versión 2 de la Licencia, o (a su elección) cualquier versión 
posterior.
   
Este programa se distribuye con la intención de ser útil, pero SIN
NINGUNA GARANTÍA; incluso sin la garantía implícita de USABILIDAD O
UTILIDAD PARA UN FIN PARTICULAR. Vea la Licencia Pública General GNU 
para más detalles.
    
Usted debería haber recibido una copia de la Licencia Pública
General GNU junto a este programa; si no es así, escriba a la Free
Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, EEUU.

Añada también información sobre cómo contactar con usted por correo electrónico y ordinario.

Si el programa es interactivo, haga que muestre un pequeño aviso como este, cuando empiece el modo interactivo:

Gnomovision versión 69, Copyright (C) 19aa nombre del autor
	
Gnomovision viene sin NINGUNA GARANTÃA EN ABSOLUTO; para más detalles,
escriba `ver g'. Este es software libre, y su distribución es adecuada
bajo ciertas condiciones; escriba `ver c' para más detalles.

Los comandos hipotéticos ver g y ver c deben mostrar las partes apropiadas de la Licencia Pública General GNU. Por supuesto, los comandos reales que usted use podrían ser otros que ver g y ver c; incluso podrían ser clics de ratón o elementos de menú, lo que se ajuste mejor a su programa.

También debería hacer que su superior laboral (si usted trabaja como programador), o su centro académico, si los tiene, firmen una "renuncia al copyright" para el programa, si esto es necesario. Aquí hay un ejemplo; cambie los nombres:

Yoyodine, SA, renuncia a todo su derecho de copia sobre el programa
`Gnomovision' (que hace tal cosa), escrito por Juan Programador.
  
 [firma de Jefe Máximo], 1 de Mayo de 1998
    Jefe Máximo, Presidente

Esta Licencia Pública General no permite incorporar su programa a programas propietarios. Si su programa es una librería de subrutinas, puede considerar más útil el permitir enlazar programas propietarios con la librería. Si esto es lo que quiere, use la Licencia Pública General GNU para Librerías en lugar de esta Licencia.

sks-ecc-0.93/doc/download.html0000644000175000017500000000560510715702751015214 0ustar nachonacho SKS, criptografía de bolsillo

SKS

criptografía de bolsillo

Fuentes Sources

sks-source-0.93.bz2
sks-source-0.93.zip
Checksums (MD5-TIGER)

Binarios Binaries

Linux-UnixWindows
Español Checksums Español Checksums
English Checksums English Checksums

Interfaz gráfico (Linux)

  • gsks, frontend programado en Bash. Invoca a zenity para crear sencillos diálogos interactivos. Por supuesto, hay que tener instalado 'zenity'. Más información en miscelanea.

Some english docs

sks-ecc-0.93/doc/dis.html0000644000175000017500000003632010715702751014162 0ustar nachonacho SKS, criptografía de bolsillo

SKS

criptografía de bolsillo

Filosofía general

Al igual que pegwit, SKS está orientado hacia la simplicidad y facilidad de uso. Por eso, el número de primitivas y opciones ha sido reducido al mínimo, posiblemente al coste de algunas funcionalidades.

Sin embargo, al contrario que pegwit, SKS sí conserva las claves públicas en un fichero que se guarda en el área de configuración del usuario. Esto se hace para elegir cómodamente las claves mediante cadenas simples que las identifiquen. Pero no hay ninguna otra funcionalidad asocidada a los "anillos de claves"; esto es:

  • No se conservan claves privadas
  • No hay control de confianza de las claves públicas almacenadas
  • No hay certificados de revocación

Pero esto permite que, con sólo tener a mano el ejecutable y recordar la propia contraseña, uno puede usarlo en un ordenador ajeno para descifrar los mensajes que se le hayan dirigido. En contrapartida, la responsabilidad de verificar el origen de las claves recae en el propio usuario; asimismo, éste debe estar pendiente de tener a mano las claves que va a necesitar cuando no esté junto a su ordenador.

Recursos mínimos

SKS consume muy pocos recursos del sistema. Para hacer esto posible, el proceso de datos se hace en forma de "flujo", es decir, los datos se van procesando sobre la marcha, y por eso la memoria caché que se requiere es relativamente pequeña (en torno a 1 Mb en el escenario más exigente).

Implementación

La mejor forma de analizar la implementación es consultar el código fuente que se suministra. No obstante, se describen aquí brevemente algunos detalles de la misma.

Los elementos criptográficos son:

  • Módulo de clave pública: curva elíptica sobre GF (2191)
  • Módulo de clave simétrica: AES con clave de 192 bits en modo CTR
  • Función resumen, para firmas y contraseñas: TIGER (192 bits)
  • Módulo pseudoaleatorio: /dev/urandom en Linux-Unix y CryptGenRandom en Windows

La curva elíptica

El campo está representado por polinomios en GF (2) de grado 191 (primo), esto es, GF (2191). La alternativa, que es la representación mediante Base Normal Óptima (ONB), es más rápida pero también más difícil de implementar y de revisar por terceros. En cualquier caso, la representación polinómica de SKS está muy optimizada, de modo que su tiempo de ejecución es más que razonable incluso en equipos antiguos.

El polinomio primitivo para reducir las multiplicaciones es:

s191 + s9 + 1

y la ecuación de la curva es:

y2 + xy  = x3 +  x2 +  (s12 + s10 +  s6 + s2 + 1)

Y el orden del punto fijo de la curva es un número de 190 bits —que llamaremos p—, que cumple la condición MOV hasta 100 iteraciones (lo mínimo es 9). Por tanto, la seguridad que se espera del bloque de curva elípitica es la mitad del tamaño de p, esto es, 95 bits.Todas estas constantes están definidas en los ficheros de cabecera gflib.h, eclib.h, y eccrypt.h.

Los puntos de la curva son parejas de polinomios (x, y) pero para su almacenamiento, SKS guarda sólo el polinomio x y un bit que decide cuál de las dos soluciones de la ecuación cuadrática para y hay que escoger.

Generación de claves públicas

La clave pública P se genera mediante,

P = d·Q

donde d es el multiplicador obtenido mediante el resumen de la contraseña, que se puede considerar como la clave privada, y Q es el punto fijo de la curva, que es común para todos los usuarios del sistema.

Cifrado

El emisor del mensaje propone, como clave común para cifrado simétrico, lo siguiente:

K = k·Q
0 < k < p

donde k es un multiplicador aleatorio, y se lo comunica al receptor mediante:

M = k·P

el cual recupera la clave simétrica, K, mediante el uso de su clave privada, d:

e = d-1 mod p
M·e =  (k·P)e =  (k·d·Q)e =  (k·Q)d·e = K

Firma

SKS utiliza el algoritmo DSA de curvas elípticas (ECDSA) para generar las firmas. El algoritmo genera un par de números, (r, s) a partir de la clave privada del usuario, d, y del resumen h del mensaje que se firma, de la siguiente forma:

r = [k·Q]x  mod p

donde k es un multiplicador aleatorio. Es decir, r es el resultado de convertir en número el polinomio x del producto de curva elíptica k·Q. Por otro lado:

s = k· (h + d·r )-1 mod p

El mensaje y el par (r, s) se envían al destinatario, el cual comprueba la firma calculando el resumen del mensaje, h, y tomando la clave pública del emisor, P. Entonces efectúa el siguiente cálculo:

r' = [(h·sQ  + (r·sP]x  mod p

si r' = r entonces se acepta la firma como válida. Esto es fácil de comprobar sustituyendo P y s en r'.

Cifrado simétrico

SKS usa el algoritmo de cifrado AES (Advanced Encryption Standard, o estándar de cifrado avanzado) con una clave de 192 bits. AES es formalmente idéntico al algoritmo Rijndael, pero con la longitud de bloque fija en 128 bits.

El modo de cifrado elegido es CTR (CounTeR, contador), que permite recuperar información incluso si se ha corrompido parcialmente el fichero y con el que no es necesario rellenar el original para ajustar su longitud a la longitud del bloque de cifrado. Se trata de cifrar un contador, del mismo tamaño que el bloque, escogido al azar. Funciona de la siguiente forma:

Ci = Mi ^  EK (i)

donde S es el contador, Mi, Ci el bloque original y cifrado respectivamente. EK() representa el algoritmo de cifrado para una clave dada K. El símbolo ^ representa la operación "OR exclusivo" (XOR).

El descifrado es idéntico, salvo que se invierten Mi, Ci:

Mi = Ci ^  EK (i)

Obsérvese que no se usa el algoritmo de cifrado inverso. En el proceso de cifrado se usa un mecanismo de autentificación HMAC para garantizar la integridad del mensaje.

Función resumen

Como se ha dicho, SKS usa el algoritmo TIGER para generar resúmenes (hash) de:

  • contraseñas para generación de la clave privada,
  • contraseñas para claves de cifrado convencional,
  • mensajes y ficheros para firmas digitales,
  • claves públicas para la creación de la huella digital.

También se usa TIGER en el módulo pseudoaleatorio.

Adicionalmente, se usa el algoritmo CRC32, de 32 bits, para obtener el identificador numérico de cada clave. Los 24 bits menos significativos del identificador se añaden a la clave cuando ésta se exporta o se genera, a modo de control de integridad.

El algoritmo TIGER goza de la confianza de la comunidad criptográfica y se considera seguro bajo cualquier punto de vista. Es muy rápido y, además, su longitud de 192 bits se adecúa a las longitudes de los multiplicadores del campo de curva elíptica. A continuación se detalla la implementación del algoritmo.

Generación de claves privadas

Los caracteres de la contraseña ocupan las primeras posiciones de un buffer en que previamente se han cargado 1024 bits procedentes del número Pi, que actúan a modo de "sal" para dificultar ataques de diccionario. A continuación se toma el resumen de todo el buffer y la salida se considera como un número, n, de 192 bits. La clave privada se obtiene mediante:

d = n mod p

La entropía de d, suponiendo que n tiene una entropía de 192 bits, es de 189,9 bits, muy próxima al límite teórico de 190 bits.

Generación de claves de cifrado convencional

A partir de la contraseña se obtiene n exactamente igual que el caso anterior. La clave de cifrado convencional se obtiene tomando otra vez el resumen de n y pasando directamente el resultado al proceso de cifrado simétrico

Resumen para firmas digitales

El número h se obtiene encadenando al final del fichero/texto que se desea firmar 4 octetos que representan la fecha (en colocación little endian). A continuación se obtiene el resumen del conjunto y se interpreta como un número, h', de 192 bits, de donde:

h = h' mod p

Huellas digitales

Se toma el resumen de la clave pública y se interpreta como un número de 192 bits, del que se muestran sus 30 cifras menos significativas en base-36.

Módulo pseudoaleatorio

SKS necesita bits aleatorios para:

  1. el multiplicador que genera la clave simétrica (190 bits),
  2. el multiplicador que co-genera la firma (190 bits),
  3. el valor de partida del contador para el modo de cifrado simétrico CTR (128 bits).

En los casos 1. y 2. el número obtenido se toma módulo p. En el caso 3. se trunca el resultado a 128 bits.

En principio, estos bits se obtienen de un dispositivo especial del sistema. En Linux-Unix se invoca a /dev/random y en Windows a CryptGenRandom(). Para minimizar cualquier posible sesgo de estos dispositivos, se toman 1536 bits los cuales se procesan mediante TIGER para reducirlos a 192 bits.

A partir de la versión 0.92, los bits obtenidos de los dispositivos se mezclan, antes de la reducción, con el contenido de un fichero del área de usuario —.sksprng en Linux y PRNG.BIN en Windows—, si es que éste existe. Esto permite al usuario explotar sus propias fuentes de material aleatorio y usarlas en SKS, escribiendo en los ficheros mencionados hasta 1536 bits obtenidos de estas fuentes.

Si no es posible usar estos dispositivos, SKS recurre a un método estándar (ANSI C) que invoca repetidamente el reloj del sistema. Este método produce bits aleatorios de no muy alta calidad y es relativamente lento, por lo que está configurado a tomar sólo 128 bits (se puede cambiar en tiempo de compilación). Estos bits se encadenan con más material pseudoaletorio de baja calidad y se procesan varias veces mediante TIGER. El fichero fuente entropy.c contiene información al respecto.

sks-ecc-0.93/doc/misc.html0000644000175000017500000000553010715702751014335 0ustar nachonacho SKS, criptografía de bolsillo

SKS

criptografía de bolsillo

Dirección permanente

La página web permanente de SKS es:

que aconsejo visitar para descargar la última versión del programa y de esta documentación.

Scripts de prueba

test.php

He realizado un pequeño guión de comandos en PHP para probar el programa interactivamente:

Envío de correo

Con el siguiente script puedes enviarme un mensaje cifrado con la propia aplicación:

gsks

Actualmente hay disponible un guión de comandos bash que lanza diálogos interactivos con los que (des)cifrar firmar y verificar textos; también maneja el anillo de claves. El (des)cifrado es siempre de clave pública. No hay interacción directa con el portapapeles por problemas con la codificación UTF8 que tienen los programas habituales (xsel, xclip) de lectura/escritura del portapapeles; es el usuario quien tiene que cortar/pegar a voluntad.

Es sólo para linux y necesita el paquete zenity. Puedes descargarlo en el siguiente enlace. También se encuentra en la sección de descargas.

sks-ecc-0.93/doc/fix.css0000644000175000017500000000017310715702751014012 0ustar nachonacho/**************** IE fixes ****************/ html {overflow:hidden;} body {height:100%; width:100%; overflow:auto;}sks-ecc-0.93/doc/manual.html0000644000175000017500000004454210715702751014665 0ustar nachonacho SKS, criptografía de bolsillo

SKS

criptografía de bolsillo

Resumen

Al ejecutar SKS sin parámetros aparece un breve resumen del manual:

Modo de uso:
 cifrado convencional
   -c claro cifrado  < contraseña
   -C     (compresión previa de datos)
 cifrado de clave pública
   -e claro cifrado [id 1]  [id 2] ... [id n]*
   -E     (compresión previa de datos)
 descifrar (todos los casos)
   -d cifrado claro < contraseña
 firmar/verificar/resumir
   -s claro firma < contraseña
   -S texto < contraseña > texto-firmado
   -v claro firma
   -V texto-firmado >texto
   -r fichero1 fichero2 ... fichero-n > resumen hexadecimal (TIGER)
 -f[operación] [introduce SKS -f para más detalles]
 -b[operación] [introduce SKS -b para más detalles]
 -k[operación] [introduce SKS -k para más detalles]
 (*) Será seleccionada toda clave que contenga cualquier identificador
     La ausencia de identificador selecciona todas las claves
Este resumen aparece también cuando se suministra un número incorrecto de parámetros o si el primer parámetro es incorrecto. Nótese que algunas órdenes admiten un número indefinido de parámetros y que -S, -V son distintos a -s, -v.

Los caracteres [ < ] y [ > ] indican que SKS require datos de la entrada estándar (stdin) y devuelve datos por la salida estándar (stdout). Además, hay diversos mensajes, tanto de error como de advertencia o información, que se ofrecen por la salida de error (stderr); estos mensajes están disponibles en español e inglés, según la versión que descargues.

Cifrado

Para cifrar un fichero hace falta una(s) clave(s) pública(s). En general no será tu propia clave pública, sino la de aquellos a los que se destina el fichero. Si tu clave pública está en tu anillo (que es lo más normal) puedes elegirla también para que puedas ver en el futuro el contenido del fichero, si es que planeas eliminar el original.

Las claves públicas de tus corresponsales te las han de enviar ellos y está en tu mano comprobar que realmente provienen de quien dice. En el apartado Gestión de Claves hay más información al respecto. El fichero de claves que se suministra contiene las siguientes claves:

 [6be386a4]: Hola Mundo /hola mundo/
 [40023a50]: Hello World /hello world/
 [5425be1c]: Jose Luis Torrente <jltorrente@caspa.net> /amiguete/
 [00e14ca8]: Manuel Pancorbo Castro <mpancorbo # wanadoo.es>

Para cifrar el fichero mensaje.txt simplemente teclea:

    sks -e mensaje.txt mensaje.txt.e torrente
donde mensaje.txt.e es el fichero cifrado que creará el programa.

OJO, si ya existiera un fichero con ese nombre, SKS lo sobreescribirá sin advertencia previa. El original NO se borra automáticamente.

torrente es un identificador que coincide, en este caso, sólo con una clave. Como identificador vale cualquier cadena de texto, que se compara con las etiquetas que identifican cada clave, así como con el identificador numérico de éstas.

    sks -e mensaje.txt mensaje.txt.e 5425be1c
también selecciona la misma clave.

Se pueden usar todos los identificadores que se consideren oportunos y las claves que se seleccionan para cifrar son aquellas cuyas etiquetas y/o ids. numéricos contengan alguna de las cadenas introducidas. La comparación es sensible a las mayúsculas.

    sks -e mensaje.txt mensaje.txt.e caspa
    sks -e mensaje.txt mensaje.txt.e @
    sks -e mensaje.txt mensaje.txt.e 5425
    sks -e mensaje.txt mensaje.txt.e "Jose Luis"
seleccionan la misma clave;
    sks -e mensaje.txt mensaje.txt.e s
selecciona la clave anterior y también la clave 00e14ca8. Sin embargo,
    sks -e mensaje.txt mensaje.txt.e sr
no selecciona ninguna (el programa no hace nada y emite un mensaje de advertencia) porque la cadena "sr" no existe en ninguna etiqueta.
    sks -e mensaje.txt mensaje.txt.e Hola Hello
Selecciona las claves 6be386a4 y 40023a50.

Si no se introduce ninguna cadena, el programa selecciona todas las claves del anillo.

Una vez que pulsas 'Intro' (como en el último ejemplo) el programa emite un mensaje:

SKS. Claves seleccionadas:
 [6be386a4]: Hola Mundo /hola mundo/
 [40023a50]: Hello World /hello world/
y en el directorio aparece el fichero mensaje.txt.e

Compresión

Si en lugar de la opción -e seleccionamos la opción -E el programa se comporta exactamente igual, salvo que comprime primero los datos.

    sks -E mensaje.txt mensaje.txt.e torrente
La opción de compresión es interesante para archivos de texto, de procesadores de texto y cualquiera que no esté comprimido por si mismo. Los ficheros jpg, zip, y cualesquiera otros formatos comprimidos se cifran mejor con la opción -e, que ahorra tiempo de proceso.

Cifrado convencional

Las opciones -c y -C cifran el fichero de forma convencional, con una clave generada a partir de una contraseña; por seguridad, contraseñas iguales generan claves distintas según si elegimos cifrado convencional o si generamos claves privadas. La opción en mayúsculas comprime, igual que con el cifrado de clave pública. El programa sólo necesita dos parámetros: el fichero de entrada y el de salida; la contraseña se pide por línea de comandos, sin eco de salida, para garantizar máxima privacidad.

Descifrado

Para descifrar un mensaje —no importa de qué manera se haya cifrado, convencionalmente o con clave pública, con o sin compresión— se usa la opción -d:

    sks -d mensaje.txt.e mensaje.txt
donde mensaje.txt.e es el fichero cifrado y mensaje.txt el fichero que creará el programa ya descifrado (la misma advertencia acerca del peligro de sobreescribir un fichero ya existente). Se pide una contraseña por línea de comandos que corresponde bien a alguna clave pública con la que se halla cifrado el original (opciones -e y -E), bien a la contraseña usada en el cifrado convencional (opciones -c y -C).

Si se usó cifrado de clave pública, se muestran los identificadores que se encuentren en la cabecera del fichero. Sólo identificadores, sin la etiqueta, porque el programa asume que NO todas las claves que se usaron para cifrar están en el anillo de claves del receptor (¡puede que ninguna, si se trata de un espía!) y por tanto elude comparar las claves que encuentra con las que hay en el anillo, que es donde residen las etiquetas.

Si la contraseña introducida corresponde a alguna de las claves públicas presentes, entonces su identificador aparece señalado:

    [6be386a4]: *
    [40023a50]: 
    [5425be1c]: 
    [00e14ca8]: 
Si se ha usado cifrado convencional y la contraseña es correcta, no se emite mensaje alguno. Si la contraseña es incorrecta entonces se da una alarma de fallo de autentificación, pero se crea el nuevo fichero lleno de, previsiblemente, basura.

Firma

Para firmar un fichero se usa la clave privada. Se genera un trozo de código que identifica unívocamente al creador de la clave, al contenido del archivo (por medio de una función resumen o hash) y a la fecha en que fue generada la firma, la cual también figura en la cabecera del trozo de código (que llamaremos "firma"). Cualquier intento por parte de un interventor —malicioso o accidental— de cambiar alguno de estos tres elementos impide verificar correctamente la firma. Esto permite identificarte como emisor del fichero y dificulta la suplantación en el anónimo mundo digital.

Se procede así:

    sks -s mensaje.txt mensaje.sig
donde mensaje.txt es el fichero que se pretende firmar y mensaje.sig el fichero que se creará con la firma (un par de líneas de armadura en base 64). A continuación se introduce la contraseña y se comprueba si la clave publica correspondiente se encuentra en el anillo, informando de ello al usuario pero procediendo con la firma en cualquier caso. La información puede ser útil si el firmante tiene su clave en el anillo, como comprobación que ha introducido la contraseña correctamente.

El receptor obtiene tanto el fichero original como el fichero de firma. Para verificar la firma hay que teclear:

    sks -v mensaje.txt mensaje.sig
El programa localiza por sí mismo la clave pública del firmante en el anillo de claves del receptor (si no estuviera, daría una advertencia) y procede a ejecutar el algoritmo de verificación. Si todo está en orden, emite un mensaje como el siguiente:
   [5425be1c]: Jose Luis Torrente <jltorrente@caspa.net> /amiguete/
  SKS. Firma correcta realizada en: 2004-06-24, 13:49 

Firma incrustada

Si se pretende firmar un mensaje de texto claro, es posible que queramos incrustar la firma al final del mismo, de forma que el receptor reciba un único fichero. Para eso hacemos:

    sks -S mensaje.txt
que nos preguntará la contraseña y emitirá el mensaje (con una cabecera de identificación) y la firma incrustada al final, por la salida estándar. Para conservar el fichero no tenemos más que redirigir la salida:
    sks -S mensaje.txt > mensaje.txt.signed
que el receptor confirma mediante la orden -V:
    sks -V mensaje.txt.signed
El mensaje original, sin la cabecera y sin los códigos de firma, sale por la salida estándar, que podemos redirigir, mientras que el mensaje de verificación se emite por la salida de error. Si sólo nos interesa la verificación, podemos redirigir la salida hacia la papelera o, en Linux-Unix, hacia /dev/null:
    sks -V mensaje.txt.signed > /dev/null
La firma con -S está pensada para ficheros de texto, de forma que los códigos de fin de línea son excluídos del cálculo de la función resumen. Esto se hace para garantizar que las firmas realizadas en un determinado entorno operativo sean verificables en otro, por la falta de uniformidad que existe en códigos de fin de línea.

Función resumen

SKS proporciona un comando para obtener un resumen (hash) de 192 bits ( algoritmo TIGER), de una manera muy similar a cómo la aplicación md5sum genera resúmenes de 128 bits mediante el algoritmo MD5. Esto se hace mediante la orden -r:

    sks -r mensaje.txt
que da como resultado algo similar a:
    b98ef1b942071187176585271b4008722ebb96d550b1279d  mensaje.txt
Se pueden especificar varios ficheros o usar comodines:
    sks -r *.txt
	
    b98ef1b942071187176585271b4008722ebb96d550b1279d  mensaje.txt
    a7ea8f6641da42ef35cf6b359ea790a25de29a65978977b5  test.txt
que es equivalente a
    sks -r mensaje.txt test.txt

Los creadores de TIGER desarrollaron una segunda versión del algoritmo, que afecta sólo en la forma de rellenar el último segmento parcial de texto antes de obtener el resumen final. SKS usa la primera versión, por lo que los resúmenes obtenidos para un mismo ficher pueden diferir de otra aplicación que use TIGER-2.

Modo de filtro

SKS se puede utilizar como un filtro dentro de una cadena de proceso de archivos de texto. En este caso, el texto que va a ser procesado entra siempre por la entrada estándar (stdin) y el resultado se emite por la salida estándar. Si la operación solicitada es el cifrado, entonces el resultado se codifica en base64 para transformarlo en cadenas texto que se pueden imprimir o editar.

También se pueden filtrar archivos binarios (opción -b), pero en este caso no se aplica codificación base64.

En este modo de funcionamiento los identificadores y contraseñas se introducen como parámetros del programa. Esto hace "visible" la contraseña si se usa directamente la línea de comandos para hacer uso de este modo. En realidad, el modo de filtro está pensado para usarlo dentro de guiones de comandos (scripts) de más alto nivel, donde las contraseñas se deben introducir mediante formularios con eco de estrella apropiados o similares.

Sin embargo, los ejemplos que se proporcionan aquí están escritos directamente en línea de comandos para mostrar con más claridad el funcionamiento. También se asumirá que se pretende filtro de texto (ASCII); el filtro binario es mucho más sencillo de entender a partir del filtro de texto.

Mediante la orden sks -f o sks -b obtenemos un breve resumen del manual del modo de filtro:

Modo de uso [filtrado]:
 cifrado convencional
   -fc "contraseña" <claro >cifrado-ascii
   -fC       (compresión previa de datos)
 cifrado de clave pública
   -fe [id 1]  [id 2] ... [id n]*  <claro >cifrado-ascii
   -fE       (compresión previa de datos)
 descifrar (todos casos)
   -fd "contraseña" <cifrado-ascii >claro
 firmar/verificar
   -fS "contraseña" <texto >texto-firmado
   -fV <texto-firmado >texto
[filtrado binario]:
 cifrado convencional
   -bc "contraseña" <claro >cifrado
   -bC       (compresión previa de datos)
 cifrado de clave pública
   -be [id 1]  [id 2] ... [id n]*  <claro >cifrado
   -bE       (compresión previa de datos)
 descifrar (todos casos)
   -bd "contraseña" <cifrado >claro
 (*) Será seleccionada toda clave que contenga cualquier identificador
     La ausencia de identificador selecciona todas las claves

La segunda letra tras la f elige la función del programa que actúa de forma muy similar a la orden en modo de no filtrado. Por ejemplo, para cifrar un flujo de texto con destino al usuario Torrente:
    ...(flujo de texto).. | sks -fE Torrente 
Un ejemplo más concreto usando la línea de comandos de Linux-Unix:
    cat mensaje.txt | sks -fE Torrente > cifrado.txt
donde en lugar de cifrado.txt se puede "enchufar" (pipe) otro programa, por ejemplo, de correo eléctrónico:
    cat mensaje.txt | sks -fE Torrente           \\
    | mail jltorrente@caspa.net -s "Lee esto"
El receptor usa la orden -fd para descifrarlo:
    cat cifrado.txt | sks -fd amiguete 
Si la contraseña está formada por palabras separadas por espacios, se pueden usar comillas:
    cat cifrado.txt | sks -fd "hola mundo"
Si el flujo de entrada contiene varios bloques de texto cifrado, el programa intentará descifrar todos con la clave propuesta. Los bloques se identifican con indicadores de comienzo y fin de armadura que incluyen los símbolos ###. La salida contiene sólo el texto descifrado; cualquier texto fuera de la armadura no se considera.

Para firmar se procede con -fS y el resultado es la entrada que se proporciona, junto con la cabecera de identificación, y con el código de firma incrustado al final. Por ejemplo, el usuario Hola Mundo firma un mensaje que envía al usuario Torrente:

    cat mensaje.txt | sks -fS "hola mundo"        \\
    | mail jltorrente@caspa.net -s "Lee esto"
y el receptor lo verifica mediante:
    cat mensaje.txt | sks -fV 
y obiene el mensaje "limpio" a la salida, más una confirmación por la salida de error (stderr).

Por su filosofía minimalista, el programa no contempla una orden para firmar y cifrar. Se puede invocar al programa dos veces y "enchufar" las salidas:

    cat mensaje.txt | sks -fS "hola mundo"          \\
    | sks -fE Torrente hola > mensaje.sks
que el receptor puede verificar mediante:
    cat mensaje.sks | sks -fd amiguete | sks -fV > mensaje.txt
sks-ecc-0.93/doc/filtro.html0000644000175000017500000001460310715702751014702 0ustar nachonacho SKS, criptografía de bolsillo

SKS, criptografía de bolsillo

Modo de filtro

SKS se puede utilizar como un filtro dentro de una cadena de proceso de archivos de texto. En este caso, el texto que va a ser procesado entra siempre por la entrada estándar (stdin) y el resultado se emite por la salida estándar. Si la operación solicitada es el cifrado, entonces el resultado se codifica en base64 para transformarlo en cadenas texto que se pueden imprimir o editar.

También se pueden filtrar archivos binarios (opción -b), pero en este caso no se aplica codificación base64.

En este modo de funcionamiento los identificadores y contraseñas se introducen como parámetros del programa. Esto hace "visible" la contraseña si se usa directamente la línea de comandos para hacer uso de este modo. En realidad, el modo de filtro está pensado para usarlo dentro de guiones de comandos (scripts) de más alto nivel, donde las contraseñas se deben introducir mediante formularios con eco de estrella apropiados o similares.

Sin embargo, los ejemplos que se proporcionan aquí están escritos directamente en línea de comandos para mostrar con más claridad el funcionamiento. También se asumirá que se pretende filtro de texto (ASCII); el filtro binario es mucho más sencillo de entender a partir del filtro de texto.

Mediante la orden sks -f o sks -b obtenemos un breve resumen del manual del modo de filtro:

Modo de uso [filtrado]:
 cifrado convencional
   -fc "contraseña" <claro >cifrado-ascii
   -fC       (compresión previa de datos)
 cifrado de clave pública
   -fe [id 1]  [id 2] ... [id n]*  <claro >cifrado-ascii
   -fE       (compresión previa de datos)
 descifrar (todos casos)
   -fd "contraseña" <cifrado-ascii >claro
 firmar/verificar
   -fS "contraseña" <texto >texto-firmado
   -fV <texto-firmado >texto
[filtrado binario]:
 cifrado convencional
   -bc "contraseña" <claro >cifrado
   -bC       (compresión previa de datos)
 cifrado de clave pública
   -be [id 1]  [id 2] ... [id n]*  <claro >cifrado
   -bE       (compresión previa de datos)
 descifrar (todos casos)
   -bd "contraseña" <cifrado >claro
 (*) Será seleccionada toda clave que contenga cualquier identificador
     La ausencia de identificador selecciona todas las claves

La segunda letra tras la f elige la función del programa que actúa de forma muy similar a la orden en modo de no filtrado. Por ejemplo, para cifrar un flujo de texto con destino al usuario Torrente:
    ...(flujo de texto).. | sks -fE Torrente 
Un ejemplo más concreto usando la línea de comandos de Linux-Unix:
    cat mensaje.txt | sks -fE Torrente > cifrado.txt
donde en lugar de cifrado.txt se puede "enchufar" (pipe) otro programa, por ejemplo, de correo eléctrónico:
    cat mensaje.txt | sks -fE Torrente           \\
    | mail jltorrente@caspa.net -s "Lee esto"
El receptor usa la orden -fd para descifrarlo:
    cat cifrado.txt | sks -fd amiguete 
Si la contraseña está formada por palabras separadas por espacios, se pueden usar comillas:
    cat cifrado.txt | sks -fd "hola mundo"
Si el flujo de entrada contiene varios bloques de texto cifrado, el programa intentará descifrar todos con la clave propuesta. Los bloques se identifican con indicadores de comienzo y fin de armadura que incluyen los símbolos ###. La salida contiene sólo el texto descifrado; cualquier texto fuera de la armadura no se considera.

Para firmar se procede con -fS y el resultado es la entrada que se proporciona, junto con la cabecera de identificación, y con el código de firma incrustado al final. Por ejemplo, el usuario Hola Mundo firma un mensaje que envía al usuario Torrente:

    cat mensaje.txt | sks -fS "hola mundo"        \\
    | mail jltorrente@caspa.net -s "Lee esto"
y el receptor lo verifica mediante:
    cat mensaje.txt | sks -fV 
y obiene el mensaje "limpio" a la salida, más una confirmación por la salida de error (stderr).

Por su filosofía minimalista, el programa no contempla una orden para firmar y cifrar. Se puede invocar al programa dos veces y "enchufar" las salidas:

    cat mensaje.txt | sks -fS "hola mundo"          \\
    | sks -fE Torrente hola > mensaje.sks
que el receptor puede verificar mediante:
    cat mensaje.sks | sks -fd amiguete | sks -fV > mensaje.txt
sks-ecc-0.93/doc/gpl.txt0000644000175000017500000004313110715702751014036 0ustar nachonacho GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. sks-ecc-0.93/doc/clave.html0000644000175000017500000002653610715702751014505 0ustar nachonacho SKS, criptografía de bolsillo

SKS

criptografía de bolsillo

Gestión de claves

Ya hemos visto en la sección de instalación cómo importar claves y cómo generar una clave propia. Hay más opciones cuyo manual breve obtenemos mediante sks -k:

Modo de uso [gestión de claves]:
 generación de clave
   -kg < id. de clave / contraseña > clave
 listado de claves
   -kl [id 1] [id 2] ... [id n]* > lista
 listado base-36 de claves (huella digital en modo ICAO)
   -kf [id 1] [id 2] ... [id n]* > lista
 exportación de claves
   -ke [id 1] [id 2] ... [id n]* > claves
 importación de claves
   -ki fichero-de-claves  < fichero-de-claves (alternativamente)
 borrar clave
   -kd id.-numérico  < id.-numérico (alternativamente)
 (*) Será seleccionada toda clave que contenga cualquier identificador
     La ausencia de identificador selecciona todas las claves
 Fichero de claves: /home/manuel/.skspkr

Generación de claves

Ya hemos visto que para generar un par de claves pública-privada hay que teclear:

    sks -kg

El programa te pedirá una descripción identificativa de la clave y, a continuación, la contraseña. Se admite cualquier entrada por stdin que contenga al menos dos líneas: la primera como identificador y la segunda como contraseña. Por la salida estándar se emite la clave pública en formato legible por la función -ki (importar clave). De esta forma se puede redireccionar a un fichero con vistas a su distribución. No obstante, esto se puede hacer más adelante, mediante la exportación de claves.

Por diseño, el programa almacena sólo la clave pública. La clave privada es la propia contraseña (convenientemente "aliñada" y "digerida" por la función resumen) y ésta se almacena únicamente en tu memoria. De esta forma no te hace falta más que una copia del programa para generar en cualquier momento tu clave pública.

Como identificador conviene poner el nombre y/o dirección de correo electrónico. Se pueden usar cadenas de texto con cualquier tipo de caracteres, incluídos acentos, comillas, etc. Sin embargo, para la contraseña deberíamos emplear exclusivamente caracteres ASCII y, dentro de éstos, evitar todo tipo de comillas para que los guiones de comandos no se hagan un lío (las diversas comillas juegan papeles importantes como separadores en muchos lenguajes script). Tanto el identificador como la contraseña admiten un máximo de 256 caracteres.

Aquí viene ahora todo el rollo ese del cuidado en la elección de la contraseña, la poquísima entropía por letra de las lenguas naturales, la asombrosa eficiencia de los ataques de diccionario, etc, etc. Para resumir recomiendo una visita a diceware, que explica todo lo que hay que saber sobre contraseñas y ofrece un sencillo método con dados para generar contraseñas fuertes. Está en inglés pero hay enlaces a la versión en español (si bien es un poco cutre...).

Listado

Mediante la orden -kl obtenemos un listado simple de todas las claves del anillo. Se lista una clave por línea; por cada clave se muestra un identificador numérico de 32 bits, calculado a partir de todos los bits de la clave pública, y a continuación el identificador textual.

Se puede filtrar las claves añadiendo identificadores que coincidan con el criterio de búsqueda. El sistema es idéntico al de selección de claves en cifrado de clave pública. Por ejemplo:

    sks -kl Hola Hello
lista las siguientes claves:
 [6be386a4]: Hola Mundo /hola mundo/
 [40023a50]: Hello World /hello world/

Huella digital

La orden -kf lista la "huella digital" (o fingerprint, que a veces se traduce literalmente por "huella dactilar") de cada clave para la comprobación por via telefónica o directa con su propietario. La huella digital es un resumen de la clave del cual se extraen los 30 dígitos, en base 36, menos significativos, en grupos de 5. En base 36 se usan los 10 dígitos del 0 al 9 más el alfabeto ICAO de 26 letras. Las letras se muestran en mayúsculas para mejor visibilidad, salvo la letra "o" que es minúscula para distinguirla mejor de la cifra "0".

Por ejemplo, las huellas del anillo de prueba son:

 [6be386a4]: Hola Mundo /hola mundo/
  F4XFT 5K97H AF4QN Y5454 HQJDS 894ME

 [40023a50]: Hello World /hello world/
  RM8QQ JR20C H3RLW F8YW9 PL64Q ZHZ9E

 [5425be1c]: Jose Luis Torrente <jltorrente@caspa.net> /amiguete/
  8EBGT BFFL2 PCFLL AYLKW RQMRK CSF9Z

 [00e14ca8]: Manuel Pancorbo Castro <mpancorbo # wanadoo.es>
  803ME P8X9X 6ZA5T YIC2P o7QL2 RDLX8
He preferido usar base 36 en lugar de la base hexadecimal porque:

  1. Permite cadenas más cortas con fuerte resistencia a colisiones sin comprometer la legibilidad . Por ejemplo, GPG usa el algoritmo SHA1 que produce huellas de 40 dígitos hexadecimales con una resistencia de 160 bits. Las huellas de SKS usa el algoritmo de resumen TIGER, del cual se toman 30 dígitos en base 36 con una resistencia de 156 bits.
  2. Permite dictar la huella mediante un método que ha probado su eficacia como es el alfabeto ICAO (Organización Internacional de Aviación Civil). De esta forma se mejora mucho la distinguibilidad en medios ruidosos, como es la línea telefónica (peor todavía si se trata de celurares) o la radio. Por ejemplo, para dictar la huella de mi clave diría: ocho, cero, tres, maik, eco..., o bien ocho de octavo, cero de nada, tres de tercero, eme de madrid, e de españa..., o cualquier otra convención que entiendan los interlocutores.

Se pueden filtrar las claves de las que se quiere obtener la huella. El procedimiento es exactamente el mismo que en el listado ordinario:

    sks -kf Hola Hello
	
 [6be386a4]: Hola Mundo /hola mundo/
  EM498 SDJQH 4545Y NQ4FA H79K5 TFX4F

 [40023a50]: Hello World /hello world/
  E9ZHZ Q46LP 9WY8F WLR3H C02RJ QQ8MR

Exportación de claves

El objetivo de esta orden es transportar las claves del anillo y tenerlas a mano junto con el programa para usarlas en toda ocasión. También es útil para extraer la propia clave y distribuirla. Por último, es una alternativa de verificación de claves, aunque un poco más farragosa porque la clave se muestra en base 64, que usa letras mayúsculas y minúsculas mezcladas.

Tecleando sks -ke obtenemos a la salida el listado de todas las claves en formato listo para su importación.

-----SKS KEY-----
key: bOKoAFmL259zVgL1BUBHkv0Csy5a5ZHCpIbj
Hola Mundo /hola mundo/

-----SKS KEY-----
key: xkrhNQDF7OaJU5mCb5yLMjZoEF8GqXhXUDoC
Hello World /hello world/

-----SKS KEY-----
key: il8XBZKD5ZdRsmVtvVE22qK+ZjWA4YzCHL4l
Jose Luis Torrente <jltorrente@caspa.net> /amiguete/

-----SKS KEY-----
key: Aa86V48h3xy+5uoQIzXgiKCBSQN3gm7WqEzh
Manuel Pancorbo Castro <mpancorbo # wanadoo.es>
Como siempre, podemos redirigir la salida a un fichero para su uso posterior. Por supuesto, se puede filtrar la búsqueda de la misma forma que hemos visto hasta ahora. Por ejemplo, si quisiera enviar mi clave a alguien podría hacer:
    sks -ke 00e14ca8 | mail miamigo@colegas.net -s "Mi clave"

Importación de claves

Para incorporar una o varias claves que tus corresponsales te hayan enviado, se usa la orden -ki.

    sks -ki miclave
donde miclave es el fichero que contiene las claves, tal y como las muestra la orden -ke. Si no hay argumento tras -ki, entonces el programa espera las claves por la entrada estándar stdin.

Borrar claves

Para borrar una clave es imprescindible saber su identificador numérico (las 8 cifras hexadecimales, no sirve introducirlo parcialmente) y sólo se pueden borrar de una en una. Esto es así para evitar el borrado accidental de una clave o de todo el anillo. La orden es -kd:

    sks -kd
y el programa emite el listado breve de todas las claves y pide el identificador de la clave que se desea eliminar. Alternativamente, si ya se conoce el identificador, entonces éste se puede teclear como parámetro de entrada:
    sks -kd 40023a50

Otras funciones

Debido al diseño minimalista de SKS, no se contemplan otras opciones (cambiar el identificador textual, borrar varias claves,...) y, menos aún, la opción de firmar claves para garantizar con la propia firma la identidad. Esto último, el crédito en las claves, es cuestión del usuario.

Si se quieren manipular claves, se puede hacer directamente sobre el fichero que contiene el anillo. El fichero y su ruta completa aparecen al final de la pantalla de ayuda. Se puede editar el fichero para borrar varias claves de golpe, modificar identificadores textuales, insertar claves "a pelo", etc.

sks-ecc-0.93/doc/instal.html0000644000175000017500000001351410715702751014675 0ustar nachonacho SKS, criptografía de bolsillo

SKS

criptografía de bolsillo

Instalación

SKS es una herramienta por línea de comandos que no precisa instalación. Las instrucciones de puesta en marcha que siguen son válidas para CPUs x86 en entornos Linux-Unix y Windows 2000, XP, NT. Para Windows 98/ME/95 hay unos consejos complementarios. Para otras arquitecturas conviene compilar los fuentes.

Desde la versión 0.93 no se garantiza la descarga de binarios en esta web: la multiplicidad de plataformas hace engorroso el mantenimiento de éstos. Se recomienda compilar los fuentes o instalar el paquete Debian sks-ecc.

Procedimiento de instalación

Descomprime el correspondiente fichero (.zip para Windows o .bz2 para Linux-Unix); copia el ejecutable en cualquier directorio al que apunte la variable PATH (bajo Linux-Unix, es posible que tengas que dar este paso como administrador). Si no lo has hecho ya, tienes que abrir una consola de comandos (terminal) que bajo Windows suele estar en un icono llamado "Símbolo del sistema" o similar. Una vez allí cambia al directorio raíz de la instalación y teclea:

    sks -ki skspkr
lo cual cargará las claves contenidas en el fichero skspkr en tu anillo de claves. Este fichero contiene mi clave pública y tres claves públicas de prueba (sus contraseñas son visibles en las etiquetas identificadoras, enmarcadas por barras /contraseña/). Ahora puedes comprobar que el ejecutable proviene realmente del autor, mediante:
    sks -v sks sks.skg     *** Linux-Unix ***
    sks -v sks.exe sks.skg *** Windows ***
que emitirá el mensaje:
 [00e14ca8]: Manuel Pancorbo Castro <mpancorbo@wanadoo.es>
SKS. Firma correcta realizada en: 2004-05-10, 13:34
la fecha puede variar, dependiendo del momento justo de generar la firma. A continuación puedes generar tu propia clave pública:
    sks -kg > miclave
donde miclave es el nombre de fichero que va a contener tu clave pública para su distribución. El programa te pedirá una descripción identificativa de la clave y, a continuación, la contraseña. La clave pública se queda instalada por defecto en tu anillo de claves.

Para los usuarios de Windows 98/ME/95/3.1 y DOS

Antes de arrancar el programa, tienes que definir la variable de entorno APPDATA:

    set APPDATA=<directorio>
donde <directorio> es cualquier directorio del disco, que ya exista previamente, a tu elección y SIN la barra invertida final [ \ ]; por ejemplo:
    set APPDATA=C:\Cripto
    set APPDATA="C:\Mis Documentos"
Dentro de éste se creará un subdirectorio \SKS donde se guardará el anillo de claves. Es conveniente que automatices el proceso, incluyendo la orden anterior en el fichero C:\Autoexec.bat o bien escribiendo un guión de comandos (.bat) que defina la variable y lance la aplicación.

Bajo versiones antiguas de Windows, es posible que el programa vaya lento al calcular números aleatorios. Esto es porque la función CryptGenRandom no está disponible en estas versiones del sistema operativo y el programa elige un método alternativo, que cumple la norma ANSI, que es más lento.

Compilar las fuentes

Como todo programa de libre distribución, se adjuntan las fuentes, en lenguaje ANSI C. El compilador usado ha sido gcc; en Windows existe un conjunto de utilidades GNU llamado MinGW que incluye este compilador. Otros compiladores pueden necesitar la revisión del fichero Makefile que se adjunta. Procedimiento:

    make                    *** Linux-Unix ***
    make -f Makefile.w32    *** Windows ***

Para instalarlo en el sistema (hay que tener privilegios de administrador):

    make install                   *** Linux-Unix ***
    make -f Makefile.w32 install   *** Windows ***

Se recomienda editar previamente el fichero Makefile (o Makefile.w32) y adaptarlo a las necesidades propias: directorio de instalación, idioma, uso de determinadas librerías, etc. Todas las variables que permiten personalizar la compilación se encuentran al principio del fichero.

sks-ecc-0.93/doc/andreas07.css0000644000175000017500000000723710715702751015020 0ustar nachonacho/* andreas07 - an open source xhtml/css website layout by Andreas Viklund - http://andreasviklund.com . Free to use for any purpose as long as the proper credits are given for the original design work. Version: 1.1, November 28, 2005 */ /**************** Page and tag styles ****************/ body {margin:0; padding:0; color:#303030; background:#fafafa url(img/bodybg.gif) top left repeat-y; font:76% Verdana,Tahoma,sans-serif;} ul {list-style:circle; margin:15px 0 20px 0; font-size:0.9em;} li {margin:0 0 8px 25px;} a {color:#d85d5d; font-weight:bold; text-decoration:none;} a:hover {color:#505050; text-decoration:underline;} img {float:left; margin:0 15px 15px 0; padding:1px; background:#ffffff; border:1px solid #d0d0d0;} a img {border-color:#d85d5d;} a img:hover {background:#d85d5d; border-color:#d85d5d;} /**************** Sidebar area styles ****************/ #sidebar {position:absolute; top:0; left:0; width:220px; height:100%; overflow:auto; background:#e0e0e0 url(img/sidebarbg.gif) top right repeat-y; text-align:right;} body > #sidebar {position:fixed;} #sidebar h1 {margin:20px 18px 0 5px; color:#d85d5d; font-family: Courier New,Courier,monospace; font-size:1.6em; letter-spacing:-2px; text-align:right;} #sidebar h2, #sidebar h3 {margin:0 20px 18px 5px; color:#808080; font-size:1.1em; font-weight:bold; letter-spacing:-1px; text-align:right;} #sidebar h3 {margin:20px 18px 4px 5px; color:#606060;} #sidebar p {margin:0 20px 18px 5px; color:#606060; font-size:0.8em;} #sidebar a {color:#808080} /**************** Navigation menu styles ****************/ #menu a {display:block; width:202px; padding:5px 18px 5px 0; color:#606060; background:#e0e0e0 url(img/sidebarbg.gif) top right repeat-y; font-size:1.8em; font-weight:normal; text-decoration:none; letter-spacing:-2px;} #menu a.submenu {font-size: 1.2em; padding:3px 18px 3px 0; letter-spacing:-1px;} #menu a:hover {color:#303030; background:#f0f0f0 url(img/sidebarbg.gif) top right repeat-y;} #menu a.active {padding:5px 18px 5px 0; background:#fafafa; border-top:2px solid #c0c0c0; border-bottom:2px solid #c0c0c0;} #menu a.active:hover {color:#505050; background:#fafafa;} /**************** Content area styles ****************/ #content {width:520px; margin:0 0 0 240px; padding:20px 0; background:#fafafa;} /* estos son mis propios estilos */ pre { background: #e0e0e0; font-family: Courier New,Courier,monospace; /* background: black; color: lime;*/ } kbd{font-family: Courier New,Courier,monospace;} em.math{ color: #000000; font-family: serif; font-style:italic; } em.func{ color: #000000; font-family: serif; font-style:normal; } th{ font-weight : bold; font-size: 11px; } td.math{ font: 1.1em serif; /*text-align: center;*/ } .math{ font: 1.3em serif; text-align: center; margin-bottom: 12px; /*background: silver; margin-left: 3em;*/ /*padding left: 0.5em; padding-top: -3em; padding-bottom: -3em;*/ } /* fin */ #content p {margin:0 0 20px 0; line-height:1.5em;} #content h1 {margin:0; color:#d85d5d; font-family: Courier New,Courier,monospace; font-size:4em; letter-spacing:-5px; text-align:center;} #content h2 {margin:0; color:#808080; font-family: Courier New,Courier,monospace;/*font-weight:normal;*/font-size:2.5em; letter-spacing:-2px; text-align:center;} #content h3 {clear:both; margin:30px 0 10px 0; color:#d85d5d; font-weight:normal; font-size: 2em; letter-spacing:-2px; border-bottom:4px solid #dadada;} #content h4 {margin:20px 18px 8px 3em; color:#606060; font-size:1.1em; font-weight:bold; letter-spacing:-1px;} sks-ecc-0.93/doc/img/0000755000175000017500000000000010715702751013265 5ustar nachonachosks-ecc-0.93/doc/img/example-small.png0000644000175000017500000000070210715702751016533 0ustar nachonacho‰PNG  IHDR€€ôà‘ùgAMA¯È7ŠétEXtSoftwareAdobe ImageReadyqÉe<lPLTE䮮躺ÑuuíÉÉÖ„„îËËíÈÈëÂÂ׆†Ê__ÚìÅÅè¹¹Öƒƒá¥¥ïÏÏÏnnÊ``ä­­Ü••㪪泳ݙ™å°°á¤¤é½½æ´´ê¿¿ßŸŸðÑÑ㫫鼼ࢢëÃÃç··êÀÀ¥f°eÜIDATxÚìÚ9RAÁåF܇@ Ðñÿ?â§³æÈ¨²'fs½Ž‰ž>éÖ3}“÷½Ð‚¦ ÀpÀyá6´¢Gz¥s  @€ŒxÁžnèH_tK—´¥ Àx€†8Ì´£;z§É @€ÃW$àƒ~I€‡çx @€ã×äÚÍ´$"ž)@€0àrO>H8p<‘Œ?äÂD€àôgôF.,øárA @€“ü 0Û%¿L~ØùIEND®B`‚sks-ecc-0.93/doc/img/example.jpg0000644000175000017500000002106010715702751015421 0ustar nachonachoÿØÿàJFIFddÿìDuckyÿîAdobedÀÿÛ„   #%'%#//33//@@@@@@@@@@@@@@@&&0##0+.'''.+550055@@?@@@@@@@@@@@@ÿÀ "ÿÄ™!1AQa"q2‘B¡±R#ðÁÑáñbr‚’²Ó$4!1AQaq¡‘"2ÁñB±ÑRr‚ÿÚ ?ÑB`zÁB2H‘$@‘¢1bÄbÆC.»L|ǽ&²hL†·Æ tY7{F:õ§IÚfg;Û—·ø\בèUÂ0åú®Åæp/X¤bûÅå{jWF«ƒ~¨›ÐØœÌD­’ܯsÁÁįʖ¾ÔPYÜáß´¤àÊÕmÂÉÓ¿m'‹å~«ç½Œxã doüŽŸ²`Ëï~çšÃòrø°A_ô©?¸ðù®µ>€Ä¬Ï“"m€ø°Ÿ=ÉÍäeÓ#»ù³³ò&PæbA$é籉òx.¿ÄK[ûד™{HF wH¹ÆÏÉÍëZj7°œ#™îÃFÖd/+:û§Nš’$»Iµ8•zɸåÉz_Í|LÙ(íGøÎZóù A9 õ½Çî9ÕƒzXu4¦â5yZ#Õps1Ìë«ØÇñ}Ṋ^ÃWòi×Ãï\<Š dìbkµô6|O(äÍü¥¥ºï=jKm¸Zҕ㢵—Ôô ö1ceFƒ 5bÌÕ  P­uÕfg`Øû|Ž£}¦|YXdF½kqåIjûZ]àí~Ì8þáÏ,@Òä7ÃFhýï>ßíGšüüà d VÃ1b Ø($ï<Ö,ù0çÌP]Y oÚÛÅò09ªòçRºœïíp§SëþÕï¾Ûï!àeûŸh€à©R;¶4Õá+îü¿·‚æoJâgοHs_Û=ó “éä‡ øê¿´O[î|¡±mTÚªø¨úã¤-l‡Šnœ~g1»1#z»Û!Üu×§—úÄ«w’XMtìU”äÉ}ÇT]´ÿ8·*ÔŠÅTUÛü¦'¢‘7d $nZ[ÐÌM*ÉPê”À·PT+w˜×wJnå¦ ý'@ ¸†  ÚHÕÆq‚]mFÆ·#S¨´ñÒ‘J¾Ý]ºžàu“v@¹½ ¿)zQéí®Ñâ%ޥޭ½Ý˜RŒ=]È …:øTSu×à7r§V!:“uw:\?cä笙/„ÑÀ9Xy!Ûþß„oAZõ¢›89XÑóåTĽÙè¢ïý'ªöî"¨KårL¤X€ðQÐJ'‹ÂR¼t [FÈI.ß?»håm7¹¥T¼¼Žë¨Ì™fl™!“ fgÉplŠÔ¦W¸‹–f¸»’n*L.DE"€ÊÂBáD2!@BŒ“­BYÎ*„E “@e„ºÊ u,—jS0Ñ|µ4æjœ\}ùløõƒ*¸MN(íÆNl…nôŒÆ”²2ámL®‡<­Ù9Ù\–$i]dcÊCNÚ\3§að³Ö R4ÚIºI£G¹s3àá«ñœcÈî¨Z!h“W<îBìÅ‹»jKÌO™q/áW®ÅVb ׸Ÿ €«X­ ›<›pÑ*ùbûYoMzÊzw4Q€ÇR6ªU{Ëhº[I6Ðö+¯Íà%° }¿p‚H¾îã©2YúƒŒYm:ùü#i{(Ú {ÆK} ¹´Ͱ• Š Qlzï,̸‚ “¯hé-Åáòy„ž.5LcC•Ïjÿ™ø@R’—…ÜÌÌ«}Þ€$M¼hæòÈË_g r %Oð¦çâjux~ÕÂá—(Ž@õ}ǪØ>;Çä÷Æ×[”ªº˜ßžÏkþ™n7µûŒŠƒ&efÉêaÿ‹ÿQ/Èå*ƒG¤É““™þ›£3¸È}Og¨YSØÅQ·7rÉNBIØVËZ ¢Ð±&ÅHy&°¤£å$Å&K e F‰" •’dDQhBð„#xB0„ „!B¡Ff.„C*$‰DH—R*PIº‰‹Îñ¼ê¹;3O¨übZ•eôüDPí1âË4Œ‚¦ˆâ²rcæaR ©Îí*ã]vîßS:|ŒŠwÞs²ÝcR,€:к’͸æ ãŒFÅ‚Ïq êIú¾rË‹#è4SøÝFc¦@Êtu w£bK1Ôw:\ƒ®X‡ã=33wbÛ hü53G­ô­­v‹u-×]¬ ˆ¤Ø¯²Äš_€”(Ë©Ô î9qºÕµu°$²7u£¸õ 93S¡%|噦¹zŒ{q‰ü¶ ŸGSþR€­öÝu¡$Vàƒó• kñ½Œ£Nà޲¥jÉùzL@$‚/r:źdmå¼ÐP“¥Þš*·1’êe"ˆ7æÒ08"‰ÐìF”e›ê£[×Â-”ƒDQëÑpJê Ž¿)|Á9¼°ä£é£~OÛûâU¨ëcÆKP}'¯…À5M=CˆÅñ.DÔ04G…1Ä„*£@°IÜ lÙÍãŒàrjÙhe¿ÌSç¤çï`I:u¤Ñ9Gªèã¿Ûè87ijÔÐ üfŽ7ò³ãÀºw‚,~P5îùL–lÝYˆž‹ÙxËß`>ç"‚î+ý›÷Aà®5¹ÁÐÈ1¯f4©‰AjU³;‘™ØúWPzP‡#(bì†ÁnÔÁ}7ó‹b„&Þ?ØÌ™ÛUœ6ÎÙIíê4Ø ¦’½ÔIFÌ6h¼(Ô¥´Ôv§]&²w³(¯Êt¨Ð¬àUöU*‹ uÖBýÌŽ6É’´ ßøŽÂná{G/šßqÇÙÀÔCŸ©‡ûWûÌô\Ooãñq XWµwc¹câÇÆR«~ 99éL/ªÞÇ ‡ìOaùm÷Cö”Rù³®¸4T@TRªŠà&îÅ]†±L >RÕR9mÍk¼˜[ ¹¦&IøXÔmò›¾Ý2¤„÷¢36%Q@LÙk5ea2ä12ë"j®-ŒcE4F¨–2†Y¥ E"Є ¡DQXBЄ !°„#hBB€ŠBABdI€ Ú$Jä4¦1ç:Í|!¤Ã½S_è\KSK¯¤êâ^1`\N€Ç;ŠÞhr9“!œþ“ÝgC¸fbÚž¿‚„±=$³j¸F ª¸ò·`µb¨ºVoª¾;×I¬ß”¾½&¼ü5ÈY—#bÊ@õ)´%~žô#_ &\Ÿwÿ²¥S@¬=X‹tõô¿%£ZÙ= ö;gC U2 "²ŽÒ[fÔ„kP96­¿l;@Ó·åþ1")Àîë¶Ú‹”|L@¶¢7'SQÅ‹!GSqL½¶X±½”Gœ L;\ÕsäkyFG Å·4/ÎYŠQaJ½N± ™4£g ;íHp'êíÿ°;ˆv  N½kHƒÉÆ,µP-ÖGõ)coÆàYP5.´62ªm†½ÁÞ =ºùé¼°e:0[èÛ Ka^ €ÕbÛ;‡p>‰µWÖkPH6 ùK Tn@Ê6 *m–ÆøŽ„î$j4:‚5£“×îc&úŽ‚bÏŒ%” ámã’c(ÌÙ'ý¡'asÊÀxÙ»€þ[ê¾Zí5ç%ÁZ:î Zä%>Æe,§c¹ÖnH¶4ÿç°Ž>#Éä&йüÜÏOŸ>,XS‹rŠ«Z•Q¿Ìζâ|¬D¸R¸Áú¼¾hÅË|žœOݨ T“µ+…Ee¬·ì™A´Ƶå .¦óä4Mö/€™Û‹È ulh,’À­™jV^…Ç´údßCgõøñ³§vCP”j{ž%+Ÿì?'¦±¦Jǃƒ·vùL …V´ÔîjÌz¨ Û°èõbrdS´ñ‡ï¸Ã>.K;)¢¬ƒgJ5‹õ7»cjÈ+x¢ýcÞ‰ÿÍeÕŵ‹iÉâ~ äò(Bz”²?têãfÉŒ3ã8Éü­Wû!)‰ÒÕÔÌbš9„KÄhˆiC,dŠ&„ˆB„!/B1BV„¤!Š-B&„b-&@“)”zc@”Ê=&µ9ÙAïš1ª"™o$ÒˆhIF¶xFœL@¬ºÊcZB%ËG=™Ÿí±4†Äv#O­TuçüaÞ`‰é§Œ¸ÀXQz@"jû"öÒ51àOääöž;·c#u8Ø 'á´KðSÕ²5=L*¾Bz#ki“‘‚ƃÎ'T:ó[FÎØT$!o=nïå(x¸ZÙ՛ȱ©¿&I¯„[¥ ~bL«ù9ÙxhWùh Ö‡s9<ÏoÌ×W㦂zdQÞœÑ“Ç æeD]ÝôQpÛØo‘DYJgγq3c:Y>Ä…ÎOÒoÊ{lü|Ù—´^¹3)[ÿ†=ÿòŠ_lT>µî#ómûÐÜûI?µG•g_—N4€@"öÖ¶–þ—ž¤H‚Lõ‡ŽMà*¨lu”(VÓ*±QéÊ\tèíó<ææ£H#©$'K Õ9† IšŸ YB²ï­‡Àº[èjK6¢…ß©Gæ—µD`:±bA™r°8Ž@”«õMk46"§o‰S"»a8K“‰ˆcŒŸIaÖ¢N0rñ»¹6u²@ð©Ãáã ®,÷-š™ÏØ Ööþo1.ìØô¢Ì–Íe7&U«®^Y»‹‡‹€sfdÆ1g+•Û·¸ ý·å3r¿Rr2vâöÀx¸|̪Ùrà …¹½«9òr±zT0ìb(0ê©…øí‰Š¸®ÝÎÿ„&q«ÙîsÖ å/•¾ï##eÈN‘‹0‡¥bhu=”Kòd)NLƒe(ñ&]1³ì¤vl¦O©ªkJôË‹PuÝŽ€ÅÀ^Õ[—ð‘«Qã3bVQà,  6Ú%qeîFº tƽ§ =GŒPäãsÚ–oÃhÔg7 ^šêc%ÉݬV»Aò’]qžôWqÒ TØ–ð¹rº)ØX0 Ÿ] ÷ !¶¯„ê{/$cq‡’QÕ€\9Mèc-×ý·ððœ¤d®Ä}'Â]‘À«ú[b¦ôÛÀÆœ9&ôÝWSذÒ!ÄÁÁ÷"˜y Ü…L‡êîè¯ãä¿#kCy¬ÉÀèêáüÌÓCÄ0’ÍjV¥H©Fˆ¤È2 N°±Œ„Žè@’Є#²a€L!g„!fxBt¡J0B’$ a,¦_¦0JdÚZ˜;o,؉ ŠÆ—™µ {4B •UK(Á¹. µÅÜ.2`hÞ]H7$4Ñ •d !MÆ,dèdÍÆMNg,v¦Þ3¼ê Ôã{šö‚çI6F¼6–‘’{qJ:·„c g\™û²d]UoЇý«µùï+02 é'p?Î95?CyÁRŒõ_Äk"Üÿ‡ŒK bßd„Buf­ßHFî:7Ð$§p Hð$G„ŽãæN’¬QP»ÀRgþŸRã$êS/·c'¸*©­Ô‘©Œ9󫤲.µ¹—‘È÷67‰Qhu±ŒX-oèãâ+'·dKÈïM¼çò8ü¬gÓÙo[™Ï¾ä&Š¨Ú“ÂaÉÁ÷´Bù9îh¬!¾Ú5gþ±ø€äçF¬¸ mÜ´Dép ¹VÇ™ ³‡Ÿ#úó»ÀÞkâ²áÉ݈’P‘m­ž±8]šÌçMÑ>ǨLÉ…Yßw¥ üZúWÊWí­ÊÃkéȬU”ú@mg'?¹eÈBåvüÖPúwˆÏî|ìØL…—+}̆‡sðÒ9ZûwM5†eû<–ïN$~Ϩ÷(ò¿Vó/‡úƒ@2ãûa…‚½¥Hø‹šñæn>UȺëL½Nâw}?ÐŒ×÷8§Zܨ?áã ^»œ;Zªt®;Æö®SSr29&½::˜=¿ èîcã½ §ïág`¤_k乡[’†²c\YÓCøC/Q¥Z¨ªù¼û™ÓŽ€ŠP£cÒ¥‡ ïg­õš>⑪”½ìK(GúH¿avftÀŒhc¡ØÔŸ²ÅFõ/åcÒ8*†õ€Oì¹ ès±ÁÎÙ°…ÈCfÇ£‘» ô·Ì~ÙÌD`ݪÀ(w IÅ“&¹Á ã 0ÿopîFœzîQò;L¦¢™j=ÙTY:Æaäó±c5b[9ê›ÑbÔ̹¹ºL¯Ï|ǵ4_ßÔÝ|dÌèj©·6'ï–:K fÖ18Ê‘ eÐT™$ʘÈ"„&„E„!baDQHBÕ„!(çB%„¨–a)“ia! Eâ_Q3Rˆ¬B£„¬Æ iA-™h\‚dZä‰Né ˜ C¤€ÄK©&2ZXœrG¤€Ä?ˆôüçLßo÷ÎG9A`Þ§"¼€?TVоõ $Ù±Gk@²÷ðQW»ÔÚVÒã° d› R„Z«7‰m·“§ åÀvÓ¶¥×·ö0hGk~aó&¤ý»¯A4v­h(R¨»·Ê„öY¥¿ áý:Üôk~èßQ>• t³'í†ÚùBqœ*·§Ùw„ç{²âÁŠò¹•…Û/Êv3åN6Èä*¶ÓËä9}Ó–O¥ÎçeQ¹ŠÝ8åͺ!.¿k€Ü“¦Lì1q”î¾câùïùX½*|[ó£Þr±uLK¸8I±¹+ýÑ\”_¿„dºø(™;ß"Õ5ñ—â'gûEüfEÌÜ2â:wGÊ(Ö viqÏê„þ(a!ò7ô$B'OÙ9%—7;RŸK©Ýoªüg#Ü'%œGP:©Þh ”ªûŸVÄu™â>Æo['­sÿ/û›/+Ú9­öY®ªËå=G 3òx8ùª¡ñäJj¼g7›ƒ¼{ ä`¦Í€w ¢GýfïÐÜõn6n.F‡½AèRFw³IÆc?ÚZô|«¤>Ò>¬ â>zp˜÷’1ä;:ÐüGYÇÍ›ì¹'·"žkP:YÙbQ?m‰°ä €»…:éÜu±F¤/#Y ?£;”‹«ÔÄ^z¢´ô»¯„²³…kPA“A)Ôn.·‘}„°äˆÄ:·n‹{6â4I&ô¢ v‘sâZ`ÀŠÔf¡ýC?§$ìXx- ÙÌʨ¸ÒÁµ”Ý€“œqò9tìcáXîÊK3d\°ÆŠiGÎ&›Ô+ÉZ¨ªÏrœ."ã‘gÆt@Dá 1Žà %¬Ý»1YŒXfc©µUD,ƒ Œ %À™dDQHB(¬! ´!ÑB2B$ÂŒ "VLX*Æ1*00ˆBjXY€šªBƒPd$FN/Ò@³,1. BÂÔ°“r¥HÄÆÐ©Å䲿!™€ ãGÕûg]Ú”Öý'vh,Z¶²b±|KVB©;€A•~•ÔudÙà’Oh¡$ѱ‹JSÉ]-Œ¨^µg©2H£GSã$[]è$ökgS$6üe2gà æeEÉc@@=tî;yÌ\ÏpÁÅÆ[)6XùN»þ­EîÃÀûƒ•…œ!ÉÏÊ?w;—fêNÑ2ª”ÃËì‡ûÏêG5þØ1)Ñ/Sñž‡ØñbÅíïÏä ´Üô@?¾p=³Ú¹óB~Ö2WéÛá=W¹qO+/jã·¨ça¥*ô†·e7‡ì‘Ìý?Ãt÷<žë+ ’0)(foÖŠŸÖqøXï»)Ô|ç³á`ÃÂã®<@€<ÅsÛúÿÕ€¦B= MÙµÑÅ~o'k±*ñ•‰ÔGÃI乸Fzn¶½î}-P n´ª©äýóÚÀ÷^?"M¦ñBYðR½¹×ÒÊËàgäûs*Ël®?Sé®@\ù}¿)ô‹íÌí=Zñûp2±ºùXž3™¸>ô™G¤;kÐD—BïijË¥¶¿KŽ.Gö?r=Ê[Ûù&˜~U'¬¯/‹ŸÚ¹‡‘ñÆÏgèÝ.v[rpu ¬(©‹ã"}¶öîQ¼T~ÆSºˆ BsÛTqO7—˜ÌH:ÕËâLö I“—‹›‹É8r mчÒËâ&Ì8‰õ9ísç Ý4” ãñ˜•Zž¤u<<^2¨9A$î27!pŠS@ y,ú.€ÊPŒ¬­oèfn5=¸•‰ñ$ÌNRU*ÝkåÆãdÉE¶,GâUޱ6iZ$²nþ©j†òØ%xø„‰³±h $¶“ÁÎC”­&…ËCÄ˰]€ª7ˆm§ÐYf:ÊkÒ†ŠH’d@¢Ð„ ˆBh„!˜B€„!ËBŒDÉ‘2*`(P"Ö\ ŒY}â”ÆˆÉdB€ŠI‘$@`±ŠhE‰nꀘgÈLãäå&2CšÔŽã®ækæfô°½Á‡É{±{ŸÂM™ÑÃÇ:dω–Ñ’ ºçÄ –`nIyæÁ7¡ l|%‹+{Ó{ÒNãWÀ»üžåÄM(øYýÓ&_⢊ÙATÎrJ³h¦,ñÛO·1® /&ìÿ¨¹ …qcTcù‰î©çýÓËå¿~|…Îà7åÄ_ 8×Ê4Å~4–0sËâ+´^´‰ŒÈÐé;^Ãí«É嫺Þ,^¢ÄÊ“S-é¢ö>öÿo^ñü܃»!ëmþ£ÆÂ=YXzŸ¬†õv ÛsðJ€ €ÐxF‘·¿ô)ö£^¾yÓÜfÏï¼ÞSàŽ@'Æç¯ÎÁq;¶sý‹„œ\ çëÎìì~pzޏ£~Nº¨ ´6œ¿zÄ1½C‚O”ê÷Ãû&t^þ; ?„vО'Oȼkh—ZÏ;úŸÛN\Ôb_æ!îÓÄN÷¯Öº ¶|jëÚTÛY&« §£Ã9>ÉÉ<Ž&6#UGQã6r0+Ž¡—U#¡™}¿àågÄ‹@¥Õí €¬K(»½¶“ „οÓòµÕ[ªå9|Ûáp|C¥‡ˆ¦Ãn uØ L¼tÎ¥2-¯CÕO”*—Iøìqøøß+kd’'cÁíífåÄá @]:ÍD…Ò ½Éäå—*Pi°Š|ù]»1œ>$Ñ›C3¿ºñ±XPXôé~H­[Ò»‹žäõd{ò•ɇ%Óy‡7½foN5íçåò¤Ÿœ—eÐÚ¼WýM$l|ŠM/‰ñ Ø_„ÅÉ}N“B{VmËTYì[TJ7 9pÐõ ó1ì÷¶¢r?þvUã8Ç2?aºê%Kìfé]U¤ØN°º”¸\ …¥.€„!‹Â€‡BŒ‘°„ H˜B(!DB0&“)&DF‰Eª±ƒ`½#$*ËÖ!² $‘"£$È`¥25 bfnF@žaU,ËÏÍB§3–3W37s3:ã-©™7'ov¬•POHÔÆ|#“ë4¦ Zâqñ¯HÇÀ£Z²F³HPÒ™Ž’ Ëslãs´¹ÈÏ{ úN¿1®ÿ°œŒ¿]õ¹+Ský¨®+3E’E3=§µpÓ‡Ä^áüÆÍñžØñ®~XîúPwŽÂzÒAíA¹Ûá)w0äi%U×,¾ôýÆÝ¿`; tð‹QK]<%=~rÎv+”Á07jQÇO·‰F€žG­ñŠÐ6³HFêíKâI°5˜ùÌ>Ó)׸TÖͧÂs=Ï(Uk;ÁèjlŒü7¼+­ÖšÍ}À½:NO·g'¹oó\Þ[¸)ëã!<¬Y™r¿Ùç¦oË•{â'F©C®Æaæ dR+6q˜60„Ø¡GÊ5«þÚ¾ØeÊÚØß¡‘Œé{9z£Gå  øÔfb³;qÃ5ZÕéÒ§'?¹äÊOf‚v²¨l6wÐkç9éíh–Ç[$þ2Z} xÝ»,œ†lÙ7¸ï ÁPPZ©Ÿ6dAÒ¯Œ(˜@F hÒSP*HÊ€±‰Ë:(@$–"#žÛ;Ë÷wJ0k$÷X2¦úÀT‘—¨H¸@“L!È4BŒ€„!B"‘–„‰0ÿÙsks-ecc-0.93/doc/img/bodybg.gif0000644000175000017500000000015310715702751015221 0ustar nachonachoGIF89aБøøøàààÀÀÀ,ÐDŒ©Ëí£œ´Ú‹™ û†âH–扦êʶî ÇòL×öçúžoÙ ‡Ä¢ñˆL*—̦ó J§ÔªõŠÍj·Ün·;sks-ecc-0.93/doc/img/sidebarbg.gif0000644000175000017500000000004310715702751015673 0ustar nachonachoGIF89a€ÀÀÀ,„Q;sks-ecc-0.93/doc/linux-man.html0000644000175000017500000001420610715702751015312 0ustar nachonacho SKS(1) manual page Table of Contents

Name

sks - Provides public key encryption/authentication

Synopsis


sks command [args]

Description

sks is a public key application for encryption/authentication, based on Elliptic Curve Cryptografy (ECC). Its minimalist design points to simple, light, fast, easy to use and multiplatform product, unencumbered by patents that is indeed distributed under GPL. All these features are given along with high quality cryptografy.

Its cryptografic elements are:

  • Public key module: elliptic curve over GF (2^191)
  • Simmetric key module: AES 192-bits key, with CTR mode
  • Hash (for signatures, HMAC and passwords): TIGER (192 bits)
  • PRNG module: /dev/urandom. User can provide her own entropy source

Options

-l
Shows license terms.

Commands in interactive mode

-c|-C pfile cfile
Ciphers conventionally pfile and outputs cfile. Uppercase precompress pfile. Password is asked.
-e|-E pfile cfile [keyid] [...]
Ciphers pfile with public key(s) identified by keyid(s). Output is driven to cfile. Uppercase precompress pfile.
-d cfile pfile
Deciphers cfile onto pfile, whatever the ciphering mode was. Password is asked.
-s pfile dsign
Signs pfile and outputs detached signature to dsign. Password is asked.
-S pfile
Signs printable pfile and outputs through stdout the clearsigned text. Password is asked.
-v pfile dsign
Verifies that dsign is a valid signature of pfile. A verify report is output to stderr. If verification is OK, date and key id. of signer are given.
-V pfile
Verifies clearsigned texts on pfile and outputs through stdout the original texts. Verify report are output to stderr. Wheather a good verification is found, date and key id. of signer are given.
-r pfile [...]
Outputs the TIGER-hash of given pfile(s), in a ’md5sum’ fashion.

Commands in filter mode. Text filter is introduced by -f. Binary filter is introduced by -b

-fc|-fC|-bc|-bC "passw"
Ciphers conventionally stdin with password string passw, and gives output through stdout. Uppercase precompress input.
-fe|-fE|-be|-bE [keyid] [...]
Ciphers stdin with public(s) key(s) identified by keyid(s). Output is driven to stdout. Uppercase precompress input.
-fd|-bd "passw"
Deciphers stdin onto stdout by means of password string passw, whatever the ciphering mode was.
-fS "passw"
Signs stdin with password string passw, and outputs through stdout the clearsigned text.
-fV
Verifies clearsigned texts on stdin and outputs through stdout the original texts. Verify reports are output to stderr. Wheather a good verification is found, date and key id. of signer are given.

Commands to manage keyring.

-kg
Public/private key generation. It asks for a descriptive identifier and then asks for a password. Both can be input in a pipe through stdin: the first line is taken as the identifier and the second as the password. The public key is stored in keyring and is output to stdout. The private key is not stored.
-ki keyfile
Imports all keys in keyfile. Alternatively, keyfile can be piped through stdin.
-kd numid
Deletes key identified by hexadecimal id. numid.
-kl [keyid] [...]
Lists the hexadecimal and description ids. of keys matched by keyid(s).
-kf [keyid] [...]
List the fingerprint of keys matched by keyid(s). Fingerprint is given in base 36, with ICAO alfabet.
-ke [keyid] [...]
Exports the keys matched by keyid(s) through stdout.

Hints

All files are parsed in a streamish almost unbuffered mode. This means that in interactive mode, pfile and cfile must not coincide. Unpredictible results may occur otherwise.

All keys that matches the patterns given by keyid parameters are selected. keyid(s) can match partially hexadecimal and/or description identifiers. If no keyid is given, all keys will be selected. Exception is -kd command, that only admits one hexadecimal pattern that completely matches the target key hexadecimal id.

Author

Written by Manuel Pancorbo Castro <mpancorbo@gmail.com>.

Bugs

Report bugs to <mpancorbo@gmail.com>.

Copyright

Copyright © 2004-2007 M. Pancorbo - All Rights Reserved This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, Inc.

See Also

Complete manual and design notes (in spanish):


 http://sks.merseine.nu

sks-ecc-0.93/doc/index.html0000644000175000017500000001362610715702751014516 0ustar  nachonacho



	
	
	

	SKS, criptografía de bolsillo







SKS

criptografía de bolsillo

Novedades

[Noviembre 2007] Versión 0.93. Se ha cambiado la librería matemática a TomFastMath (tfm). Es una mejora del autor de la anterior librería que busca mayor rapidez (no hay 'mallocs', hay operaciones en ensamblador para determinadas arquitecturas...) pero, sobre todo, aprovecha toda la longitud del registro (32 o 64 bits) como cifras binarias efectivas. También se ha mejorado el multiplicador GF(2) con técnicas ligadas al método de Karatsuba.

[Mayo 2007] Nueva versión 0.92c. Corregido un error que impedía el correcto funcionamiento en arquitecturas de 64 bits. Los fuentes ya han sido corregidos en la sección de descargas.

[Junio 2006] El programa ha sido "debianizado" bajo el nombre sks-ecc. Gracias a Nacho Barrientos por su interés y su iniciativa.

[Junio 2006] La nueva versión 0.92b corrige un fallo en el cifrado de ficheros muy pequeños. Se puede descargar aquí el parche para la versión 0.92 (sólo fuentes).

[Mayo 2006] Para los usuarios de linux, está disponible un interfaz gráfico (un frontend) que realiza sencillas operaciones de cifrado de textos. Disponible en la sección de descargas y también en miscelanea, donde se da más amplia información.

Introducción

SKS es una herramienta de cifrado/autentificación de clave pública mediante línea de comandos, basada en la llamada criptografía de Grupo de Curva Elíptica (CGCE). Su diseño minimalista está orientado a la criptografía de bolsillo, esto es, una herramienta muy sencilla de usar, transportar (el ejecutable ocupa aprox. 100 Kb), multiplataforma (Linux-Unix y diversos Windows, por el momento), extremadamente rápida, libre de patentes y distribuída bajo licencia GPL. Todo ello sin comprometer un ápice la seguridad y ofreciendo por tanto una calidad de cifrado apta para los más exigentes.

Sus elementos criptográficos son:

  • Módulo de clave pública: curva elíptica sobre GF (2191)
  • Módulo de clave simétrica: AES con clave de 192 bits en modo CTR
  • Función resumen, para firmas y contraseñas: TIGER (192 bits)
  • Módulo pseudoaleatorio: /dev/urandom en Linux-Unix y CryptGenRandom en Windows

Está basada —tanto en filosofía como en parte del código— en una aplicación llamada pegwit, que nació a finales de los 90 como contrapartida a un cada vez más super-sofisticado PGP, lleno de funcionalidades superfluas y con un tamaño cada vez más creciente y aparatoso que hacía difícil la evaluación del código subyacente. Pegwit usaba una curva de campo compuesto (no primo) que se ha mostrado débil tras los estudios de Gaudry, Hess y Smart acerca de este tipo de curvas. La curva de SKS es de campo primo y reúne todas las exigencias de seguridad de CGCE (orden primo, condición MOV, etc). Todo esto se discute en el diseño de SKS.

Incluso con el desarrollo y popularización de GPG, una herramienta como SKS tiene su razón de ser: la CGCE proporciona claves y firmas más compactas que RSA o DH, para un mismo nivel de seguridad (la curva de SKS es igual de fuerte que una clave RSA de 1024 bits) y además es mucho más rápida: en aritmética de alta precisión, tanto en GF (2m) como en GF (p), las operaciones aritméticas normales "cuestan" del orden de m2, mientras que las complejas (como la exponenciación modular) pueden tener un orden de m3 por tanto, en principio, SKS opera entre 30 y 150 veces más rápido que GPG con claves RSA de 1024 bits.

Además, GPG sigue siendo un programa muy sofisticado y pesado. SKS cabe en un diskete, no necesita instalación previa, no conserva claves privadas y su uso es inmediato.

sks-ecc-0.93/eccrypt.c0000644000175000017500000002616110713725433013567 0ustar nachonacho/* * Cryptografic primitives on Elliptic Curve Group * (Part of SKS cryptosystem) * * * Copyright (C) 2004-2007 Manuel Pancorbo Castro * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Manuel Pancorbo Castro * * */ #include #define _ECCRYPT_C #include "eccrypt.h" static vl_number point_order; static ec_point curve_point; static _ecpoint curve_prevs[16]; /** 16 first values of j·Q **/ static vl_number uno; static vl_number menosuno; static int ECC_Init = 0; #define eccMod(DST, SRC) fp_mod(SRC, point_order, DST) /*#define eccMod(DST, SRC) {if (DST != SRC) vlCopy(DST, SRC); \ while(fp_cmp_mag(DST, point_order) == FP_GT) \ fp_sub(DST, point_order, DST);} */ #define eccInvMod(DST,SRC) fp_invmod(SRC, point_order, DST) #define eccMulMod(DST,A, B) fp_mulmod(A, B, point_order, DST) /*#define eccAddMod(DST,A, B) mp_addmod(A, B, point_order, DST)*/ #define eccAddMod(DST,A, B) {fp_add(DST, A, B); \ while(fp_cmp_mag(DST, point_order) == FP_GT) \ fp_sub(DST, point_order, DST);} #define eccPointSub(DST, DIM) fp_sub(point_order, DIM, DST) /*#define eccSetPoint(A) ecCopy(A, curve_point)*/ #define vlRead(A,B) fp_read_radix(A, B, 16); /** Sets the firs 16 values of k·P **/ static void calculate_16 (ec_point prev, ec_point in) { register int i; register _ecpoint *out = prev; //gfOpen(out->x); gfOpen(out->y); ecZero(out++); //gfOpen(out->x); gfOpen(out->y); ecCopy(out, in); ++out; for(i = 2; i < 16; i += 2, out += 2){ //gfOpen(out->x); gfOpen(out->y); ecCopy(out, prev + i/2); ecDouble(out); //gfOpen((out+1)->x); gfOpen((out+1)->y); ecCopy(out + 1, out); ecAdd(out + 1, in); } } static void ecMultiplyAdd (ec_point p, vl_number k, vl_number j) /* sets p := k·p +j·Q Q: -> fixed point in the curve It uses projective coordinates It uses first 16 previously calculated values of k·p and j·Q */ { assert( (p != NULL) ); assert ((j != NULL) || (k != NULL)); //assert(ecExists(p); register int i; _ecpoint prev[16]; /** Table of first 16 values of k·P **/ vlPoint kbuf; /** byte buffer of input 'k'-number **/ /*zeromem(kbuf, GF_SIZE);*/ memset(kbuf, 0, GF_SIZE); vlPoint jbuf; /** byte buffer of input 'j'-number **/ /*zeromem(jbuf, GF_SIZE);*/ memset(jbuf, 0, GF_SIZE); if(k != NULL){ calculate_16(prev, p); vlPack (k, kbuf); } if(j != NULL) vlPack(j, jbuf); ec_projective r; unsigned char c, h; //ecProjOpen(r); gfZero(r->x); gfZero(r->y); gfSet(r->z, 1); for(i = 0; i < GF_SIZE; ++i){ ecProjDouble(r);ecProjDouble(r); ecProjDouble(r);ecProjDouble(r); if( (c = kbuf[i]) ) ecProjAdd(r, prev + ((c >> 4) & 0x0f)); if( (h = jbuf[i]) ) ecProjAdd(r, curve_prevs + ((h >> 4) & 0x0f)); ecProjDouble(r);ecProjDouble(r); ecProjDouble(r);ecProjDouble(r); if((c)) ecProjAdd(r, prev + (c & 0x0f)); if((h)) ecProjAdd(r, curve_prevs + (h & 0x0f)); } ecProj2Affine(p, r); ecProjClear(r); if(k != NULL){ for(i = 0; i < 16; ++i){ gfClear((prev+i)->x); gfClear((prev+i)->y); } } } /* ecMultiplyAdd */ ERROR eccInit() { if(ECC_Init) return 0; gfInit(); //vlOpen(point_order); //ecOpen(curve_point); /*vlUnpack(point_order, point_order_raw);*/ vlRead(point_order, point_order_raw); if(ecUnpack(curve_point, curve_point_raw)) return 1; /** Sets the firs 16 values of j·Q **/ calculate_16(curve_prevs, curve_point); #if 0 unsigned int primo; fp_prime_is_prime(point_order, 200, &primo); if(!primo) return 2; #endif /** Sets one and minus one constants **/ //vlOpen(uno); vlOpen(menosuno); vlSet(uno, 1); eccPointSub(menosuno, uno); ECC_Init = 1; return 0; } void eccQuit() { if (!ECC_Init) return; vlClear(point_order); ecClear(curve_point); vlClear(uno); vlClear(menosuno); int i; for(i = 0; i < 16; ++i){ gfClear((curve_prevs+i)->x); gfClear((curve_prevs+i)->y); } gfQuit(); ECC_Init = 0; } ERROR eccCheck(/* const */ PubKey a) /** Checks if input pubkey is OK **/ { ec_point dummy; ERROR err; if (!ECC_Init) eccInit(); //ecOpen(dummy); if((err = ecUnpack(dummy, a))) return err; /* ecDouble(dummy); ecPack(dummy, doub);*/ ecClear(dummy); return 0; } ERROR eccMakePublicKey (PubKey pub_raw, PrivKey priv_raw) /** sets P = d·Q where: P: public key d: priv. key Q: fixed curve point **/ { ec_point pub; vl_number priv; assert((pub_raw != NULL) && (priv_raw != NULL)); if (!ECC_Init) eccInit(); //vlOpen(priv); vlUnpack(priv, priv_raw); eccMod(priv, priv); /** Values 0, 1 or (p-1) should be avoided **/ if( vl_iszero(priv) || vlEqual(priv, uno) || vlEqual(priv, menosuno)){ vlClear(priv); return -1; } //ecOpen(pub); /*eccSetPoint(pub); ecMultiply(pub, priv);*/ ecMultiplyAdd(pub, NULL, priv); ecPack(pub, pub_raw); vlClear(priv); ecClear(pub); return 0; } ERROR eccEncode (PubKey *pubs_raw, ecPoint *coded_raw, vlPoint sec_raw, int N) /** Different coded keys (M_i) are obtained by: M_i = k · P_i where 'k' is the secret multiplier and P_i, the pub. keys The secret code is K = k · Q where 'Q' is the fixed point in curve **/ { ec_point Q; vl_number sec; int i, err = 0; /*assert( (pubs_raw != NULL) && (coded_raw != NULL) && (sec_raw != NULL) );*/ if (!ECC_Init) eccInit(); //vlOpen(sec); vlUnpack(sec, sec_raw); eccMod(sec, sec); //ecOpen(Q); for(i = 0; i < N; ++i){ if((err = ecUnpack(Q, pubs_raw[i]))) goto eccEncode_ERROR; ecMultiplyAdd(Q, sec, NULL); ecPack(Q, coded_raw[i]); } /*eccSetPoint(Q); ecMultiply(Q, sec);*/ ecMultiplyAdd(Q, NULL, sec); ecPack(Q, sec_raw); eccEncode_ERROR: vlClear(sec); ecClear(Q); return err; } ERROR eccDecode (PrivKey priv_raw, ecPoint coded_raw, vlPoint sec_raw) /** Secret key 'K' is recovered by: K = (d^-1)·M where 'y' is the private key corresponding to recipient pub. key P = d·Q where Q is the fixed point in curve. Proof: M = k·P = k·(d·Q) = d·(k·Q) = d·K (d^-1)·M = (d^-1)·d·K = K **/ { vl_number priv; ec_point M; if (!ECC_Init) eccInit(); //ecOpen(M); if(ecUnpack(M, coded_raw)){ ecClear(M); return 1; } //vlOpen(priv); vlUnpack(priv, priv_raw); eccInvMod(priv, priv); ecMultiplyAdd(M, priv, NULL); ecPack(M, sec_raw); vlClear(priv); ecClear(M); return 0; } ERROR eccSign(PrivKey priv_raw, vlPoint k_raw, vlPoint hash_raw, sgPair *sig) /** ECDSA signature (r, s): r <- (k·Q)x s = (k)·((h + d.r)^-1) *** i.e. 'r' holds the x-coordinate of (k·Q) and considers it a number in Z(p) where: k: random multiplier Q: fixed curve point d: priv. key h: hash / MAC **/ { vl_number k, priv; _gf_poly *hsh, *r, *s; ec_point Q; if (!ECC_Init) eccInit(); //vlOpen(k); ecOpen(Q); vlUnpack(k, k_raw); eccMod(k, k); /*eccSetPoint(Q); ecMultiply(Q, k);*/ ecMultiplyAdd(Q, NULL, k); r = (Q->x); /* r = (k·Q)x */ eccMod(r, r); if(vl_iszero(r)) return -1; //vlOpen(priv); vlUnpack(priv, priv_raw); eccMod(priv, priv); eccMulMod(priv, r, priv); /* d·r */ s = priv; hsh = (Q->y); vlUnpack(hsh, hash_raw); eccAddMod(s, hsh, s); /* h + d·r */ if(vl_iszero(s)) return -1; eccInvMod(s, s); /* (h + d·r)^-1 */ eccMulMod(s, k, s); /* s = k·(h + d·r)^-1 */ vlPack(s, sig->s); vlPack(r, sig->r); vlClear(k); vlClear(priv); ecClear(Q); return 0; } int eccVerify(PubKey pub_raw, vlPoint hash_raw, sgPair *sig) /** Now is performed the calculus: [(h·s)·Q + (r·s)·P]x where 'P' is the public key, P = d·Q and this must be equal to 'r'. Proof: (h·s)·Q + (r·s)·P = s·(h·Q + r·P) = s·(h·Q + r·d·Q) = s·(h + r·d)·Q by definition: s = k·(h + d·r)^-1, so (h·s)·Q + (r·s)·P = k·Q ==> [(h·s)·Q + (r·s)·P]x = [k·Q]x but 'r' is defined as: r = [k·Q]x QED **/ { ec_point pub; vl_number hsh, r, s; int ver; if (!ECC_Init) eccInit(); /*ecOpen(Q); eccSetPoint(Q);*/ //vlOpen(hsh); vlOpen(s); vlUnpack(hsh, hash_raw); vlUnpack(s, sig->s); eccMulMod(hsh, s, hsh); /* h·s */ /*ecMultiply(Q, hsh); */ /* (h·s)·Q */ /*r = hsh;*/ //vlOpen(r); vlUnpack(r, sig->r); eccMulMod(s, r, s); /* s <- r·s */ //ecOpen(pub); if(ecUnpack(pub, pub_raw)) { ver = 0; goto eccVerify_ERROR;} /*ecMultiply(pub, s);*/ /* (r·s)·P */ /*ecAdd(Q, pub); */ /* (h·s)·Q + (r·s)·P */ ecMultiplyAdd(pub, s, hsh); /* (h·s)·Q + (r·s)·P */ /*** Compare: [(h·s)·Q + (r·s)·P] == r ?? ***/ eccMod(s, /*Q->x*/ pub->x); /** Now s <- [(h·s)·Q + (r·s)·P]x **/ ver = vlEqual(s, r); eccVerify_ERROR: vlClear(hsh); vlClear(s); vlClear(r); ecClear(pub); /*ecClear(Q);*/ return ver; } #ifdef MAIN #include eccRandom(vlPoint r) { int i, size = sizeof(unsigned long int); for(i = 0; i < GF_SIZE; i += size){ *((unsigned long int *)&(r[i])) = rand(); } } eccPrint(char *tag, vlPoint p) { vl_number q; //vlOpen(q); vlUnpack(q, p); gfPrint(stderr, tag, q); vlClear(q); } main(int argc, char ** argv) { int i, yb, crypt_fail = 0, sign_fail = 0, test_count; clock_t elapsed_crypt = 0L, elapsed_sign = 0L, elapsed_key = 0L; PubKey pub; PrivKey priv; vlPoint sec1, sec2, msg; sgPair sig; ecPoint cod; if(argc > 1){ test_count = atoi(argv[1]); } else test_count = 1; eccInit(); srand ((unsigned)(time(NULL) % 65521U)); for(i = 0; i < test_count; ++i){ /** Make key **/ eccRandom(priv); elapsed_key -= clock(); eccMakePublicKey(pub, priv); elapsed_key += clock(); /** crypt/decrypt **/ eccRandom(sec1); elapsed_crypt -= clock(); eccEncode(&pub, &cod, sec1, 1); eccDecode(priv, cod, sec2); elapsed_crypt += clock(); if(memcmp(sec1, sec2, GF_SIZE)){ crypt_fail++; #ifdef DEBUG eccPrint("sec1", sec1); eccPrint("sec2", sec2); #endif } /** sign/verify **/ eccRandom(msg); int ver; do{ eccRandom(sec1); elapsed_sign -= clock(); ver = eccSign(priv, sec1, msg, &sig); elapsed_sign += clock(); } while(ver); elapsed_sign -= clock(); ver = eccVerify(pub, msg, &sig); elapsed_sign += clock(); if(!ver) sign_fail++; } printf ("Done.\nEncrypt-Decrypt time: %.3f s/cicle.\n", (float)elapsed_crypt/CLOCKS_PER_SEC/(test_count)); printf ("Sign/Verify time: %.3f s/cicle.\n", (float)elapsed_sign/CLOCKS_PER_SEC/(test_count)); printf ("Key generation time: %.3f s/key.\n", (float)elapsed_key/CLOCKS_PER_SEC/(test_count)); if (crypt_fail) printf ("---> %d fails in encryption/decryption <---\n", crypt_fail); if (sign_fail) printf ("---> %d fails in signing /verifying <---\n", sign_fail); eccQuit(); return crypt_fail | sign_fail; } #endif sks-ecc-0.93/eccrypt.h0000644000175000017500000000463410604550755013577 0ustar nachonacho#ifndef __ECCRYPT_H #define __ECCRYPT_H #include "eclib.h" typedef ecPoint PubKey; typedef vlPoint PrivKey; typedef struct { vlPoint r, s; } sgPair; ERROR eccInit(void); void eccQuit(void); ERROR eccCheck(PubKey/*, PubKey*/); ERROR eccMakePublicKey (PubKey, PrivKey); ERROR eccEncode (PubKey *, ecPoint *, vlPoint, int); ERROR eccDecode (PrivKey, ecPoint, vlPoint); ERROR eccSign(PrivKey, vlPoint, vlPoint, sgPair *); int eccVerify(PubKey, vlPoint, sgPair *); #ifdef _ECCRYPT_C #if (GF_T==9) static ecPoint curve_point_raw = { 0xa0, 0xb8, 0x6b, 0xdb, 0xa1, 0x68, 0x1c, 0x86, 0x9f, 0xda, 0x56, 0x88, 0xef, 0xe1, 0xc4, 0xea, 0x39, 0xdb, 0xa4, 0x17, 0xa3, 0xb0, 0x20, 0x62 }; /* static vlPoint point_order_raw ={ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x4F, 0x53, 0x25, 0x90, 0x16, 0x9C, 0x84, 0xD7, 0xF3, 0xB5, 0x97 }; */ static char point_order_raw[] = "400000000000000000000000164F532590169C84D7F3B597"; #elif (GF_T==18) static ecPoint curve_point_raw = { 0xb8, 0x50, 0xb3, 0xf1, 0xf4, 0x2c, 0x89, 0xaf, 0x55, 0xa3, 0x2b, 0x45, 0x7c, 0xbe, 0x8d, 0x7e, 0x2a, 0x6f, 0xc5, 0x5e, 0xf2, 0x32, 0xd0, 0x18 }; /*static vlPoint point_order_raw ={ 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0x3C, 0x68, 0x52, 0xA8, 0xA6, 0x33, 0x27, 0xB9, 0x8D, 0xCA, 0xB5 }; */ static car point_order_raw[]= "1FFFFFFFFFFFFFFFFFFFFFFFFD3C6852A8A63327B98DCAB5"; #elif (GF_T==71) static ecPoint curve_point_raw = { 0x43, 0x9b, 0x99, 0x77, 0xe7, 0x03, 0x29, 0xd3, 0x65, 0x71, 0xb9, 0x66, 0x49, 0xad, 0x2c, 0xab, 0xca, 0x2d, 0xd5, 0xf3, 0x2c, 0x1e, 0x7d, 0x68 }; /*static vlPoint point_order_raw ={ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0xB4, 0x5E, 0x4B, 0x0E, 0x81, 0x08, 0x56, 0x05, 0x8B, 0x92, 0x15 }; */ static car point_order_raw[]= "2000000000000000000000002CB45E4B0E810856058B9215"; #elif (GF_T==140) static ecPoint curve_point_raw = { 0xc9, 0x69, 0x7c, 0xdd, 0xf0, 0x22, 0xf9, 0xa4, 0x69, 0x4c, 0x7b, 0xcf, 0x21, 0xb9, 0x39, 0xbc, 0xc1, 0xe5, 0x5c, 0xe4, 0x5e, 0x0f, 0x82, 0xc2 }; /*static vlPoint point_order_raw ={ 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xE1, 0x49, 0xB5, 0x2B, 0x7A, 0x39, 0x39, 0xBC, 0x44, 0xE0, 0x55 };*/ static car point_order_raw[]= "1FFFFFFFFFFFFFFFFFFFFFFFF0E149B52B7A3939BC44E055"; #endif /* ? GF_T */ #endif /* ? _ECCRYPT_C */ #endif /* ?__ECCRYPT_H */ sks-ecc-0.93/eclib.c0000644000175000017500000004574510713725422013203 0ustar nachonacho/* * Algebraic operations on Elliptic Curve Group * (Part of SKS cryptosystem) * * * Copyright (C) 2004-2007 Manuel Pancorbo Castro * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Manuel Pancorbo Castro * * */ #include #include "eclib.h" int ecCheck (/*const*/ ec_point p) /* confirm that y^2 + x*y + (EC_A x^2) = x^3 + EC_B for point p */ /* returns 1 if true (p belongs to curve) or 0 if false */ { gf_poly t1, t2, t3; assert(p != NULL); //assert(ecExists(p)); #ifdef EC_A gf_poly a; //gfOpen(a); gfSet(a, EC_A); #endif //gfOpen(t3); gfOpen(t1); gfOpen(t2); gfSquare (t1, p->y); gfMultiply (t2, p->x, p->y); gfAdd (t1, t1, t2); /* t1 := y^2 + x*y */ gfSquare (t2, p->x); /* t2 = x^2 */ #ifdef EC_A gfMultiply(t3, t2, a); /* t3 = EC_A x^2 */ gfAdd(t1, t1, t3); /* t1 = y^2 + x*y + EC_A x^2 */ gfClear(a); #endif gfMultiply (t3, t2, p->x); gfSet(t2, EC_B); /** t2 <- EC_B **/ gfAdd (t2, t3, t2); /** t2 := x^3 + EC_B */ int ret = gfEqual (t1, t2); gfClear(t3), gfClear(t1), gfClear(t2); return ret; } /* ecCheck */ #if 0 ec_point ec_Open() { ec_point a; if( (a = malloc(sizeof(_ecpoint))) == NULL ) return NULL; //gfOpen(a->x); if( a->x == NULL ) return NULL; //gfOpen(a->y); if( a->y == NULL ) return NULL; return a; } ec_projective ec_ProjOpen() { ec_projective a; if( (a = malloc(sizeof(_ecprojective))) == NULL ) return NULL; //gfOpen(a->x); if( a->x == NULL ) return NULL; //gfOpen(a->y); if( a->y == NULL ) return NULL; //gfOpen(a->z); if( a->z == NULL ) return NULL; return a; } #endif void ecClear(ec_point a) { assert(a != NULL); gfClear(a->x); gfClear(a->y); //free(a); } void ecProjClear(ec_projective a) { assert(a != NULL); gfClear(a->x); gfClear(a->y); gfClear(a->z); //free(a); } int ecEqual (/*const*/ ec_point p, /*const*/ ec_point q) /* evaluates to 1 if p == q, otherwise 0 (or an error code) */ { assert( (p != NULL) && (q != NULL) ); //assert(ecExists(p) && ecExists(q)); return gfEqual (p->x, q->x) && gfEqual (p->y, q->y); } /* ecEqual */ void ecZero(ec_point p) /* sets p to the point at infinity O, clearing entirely the content of p */ { assert(p != NULL); //assert(ecExists(p)); gfZero (p->x); gfZero (p->y); } /* ecZero */ void ecCopy (ec_point p, /*const*/ ec_point q) /* sets p := q */ { assert( (p != NULL) && (q != NULL) ); //assert(ecExists(p) && ecExists(q)); gfCopy (p->x, q->x); gfCopy (p->y, q->y); } /* ecCopy */ void ecProj2Affine(ec_point p, /* const */ ec_projective q) /* Changes projective coordinates (q) to affine (p) p <- q */ { assert( (p != NULL) && (q != NULL) ); //assert(ecExists(p) && ecProjExists(q)); gf_poly z2; if(gf_iszero(q->z)){ /** Infinite point **/ gfZero(p->x); gfZero(p->y); } else{ //gfOpen(z2); gfSquare(z2, q->z); gfDivide(p->x, q->x, q->z); gfDivide(p->y, q->y, z2); gfClear(z2); } } /* ecProj2Affine */ void ecAffine2Proj(ec_projective q, /* const */ ec_point p ) /* Changes affine coordinates (p) to projective (q) q <- p */ { assert( (p != NULL) && (q != NULL) ); //assert(ecExists(p) && ecProjExists(q)); gfCopy(q->x, p->x); gfCopy(q->y, p->y); gfSet(q->z, 1); } /* ecAffine2Proj */ ERROR ecCalcY (ec_point p, int ybit) /* given the x coordinate of p, evaluate y such that y^2 + x*y = x^3 + EC_B */ { gf_poly a, b, t; assert(p != NULL); //assert(ecExists(p)); //gfOpen(a); gfOpen(b); gfOpen(t); gfSet(b, EC_B); if(gf_iszero(p->x)){ /* elliptic equation reduces to y^2 = EC_B: */ #ifdef EC_SQR_B gfSet(p->y, EC_SQR_B); #else gfSquareRoot (p->y, EC_B); #endif gfClear (a); gfClear (t); gfClear (b); return 0; } /* evaluate alpha = x^3 + b = (x^2)*x + EC_B: */ gfSquare (t, p->x); /* keep t = x^2 for beta evaluation */ gfMultiply (a, t, p->x); gfAdd (a, a, b); /* now a == alpha */ if(gf_iszero(a)){ gfZero(p->y); gfClear (a); gfClear (t); gfClear (b); return 0; } /* evaluate beta = alpha/x^2 = x + EC_B/x^2 + (EC_A) */ /*gfInvert(a, t); gfMultiply(a, b, a);*/ gfDivide(a, b, t); #ifdef EC_A gfSmallAdd(a, EC_A); #endif gfAdd (a, p->x, a); /* now a == beta */ /* check if a solution exists: */ if (gfTrace (a) != 0) { /* destroy potentially sensitive data: */ gfClear (a); gfClear (t); gfClear (b); return 1; /* no solution */ } /* solve equation t^2 + t + beta = 0 so that gfYbit(t) == ybit: */ if(gfQuadSolve (t, a)) return 0; if (gfYbit (t) != ybit) { gfSet(a, 1); gfAdd(t, a, t); } /* compute y = x*t: */ gfMultiply (p->y, p->x, t); /* destroy potentially sensitive data: */ gfClear (a); gfClear (t); gfClear (b); return 0; } /* ecCalcY */ void ecRandom (ec_point p) /* sets p to a random point of the elliptic curve defined by y^2 + x*y = x^3 + EC_B */ /* Only for testing purposes */ { int check; assert(p != NULL); //assert(ecExists(p)); do { /* generate a pseudo-random x component: */ gfRandom (p->x); /* evaluate the corresponding y component: */ check = ecCalcY (p, 0); #ifdef CHECK_POINT_DERIVATION if (ecCheck (p)) { printf (">>> invalid elliptic curve point <<<\n"); return; } #endif /* ?CHECK_POINT_DERIVATION */ } while (check); #ifdef CHECK_POINT_DERIVATION printf("point OK\n"); #endif } /* ecRandom */ int ecYbit (/*const*/ ec_point p) /* evaluates to 0 if p->x == 0, otherwise to gfYbit (p->y / p->x) */ { gf_poly t1, t2; assert(p != NULL); //assert(ecExists(p)); if (gf_iszero(p->x)) { return 0; } else { //gfOpen(t1); gfOpen(t2); /*gfInvert (t1, p->x); gfMultiply (t2, p->y, t1);*/ gfDivide(t2, p->y, p->x); return gfYbit (t2); gfClear(t1); gfClear(t2); } } /* ecYbit */ void ecProjDouble (ec_projective p) /* sets p := 2*p in projective coordinates */ { assert(p != NULL); //assert(ecProjExists(p)); if(gf_iszero(p->x) && gf_iszero(p->y) /*&& gf_iszero(p->z)*/) return; gf_poly z2, bz4; //gfOpen(z2); gfOpen(bz4); gfSquare(z2, p->z); gfSquare(p->x, p->x); gfMultiply(p->z, p->x, z2); /** Z <- Z^2 * X^2 **/ gfSquare(bz4, z2); gfZero(z2); gfSmallAdd(z2, EC_B); gfMultiply(bz4, bz4, z2); /** bz4 = EC_B * Z^4 **/ gfSquare(p->x, p->x); gfAdd(p->x, p->x, bz4); /** X <- X^4 + bz4 **/ gfSquare(p->y, p->y); gfAdd(p->y, p->y, bz4); #ifdef EC_A /** A == 1 **/ gfAdd(p->y, p->y, p->z); #endif gfMultiply(p->y, p->y, p->x); /** X * (EC_A * Z + Y^2 + bz4) **/ gfMultiply(bz4, bz4, p->z); gfAdd(p->y, p->y, bz4); /** Y <- Z * bz4 + X * (EC_A * Z + Y^2 + bz4) **/ gfClear(z2), gfClear(bz4); } void ecProjAdd (ec_projective p, /*const*/ ec_point q) /* sets p := p + q in projective coordinates. It is assumed q.z = 1 */ { assert( (p != NULL) && (q != NULL) ); //assert(ecProjExists(p) && ecExists(q)); /* first check if there is indeed work to do (q == 0): */ if (gf_iszero(q->x) && gf_iszero(q->y)) return; /* if p == 0 */ if (gf_iszero(p->x) && gf_iszero(p->y)){ ecAffine2Proj(p, q); return; } gf_poly A, B, z2, C, D, E, F, G; //gfOpen(A); gfOpen(B); gfOpen(z2); gfSquare(z2, p->z); gfMultiply(A, q->y, z2); gfAdd(A, A, p->y); /* A = Y1 Z0^2 + Y0 */ gfMultiply(B, q->x, p->z); gfAdd(B, B, p->x); /* B = X1 Z0 + X0 */ if(gf_iszero(B)){ if(gf_iszero(A)){ /** A = B = 0 The same point. Double it! **/ ecProjDouble(p); } else{ /** B = 0. The opposite point. Result is infinite **/ gfZero(p->x); gfZero(p->y); gfSet(p->z, 1); } } else{ //gfOpen(C); gfOpen(D); gfMultiply(C, p->z, B); /* C = B Z0 */ #ifdef EC_A /** A == 1 **/ gfAdd(D, C, z2); #else gfCopy(D, C); #endif gfSquare(B, B); gfMultiply(D, D, B); /* D = B^2 (C + a Z0^2) */ gfSquare(p->z, C); /* Z2 = C^2 */ // E = z2; gfMultiply(E, A, C); /* E = A C */ gfSquare(p->x, A); gfAdd(p->x, p->x, D); gfAdd(p->x, p->x, E); /* X2 = A^2 + D + E */ //F = A; G = B; gfMultiply(F, q->x, p->z); gfAdd(F, F, p->x); /* F = X2 + X1 Z2 */ gfMultiply(G, q->y, p->z); gfAdd(G, G, p->x); /* G = X2 + Y1 Z2 */ gfMultiply(G, G, p->z); gfMultiply(p->y, E, F); gfAdd(p->y, p->y, G); /* Y2 = E F + G Z2 */ gfClear(C); gfClear(D); } gfClear(A); gfClear(B); gfClear(z2); gfClear(E);gfClear(G);gfClear(F); } void ecDouble (ec_point p) /* sets p := 2*p */ { gf_poly lambda, t1, t2; /*gf_poly a;*/ /*short int A;*/ assert(p != NULL); //assert(ecExists(p)); if(gf_iszero(p->x) && gf_iszero(p->y)) return; /*a->K = 1; a->P[0] = A = EC_A; */ /* evaluate lambda = x + y/x: */ //gfOpen(lambda); gfOpen(t1); gfOpen(t2); /*gfInvert (t1, p->x); gfMultiply (lambda, p->y, t1);*/ gfDivide(lambda, p->y, p->x); gfAdd (lambda, lambda, p->x); /* evaluate x3 = lambda^2 + lambda + (EC_A): */ gfSquare (t1, lambda); #ifdef EC_A gfSmallAdd(t1, EC_A); #endif gfAdd (t1, t1, lambda); /* now t1 = x3 */ /* evaluate y3 = x^2 + lambda*x3 + x3: */ gfSquare (p->y, p->x); gfMultiply (t2, lambda, t1); gfAdd (p->y, p->y, t2); gfAdd (p->y, p->y, t1); /* deposit the value of x3: */ gfCopy (p->x, t1); gfClear(lambda); gfClear(t1); gfClear(t2); } /* ecDouble */ void ecAdd (ec_point p, /*const*/ ec_point q) /* sets p := p + q */ { assert( (p != NULL) && (q != NULL) ); //assert(ecExists(p) && ecExists(q)); /* first check if there is indeed work to do (q != 0): */ if (!gf_iszero(q->x) || !gf_iszero(q->y)) { if (!gf_iszero(p->x) || !gf_iszero(p->y)) { /* p != 0 and q != 0 */ if (gfEqual (p->x, q->x)) { /* either p == q or p == -q: */ if (gfEqual (p->y, q->y)) { /* points are equal; double p: */ ecDouble (p); } else { /* must be inverse: result is zero */ /* (should assert that q->y = p->x + p->y) */ ecZero(p); } } else { /* p != 0, q != 0, p != q, p != -q */ gf_poly lambda, t, tx, ty, x3; //gfOpen(lambda); gfOpen(t); gfOpen(tx); //gfOpen(ty); gfOpen(x3); /* evaluate lambda = (y1 + y2)/(x1 + x2): */ gfAdd (ty, p->y, q->y); gfAdd (tx, p->x, q->x); /*gfInvert (t, tx); gfMultiply (lambda, ty, t);*/ gfDivide(lambda, ty, tx); /* evaluate x3 = lambda^2 + lambda + x1 + x2 + (EC_A): */ gfSquare (x3, lambda); gfAdd (x3, x3, lambda); gfAdd (x3, x3, tx); #ifdef EC_A gfSmallAdd(x3, EC_A); #endif /* evaluate y3 = lambda*(x1 + x3) + x3 + y1: */ gfAdd (tx, p->x, x3); gfMultiply (t, lambda, tx); gfAdd (t, t, x3); gfAdd (p->y, t, p->y); /* deposit the value of x3: */ gfCopy (p->x, x3); gfClear(lambda); gfClear(t); gfClear(tx); gfClear(ty); gfClear(x3); } } else { /* just copy q into p: */ gfCopy (p->x, q->x); gfCopy (p->y, q->y); } } } /* ecAdd */ static int diff_vector(signed char *b, vl_number x ) { assert(b != NULL); int old_bit, actual_bit, i = 0; vl_number w; //vlOpen(w); vlCopy(w, x); actual_bit = old_bit = gf_one(w); b[i++] = -actual_bit; do{ gf2m_Div_x(w, w); actual_bit = gf_one(w); b[i++] = old_bit - actual_bit; old_bit = actual_bit; } while(!gf_iszero(w)); vlClear(w); return i; } void ecMultiply (ec_point p, vl_number k) /* sets p := k*p It uses projective coordinates It uses Minimal Average Weight representations see: "A New Minimal Average Weight Representation for Left-to-Right Point Multiplication Methods" M. Khabbazian and T.A. Gulliver http://eprint.iacr.org/2004/266.ps */ #define MWIN_SIZE 8 /** Number of points of given representation **/ { assert( (p != NULL) && (k != NULL) ); //assert(ecExists(p) && vlExists(k)); if(gf_iszero(k)){ ecZero(p); return; } _ecpoint pos_buf[MWIN_SIZE], /** Table for positives 1,3,...2M-1 **/ neg_buf[MWIN_SIZE]; /** Table for negatives -1,-3,...-(2M-1) **/ _ecpoint *pos = pos_buf, *neg = neg_buf; ec_point pp; register int i, j, t, v, last_one = 0, length; const int m2 = 2*MWIN_SIZE; /*** Precalculate values ***/ //ecOpen(pp); ecCopy(pp, p); ecDouble(pp); for(i = 0; i < MWIN_SIZE; ++i, ++pos, ++neg){ //gfOpen(pos->x); gfOpen(neg->x); //gfOpen(pos->y); gfOpen(neg->y); if(!i){ ecCopy(pos, p); } else{ ecCopy(pos, pos - 1); ecAdd(pos, pp); } ecCopy(neg, pos); ecNegate(neg); } ecClear(pp); /*** obtain vector with differences ***/ signed char b[GF_M + 1]; memset(b, 0, GF_M + 1); length = diff_vector(b, k); /*** start! ***/ ec_projective r; //ecProjOpen(r); gfZero(r->x); gfZero(r->y); gfSet(r->z, 1); pos = pos_buf; neg = neg_buf; for(i = length - 1; i >= 0; /***/){ v = b[i]; if(v) last_one = i; for(j = i -1; (j >= 0); --j){ t = b[j]; v *= 2; v += t; if(abs(v) > m2) break; else if(t) last_one = j; } v = b[i]; for(j = i - 1; (j >= last_one); --j){ v *= 2; v += b[j]; } j = i - last_one + 1; while(j--) ecProjDouble(r); i = last_one - 1; last_one = 0; if(!v) break; /*** It shoudn't happen until end ***/ j = (abs(v) - 1) / 2; if(v > 0) ecProjAdd(r, pos + j); else ecProjAdd(r, neg + j); } ecProj2Affine(p, r); ecProjClear(r); memset(b, 0, GF_M + 1); for(i = 0; i < MWIN_SIZE; ++i, ++pos, ++neg){ gfClear(pos->x); gfClear(neg->x); gfClear(pos->y); gfClear(neg->y); } return; } /* ecMultiply */ #if 0 #endif void ecPack (/*const*/ ec_point p, ecPoint k ) /* packs ec. point into array (compressed point) */ { assert( (p != NULL) && (k != NULL) ); //assert(ecExists(p) ); gf_poly tmp; memset(k, 0, GF_SIZE); if(gf_iszero(p->x)) return; //gfOpen(tmp); gfCopy(tmp, p->x); gf2m_Mul_x(tmp, tmp); *(tmp->dp) |= ecYbit(p); gfPack(tmp, k); gfClear(tmp); } ERROR ecUnpack ( ec_point p, /*const*/ ecPoint k ) /* unpacks compressed ec. point from array into full ec. point */ { assert((p != NULL) && (k != NULL)); //assert(ecExists(p)); int ybit; gfUnpack(p->x, k); ybit = gfYbit(p->x); gf2m_Div_x(p->x, p->x); return ecCalcY(p, ybit); } void ecNegate (ec_point p) /* sets p := -p */ { gfAdd (p->y, p->x, p->y); } /* ecNegate */ #ifdef ECLIB_TEST #include #include void ecSub (ec_point p, /*const*/ ec_point r) /* sets p := p - r */ { ec_point t; //ecOpen(t); gfCopy (t->x, r->x); gfAdd (t->y, r->x, r->y); ecAdd (p, t); ecClear(t); } /* ecSub */ main(int argc, char ** argv) { int i, yb, nfail = 0, afail = 0, sfail = 0, dfail = 0, cfail = 0, qfail = 0, pfail = 0, yfail = 0, test_count; ec_point f, g, x, y; ec_projective xproj; vl_number m, n; clock_t elapsed = 0L; if(argc > 1){ test_count = atoi(argv[1]); } else test_count = 10; gfInit(); srand ((unsigned)(time(NULL) % 65521U)); //ecOpen(f); ecOpen(g); //ecOpen(x); ecOpen(y); //ecProjOpen(xproj); i = 0; ecZero(f); do{ gfSet(f->x, ++i); } while(ecCalcY(f, 0)); fprintf(stderr, "Primer elemento de curva:\n"); gfPrint(stderr, "F.x", f->x); gfPrint(stderr, "F.y", f->y); /*printf ("Tamaño ulong64: %d\n", sizeof(ulong64));*/ printf ("Executing %d curve self tests GF(2^%d)...\n", test_count, GF_M); /*elapsed = -clock ();*/ for (i = 0; i < test_count; i++) { ecRandom (f); ecRandom (g); /*gfSet(f->x, 7); ecCalcY(f, 0); gfSet(g->x, 0); ecCalcY(g, 0);*/ /* y calculation test: */ yb = ecYbit (f); ecZero (x); gfCopy (x->x, f->x); if(ecCalcY (x, yb)) printf("Error cálculo y\n"); if (!ecEqual (f, x)) { yfail++; printf ("Y calculation test #%d failed!\n", i); gfPrint(stderr, "F.x", f->x); gfPrint(stderr, "X.x", x->x); fprintf(stderr, "\n"); gfPrint(stderr, "F.y", f->y); gfPrint(stderr, "X.y", x->y); } /* addition test: f+g = g+f */ ecCopy (x, f); ecAdd (x, g); ecCopy (y, g); ecAdd (y, f); if (!ecEqual (x, y)) { afail++; printf ("Addition test #%d failed!\n", i); } /* projective addition test: f+g (proj) = f+g (affine) */ ecAffine2Proj(xproj, f); ecProjAdd (xproj, g); ecProj2Affine(x, xproj); ecCopy (y, f); ecAdd (y, g); if (!ecEqual (x, y)) { sfail++; printf ("Projective addition test #%d failed!\n", i); gfPrint(stderr, "X.x", x->x); gfPrint(stderr, "Y.x", y->x); gfPrint(stderr, "X.y", x->y); gfPrint(stderr, "Y.y", y->y); fprintf(stderr, "\n"); } /* projective duplication test 2*f (proj) = 2*f (affine)*/ ecAffine2Proj(xproj, f); ecProjDouble(xproj); ecProj2Affine(x, xproj); ecCopy(y, f); ecDouble(y); if (!ecEqual (x, y)) { dfail++; printf ("Projective duplication test #%d failed!\n", i); gfPrint(stderr, "X.x", x->x); gfPrint(stderr, "Y.x", y->x); gfPrint(stderr, "X.y", x->y); gfPrint(stderr, "Y.y", y->y); fprintf(stderr, "\n"); } /* quadruplication test: 2*(2*f) = f + f + f + f */ ecCopy (x, f); ecDouble (x); ecDouble (x); ecZero (y); ecAdd (y, f); ecAdd (y, f); ecAdd (y, f); ecAdd (y, f); if (!ecEqual (x, y)) { qfail++; printf ("Quadruplication test #%d failed!\n", i); } /* scalar multiplication commutativity test: m*(n*f) = n*(m*f) */ //vlOpen(n); vlOpen(m); vlRandom(n); vlRandom(m); /*vlSet(n, 266); vlSet(m, 2);*/ /*gfPrint(stderr, "F.x", f->x);*/ ecCopy (x, f); ecCopy (y, f); elapsed -= clock (); ecMultiply (x, n); ecMultiply (x, m); /*gfPrint(stderr, "X.x", x->x);*/ ecMultiply (y, m); ecMultiply (y, n); /*gfPrint(stderr, "Y.x", y->x);*/ elapsed += clock (); if (!ecEqual (x, y)) { cfail++; printf ("Conmutative test #%d failed!\n", i); gfPrint(stderr, "X.x", x->x); gfPrint(stderr, "Y.x", y->x); fprintf(stderr, "\n"); gfPrint(stderr, "X.y", x->y); gfPrint(stderr, "Y.y", y->y); } /* packing test: unpack (pack (f)) = f */ ecPoint p; ecPack (f, p); ecUnpack (x, p); if (!ecEqual (f, x)) { pfail++; printf ("Packing test #%d failed!\n", i); gfPrint(stderr, "F.x", f->x); gfPrint(stderr, "X.x", x->x); fprintf(stderr, "\n"); gfPrint(stderr, "F.y", f->y); gfPrint(stderr, "X.y", x->y); } } /*elapsed += clock ();*/ /*gfClear(m), gfClear(n), gfClear(p);*/ ecClear(f); ecClear(g); ecClear(x); ecClear(y); vlClear(m); vlClear(n); ecProjClear(xproj); gfQuit(); printf (" done, scalar multiplication time: %.3f s\n", (float)elapsed/CLOCKS_PER_SEC/(test_count?4*test_count:4)); if (nfail) printf ("---> %d negations failed <---\n", nfail); if (afail) printf ("---> %d additions failed <---\n", afail); if (sfail) printf ("---> %d projective additions failed <---\n", sfail); if (qfail) printf ("---> %d quadruplications failed <---\n", qfail); if (dfail) printf ("---> %d projective duplications failed <---\n", dfail); if (cfail) printf ("---> %d conmutations failed <---\n", cfail); if (yfail) printf ("---> %d y calculations failed <---\n", yfail); if (pfail) printf ("---> %d packings failed <---\n", pfail); return nfail || afail || sfail || qfail || cfail || yfail || pfail; } #endif /* ECLIB_TEST */ sks-ecc-0.93/eclib.h0000644000175000017500000000413710706514204013172 0ustar nachonacho#ifndef __ECLIB_H #define __ECLIB_H #include #include "gflib.h" #if (GF_M==191) #if (GF_T==71) #define EC_B 0x145 #define EC_SQR_B 0x1B #elif (GF_T==9) #define EC_B 0x1445 #define EC_SQR_B 0x6B #define EC_A 1 #elif (GF_T==140) #define EC_B 0x1541 #define EC_SQR_B 0x79 #elif (GF_T==18) #define EC_B 0x55 #define EC_SQR_B 0x0F #else #error "Unsupported trinomial" #endif /* ? GF_T */ #else #error "Unsupported trinomial" #endif /* ?GF_M */ #define ecOpen(A) {A = ec_Open();} #define ecProjOpen(A) {A = ec_ProjOpen();} /*#define ecClear(A) {gfClear((A)->x); gfClear((A)->y);}*/ #define ecExists(A) (gfExists((A)->x) && gfExists((A)->y)) #define ecProjExists(A) (gfExists((A)->x) && gfExists((A)->y) && gfExists((A)->z)) typedef struct { gf_poly x, y; } _ecpoint ; typedef struct { gf_poly x, y, z; } _ecprojective ; typedef _ecpoint ec_point[1]; typedef _ecprojective ec_projective[1]; typedef gf_poly vl_number; /*** Compressed types ****/ typedef gfPoint ecPoint; typedef gfPoint vlPoint; #define vlOpen gfOpen #define vlSet gfSet #define vlCopy gfCopy #define vlRandom gfRandom #define vlClear gfClear #define vlExists gfExists #define vlPack gfPack #define vlUnpack gfUnpack #define vl_iszero gf_iszero #define vlEqual gfEqual int ecCheck (/*const*/ ec_point p); //ec_point ec_Open(void); void ecClear(ec_point a); int ecEqual (/*const*/ ec_point p, /*const*/ ec_point q); void ecZero(ec_point p); void ecCopy (ec_point p, /*const*/ ec_point q); ERROR ecCalcY (ec_point p, int ybit); void ecRandom (ec_point p); int ecYbit (/*const*/ ec_point p); void ecDouble (ec_point p); void ecAdd (ec_point p, /*const*/ ec_point q); /*void ecMultiply (ec_point p, vl_number k); */ void ecPack (/*const*/ ec_point p, ecPoint k ); ERROR ecUnpack ( ec_point p, /*const*/ ecPoint k ); void ecNegate (ec_point p); #ifdef _ECCRYPT_C //ec_projective ec_ProjOpen(void); void ecProjClear(ec_projective a); void ecProj2Affine(ec_point p, /* const */ ec_projective q); void ecProjDouble (ec_projective p); void ecProjAdd (ec_projective p, /*const*/ ec_point q); #endif /* _ECCRYPT_C */ #endif /* __ECLIB_H */ sks-ecc-0.93/entropy.c0000744000175000017500000001072010715702751013611 0ustar nachonacho/* entropy.c For 'sks' project Copyright (C) 2004-2007 Manuel Pancorbo Castro This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Manuel Pancorbo Castro */ /******************** ** Entropy functions **/ #include #include "mycrypt.h" #include "sks.h" static int rng_ansic(unsigned char *, unsigned long ); #ifdef WIN32 static int rng_windows(char *, int ); #endif #define RANDOM_NUM 16 #define DIGEST_SIZE (HASH_SIZE*8) /** Should be multiple of HASH_SIZE **/ static int parity(unsigned char a) { int p = 0; while(a){ p ^= (a & 1); a >>= 1; } return p; } static int rng_ansic(unsigned char *buf, unsigned long len) /** Code taken from LibTomCrypt by Tom St Denis **/ { clock_t t1; int acc, bits, a, b; unsigned long l; l = len; bits = 8; acc = a = b = 0; while (len--) { /*if (callback != NULL) callback();*/ fputs("ANSI-rng: ", stderr); fprintf(stderr, "%ld\r", l-len); while (bits) { do { t1 = XCLOCK(); while (t1 == XCLOCK()) a ^= 1; t1 = XCLOCK(); while (t1 == XCLOCK()) b ^= 1; } while (a == b); acc = (acc << 1) | a; acc = (acc << 1) | parity(t1 & 0xff); bits -= 2; b = a; } *buf++ = acc; acc = 0; bits = 8; } fputs("\n", stderr); acc = bits = a = b = 0; return l; } int get_entropy(unsigned char *seed, size_t nbytes) { assert(nbytes <= HASH_SIZE); assert(seed != NULL); unsigned char junk[DIGEST_SIZE]; unsigned char bin[DIGEST_SIZE]; FILE *old; int i; /** entropy source: prng-file (perhaps good source?) **/ old = open_prngfile(); if( old != NULL){ fread(bin, 1, DIGEST_SIZE, old); } else fprintf(stderr, "No se encuentra prng\n"); #ifdef DEVRANDOM #ifdef LINUX FILE *rnd; if((rnd = fopen("/dev/urandom", "rb")) == NULL) if((rnd = fopen("/dev/random", "rb")) == NULL) goto ansi_entropy; fread(junk, 1, DIGEST_SIZE, rnd); fclose(rnd); #endif /* LINUX */ #ifdef WIN32 if(!rng_windows(junk, DIGEST_SIZE)) goto ansi_entropy; #endif /* WIN32 */ if(old != NULL){ for(i = 0; i < DIGEST_SIZE; ++i) junk[i] ^= bin[i]; zeromem(bin, DIGEST_SIZE); } hash_binary(junk, junk, DIGEST_SIZE); memcpy(seed, junk, nbytes); goto entropy_end; /*zeromem(junk, nbytes); return nbytes;*/ ansi_entropy: #endif /* DEVRANDOM */ { clock_t *t; if(old != NULL){ memcpy(junk, bin, DIGEST_SIZE); zeromem(bin, DIGEST_SIZE); } /** low-quality entropy source: date **/ t = (clock_t *) &(junk[0]); *t = XCLOCK(); /** Hash it along old junk material **/ hash_binary(junk + HASH_SIZE, junk, DIGEST_SIZE); /** Third: rng_ansic **/ if (!rng_ansic(junk, RANDOM_NUM)) return 0; hash_binary(junk, junk, DIGEST_SIZE); memcpy(seed, junk, nbytes); } entropy_end: /** Hide the result with more hashing. Keep it as junk material for further 'get_entropy' callings **/ for(i = 0; i < DIGEST_SIZE; i += HASH_SIZE) hash_binary(junk + i, junk, DIGEST_SIZE); /** keep this material for as further junk bits **/ if(old != NULL){ rewind(old); fwrite(junk, 1, DIGEST_SIZE, old); fclose(old); } return nbytes; } #ifdef WIN32 #define _WIN32_WINNT 0x0400 #include #include static int rng_windows(char *seed, int nbytes) /** Code taken from LibTomCrypt by Tom St Denis **/ { HCRYPTPROV hProv = 0; if (!CryptAcquireContext(&hProv, NULL, MS_DEF_PROV, PROV_RSA_FULL, (CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET)) && !CryptAcquireContext (&hProv, NULL, MS_DEF_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET | CRYPT_NEWKEYSET)) return 0; if (CryptGenRandom(hProv, nbytes, seed) == TRUE) { CryptReleaseContext(hProv, 0); return nbytes; } else { CryptReleaseContext(hProv, 0); return 0; } } #endif sks-ecc-0.93/gflib.c0000644000175000017500000005717410715702733013211 0ustar nachonacho/* * Algebraic operations on the finite field GF(2^m) * * * * Copyright (C) 2004-2007 Manuel Pancorbo Castro * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Manuel Pancorbo Castro * * */ #include #include #include #include #include #define _GFLIB_C #include "gflib.h" static gf_poly R; static int GF_Init = 0; //#if (defined FULLTABLES) && ((GF_DIGIT_BIT)==28) // #define GF_SQR_TABLE_SIZE (1<<14) // gf_unit sqr[GF_SQR_TABLE_SIZE]; //#else #define GF_SQR_TABLE_SIZE (1 << 8) static unsigned short int sqr[GF_SQR_TABLE_SIZE]; //#endif #if !(defined GF_TM1) && (defined FULLTABLES) static _gf_poly quad[GF_M]; #endif static int tables_builded = 0; static void build_tables(void) { gf_unit i, ii, jj; gf_unit c; gf_poly a; gf_unit lim = GF_SQR_TABLE_SIZE; for(i = 0; i < lim; ++i){ /** Sqr **/ jj = 1, ii = i, c = 0; while(ii){ if(ii & 1) c ^= jj; jj <<= 2; ii >>= 1; } sqr[i] = c; } #if !(defined GF_TM1) && (defined FULLTABLES) /* QuadSolve quick table */ tables_builded = 1; gf2m_Set(a, 1); for(i = 0; i < GF_M; ++i){ if(i == GF_TM0) gf2m_Zero(&quad[i]); else gf2m_SlowQuadSolve(&quad[i],a); gf2m_Mul_x(a,a); } #endif } /* gf_poly gf2m_Open() { gf_poly a; if( (a = malloc(sizeof(mp_int))) == NULL ) return NULL; if(mp_init_size(a, 2*GF_M / GF_DIGIT_BIT + 4)) return NULL; return a; } */ ERROR gf2m_Init(void) /* Sets global 'R' with reduction trinomial */ /* Sets auxiliar variables */ { if(GF_Init) return 0; GF_Init = 1; //gfOpen(R); if(R == NULL) return 1; gf2m_Set(R, 1); gf2m_Mul_xn(R, GF_M - GF_T, R); fp_add_d(R, 1, R); gf2m_Mul_xn(R, GF_T, R); fp_add_d(R, 1, R); if(!tables_builded){ build_tables(); tables_builded = 1; } return 0; } void gf2m_Quit(void) { //gfClear(R); GF_Init = 0; } int gf2m_Deg(gf_poly a) { register int deg; register gf_unit c; int m = a->used; assert(a != NULL); //assert(gfExists(a)); if(gf_iszero(a)) return -1; /*while(!DIGIT(a, m - 1)) m--;*/ c = a->dp[m-1]; deg = (m-1) * GF_DIGIT_BIT; while(c){ ++deg; c >>= 1; } return deg - 1; } #if 0 void gf2m_Clear(gf_poly a) { return; //assert( a != NULL ); //assert(gfExists(a)); //gf2m_Zero(a); //mp_clear(a); //free(a); } #endif void gf2m_Pack(gf_poly a, gfPoint b) { memset(b, 0, GF_SIZE); if (gf_iszero(a)) return; gfPut(a, b + GF_SIZE - gfSize(a)); } void gf2m_SmallAdd(gf_poly a, gf_unit b) { assert( (a != NULL) ); //assert( gfExists(a) ); if(!b) return; if(gf_iszero(a)){ *(a->dp) ^= b; a->used++; } else{ *(a->dp) ^= b; gf_clamp(a); } } void gf2m_Add(gf_poly c, gf_poly a, gf_poly b) { int ix, px; _gf_poly *x; gf_poly t; if (a->used > b->used) { gfCopy(t, a); px = b->used; x = b; } else { gfCopy(t, b); px = a->used; x = a; } for (ix = 0; ix < px; ix++) { t->dp[ix] ^= x->dp[ix]; } gf_clamp (t); gfCopy(c, t); } //#if (sizeof(fp_digit) > GF_T) inline void gf2m_Reduce_Small_T(gf_poly p) /* reduces p mod the irreducible trinomial X^191 + X^9 + 1 */ { assert(GF_Init); assert(p != NULL); //assert(gfExists(p)); const int digit_offset = GF_M/GF_DIGIT_BIT; const int bit_offset_M0 = GF_M % GF_DIGIT_BIT; const int bit_offset_MT = (GF_M-GF_T) % GF_DIGIT_BIT; register gf_unit val, *ptr /*, mask*/; gf_word mask; ptr = &(p->dp[p->used-1]); while(p->used > digit_offset + 1){ if((val = *ptr)){ /* mask = (val >> bit_offset_MT); mask ^= (val >> bit_offset_M0); *(ptr - digit_offset) ^= mask; */ mask = ((gf_word) val << (GF_DIGIT_BIT - bit_offset_MT)); mask ^= ((gf_word) val << (GF_DIGIT_BIT - bit_offset_M0)); //mask &= GF_MASK; *(ptr - digit_offset -1) ^= (gf_unit) (mask & GF_MASK); *(ptr - digit_offset) ^= (gf_unit) (mask >> GF_DIGIT_BIT); *ptr = 0; } ptr--; p->used--; } if(p->used == digit_offset + 1){ mask = (((gf_unit)1 << bit_offset_M0) - 1) ^ GF_MASK; if((val = *ptr & mask)){ *ptr &= (mask ^ GF_MASK); mask = (val >> bit_offset_MT); mask ^= (val >> bit_offset_M0); *(ptr - digit_offset) ^= mask; } } while(!(*ptr) && p->used){ptr--, p->used--;} } //#elif (GF_T % GF_DIGIT_BIT == 0) void gf2m_Reduce_Congruent_T(gf_poly p) /* reduces p mod the irreducible trinomial X^191 + X^(GF_DIGIT_BIT*n) + 1 */ { assert(GF_Init); assert(p != NULL); //assert(gfExists(p)); const int digit_offset_M0 = GF_M/GF_DIGIT_BIT; const int digit_offset_MT = (GF_M-GF_T) / GF_DIGIT_BIT; const int bit_offset_M0 = GF_M % GF_DIGIT_BIT; register gf_unit val, *ptr, mask; ptr = &(p->dp[p->used-1]); while(p->used > digit_offset_M0 + 1){ if((val = *ptr)){ mask = (val >> bit_offset_M0); *(ptr - digit_offset_M0) ^= mask; *(ptr - digit_offset_MT) ^= mask; mask = (val << (GF_DIGIT_BIT - bit_offset_M0)) & GF_MASK; *(ptr - digit_offset_M0 -1) ^= mask; *(ptr - digit_offset_MT -1) ^= mask; *ptr = 0; } ptr--; p->used--; } if(p->used == digit_offset_M0 + 1){ mask = (((gf_unit)1 << bit_offset_M0) - 1) ^ GF_MASK; if((val = *ptr & mask)){ *ptr &= (mask ^ GF_MASK); mask = (val >> bit_offset_M0); *(ptr - digit_offset_M0) ^= mask; *(ptr - digit_offset_MT) ^= mask; } } while(!(*ptr) && p->used){ptr--, p->used--;} } //#elif (GF_M - GF_T > GF_DIGIT_BIT) void gf2m_Reduce_General(gf_poly p) /* reduces p mod the irreducible trinomial X^191 + Y^T + 1 */ { assert(GF_Init); assert(p != NULL); //assert(gfExists(p)); const int digit_offset_M0 = GF_M/GF_DIGIT_BIT; const int digit_offset_MT = (GF_M-GF_T) / GF_DIGIT_BIT; const int bit_offset_M0 = GF_M % GF_DIGIT_BIT; const int bit_offset_MT = (GF_M-GF_T) % GF_DIGIT_BIT; register gf_unit val, *ptr, mask; ptr = &(p->dp[p->used-1]); while(p->used > digit_offset_M0 + 1){ if((val = *ptr)){ mask = (val >> bit_offset_M0); *(ptr - digit_offset_M0) ^= mask; mask = (val >> bit_offset_MT); *(ptr - digit_offset_MT) ^= mask; mask = (val << (GF_DIGIT_BIT - bit_offset_M0)) & GF_MASK; *(ptr - digit_offset_M0 -1) ^= mask; mask = (val << (GF_DIGIT_BIT - bit_offset_MT)) & GF_MASK; *(ptr - digit_offset_MT -1) ^= mask; *ptr = 0; } ptr--; p->used--; } if(p->used == digit_offset_M0 + 1){ mask = (((gf_unit)1 << bit_offset_M0) - 1) ^ GF_MASK; if((val = *ptr & mask)){ *ptr &= (mask ^ GF_MASK); mask = (val >> bit_offset_M0); *(ptr - digit_offset_M0) ^= mask; mask = (val >> bit_offset_MT); *(ptr - digit_offset_MT) ^= mask; } } while(!(*ptr) && p->used){ptr--, p->used--;} } void gf2m_Reduce(gf_poly p) { if(GF_T < GF_DIGIT_BIT) gf2m_Reduce_Small_T(p); else if(GF_T % GF_DIGIT_BIT == 0) gf2m_Reduce_Congruent_T(p); else if(GF_M - GF_T > GF_DIGIT_BIT) gf2m_Reduce_General(p); return; } //#else // #error "Unsupported trinomial" //#endif #if 0 inline gf_unit gf2m_HalfSmallMult(gf_unit a, gf_unit b) { register gf_unit c = 0; register gf_unit mdor, mando; mdor = (a < b) ? a : b; mando = ( (a ^ b)) ^ mdor; while(mdor){ if(mdor & (gf_unit) 1) c ^= mando; mdor >>= 1; mando <<= 1; } return c; } inline gf_word gf2m_SmallMult(gf_unit a, gf_unit b) /*** returns a*b ***/ { //if(!a || !b) return (gf_word) 0; gf_unit lo_a, hi_a, lo_b, hi_b; static gf_unit shift2 = sizeof(gf_unit)/2; //static gf_unit shift = sizeof(gf_unit); static gf_unit mask = (1 << sizeof(gf_unit)/2) - 1; gf_unit lo_c, hi_c; gf_word c; lo_a = a & mask, lo_b = b & mask; hi_a = a >> shift2, hi_b = b >> shift2; lo_c = gf2m_HalfSmallMult(lo_a, lo_b); hi_c = gf2m_HalfSmallMult(hi_a, hi_b); c = (gf_word) hi_c << (gf_word) shift2; c ^= gf2m_HalfSmallMult(hi_a^lo_a, hi_b^lo_b)^lo_c^hi_c; c <<= (gf_word) shift2; c ^= (gf_word)lo_c; return c; } #endif inline gf_word gf2m_SmallMult(gf_unit a, gf_unit b) /*** returns a*b ***/ { gf_word c = 0; gf_word mdor, mando; mdor =(gf_word) (a < b) ? a : b; mando = ((gf_word) (a ^ b)) ^ mdor; while(mdor){ if(mdor & (gf_word) 1) c ^= mando; mdor >>= 1; mando <<= 1; } return c; } void _gf2m_Multiply (gf_poly s, /*const*/ gf_poly p, /*const*/ gf_poly q) /** Sets s = p*q (no reduction) **/ /** It computes products of size GF_DIGIT_BIT **/ { int deg_p, deg_q, sum; register int i, j, k; gf_word c, d[2*GF_M/GF_DIGIT_BIT+3]; gf_poly r; assert( (s != NULL) && (p != NULL) && (q != NULL) ); //assert(gfExists(s) && gfExists(p) && gfExists(q)); while(p->used < q->used) p->dp[p->used++] = 0; while(q->used < p->used) q->dp[q->used++] = 0; deg_p = p->used; deg_q = q->used; sum = deg_p + deg_q - 1; //gfOpen(r); gf2m_Zero(r); memset(d, 0, sizeof(d)); for(k = 0; k < sum; ++k){ if(k < deg_p && k < deg_q) d[k] = gf2m_SmallMult(p->dp[k], q->dp[k]); c = 0; i = k - deg_q + 1; for(i = ((i < 0)? 0:i), j = k - i; (i < deg_p) && (j >= i); ++i, --j){ if(i == j){ c ^= d[i]; } else { c ^= gf2m_SmallMult(p->dp[i] ^ p->dp[j], q->dp[i] ^ q->dp[j])^d[i]^d[j]; } } r->dp[k] ^= (c & GF_MASK); r->dp[k+1] ^= (c >> (gf_unit)GF_DIGIT_BIT); r->used += 2; /*gf_clamp(r);*/ } r->used++; gf_clamp(r); gfCopy(s, r); gfClear(r); gf_clamp(p); gf_clamp(q); } void gf2m_Multiply (gf_poly r, /*const*/ gf_poly p, /*const*/ gf_poly q) /** Sets r = p*q (mod R) **/ { _gf2m_Multiply (r, p, q); gf2m_Reduce(r); } #if 0 void _gf2m_Square(gf_poly r, /*const */ gf_poly p) /* sets r = p^2 No reduction */ /* only if GF_DIGIT_BIT == 28 **/ { register int i; register gf_unit c; const gf_unit mask = (1 << 14) - 1; gf_poly s; assert( (r != NULL) && (p != NULL) ); //assert(gfExists(r) && gfExists(p)); if(!tables_builded){ build_tables(); tables_builded = 1; } //gfOpen(s); gfZero(s); for(i = 0; i < p->used; ++i){ c = p->dp[i]; s->dp[s->used++] = sqr[c & mask]; s->dp[s->used++] = sqr[c >> 14]; } s->used++; gf_clamp(s); gfCopy(r, s); //gfClear(s); } #else void _gf2m_Square(gf_poly r, /*const */ gf_poly p) { register int i, j; register gf_unit c; int k, t; gf_word d; gf_poly s; assert( (r != NULL) && (p != NULL) ); //assert(gfExists(r) && gfExists(p)); if(!tables_builded){ build_tables(); tables_builded = 1; } //gfOpen(s); gfZero(s); for(i = k = 0; i < p->used; ++i, k += 2){ c = p->dp[i]; d = 0; j = 0; //fprintf(stderr, "Segmento %d:\t%lX\n", i, c); while(c){ t= sqr[(int)(c & 0xff)]; //fprintf(stderr, "%04x ", t); d ^= ((gf_word) t) << j; j += 16; //d <<= 16; c >>= 8; c &= GF_MASK; } //fprintf(stderr, "\n"); s->dp[k] ^= (d & GF_MASK); s->dp[k+1] ^= (d >> (gf_unit)GF_DIGIT_BIT); s->used += 2; } s->used++; gf_clamp(s); gfCopy(r, s); gfClear(s); } #endif void gf2m_Square(gf_poly r, /*const */ gf_poly p) /* sets r = p^2 (mod R) */ { _gf2m_Square(r, p); gf2m_Reduce(r); } /*** New inversion algorithm (a bit faster than previous ***/ ERROR gf2m_Divide (gf_poly g1,/* const */ gf_poly p, /* const */ gf_poly a) /* sets b := (p / a) mod (x^GF_M + x^GF_T + 1) */ /* warning: a, b and p must not overlap! */ /* 'p' can be null. Then, it will be performed a^-1 mod R */ { assert (GF_Init != 0); assert( (g1 != NULL) && (a != NULL) ); //assert(gfExists(b) && gfExists(a)); assert ((g1 != a) && (p != a)); if(gf_iszero(a)) return 1; const int M_digit_offset = (GF_M - 1)/ GF_DIGIT_BIT, T_digit_offset = (GF_T - 1)/ GF_DIGIT_BIT, M_bit_offset = (GF_M - 1) % GF_DIGIT_BIT, T_bit_offset = (GF_T - 1) % GF_DIGIT_BIT; const gf_unit lo = ((gf_unit)1 << T_bit_offset); const gf_unit hi = ((gf_unit)1 << M_bit_offset); int flag; /*register*/ gf_poly u, v, g2/*, g1*/; //g1[0] = b[0] /** Alias of b **/; //gfOpen(g2); gfOpen(u); gfOpen(v); /* initialize g1 := p; g2 := 0; u := a; v := x^GF_M + x^GF_T + 1: */ if(p == NULL){ /** Interprets 'only inversion of a' **/ gf2m_Set(g1, 1); } else { gfCopy(g1, p); } gf2m_Zero(g2); gf2m_Copy(u, a), gf2m_Copy(v, R); /*int count = 0;*/ while( (gf2m_CmpOne(u) != GF_EQ) && (gf2m_CmpOne(v) != GF_EQ)){ while(!gf_one(u)){ gf2m_Div_x(u, u); flag = gf_one(g1); gf2m_Div_x(g1, g1); if(flag){ g1->dp[M_digit_offset] ^= hi; g1->dp[T_digit_offset] ^= lo; g1->used = M_digit_offset + 1; } } while(!gf_one(v)){ gf2m_Div_x(v, v); flag = gf_one(g2); gf2m_Div_x(g2, g2); if(flag){ g2->dp[M_digit_offset] ^= hi; g2->dp[T_digit_offset] ^= lo; g2->used = M_digit_offset + 1; } } if(gf2m_Comp(u, v) == GF_GT){ gf2m_Add(u, u, v); gf2m_Add(g1, g1, g2); } else{ gf2m_Add(v, u, v); gf2m_Add(g2, g1, g2); } } if(gf2m_CmpOne(v) == GF_EQ) gf2m_Copy(g1, g2); gfClear(g2), gfClear(u), gfClear(v); return 0; } void gf2m_SquareRoot (gf_poly p, gf_unit b) /* sets p := sqrt(b) = b^(2^(GF_M-1)) */ { register int i; gf_poly q; assert(p != NULL); //assert(gfExists(p)); assert (GF_Init != 0); if(!b){ gf2m_Zero(p); return; } //gfOpen(q); gf2m_Set(p, b); i = GF_M - 1; while (i) { gf2m_Square (q, p); gf2m_Square (p, q); i -= 2; } gfClear(q); } /* gf2m_SquareRoot */ #ifndef TRACE_MASK int gf2m_Trace(/*const*/ gf_poly p) { int tr = 0; gf_poly t; assert (GF_Init != 0); assert( p != NULL ); //assert(gfExists(p)); //gfOpen(t); //mp_div_2d(p, GF_TM0, t, NULL); gf2m_Div_xn(t, GF_TM0, p); tr ^= gf_one(t); #ifdef GF_TM1 while(!gf_iszero(t)){ //mp_div_2d(t, GF_TM1, t, NULL); gf2m_Div_xn(t, GF_TM1, t); tr ^= gf_one(t); } #endif gfClear(t); return tr; } /* gf2m_Trace */ ERROR gf2m_SlowQuadSolve (gf_poly p, /*const*/ gf_poly beta) /* sets p to a solution of p^2 + p = beta Slow version */ { #if 0 assert (GF_Init != 0); assert( (beta != NULL) && (p != NULL) ); //assert(gfExists(beta) && gfExists(p)); assert (p != beta); if (gfTrace (beta) != 0) { return 1; /* no solution */ } #endif register int i; gf2m_Copy (p, beta); for (i = 0; i < GF_M/2; i++) { gf2m_Square (p, p); gf2m_Square (p, p); gf2m_Add (p, p, beta); } return 0; } /* gfQuadSolve */ ERROR gf2m_QuadSolve (gf_poly p, /*const*/ gf_poly beta) /* sets p to a solution of p^2 + p = beta Quick version. It uses precalculated values of beta = x^i */ { assert (GF_Init != 0); assert( (beta != NULL) && (p != NULL) ); assert (p != beta); if (gfTrace (beta) != 0) { return 1; /* no solution */ } #if !(defined GF_TM1) && (defined FULLTABLES) register int i; int j; register gf_unit bit_check = 1; gf2m_Zero(p); for(i = 0; i < GF_DIGIT_BIT; ++i){ for(j = 0; j < beta->used; ++j){ if(bit_check & beta->dp[j]) gf2m_Add(p, p, quad+GF_DIGIT_BIT*j+i); } bit_check <<= 1; } return 0; #else return gf2m_SlowQuadSolve (p, beta); #endif /* GF_TM1 - FULLTABLES */ } #endif /* ?TRACE_MASK */ void gf2m_Random(gf_poly a) /* Only for testing purposes */ { int i, shift; unsigned int rnd; assert( a != NULL); //assert(gfExists(a)); gf2m_Zero(a); shift = (sizeof(rnd) > GF_DIGIT_BIT)? GF_DIGIT_BIT: sizeof(rnd); for(i = 0; i < GF_M/shift + 1; ++i){ gf2m_Mul_xn(a, shift, a); //mp_mul_2d(a, shift, a); rnd = rand(); fp_add_d(a, rnd & GF_MASK, a); } gf2m_Reduce(a); } void gf2m_Print (FILE *fOut, /*const*/ char *tag, /*const*/ gf_poly p) /* prints tag and the contents of p to file fOut */ { char buf[256]; fp_toradix(p, buf,16); fprintf (fOut, "%s = %s\n", tag, buf); } #if defined GFLIB_TEST || defined TRACE_MASK int gf2m_SlowTrace (/*const*/ gf_poly p) /* slowly evaluates to the trace of p (or an error code) */ { int i; gf_poly t; assert (GF_Init != 0); //gfOpen(t); gf2m_Copy (t, p); for (i = 1; i < GF_M; i++) { gf2m_Square (t, t); gf2m_Add (t, t, p); } i = (t->used != 0); gfClear(t); return i; } /* gfSlowTrace */ #endif #ifdef GFLIB_TEST main(int argc, char ** argv) { int i, test_count ,afail = 0 ,mfail = 0 ,dfail = 0 ,sfail = 0 ,ifail = 0 // ,kfail = 0 ,rfail = 0 ,tfail = 0 ,qfail = 0 ,gfail = 0 ,dvfail = 0 ; gf_poly f, g, h, x, y, z; gf_unit b; clock_t elapsed, elap_quad = 0L, elap_mul = 0, //elap_kar = 0, elap_inv = 0, //elap_inv2 = 0, elap_sqr = 0; gf_word TOGGLE = ((gf_word)1 << GF_DIGIT_BIT) - 1; if(argc > 1){ test_count = atoi(argv[1]); } else test_count = 10; printf("Bits por dígito %d\n", GF_DIGIT_BIT); printf("Máscara %ld\n", GF_MASK); printf("Tamaño de dígito %d\n", sizeof(gf_unit)); printf("Tamaño de doble %d\n", sizeof(gf_word)); gfInit(); gfPrint(stderr, "R", R); srand ((unsigned)(time(NULL) % 65521U)); printf ("Executing %d field self tests.", test_count); /*printf("Parameters:\n Curve: %d\nField (2^%d)(2^%d)\n", LaCurva, GF_L, GF_K);*/ printf("Bits: %d\nTrinomial: %d\n", GF_M, GF_T); //gfOpen(f); gfOpen(g); gfOpen(h); //gfOpen(x); gfOpen(y); gfOpen(z); elapsed = -clock (); for (i = 0; i < test_count; i++) { gfRandom (f); gfRandom (g); gfRandom (h); /* addition test: f+g = g+f */ gfAdd (x, f, g); gfAdd (y, g, f); /*gfPrint(stderr, "sumando 1:\n", f); gfPrint(stderr, "sumando 2:\n", g); gfPrint(stderr, "resultado:\n", x);*/ if (!gfEqual (x, y)) { afail++; /* printf ("Addition test #%d failed!\n", i); */ } /* multiplication test: f*g = g*f */ /*mp_set(f, 1); gf_clamp(f);*/ elap_mul -= clock(); gf2m_Multiply (x, f, g); gf2m_Multiply (y, g, f); elap_mul += clock(); if (!gfEqual (x, y)) { fprintf(stderr, "Tamaño gf_word = %d\n", sizeof(gf_word)); gfPrint(stderr, "Verdadero", x); gfPrint(stderr, "Prueba ", y); mfail++; /*fprintf(stderr, "Elementos f: %d\n\n", f->K); fprintf(stderr, "Elementos g: %d\n\n", g->K);*/ /* printf ("Multiplication test #%d failed!\n", i); */ /*fprintf(stderr, "Prueba de multiplicar: %lx x %lx = %llx\n", b = (1 << GF_DIGIT_BIT ) - 1; 1, b, gf2m_SmallMult(b, 1));*/ } /* distribution test: f*(g+h) = f*g + f*h */ elap_mul -= clock(); gfMultiply (x, f, g); gfMultiply (y, f, h); elap_mul += clock(); gfAdd (y, x, y); gfAdd (z, g, h); elap_mul -= clock(); gfMultiply (x, f, z); elap_mul += clock(); if (!gfEqual (x, y)) { dfail++; /*gfPrint(stderr, "f", f); gfPrint(stderr, "g", g); gfPrint(stderr, "h", h); gfPrint(stderr, "f*(g+h)", x); fprintf(stderr, "Elementos: %d\n\n", x->K); gfPrint(stderr, "f*g+f*h", y); fprintf(stderr, "Elementos: %d\n\n", y->K); return -1; */ /* printf ("Distribution test #%d failed!\n", i); */ } /* karatsuba mul. test */ #if 0 elap_mul -= clock(); gfMultiply (x, f, g); elap_mul += clock(); elap_kar -= clock(); gf2m_KaratsubaMul(y, f, g); gfReduce(y); elap_kar += clock(); if (!gfEqual (x, y)) { kfail++; /*gfPrint(stderr, "f", f); gfPrint(stderr, "g", g); gfPrint(stderr, "h", h); gfPrint(stderr, "f*(g+h)", x); fprintf(stderr, "Elementos: %d\n\n", x->K); gfPrint(stderr, "f*g+f*h", y); fprintf(stderr, "Elementos: %d\n\n", y->K); return -1; */ /* printf ("Distribution test #%d failed!\n", i); */ } #endif /* squaring test: f^2 = f*f */ gfZero(x), gfZero(y); gfSet(f, 0xA234567); gf2m_Mul_xn(f, 100, f); gfReduce(f); elap_sqr -= clock(); _gf2m_Square (x, f); gfReduce(x); elap_sqr += clock(); elap_mul -= clock(); _gf2m_Multiply (y, f, f); gfReduce(y); elap_mul += clock(); if (!gfEqual (x, y)) { sfail++; gfPrint(stderr, "f", f); gfPrint(stderr, "f^2", x); gfPrint(stderr, "f*f", y); fprintf(stderr, "Número de dígitos: %d\n", x->used); fprintf(stderr, "Último dígito: %lx\n", y->dp[y->used-1]); fprintf(stderr, "Siguiente dígito: %lx\n", y->dp[y->used]); /*return -1;*/ /* printf ("Squaring test #%d failed:\n", i); */ } /** inversion test: g*(f/g) = f **/ if (!gf_iszero(g)) { /*gf2m_Set(g, 2);*/ gfReduce(g); elap_inv -= clock(); gf2m_Divide (x, f, g); /* x = 1/g */ elap_inv += clock(); //elap_inv2 -= clock(); //gf2m_Divide2 (y, f, x); /* y = f/x = f*g/f = g */ //elap_inv2 += clock(); /*gfReduce(f);*/ /*fprintf(stderr, "Grado de f: %d\n", gfDeg(f));*/ gfMultiply(y, g, x); /* y= x*g =? f */ if (!gfEqual (f, y)) { gfPrint(stderr, "Dividendo, f", f); gfPrint(stderr, "Divisor, g", g); gfPrint(stderr, "Cociente, x", x); gfPrint(stderr, "g·x = f?", y); ifail++; printf ("Inversion test #%d failed!\n", i); } } #if 0 /** new square algorithm test **/ mp_div_2d(g, GF_M/2, g, NULL); gfSquare(x, g); _gf2m_Square_new(y, g); gfReduce(y); if(!gfEqual (x, y)) { gfPrint(stderr, "Original", g); gfPrint(stderr, "Cuadrado ", x); gfPrint(stderr, "Nuevo cuadrado", y); return -1; } #endif /** square root test: sqrt(b)^2 = b */ b = rand () & TOGGLE; gf2m_Zero(z); if (b) { gf2m_Set(z, b); } else { gf2m_Zero(z); } gfSquareRoot (y, b); gfSquare (x, y); //_gf2m_Square_old(x, y); //gf2m_Reduce(x); if (!gfEqual (x, z)) { rfail++; gfPrint(stderr, "Original", z); gfPrint(stderr, "Raiz cuadrada", y); fprintf(stderr, "Grado: %d\n", gfDeg(y)); gfPrint(stderr, "y*y", x); return -1; /* printf ("Square root test #%d failed!\n", i); */ } /* trace test: slow tr(f) = tr(f) */ if (gfTrace (f) != gfSlowTrace (f)) { tfail++; /* printf ("Trace test #%d failed!\n", i); */ } /** quadratic equation solution test: x^2 + x = f (where tr(f) = 0)*/ if (gfTrace (f) == 0) { /*fprintf(stderr, "Traza no nula\n");*/ elap_quad -= clock (); gfQuadSolve (x, f); elap_quad += clock (); elap_sqr -= clock(); gfSquare (y, x); elap_sqr += clock(); gfAdd (y, y, x); if (!gfEqual (y, f)) { qfail++; /* printf ("Quadratic equation test #%d failed!\n", i); */ } } } elapsed += clock (); gfQuit(); printf (" done, elapsed time = %.2f s.\n", (float)elapsed/CLOCKS_PER_SEC); printf (" multiplication time = %.4f s.\n", (float)elap_mul/CLOCKS_PER_SEC/7.); //printf (" karatsuba mult. time = %.4f s.\n", (float)elap_kar/CLOCKS_PER_SEC); printf (" squaring time = %.4f s.\n", (float)elap_sqr/CLOCKS_PER_SEC/2.); printf (" quad- solving time = %.4f s.\n", (float)elap_quad/CLOCKS_PER_SEC); printf (" inversion time = %.4f s.\n", (float)elap_inv/CLOCKS_PER_SEC); //printf (" old inversion time = %.4f s.\n", (float)elap_inv2/CLOCKS_PER_SEC); if (gfail) printf ("---> %d degree checks failed <---\n", gfail); if (afail) printf ("---> %d additions failed <---\n", afail); if (mfail) printf ("---> %d multiplications failed <---\n", mfail); if (dfail) printf ("---> %d distributions failed <---\n", dfail); if (sfail) printf ("---> %d squarings failed <---\n", sfail); if (ifail) printf ("---> %d inversions failed <---\n", ifail); if (rfail) printf ("---> %d square roots failed <---\n", rfail); if (tfail) printf ("---> %d traces failed <---\n", tfail); /*if (qfail) printf ("---> %d quadratic equations failed <---\n", qfail);*/ //gfClear(x), gfClear(y), gfClear(z), gfClear(f), gfClear(g), gfClear(h); return afail || mfail || dfail || dvfail || sfail || ifail || rfail || tfail || qfail; } #elif defined TRACE_MASK main() { gf_poly x; int tr, i; //gfOpen(x); gf2m_Set(x, 1); gfInit(); printf("Polinomio: x^%d + x^%d + 1\n", GF_M, GF_T); for(i = 0; i < GF_M; ++i){ /*tr = gf2m_SlowTrace(x);*/ if((tr = gf2m_SlowTrace(x))) printf("Elemento: %d\tTraza: %d\n", i, tr); gf2m_Mul_x(x,x); } //gfClear(x); gfQuit(); } #endif sks-ecc-0.93/gflib.h0000644000175000017500000001013310715666303013200 0ustar nachonacho#ifndef __GFLIB_H #define __GFLIB_H /*** Prepared for X^191 + X^9 + 1 ***/ /*** Prepared for X^191 + X^18 + 1 ***/ /*** Prepared for X^191 + X^71 + 1 ***/ /*** Prepared for X^191 + X^140 + 1 ***/ #ifndef GF_M #define GF_M 191 #endif #ifndef GF_T #define GF_T 9 #endif #define GF_SIZE (GF_M/8 + 1) #ifndef TRACE_MASK #if (GF_M ==191) #if (GF_T==71) /*#define GF_TM0 0*/ #define GF_TM0 0 #elif (GF_T==9) /*#define GF_TM0 0*/ #define GF_TM0 0 #elif (GF_T==140) #define GF_TM1 51 #define GF_TM0 0 #elif (GF_T==18) #define GF_TM1 173 #define GF_TM0 0 #else #error "Unsupported trinomial" #endif /* ? GF_T */ #elif (GF_M==97) #if (GF_T==33 || GF_T==63) #define GF_TM0 0 #elif (GF_T==6) #define GF_TM0 0 #define GF_TM1 91 #else #error "Unsupported trinomial" #endif /* ? GF_T */ #else #error "Unsupported trinomial" #endif /* ?GF_M */ #endif /* ? TRACE_MASK */ #if 0 #include #include #include #ifndef DIGIT_BIT #ifdef __x86_64__ #define DIGIT_BIT 64 #else #define DIGIT_BIT 32 #endif /* ?__x86_64__*/ #endif /* ?DIGIT_BIT */ #endif //#include #include #ifndef DIGIT_BIT #error "No DIGIT_BIT" #endif //#define LAST_DIGIT(m) DIGIT(m,(m->used - 1)) #define GF_DIGIT_BIT DIGIT_BIT typedef int ERROR; typedef fp_digit gf_unit; typedef fp_word gf_word; typedef fp_int _gf_poly; typedef fp_int gf_poly[1]; /*** Compressed type ****/ typedef unsigned char gfPoint[GF_SIZE]; #define GF_MASK FP_MASK #define GF_EQ FP_EQ #define GF_GT FP_GT #define GF_LT FP_LT #define gf_iszero fp_iszero #define gfYbit fp_isodd #define gf_one fp_isodd #define gf_clamp fp_clamp #define gf2m_CmpOne(A) fp_cmp_d(A,1) #define gf_toradix(A,B,C) fp_toradix(A,B,C) //#define gfExists(A) (((A)->alloc != 0) && ((A)->dp != NULL)) #define gfGet(A,B,C) fp_read_unsigned_bin((A),(B),(C)) #define gfPut(A,B) fp_to_unsigned_bin((A),(B)) #define gfSize(A) fp_unsigned_bin_size((A)) /*#define gfPack(A, B) gfPut(A,B)*/ #define gfUnpack(A,B) gfGet(A,B, GF_SIZE) /*#define gfGet mpGet #define gfPut mpPut #define gfSize mpSize */ #define gf2m_Equal(A, B) (!fp_cmp_mag(A,B)) #define gf2m_Comp(A, B) fp_cmp_mag(A,B) #define gf2m_Copy(D, S) fp_copy(S, D) //#define gf2m_Add(D, A, B) fp_xor(A, B, D) #define gf2m_Set fp_set #define gf2m_Zero fp_zero #define gf2m_Clear fp_zero #define gf2m_Div_x(A,B) fp_div_2(B,A) #define gf2m_Div_xn(A,D,B) fp_div_2d(B,D,A,NULL) #define gf2m_Mul_x(A,B) fp_mul_2(B,A) #define gf2m_Mul_xn(A,D,B) fp_mul_2d(B,(D),A) /*#define gf2m_Square(D, S) gf2m_Multiplica(D, S, S)*/ /*int gf2m_Open(gf_poly *a);*/ //gf_poly gf2m_Open(void); ERROR gf2m_Init(void); void gf2m_Quit(void); int gf2m_Deg(gf_poly a); void gf2m_Add(gf_poly c, gf_poly a, gf_poly b); //void gf2m_Clear(gf_poly a); void gf2m_Pack(gf_poly a, gfPoint b); void gf2m_SmallAdd(gf_poly a, gf_unit b); void gf2m_Reduce(gf_poly p); void gf2m_Multiply (gf_poly r, /*const*/ gf_poly p, /*const*/ gf_poly q); void gf2m_Square(gf_poly r, gf_poly p); /*ERROR gf2m_Invert (gf_poly b, gf_poly a);*/ ERROR gf2m_Divide (gf_poly b,/* const */ gf_poly p, /* const */ gf_poly a); void gf2m_SquareRoot (gf_poly p, gf_unit b); int gf2m_Trace(/*const*/ gf_poly p); ERROR gf2m_QuadSolve (gf_poly p, /*const*/ gf_poly beta); ERROR gf2m_SlowQuadSolve (gf_poly p, /*const*/ gf_poly beta); void gf2m_Random(gf_poly a); void gf2m_Print (FILE *fOut, /*const*/ char *tag, /*const*/ gf_poly p); #define gfInit gf2m_Init #define gfQuit gf2m_Quit #define gfDeg gf2m_Deg #define gfPack gf2m_Pack #define gfEqual gf2m_Equal #define gfCopy gf2m_Copy #define gfAdd gf2m_Add #define gfReduce gf2m_Reduce #define gfMultiply gf2m_Multiply #define gfSquare gf2m_Square /*#define gfInvert gf2m_Invert*/ #define gfSquareRoot gf2m_SquareRoot #define gfSlowTrace gf2m_SlowTrace #define gfTrace gf2m_Trace #define gfQuadSolve gf2m_QuadSolve #define gfRandom gf2m_Random #define gfPrint gf2m_Print #define gfSet gf2m_Set #define gfZero gf2m_Zero #define gfSmallAdd gf2m_SmallAdd #define gfDivide gf2m_Divide #define gfClear(A) gf2m_Clear((A)) //#define gfOpen(A) {A = gf2m_Open();} #define gfInvert(A,B) gf2m_Divide(A,NULL,B) #endif /* ? __GF2M_H */ sks-ecc-0.93/hash.c0000644000175000017500000001114510715702751013035 0ustar nachonacho/* hash.c Hashing high-level functions of 'sks' project Copyright (C) 2004-2007 Manuel Pancorbo Castro This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Manuel Pancorbo Castro */ /*#include */ #include #include "mycrypt.h" #include "sks.h" /** First 2048 bits of PI/4. To be the salt of passwords **/ unsigned char salt[PASSWD_SIZE] = { 0xc9, 0x0f, 0xda, 0xa2, 0x21, 0x68, 0xc2, 0x34, 0xc4, 0xc6, 0x62, 0x8b, 0x80, 0xdc, 0x1c, 0xd1, 0x29, 0x02, 0x4e, 0x08, 0x8a, 0x67, 0xcc, 0x74, 0x02, 0x0b, 0xbe, 0xa6, 0x3b, 0x13, 0x9b, 0x22, 0x51, 0x4a, 0x08, 0x79, 0x8e, 0x34, 0x04, 0xdd, 0xef, 0x95, 0x19, 0xb3, 0xcd, 0x3a, 0x43, 0x1b, 0x30, 0x2b, 0x0a, 0x6d, 0xf2, 0x5f, 0x14, 0x37, 0x4f, 0xe1, 0x35, 0x6d, 0x6d, 0x51, 0xc2, 0x45, 0xe4, 0x85, 0xb5, 0x76, 0x62, 0x5e, 0x7e, 0xc6, 0xf4, 0x4c, 0x42, 0xe9, 0xa6, 0x37, 0xed, 0x6b, 0x0b, 0xff, 0x5c, 0xb6, 0xf4, 0x06, 0xb7, 0xed, 0xee, 0x38, 0x6b, 0xfb, 0x5a, 0x89, 0x9f, 0xa5, 0xae, 0x9f, 0x24, 0x11, 0x7c, 0x4b, 0x1f, 0xe6, 0x49, 0x28, 0x66, 0x51, 0xec, 0xe4, 0x5b, 0x3d, 0xc2, 0x00, 0x7c, 0xb8, 0xa1, 0x63, 0xbf, 0x05, 0x98, 0xda, 0x48, 0x36, 0x1c, 0x55, 0xd3, 0x9a, 0x69, 0x16, 0x3f, 0xa8, 0xfd, 0x24, 0xcf, 0x5f, 0x83, 0x65, 0x5d, 0x23, 0xdc, 0xa3, 0xad, 0x96, 0x1c, 0x62, 0xf3, 0x56, 0x20, 0x85, 0x52, 0xbb, 0x9e, 0xd5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6d, 0x67, 0x0c, 0x35, 0x4e, 0x4a, 0xbc, 0x98, 0x04, 0xf1, 0x74, 0x6c, 0x08, 0xca, 0x18, 0x21, 0x7c, 0x32, 0x90, 0x5e, 0x46, 0x2e, 0x36, 0xce, 0x3b, 0xe3, 0x9e, 0x77, 0x2c, 0x18, 0x0e, 0x86, 0x03, 0x9b, 0x27, 0x83, 0xa2, 0xec, 0x07, 0xa2, 0x8f, 0xb5, 0xc5, 0x5d, 0xf0, 0x6f, 0x4c, 0x52, 0xc9, 0xde, 0x2b, 0xcb, 0xf6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7c, 0xea, 0x95, 0x6a, 0xe5, 0x15, 0xd2, 0x26, 0x18, 0x98, 0xfa, 0x05, 0x10, 0x15, 0x72, 0x8e, 0x5a, 0x8a, 0xaa, 0xc4, 0x2d, 0xad, 0x33, 0x17, 0x0d, 0x04, 0x50, 0x7a, 0x33, 0xa8, 0x55, 0x21, 0xab, 0xdf, 0x1c, 0xba, 0x64, }; const char end_common [] = "###-------------------------SKS"; /******************* ** Hashing functions **/ ERROR hash_password(char *frase, PrivKey p) { unsigned char pass[PASSWD_SIZE]; memcpy(pass, salt, PASSWD_SIZE); memcpy(pass, frase, strlen(frase)); return hash_binary(p, pass, PASSWD_SIZE); } ERROR hash_binary(byte *buf, byte *bin, size_t len) { hash_state md; ERROR err; tiger_init(&md); if((err = tiger_process(&md, bin, len))) return err; if((err = tiger_done(&md, buf))) return err; return 0; } static hash_state md_file; ERROR hash_binary_file(FILE *inp) { byte *buffer; int fd, i = 1; unsigned long int len, max_size = MAX_ALLOC_SIZE; ERROR err; while((buffer = malloc(max_size)) == NULL){ max_size /= ++i; } tiger_init(&md_file); fd = fileno(inp); while(/*!(feof(inp))*/ 1){ if(!(len = read(fd, buffer, max_size))) break; if((err = tiger_process(&md_file, buffer, len))) return err; } /*if((err = tiger_done(&md, out))) return err;*/ zeromem(buffer, max_size); free(buffer); return 0; } ERROR hash_ascii_text(FILE * f_inp, FILE * f_out, int write) { unsigned n; byte buffer[MEDIUM_BUF]; /*hash_state md;*/ ERROR err = 0; tiger_init(&md_file); while (!feof(f_inp)){ fgets((char *)buffer, MEDIUM_BUF, f_inp); /* EOL -> \n */ n = strlen((char *)buffer); if(!n) break; if((buffer[n-1] == '\n') || (buffer[n-1] == '\r')) buffer[n-1] = 0; if((buffer[n-2] == '\n') || (buffer[n-2] == '\r')) buffer[n-2] = 0; n = strlen((char*)buffer); if(!write && !strncmp((char *)buffer, end_common, sizeof(end_common) - 1)) break; /* must be end of packet */ fputs( (char*)buffer, f_out); fputs("\n", f_out); if((err = tiger_process(&md_file, buffer, n))) return err; memset(buffer, 0, n); } /*err = tiger_done(&md, c);*/ zeromem( buffer, sizeof(buffer)); burn_stack(MEDIUM_BUF + 100); return err; } ERROR hash_time(vlPoint c, time_t t) { if(t != 0L){ unsigned char tmp[4]; int i; for(i = 0; i < 4; ++i){ tmp[i] = t & 0xff; t >>= 8; } tiger_process(&md_file, tmp, 4); } return tiger_done(&md_file, c); } sks-ecc-0.93/keyring.c0000644000175000017500000002076210715702751013567 0ustar nachonacho/* keyring.c Key management functions of 'sks' project Copyright (C) 2004-2007 Manuel Pancorbo Castro This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Manuel Pancorbo Castro */ #include #include #include #include #include "gflib.h" #include "binasc.h" #include "sks.h" const char pubkey_head [] = "-----SKS KEY-----"; const char pubkey_magic [] = "key: "; keyring default_kr = {NULL, NULL, 0}; extern char err_open_failed[]; extern char err_bad_public_key[]; extern char err_corr_public_key[]; extern char msg_added_key[]; extern char msg_key_exists[]; extern char msg_deleted_key[]; extern char ask_idnum[]; FILE * chkopen( char * s, char * mode ) { FILE * result = fopen(s,mode); if (!result) { fputs(CHCONV(err_open_failed), stderr ); fputs( s, stderr ); fputs("\n", stderr); } return result; } void get_full_path(char *name, char * buf) { strcpy(buf, ""); #ifdef LINUX struct passwd *pwd; pwd = getpwuid(getuid()); strcat(buf, pwd->pw_dir); strcat(buf, name); #elif defined WIN32 strcat(buf, getenv(HOME_VAR)); strcat(buf, KEY_DIR); strcat(buf, name); #endif } FILE * open_keyring(char * mode ) { char buf[SMALL_BUF]; FILE *result; get_full_path(KEYRING, buf); result = fopen(buf,mode); if(result == NULL){ if(mode[0] == 'r') result = fopen(buf, "w+"); } if(result == NULL){ fputs( CHCONV(err_open_failed), stderr ); fputs( buf, stderr ); fputs("\n", stderr); } return result; } FILE * open_prngfile(void) { char buf[SMALL_BUF]; FILE *result; get_full_path(PRNGFILE, buf); result = fopen(buf, "r+"); if(result == NULL) result = fopen(buf, "w+"); return result; } ERROR get_keyid(PubKey key, unsigned long *id) { static unsigned long int check = (GF_M << 24) + (GF_T << 16) + (EC_B << 4) #ifdef EC_A + EC_A #endif ; *id = crc32(check, key, KEY_SIZE); return 0; } ERROR write_pubkey(FILE *ptr, keychain *key) { assert((ptr != NULL) && (key != NULL)); unsigned long int id; fputs(pubkey_magic, ptr); fwritePlus(key->val, 1, KEY_SIZE, ptr, 0); id = key->id; /** Three low bytes of id. are output as crc-like integrity check **/ fputcPlus((id & 0xFF), ptr, 0); id >>= 8; fputcPlus((id & 0xFF), ptr, 0); id >>= 8; fputcPlus((id & 0xFF), ptr, 0); flushArmour(ptr); fputs(key->lab, ptr); fputs("\n", ptr); return 0; } ERROR get_pubkey(FILE *ptr, keychain *b) { char buf[SMALL_BUF]; int size, len; unsigned long int id1, a; len = strlen(pubkey_magic); fread(buf, 1, len, ptr); if(strncmp(buf, pubkey_magic, len)) return -3; size = freadPlus(b->val, 1, KEY_SIZE, ptr, 0); if(size != KEY_SIZE) return -2; /** Check integrity **/ get_keyid(b->val, &(b->id)); freadPlus(buf, 1, 3, ptr, 0); id1 = buf[0] & 0xff; a = buf[1] & 0xff; id1 += a << 8; a = buf[2] & 0xff; id1 += a << 16; if(id1 != (b->id & 0x00ffffff)) return -1; burnBinasc(); return 0; } ERROR new_key_chain(keyring *kr) { assert(kr != NULL); kr->vector = realloc(kr->vector, (kr->N + 1) * sizeof(keychain)); if(kr->vector == NULL) return -1; kr->actual = &(kr->vector[kr->N]); kr->N++; return 0; } void close_keyring(keyring *kr) { if(kr->N == 0) return; /** Nothing to do **/ free(kr->vector); kr->N = 0; kr->vector = kr->actual = NULL; } ERROR add_to_keyring(keyring *kr, keychain *a) { assert(kr != NULL); assert(a != NULL); if (new_key_chain(kr)) return -1; memcpy(kr->actual, a, sizeof(keychain)); return 0; } ERROR load_keyring(FILE *inp, keyring *kr) { char buf[SMALL_BUF]; ERROR err = 0; int main_kr = 0, i = 0; keychain a; assert(kr != NULL); kr->N = 0; if(inp == NULL){ #ifdef WIN32 #include if(kr == &default_kr){ char dir_buf[SMALL_BUF]; DIR *check; strcpy(dir_buf, getenv(HOME_VAR)); strcat(dir_buf, KEY_DIR); if((check = opendir(dir_buf)) == NULL){ char order[SMALL_BUF]; strcpy(order, "mkdir \""); strcat(order, dir_buf); strcat(order, "\""); system(order); } } #endif if((inp = open_keyring("r")) == NULL) return -1; main_kr = 1; } while(!position(inp, pubkey_head) && !feof(inp)){ if((err = get_pubkey(inp, &a))){ if(err == -3){ fputs( CHCONV(err_bad_public_key), stderr ); fputs( pubkey_magic, stderr ); fputs( "\n", stderr ); } else fputs( CHCONV(err_corr_public_key), stderr ); } fgets(a.lab, SMALL_BUF, inp); add_to_keyring(kr, &a); if (kr == &default_kr){ fgets(buf, SMALL_BUF, inp); } ++i; } kr->actual = &(kr->vector[0]); if(main_kr) fclose(inp); return err; } ERROR write_keyring() { keyring *kr = &default_kr; FILE *kr_file; int i; kr_file = open_keyring("w"); for(i = 0; i < kr->N; ++i){ fputs(pubkey_head, kr_file), fputs("\n", kr_file); if(write_pubkey(kr_file, kr->vector + i )) return -1; } fclose(kr_file); return 0; } int search_pubkey(keyring *inp, int *ext, char **pattern, FILE *out, int mode) { char idstring[16]; ERROR err = 0; int i, j, hit = 0, total = 0; for(i = 0; i < inp->N; ++i){ if(pattern == NULL) hit = 1; else{ /*get_keyid(inp->vector[i].val, &id);*/ sprintf(idstring, "%08lx", inp->vector[i].id); for(j = 0; (pattern[j] != NULL) && (hit == 0); ++j){ if((str_match(inp->vector[i].lab, pattern[j])) || (str_match(idstring, pattern[j])) ){ hit = 1; } } } if(hit){ if(ext != NULL){ *ext = i; ++ext; } if(out != NULL){ /** Put out mode **/ if(mode == 'l' || mode == 'f'){ fprintf(out, " [%08lx]: ", inp->vector[i].id); fputs(inp->vector[i].lab, out); if(mode == 'f'){ fputs(" ", out); /* for(j = 0; j < KEY_SIZE; ++j){ fprintf(out, "%02X", inp->vector[i].val[j]); if(!((j+1)%4)) fputs(" ", out); } */ fputs_base36(inp->vector[i].val, out); fputs("\n\n", out); } } else { /** mode == EXPORT **/ fputs(pubkey_head, out), fputs("\n", out); if((err = write_pubkey(out, inp->vector + i/*[i].val, pubkey_magic*/))) return -1; } } total++; } hit = 0; } return total; } ERROR import_keyring(FILE *inp) { keyring ext = {NULL, NULL, 0}; int i, j, coincid, err = 0, change = 0; char idstring[16], *pattern[2]; if(( err = load_keyring(inp, &ext))) return err; pattern[1] = NULL; for(i = 0; i < ext.N; ++i){ /** Look for coincidences in actual keyring **/ coincid = 0; for(j = 0; j < default_kr.N; ++j){ if(!memcmp(ext.vector[i].val, default_kr.vector[j].val, KEY_SIZE)){ coincid = 1; break; } } if (!coincid){ add_to_keyring(&default_kr, ext.vector + i); change = 1; fprintf(stderr, "%s [%08lx]: %s", CHCONV(msg_added_key), ext.vector[i].id, ext.vector[i].lab); } else{ sprintf(idstring, "%08lx", ext.vector[i].id); fprintf(stderr, "->%s<- %s", idstring, CHCONV(msg_key_exists)); pattern[0] = &(idstring[0]); search_pubkey(&default_kr, NULL, pattern, stderr, 'l'); } } if(change) write_keyring(); close_keyring(&ext); return 0; } ERROR delete_element(char *idstring) { keyring ext = {NULL, NULL, /*-1,*/ 0}; int i, change = 0; ERROR err = 0; unsigned long int id; char buf[SMALL_BUF]; if(idstring == NULL){ search_pubkey(&default_kr, NULL, NULL, stderr, 'l'); get_text(stdin, buf, CHCONV(ask_idnum)); idstring = buf; } sscanf(idstring, "%lx", &id); fprintf(stderr, " [%08lx] ", id); for(i = 0; i < default_kr.N; ++i){ if((err = add_to_keyring(&ext, default_kr.vector + i))) break; } close_keyring(&default_kr); for(i = 0; i < ext.N; ++i){ if(id != ext.vector[i].id){ if((err = add_to_keyring(&default_kr, ext.vector + i))) break; } else change = 1; } if(change){ fputs(CHCONV(msg_deleted_key), stderr); search_pubkey(&default_kr, NULL, NULL, stderr, 'l'); write_keyring(); } else{ search_pubkey(&default_kr, NULL, NULL, NULL, 'l'); err = -1; } if(ext.N) close_keyring(&ext); return err; } sks-ecc-0.93/ltc/0000755000175000017500000000000010715702751012526 5ustar nachonachosks-ecc-0.93/ltc/tiger.c0000644000175000017500000015202110715702751014005 0ustar nachonacho/* tiger.c (Part of SKS cryptosystem) Primitives of 'tiger'-hash This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Manuel Pancorbo Castro */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@iahu.ca, http://libtomcrypt.org */ #include "mycrypt.h" void burn_stack(unsigned long); #ifdef TIGER const struct _hash_descriptor tiger_desc = { "tiger", 1, 24, 64, &tiger_init, &tiger_process, &tiger_done, &tiger_test }; #define t1 (table) #define t2 (table+256) #define t3 (table+256*2) #define t4 (table+256*3) #ifdef SMALL_CODE static ulong64 table[4*256]; static int table_builded = 0; typedef unsigned char octet[8]; #else static const ulong64 table[4*256] = { CONST64(0x02AAB17CF7E90C5E) /* 0 */, CONST64(0xAC424B03E243A8EC) /* 1 */, CONST64(0x72CD5BE30DD5FCD3) /* 2 */, CONST64(0x6D019B93F6F97F3A) /* 3 */, CONST64(0xCD9978FFD21F9193) /* 4 */, CONST64(0x7573A1C9708029E2) /* 5 */, CONST64(0xB164326B922A83C3) /* 6 */, CONST64(0x46883EEE04915870) /* 7 */, CONST64(0xEAACE3057103ECE6) /* 8 */, CONST64(0xC54169B808A3535C) /* 9 */, CONST64(0x4CE754918DDEC47C) /* 10 */, CONST64(0x0AA2F4DFDC0DF40C) /* 11 */, CONST64(0x10B76F18A74DBEFA) /* 12 */, CONST64(0xC6CCB6235AD1AB6A) /* 13 */, CONST64(0x13726121572FE2FF) /* 14 */, CONST64(0x1A488C6F199D921E) /* 15 */, CONST64(0x4BC9F9F4DA0007CA) /* 16 */, CONST64(0x26F5E6F6E85241C7) /* 17 */, CONST64(0x859079DBEA5947B6) /* 18 */, CONST64(0x4F1885C5C99E8C92) /* 19 */, CONST64(0xD78E761EA96F864B) /* 20 */, CONST64(0x8E36428C52B5C17D) /* 21 */, CONST64(0x69CF6827373063C1) /* 22 */, CONST64(0xB607C93D9BB4C56E) /* 23 */, CONST64(0x7D820E760E76B5EA) /* 24 */, CONST64(0x645C9CC6F07FDC42) /* 25 */, CONST64(0xBF38A078243342E0) /* 26 */, CONST64(0x5F6B343C9D2E7D04) /* 27 */, CONST64(0xF2C28AEB600B0EC6) /* 28 */, CONST64(0x6C0ED85F7254BCAC) /* 29 */, CONST64(0x71592281A4DB4FE5) /* 30 */, CONST64(0x1967FA69CE0FED9F) /* 31 */, CONST64(0xFD5293F8B96545DB) /* 32 */, CONST64(0xC879E9D7F2A7600B) /* 33 */, CONST64(0x860248920193194E) /* 34 */, CONST64(0xA4F9533B2D9CC0B3) /* 35 */, CONST64(0x9053836C15957613) /* 36 */, CONST64(0xDB6DCF8AFC357BF1) /* 37 */, CONST64(0x18BEEA7A7A370F57) /* 38 */, CONST64(0x037117CA50B99066) /* 39 */, CONST64(0x6AB30A9774424A35) /* 40 */, CONST64(0xF4E92F02E325249B) /* 41 */, CONST64(0x7739DB07061CCAE1) /* 42 */, CONST64(0xD8F3B49CECA42A05) /* 43 */, CONST64(0xBD56BE3F51382F73) /* 44 */, CONST64(0x45FAED5843B0BB28) /* 45 */, CONST64(0x1C813D5C11BF1F83) /* 46 */, CONST64(0x8AF0E4B6D75FA169) /* 47 */, CONST64(0x33EE18A487AD9999) /* 48 */, CONST64(0x3C26E8EAB1C94410) /* 49 */, CONST64(0xB510102BC0A822F9) /* 50 */, CONST64(0x141EEF310CE6123B) /* 51 */, CONST64(0xFC65B90059DDB154) /* 52 */, CONST64(0xE0158640C5E0E607) /* 53 */, CONST64(0x884E079826C3A3CF) /* 54 */, CONST64(0x930D0D9523C535FD) /* 55 */, CONST64(0x35638D754E9A2B00) /* 56 */, CONST64(0x4085FCCF40469DD5) /* 57 */, CONST64(0xC4B17AD28BE23A4C) /* 58 */, CONST64(0xCAB2F0FC6A3E6A2E) /* 59 */, CONST64(0x2860971A6B943FCD) /* 60 */, CONST64(0x3DDE6EE212E30446) /* 61 */, CONST64(0x6222F32AE01765AE) /* 62 */, CONST64(0x5D550BB5478308FE) /* 63 */, CONST64(0xA9EFA98DA0EDA22A) /* 64 */, CONST64(0xC351A71686C40DA7) /* 65 */, CONST64(0x1105586D9C867C84) /* 66 */, CONST64(0xDCFFEE85FDA22853) /* 67 */, CONST64(0xCCFBD0262C5EEF76) /* 68 */, CONST64(0xBAF294CB8990D201) /* 69 */, CONST64(0xE69464F52AFAD975) /* 70 */, CONST64(0x94B013AFDF133E14) /* 71 */, CONST64(0x06A7D1A32823C958) /* 72 */, CONST64(0x6F95FE5130F61119) /* 73 */, CONST64(0xD92AB34E462C06C0) /* 74 */, CONST64(0xED7BDE33887C71D2) /* 75 */, CONST64(0x79746D6E6518393E) /* 76 */, CONST64(0x5BA419385D713329) /* 77 */, CONST64(0x7C1BA6B948A97564) /* 78 */, CONST64(0x31987C197BFDAC67) /* 79 */, CONST64(0xDE6C23C44B053D02) /* 80 */, CONST64(0x581C49FED002D64D) /* 81 */, CONST64(0xDD474D6338261571) /* 82 */, CONST64(0xAA4546C3E473D062) /* 83 */, CONST64(0x928FCE349455F860) /* 84 */, CONST64(0x48161BBACAAB94D9) /* 85 */, CONST64(0x63912430770E6F68) /* 86 */, CONST64(0x6EC8A5E602C6641C) /* 87 */, CONST64(0x87282515337DDD2B) /* 88 */, CONST64(0x2CDA6B42034B701B) /* 89 */, CONST64(0xB03D37C181CB096D) /* 90 */, CONST64(0xE108438266C71C6F) /* 91 */, CONST64(0x2B3180C7EB51B255) /* 92 */, CONST64(0xDF92B82F96C08BBC) /* 93 */, CONST64(0x5C68C8C0A632F3BA) /* 94 */, CONST64(0x5504CC861C3D0556) /* 95 */, CONST64(0xABBFA4E55FB26B8F) /* 96 */, CONST64(0x41848B0AB3BACEB4) /* 97 */, CONST64(0xB334A273AA445D32) /* 98 */, CONST64(0xBCA696F0A85AD881) /* 99 */, CONST64(0x24F6EC65B528D56C) /* 100 */, CONST64(0x0CE1512E90F4524A) /* 101 */, CONST64(0x4E9DD79D5506D35A) /* 102 */, CONST64(0x258905FAC6CE9779) /* 103 */, CONST64(0x2019295B3E109B33) /* 104 */, CONST64(0xF8A9478B73A054CC) /* 105 */, CONST64(0x2924F2F934417EB0) /* 106 */, CONST64(0x3993357D536D1BC4) /* 107 */, CONST64(0x38A81AC21DB6FF8B) /* 108 */, CONST64(0x47C4FBF17D6016BF) /* 109 */, CONST64(0x1E0FAADD7667E3F5) /* 110 */, CONST64(0x7ABCFF62938BEB96) /* 111 */, CONST64(0xA78DAD948FC179C9) /* 112 */, CONST64(0x8F1F98B72911E50D) /* 113 */, CONST64(0x61E48EAE27121A91) /* 114 */, CONST64(0x4D62F7AD31859808) /* 115 */, CONST64(0xECEBA345EF5CEAEB) /* 116 */, CONST64(0xF5CEB25EBC9684CE) /* 117 */, CONST64(0xF633E20CB7F76221) /* 118 */, CONST64(0xA32CDF06AB8293E4) /* 119 */, CONST64(0x985A202CA5EE2CA4) /* 120 */, CONST64(0xCF0B8447CC8A8FB1) /* 121 */, CONST64(0x9F765244979859A3) /* 122 */, CONST64(0xA8D516B1A1240017) /* 123 */, CONST64(0x0BD7BA3EBB5DC726) /* 124 */, CONST64(0xE54BCA55B86ADB39) /* 125 */, CONST64(0x1D7A3AFD6C478063) /* 126 */, CONST64(0x519EC608E7669EDD) /* 127 */, CONST64(0x0E5715A2D149AA23) /* 128 */, CONST64(0x177D4571848FF194) /* 129 */, CONST64(0xEEB55F3241014C22) /* 130 */, CONST64(0x0F5E5CA13A6E2EC2) /* 131 */, CONST64(0x8029927B75F5C361) /* 132 */, CONST64(0xAD139FABC3D6E436) /* 133 */, CONST64(0x0D5DF1A94CCF402F) /* 134 */, CONST64(0x3E8BD948BEA5DFC8) /* 135 */, CONST64(0xA5A0D357BD3FF77E) /* 136 */, CONST64(0xA2D12E251F74F645) /* 137 */, CONST64(0x66FD9E525E81A082) /* 138 */, CONST64(0x2E0C90CE7F687A49) /* 139 */, CONST64(0xC2E8BCBEBA973BC5) /* 140 */, CONST64(0x000001BCE509745F) /* 141 */, CONST64(0x423777BBE6DAB3D6) /* 142 */, CONST64(0xD1661C7EAEF06EB5) /* 143 */, CONST64(0xA1781F354DAACFD8) /* 144 */, CONST64(0x2D11284A2B16AFFC) /* 145 */, CONST64(0xF1FC4F67FA891D1F) /* 146 */, CONST64(0x73ECC25DCB920ADA) /* 147 */, CONST64(0xAE610C22C2A12651) /* 148 */, CONST64(0x96E0A810D356B78A) /* 149 */, CONST64(0x5A9A381F2FE7870F) /* 150 */, CONST64(0xD5AD62EDE94E5530) /* 151 */, CONST64(0xD225E5E8368D1427) /* 152 */, CONST64(0x65977B70C7AF4631) /* 153 */, CONST64(0x99F889B2DE39D74F) /* 154 */, CONST64(0x233F30BF54E1D143) /* 155 */, CONST64(0x9A9675D3D9A63C97) /* 156 */, CONST64(0x5470554FF334F9A8) /* 157 */, CONST64(0x166ACB744A4F5688) /* 158 */, CONST64(0x70C74CAAB2E4AEAD) /* 159 */, CONST64(0xF0D091646F294D12) /* 160 */, CONST64(0x57B82A89684031D1) /* 161 */, CONST64(0xEFD95A5A61BE0B6B) /* 162 */, CONST64(0x2FBD12E969F2F29A) /* 163 */, CONST64(0x9BD37013FEFF9FE8) /* 164 */, CONST64(0x3F9B0404D6085A06) /* 165 */, CONST64(0x4940C1F3166CFE15) /* 166 */, CONST64(0x09542C4DCDF3DEFB) /* 167 */, CONST64(0xB4C5218385CD5CE3) /* 168 */, CONST64(0xC935B7DC4462A641) /* 169 */, CONST64(0x3417F8A68ED3B63F) /* 170 */, CONST64(0xB80959295B215B40) /* 171 */, CONST64(0xF99CDAEF3B8C8572) /* 172 */, CONST64(0x018C0614F8FCB95D) /* 173 */, CONST64(0x1B14ACCD1A3ACDF3) /* 174 */, CONST64(0x84D471F200BB732D) /* 175 */, CONST64(0xC1A3110E95E8DA16) /* 176 */, CONST64(0x430A7220BF1A82B8) /* 177 */, CONST64(0xB77E090D39DF210E) /* 178 */, CONST64(0x5EF4BD9F3CD05E9D) /* 179 */, CONST64(0x9D4FF6DA7E57A444) /* 180 */, CONST64(0xDA1D60E183D4A5F8) /* 181 */, CONST64(0xB287C38417998E47) /* 182 */, CONST64(0xFE3EDC121BB31886) /* 183 */, CONST64(0xC7FE3CCC980CCBEF) /* 184 */, CONST64(0xE46FB590189BFD03) /* 185 */, CONST64(0x3732FD469A4C57DC) /* 186 */, CONST64(0x7EF700A07CF1AD65) /* 187 */, CONST64(0x59C64468A31D8859) /* 188 */, CONST64(0x762FB0B4D45B61F6) /* 189 */, CONST64(0x155BAED099047718) /* 190 */, CONST64(0x68755E4C3D50BAA6) /* 191 */, CONST64(0xE9214E7F22D8B4DF) /* 192 */, CONST64(0x2ADDBF532EAC95F4) /* 193 */, CONST64(0x32AE3909B4BD0109) /* 194 */, CONST64(0x834DF537B08E3450) /* 195 */, CONST64(0xFA209DA84220728D) /* 196 */, CONST64(0x9E691D9B9EFE23F7) /* 197 */, CONST64(0x0446D288C4AE8D7F) /* 198 */, CONST64(0x7B4CC524E169785B) /* 199 */, CONST64(0x21D87F0135CA1385) /* 200 */, CONST64(0xCEBB400F137B8AA5) /* 201 */, CONST64(0x272E2B66580796BE) /* 202 */, CONST64(0x3612264125C2B0DE) /* 203 */, CONST64(0x057702BDAD1EFBB2) /* 204 */, CONST64(0xD4BABB8EACF84BE9) /* 205 */, CONST64(0x91583139641BC67B) /* 206 */, CONST64(0x8BDC2DE08036E024) /* 207 */, CONST64(0x603C8156F49F68ED) /* 208 */, CONST64(0xF7D236F7DBEF5111) /* 209 */, CONST64(0x9727C4598AD21E80) /* 210 */, CONST64(0xA08A0896670A5FD7) /* 211 */, CONST64(0xCB4A8F4309EBA9CB) /* 212 */, CONST64(0x81AF564B0F7036A1) /* 213 */, CONST64(0xC0B99AA778199ABD) /* 214 */, CONST64(0x959F1EC83FC8E952) /* 215 */, CONST64(0x8C505077794A81B9) /* 216 */, CONST64(0x3ACAAF8F056338F0) /* 217 */, CONST64(0x07B43F50627A6778) /* 218 */, CONST64(0x4A44AB49F5ECCC77) /* 219 */, CONST64(0x3BC3D6E4B679EE98) /* 220 */, CONST64(0x9CC0D4D1CF14108C) /* 221 */, CONST64(0x4406C00B206BC8A0) /* 222 */, CONST64(0x82A18854C8D72D89) /* 223 */, CONST64(0x67E366B35C3C432C) /* 224 */, CONST64(0xB923DD61102B37F2) /* 225 */, CONST64(0x56AB2779D884271D) /* 226 */, CONST64(0xBE83E1B0FF1525AF) /* 227 */, CONST64(0xFB7C65D4217E49A9) /* 228 */, CONST64(0x6BDBE0E76D48E7D4) /* 229 */, CONST64(0x08DF828745D9179E) /* 230 */, CONST64(0x22EA6A9ADD53BD34) /* 231 */, CONST64(0xE36E141C5622200A) /* 232 */, CONST64(0x7F805D1B8CB750EE) /* 233 */, CONST64(0xAFE5C7A59F58E837) /* 234 */, CONST64(0xE27F996A4FB1C23C) /* 235 */, CONST64(0xD3867DFB0775F0D0) /* 236 */, CONST64(0xD0E673DE6E88891A) /* 237 */, CONST64(0x123AEB9EAFB86C25) /* 238 */, CONST64(0x30F1D5D5C145B895) /* 239 */, CONST64(0xBB434A2DEE7269E7) /* 240 */, CONST64(0x78CB67ECF931FA38) /* 241 */, CONST64(0xF33B0372323BBF9C) /* 242 */, CONST64(0x52D66336FB279C74) /* 243 */, CONST64(0x505F33AC0AFB4EAA) /* 244 */, CONST64(0xE8A5CD99A2CCE187) /* 245 */, CONST64(0x534974801E2D30BB) /* 246 */, CONST64(0x8D2D5711D5876D90) /* 247 */, CONST64(0x1F1A412891BC038E) /* 248 */, CONST64(0xD6E2E71D82E56648) /* 249 */, CONST64(0x74036C3A497732B7) /* 250 */, CONST64(0x89B67ED96361F5AB) /* 251 */, CONST64(0xFFED95D8F1EA02A2) /* 252 */, CONST64(0xE72B3BD61464D43D) /* 253 */, CONST64(0xA6300F170BDC4820) /* 254 */, CONST64(0xEBC18760ED78A77A) /* 255 */, CONST64(0xE6A6BE5A05A12138) /* 256 */, CONST64(0xB5A122A5B4F87C98) /* 257 */, CONST64(0x563C6089140B6990) /* 258 */, CONST64(0x4C46CB2E391F5DD5) /* 259 */, CONST64(0xD932ADDBC9B79434) /* 260 */, CONST64(0x08EA70E42015AFF5) /* 261 */, CONST64(0xD765A6673E478CF1) /* 262 */, CONST64(0xC4FB757EAB278D99) /* 263 */, CONST64(0xDF11C6862D6E0692) /* 264 */, CONST64(0xDDEB84F10D7F3B16) /* 265 */, CONST64(0x6F2EF604A665EA04) /* 266 */, CONST64(0x4A8E0F0FF0E0DFB3) /* 267 */, CONST64(0xA5EDEEF83DBCBA51) /* 268 */, CONST64(0xFC4F0A2A0EA4371E) /* 269 */, CONST64(0xE83E1DA85CB38429) /* 270 */, CONST64(0xDC8FF882BA1B1CE2) /* 271 */, CONST64(0xCD45505E8353E80D) /* 272 */, CONST64(0x18D19A00D4DB0717) /* 273 */, CONST64(0x34A0CFEDA5F38101) /* 274 */, CONST64(0x0BE77E518887CAF2) /* 275 */, CONST64(0x1E341438B3C45136) /* 276 */, CONST64(0xE05797F49089CCF9) /* 277 */, CONST64(0xFFD23F9DF2591D14) /* 278 */, CONST64(0x543DDA228595C5CD) /* 279 */, CONST64(0x661F81FD99052A33) /* 280 */, CONST64(0x8736E641DB0F7B76) /* 281 */, CONST64(0x15227725418E5307) /* 282 */, CONST64(0xE25F7F46162EB2FA) /* 283 */, CONST64(0x48A8B2126C13D9FE) /* 284 */, CONST64(0xAFDC541792E76EEA) /* 285 */, CONST64(0x03D912BFC6D1898F) /* 286 */, CONST64(0x31B1AAFA1B83F51B) /* 287 */, CONST64(0xF1AC2796E42AB7D9) /* 288 */, CONST64(0x40A3A7D7FCD2EBAC) /* 289 */, CONST64(0x1056136D0AFBBCC5) /* 290 */, CONST64(0x7889E1DD9A6D0C85) /* 291 */, CONST64(0xD33525782A7974AA) /* 292 */, CONST64(0xA7E25D09078AC09B) /* 293 */, CONST64(0xBD4138B3EAC6EDD0) /* 294 */, CONST64(0x920ABFBE71EB9E70) /* 295 */, CONST64(0xA2A5D0F54FC2625C) /* 296 */, CONST64(0xC054E36B0B1290A3) /* 297 */, CONST64(0xF6DD59FF62FE932B) /* 298 */, CONST64(0x3537354511A8AC7D) /* 299 */, CONST64(0xCA845E9172FADCD4) /* 300 */, CONST64(0x84F82B60329D20DC) /* 301 */, CONST64(0x79C62CE1CD672F18) /* 302 */, CONST64(0x8B09A2ADD124642C) /* 303 */, CONST64(0xD0C1E96A19D9E726) /* 304 */, CONST64(0x5A786A9B4BA9500C) /* 305 */, CONST64(0x0E020336634C43F3) /* 306 */, CONST64(0xC17B474AEB66D822) /* 307 */, CONST64(0x6A731AE3EC9BAAC2) /* 308 */, CONST64(0x8226667AE0840258) /* 309 */, CONST64(0x67D4567691CAECA5) /* 310 */, CONST64(0x1D94155C4875ADB5) /* 311 */, CONST64(0x6D00FD985B813FDF) /* 312 */, CONST64(0x51286EFCB774CD06) /* 313 */, CONST64(0x5E8834471FA744AF) /* 314 */, CONST64(0xF72CA0AEE761AE2E) /* 315 */, CONST64(0xBE40E4CDAEE8E09A) /* 316 */, CONST64(0xE9970BBB5118F665) /* 317 */, CONST64(0x726E4BEB33DF1964) /* 318 */, CONST64(0x703B000729199762) /* 319 */, CONST64(0x4631D816F5EF30A7) /* 320 */, CONST64(0xB880B5B51504A6BE) /* 321 */, CONST64(0x641793C37ED84B6C) /* 322 */, CONST64(0x7B21ED77F6E97D96) /* 323 */, CONST64(0x776306312EF96B73) /* 324 */, CONST64(0xAE528948E86FF3F4) /* 325 */, CONST64(0x53DBD7F286A3F8F8) /* 326 */, CONST64(0x16CADCE74CFC1063) /* 327 */, CONST64(0x005C19BDFA52C6DD) /* 328 */, CONST64(0x68868F5D64D46AD3) /* 329 */, CONST64(0x3A9D512CCF1E186A) /* 330 */, CONST64(0x367E62C2385660AE) /* 331 */, CONST64(0xE359E7EA77DCB1D7) /* 332 */, CONST64(0x526C0773749ABE6E) /* 333 */, CONST64(0x735AE5F9D09F734B) /* 334 */, CONST64(0x493FC7CC8A558BA8) /* 335 */, CONST64(0xB0B9C1533041AB45) /* 336 */, CONST64(0x321958BA470A59BD) /* 337 */, CONST64(0x852DB00B5F46C393) /* 338 */, CONST64(0x91209B2BD336B0E5) /* 339 */, CONST64(0x6E604F7D659EF19F) /* 340 */, CONST64(0xB99A8AE2782CCB24) /* 341 */, CONST64(0xCCF52AB6C814C4C7) /* 342 */, CONST64(0x4727D9AFBE11727B) /* 343 */, CONST64(0x7E950D0C0121B34D) /* 344 */, CONST64(0x756F435670AD471F) /* 345 */, CONST64(0xF5ADD442615A6849) /* 346 */, CONST64(0x4E87E09980B9957A) /* 347 */, CONST64(0x2ACFA1DF50AEE355) /* 348 */, CONST64(0xD898263AFD2FD556) /* 349 */, CONST64(0xC8F4924DD80C8FD6) /* 350 */, CONST64(0xCF99CA3D754A173A) /* 351 */, CONST64(0xFE477BACAF91BF3C) /* 352 */, CONST64(0xED5371F6D690C12D) /* 353 */, CONST64(0x831A5C285E687094) /* 354 */, CONST64(0xC5D3C90A3708A0A4) /* 355 */, CONST64(0x0F7F903717D06580) /* 356 */, CONST64(0x19F9BB13B8FDF27F) /* 357 */, CONST64(0xB1BD6F1B4D502843) /* 358 */, CONST64(0x1C761BA38FFF4012) /* 359 */, CONST64(0x0D1530C4E2E21F3B) /* 360 */, CONST64(0x8943CE69A7372C8A) /* 361 */, CONST64(0xE5184E11FEB5CE66) /* 362 */, CONST64(0x618BDB80BD736621) /* 363 */, CONST64(0x7D29BAD68B574D0B) /* 364 */, CONST64(0x81BB613E25E6FE5B) /* 365 */, CONST64(0x071C9C10BC07913F) /* 366 */, CONST64(0xC7BEEB7909AC2D97) /* 367 */, CONST64(0xC3E58D353BC5D757) /* 368 */, CONST64(0xEB017892F38F61E8) /* 369 */, CONST64(0xD4EFFB9C9B1CC21A) /* 370 */, CONST64(0x99727D26F494F7AB) /* 371 */, CONST64(0xA3E063A2956B3E03) /* 372 */, CONST64(0x9D4A8B9A4AA09C30) /* 373 */, CONST64(0x3F6AB7D500090FB4) /* 374 */, CONST64(0x9CC0F2A057268AC0) /* 375 */, CONST64(0x3DEE9D2DEDBF42D1) /* 376 */, CONST64(0x330F49C87960A972) /* 377 */, CONST64(0xC6B2720287421B41) /* 378 */, CONST64(0x0AC59EC07C00369C) /* 379 */, CONST64(0xEF4EAC49CB353425) /* 380 */, CONST64(0xF450244EEF0129D8) /* 381 */, CONST64(0x8ACC46E5CAF4DEB6) /* 382 */, CONST64(0x2FFEAB63989263F7) /* 383 */, CONST64(0x8F7CB9FE5D7A4578) /* 384 */, CONST64(0x5BD8F7644E634635) /* 385 */, CONST64(0x427A7315BF2DC900) /* 386 */, CONST64(0x17D0C4AA2125261C) /* 387 */, CONST64(0x3992486C93518E50) /* 388 */, CONST64(0xB4CBFEE0A2D7D4C3) /* 389 */, CONST64(0x7C75D6202C5DDD8D) /* 390 */, CONST64(0xDBC295D8E35B6C61) /* 391 */, CONST64(0x60B369D302032B19) /* 392 */, CONST64(0xCE42685FDCE44132) /* 393 */, CONST64(0x06F3DDB9DDF65610) /* 394 */, CONST64(0x8EA4D21DB5E148F0) /* 395 */, CONST64(0x20B0FCE62FCD496F) /* 396 */, CONST64(0x2C1B912358B0EE31) /* 397 */, CONST64(0xB28317B818F5A308) /* 398 */, CONST64(0xA89C1E189CA6D2CF) /* 399 */, CONST64(0x0C6B18576AAADBC8) /* 400 */, CONST64(0xB65DEAA91299FAE3) /* 401 */, CONST64(0xFB2B794B7F1027E7) /* 402 */, CONST64(0x04E4317F443B5BEB) /* 403 */, CONST64(0x4B852D325939D0A6) /* 404 */, CONST64(0xD5AE6BEEFB207FFC) /* 405 */, CONST64(0x309682B281C7D374) /* 406 */, CONST64(0xBAE309A194C3B475) /* 407 */, CONST64(0x8CC3F97B13B49F05) /* 408 */, CONST64(0x98A9422FF8293967) /* 409 */, CONST64(0x244B16B01076FF7C) /* 410 */, CONST64(0xF8BF571C663D67EE) /* 411 */, CONST64(0x1F0D6758EEE30DA1) /* 412 */, CONST64(0xC9B611D97ADEB9B7) /* 413 */, CONST64(0xB7AFD5887B6C57A2) /* 414 */, CONST64(0x6290AE846B984FE1) /* 415 */, CONST64(0x94DF4CDEACC1A5FD) /* 416 */, CONST64(0x058A5BD1C5483AFF) /* 417 */, CONST64(0x63166CC142BA3C37) /* 418 */, CONST64(0x8DB8526EB2F76F40) /* 419 */, CONST64(0xE10880036F0D6D4E) /* 420 */, CONST64(0x9E0523C9971D311D) /* 421 */, CONST64(0x45EC2824CC7CD691) /* 422 */, CONST64(0x575B8359E62382C9) /* 423 */, CONST64(0xFA9E400DC4889995) /* 424 */, CONST64(0xD1823ECB45721568) /* 425 */, CONST64(0xDAFD983B8206082F) /* 426 */, CONST64(0xAA7D29082386A8CB) /* 427 */, CONST64(0x269FCD4403B87588) /* 428 */, CONST64(0x1B91F5F728BDD1E0) /* 429 */, CONST64(0xE4669F39040201F6) /* 430 */, CONST64(0x7A1D7C218CF04ADE) /* 431 */, CONST64(0x65623C29D79CE5CE) /* 432 */, CONST64(0x2368449096C00BB1) /* 433 */, CONST64(0xAB9BF1879DA503BA) /* 434 */, CONST64(0xBC23ECB1A458058E) /* 435 */, CONST64(0x9A58DF01BB401ECC) /* 436 */, CONST64(0xA070E868A85F143D) /* 437 */, CONST64(0x4FF188307DF2239E) /* 438 */, CONST64(0x14D565B41A641183) /* 439 */, CONST64(0xEE13337452701602) /* 440 */, CONST64(0x950E3DCF3F285E09) /* 441 */, CONST64(0x59930254B9C80953) /* 442 */, CONST64(0x3BF299408930DA6D) /* 443 */, CONST64(0xA955943F53691387) /* 444 */, CONST64(0xA15EDECAA9CB8784) /* 445 */, CONST64(0x29142127352BE9A0) /* 446 */, CONST64(0x76F0371FFF4E7AFB) /* 447 */, CONST64(0x0239F450274F2228) /* 448 */, CONST64(0xBB073AF01D5E868B) /* 449 */, CONST64(0xBFC80571C10E96C1) /* 450 */, CONST64(0xD267088568222E23) /* 451 */, CONST64(0x9671A3D48E80B5B0) /* 452 */, CONST64(0x55B5D38AE193BB81) /* 453 */, CONST64(0x693AE2D0A18B04B8) /* 454 */, CONST64(0x5C48B4ECADD5335F) /* 455 */, CONST64(0xFD743B194916A1CA) /* 456 */, CONST64(0x2577018134BE98C4) /* 457 */, CONST64(0xE77987E83C54A4AD) /* 458 */, CONST64(0x28E11014DA33E1B9) /* 459 */, CONST64(0x270CC59E226AA213) /* 460 */, CONST64(0x71495F756D1A5F60) /* 461 */, CONST64(0x9BE853FB60AFEF77) /* 462 */, CONST64(0xADC786A7F7443DBF) /* 463 */, CONST64(0x0904456173B29A82) /* 464 */, CONST64(0x58BC7A66C232BD5E) /* 465 */, CONST64(0xF306558C673AC8B2) /* 466 */, CONST64(0x41F639C6B6C9772A) /* 467 */, CONST64(0x216DEFE99FDA35DA) /* 468 */, CONST64(0x11640CC71C7BE615) /* 469 */, CONST64(0x93C43694565C5527) /* 470 */, CONST64(0xEA038E6246777839) /* 471 */, CONST64(0xF9ABF3CE5A3E2469) /* 472 */, CONST64(0x741E768D0FD312D2) /* 473 */, CONST64(0x0144B883CED652C6) /* 474 */, CONST64(0xC20B5A5BA33F8552) /* 475 */, CONST64(0x1AE69633C3435A9D) /* 476 */, CONST64(0x97A28CA4088CFDEC) /* 477 */, CONST64(0x8824A43C1E96F420) /* 478 */, CONST64(0x37612FA66EEEA746) /* 479 */, CONST64(0x6B4CB165F9CF0E5A) /* 480 */, CONST64(0x43AA1C06A0ABFB4A) /* 481 */, CONST64(0x7F4DC26FF162796B) /* 482 */, CONST64(0x6CBACC8E54ED9B0F) /* 483 */, CONST64(0xA6B7FFEFD2BB253E) /* 484 */, CONST64(0x2E25BC95B0A29D4F) /* 485 */, CONST64(0x86D6A58BDEF1388C) /* 486 */, CONST64(0xDED74AC576B6F054) /* 487 */, CONST64(0x8030BDBC2B45805D) /* 488 */, CONST64(0x3C81AF70E94D9289) /* 489 */, CONST64(0x3EFF6DDA9E3100DB) /* 490 */, CONST64(0xB38DC39FDFCC8847) /* 491 */, CONST64(0x123885528D17B87E) /* 492 */, CONST64(0xF2DA0ED240B1B642) /* 493 */, CONST64(0x44CEFADCD54BF9A9) /* 494 */, CONST64(0x1312200E433C7EE6) /* 495 */, CONST64(0x9FFCC84F3A78C748) /* 496 */, CONST64(0xF0CD1F72248576BB) /* 497 */, CONST64(0xEC6974053638CFE4) /* 498 */, CONST64(0x2BA7B67C0CEC4E4C) /* 499 */, CONST64(0xAC2F4DF3E5CE32ED) /* 500 */, CONST64(0xCB33D14326EA4C11) /* 501 */, CONST64(0xA4E9044CC77E58BC) /* 502 */, CONST64(0x5F513293D934FCEF) /* 503 */, CONST64(0x5DC9645506E55444) /* 504 */, CONST64(0x50DE418F317DE40A) /* 505 */, CONST64(0x388CB31A69DDE259) /* 506 */, CONST64(0x2DB4A83455820A86) /* 507 */, CONST64(0x9010A91E84711AE9) /* 508 */, CONST64(0x4DF7F0B7B1498371) /* 509 */, CONST64(0xD62A2EABC0977179) /* 510 */, CONST64(0x22FAC097AA8D5C0E) /* 511 */, CONST64(0xF49FCC2FF1DAF39B) /* 512 */, CONST64(0x487FD5C66FF29281) /* 513 */, CONST64(0xE8A30667FCDCA83F) /* 514 */, CONST64(0x2C9B4BE3D2FCCE63) /* 515 */, CONST64(0xDA3FF74B93FBBBC2) /* 516 */, CONST64(0x2FA165D2FE70BA66) /* 517 */, CONST64(0xA103E279970E93D4) /* 518 */, CONST64(0xBECDEC77B0E45E71) /* 519 */, CONST64(0xCFB41E723985E497) /* 520 */, CONST64(0xB70AAA025EF75017) /* 521 */, CONST64(0xD42309F03840B8E0) /* 522 */, CONST64(0x8EFC1AD035898579) /* 523 */, CONST64(0x96C6920BE2B2ABC5) /* 524 */, CONST64(0x66AF4163375A9172) /* 525 */, CONST64(0x2174ABDCCA7127FB) /* 526 */, CONST64(0xB33CCEA64A72FF41) /* 527 */, CONST64(0xF04A4933083066A5) /* 528 */, CONST64(0x8D970ACDD7289AF5) /* 529 */, CONST64(0x8F96E8E031C8C25E) /* 530 */, CONST64(0xF3FEC02276875D47) /* 531 */, CONST64(0xEC7BF310056190DD) /* 532 */, CONST64(0xF5ADB0AEBB0F1491) /* 533 */, CONST64(0x9B50F8850FD58892) /* 534 */, CONST64(0x4975488358B74DE8) /* 535 */, CONST64(0xA3354FF691531C61) /* 536 */, CONST64(0x0702BBE481D2C6EE) /* 537 */, CONST64(0x89FB24057DEDED98) /* 538 */, CONST64(0xAC3075138596E902) /* 539 */, CONST64(0x1D2D3580172772ED) /* 540 */, CONST64(0xEB738FC28E6BC30D) /* 541 */, CONST64(0x5854EF8F63044326) /* 542 */, CONST64(0x9E5C52325ADD3BBE) /* 543 */, CONST64(0x90AA53CF325C4623) /* 544 */, CONST64(0xC1D24D51349DD067) /* 545 */, CONST64(0x2051CFEEA69EA624) /* 546 */, CONST64(0x13220F0A862E7E4F) /* 547 */, CONST64(0xCE39399404E04864) /* 548 */, CONST64(0xD9C42CA47086FCB7) /* 549 */, CONST64(0x685AD2238A03E7CC) /* 550 */, CONST64(0x066484B2AB2FF1DB) /* 551 */, CONST64(0xFE9D5D70EFBF79EC) /* 552 */, CONST64(0x5B13B9DD9C481854) /* 553 */, CONST64(0x15F0D475ED1509AD) /* 554 */, CONST64(0x0BEBCD060EC79851) /* 555 */, CONST64(0xD58C6791183AB7F8) /* 556 */, CONST64(0xD1187C5052F3EEE4) /* 557 */, CONST64(0xC95D1192E54E82FF) /* 558 */, CONST64(0x86EEA14CB9AC6CA2) /* 559 */, CONST64(0x3485BEB153677D5D) /* 560 */, CONST64(0xDD191D781F8C492A) /* 561 */, CONST64(0xF60866BAA784EBF9) /* 562 */, CONST64(0x518F643BA2D08C74) /* 563 */, CONST64(0x8852E956E1087C22) /* 564 */, CONST64(0xA768CB8DC410AE8D) /* 565 */, CONST64(0x38047726BFEC8E1A) /* 566 */, CONST64(0xA67738B4CD3B45AA) /* 567 */, CONST64(0xAD16691CEC0DDE19) /* 568 */, CONST64(0xC6D4319380462E07) /* 569 */, CONST64(0xC5A5876D0BA61938) /* 570 */, CONST64(0x16B9FA1FA58FD840) /* 571 */, CONST64(0x188AB1173CA74F18) /* 572 */, CONST64(0xABDA2F98C99C021F) /* 573 */, CONST64(0x3E0580AB134AE816) /* 574 */, CONST64(0x5F3B05B773645ABB) /* 575 */, CONST64(0x2501A2BE5575F2F6) /* 576 */, CONST64(0x1B2F74004E7E8BA9) /* 577 */, CONST64(0x1CD7580371E8D953) /* 578 */, CONST64(0x7F6ED89562764E30) /* 579 */, CONST64(0xB15926FF596F003D) /* 580 */, CONST64(0x9F65293DA8C5D6B9) /* 581 */, CONST64(0x6ECEF04DD690F84C) /* 582 */, CONST64(0x4782275FFF33AF88) /* 583 */, CONST64(0xE41433083F820801) /* 584 */, CONST64(0xFD0DFE409A1AF9B5) /* 585 */, CONST64(0x4325A3342CDB396B) /* 586 */, CONST64(0x8AE77E62B301B252) /* 587 */, CONST64(0xC36F9E9F6655615A) /* 588 */, CONST64(0x85455A2D92D32C09) /* 589 */, CONST64(0xF2C7DEA949477485) /* 590 */, CONST64(0x63CFB4C133A39EBA) /* 591 */, CONST64(0x83B040CC6EBC5462) /* 592 */, CONST64(0x3B9454C8FDB326B0) /* 593 */, CONST64(0x56F56A9E87FFD78C) /* 594 */, CONST64(0x2DC2940D99F42BC6) /* 595 */, CONST64(0x98F7DF096B096E2D) /* 596 */, CONST64(0x19A6E01E3AD852BF) /* 597 */, CONST64(0x42A99CCBDBD4B40B) /* 598 */, CONST64(0xA59998AF45E9C559) /* 599 */, CONST64(0x366295E807D93186) /* 600 */, CONST64(0x6B48181BFAA1F773) /* 601 */, CONST64(0x1FEC57E2157A0A1D) /* 602 */, CONST64(0x4667446AF6201AD5) /* 603 */, CONST64(0xE615EBCACFB0F075) /* 604 */, CONST64(0xB8F31F4F68290778) /* 605 */, CONST64(0x22713ED6CE22D11E) /* 606 */, CONST64(0x3057C1A72EC3C93B) /* 607 */, CONST64(0xCB46ACC37C3F1F2F) /* 608 */, CONST64(0xDBB893FD02AAF50E) /* 609 */, CONST64(0x331FD92E600B9FCF) /* 610 */, CONST64(0xA498F96148EA3AD6) /* 611 */, CONST64(0xA8D8426E8B6A83EA) /* 612 */, CONST64(0xA089B274B7735CDC) /* 613 */, CONST64(0x87F6B3731E524A11) /* 614 */, CONST64(0x118808E5CBC96749) /* 615 */, CONST64(0x9906E4C7B19BD394) /* 616 */, CONST64(0xAFED7F7E9B24A20C) /* 617 */, CONST64(0x6509EADEEB3644A7) /* 618 */, CONST64(0x6C1EF1D3E8EF0EDE) /* 619 */, CONST64(0xB9C97D43E9798FB4) /* 620 */, CONST64(0xA2F2D784740C28A3) /* 621 */, CONST64(0x7B8496476197566F) /* 622 */, CONST64(0x7A5BE3E6B65F069D) /* 623 */, CONST64(0xF96330ED78BE6F10) /* 624 */, CONST64(0xEEE60DE77A076A15) /* 625 */, CONST64(0x2B4BEE4AA08B9BD0) /* 626 */, CONST64(0x6A56A63EC7B8894E) /* 627 */, CONST64(0x02121359BA34FEF4) /* 628 */, CONST64(0x4CBF99F8283703FC) /* 629 */, CONST64(0x398071350CAF30C8) /* 630 */, CONST64(0xD0A77A89F017687A) /* 631 */, CONST64(0xF1C1A9EB9E423569) /* 632 */, CONST64(0x8C7976282DEE8199) /* 633 */, CONST64(0x5D1737A5DD1F7ABD) /* 634 */, CONST64(0x4F53433C09A9FA80) /* 635 */, CONST64(0xFA8B0C53DF7CA1D9) /* 636 */, CONST64(0x3FD9DCBC886CCB77) /* 637 */, CONST64(0xC040917CA91B4720) /* 638 */, CONST64(0x7DD00142F9D1DCDF) /* 639 */, CONST64(0x8476FC1D4F387B58) /* 640 */, CONST64(0x23F8E7C5F3316503) /* 641 */, CONST64(0x032A2244E7E37339) /* 642 */, CONST64(0x5C87A5D750F5A74B) /* 643 */, CONST64(0x082B4CC43698992E) /* 644 */, CONST64(0xDF917BECB858F63C) /* 645 */, CONST64(0x3270B8FC5BF86DDA) /* 646 */, CONST64(0x10AE72BB29B5DD76) /* 647 */, CONST64(0x576AC94E7700362B) /* 648 */, CONST64(0x1AD112DAC61EFB8F) /* 649 */, CONST64(0x691BC30EC5FAA427) /* 650 */, CONST64(0xFF246311CC327143) /* 651 */, CONST64(0x3142368E30E53206) /* 652 */, CONST64(0x71380E31E02CA396) /* 653 */, CONST64(0x958D5C960AAD76F1) /* 654 */, CONST64(0xF8D6F430C16DA536) /* 655 */, CONST64(0xC8FFD13F1BE7E1D2) /* 656 */, CONST64(0x7578AE66004DDBE1) /* 657 */, CONST64(0x05833F01067BE646) /* 658 */, CONST64(0xBB34B5AD3BFE586D) /* 659 */, CONST64(0x095F34C9A12B97F0) /* 660 */, CONST64(0x247AB64525D60CA8) /* 661 */, CONST64(0xDCDBC6F3017477D1) /* 662 */, CONST64(0x4A2E14D4DECAD24D) /* 663 */, CONST64(0xBDB5E6D9BE0A1EEB) /* 664 */, CONST64(0x2A7E70F7794301AB) /* 665 */, CONST64(0xDEF42D8A270540FD) /* 666 */, CONST64(0x01078EC0A34C22C1) /* 667 */, CONST64(0xE5DE511AF4C16387) /* 668 */, CONST64(0x7EBB3A52BD9A330A) /* 669 */, CONST64(0x77697857AA7D6435) /* 670 */, CONST64(0x004E831603AE4C32) /* 671 */, CONST64(0xE7A21020AD78E312) /* 672 */, CONST64(0x9D41A70C6AB420F2) /* 673 */, CONST64(0x28E06C18EA1141E6) /* 674 */, CONST64(0xD2B28CBD984F6B28) /* 675 */, CONST64(0x26B75F6C446E9D83) /* 676 */, CONST64(0xBA47568C4D418D7F) /* 677 */, CONST64(0xD80BADBFE6183D8E) /* 678 */, CONST64(0x0E206D7F5F166044) /* 679 */, CONST64(0xE258A43911CBCA3E) /* 680 */, CONST64(0x723A1746B21DC0BC) /* 681 */, CONST64(0xC7CAA854F5D7CDD3) /* 682 */, CONST64(0x7CAC32883D261D9C) /* 683 */, CONST64(0x7690C26423BA942C) /* 684 */, CONST64(0x17E55524478042B8) /* 685 */, CONST64(0xE0BE477656A2389F) /* 686 */, CONST64(0x4D289B5E67AB2DA0) /* 687 */, CONST64(0x44862B9C8FBBFD31) /* 688 */, CONST64(0xB47CC8049D141365) /* 689 */, CONST64(0x822C1B362B91C793) /* 690 */, CONST64(0x4EB14655FB13DFD8) /* 691 */, CONST64(0x1ECBBA0714E2A97B) /* 692 */, CONST64(0x6143459D5CDE5F14) /* 693 */, CONST64(0x53A8FBF1D5F0AC89) /* 694 */, CONST64(0x97EA04D81C5E5B00) /* 695 */, CONST64(0x622181A8D4FDB3F3) /* 696 */, CONST64(0xE9BCD341572A1208) /* 697 */, CONST64(0x1411258643CCE58A) /* 698 */, CONST64(0x9144C5FEA4C6E0A4) /* 699 */, CONST64(0x0D33D06565CF620F) /* 700 */, CONST64(0x54A48D489F219CA1) /* 701 */, CONST64(0xC43E5EAC6D63C821) /* 702 */, CONST64(0xA9728B3A72770DAF) /* 703 */, CONST64(0xD7934E7B20DF87EF) /* 704 */, CONST64(0xE35503B61A3E86E5) /* 705 */, CONST64(0xCAE321FBC819D504) /* 706 */, CONST64(0x129A50B3AC60BFA6) /* 707 */, CONST64(0xCD5E68EA7E9FB6C3) /* 708 */, CONST64(0xB01C90199483B1C7) /* 709 */, CONST64(0x3DE93CD5C295376C) /* 710 */, CONST64(0xAED52EDF2AB9AD13) /* 711 */, CONST64(0x2E60F512C0A07884) /* 712 */, CONST64(0xBC3D86A3E36210C9) /* 713 */, CONST64(0x35269D9B163951CE) /* 714 */, CONST64(0x0C7D6E2AD0CDB5FA) /* 715 */, CONST64(0x59E86297D87F5733) /* 716 */, CONST64(0x298EF221898DB0E7) /* 717 */, CONST64(0x55000029D1A5AA7E) /* 718 */, CONST64(0x8BC08AE1B5061B45) /* 719 */, CONST64(0xC2C31C2B6C92703A) /* 720 */, CONST64(0x94CC596BAF25EF42) /* 721 */, CONST64(0x0A1D73DB22540456) /* 722 */, CONST64(0x04B6A0F9D9C4179A) /* 723 */, CONST64(0xEFFDAFA2AE3D3C60) /* 724 */, CONST64(0xF7C8075BB49496C4) /* 725 */, CONST64(0x9CC5C7141D1CD4E3) /* 726 */, CONST64(0x78BD1638218E5534) /* 727 */, CONST64(0xB2F11568F850246A) /* 728 */, CONST64(0xEDFABCFA9502BC29) /* 729 */, CONST64(0x796CE5F2DA23051B) /* 730 */, CONST64(0xAAE128B0DC93537C) /* 731 */, CONST64(0x3A493DA0EE4B29AE) /* 732 */, CONST64(0xB5DF6B2C416895D7) /* 733 */, CONST64(0xFCABBD25122D7F37) /* 734 */, CONST64(0x70810B58105DC4B1) /* 735 */, CONST64(0xE10FDD37F7882A90) /* 736 */, CONST64(0x524DCAB5518A3F5C) /* 737 */, CONST64(0x3C9E85878451255B) /* 738 */, CONST64(0x4029828119BD34E2) /* 739 */, CONST64(0x74A05B6F5D3CECCB) /* 740 */, CONST64(0xB610021542E13ECA) /* 741 */, CONST64(0x0FF979D12F59E2AC) /* 742 */, CONST64(0x6037DA27E4F9CC50) /* 743 */, CONST64(0x5E92975A0DF1847D) /* 744 */, CONST64(0xD66DE190D3E623FE) /* 745 */, CONST64(0x5032D6B87B568048) /* 746 */, CONST64(0x9A36B7CE8235216E) /* 747 */, CONST64(0x80272A7A24F64B4A) /* 748 */, CONST64(0x93EFED8B8C6916F7) /* 749 */, CONST64(0x37DDBFF44CCE1555) /* 750 */, CONST64(0x4B95DB5D4B99BD25) /* 751 */, CONST64(0x92D3FDA169812FC0) /* 752 */, CONST64(0xFB1A4A9A90660BB6) /* 753 */, CONST64(0x730C196946A4B9B2) /* 754 */, CONST64(0x81E289AA7F49DA68) /* 755 */, CONST64(0x64669A0F83B1A05F) /* 756 */, CONST64(0x27B3FF7D9644F48B) /* 757 */, CONST64(0xCC6B615C8DB675B3) /* 758 */, CONST64(0x674F20B9BCEBBE95) /* 759 */, CONST64(0x6F31238275655982) /* 760 */, CONST64(0x5AE488713E45CF05) /* 761 */, CONST64(0xBF619F9954C21157) /* 762 */, CONST64(0xEABAC46040A8EAE9) /* 763 */, CONST64(0x454C6FE9F2C0C1CD) /* 764 */, CONST64(0x419CF6496412691C) /* 765 */, CONST64(0xD3DC3BEF265B0F70) /* 766 */, CONST64(0x6D0E60F5C3578A9E) /* 767 */, CONST64(0x5B0E608526323C55) /* 768 */, CONST64(0x1A46C1A9FA1B59F5) /* 769 */, CONST64(0xA9E245A17C4C8FFA) /* 770 */, CONST64(0x65CA5159DB2955D7) /* 771 */, CONST64(0x05DB0A76CE35AFC2) /* 772 */, CONST64(0x81EAC77EA9113D45) /* 773 */, CONST64(0x528EF88AB6AC0A0D) /* 774 */, CONST64(0xA09EA253597BE3FF) /* 775 */, CONST64(0x430DDFB3AC48CD56) /* 776 */, CONST64(0xC4B3A67AF45CE46F) /* 777 */, CONST64(0x4ECECFD8FBE2D05E) /* 778 */, CONST64(0x3EF56F10B39935F0) /* 779 */, CONST64(0x0B22D6829CD619C6) /* 780 */, CONST64(0x17FD460A74DF2069) /* 781 */, CONST64(0x6CF8CC8E8510ED40) /* 782 */, CONST64(0xD6C824BF3A6ECAA7) /* 783 */, CONST64(0x61243D581A817049) /* 784 */, CONST64(0x048BACB6BBC163A2) /* 785 */, CONST64(0xD9A38AC27D44CC32) /* 786 */, CONST64(0x7FDDFF5BAAF410AB) /* 787 */, CONST64(0xAD6D495AA804824B) /* 788 */, CONST64(0xE1A6A74F2D8C9F94) /* 789 */, CONST64(0xD4F7851235DEE8E3) /* 790 */, CONST64(0xFD4B7F886540D893) /* 791 */, CONST64(0x247C20042AA4BFDA) /* 792 */, CONST64(0x096EA1C517D1327C) /* 793 */, CONST64(0xD56966B4361A6685) /* 794 */, CONST64(0x277DA5C31221057D) /* 795 */, CONST64(0x94D59893A43ACFF7) /* 796 */, CONST64(0x64F0C51CCDC02281) /* 797 */, CONST64(0x3D33BCC4FF6189DB) /* 798 */, CONST64(0xE005CB184CE66AF1) /* 799 */, CONST64(0xFF5CCD1D1DB99BEA) /* 800 */, CONST64(0xB0B854A7FE42980F) /* 801 */, CONST64(0x7BD46A6A718D4B9F) /* 802 */, CONST64(0xD10FA8CC22A5FD8C) /* 803 */, CONST64(0xD31484952BE4BD31) /* 804 */, CONST64(0xC7FA975FCB243847) /* 805 */, CONST64(0x4886ED1E5846C407) /* 806 */, CONST64(0x28CDDB791EB70B04) /* 807 */, CONST64(0xC2B00BE2F573417F) /* 808 */, CONST64(0x5C9590452180F877) /* 809 */, CONST64(0x7A6BDDFFF370EB00) /* 810 */, CONST64(0xCE509E38D6D9D6A4) /* 811 */, CONST64(0xEBEB0F00647FA702) /* 812 */, CONST64(0x1DCC06CF76606F06) /* 813 */, CONST64(0xE4D9F28BA286FF0A) /* 814 */, CONST64(0xD85A305DC918C262) /* 815 */, CONST64(0x475B1D8732225F54) /* 816 */, CONST64(0x2D4FB51668CCB5FE) /* 817 */, CONST64(0xA679B9D9D72BBA20) /* 818 */, CONST64(0x53841C0D912D43A5) /* 819 */, CONST64(0x3B7EAA48BF12A4E8) /* 820 */, CONST64(0x781E0E47F22F1DDF) /* 821 */, CONST64(0xEFF20CE60AB50973) /* 822 */, CONST64(0x20D261D19DFFB742) /* 823 */, CONST64(0x16A12B03062A2E39) /* 824 */, CONST64(0x1960EB2239650495) /* 825 */, CONST64(0x251C16FED50EB8B8) /* 826 */, CONST64(0x9AC0C330F826016E) /* 827 */, CONST64(0xED152665953E7671) /* 828 */, CONST64(0x02D63194A6369570) /* 829 */, CONST64(0x5074F08394B1C987) /* 830 */, CONST64(0x70BA598C90B25CE1) /* 831 */, CONST64(0x794A15810B9742F6) /* 832 */, CONST64(0x0D5925E9FCAF8C6C) /* 833 */, CONST64(0x3067716CD868744E) /* 834 */, CONST64(0x910AB077E8D7731B) /* 835 */, CONST64(0x6A61BBDB5AC42F61) /* 836 */, CONST64(0x93513EFBF0851567) /* 837 */, CONST64(0xF494724B9E83E9D5) /* 838 */, CONST64(0xE887E1985C09648D) /* 839 */, CONST64(0x34B1D3C675370CFD) /* 840 */, CONST64(0xDC35E433BC0D255D) /* 841 */, CONST64(0xD0AAB84234131BE0) /* 842 */, CONST64(0x08042A50B48B7EAF) /* 843 */, CONST64(0x9997C4EE44A3AB35) /* 844 */, CONST64(0x829A7B49201799D0) /* 845 */, CONST64(0x263B8307B7C54441) /* 846 */, CONST64(0x752F95F4FD6A6CA6) /* 847 */, CONST64(0x927217402C08C6E5) /* 848 */, CONST64(0x2A8AB754A795D9EE) /* 849 */, CONST64(0xA442F7552F72943D) /* 850 */, CONST64(0x2C31334E19781208) /* 851 */, CONST64(0x4FA98D7CEAEE6291) /* 852 */, CONST64(0x55C3862F665DB309) /* 853 */, CONST64(0xBD0610175D53B1F3) /* 854 */, CONST64(0x46FE6CB840413F27) /* 855 */, CONST64(0x3FE03792DF0CFA59) /* 856 */, CONST64(0xCFE700372EB85E8F) /* 857 */, CONST64(0xA7BE29E7ADBCE118) /* 858 */, CONST64(0xE544EE5CDE8431DD) /* 859 */, CONST64(0x8A781B1B41F1873E) /* 860 */, CONST64(0xA5C94C78A0D2F0E7) /* 861 */, CONST64(0x39412E2877B60728) /* 862 */, CONST64(0xA1265EF3AFC9A62C) /* 863 */, CONST64(0xBCC2770C6A2506C5) /* 864 */, CONST64(0x3AB66DD5DCE1CE12) /* 865 */, CONST64(0xE65499D04A675B37) /* 866 */, CONST64(0x7D8F523481BFD216) /* 867 */, CONST64(0x0F6F64FCEC15F389) /* 868 */, CONST64(0x74EFBE618B5B13C8) /* 869 */, CONST64(0xACDC82B714273E1D) /* 870 */, CONST64(0xDD40BFE003199D17) /* 871 */, CONST64(0x37E99257E7E061F8) /* 872 */, CONST64(0xFA52626904775AAA) /* 873 */, CONST64(0x8BBBF63A463D56F9) /* 874 */, CONST64(0xF0013F1543A26E64) /* 875 */, CONST64(0xA8307E9F879EC898) /* 876 */, CONST64(0xCC4C27A4150177CC) /* 877 */, CONST64(0x1B432F2CCA1D3348) /* 878 */, CONST64(0xDE1D1F8F9F6FA013) /* 879 */, CONST64(0x606602A047A7DDD6) /* 880 */, CONST64(0xD237AB64CC1CB2C7) /* 881 */, CONST64(0x9B938E7225FCD1D3) /* 882 */, CONST64(0xEC4E03708E0FF476) /* 883 */, CONST64(0xFEB2FBDA3D03C12D) /* 884 */, CONST64(0xAE0BCED2EE43889A) /* 885 */, CONST64(0x22CB8923EBFB4F43) /* 886 */, CONST64(0x69360D013CF7396D) /* 887 */, CONST64(0x855E3602D2D4E022) /* 888 */, CONST64(0x073805BAD01F784C) /* 889 */, CONST64(0x33E17A133852F546) /* 890 */, CONST64(0xDF4874058AC7B638) /* 891 */, CONST64(0xBA92B29C678AA14A) /* 892 */, CONST64(0x0CE89FC76CFAADCD) /* 893 */, CONST64(0x5F9D4E0908339E34) /* 894 */, CONST64(0xF1AFE9291F5923B9) /* 895 */, CONST64(0x6E3480F60F4A265F) /* 896 */, CONST64(0xEEBF3A2AB29B841C) /* 897 */, CONST64(0xE21938A88F91B4AD) /* 898 */, CONST64(0x57DFEFF845C6D3C3) /* 899 */, CONST64(0x2F006B0BF62CAAF2) /* 900 */, CONST64(0x62F479EF6F75EE78) /* 901 */, CONST64(0x11A55AD41C8916A9) /* 902 */, CONST64(0xF229D29084FED453) /* 903 */, CONST64(0x42F1C27B16B000E6) /* 904 */, CONST64(0x2B1F76749823C074) /* 905 */, CONST64(0x4B76ECA3C2745360) /* 906 */, CONST64(0x8C98F463B91691BD) /* 907 */, CONST64(0x14BCC93CF1ADE66A) /* 908 */, CONST64(0x8885213E6D458397) /* 909 */, CONST64(0x8E177DF0274D4711) /* 910 */, CONST64(0xB49B73B5503F2951) /* 911 */, CONST64(0x10168168C3F96B6B) /* 912 */, CONST64(0x0E3D963B63CAB0AE) /* 913 */, CONST64(0x8DFC4B5655A1DB14) /* 914 */, CONST64(0xF789F1356E14DE5C) /* 915 */, CONST64(0x683E68AF4E51DAC1) /* 916 */, CONST64(0xC9A84F9D8D4B0FD9) /* 917 */, CONST64(0x3691E03F52A0F9D1) /* 918 */, CONST64(0x5ED86E46E1878E80) /* 919 */, CONST64(0x3C711A0E99D07150) /* 920 */, CONST64(0x5A0865B20C4E9310) /* 921 */, CONST64(0x56FBFC1FE4F0682E) /* 922 */, CONST64(0xEA8D5DE3105EDF9B) /* 923 */, CONST64(0x71ABFDB12379187A) /* 924 */, CONST64(0x2EB99DE1BEE77B9C) /* 925 */, CONST64(0x21ECC0EA33CF4523) /* 926 */, CONST64(0x59A4D7521805C7A1) /* 927 */, CONST64(0x3896F5EB56AE7C72) /* 928 */, CONST64(0xAA638F3DB18F75DC) /* 929 */, CONST64(0x9F39358DABE9808E) /* 930 */, CONST64(0xB7DEFA91C00B72AC) /* 931 */, CONST64(0x6B5541FD62492D92) /* 932 */, CONST64(0x6DC6DEE8F92E4D5B) /* 933 */, CONST64(0x353F57ABC4BEEA7E) /* 934 */, CONST64(0x735769D6DA5690CE) /* 935 */, CONST64(0x0A234AA642391484) /* 936 */, CONST64(0xF6F9508028F80D9D) /* 937 */, CONST64(0xB8E319A27AB3F215) /* 938 */, CONST64(0x31AD9C1151341A4D) /* 939 */, CONST64(0x773C22A57BEF5805) /* 940 */, CONST64(0x45C7561A07968633) /* 941 */, CONST64(0xF913DA9E249DBE36) /* 942 */, CONST64(0xDA652D9B78A64C68) /* 943 */, CONST64(0x4C27A97F3BC334EF) /* 944 */, CONST64(0x76621220E66B17F4) /* 945 */, CONST64(0x967743899ACD7D0B) /* 946 */, CONST64(0xF3EE5BCAE0ED6782) /* 947 */, CONST64(0x409F753600C879FC) /* 948 */, CONST64(0x06D09A39B5926DB6) /* 949 */, CONST64(0x6F83AEB0317AC588) /* 950 */, CONST64(0x01E6CA4A86381F21) /* 951 */, CONST64(0x66FF3462D19F3025) /* 952 */, CONST64(0x72207C24DDFD3BFB) /* 953 */, CONST64(0x4AF6B6D3E2ECE2EB) /* 954 */, CONST64(0x9C994DBEC7EA08DE) /* 955 */, CONST64(0x49ACE597B09A8BC4) /* 956 */, CONST64(0xB38C4766CF0797BA) /* 957 */, CONST64(0x131B9373C57C2A75) /* 958 */, CONST64(0xB1822CCE61931E58) /* 959 */, CONST64(0x9D7555B909BA1C0C) /* 960 */, CONST64(0x127FAFDD937D11D2) /* 961 */, CONST64(0x29DA3BADC66D92E4) /* 962 */, CONST64(0xA2C1D57154C2ECBC) /* 963 */, CONST64(0x58C5134D82F6FE24) /* 964 */, CONST64(0x1C3AE3515B62274F) /* 965 */, CONST64(0xE907C82E01CB8126) /* 966 */, CONST64(0xF8ED091913E37FCB) /* 967 */, CONST64(0x3249D8F9C80046C9) /* 968 */, CONST64(0x80CF9BEDE388FB63) /* 969 */, CONST64(0x1881539A116CF19E) /* 970 */, CONST64(0x5103F3F76BD52457) /* 971 */, CONST64(0x15B7E6F5AE47F7A8) /* 972 */, CONST64(0xDBD7C6DED47E9CCF) /* 973 */, CONST64(0x44E55C410228BB1A) /* 974 */, CONST64(0xB647D4255EDB4E99) /* 975 */, CONST64(0x5D11882BB8AAFC30) /* 976 */, CONST64(0xF5098BBB29D3212A) /* 977 */, CONST64(0x8FB5EA14E90296B3) /* 978 */, CONST64(0x677B942157DD025A) /* 979 */, CONST64(0xFB58E7C0A390ACB5) /* 980 */, CONST64(0x89D3674C83BD4A01) /* 981 */, CONST64(0x9E2DA4DF4BF3B93B) /* 982 */, CONST64(0xFCC41E328CAB4829) /* 983 */, CONST64(0x03F38C96BA582C52) /* 984 */, CONST64(0xCAD1BDBD7FD85DB2) /* 985 */, CONST64(0xBBB442C16082AE83) /* 986 */, CONST64(0xB95FE86BA5DA9AB0) /* 987 */, CONST64(0xB22E04673771A93F) /* 988 */, CONST64(0x845358C9493152D8) /* 989 */, CONST64(0xBE2A488697B4541E) /* 990 */, CONST64(0x95A2DC2DD38E6966) /* 991 */, CONST64(0xC02C11AC923C852B) /* 992 */, CONST64(0x2388B1990DF2A87B) /* 993 */, CONST64(0x7C8008FA1B4F37BE) /* 994 */, CONST64(0x1F70D0C84D54E503) /* 995 */, CONST64(0x5490ADEC7ECE57D4) /* 996 */, CONST64(0x002B3C27D9063A3A) /* 997 */, CONST64(0x7EAEA3848030A2BF) /* 998 */, CONST64(0xC602326DED2003C0) /* 999 */, CONST64(0x83A7287D69A94086) /* 1000 */, CONST64(0xC57A5FCB30F57A8A) /* 1001 */, CONST64(0xB56844E479EBE779) /* 1002 */, CONST64(0xA373B40F05DCBCE9) /* 1003 */, CONST64(0xD71A786E88570EE2) /* 1004 */, CONST64(0x879CBACDBDE8F6A0) /* 1005 */, CONST64(0x976AD1BCC164A32F) /* 1006 */, CONST64(0xAB21E25E9666D78B) /* 1007 */, CONST64(0x901063AAE5E5C33C) /* 1008 */, CONST64(0x9818B34448698D90) /* 1009 */, CONST64(0xE36487AE3E1E8ABB) /* 1010 */, CONST64(0xAFBDF931893BDCB4) /* 1011 */, CONST64(0x6345A0DC5FBBD519) /* 1012 */, CONST64(0x8628FE269B9465CA) /* 1013 */, CONST64(0x1E5D01603F9C51EC) /* 1014 */, CONST64(0x4DE44006A15049B7) /* 1015 */, CONST64(0xBF6C70E5F776CBB1) /* 1016 */, CONST64(0x411218F2EF552BED) /* 1017 */, CONST64(0xCB0C0708705A36A3) /* 1018 */, CONST64(0xE74D14754F986044) /* 1019 */, CONST64(0xCD56D9430EA8280E) /* 1020 */, CONST64(0xC12591D7535F5065) /* 1021 */, CONST64(0xC83223F1720AEF96) /* 1022 */, CONST64(0xC3A0396F7363A51F) /* 1023 */}; #endif /* SMALL_CODE */ #ifdef _MSC_VER #define INLINE __inline #else #define INLINE #endif /* one round of the hash function */ INLINE static void tround(ulong64 *a, ulong64 *b, ulong64 *c, ulong64 x, int mul) { ulong64 tmp; tmp = (*c ^= x); *a -= t1[byte(tmp, 0)] ^ t2[byte(tmp, 2)] ^ t3[byte(tmp, 4)] ^ t4[byte(tmp, 6)]; tmp = (*b += t4[byte(tmp, 1)] ^ t3[byte(tmp, 3)] ^ t2[byte(tmp,5)] ^ t1[byte(tmp,7)]); switch (mul) { case 5: *b = (tmp << 2) + tmp; break; case 7: *b = (tmp << 3) - tmp; break; case 9: *b = (tmp << 3) + tmp; break; } } /* one complete pass */ static void pass(ulong64 *a, ulong64 *b, ulong64 *c, ulong64 *x, int mul) { tround(a,b,c,x[0],mul); tround(b,c,a,x[1],mul); tround(c,a,b,x[2],mul); tround(a,b,c,x[3],mul); tround(b,c,a,x[4],mul); tround(c,a,b,x[5],mul); tround(a,b,c,x[6],mul); tround(b,c,a,x[7],mul); } /* The key mixing schedule */ static void key_schedule(ulong64 *x) { x[0] -= x[7] ^ CONST64(0xA5A5A5A5A5A5A5A5); x[1] ^= x[0]; x[2] += x[1]; x[3] -= x[2] ^ ((~x[1])<<19); x[4] ^= x[3]; x[5] += x[4]; x[6] -= x[5] ^ ((~x[4])>>23); x[7] ^= x[6]; x[0] += x[7]; x[1] -= x[0] ^ ((~x[7])<<19); x[2] ^= x[1]; x[3] += x[2]; x[4] -= x[3] ^ ((~x[2])>>23); x[5] ^= x[4]; x[6] += x[5]; x[7] -= x[6] ^ CONST64(0x0123456789ABCDEF); } #ifdef CLEAN_STACK static void _tiger_compress(hash_state *md, unsigned char *buf) #else static void tiger_compress(hash_state *md, unsigned char *buf) #endif { ulong64 a, b, c, x[8]; unsigned long i; /* load words */ for (i = 0; i < 8; i++) { LOAD64L(x[i],&buf[8*i]); } a = md->tiger.state[0]; b = md->tiger.state[1]; c = md->tiger.state[2]; pass(&a,&b,&c,x,5); key_schedule(x); pass(&c,&a,&b,x,7); key_schedule(x); pass(&b,&c,&a,x,9); /* store state */ md->tiger.state[0] = a ^ md->tiger.state[0]; md->tiger.state[1] = b - md->tiger.state[1]; md->tiger.state[2] = c + md->tiger.state[2]; } #ifdef CLEAN_STACK static void tiger_compress(hash_state *md, unsigned char *buf) { _tiger_compress(md, buf); burn_stack(sizeof(ulong64) * 11 + sizeof(unsigned long)); } #endif #ifdef SMALL_CODE static void build_table() { unsigned char str[] = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham"; int passes = 5; hash_state md; octet *table_ch; octet *state_ch = (octet*) md.tiger.state; unsigned char tempstr[64]; int i, j, cnt, sb, col, abc; static int running = 0; while(running); running = 1; if(table_builded){running = 0; return;} table_ch = (octet*) table; md.tiger.state[0] = CONST64(0x0123456789ABCDEF); md.tiger.state[1] = CONST64(0xFEDCBA9876543210); md.tiger.state[2] = CONST64(0xF096A5B4C3B2E187); #ifdef ENDIAN_LITTLE for(j=0; j<64; j++) tempstr[j] = str[j]; #else for(j=0; j<64; j++) tempstr[j^7] = str[j]; #endif for(i=0; i<1024; i++) for(col=0; col<8; col++) table_ch[i][col] = i&255; abc=2; for(cnt=0; cnt #include #ifdef ENDIAN_LITTLE #define M 1 #define L 0 #else #define M 0 #define L 1 #endif #ifdef __alpha #define MASK 0x00000000FFFFFFFFLL #else #define MASK 0xFFFFFFFF #endif main() { int i; ulong32 mytable[4*256][2]; build_table(); memcpy(mytable, table, sizeof(table)); printf("/* sboxes.c: Tiger S boxes */\n"); printf("typedef unsigned long long int word64;\n"); printf("word64 table[4*256] = {\n"); for(i=0; i<1024; i++) { printf(" 0x%08lX%08lXLL /* %4d */", mytable[i][M]&MASK, mytable[i][L]&MASK, i); if(i < 1023) printf(","); else printf("};"); if(i&1) printf("\n"); } printf("\n\n\n"); printf("/* sboxes32.c: Tiger S boxes for 32-bit-only compilers */\n"); printf("typedef unsigned long word32;\n"); printf("word32 table[4*256][2] = {\n"); for(i=0; i<1024; i++) { printf(" 0x%08lX, 0x%08lX /* %4d */", mytable[i][L]&MASK, mytable[i][M]&MASK, i); if(i < 1023) printf(","); else printf("};"); if(i&1) printf("\n"); } } #endif /* MAIN */ #endif /* SMALL_CODE */ void tiger_init(hash_state *md) { _ARGCHK(md != NULL); #ifdef SMALL_CODE if(!table_builded) build_table(); #endif md->tiger.state[0] = CONST64(0x0123456789ABCDEF); md->tiger.state[1] = CONST64(0xFEDCBA9876543210); md->tiger.state[2] = CONST64(0xF096A5B4C3B2E187); md->tiger.curlen = 0; md->tiger.length = 0; } HASH_PROCESS(tiger_process, tiger_compress, tiger, 64) int tiger_done(hash_state * md, unsigned char *hash) { _ARGCHK(md != NULL); _ARGCHK(hash != NULL); if (md->tiger.curlen >= sizeof(md->tiger.buf)) { return CRYPT_INVALID_ARG; } /* increase the length of the message */ md->tiger.length += md->tiger.curlen * 8; /* append the '1' bit */ md->tiger.buf[md->tiger.curlen++] = (unsigned char)0x01; /* if the length is currently above 56 bytes we append zeros * then compress. Then we can fall back to padding zeros and length * encoding like normal. */ if (md->tiger.curlen > 56) { while (md->tiger.curlen < 64) { md->tiger.buf[md->tiger.curlen++] = (unsigned char)0; } tiger_compress(md, md->tiger.buf); md->tiger.curlen = 0; } /* pad upto 56 bytes of zeroes */ while (md->tiger.curlen < 56) { md->tiger.buf[md->tiger.curlen++] = (unsigned char)0; } /* store length */ STORE64L(md->tiger.length, md->tiger.buf+56); tiger_compress(md, md->tiger.buf); /* copy output */ STORE64L(md->tiger.state[0], &hash[0]); STORE64L(md->tiger.state[1], &hash[8]); STORE64L(md->tiger.state[2], &hash[16]); #ifdef CLEAN_STACK zeromem(md, sizeof(hash_state)); #endif return CRYPT_OK; } int tiger_test(void) { #ifndef LTC_TEST return CRYPT_NOP; #else static const struct { char *msg; unsigned char hash[24]; } tests[] = { { "", { 0x32, 0x93, 0xac, 0x63, 0x0c, 0x13, 0xf0, 0x24, 0x5f, 0x92, 0xbb, 0xb1, 0x76, 0x6e, 0x16, 0x16, 0x7a, 0x4e, 0x58, 0x49, 0x2d, 0xde, 0x73, 0xf3 } }, { "abc", { 0x2a, 0xab, 0x14, 0x84, 0xe8, 0xc1, 0x58, 0xf2, 0xbf, 0xb8, 0xc5, 0xff, 0x41, 0xb5, 0x7a, 0x52, 0x51, 0x29, 0x13, 0x1c, 0x95, 0x7b, 0x5f, 0x93 } }, { "Tiger", { 0xdd, 0x00, 0x23, 0x07, 0x99, 0xf5, 0x00, 0x9f, 0xec, 0x6d, 0xeb, 0xc8, 0x38, 0xbb, 0x6a, 0x27, 0xdf, 0x2b, 0x9d, 0x6f, 0x11, 0x0c, 0x79, 0x37 } }, { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-", { 0xf7, 0x1c, 0x85, 0x83, 0x90, 0x2a, 0xfb, 0x87, 0x9e, 0xdf, 0xe6, 0x10, 0xf8, 0x2c, 0x0d, 0x47, 0x86, 0xa3, 0xa5, 0x34, 0x50, 0x44, 0x86, 0xb5 } }, { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-", { 0xc5, 0x40, 0x34, 0xe5, 0xb4, 0x3e, 0xb8, 0x00, 0x58, 0x48, 0xa7, 0xe0, 0xae, 0x6a, 0xac, 0x76, 0xe4, 0xff, 0x59, 0x0a, 0xe7, 0x15, 0xfd, 0x25 } }, }; int i; unsigned char tmp[24]; hash_state md; for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) { tiger_init(&md); tiger_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg)); tiger_done(&md, tmp); if (memcmp(tmp, tests[i].hash, 24) != 0) { return CRYPT_FAIL_TESTVECTOR; } } return CRYPT_OK; #endif } #endif /* Hash of "": 24F0130C63AC9332 16166E76B1BB925F F373DE2D49584E7A Hash of "abc": F258C1E88414AB2A 527AB541FFC5B8BF 935F7B951C132951 Hash of "Tiger": 9F00F599072300DD 276ABB38C8EB6DEC 37790C116F9D2BDF Hash of "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-": 87FB2A9083851CF7 470D2CF810E6DF9E B586445034A5A386 Hash of "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789": 467DB80863EBCE48 8DF1CD1261655DE9 57896565975F9197 Hash of "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham": 0C410A042968868A 1671DA5A3FD29A72 5EC1E457D3CDB303 Hash of "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge.": EBF591D5AFA655CE 7F22894FF87F54AC 89C811B6B0DA3193 Hash of "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996.": 3D9AEB03D1BD1A63 57B2774DFD6D5B24 DD68151D503974FC Hash of "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-": 00B83EB4E53440C5 76AC6AAEE0A74858 25FD15E70A59FFE4 */ sks-ecc-0.93/ltc/mycrypt.h0000644000175000017500000005421610715702751014416 0ustar nachonacho#ifndef CRYPT_H_ #define CRYPT_H_ #include #include #include #include #include #include #include /* if there is a custom definition header file use it */ /*#include */ #define XMALLOC malloc #define XREALLOC realloc #define XCALLOC calloc #define XFREE free #define XCLOCK clock #define XCLOCKS_PER_SEC CLOCKS_PER_SEC #define RIJNDAEL /* #define SHA256 */ #define TIGER /*#define LTC_TEST*/ #define CLEAN_STACK #ifdef __cplusplus extern "C" { #endif /* version */ #define CRYPT 0x0094 #define SCRYPT "0.94" /* max size of either a cipher/hash block or symmetric key [largest of the two] */ #define MAXBLOCKSIZE 128 /* ch1-01-1 */ /* error codes [will be expanded in future releases] */ enum { CRYPT_OK=0, /* Result OK */ CRYPT_ERROR, /* Generic Error */ CRYPT_NOP, /* Not a failure but no operation was performed */ CRYPT_INVALID_KEYSIZE, /* Invalid key size given */ CRYPT_INVALID_ROUNDS, /* Invalid number of rounds */ CRYPT_FAIL_TESTVECTOR, /* Algorithm failed test vectors */ CRYPT_BUFFER_OVERFLOW, /* Not enough space for output */ CRYPT_INVALID_PACKET, /* Invalid input packet given */ CRYPT_INVALID_PRNGSIZE, /* Invalid number of bits for a PRNG */ CRYPT_ERROR_READPRNG, /* Could not read enough from PRNG */ CRYPT_INVALID_CIPHER, /* Invalid cipher specified */ CRYPT_INVALID_HASH, /* Invalid hash specified */ CRYPT_INVALID_PRNG, /* Invalid PRNG specified */ CRYPT_MEM, /* Out of memory */ CRYPT_PK_TYPE_MISMATCH, /* Not equivalent types of PK keys */ CRYPT_PK_NOT_PRIVATE, /* Requires a private PK key */ CRYPT_INVALID_ARG, /* Generic invalid argument */ CRYPT_FILE_NOTFOUND, /* File Not Found */ CRYPT_PK_INVALID_TYPE, /* Invalid type of PK key */ CRYPT_PK_INVALID_SYSTEM,/* Invalid PK system specified */ CRYPT_PK_DUP, /* Duplicate key already in key ring */ CRYPT_PK_NOT_FOUND, /* Key not found in keyring */ CRYPT_PK_INVALID_SIZE, /* Invalid size input for PK parameters */ CRYPT_INVALID_PRIME_SIZE/* Invalid size of prime requested */ }; /* ch1-01-1 */ /*#include */ /* This is the build config file. * * With this you can setup what to inlcude/exclude automatically during any build. Just comment * out the line that #define's the word for the thing you want to remove. phew! */ #ifndef MYCRYPT_CFG_H #define MYCRYPT_CFG_H /* you can change how memory allocation works ... */ extern void *XMALLOC(size_t n); extern void *REALLOC(void *p, size_t n); extern void *XCALLOC(size_t n, size_t s); extern void XFREE(void *p); /* change the clock function too */ extern clock_t XCLOCK(void); /* ch1-01-1 */ /* type of argument checking, 0=default, 1=fatal and 2=none */ #define ARGTYPE 2 /* ch1-01-1 */ /* Controls endianess and size of registers. Leave uncommented to get platform neutral [slower] code */ /* detect x86-32 machines somewhat */ #if (defined(_MSC_VER) && defined(WIN32)) || (defined(__GNUC__) && (defined(__DJGPP__) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__i386__))) #define ENDIAN_LITTLE #define ENDIAN_32BITWORD #endif /* detects MIPS R5900 processors (PS2) */ #if (defined(__R5900) || defined(R5900) || defined(__R5900__)) && (defined(_mips) || defined(__mips__) || defined(mips)) #define ENDIAN_LITTLE #define ENDIAN_64BITWORD #endif /* #define ENDIAN_LITTLE */ /* #define ENDIAN_BIG */ /* #define ENDIAN_32BITWORD */ /* #define ENDIAN_64BITWORD */ #if (defined(ENDIAN_BIG) || defined(ENDIAN_LITTLE)) && !(defined(ENDIAN_32BITWORD) || defined(ENDIAN_64BITWORD)) #error You must specify a word size as well as endianess in mycrypt_cfg.h #endif #if !(defined(ENDIAN_BIG) || defined(ENDIAN_LITTLE)) #define ENDIAN_NEUTRAL #endif #ifdef YARROW #ifndef CTR #error YARROW requires CTR chaining mode to be defined! #endif #endif /* packet code */ #if defined(MRSA) || defined(MDH) || defined(MECC) #define PACKET /* size of a packet header in bytes */ #define PACKET_SIZE 4 /* Section tags */ #define PACKET_SECT_RSA 0 #define PACKET_SECT_DH 1 #define PACKET_SECT_ECC 2 #define PACKET_SECT_DSA 3 /* Subsection Tags for the first three sections */ #define PACKET_SUB_KEY 0 #define PACKET_SUB_ENCRYPTED 1 #define PACKET_SUB_SIGNED 2 #define PACKET_SUB_ENC_KEY 3 #endif #endif /* MYCRYPT_CFG_H */ /*------------------------*/ /*#include */ /* fix for MSVC ...evil! */ #ifdef _MSC_VER #define CONST64(n) n ## ui64 typedef unsigned __int64 ulong64; #else #define CONST64(n) n ## ULL typedef unsigned long long ulong64; #endif /* this is the "32-bit at least" data type * Re-define it to suit your platform but it must be at least 32-bits */ typedef unsigned long ulong32; /* ---- HELPER MACROS ---- */ #ifdef ENDIAN_NEUTRAL #define STORE32L(x, y) \ { (y)[3] = (unsigned char)(((x)>>24)&255); (y)[2] = (unsigned char)(((x)>>16)&255); \ (y)[1] = (unsigned char)(((x)>>8)&255); (y)[0] = (unsigned char)((x)&255); } #define LOAD32L(x, y) \ { x = ((unsigned long)((y)[3] & 255)<<24) | \ ((unsigned long)((y)[2] & 255)<<16) | \ ((unsigned long)((y)[1] & 255)<<8) | \ ((unsigned long)((y)[0] & 255)); } #define STORE64L(x, y) \ { (y)[7] = (unsigned char)(((x)>>56)&255); (y)[6] = (unsigned char)(((x)>>48)&255); \ (y)[5] = (unsigned char)(((x)>>40)&255); (y)[4] = (unsigned char)(((x)>>32)&255); \ (y)[3] = (unsigned char)(((x)>>24)&255); (y)[2] = (unsigned char)(((x)>>16)&255); \ (y)[1] = (unsigned char)(((x)>>8)&255); (y)[0] = (unsigned char)((x)&255); } #define LOAD64L(x, y) \ { x = (((ulong64)((y)[7] & 255))<<56)|(((ulong64)((y)[6] & 255))<<48)| \ (((ulong64)((y)[5] & 255))<<40)|(((ulong64)((y)[4] & 255))<<32)| \ (((ulong64)((y)[3] & 255))<<24)|(((ulong64)((y)[2] & 255))<<16)| \ (((ulong64)((y)[1] & 255))<<8)|(((ulong64)((y)[0] & 255))); } #define STORE32H(x, y) \ { (y)[0] = (unsigned char)(((x)>>24)&255); (y)[1] = (unsigned char)(((x)>>16)&255); \ (y)[2] = (unsigned char)(((x)>>8)&255); (y)[3] = (unsigned char)((x)&255); } #define LOAD32H(x, y) \ { x = ((unsigned long)((y)[0] & 255)<<24) | \ ((unsigned long)((y)[1] & 255)<<16) | \ ((unsigned long)((y)[2] & 255)<<8) | \ ((unsigned long)((y)[3] & 255)); } #define STORE64H(x, y) \ { (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255); \ (y)[2] = (unsigned char)(((x)>>40)&255); (y)[3] = (unsigned char)(((x)>>32)&255); \ (y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255); \ (y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); } #define LOAD64H(x, y) \ { x = (((ulong64)((y)[0] & 255))<<56)|(((ulong64)((y)[1] & 255))<<48) | \ (((ulong64)((y)[2] & 255))<<40)|(((ulong64)((y)[3] & 255))<<32) | \ (((ulong64)((y)[4] & 255))<<24)|(((ulong64)((y)[5] & 255))<<16) | \ (((ulong64)((y)[6] & 255))<<8)|(((ulong64)((y)[7] & 255))); } #endif /* ENDIAN_NEUTRAL */ #ifdef ENDIAN_LITTLE #define STORE32H(x, y) \ { (y)[0] = (unsigned char)(((x)>>24)&255); (y)[1] = (unsigned char)(((x)>>16)&255); \ (y)[2] = (unsigned char)(((x)>>8)&255); (y)[3] = (unsigned char)((x)&255); } #define LOAD32H(x, y) \ { x = ((unsigned long)((y)[0] & 255)<<24) | \ ((unsigned long)((y)[1] & 255)<<16) | \ ((unsigned long)((y)[2] & 255)<<8) | \ ((unsigned long)((y)[3] & 255)); } #define STORE64H(x, y) \ { (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255); \ (y)[2] = (unsigned char)(((x)>>40)&255); (y)[3] = (unsigned char)(((x)>>32)&255); \ (y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255); \ (y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); } #define LOAD64H(x, y) \ { x = (((ulong64)((y)[0] & 255))<<56)|(((ulong64)((y)[1] & 255))<<48) | \ (((ulong64)((y)[2] & 255))<<40)|(((ulong64)((y)[3] & 255))<<32) | \ (((ulong64)((y)[4] & 255))<<24)|(((ulong64)((y)[5] & 255))<<16) | \ (((ulong64)((y)[6] & 255))<<8)|(((ulong64)((y)[7] & 255))); } #ifdef ENDIAN_32BITWORD #define STORE32L(x, y) \ { unsigned long __t = (x); memcpy(y, &__t, 4); } #define LOAD32L(x, y) \ memcpy(&(x), y, 4); #define STORE64L(x, y) \ { (y)[7] = (unsigned char)(((x)>>56)&255); (y)[6] = (unsigned char)(((x)>>48)&255); \ (y)[5] = (unsigned char)(((x)>>40)&255); (y)[4] = (unsigned char)(((x)>>32)&255); \ (y)[3] = (unsigned char)(((x)>>24)&255); (y)[2] = (unsigned char)(((x)>>16)&255); \ (y)[1] = (unsigned char)(((x)>>8)&255); (y)[0] = (unsigned char)((x)&255); } #define LOAD64L(x, y) \ { x = (((ulong64)((y)[7] & 255))<<56)|(((ulong64)((y)[6] & 255))<<48)| \ (((ulong64)((y)[5] & 255))<<40)|(((ulong64)((y)[4] & 255))<<32)| \ (((ulong64)((y)[3] & 255))<<24)|(((ulong64)((y)[2] & 255))<<16)| \ (((ulong64)((y)[1] & 255))<<8)|(((ulong64)((y)[0] & 255))); } #else /* 64-bit words then */ #define STORE32L(x, y) \ { unsigned long __t = (x); memcpy(y, &__t, 4); } #define LOAD32L(x, y) \ { memcpy(&(x), y, 4); x &= 0xFFFFFFFF; } #define STORE64L(x, y) \ { ulong64 __t = (x); memcpy(y, &__t, 8); } #define LOAD64L(x, y) \ { memcpy(&(x), y, 8); } #endif /* ENDIAN_64BITWORD */ #endif /* ENDIAN_LITTLE */ #ifdef ENDIAN_BIG #define STORE32L(x, y) \ { (y)[3] = (unsigned char)(((x)>>24)&255); (y)[2] = (unsigned char)(((x)>>16)&255); \ (y)[1] = (unsigned char)(((x)>>8)&255); (y)[0] = (unsigned char)((x)&255); } #define LOAD32L(x, y) \ { x = ((unsigned long)((y)[3] & 255)<<24) | \ ((unsigned long)((y)[2] & 255)<<16) | \ ((unsigned long)((y)[1] & 255)<<8) | \ ((unsigned long)((y)[0] & 255)); } #define STORE64L(x, y) \ { (y)[7] = (unsigned char)(((x)>>56)&255); (y)[6] = (unsigned char)(((x)>>48)&255); \ (y)[5] = (unsigned char)(((x)>>40)&255); (y)[4] = (unsigned char)(((x)>>32)&255); \ (y)[3] = (unsigned char)(((x)>>24)&255); (y)[2] = (unsigned char)(((x)>>16)&255); \ (y)[1] = (unsigned char)(((x)>>8)&255); (y)[0] = (unsigned char)((x)&255); } #define LOAD64L(x, y) \ { x = (((ulong64)((y)[7] & 255))<<56)|(((ulong64)((y)[6] & 255))<<48) | \ (((ulong64)((y)[5] & 255))<<40)|(((ulong64)((y)[4] & 255))<<32) | \ (((ulong64)((y)[3] & 255))<<24)|(((ulong64)((y)[2] & 255))<<16) | \ (((ulong64)((y)[1] & 255))<<8)|(((ulong64)((y)[0] & 255))); } #ifdef ENDIAN_32BITWORD #define STORE32H(x, y) \ { unsigned long __t = (x); memcpy(y, &__t, 4); } #define LOAD32H(x, y) \ memcpy(&(x), y, 4); #define STORE64H(x, y) \ { (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255); \ (y)[2] = (unsigned char)(((x)>>40)&255); (y)[3] = (unsigned char)(((x)>>32)&255); \ (y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255); \ (y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); } #define LOAD64H(x, y) \ { x = (((ulong64)((y)[0] & 255))<<56)|(((ulong64)((y)[1] & 255))<<48)| \ (((ulong64)((y)[2] & 255))<<40)|(((ulong64)((y)[3] & 255))<<32)| \ (((ulong64)((y)[4] & 255))<<24)|(((ulong64)((y)[5] & 255))<<16)| \ (((ulong64)((y)[6] & 255))<<8)| (((ulong64)((y)[7] & 255))); } #else /* 64-bit words then */ #define STORE32H(x, y) \ { unsigned long __t = (x); memcpy(y, &__t, 4); } #define LOAD32H(x, y) \ { memcpy(&(x), y, 4); x &= 0xFFFFFFFF; } #define STORE64H(x, y) \ { ulong64 __t = (x); memcpy(y, &__t, 8); } #define LOAD64H(x, y) \ { memcpy(&(x), y, 8); } #endif /* ENDIAN_64BITWORD */ #endif /* ENDIAN_BIG */ #define BSWAP(x) ( ((x>>24)&0x000000FFUL) | ((x<<24)&0xFF000000UL) | \ ((x>>8)&0x0000FF00UL) | ((x<<8)&0x00FF0000UL) ) #ifdef _MSC_VER /* instrinsic rotate */ #include #pragma intrinsic(_lrotr,_lrotl) #define ROR(x,n) _lrotr(x,n) #define ROL(x,n) _lrotl(x,n) #elif defined(__GNUC__) && defined(__i386__) static inline unsigned long ROL(unsigned long word, int i) { __asm__("roll %%cl,%0" :"=r" (word) :"0" (word),"c" (i)); return word; } static inline unsigned long ROR(unsigned long word, int i) { __asm__("rorl %%cl,%0" :"=r" (word) :"0" (word),"c" (i)); return word; } #else /* rotates the hard way */ #define ROL(x, y) ( (((unsigned long)(x)<<(unsigned long)((y)&31)) | (((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL) #define ROR(x, y) ( ((((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)((y)&31)) | ((unsigned long)(x)<<(unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL) #endif #define ROL64(x, y) \ ( (((x)<<((ulong64)(y)&63)) | \ (((x)&CONST64(0xFFFFFFFFFFFFFFFF))>>((ulong64)64-((y)&63)))) & CONST64(0xFFFFFFFFFFFFFFFF)) #define ROR64(x, y) \ ( ((((x)&CONST64(0xFFFFFFFFFFFFFFFF))>>((ulong64)(y)&CONST64(63))) | \ ((x)<<((ulong64)(64-((y)&CONST64(63)))))) & CONST64(0xFFFFFFFFFFFFFFFF)) #undef MAX #undef MIN #define MAX(x, y) ( ((x)>(y))?(x):(y) ) #define MIN(x, y) ( ((x)<(y))?(x):(y) ) /* extract a byte portably */ #ifdef _MSC_VER #define byte(x, n) ((unsigned char)((x) >> (8 * (n)))) #else #define byte(x, n) (((x) >> (8 * (n))) & 255) #endif /*------------------------*/ /*#include */ struct rijndael_key { ulong32 eK[64], dK[64]; int Nr; }; typedef union Symmetric_key { struct rijndael_key rijndael; } symmetric_key; extern struct _cipher_descriptor { char *name; unsigned char ID; int min_key_length, max_key_length, block_length, default_rounds; int (*setup)(const unsigned char *key, int keylength, int num_rounds, symmetric_key *skey); void (*ecb_encrypt)(const unsigned char *pt, unsigned char *ct, symmetric_key *key); void (*ecb_decrypt)(const unsigned char *ct, unsigned char *pt, symmetric_key *key); int (*test)(void); int (*keysize)(int *desired_keysize); } cipher_descriptor[]; /* make aes an alias */ #define aes_setup rijndael_setup #define aes_ecb_encrypt rijndael_ecb_encrypt #define aes_ecb_decrypt rijndael_ecb_decrypt #define aes_test rijndael_test #define aes_keysize rijndael_keysize extern int rijndael_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); extern void rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *key); extern void rijndael_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *key); extern int rijndael_test(void); extern int rijndael_keysize(int *desired_keysize); extern const struct _cipher_descriptor rijndael_desc, aes_desc; extern int find_cipher(const char *name); extern int find_cipher_any(const char *name, int blocklen, int keylen); extern int find_cipher_id(unsigned char ID); extern int register_cipher(const struct _cipher_descriptor *cipher); extern int unregister_cipher(const struct _cipher_descriptor *cipher); extern int cipher_is_valid(int idx); /*------------------------*/ /*#include */ #ifdef SHA256 struct sha256_state { ulong64 length; ulong32 state[8], curlen; unsigned char buf[64]; }; #endif #ifdef TIGER struct tiger_state { ulong64 state[3], length; unsigned long curlen; unsigned char buf[64]; }; #endif typedef union Hash_state { #ifdef SHA256 struct sha256_state sha256; #endif #ifdef TIGER struct tiger_state tiger; #endif } hash_state; extern struct _hash_descriptor { char *name; unsigned char ID; unsigned long hashsize; /* digest output size in bytes */ unsigned long blocksize; /* the block size the hash uses */ void (*init)(hash_state *); int (*process)(hash_state *, const unsigned char *, unsigned long); int (*done)(hash_state *, unsigned char *); int (*test)(void); } hash_descriptor[]; #ifdef SHA256 extern void sha256_init(hash_state * md); extern int sha256_process(hash_state * md, const unsigned char *buf, unsigned long len); extern int sha256_done(hash_state * md, unsigned char *hash); extern int sha256_test(void); extern const struct _hash_descriptor sha256_desc; #endif #ifdef TIGER extern void tiger_init(hash_state * md); extern int tiger_process(hash_state * md, const unsigned char *buf, unsigned long len); extern int tiger_done(hash_state * md, unsigned char *hash); extern int tiger_test(void); extern const struct _hash_descriptor tiger_desc; #endif extern int find_hash(const char *name); extern int find_hash_id(unsigned char ID); extern int find_hash_any(const char *name, int digestlen); extern int register_hash(const struct _hash_descriptor *hash); extern int unregister_hash(const struct _hash_descriptor *hash); extern int hash_is_valid(int idx); extern int hash_memory(int hash, const unsigned char *data, unsigned long len, unsigned char *dst, unsigned long *outlen); extern int hash_filehandle(int hash, FILE *in, unsigned char *dst, unsigned long *outlen); extern int hash_file(int hash, const char *fname, unsigned char *dst, unsigned long *outlen); /* a simple macro for making hash "process" functions */ #define HASH_PROCESS(func_name, compress_name, state_var, block_size) \ int func_name (hash_state * md, const unsigned char *buf, unsigned long len) \ { \ unsigned long n; \ _ARGCHK(md != NULL); \ _ARGCHK(buf != NULL); \ if (md-> state_var .curlen > sizeof(md-> state_var .buf)) { \ return CRYPT_INVALID_ARG; \ } \ while (len > 0) { \ if (md-> state_var .curlen == 0 && len >= block_size) { \ compress_name (md, (unsigned char *)buf); \ md-> state_var .length += block_size * 8; \ buf += block_size; \ len -= block_size; \ } else { \ n = MIN(len, (block_size - md-> state_var .curlen)); \ memcpy(md-> state_var .buf + md-> state_var.curlen, buf, (size_t)n); \ md-> state_var .curlen += n; \ buf += n; \ len -= n; \ if (md-> state_var .curlen == block_size) { \ compress_name (md, md-> state_var .buf); \ md-> state_var .length += 8*block_size; \ md-> state_var .curlen = 0; \ } \ } \ } \ return CRYPT_OK; \ } /*------------------------------*/ /*#include #include #include NOT NEEDED */ /*#include */ /* extern void zeromem(void *dst, size_t len); extern void burn_stack(unsigned long len); */ #define zeromem(A, B) memset(A, 0, B) extern const char *error_to_string(int err); extern int mpi_to_ltc_error(int err); extern const char *crypt_build_settings; /*---------------------------------*/ /*#include NOT NEEDED */ /*#include */ /* Defines the _ARGCHK macro used within the library */ /* ch1-01-1 */ /* ARGTYPE is defined in mycrypt_cfg.h */ #if ARGTYPE == 0 #include /* this is the default LibTomCrypt macro */ extern void crypt_argchk(char *v, char *s, int d); #define _ARGCHK(x) if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } #elif ARGTYPE == 1 /* fatal type of error */ #define _ARGCHK(x) assert((x)) #elif ARGTYPE == 2 #define _ARGCHK(x) #endif /* ch1-01-1 */ /*-------------------*/ #ifdef __cplusplus } #endif #endif /* CRYPT_H_ */ sks-ecc-0.93/ltc/aes_tab.c0000644000175000017500000021142210715702751014272 0ustar nachonacho/* aes_tab.c (Part of SKS cryptosystem) Explicit tables for Rijndael (AES) encryption This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Manuel Pancorbo Castro */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@iahu.ca, http://libtomcrypt.org */ /* The precomputed tables for AES */ /* Te0[x] = S [x].[02, 01, 01, 03]; Te1[x] = S [x].[03, 02, 01, 01]; Te2[x] = S [x].[01, 03, 02, 01]; Te3[x] = S [x].[01, 01, 03, 02]; Te4[x] = S [x].[01, 01, 01, 01]; Td0[x] = Si[x].[0e, 09, 0d, 0b]; Td1[x] = Si[x].[0b, 0e, 09, 0d]; Td2[x] = Si[x].[0d, 0b, 0e, 09]; Td3[x] = Si[x].[09, 0d, 0b, 0e]; Td4[x] = Si[x].[01, 01, 01, 01]; */ static const ulong32 TE0[256] = { 0xc66363a5UL, 0xf87c7c84UL, 0xee777799UL, 0xf67b7b8dUL, 0xfff2f20dUL, 0xd66b6bbdUL, 0xde6f6fb1UL, 0x91c5c554UL, 0x60303050UL, 0x02010103UL, 0xce6767a9UL, 0x562b2b7dUL, 0xe7fefe19UL, 0xb5d7d762UL, 0x4dababe6UL, 0xec76769aUL, 0x8fcaca45UL, 0x1f82829dUL, 0x89c9c940UL, 0xfa7d7d87UL, 0xeffafa15UL, 0xb25959ebUL, 0x8e4747c9UL, 0xfbf0f00bUL, 0x41adadecUL, 0xb3d4d467UL, 0x5fa2a2fdUL, 0x45afafeaUL, 0x239c9cbfUL, 0x53a4a4f7UL, 0xe4727296UL, 0x9bc0c05bUL, 0x75b7b7c2UL, 0xe1fdfd1cUL, 0x3d9393aeUL, 0x4c26266aUL, 0x6c36365aUL, 0x7e3f3f41UL, 0xf5f7f702UL, 0x83cccc4fUL, 0x6834345cUL, 0x51a5a5f4UL, 0xd1e5e534UL, 0xf9f1f108UL, 0xe2717193UL, 0xabd8d873UL, 0x62313153UL, 0x2a15153fUL, 0x0804040cUL, 0x95c7c752UL, 0x46232365UL, 0x9dc3c35eUL, 0x30181828UL, 0x379696a1UL, 0x0a05050fUL, 0x2f9a9ab5UL, 0x0e070709UL, 0x24121236UL, 0x1b80809bUL, 0xdfe2e23dUL, 0xcdebeb26UL, 0x4e272769UL, 0x7fb2b2cdUL, 0xea75759fUL, 0x1209091bUL, 0x1d83839eUL, 0x582c2c74UL, 0x341a1a2eUL, 0x361b1b2dUL, 0xdc6e6eb2UL, 0xb45a5aeeUL, 0x5ba0a0fbUL, 0xa45252f6UL, 0x763b3b4dUL, 0xb7d6d661UL, 0x7db3b3ceUL, 0x5229297bUL, 0xdde3e33eUL, 0x5e2f2f71UL, 0x13848497UL, 0xa65353f5UL, 0xb9d1d168UL, 0x00000000UL, 0xc1eded2cUL, 0x40202060UL, 0xe3fcfc1fUL, 0x79b1b1c8UL, 0xb65b5bedUL, 0xd46a6abeUL, 0x8dcbcb46UL, 0x67bebed9UL, 0x7239394bUL, 0x944a4adeUL, 0x984c4cd4UL, 0xb05858e8UL, 0x85cfcf4aUL, 0xbbd0d06bUL, 0xc5efef2aUL, 0x4faaaae5UL, 0xedfbfb16UL, 0x864343c5UL, 0x9a4d4dd7UL, 0x66333355UL, 0x11858594UL, 0x8a4545cfUL, 0xe9f9f910UL, 0x04020206UL, 0xfe7f7f81UL, 0xa05050f0UL, 0x783c3c44UL, 0x259f9fbaUL, 0x4ba8a8e3UL, 0xa25151f3UL, 0x5da3a3feUL, 0x804040c0UL, 0x058f8f8aUL, 0x3f9292adUL, 0x219d9dbcUL, 0x70383848UL, 0xf1f5f504UL, 0x63bcbcdfUL, 0x77b6b6c1UL, 0xafdada75UL, 0x42212163UL, 0x20101030UL, 0xe5ffff1aUL, 0xfdf3f30eUL, 0xbfd2d26dUL, 0x81cdcd4cUL, 0x180c0c14UL, 0x26131335UL, 0xc3ecec2fUL, 0xbe5f5fe1UL, 0x359797a2UL, 0x884444ccUL, 0x2e171739UL, 0x93c4c457UL, 0x55a7a7f2UL, 0xfc7e7e82UL, 0x7a3d3d47UL, 0xc86464acUL, 0xba5d5de7UL, 0x3219192bUL, 0xe6737395UL, 0xc06060a0UL, 0x19818198UL, 0x9e4f4fd1UL, 0xa3dcdc7fUL, 0x44222266UL, 0x542a2a7eUL, 0x3b9090abUL, 0x0b888883UL, 0x8c4646caUL, 0xc7eeee29UL, 0x6bb8b8d3UL, 0x2814143cUL, 0xa7dede79UL, 0xbc5e5ee2UL, 0x160b0b1dUL, 0xaddbdb76UL, 0xdbe0e03bUL, 0x64323256UL, 0x743a3a4eUL, 0x140a0a1eUL, 0x924949dbUL, 0x0c06060aUL, 0x4824246cUL, 0xb85c5ce4UL, 0x9fc2c25dUL, 0xbdd3d36eUL, 0x43acacefUL, 0xc46262a6UL, 0x399191a8UL, 0x319595a4UL, 0xd3e4e437UL, 0xf279798bUL, 0xd5e7e732UL, 0x8bc8c843UL, 0x6e373759UL, 0xda6d6db7UL, 0x018d8d8cUL, 0xb1d5d564UL, 0x9c4e4ed2UL, 0x49a9a9e0UL, 0xd86c6cb4UL, 0xac5656faUL, 0xf3f4f407UL, 0xcfeaea25UL, 0xca6565afUL, 0xf47a7a8eUL, 0x47aeaee9UL, 0x10080818UL, 0x6fbabad5UL, 0xf0787888UL, 0x4a25256fUL, 0x5c2e2e72UL, 0x381c1c24UL, 0x57a6a6f1UL, 0x73b4b4c7UL, 0x97c6c651UL, 0xcbe8e823UL, 0xa1dddd7cUL, 0xe874749cUL, 0x3e1f1f21UL, 0x964b4bddUL, 0x61bdbddcUL, 0x0d8b8b86UL, 0x0f8a8a85UL, 0xe0707090UL, 0x7c3e3e42UL, 0x71b5b5c4UL, 0xcc6666aaUL, 0x904848d8UL, 0x06030305UL, 0xf7f6f601UL, 0x1c0e0e12UL, 0xc26161a3UL, 0x6a35355fUL, 0xae5757f9UL, 0x69b9b9d0UL, 0x17868691UL, 0x99c1c158UL, 0x3a1d1d27UL, 0x279e9eb9UL, 0xd9e1e138UL, 0xebf8f813UL, 0x2b9898b3UL, 0x22111133UL, 0xd26969bbUL, 0xa9d9d970UL, 0x078e8e89UL, 0x339494a7UL, 0x2d9b9bb6UL, 0x3c1e1e22UL, 0x15878792UL, 0xc9e9e920UL, 0x87cece49UL, 0xaa5555ffUL, 0x50282878UL, 0xa5dfdf7aUL, 0x038c8c8fUL, 0x59a1a1f8UL, 0x09898980UL, 0x1a0d0d17UL, 0x65bfbfdaUL, 0xd7e6e631UL, 0x844242c6UL, 0xd06868b8UL, 0x824141c3UL, 0x299999b0UL, 0x5a2d2d77UL, 0x1e0f0f11UL, 0x7bb0b0cbUL, 0xa85454fcUL, 0x6dbbbbd6UL, 0x2c16163aUL, }; /*static*/ const ulong32 Te4[256] = { /** The main table is kept visible **/ 0x63636363UL, 0x7c7c7c7cUL, 0x77777777UL, 0x7b7b7b7bUL, 0xf2f2f2f2UL, 0x6b6b6b6bUL, 0x6f6f6f6fUL, 0xc5c5c5c5UL, 0x30303030UL, 0x01010101UL, 0x67676767UL, 0x2b2b2b2bUL, 0xfefefefeUL, 0xd7d7d7d7UL, 0xababababUL, 0x76767676UL, 0xcacacacaUL, 0x82828282UL, 0xc9c9c9c9UL, 0x7d7d7d7dUL, 0xfafafafaUL, 0x59595959UL, 0x47474747UL, 0xf0f0f0f0UL, 0xadadadadUL, 0xd4d4d4d4UL, 0xa2a2a2a2UL, 0xafafafafUL, 0x9c9c9c9cUL, 0xa4a4a4a4UL, 0x72727272UL, 0xc0c0c0c0UL, 0xb7b7b7b7UL, 0xfdfdfdfdUL, 0x93939393UL, 0x26262626UL, 0x36363636UL, 0x3f3f3f3fUL, 0xf7f7f7f7UL, 0xccccccccUL, 0x34343434UL, 0xa5a5a5a5UL, 0xe5e5e5e5UL, 0xf1f1f1f1UL, 0x71717171UL, 0xd8d8d8d8UL, 0x31313131UL, 0x15151515UL, 0x04040404UL, 0xc7c7c7c7UL, 0x23232323UL, 0xc3c3c3c3UL, 0x18181818UL, 0x96969696UL, 0x05050505UL, 0x9a9a9a9aUL, 0x07070707UL, 0x12121212UL, 0x80808080UL, 0xe2e2e2e2UL, 0xebebebebUL, 0x27272727UL, 0xb2b2b2b2UL, 0x75757575UL, 0x09090909UL, 0x83838383UL, 0x2c2c2c2cUL, 0x1a1a1a1aUL, 0x1b1b1b1bUL, 0x6e6e6e6eUL, 0x5a5a5a5aUL, 0xa0a0a0a0UL, 0x52525252UL, 0x3b3b3b3bUL, 0xd6d6d6d6UL, 0xb3b3b3b3UL, 0x29292929UL, 0xe3e3e3e3UL, 0x2f2f2f2fUL, 0x84848484UL, 0x53535353UL, 0xd1d1d1d1UL, 0x00000000UL, 0xededededUL, 0x20202020UL, 0xfcfcfcfcUL, 0xb1b1b1b1UL, 0x5b5b5b5bUL, 0x6a6a6a6aUL, 0xcbcbcbcbUL, 0xbebebebeUL, 0x39393939UL, 0x4a4a4a4aUL, 0x4c4c4c4cUL, 0x58585858UL, 0xcfcfcfcfUL, 0xd0d0d0d0UL, 0xefefefefUL, 0xaaaaaaaaUL, 0xfbfbfbfbUL, 0x43434343UL, 0x4d4d4d4dUL, 0x33333333UL, 0x85858585UL, 0x45454545UL, 0xf9f9f9f9UL, 0x02020202UL, 0x7f7f7f7fUL, 0x50505050UL, 0x3c3c3c3cUL, 0x9f9f9f9fUL, 0xa8a8a8a8UL, 0x51515151UL, 0xa3a3a3a3UL, 0x40404040UL, 0x8f8f8f8fUL, 0x92929292UL, 0x9d9d9d9dUL, 0x38383838UL, 0xf5f5f5f5UL, 0xbcbcbcbcUL, 0xb6b6b6b6UL, 0xdadadadaUL, 0x21212121UL, 0x10101010UL, 0xffffffffUL, 0xf3f3f3f3UL, 0xd2d2d2d2UL, 0xcdcdcdcdUL, 0x0c0c0c0cUL, 0x13131313UL, 0xececececUL, 0x5f5f5f5fUL, 0x97979797UL, 0x44444444UL, 0x17171717UL, 0xc4c4c4c4UL, 0xa7a7a7a7UL, 0x7e7e7e7eUL, 0x3d3d3d3dUL, 0x64646464UL, 0x5d5d5d5dUL, 0x19191919UL, 0x73737373UL, 0x60606060UL, 0x81818181UL, 0x4f4f4f4fUL, 0xdcdcdcdcUL, 0x22222222UL, 0x2a2a2a2aUL, 0x90909090UL, 0x88888888UL, 0x46464646UL, 0xeeeeeeeeUL, 0xb8b8b8b8UL, 0x14141414UL, 0xdedededeUL, 0x5e5e5e5eUL, 0x0b0b0b0bUL, 0xdbdbdbdbUL, 0xe0e0e0e0UL, 0x32323232UL, 0x3a3a3a3aUL, 0x0a0a0a0aUL, 0x49494949UL, 0x06060606UL, 0x24242424UL, 0x5c5c5c5cUL, 0xc2c2c2c2UL, 0xd3d3d3d3UL, 0xacacacacUL, 0x62626262UL, 0x91919191UL, 0x95959595UL, 0xe4e4e4e4UL, 0x79797979UL, 0xe7e7e7e7UL, 0xc8c8c8c8UL, 0x37373737UL, 0x6d6d6d6dUL, 0x8d8d8d8dUL, 0xd5d5d5d5UL, 0x4e4e4e4eUL, 0xa9a9a9a9UL, 0x6c6c6c6cUL, 0x56565656UL, 0xf4f4f4f4UL, 0xeaeaeaeaUL, 0x65656565UL, 0x7a7a7a7aUL, 0xaeaeaeaeUL, 0x08080808UL, 0xbabababaUL, 0x78787878UL, 0x25252525UL, 0x2e2e2e2eUL, 0x1c1c1c1cUL, 0xa6a6a6a6UL, 0xb4b4b4b4UL, 0xc6c6c6c6UL, 0xe8e8e8e8UL, 0xddddddddUL, 0x74747474UL, 0x1f1f1f1fUL, 0x4b4b4b4bUL, 0xbdbdbdbdUL, 0x8b8b8b8bUL, 0x8a8a8a8aUL, 0x70707070UL, 0x3e3e3e3eUL, 0xb5b5b5b5UL, 0x66666666UL, 0x48484848UL, 0x03030303UL, 0xf6f6f6f6UL, 0x0e0e0e0eUL, 0x61616161UL, 0x35353535UL, 0x57575757UL, 0xb9b9b9b9UL, 0x86868686UL, 0xc1c1c1c1UL, 0x1d1d1d1dUL, 0x9e9e9e9eUL, 0xe1e1e1e1UL, 0xf8f8f8f8UL, 0x98989898UL, 0x11111111UL, 0x69696969UL, 0xd9d9d9d9UL, 0x8e8e8e8eUL, 0x94949494UL, 0x9b9b9b9bUL, 0x1e1e1e1eUL, 0x87878787UL, 0xe9e9e9e9UL, 0xcecececeUL, 0x55555555UL, 0x28282828UL, 0xdfdfdfdfUL, 0x8c8c8c8cUL, 0xa1a1a1a1UL, 0x89898989UL, 0x0d0d0d0dUL, 0xbfbfbfbfUL, 0xe6e6e6e6UL, 0x42424242UL, 0x68686868UL, 0x41414141UL, 0x99999999UL, 0x2d2d2d2dUL, 0x0f0f0f0fUL, 0xb0b0b0b0UL, 0x54545454UL, 0xbbbbbbbbUL, 0x16161616UL, }; static const ulong32 TD0[256] = { 0x51f4a750UL, 0x7e416553UL, 0x1a17a4c3UL, 0x3a275e96UL, 0x3bab6bcbUL, 0x1f9d45f1UL, 0xacfa58abUL, 0x4be30393UL, 0x2030fa55UL, 0xad766df6UL, 0x88cc7691UL, 0xf5024c25UL, 0x4fe5d7fcUL, 0xc52acbd7UL, 0x26354480UL, 0xb562a38fUL, 0xdeb15a49UL, 0x25ba1b67UL, 0x45ea0e98UL, 0x5dfec0e1UL, 0xc32f7502UL, 0x814cf012UL, 0x8d4697a3UL, 0x6bd3f9c6UL, 0x038f5fe7UL, 0x15929c95UL, 0xbf6d7aebUL, 0x955259daUL, 0xd4be832dUL, 0x587421d3UL, 0x49e06929UL, 0x8ec9c844UL, 0x75c2896aUL, 0xf48e7978UL, 0x99583e6bUL, 0x27b971ddUL, 0xbee14fb6UL, 0xf088ad17UL, 0xc920ac66UL, 0x7dce3ab4UL, 0x63df4a18UL, 0xe51a3182UL, 0x97513360UL, 0x62537f45UL, 0xb16477e0UL, 0xbb6bae84UL, 0xfe81a01cUL, 0xf9082b94UL, 0x70486858UL, 0x8f45fd19UL, 0x94de6c87UL, 0x527bf8b7UL, 0xab73d323UL, 0x724b02e2UL, 0xe31f8f57UL, 0x6655ab2aUL, 0xb2eb2807UL, 0x2fb5c203UL, 0x86c57b9aUL, 0xd33708a5UL, 0x302887f2UL, 0x23bfa5b2UL, 0x02036abaUL, 0xed16825cUL, 0x8acf1c2bUL, 0xa779b492UL, 0xf307f2f0UL, 0x4e69e2a1UL, 0x65daf4cdUL, 0x0605bed5UL, 0xd134621fUL, 0xc4a6fe8aUL, 0x342e539dUL, 0xa2f355a0UL, 0x058ae132UL, 0xa4f6eb75UL, 0x0b83ec39UL, 0x4060efaaUL, 0x5e719f06UL, 0xbd6e1051UL, 0x3e218af9UL, 0x96dd063dUL, 0xdd3e05aeUL, 0x4de6bd46UL, 0x91548db5UL, 0x71c45d05UL, 0x0406d46fUL, 0x605015ffUL, 0x1998fb24UL, 0xd6bde997UL, 0x894043ccUL, 0x67d99e77UL, 0xb0e842bdUL, 0x07898b88UL, 0xe7195b38UL, 0x79c8eedbUL, 0xa17c0a47UL, 0x7c420fe9UL, 0xf8841ec9UL, 0x00000000UL, 0x09808683UL, 0x322bed48UL, 0x1e1170acUL, 0x6c5a724eUL, 0xfd0efffbUL, 0x0f853856UL, 0x3daed51eUL, 0x362d3927UL, 0x0a0fd964UL, 0x685ca621UL, 0x9b5b54d1UL, 0x24362e3aUL, 0x0c0a67b1UL, 0x9357e70fUL, 0xb4ee96d2UL, 0x1b9b919eUL, 0x80c0c54fUL, 0x61dc20a2UL, 0x5a774b69UL, 0x1c121a16UL, 0xe293ba0aUL, 0xc0a02ae5UL, 0x3c22e043UL, 0x121b171dUL, 0x0e090d0bUL, 0xf28bc7adUL, 0x2db6a8b9UL, 0x141ea9c8UL, 0x57f11985UL, 0xaf75074cUL, 0xee99ddbbUL, 0xa37f60fdUL, 0xf701269fUL, 0x5c72f5bcUL, 0x44663bc5UL, 0x5bfb7e34UL, 0x8b432976UL, 0xcb23c6dcUL, 0xb6edfc68UL, 0xb8e4f163UL, 0xd731dccaUL, 0x42638510UL, 0x13972240UL, 0x84c61120UL, 0x854a247dUL, 0xd2bb3df8UL, 0xaef93211UL, 0xc729a16dUL, 0x1d9e2f4bUL, 0xdcb230f3UL, 0x0d8652ecUL, 0x77c1e3d0UL, 0x2bb3166cUL, 0xa970b999UL, 0x119448faUL, 0x47e96422UL, 0xa8fc8cc4UL, 0xa0f03f1aUL, 0x567d2cd8UL, 0x223390efUL, 0x87494ec7UL, 0xd938d1c1UL, 0x8ccaa2feUL, 0x98d40b36UL, 0xa6f581cfUL, 0xa57ade28UL, 0xdab78e26UL, 0x3fadbfa4UL, 0x2c3a9de4UL, 0x5078920dUL, 0x6a5fcc9bUL, 0x547e4662UL, 0xf68d13c2UL, 0x90d8b8e8UL, 0x2e39f75eUL, 0x82c3aff5UL, 0x9f5d80beUL, 0x69d0937cUL, 0x6fd52da9UL, 0xcf2512b3UL, 0xc8ac993bUL, 0x10187da7UL, 0xe89c636eUL, 0xdb3bbb7bUL, 0xcd267809UL, 0x6e5918f4UL, 0xec9ab701UL, 0x834f9aa8UL, 0xe6956e65UL, 0xaaffe67eUL, 0x21bccf08UL, 0xef15e8e6UL, 0xbae79bd9UL, 0x4a6f36ceUL, 0xea9f09d4UL, 0x29b07cd6UL, 0x31a4b2afUL, 0x2a3f2331UL, 0xc6a59430UL, 0x35a266c0UL, 0x744ebc37UL, 0xfc82caa6UL, 0xe090d0b0UL, 0x33a7d815UL, 0xf104984aUL, 0x41ecdaf7UL, 0x7fcd500eUL, 0x1791f62fUL, 0x764dd68dUL, 0x43efb04dUL, 0xccaa4d54UL, 0xe49604dfUL, 0x9ed1b5e3UL, 0x4c6a881bUL, 0xc12c1fb8UL, 0x4665517fUL, 0x9d5eea04UL, 0x018c355dUL, 0xfa877473UL, 0xfb0b412eUL, 0xb3671d5aUL, 0x92dbd252UL, 0xe9105633UL, 0x6dd64713UL, 0x9ad7618cUL, 0x37a10c7aUL, 0x59f8148eUL, 0xeb133c89UL, 0xcea927eeUL, 0xb761c935UL, 0xe11ce5edUL, 0x7a47b13cUL, 0x9cd2df59UL, 0x55f2733fUL, 0x1814ce79UL, 0x73c737bfUL, 0x53f7cdeaUL, 0x5ffdaa5bUL, 0xdf3d6f14UL, 0x7844db86UL, 0xcaaff381UL, 0xb968c43eUL, 0x3824342cUL, 0xc2a3405fUL, 0x161dc372UL, 0xbce2250cUL, 0x283c498bUL, 0xff0d9541UL, 0x39a80171UL, 0x080cb3deUL, 0xd8b4e49cUL, 0x6456c190UL, 0x7bcb8461UL, 0xd532b670UL, 0x486c5c74UL, 0xd0b85742UL, }; static const ulong32 Td4[256] = { 0x52525252UL, 0x09090909UL, 0x6a6a6a6aUL, 0xd5d5d5d5UL, 0x30303030UL, 0x36363636UL, 0xa5a5a5a5UL, 0x38383838UL, 0xbfbfbfbfUL, 0x40404040UL, 0xa3a3a3a3UL, 0x9e9e9e9eUL, 0x81818181UL, 0xf3f3f3f3UL, 0xd7d7d7d7UL, 0xfbfbfbfbUL, 0x7c7c7c7cUL, 0xe3e3e3e3UL, 0x39393939UL, 0x82828282UL, 0x9b9b9b9bUL, 0x2f2f2f2fUL, 0xffffffffUL, 0x87878787UL, 0x34343434UL, 0x8e8e8e8eUL, 0x43434343UL, 0x44444444UL, 0xc4c4c4c4UL, 0xdedededeUL, 0xe9e9e9e9UL, 0xcbcbcbcbUL, 0x54545454UL, 0x7b7b7b7bUL, 0x94949494UL, 0x32323232UL, 0xa6a6a6a6UL, 0xc2c2c2c2UL, 0x23232323UL, 0x3d3d3d3dUL, 0xeeeeeeeeUL, 0x4c4c4c4cUL, 0x95959595UL, 0x0b0b0b0bUL, 0x42424242UL, 0xfafafafaUL, 0xc3c3c3c3UL, 0x4e4e4e4eUL, 0x08080808UL, 0x2e2e2e2eUL, 0xa1a1a1a1UL, 0x66666666UL, 0x28282828UL, 0xd9d9d9d9UL, 0x24242424UL, 0xb2b2b2b2UL, 0x76767676UL, 0x5b5b5b5bUL, 0xa2a2a2a2UL, 0x49494949UL, 0x6d6d6d6dUL, 0x8b8b8b8bUL, 0xd1d1d1d1UL, 0x25252525UL, 0x72727272UL, 0xf8f8f8f8UL, 0xf6f6f6f6UL, 0x64646464UL, 0x86868686UL, 0x68686868UL, 0x98989898UL, 0x16161616UL, 0xd4d4d4d4UL, 0xa4a4a4a4UL, 0x5c5c5c5cUL, 0xccccccccUL, 0x5d5d5d5dUL, 0x65656565UL, 0xb6b6b6b6UL, 0x92929292UL, 0x6c6c6c6cUL, 0x70707070UL, 0x48484848UL, 0x50505050UL, 0xfdfdfdfdUL, 0xededededUL, 0xb9b9b9b9UL, 0xdadadadaUL, 0x5e5e5e5eUL, 0x15151515UL, 0x46464646UL, 0x57575757UL, 0xa7a7a7a7UL, 0x8d8d8d8dUL, 0x9d9d9d9dUL, 0x84848484UL, 0x90909090UL, 0xd8d8d8d8UL, 0xababababUL, 0x00000000UL, 0x8c8c8c8cUL, 0xbcbcbcbcUL, 0xd3d3d3d3UL, 0x0a0a0a0aUL, 0xf7f7f7f7UL, 0xe4e4e4e4UL, 0x58585858UL, 0x05050505UL, 0xb8b8b8b8UL, 0xb3b3b3b3UL, 0x45454545UL, 0x06060606UL, 0xd0d0d0d0UL, 0x2c2c2c2cUL, 0x1e1e1e1eUL, 0x8f8f8f8fUL, 0xcacacacaUL, 0x3f3f3f3fUL, 0x0f0f0f0fUL, 0x02020202UL, 0xc1c1c1c1UL, 0xafafafafUL, 0xbdbdbdbdUL, 0x03030303UL, 0x01010101UL, 0x13131313UL, 0x8a8a8a8aUL, 0x6b6b6b6bUL, 0x3a3a3a3aUL, 0x91919191UL, 0x11111111UL, 0x41414141UL, 0x4f4f4f4fUL, 0x67676767UL, 0xdcdcdcdcUL, 0xeaeaeaeaUL, 0x97979797UL, 0xf2f2f2f2UL, 0xcfcfcfcfUL, 0xcecececeUL, 0xf0f0f0f0UL, 0xb4b4b4b4UL, 0xe6e6e6e6UL, 0x73737373UL, 0x96969696UL, 0xacacacacUL, 0x74747474UL, 0x22222222UL, 0xe7e7e7e7UL, 0xadadadadUL, 0x35353535UL, 0x85858585UL, 0xe2e2e2e2UL, 0xf9f9f9f9UL, 0x37373737UL, 0xe8e8e8e8UL, 0x1c1c1c1cUL, 0x75757575UL, 0xdfdfdfdfUL, 0x6e6e6e6eUL, 0x47474747UL, 0xf1f1f1f1UL, 0x1a1a1a1aUL, 0x71717171UL, 0x1d1d1d1dUL, 0x29292929UL, 0xc5c5c5c5UL, 0x89898989UL, 0x6f6f6f6fUL, 0xb7b7b7b7UL, 0x62626262UL, 0x0e0e0e0eUL, 0xaaaaaaaaUL, 0x18181818UL, 0xbebebebeUL, 0x1b1b1b1bUL, 0xfcfcfcfcUL, 0x56565656UL, 0x3e3e3e3eUL, 0x4b4b4b4bUL, 0xc6c6c6c6UL, 0xd2d2d2d2UL, 0x79797979UL, 0x20202020UL, 0x9a9a9a9aUL, 0xdbdbdbdbUL, 0xc0c0c0c0UL, 0xfefefefeUL, 0x78787878UL, 0xcdcdcdcdUL, 0x5a5a5a5aUL, 0xf4f4f4f4UL, 0x1f1f1f1fUL, 0xddddddddUL, 0xa8a8a8a8UL, 0x33333333UL, 0x88888888UL, 0x07070707UL, 0xc7c7c7c7UL, 0x31313131UL, 0xb1b1b1b1UL, 0x12121212UL, 0x10101010UL, 0x59595959UL, 0x27272727UL, 0x80808080UL, 0xececececUL, 0x5f5f5f5fUL, 0x60606060UL, 0x51515151UL, 0x7f7f7f7fUL, 0xa9a9a9a9UL, 0x19191919UL, 0xb5b5b5b5UL, 0x4a4a4a4aUL, 0x0d0d0d0dUL, 0x2d2d2d2dUL, 0xe5e5e5e5UL, 0x7a7a7a7aUL, 0x9f9f9f9fUL, 0x93939393UL, 0xc9c9c9c9UL, 0x9c9c9c9cUL, 0xefefefefUL, 0xa0a0a0a0UL, 0xe0e0e0e0UL, 0x3b3b3b3bUL, 0x4d4d4d4dUL, 0xaeaeaeaeUL, 0x2a2a2a2aUL, 0xf5f5f5f5UL, 0xb0b0b0b0UL, 0xc8c8c8c8UL, 0xebebebebUL, 0xbbbbbbbbUL, 0x3c3c3c3cUL, 0x83838383UL, 0x53535353UL, 0x99999999UL, 0x61616161UL, 0x17171717UL, 0x2b2b2b2bUL, 0x04040404UL, 0x7e7e7e7eUL, 0xbabababaUL, 0x77777777UL, 0xd6d6d6d6UL, 0x26262626UL, 0xe1e1e1e1UL, 0x69696969UL, 0x14141414UL, 0x63636363UL, 0x55555555UL, 0x21212121UL, 0x0c0c0c0cUL, 0x7d7d7d7dUL, }; #ifdef SMALL_CODE #define Te0(x) TE0[x] #define Te1(x) ROR(TE0[x], 8) #define Te2(x) ROR(TE0[x], 16) #define Te3(x) ROR(TE0[x], 24) #define Td0(x) TD0[x] #define Td1(x) ROR(TD0[x], 8) #define Td2(x) ROR(TD0[x], 16) #define Td3(x) ROR(TD0[x], 24) #define Te4_0 0x000000FF & Te4 #define Te4_1 0x0000FF00 & Te4 #define Te4_2 0x00FF0000 & Te4 #define Te4_3 0xFF000000 & Te4 #else #define Te0(x) TE0[x] #define Te1(x) TE1[x] #define Te2(x) TE2[x] #define Te3(x) TE3[x] #define Td0(x) TD0[x] #define Td1(x) TD1[x] #define Td2(x) TD2[x] #define Td3(x) TD3[x] static const ulong32 TE1[256] = { 0xa5c66363UL, 0x84f87c7cUL, 0x99ee7777UL, 0x8df67b7bUL, 0x0dfff2f2UL, 0xbdd66b6bUL, 0xb1de6f6fUL, 0x5491c5c5UL, 0x50603030UL, 0x03020101UL, 0xa9ce6767UL, 0x7d562b2bUL, 0x19e7fefeUL, 0x62b5d7d7UL, 0xe64dababUL, 0x9aec7676UL, 0x458fcacaUL, 0x9d1f8282UL, 0x4089c9c9UL, 0x87fa7d7dUL, 0x15effafaUL, 0xebb25959UL, 0xc98e4747UL, 0x0bfbf0f0UL, 0xec41adadUL, 0x67b3d4d4UL, 0xfd5fa2a2UL, 0xea45afafUL, 0xbf239c9cUL, 0xf753a4a4UL, 0x96e47272UL, 0x5b9bc0c0UL, 0xc275b7b7UL, 0x1ce1fdfdUL, 0xae3d9393UL, 0x6a4c2626UL, 0x5a6c3636UL, 0x417e3f3fUL, 0x02f5f7f7UL, 0x4f83ccccUL, 0x5c683434UL, 0xf451a5a5UL, 0x34d1e5e5UL, 0x08f9f1f1UL, 0x93e27171UL, 0x73abd8d8UL, 0x53623131UL, 0x3f2a1515UL, 0x0c080404UL, 0x5295c7c7UL, 0x65462323UL, 0x5e9dc3c3UL, 0x28301818UL, 0xa1379696UL, 0x0f0a0505UL, 0xb52f9a9aUL, 0x090e0707UL, 0x36241212UL, 0x9b1b8080UL, 0x3ddfe2e2UL, 0x26cdebebUL, 0x694e2727UL, 0xcd7fb2b2UL, 0x9fea7575UL, 0x1b120909UL, 0x9e1d8383UL, 0x74582c2cUL, 0x2e341a1aUL, 0x2d361b1bUL, 0xb2dc6e6eUL, 0xeeb45a5aUL, 0xfb5ba0a0UL, 0xf6a45252UL, 0x4d763b3bUL, 0x61b7d6d6UL, 0xce7db3b3UL, 0x7b522929UL, 0x3edde3e3UL, 0x715e2f2fUL, 0x97138484UL, 0xf5a65353UL, 0x68b9d1d1UL, 0x00000000UL, 0x2cc1ededUL, 0x60402020UL, 0x1fe3fcfcUL, 0xc879b1b1UL, 0xedb65b5bUL, 0xbed46a6aUL, 0x468dcbcbUL, 0xd967bebeUL, 0x4b723939UL, 0xde944a4aUL, 0xd4984c4cUL, 0xe8b05858UL, 0x4a85cfcfUL, 0x6bbbd0d0UL, 0x2ac5efefUL, 0xe54faaaaUL, 0x16edfbfbUL, 0xc5864343UL, 0xd79a4d4dUL, 0x55663333UL, 0x94118585UL, 0xcf8a4545UL, 0x10e9f9f9UL, 0x06040202UL, 0x81fe7f7fUL, 0xf0a05050UL, 0x44783c3cUL, 0xba259f9fUL, 0xe34ba8a8UL, 0xf3a25151UL, 0xfe5da3a3UL, 0xc0804040UL, 0x8a058f8fUL, 0xad3f9292UL, 0xbc219d9dUL, 0x48703838UL, 0x04f1f5f5UL, 0xdf63bcbcUL, 0xc177b6b6UL, 0x75afdadaUL, 0x63422121UL, 0x30201010UL, 0x1ae5ffffUL, 0x0efdf3f3UL, 0x6dbfd2d2UL, 0x4c81cdcdUL, 0x14180c0cUL, 0x35261313UL, 0x2fc3ececUL, 0xe1be5f5fUL, 0xa2359797UL, 0xcc884444UL, 0x392e1717UL, 0x5793c4c4UL, 0xf255a7a7UL, 0x82fc7e7eUL, 0x477a3d3dUL, 0xacc86464UL, 0xe7ba5d5dUL, 0x2b321919UL, 0x95e67373UL, 0xa0c06060UL, 0x98198181UL, 0xd19e4f4fUL, 0x7fa3dcdcUL, 0x66442222UL, 0x7e542a2aUL, 0xab3b9090UL, 0x830b8888UL, 0xca8c4646UL, 0x29c7eeeeUL, 0xd36bb8b8UL, 0x3c281414UL, 0x79a7dedeUL, 0xe2bc5e5eUL, 0x1d160b0bUL, 0x76addbdbUL, 0x3bdbe0e0UL, 0x56643232UL, 0x4e743a3aUL, 0x1e140a0aUL, 0xdb924949UL, 0x0a0c0606UL, 0x6c482424UL, 0xe4b85c5cUL, 0x5d9fc2c2UL, 0x6ebdd3d3UL, 0xef43acacUL, 0xa6c46262UL, 0xa8399191UL, 0xa4319595UL, 0x37d3e4e4UL, 0x8bf27979UL, 0x32d5e7e7UL, 0x438bc8c8UL, 0x596e3737UL, 0xb7da6d6dUL, 0x8c018d8dUL, 0x64b1d5d5UL, 0xd29c4e4eUL, 0xe049a9a9UL, 0xb4d86c6cUL, 0xfaac5656UL, 0x07f3f4f4UL, 0x25cfeaeaUL, 0xafca6565UL, 0x8ef47a7aUL, 0xe947aeaeUL, 0x18100808UL, 0xd56fbabaUL, 0x88f07878UL, 0x6f4a2525UL, 0x725c2e2eUL, 0x24381c1cUL, 0xf157a6a6UL, 0xc773b4b4UL, 0x5197c6c6UL, 0x23cbe8e8UL, 0x7ca1ddddUL, 0x9ce87474UL, 0x213e1f1fUL, 0xdd964b4bUL, 0xdc61bdbdUL, 0x860d8b8bUL, 0x850f8a8aUL, 0x90e07070UL, 0x427c3e3eUL, 0xc471b5b5UL, 0xaacc6666UL, 0xd8904848UL, 0x05060303UL, 0x01f7f6f6UL, 0x121c0e0eUL, 0xa3c26161UL, 0x5f6a3535UL, 0xf9ae5757UL, 0xd069b9b9UL, 0x91178686UL, 0x5899c1c1UL, 0x273a1d1dUL, 0xb9279e9eUL, 0x38d9e1e1UL, 0x13ebf8f8UL, 0xb32b9898UL, 0x33221111UL, 0xbbd26969UL, 0x70a9d9d9UL, 0x89078e8eUL, 0xa7339494UL, 0xb62d9b9bUL, 0x223c1e1eUL, 0x92158787UL, 0x20c9e9e9UL, 0x4987ceceUL, 0xffaa5555UL, 0x78502828UL, 0x7aa5dfdfUL, 0x8f038c8cUL, 0xf859a1a1UL, 0x80098989UL, 0x171a0d0dUL, 0xda65bfbfUL, 0x31d7e6e6UL, 0xc6844242UL, 0xb8d06868UL, 0xc3824141UL, 0xb0299999UL, 0x775a2d2dUL, 0x111e0f0fUL, 0xcb7bb0b0UL, 0xfca85454UL, 0xd66dbbbbUL, 0x3a2c1616UL, }; static const ulong32 TE2[256] = { 0x63a5c663UL, 0x7c84f87cUL, 0x7799ee77UL, 0x7b8df67bUL, 0xf20dfff2UL, 0x6bbdd66bUL, 0x6fb1de6fUL, 0xc55491c5UL, 0x30506030UL, 0x01030201UL, 0x67a9ce67UL, 0x2b7d562bUL, 0xfe19e7feUL, 0xd762b5d7UL, 0xabe64dabUL, 0x769aec76UL, 0xca458fcaUL, 0x829d1f82UL, 0xc94089c9UL, 0x7d87fa7dUL, 0xfa15effaUL, 0x59ebb259UL, 0x47c98e47UL, 0xf00bfbf0UL, 0xadec41adUL, 0xd467b3d4UL, 0xa2fd5fa2UL, 0xafea45afUL, 0x9cbf239cUL, 0xa4f753a4UL, 0x7296e472UL, 0xc05b9bc0UL, 0xb7c275b7UL, 0xfd1ce1fdUL, 0x93ae3d93UL, 0x266a4c26UL, 0x365a6c36UL, 0x3f417e3fUL, 0xf702f5f7UL, 0xcc4f83ccUL, 0x345c6834UL, 0xa5f451a5UL, 0xe534d1e5UL, 0xf108f9f1UL, 0x7193e271UL, 0xd873abd8UL, 0x31536231UL, 0x153f2a15UL, 0x040c0804UL, 0xc75295c7UL, 0x23654623UL, 0xc35e9dc3UL, 0x18283018UL, 0x96a13796UL, 0x050f0a05UL, 0x9ab52f9aUL, 0x07090e07UL, 0x12362412UL, 0x809b1b80UL, 0xe23ddfe2UL, 0xeb26cdebUL, 0x27694e27UL, 0xb2cd7fb2UL, 0x759fea75UL, 0x091b1209UL, 0x839e1d83UL, 0x2c74582cUL, 0x1a2e341aUL, 0x1b2d361bUL, 0x6eb2dc6eUL, 0x5aeeb45aUL, 0xa0fb5ba0UL, 0x52f6a452UL, 0x3b4d763bUL, 0xd661b7d6UL, 0xb3ce7db3UL, 0x297b5229UL, 0xe33edde3UL, 0x2f715e2fUL, 0x84971384UL, 0x53f5a653UL, 0xd168b9d1UL, 0x00000000UL, 0xed2cc1edUL, 0x20604020UL, 0xfc1fe3fcUL, 0xb1c879b1UL, 0x5bedb65bUL, 0x6abed46aUL, 0xcb468dcbUL, 0xbed967beUL, 0x394b7239UL, 0x4ade944aUL, 0x4cd4984cUL, 0x58e8b058UL, 0xcf4a85cfUL, 0xd06bbbd0UL, 0xef2ac5efUL, 0xaae54faaUL, 0xfb16edfbUL, 0x43c58643UL, 0x4dd79a4dUL, 0x33556633UL, 0x85941185UL, 0x45cf8a45UL, 0xf910e9f9UL, 0x02060402UL, 0x7f81fe7fUL, 0x50f0a050UL, 0x3c44783cUL, 0x9fba259fUL, 0xa8e34ba8UL, 0x51f3a251UL, 0xa3fe5da3UL, 0x40c08040UL, 0x8f8a058fUL, 0x92ad3f92UL, 0x9dbc219dUL, 0x38487038UL, 0xf504f1f5UL, 0xbcdf63bcUL, 0xb6c177b6UL, 0xda75afdaUL, 0x21634221UL, 0x10302010UL, 0xff1ae5ffUL, 0xf30efdf3UL, 0xd26dbfd2UL, 0xcd4c81cdUL, 0x0c14180cUL, 0x13352613UL, 0xec2fc3ecUL, 0x5fe1be5fUL, 0x97a23597UL, 0x44cc8844UL, 0x17392e17UL, 0xc45793c4UL, 0xa7f255a7UL, 0x7e82fc7eUL, 0x3d477a3dUL, 0x64acc864UL, 0x5de7ba5dUL, 0x192b3219UL, 0x7395e673UL, 0x60a0c060UL, 0x81981981UL, 0x4fd19e4fUL, 0xdc7fa3dcUL, 0x22664422UL, 0x2a7e542aUL, 0x90ab3b90UL, 0x88830b88UL, 0x46ca8c46UL, 0xee29c7eeUL, 0xb8d36bb8UL, 0x143c2814UL, 0xde79a7deUL, 0x5ee2bc5eUL, 0x0b1d160bUL, 0xdb76addbUL, 0xe03bdbe0UL, 0x32566432UL, 0x3a4e743aUL, 0x0a1e140aUL, 0x49db9249UL, 0x060a0c06UL, 0x246c4824UL, 0x5ce4b85cUL, 0xc25d9fc2UL, 0xd36ebdd3UL, 0xacef43acUL, 0x62a6c462UL, 0x91a83991UL, 0x95a43195UL, 0xe437d3e4UL, 0x798bf279UL, 0xe732d5e7UL, 0xc8438bc8UL, 0x37596e37UL, 0x6db7da6dUL, 0x8d8c018dUL, 0xd564b1d5UL, 0x4ed29c4eUL, 0xa9e049a9UL, 0x6cb4d86cUL, 0x56faac56UL, 0xf407f3f4UL, 0xea25cfeaUL, 0x65afca65UL, 0x7a8ef47aUL, 0xaee947aeUL, 0x08181008UL, 0xbad56fbaUL, 0x7888f078UL, 0x256f4a25UL, 0x2e725c2eUL, 0x1c24381cUL, 0xa6f157a6UL, 0xb4c773b4UL, 0xc65197c6UL, 0xe823cbe8UL, 0xdd7ca1ddUL, 0x749ce874UL, 0x1f213e1fUL, 0x4bdd964bUL, 0xbddc61bdUL, 0x8b860d8bUL, 0x8a850f8aUL, 0x7090e070UL, 0x3e427c3eUL, 0xb5c471b5UL, 0x66aacc66UL, 0x48d89048UL, 0x03050603UL, 0xf601f7f6UL, 0x0e121c0eUL, 0x61a3c261UL, 0x355f6a35UL, 0x57f9ae57UL, 0xb9d069b9UL, 0x86911786UL, 0xc15899c1UL, 0x1d273a1dUL, 0x9eb9279eUL, 0xe138d9e1UL, 0xf813ebf8UL, 0x98b32b98UL, 0x11332211UL, 0x69bbd269UL, 0xd970a9d9UL, 0x8e89078eUL, 0x94a73394UL, 0x9bb62d9bUL, 0x1e223c1eUL, 0x87921587UL, 0xe920c9e9UL, 0xce4987ceUL, 0x55ffaa55UL, 0x28785028UL, 0xdf7aa5dfUL, 0x8c8f038cUL, 0xa1f859a1UL, 0x89800989UL, 0x0d171a0dUL, 0xbfda65bfUL, 0xe631d7e6UL, 0x42c68442UL, 0x68b8d068UL, 0x41c38241UL, 0x99b02999UL, 0x2d775a2dUL, 0x0f111e0fUL, 0xb0cb7bb0UL, 0x54fca854UL, 0xbbd66dbbUL, 0x163a2c16UL, }; static const ulong32 TE3[256] = { 0x6363a5c6UL, 0x7c7c84f8UL, 0x777799eeUL, 0x7b7b8df6UL, 0xf2f20dffUL, 0x6b6bbdd6UL, 0x6f6fb1deUL, 0xc5c55491UL, 0x30305060UL, 0x01010302UL, 0x6767a9ceUL, 0x2b2b7d56UL, 0xfefe19e7UL, 0xd7d762b5UL, 0xababe64dUL, 0x76769aecUL, 0xcaca458fUL, 0x82829d1fUL, 0xc9c94089UL, 0x7d7d87faUL, 0xfafa15efUL, 0x5959ebb2UL, 0x4747c98eUL, 0xf0f00bfbUL, 0xadadec41UL, 0xd4d467b3UL, 0xa2a2fd5fUL, 0xafafea45UL, 0x9c9cbf23UL, 0xa4a4f753UL, 0x727296e4UL, 0xc0c05b9bUL, 0xb7b7c275UL, 0xfdfd1ce1UL, 0x9393ae3dUL, 0x26266a4cUL, 0x36365a6cUL, 0x3f3f417eUL, 0xf7f702f5UL, 0xcccc4f83UL, 0x34345c68UL, 0xa5a5f451UL, 0xe5e534d1UL, 0xf1f108f9UL, 0x717193e2UL, 0xd8d873abUL, 0x31315362UL, 0x15153f2aUL, 0x04040c08UL, 0xc7c75295UL, 0x23236546UL, 0xc3c35e9dUL, 0x18182830UL, 0x9696a137UL, 0x05050f0aUL, 0x9a9ab52fUL, 0x0707090eUL, 0x12123624UL, 0x80809b1bUL, 0xe2e23ddfUL, 0xebeb26cdUL, 0x2727694eUL, 0xb2b2cd7fUL, 0x75759feaUL, 0x09091b12UL, 0x83839e1dUL, 0x2c2c7458UL, 0x1a1a2e34UL, 0x1b1b2d36UL, 0x6e6eb2dcUL, 0x5a5aeeb4UL, 0xa0a0fb5bUL, 0x5252f6a4UL, 0x3b3b4d76UL, 0xd6d661b7UL, 0xb3b3ce7dUL, 0x29297b52UL, 0xe3e33eddUL, 0x2f2f715eUL, 0x84849713UL, 0x5353f5a6UL, 0xd1d168b9UL, 0x00000000UL, 0xeded2cc1UL, 0x20206040UL, 0xfcfc1fe3UL, 0xb1b1c879UL, 0x5b5bedb6UL, 0x6a6abed4UL, 0xcbcb468dUL, 0xbebed967UL, 0x39394b72UL, 0x4a4ade94UL, 0x4c4cd498UL, 0x5858e8b0UL, 0xcfcf4a85UL, 0xd0d06bbbUL, 0xefef2ac5UL, 0xaaaae54fUL, 0xfbfb16edUL, 0x4343c586UL, 0x4d4dd79aUL, 0x33335566UL, 0x85859411UL, 0x4545cf8aUL, 0xf9f910e9UL, 0x02020604UL, 0x7f7f81feUL, 0x5050f0a0UL, 0x3c3c4478UL, 0x9f9fba25UL, 0xa8a8e34bUL, 0x5151f3a2UL, 0xa3a3fe5dUL, 0x4040c080UL, 0x8f8f8a05UL, 0x9292ad3fUL, 0x9d9dbc21UL, 0x38384870UL, 0xf5f504f1UL, 0xbcbcdf63UL, 0xb6b6c177UL, 0xdada75afUL, 0x21216342UL, 0x10103020UL, 0xffff1ae5UL, 0xf3f30efdUL, 0xd2d26dbfUL, 0xcdcd4c81UL, 0x0c0c1418UL, 0x13133526UL, 0xecec2fc3UL, 0x5f5fe1beUL, 0x9797a235UL, 0x4444cc88UL, 0x1717392eUL, 0xc4c45793UL, 0xa7a7f255UL, 0x7e7e82fcUL, 0x3d3d477aUL, 0x6464acc8UL, 0x5d5de7baUL, 0x19192b32UL, 0x737395e6UL, 0x6060a0c0UL, 0x81819819UL, 0x4f4fd19eUL, 0xdcdc7fa3UL, 0x22226644UL, 0x2a2a7e54UL, 0x9090ab3bUL, 0x8888830bUL, 0x4646ca8cUL, 0xeeee29c7UL, 0xb8b8d36bUL, 0x14143c28UL, 0xdede79a7UL, 0x5e5ee2bcUL, 0x0b0b1d16UL, 0xdbdb76adUL, 0xe0e03bdbUL, 0x32325664UL, 0x3a3a4e74UL, 0x0a0a1e14UL, 0x4949db92UL, 0x06060a0cUL, 0x24246c48UL, 0x5c5ce4b8UL, 0xc2c25d9fUL, 0xd3d36ebdUL, 0xacacef43UL, 0x6262a6c4UL, 0x9191a839UL, 0x9595a431UL, 0xe4e437d3UL, 0x79798bf2UL, 0xe7e732d5UL, 0xc8c8438bUL, 0x3737596eUL, 0x6d6db7daUL, 0x8d8d8c01UL, 0xd5d564b1UL, 0x4e4ed29cUL, 0xa9a9e049UL, 0x6c6cb4d8UL, 0x5656faacUL, 0xf4f407f3UL, 0xeaea25cfUL, 0x6565afcaUL, 0x7a7a8ef4UL, 0xaeaee947UL, 0x08081810UL, 0xbabad56fUL, 0x787888f0UL, 0x25256f4aUL, 0x2e2e725cUL, 0x1c1c2438UL, 0xa6a6f157UL, 0xb4b4c773UL, 0xc6c65197UL, 0xe8e823cbUL, 0xdddd7ca1UL, 0x74749ce8UL, 0x1f1f213eUL, 0x4b4bdd96UL, 0xbdbddc61UL, 0x8b8b860dUL, 0x8a8a850fUL, 0x707090e0UL, 0x3e3e427cUL, 0xb5b5c471UL, 0x6666aaccUL, 0x4848d890UL, 0x03030506UL, 0xf6f601f7UL, 0x0e0e121cUL, 0x6161a3c2UL, 0x35355f6aUL, 0x5757f9aeUL, 0xb9b9d069UL, 0x86869117UL, 0xc1c15899UL, 0x1d1d273aUL, 0x9e9eb927UL, 0xe1e138d9UL, 0xf8f813ebUL, 0x9898b32bUL, 0x11113322UL, 0x6969bbd2UL, 0xd9d970a9UL, 0x8e8e8907UL, 0x9494a733UL, 0x9b9bb62dUL, 0x1e1e223cUL, 0x87879215UL, 0xe9e920c9UL, 0xcece4987UL, 0x5555ffaaUL, 0x28287850UL, 0xdfdf7aa5UL, 0x8c8c8f03UL, 0xa1a1f859UL, 0x89898009UL, 0x0d0d171aUL, 0xbfbfda65UL, 0xe6e631d7UL, 0x4242c684UL, 0x6868b8d0UL, 0x4141c382UL, 0x9999b029UL, 0x2d2d775aUL, 0x0f0f111eUL, 0xb0b0cb7bUL, 0x5454fca8UL, 0xbbbbd66dUL, 0x16163a2cUL, }; static const ulong32 Te4_0[] = { 0x00000063UL, 0x0000007cUL, 0x00000077UL, 0x0000007bUL, 0x000000f2UL, 0x0000006bUL, 0x0000006fUL, 0x000000c5UL, 0x00000030UL, 0x00000001UL, 0x00000067UL, 0x0000002bUL, 0x000000feUL, 0x000000d7UL, 0x000000abUL, 0x00000076UL, 0x000000caUL, 0x00000082UL, 0x000000c9UL, 0x0000007dUL, 0x000000faUL, 0x00000059UL, 0x00000047UL, 0x000000f0UL, 0x000000adUL, 0x000000d4UL, 0x000000a2UL, 0x000000afUL, 0x0000009cUL, 0x000000a4UL, 0x00000072UL, 0x000000c0UL, 0x000000b7UL, 0x000000fdUL, 0x00000093UL, 0x00000026UL, 0x00000036UL, 0x0000003fUL, 0x000000f7UL, 0x000000ccUL, 0x00000034UL, 0x000000a5UL, 0x000000e5UL, 0x000000f1UL, 0x00000071UL, 0x000000d8UL, 0x00000031UL, 0x00000015UL, 0x00000004UL, 0x000000c7UL, 0x00000023UL, 0x000000c3UL, 0x00000018UL, 0x00000096UL, 0x00000005UL, 0x0000009aUL, 0x00000007UL, 0x00000012UL, 0x00000080UL, 0x000000e2UL, 0x000000ebUL, 0x00000027UL, 0x000000b2UL, 0x00000075UL, 0x00000009UL, 0x00000083UL, 0x0000002cUL, 0x0000001aUL, 0x0000001bUL, 0x0000006eUL, 0x0000005aUL, 0x000000a0UL, 0x00000052UL, 0x0000003bUL, 0x000000d6UL, 0x000000b3UL, 0x00000029UL, 0x000000e3UL, 0x0000002fUL, 0x00000084UL, 0x00000053UL, 0x000000d1UL, 0x00000000UL, 0x000000edUL, 0x00000020UL, 0x000000fcUL, 0x000000b1UL, 0x0000005bUL, 0x0000006aUL, 0x000000cbUL, 0x000000beUL, 0x00000039UL, 0x0000004aUL, 0x0000004cUL, 0x00000058UL, 0x000000cfUL, 0x000000d0UL, 0x000000efUL, 0x000000aaUL, 0x000000fbUL, 0x00000043UL, 0x0000004dUL, 0x00000033UL, 0x00000085UL, 0x00000045UL, 0x000000f9UL, 0x00000002UL, 0x0000007fUL, 0x00000050UL, 0x0000003cUL, 0x0000009fUL, 0x000000a8UL, 0x00000051UL, 0x000000a3UL, 0x00000040UL, 0x0000008fUL, 0x00000092UL, 0x0000009dUL, 0x00000038UL, 0x000000f5UL, 0x000000bcUL, 0x000000b6UL, 0x000000daUL, 0x00000021UL, 0x00000010UL, 0x000000ffUL, 0x000000f3UL, 0x000000d2UL, 0x000000cdUL, 0x0000000cUL, 0x00000013UL, 0x000000ecUL, 0x0000005fUL, 0x00000097UL, 0x00000044UL, 0x00000017UL, 0x000000c4UL, 0x000000a7UL, 0x0000007eUL, 0x0000003dUL, 0x00000064UL, 0x0000005dUL, 0x00000019UL, 0x00000073UL, 0x00000060UL, 0x00000081UL, 0x0000004fUL, 0x000000dcUL, 0x00000022UL, 0x0000002aUL, 0x00000090UL, 0x00000088UL, 0x00000046UL, 0x000000eeUL, 0x000000b8UL, 0x00000014UL, 0x000000deUL, 0x0000005eUL, 0x0000000bUL, 0x000000dbUL, 0x000000e0UL, 0x00000032UL, 0x0000003aUL, 0x0000000aUL, 0x00000049UL, 0x00000006UL, 0x00000024UL, 0x0000005cUL, 0x000000c2UL, 0x000000d3UL, 0x000000acUL, 0x00000062UL, 0x00000091UL, 0x00000095UL, 0x000000e4UL, 0x00000079UL, 0x000000e7UL, 0x000000c8UL, 0x00000037UL, 0x0000006dUL, 0x0000008dUL, 0x000000d5UL, 0x0000004eUL, 0x000000a9UL, 0x0000006cUL, 0x00000056UL, 0x000000f4UL, 0x000000eaUL, 0x00000065UL, 0x0000007aUL, 0x000000aeUL, 0x00000008UL, 0x000000baUL, 0x00000078UL, 0x00000025UL, 0x0000002eUL, 0x0000001cUL, 0x000000a6UL, 0x000000b4UL, 0x000000c6UL, 0x000000e8UL, 0x000000ddUL, 0x00000074UL, 0x0000001fUL, 0x0000004bUL, 0x000000bdUL, 0x0000008bUL, 0x0000008aUL, 0x00000070UL, 0x0000003eUL, 0x000000b5UL, 0x00000066UL, 0x00000048UL, 0x00000003UL, 0x000000f6UL, 0x0000000eUL, 0x00000061UL, 0x00000035UL, 0x00000057UL, 0x000000b9UL, 0x00000086UL, 0x000000c1UL, 0x0000001dUL, 0x0000009eUL, 0x000000e1UL, 0x000000f8UL, 0x00000098UL, 0x00000011UL, 0x00000069UL, 0x000000d9UL, 0x0000008eUL, 0x00000094UL, 0x0000009bUL, 0x0000001eUL, 0x00000087UL, 0x000000e9UL, 0x000000ceUL, 0x00000055UL, 0x00000028UL, 0x000000dfUL, 0x0000008cUL, 0x000000a1UL, 0x00000089UL, 0x0000000dUL, 0x000000bfUL, 0x000000e6UL, 0x00000042UL, 0x00000068UL, 0x00000041UL, 0x00000099UL, 0x0000002dUL, 0x0000000fUL, 0x000000b0UL, 0x00000054UL, 0x000000bbUL, 0x00000016UL }; static const ulong32 Te4_1[] = { 0x00006300UL, 0x00007c00UL, 0x00007700UL, 0x00007b00UL, 0x0000f200UL, 0x00006b00UL, 0x00006f00UL, 0x0000c500UL, 0x00003000UL, 0x00000100UL, 0x00006700UL, 0x00002b00UL, 0x0000fe00UL, 0x0000d700UL, 0x0000ab00UL, 0x00007600UL, 0x0000ca00UL, 0x00008200UL, 0x0000c900UL, 0x00007d00UL, 0x0000fa00UL, 0x00005900UL, 0x00004700UL, 0x0000f000UL, 0x0000ad00UL, 0x0000d400UL, 0x0000a200UL, 0x0000af00UL, 0x00009c00UL, 0x0000a400UL, 0x00007200UL, 0x0000c000UL, 0x0000b700UL, 0x0000fd00UL, 0x00009300UL, 0x00002600UL, 0x00003600UL, 0x00003f00UL, 0x0000f700UL, 0x0000cc00UL, 0x00003400UL, 0x0000a500UL, 0x0000e500UL, 0x0000f100UL, 0x00007100UL, 0x0000d800UL, 0x00003100UL, 0x00001500UL, 0x00000400UL, 0x0000c700UL, 0x00002300UL, 0x0000c300UL, 0x00001800UL, 0x00009600UL, 0x00000500UL, 0x00009a00UL, 0x00000700UL, 0x00001200UL, 0x00008000UL, 0x0000e200UL, 0x0000eb00UL, 0x00002700UL, 0x0000b200UL, 0x00007500UL, 0x00000900UL, 0x00008300UL, 0x00002c00UL, 0x00001a00UL, 0x00001b00UL, 0x00006e00UL, 0x00005a00UL, 0x0000a000UL, 0x00005200UL, 0x00003b00UL, 0x0000d600UL, 0x0000b300UL, 0x00002900UL, 0x0000e300UL, 0x00002f00UL, 0x00008400UL, 0x00005300UL, 0x0000d100UL, 0x00000000UL, 0x0000ed00UL, 0x00002000UL, 0x0000fc00UL, 0x0000b100UL, 0x00005b00UL, 0x00006a00UL, 0x0000cb00UL, 0x0000be00UL, 0x00003900UL, 0x00004a00UL, 0x00004c00UL, 0x00005800UL, 0x0000cf00UL, 0x0000d000UL, 0x0000ef00UL, 0x0000aa00UL, 0x0000fb00UL, 0x00004300UL, 0x00004d00UL, 0x00003300UL, 0x00008500UL, 0x00004500UL, 0x0000f900UL, 0x00000200UL, 0x00007f00UL, 0x00005000UL, 0x00003c00UL, 0x00009f00UL, 0x0000a800UL, 0x00005100UL, 0x0000a300UL, 0x00004000UL, 0x00008f00UL, 0x00009200UL, 0x00009d00UL, 0x00003800UL, 0x0000f500UL, 0x0000bc00UL, 0x0000b600UL, 0x0000da00UL, 0x00002100UL, 0x00001000UL, 0x0000ff00UL, 0x0000f300UL, 0x0000d200UL, 0x0000cd00UL, 0x00000c00UL, 0x00001300UL, 0x0000ec00UL, 0x00005f00UL, 0x00009700UL, 0x00004400UL, 0x00001700UL, 0x0000c400UL, 0x0000a700UL, 0x00007e00UL, 0x00003d00UL, 0x00006400UL, 0x00005d00UL, 0x00001900UL, 0x00007300UL, 0x00006000UL, 0x00008100UL, 0x00004f00UL, 0x0000dc00UL, 0x00002200UL, 0x00002a00UL, 0x00009000UL, 0x00008800UL, 0x00004600UL, 0x0000ee00UL, 0x0000b800UL, 0x00001400UL, 0x0000de00UL, 0x00005e00UL, 0x00000b00UL, 0x0000db00UL, 0x0000e000UL, 0x00003200UL, 0x00003a00UL, 0x00000a00UL, 0x00004900UL, 0x00000600UL, 0x00002400UL, 0x00005c00UL, 0x0000c200UL, 0x0000d300UL, 0x0000ac00UL, 0x00006200UL, 0x00009100UL, 0x00009500UL, 0x0000e400UL, 0x00007900UL, 0x0000e700UL, 0x0000c800UL, 0x00003700UL, 0x00006d00UL, 0x00008d00UL, 0x0000d500UL, 0x00004e00UL, 0x0000a900UL, 0x00006c00UL, 0x00005600UL, 0x0000f400UL, 0x0000ea00UL, 0x00006500UL, 0x00007a00UL, 0x0000ae00UL, 0x00000800UL, 0x0000ba00UL, 0x00007800UL, 0x00002500UL, 0x00002e00UL, 0x00001c00UL, 0x0000a600UL, 0x0000b400UL, 0x0000c600UL, 0x0000e800UL, 0x0000dd00UL, 0x00007400UL, 0x00001f00UL, 0x00004b00UL, 0x0000bd00UL, 0x00008b00UL, 0x00008a00UL, 0x00007000UL, 0x00003e00UL, 0x0000b500UL, 0x00006600UL, 0x00004800UL, 0x00000300UL, 0x0000f600UL, 0x00000e00UL, 0x00006100UL, 0x00003500UL, 0x00005700UL, 0x0000b900UL, 0x00008600UL, 0x0000c100UL, 0x00001d00UL, 0x00009e00UL, 0x0000e100UL, 0x0000f800UL, 0x00009800UL, 0x00001100UL, 0x00006900UL, 0x0000d900UL, 0x00008e00UL, 0x00009400UL, 0x00009b00UL, 0x00001e00UL, 0x00008700UL, 0x0000e900UL, 0x0000ce00UL, 0x00005500UL, 0x00002800UL, 0x0000df00UL, 0x00008c00UL, 0x0000a100UL, 0x00008900UL, 0x00000d00UL, 0x0000bf00UL, 0x0000e600UL, 0x00004200UL, 0x00006800UL, 0x00004100UL, 0x00009900UL, 0x00002d00UL, 0x00000f00UL, 0x0000b000UL, 0x00005400UL, 0x0000bb00UL, 0x00001600UL }; static const ulong32 Te4_2[] = { 0x00630000UL, 0x007c0000UL, 0x00770000UL, 0x007b0000UL, 0x00f20000UL, 0x006b0000UL, 0x006f0000UL, 0x00c50000UL, 0x00300000UL, 0x00010000UL, 0x00670000UL, 0x002b0000UL, 0x00fe0000UL, 0x00d70000UL, 0x00ab0000UL, 0x00760000UL, 0x00ca0000UL, 0x00820000UL, 0x00c90000UL, 0x007d0000UL, 0x00fa0000UL, 0x00590000UL, 0x00470000UL, 0x00f00000UL, 0x00ad0000UL, 0x00d40000UL, 0x00a20000UL, 0x00af0000UL, 0x009c0000UL, 0x00a40000UL, 0x00720000UL, 0x00c00000UL, 0x00b70000UL, 0x00fd0000UL, 0x00930000UL, 0x00260000UL, 0x00360000UL, 0x003f0000UL, 0x00f70000UL, 0x00cc0000UL, 0x00340000UL, 0x00a50000UL, 0x00e50000UL, 0x00f10000UL, 0x00710000UL, 0x00d80000UL, 0x00310000UL, 0x00150000UL, 0x00040000UL, 0x00c70000UL, 0x00230000UL, 0x00c30000UL, 0x00180000UL, 0x00960000UL, 0x00050000UL, 0x009a0000UL, 0x00070000UL, 0x00120000UL, 0x00800000UL, 0x00e20000UL, 0x00eb0000UL, 0x00270000UL, 0x00b20000UL, 0x00750000UL, 0x00090000UL, 0x00830000UL, 0x002c0000UL, 0x001a0000UL, 0x001b0000UL, 0x006e0000UL, 0x005a0000UL, 0x00a00000UL, 0x00520000UL, 0x003b0000UL, 0x00d60000UL, 0x00b30000UL, 0x00290000UL, 0x00e30000UL, 0x002f0000UL, 0x00840000UL, 0x00530000UL, 0x00d10000UL, 0x00000000UL, 0x00ed0000UL, 0x00200000UL, 0x00fc0000UL, 0x00b10000UL, 0x005b0000UL, 0x006a0000UL, 0x00cb0000UL, 0x00be0000UL, 0x00390000UL, 0x004a0000UL, 0x004c0000UL, 0x00580000UL, 0x00cf0000UL, 0x00d00000UL, 0x00ef0000UL, 0x00aa0000UL, 0x00fb0000UL, 0x00430000UL, 0x004d0000UL, 0x00330000UL, 0x00850000UL, 0x00450000UL, 0x00f90000UL, 0x00020000UL, 0x007f0000UL, 0x00500000UL, 0x003c0000UL, 0x009f0000UL, 0x00a80000UL, 0x00510000UL, 0x00a30000UL, 0x00400000UL, 0x008f0000UL, 0x00920000UL, 0x009d0000UL, 0x00380000UL, 0x00f50000UL, 0x00bc0000UL, 0x00b60000UL, 0x00da0000UL, 0x00210000UL, 0x00100000UL, 0x00ff0000UL, 0x00f30000UL, 0x00d20000UL, 0x00cd0000UL, 0x000c0000UL, 0x00130000UL, 0x00ec0000UL, 0x005f0000UL, 0x00970000UL, 0x00440000UL, 0x00170000UL, 0x00c40000UL, 0x00a70000UL, 0x007e0000UL, 0x003d0000UL, 0x00640000UL, 0x005d0000UL, 0x00190000UL, 0x00730000UL, 0x00600000UL, 0x00810000UL, 0x004f0000UL, 0x00dc0000UL, 0x00220000UL, 0x002a0000UL, 0x00900000UL, 0x00880000UL, 0x00460000UL, 0x00ee0000UL, 0x00b80000UL, 0x00140000UL, 0x00de0000UL, 0x005e0000UL, 0x000b0000UL, 0x00db0000UL, 0x00e00000UL, 0x00320000UL, 0x003a0000UL, 0x000a0000UL, 0x00490000UL, 0x00060000UL, 0x00240000UL, 0x005c0000UL, 0x00c20000UL, 0x00d30000UL, 0x00ac0000UL, 0x00620000UL, 0x00910000UL, 0x00950000UL, 0x00e40000UL, 0x00790000UL, 0x00e70000UL, 0x00c80000UL, 0x00370000UL, 0x006d0000UL, 0x008d0000UL, 0x00d50000UL, 0x004e0000UL, 0x00a90000UL, 0x006c0000UL, 0x00560000UL, 0x00f40000UL, 0x00ea0000UL, 0x00650000UL, 0x007a0000UL, 0x00ae0000UL, 0x00080000UL, 0x00ba0000UL, 0x00780000UL, 0x00250000UL, 0x002e0000UL, 0x001c0000UL, 0x00a60000UL, 0x00b40000UL, 0x00c60000UL, 0x00e80000UL, 0x00dd0000UL, 0x00740000UL, 0x001f0000UL, 0x004b0000UL, 0x00bd0000UL, 0x008b0000UL, 0x008a0000UL, 0x00700000UL, 0x003e0000UL, 0x00b50000UL, 0x00660000UL, 0x00480000UL, 0x00030000UL, 0x00f60000UL, 0x000e0000UL, 0x00610000UL, 0x00350000UL, 0x00570000UL, 0x00b90000UL, 0x00860000UL, 0x00c10000UL, 0x001d0000UL, 0x009e0000UL, 0x00e10000UL, 0x00f80000UL, 0x00980000UL, 0x00110000UL, 0x00690000UL, 0x00d90000UL, 0x008e0000UL, 0x00940000UL, 0x009b0000UL, 0x001e0000UL, 0x00870000UL, 0x00e90000UL, 0x00ce0000UL, 0x00550000UL, 0x00280000UL, 0x00df0000UL, 0x008c0000UL, 0x00a10000UL, 0x00890000UL, 0x000d0000UL, 0x00bf0000UL, 0x00e60000UL, 0x00420000UL, 0x00680000UL, 0x00410000UL, 0x00990000UL, 0x002d0000UL, 0x000f0000UL, 0x00b00000UL, 0x00540000UL, 0x00bb0000UL, 0x00160000UL }; static const ulong32 Te4_3[] = { 0x63000000UL, 0x7c000000UL, 0x77000000UL, 0x7b000000UL, 0xf2000000UL, 0x6b000000UL, 0x6f000000UL, 0xc5000000UL, 0x30000000UL, 0x01000000UL, 0x67000000UL, 0x2b000000UL, 0xfe000000UL, 0xd7000000UL, 0xab000000UL, 0x76000000UL, 0xca000000UL, 0x82000000UL, 0xc9000000UL, 0x7d000000UL, 0xfa000000UL, 0x59000000UL, 0x47000000UL, 0xf0000000UL, 0xad000000UL, 0xd4000000UL, 0xa2000000UL, 0xaf000000UL, 0x9c000000UL, 0xa4000000UL, 0x72000000UL, 0xc0000000UL, 0xb7000000UL, 0xfd000000UL, 0x93000000UL, 0x26000000UL, 0x36000000UL, 0x3f000000UL, 0xf7000000UL, 0xcc000000UL, 0x34000000UL, 0xa5000000UL, 0xe5000000UL, 0xf1000000UL, 0x71000000UL, 0xd8000000UL, 0x31000000UL, 0x15000000UL, 0x04000000UL, 0xc7000000UL, 0x23000000UL, 0xc3000000UL, 0x18000000UL, 0x96000000UL, 0x05000000UL, 0x9a000000UL, 0x07000000UL, 0x12000000UL, 0x80000000UL, 0xe2000000UL, 0xeb000000UL, 0x27000000UL, 0xb2000000UL, 0x75000000UL, 0x09000000UL, 0x83000000UL, 0x2c000000UL, 0x1a000000UL, 0x1b000000UL, 0x6e000000UL, 0x5a000000UL, 0xa0000000UL, 0x52000000UL, 0x3b000000UL, 0xd6000000UL, 0xb3000000UL, 0x29000000UL, 0xe3000000UL, 0x2f000000UL, 0x84000000UL, 0x53000000UL, 0xd1000000UL, 0x00000000UL, 0xed000000UL, 0x20000000UL, 0xfc000000UL, 0xb1000000UL, 0x5b000000UL, 0x6a000000UL, 0xcb000000UL, 0xbe000000UL, 0x39000000UL, 0x4a000000UL, 0x4c000000UL, 0x58000000UL, 0xcf000000UL, 0xd0000000UL, 0xef000000UL, 0xaa000000UL, 0xfb000000UL, 0x43000000UL, 0x4d000000UL, 0x33000000UL, 0x85000000UL, 0x45000000UL, 0xf9000000UL, 0x02000000UL, 0x7f000000UL, 0x50000000UL, 0x3c000000UL, 0x9f000000UL, 0xa8000000UL, 0x51000000UL, 0xa3000000UL, 0x40000000UL, 0x8f000000UL, 0x92000000UL, 0x9d000000UL, 0x38000000UL, 0xf5000000UL, 0xbc000000UL, 0xb6000000UL, 0xda000000UL, 0x21000000UL, 0x10000000UL, 0xff000000UL, 0xf3000000UL, 0xd2000000UL, 0xcd000000UL, 0x0c000000UL, 0x13000000UL, 0xec000000UL, 0x5f000000UL, 0x97000000UL, 0x44000000UL, 0x17000000UL, 0xc4000000UL, 0xa7000000UL, 0x7e000000UL, 0x3d000000UL, 0x64000000UL, 0x5d000000UL, 0x19000000UL, 0x73000000UL, 0x60000000UL, 0x81000000UL, 0x4f000000UL, 0xdc000000UL, 0x22000000UL, 0x2a000000UL, 0x90000000UL, 0x88000000UL, 0x46000000UL, 0xee000000UL, 0xb8000000UL, 0x14000000UL, 0xde000000UL, 0x5e000000UL, 0x0b000000UL, 0xdb000000UL, 0xe0000000UL, 0x32000000UL, 0x3a000000UL, 0x0a000000UL, 0x49000000UL, 0x06000000UL, 0x24000000UL, 0x5c000000UL, 0xc2000000UL, 0xd3000000UL, 0xac000000UL, 0x62000000UL, 0x91000000UL, 0x95000000UL, 0xe4000000UL, 0x79000000UL, 0xe7000000UL, 0xc8000000UL, 0x37000000UL, 0x6d000000UL, 0x8d000000UL, 0xd5000000UL, 0x4e000000UL, 0xa9000000UL, 0x6c000000UL, 0x56000000UL, 0xf4000000UL, 0xea000000UL, 0x65000000UL, 0x7a000000UL, 0xae000000UL, 0x08000000UL, 0xba000000UL, 0x78000000UL, 0x25000000UL, 0x2e000000UL, 0x1c000000UL, 0xa6000000UL, 0xb4000000UL, 0xc6000000UL, 0xe8000000UL, 0xdd000000UL, 0x74000000UL, 0x1f000000UL, 0x4b000000UL, 0xbd000000UL, 0x8b000000UL, 0x8a000000UL, 0x70000000UL, 0x3e000000UL, 0xb5000000UL, 0x66000000UL, 0x48000000UL, 0x03000000UL, 0xf6000000UL, 0x0e000000UL, 0x61000000UL, 0x35000000UL, 0x57000000UL, 0xb9000000UL, 0x86000000UL, 0xc1000000UL, 0x1d000000UL, 0x9e000000UL, 0xe1000000UL, 0xf8000000UL, 0x98000000UL, 0x11000000UL, 0x69000000UL, 0xd9000000UL, 0x8e000000UL, 0x94000000UL, 0x9b000000UL, 0x1e000000UL, 0x87000000UL, 0xe9000000UL, 0xce000000UL, 0x55000000UL, 0x28000000UL, 0xdf000000UL, 0x8c000000UL, 0xa1000000UL, 0x89000000UL, 0x0d000000UL, 0xbf000000UL, 0xe6000000UL, 0x42000000UL, 0x68000000UL, 0x41000000UL, 0x99000000UL, 0x2d000000UL, 0x0f000000UL, 0xb0000000UL, 0x54000000UL, 0xbb000000UL, 0x16000000UL }; static const ulong32 TD1[256] = { 0x5051f4a7UL, 0x537e4165UL, 0xc31a17a4UL, 0x963a275eUL, 0xcb3bab6bUL, 0xf11f9d45UL, 0xabacfa58UL, 0x934be303UL, 0x552030faUL, 0xf6ad766dUL, 0x9188cc76UL, 0x25f5024cUL, 0xfc4fe5d7UL, 0xd7c52acbUL, 0x80263544UL, 0x8fb562a3UL, 0x49deb15aUL, 0x6725ba1bUL, 0x9845ea0eUL, 0xe15dfec0UL, 0x02c32f75UL, 0x12814cf0UL, 0xa38d4697UL, 0xc66bd3f9UL, 0xe7038f5fUL, 0x9515929cUL, 0xebbf6d7aUL, 0xda955259UL, 0x2dd4be83UL, 0xd3587421UL, 0x2949e069UL, 0x448ec9c8UL, 0x6a75c289UL, 0x78f48e79UL, 0x6b99583eUL, 0xdd27b971UL, 0xb6bee14fUL, 0x17f088adUL, 0x66c920acUL, 0xb47dce3aUL, 0x1863df4aUL, 0x82e51a31UL, 0x60975133UL, 0x4562537fUL, 0xe0b16477UL, 0x84bb6baeUL, 0x1cfe81a0UL, 0x94f9082bUL, 0x58704868UL, 0x198f45fdUL, 0x8794de6cUL, 0xb7527bf8UL, 0x23ab73d3UL, 0xe2724b02UL, 0x57e31f8fUL, 0x2a6655abUL, 0x07b2eb28UL, 0x032fb5c2UL, 0x9a86c57bUL, 0xa5d33708UL, 0xf2302887UL, 0xb223bfa5UL, 0xba02036aUL, 0x5ced1682UL, 0x2b8acf1cUL, 0x92a779b4UL, 0xf0f307f2UL, 0xa14e69e2UL, 0xcd65daf4UL, 0xd50605beUL, 0x1fd13462UL, 0x8ac4a6feUL, 0x9d342e53UL, 0xa0a2f355UL, 0x32058ae1UL, 0x75a4f6ebUL, 0x390b83ecUL, 0xaa4060efUL, 0x065e719fUL, 0x51bd6e10UL, 0xf93e218aUL, 0x3d96dd06UL, 0xaedd3e05UL, 0x464de6bdUL, 0xb591548dUL, 0x0571c45dUL, 0x6f0406d4UL, 0xff605015UL, 0x241998fbUL, 0x97d6bde9UL, 0xcc894043UL, 0x7767d99eUL, 0xbdb0e842UL, 0x8807898bUL, 0x38e7195bUL, 0xdb79c8eeUL, 0x47a17c0aUL, 0xe97c420fUL, 0xc9f8841eUL, 0x00000000UL, 0x83098086UL, 0x48322bedUL, 0xac1e1170UL, 0x4e6c5a72UL, 0xfbfd0effUL, 0x560f8538UL, 0x1e3daed5UL, 0x27362d39UL, 0x640a0fd9UL, 0x21685ca6UL, 0xd19b5b54UL, 0x3a24362eUL, 0xb10c0a67UL, 0x0f9357e7UL, 0xd2b4ee96UL, 0x9e1b9b91UL, 0x4f80c0c5UL, 0xa261dc20UL, 0x695a774bUL, 0x161c121aUL, 0x0ae293baUL, 0xe5c0a02aUL, 0x433c22e0UL, 0x1d121b17UL, 0x0b0e090dUL, 0xadf28bc7UL, 0xb92db6a8UL, 0xc8141ea9UL, 0x8557f119UL, 0x4caf7507UL, 0xbbee99ddUL, 0xfda37f60UL, 0x9ff70126UL, 0xbc5c72f5UL, 0xc544663bUL, 0x345bfb7eUL, 0x768b4329UL, 0xdccb23c6UL, 0x68b6edfcUL, 0x63b8e4f1UL, 0xcad731dcUL, 0x10426385UL, 0x40139722UL, 0x2084c611UL, 0x7d854a24UL, 0xf8d2bb3dUL, 0x11aef932UL, 0x6dc729a1UL, 0x4b1d9e2fUL, 0xf3dcb230UL, 0xec0d8652UL, 0xd077c1e3UL, 0x6c2bb316UL, 0x99a970b9UL, 0xfa119448UL, 0x2247e964UL, 0xc4a8fc8cUL, 0x1aa0f03fUL, 0xd8567d2cUL, 0xef223390UL, 0xc787494eUL, 0xc1d938d1UL, 0xfe8ccaa2UL, 0x3698d40bUL, 0xcfa6f581UL, 0x28a57adeUL, 0x26dab78eUL, 0xa43fadbfUL, 0xe42c3a9dUL, 0x0d507892UL, 0x9b6a5fccUL, 0x62547e46UL, 0xc2f68d13UL, 0xe890d8b8UL, 0x5e2e39f7UL, 0xf582c3afUL, 0xbe9f5d80UL, 0x7c69d093UL, 0xa96fd52dUL, 0xb3cf2512UL, 0x3bc8ac99UL, 0xa710187dUL, 0x6ee89c63UL, 0x7bdb3bbbUL, 0x09cd2678UL, 0xf46e5918UL, 0x01ec9ab7UL, 0xa8834f9aUL, 0x65e6956eUL, 0x7eaaffe6UL, 0x0821bccfUL, 0xe6ef15e8UL, 0xd9bae79bUL, 0xce4a6f36UL, 0xd4ea9f09UL, 0xd629b07cUL, 0xaf31a4b2UL, 0x312a3f23UL, 0x30c6a594UL, 0xc035a266UL, 0x37744ebcUL, 0xa6fc82caUL, 0xb0e090d0UL, 0x1533a7d8UL, 0x4af10498UL, 0xf741ecdaUL, 0x0e7fcd50UL, 0x2f1791f6UL, 0x8d764dd6UL, 0x4d43efb0UL, 0x54ccaa4dUL, 0xdfe49604UL, 0xe39ed1b5UL, 0x1b4c6a88UL, 0xb8c12c1fUL, 0x7f466551UL, 0x049d5eeaUL, 0x5d018c35UL, 0x73fa8774UL, 0x2efb0b41UL, 0x5ab3671dUL, 0x5292dbd2UL, 0x33e91056UL, 0x136dd647UL, 0x8c9ad761UL, 0x7a37a10cUL, 0x8e59f814UL, 0x89eb133cUL, 0xeecea927UL, 0x35b761c9UL, 0xede11ce5UL, 0x3c7a47b1UL, 0x599cd2dfUL, 0x3f55f273UL, 0x791814ceUL, 0xbf73c737UL, 0xea53f7cdUL, 0x5b5ffdaaUL, 0x14df3d6fUL, 0x867844dbUL, 0x81caaff3UL, 0x3eb968c4UL, 0x2c382434UL, 0x5fc2a340UL, 0x72161dc3UL, 0x0cbce225UL, 0x8b283c49UL, 0x41ff0d95UL, 0x7139a801UL, 0xde080cb3UL, 0x9cd8b4e4UL, 0x906456c1UL, 0x617bcb84UL, 0x70d532b6UL, 0x74486c5cUL, 0x42d0b857UL, }; static const ulong32 TD2[256] = { 0xa75051f4UL, 0x65537e41UL, 0xa4c31a17UL, 0x5e963a27UL, 0x6bcb3babUL, 0x45f11f9dUL, 0x58abacfaUL, 0x03934be3UL, 0xfa552030UL, 0x6df6ad76UL, 0x769188ccUL, 0x4c25f502UL, 0xd7fc4fe5UL, 0xcbd7c52aUL, 0x44802635UL, 0xa38fb562UL, 0x5a49deb1UL, 0x1b6725baUL, 0x0e9845eaUL, 0xc0e15dfeUL, 0x7502c32fUL, 0xf012814cUL, 0x97a38d46UL, 0xf9c66bd3UL, 0x5fe7038fUL, 0x9c951592UL, 0x7aebbf6dUL, 0x59da9552UL, 0x832dd4beUL, 0x21d35874UL, 0x692949e0UL, 0xc8448ec9UL, 0x896a75c2UL, 0x7978f48eUL, 0x3e6b9958UL, 0x71dd27b9UL, 0x4fb6bee1UL, 0xad17f088UL, 0xac66c920UL, 0x3ab47dceUL, 0x4a1863dfUL, 0x3182e51aUL, 0x33609751UL, 0x7f456253UL, 0x77e0b164UL, 0xae84bb6bUL, 0xa01cfe81UL, 0x2b94f908UL, 0x68587048UL, 0xfd198f45UL, 0x6c8794deUL, 0xf8b7527bUL, 0xd323ab73UL, 0x02e2724bUL, 0x8f57e31fUL, 0xab2a6655UL, 0x2807b2ebUL, 0xc2032fb5UL, 0x7b9a86c5UL, 0x08a5d337UL, 0x87f23028UL, 0xa5b223bfUL, 0x6aba0203UL, 0x825ced16UL, 0x1c2b8acfUL, 0xb492a779UL, 0xf2f0f307UL, 0xe2a14e69UL, 0xf4cd65daUL, 0xbed50605UL, 0x621fd134UL, 0xfe8ac4a6UL, 0x539d342eUL, 0x55a0a2f3UL, 0xe132058aUL, 0xeb75a4f6UL, 0xec390b83UL, 0xefaa4060UL, 0x9f065e71UL, 0x1051bd6eUL, 0x8af93e21UL, 0x063d96ddUL, 0x05aedd3eUL, 0xbd464de6UL, 0x8db59154UL, 0x5d0571c4UL, 0xd46f0406UL, 0x15ff6050UL, 0xfb241998UL, 0xe997d6bdUL, 0x43cc8940UL, 0x9e7767d9UL, 0x42bdb0e8UL, 0x8b880789UL, 0x5b38e719UL, 0xeedb79c8UL, 0x0a47a17cUL, 0x0fe97c42UL, 0x1ec9f884UL, 0x00000000UL, 0x86830980UL, 0xed48322bUL, 0x70ac1e11UL, 0x724e6c5aUL, 0xfffbfd0eUL, 0x38560f85UL, 0xd51e3daeUL, 0x3927362dUL, 0xd9640a0fUL, 0xa621685cUL, 0x54d19b5bUL, 0x2e3a2436UL, 0x67b10c0aUL, 0xe70f9357UL, 0x96d2b4eeUL, 0x919e1b9bUL, 0xc54f80c0UL, 0x20a261dcUL, 0x4b695a77UL, 0x1a161c12UL, 0xba0ae293UL, 0x2ae5c0a0UL, 0xe0433c22UL, 0x171d121bUL, 0x0d0b0e09UL, 0xc7adf28bUL, 0xa8b92db6UL, 0xa9c8141eUL, 0x198557f1UL, 0x074caf75UL, 0xddbbee99UL, 0x60fda37fUL, 0x269ff701UL, 0xf5bc5c72UL, 0x3bc54466UL, 0x7e345bfbUL, 0x29768b43UL, 0xc6dccb23UL, 0xfc68b6edUL, 0xf163b8e4UL, 0xdccad731UL, 0x85104263UL, 0x22401397UL, 0x112084c6UL, 0x247d854aUL, 0x3df8d2bbUL, 0x3211aef9UL, 0xa16dc729UL, 0x2f4b1d9eUL, 0x30f3dcb2UL, 0x52ec0d86UL, 0xe3d077c1UL, 0x166c2bb3UL, 0xb999a970UL, 0x48fa1194UL, 0x642247e9UL, 0x8cc4a8fcUL, 0x3f1aa0f0UL, 0x2cd8567dUL, 0x90ef2233UL, 0x4ec78749UL, 0xd1c1d938UL, 0xa2fe8ccaUL, 0x0b3698d4UL, 0x81cfa6f5UL, 0xde28a57aUL, 0x8e26dab7UL, 0xbfa43fadUL, 0x9de42c3aUL, 0x920d5078UL, 0xcc9b6a5fUL, 0x4662547eUL, 0x13c2f68dUL, 0xb8e890d8UL, 0xf75e2e39UL, 0xaff582c3UL, 0x80be9f5dUL, 0x937c69d0UL, 0x2da96fd5UL, 0x12b3cf25UL, 0x993bc8acUL, 0x7da71018UL, 0x636ee89cUL, 0xbb7bdb3bUL, 0x7809cd26UL, 0x18f46e59UL, 0xb701ec9aUL, 0x9aa8834fUL, 0x6e65e695UL, 0xe67eaaffUL, 0xcf0821bcUL, 0xe8e6ef15UL, 0x9bd9bae7UL, 0x36ce4a6fUL, 0x09d4ea9fUL, 0x7cd629b0UL, 0xb2af31a4UL, 0x23312a3fUL, 0x9430c6a5UL, 0x66c035a2UL, 0xbc37744eUL, 0xcaa6fc82UL, 0xd0b0e090UL, 0xd81533a7UL, 0x984af104UL, 0xdaf741ecUL, 0x500e7fcdUL, 0xf62f1791UL, 0xd68d764dUL, 0xb04d43efUL, 0x4d54ccaaUL, 0x04dfe496UL, 0xb5e39ed1UL, 0x881b4c6aUL, 0x1fb8c12cUL, 0x517f4665UL, 0xea049d5eUL, 0x355d018cUL, 0x7473fa87UL, 0x412efb0bUL, 0x1d5ab367UL, 0xd25292dbUL, 0x5633e910UL, 0x47136dd6UL, 0x618c9ad7UL, 0x0c7a37a1UL, 0x148e59f8UL, 0x3c89eb13UL, 0x27eecea9UL, 0xc935b761UL, 0xe5ede11cUL, 0xb13c7a47UL, 0xdf599cd2UL, 0x733f55f2UL, 0xce791814UL, 0x37bf73c7UL, 0xcdea53f7UL, 0xaa5b5ffdUL, 0x6f14df3dUL, 0xdb867844UL, 0xf381caafUL, 0xc43eb968UL, 0x342c3824UL, 0x405fc2a3UL, 0xc372161dUL, 0x250cbce2UL, 0x498b283cUL, 0x9541ff0dUL, 0x017139a8UL, 0xb3de080cUL, 0xe49cd8b4UL, 0xc1906456UL, 0x84617bcbUL, 0xb670d532UL, 0x5c74486cUL, 0x5742d0b8UL, }; static const ulong32 TD3[256] = { 0xf4a75051UL, 0x4165537eUL, 0x17a4c31aUL, 0x275e963aUL, 0xab6bcb3bUL, 0x9d45f11fUL, 0xfa58abacUL, 0xe303934bUL, 0x30fa5520UL, 0x766df6adUL, 0xcc769188UL, 0x024c25f5UL, 0xe5d7fc4fUL, 0x2acbd7c5UL, 0x35448026UL, 0x62a38fb5UL, 0xb15a49deUL, 0xba1b6725UL, 0xea0e9845UL, 0xfec0e15dUL, 0x2f7502c3UL, 0x4cf01281UL, 0x4697a38dUL, 0xd3f9c66bUL, 0x8f5fe703UL, 0x929c9515UL, 0x6d7aebbfUL, 0x5259da95UL, 0xbe832dd4UL, 0x7421d358UL, 0xe0692949UL, 0xc9c8448eUL, 0xc2896a75UL, 0x8e7978f4UL, 0x583e6b99UL, 0xb971dd27UL, 0xe14fb6beUL, 0x88ad17f0UL, 0x20ac66c9UL, 0xce3ab47dUL, 0xdf4a1863UL, 0x1a3182e5UL, 0x51336097UL, 0x537f4562UL, 0x6477e0b1UL, 0x6bae84bbUL, 0x81a01cfeUL, 0x082b94f9UL, 0x48685870UL, 0x45fd198fUL, 0xde6c8794UL, 0x7bf8b752UL, 0x73d323abUL, 0x4b02e272UL, 0x1f8f57e3UL, 0x55ab2a66UL, 0xeb2807b2UL, 0xb5c2032fUL, 0xc57b9a86UL, 0x3708a5d3UL, 0x2887f230UL, 0xbfa5b223UL, 0x036aba02UL, 0x16825cedUL, 0xcf1c2b8aUL, 0x79b492a7UL, 0x07f2f0f3UL, 0x69e2a14eUL, 0xdaf4cd65UL, 0x05bed506UL, 0x34621fd1UL, 0xa6fe8ac4UL, 0x2e539d34UL, 0xf355a0a2UL, 0x8ae13205UL, 0xf6eb75a4UL, 0x83ec390bUL, 0x60efaa40UL, 0x719f065eUL, 0x6e1051bdUL, 0x218af93eUL, 0xdd063d96UL, 0x3e05aeddUL, 0xe6bd464dUL, 0x548db591UL, 0xc45d0571UL, 0x06d46f04UL, 0x5015ff60UL, 0x98fb2419UL, 0xbde997d6UL, 0x4043cc89UL, 0xd99e7767UL, 0xe842bdb0UL, 0x898b8807UL, 0x195b38e7UL, 0xc8eedb79UL, 0x7c0a47a1UL, 0x420fe97cUL, 0x841ec9f8UL, 0x00000000UL, 0x80868309UL, 0x2bed4832UL, 0x1170ac1eUL, 0x5a724e6cUL, 0x0efffbfdUL, 0x8538560fUL, 0xaed51e3dUL, 0x2d392736UL, 0x0fd9640aUL, 0x5ca62168UL, 0x5b54d19bUL, 0x362e3a24UL, 0x0a67b10cUL, 0x57e70f93UL, 0xee96d2b4UL, 0x9b919e1bUL, 0xc0c54f80UL, 0xdc20a261UL, 0x774b695aUL, 0x121a161cUL, 0x93ba0ae2UL, 0xa02ae5c0UL, 0x22e0433cUL, 0x1b171d12UL, 0x090d0b0eUL, 0x8bc7adf2UL, 0xb6a8b92dUL, 0x1ea9c814UL, 0xf1198557UL, 0x75074cafUL, 0x99ddbbeeUL, 0x7f60fda3UL, 0x01269ff7UL, 0x72f5bc5cUL, 0x663bc544UL, 0xfb7e345bUL, 0x4329768bUL, 0x23c6dccbUL, 0xedfc68b6UL, 0xe4f163b8UL, 0x31dccad7UL, 0x63851042UL, 0x97224013UL, 0xc6112084UL, 0x4a247d85UL, 0xbb3df8d2UL, 0xf93211aeUL, 0x29a16dc7UL, 0x9e2f4b1dUL, 0xb230f3dcUL, 0x8652ec0dUL, 0xc1e3d077UL, 0xb3166c2bUL, 0x70b999a9UL, 0x9448fa11UL, 0xe9642247UL, 0xfc8cc4a8UL, 0xf03f1aa0UL, 0x7d2cd856UL, 0x3390ef22UL, 0x494ec787UL, 0x38d1c1d9UL, 0xcaa2fe8cUL, 0xd40b3698UL, 0xf581cfa6UL, 0x7ade28a5UL, 0xb78e26daUL, 0xadbfa43fUL, 0x3a9de42cUL, 0x78920d50UL, 0x5fcc9b6aUL, 0x7e466254UL, 0x8d13c2f6UL, 0xd8b8e890UL, 0x39f75e2eUL, 0xc3aff582UL, 0x5d80be9fUL, 0xd0937c69UL, 0xd52da96fUL, 0x2512b3cfUL, 0xac993bc8UL, 0x187da710UL, 0x9c636ee8UL, 0x3bbb7bdbUL, 0x267809cdUL, 0x5918f46eUL, 0x9ab701ecUL, 0x4f9aa883UL, 0x956e65e6UL, 0xffe67eaaUL, 0xbccf0821UL, 0x15e8e6efUL, 0xe79bd9baUL, 0x6f36ce4aUL, 0x9f09d4eaUL, 0xb07cd629UL, 0xa4b2af31UL, 0x3f23312aUL, 0xa59430c6UL, 0xa266c035UL, 0x4ebc3774UL, 0x82caa6fcUL, 0x90d0b0e0UL, 0xa7d81533UL, 0x04984af1UL, 0xecdaf741UL, 0xcd500e7fUL, 0x91f62f17UL, 0x4dd68d76UL, 0xefb04d43UL, 0xaa4d54ccUL, 0x9604dfe4UL, 0xd1b5e39eUL, 0x6a881b4cUL, 0x2c1fb8c1UL, 0x65517f46UL, 0x5eea049dUL, 0x8c355d01UL, 0x877473faUL, 0x0b412efbUL, 0x671d5ab3UL, 0xdbd25292UL, 0x105633e9UL, 0xd647136dUL, 0xd7618c9aUL, 0xa10c7a37UL, 0xf8148e59UL, 0x133c89ebUL, 0xa927eeceUL, 0x61c935b7UL, 0x1ce5ede1UL, 0x47b13c7aUL, 0xd2df599cUL, 0xf2733f55UL, 0x14ce7918UL, 0xc737bf73UL, 0xf7cdea53UL, 0xfdaa5b5fUL, 0x3d6f14dfUL, 0x44db8678UL, 0xaff381caUL, 0x68c43eb9UL, 0x24342c38UL, 0xa3405fc2UL, 0x1dc37216UL, 0xe2250cbcUL, 0x3c498b28UL, 0x0d9541ffUL, 0xa8017139UL, 0x0cb3de08UL, 0xb4e49cd8UL, 0x56c19064UL, 0xcb84617bUL, 0x32b670d5UL, 0x6c5c7448UL, 0xb85742d0UL, }; static const ulong32 Tks0[] = { 0x00000000UL, 0x0e090d0bUL, 0x1c121a16UL, 0x121b171dUL, 0x3824342cUL, 0x362d3927UL, 0x24362e3aUL, 0x2a3f2331UL, 0x70486858UL, 0x7e416553UL, 0x6c5a724eUL, 0x62537f45UL, 0x486c5c74UL, 0x4665517fUL, 0x547e4662UL, 0x5a774b69UL, 0xe090d0b0UL, 0xee99ddbbUL, 0xfc82caa6UL, 0xf28bc7adUL, 0xd8b4e49cUL, 0xd6bde997UL, 0xc4a6fe8aUL, 0xcaaff381UL, 0x90d8b8e8UL, 0x9ed1b5e3UL, 0x8ccaa2feUL, 0x82c3aff5UL, 0xa8fc8cc4UL, 0xa6f581cfUL, 0xb4ee96d2UL, 0xbae79bd9UL, 0xdb3bbb7bUL, 0xd532b670UL, 0xc729a16dUL, 0xc920ac66UL, 0xe31f8f57UL, 0xed16825cUL, 0xff0d9541UL, 0xf104984aUL, 0xab73d323UL, 0xa57ade28UL, 0xb761c935UL, 0xb968c43eUL, 0x9357e70fUL, 0x9d5eea04UL, 0x8f45fd19UL, 0x814cf012UL, 0x3bab6bcbUL, 0x35a266c0UL, 0x27b971ddUL, 0x29b07cd6UL, 0x038f5fe7UL, 0x0d8652ecUL, 0x1f9d45f1UL, 0x119448faUL, 0x4be30393UL, 0x45ea0e98UL, 0x57f11985UL, 0x59f8148eUL, 0x73c737bfUL, 0x7dce3ab4UL, 0x6fd52da9UL, 0x61dc20a2UL, 0xad766df6UL, 0xa37f60fdUL, 0xb16477e0UL, 0xbf6d7aebUL, 0x955259daUL, 0x9b5b54d1UL, 0x894043ccUL, 0x87494ec7UL, 0xdd3e05aeUL, 0xd33708a5UL, 0xc12c1fb8UL, 0xcf2512b3UL, 0xe51a3182UL, 0xeb133c89UL, 0xf9082b94UL, 0xf701269fUL, 0x4de6bd46UL, 0x43efb04dUL, 0x51f4a750UL, 0x5ffdaa5bUL, 0x75c2896aUL, 0x7bcb8461UL, 0x69d0937cUL, 0x67d99e77UL, 0x3daed51eUL, 0x33a7d815UL, 0x21bccf08UL, 0x2fb5c203UL, 0x058ae132UL, 0x0b83ec39UL, 0x1998fb24UL, 0x1791f62fUL, 0x764dd68dUL, 0x7844db86UL, 0x6a5fcc9bUL, 0x6456c190UL, 0x4e69e2a1UL, 0x4060efaaUL, 0x527bf8b7UL, 0x5c72f5bcUL, 0x0605bed5UL, 0x080cb3deUL, 0x1a17a4c3UL, 0x141ea9c8UL, 0x3e218af9UL, 0x302887f2UL, 0x223390efUL, 0x2c3a9de4UL, 0x96dd063dUL, 0x98d40b36UL, 0x8acf1c2bUL, 0x84c61120UL, 0xaef93211UL, 0xa0f03f1aUL, 0xb2eb2807UL, 0xbce2250cUL, 0xe6956e65UL, 0xe89c636eUL, 0xfa877473UL, 0xf48e7978UL, 0xdeb15a49UL, 0xd0b85742UL, 0xc2a3405fUL, 0xccaa4d54UL, 0x41ecdaf7UL, 0x4fe5d7fcUL, 0x5dfec0e1UL, 0x53f7cdeaUL, 0x79c8eedbUL, 0x77c1e3d0UL, 0x65daf4cdUL, 0x6bd3f9c6UL, 0x31a4b2afUL, 0x3fadbfa4UL, 0x2db6a8b9UL, 0x23bfa5b2UL, 0x09808683UL, 0x07898b88UL, 0x15929c95UL, 0x1b9b919eUL, 0xa17c0a47UL, 0xaf75074cUL, 0xbd6e1051UL, 0xb3671d5aUL, 0x99583e6bUL, 0x97513360UL, 0x854a247dUL, 0x8b432976UL, 0xd134621fUL, 0xdf3d6f14UL, 0xcd267809UL, 0xc32f7502UL, 0xe9105633UL, 0xe7195b38UL, 0xf5024c25UL, 0xfb0b412eUL, 0x9ad7618cUL, 0x94de6c87UL, 0x86c57b9aUL, 0x88cc7691UL, 0xa2f355a0UL, 0xacfa58abUL, 0xbee14fb6UL, 0xb0e842bdUL, 0xea9f09d4UL, 0xe49604dfUL, 0xf68d13c2UL, 0xf8841ec9UL, 0xd2bb3df8UL, 0xdcb230f3UL, 0xcea927eeUL, 0xc0a02ae5UL, 0x7a47b13cUL, 0x744ebc37UL, 0x6655ab2aUL, 0x685ca621UL, 0x42638510UL, 0x4c6a881bUL, 0x5e719f06UL, 0x5078920dUL, 0x0a0fd964UL, 0x0406d46fUL, 0x161dc372UL, 0x1814ce79UL, 0x322bed48UL, 0x3c22e043UL, 0x2e39f75eUL, 0x2030fa55UL, 0xec9ab701UL, 0xe293ba0aUL, 0xf088ad17UL, 0xfe81a01cUL, 0xd4be832dUL, 0xdab78e26UL, 0xc8ac993bUL, 0xc6a59430UL, 0x9cd2df59UL, 0x92dbd252UL, 0x80c0c54fUL, 0x8ec9c844UL, 0xa4f6eb75UL, 0xaaffe67eUL, 0xb8e4f163UL, 0xb6edfc68UL, 0x0c0a67b1UL, 0x02036abaUL, 0x10187da7UL, 0x1e1170acUL, 0x342e539dUL, 0x3a275e96UL, 0x283c498bUL, 0x26354480UL, 0x7c420fe9UL, 0x724b02e2UL, 0x605015ffUL, 0x6e5918f4UL, 0x44663bc5UL, 0x4a6f36ceUL, 0x587421d3UL, 0x567d2cd8UL, 0x37a10c7aUL, 0x39a80171UL, 0x2bb3166cUL, 0x25ba1b67UL, 0x0f853856UL, 0x018c355dUL, 0x13972240UL, 0x1d9e2f4bUL, 0x47e96422UL, 0x49e06929UL, 0x5bfb7e34UL, 0x55f2733fUL, 0x7fcd500eUL, 0x71c45d05UL, 0x63df4a18UL, 0x6dd64713UL, 0xd731dccaUL, 0xd938d1c1UL, 0xcb23c6dcUL, 0xc52acbd7UL, 0xef15e8e6UL, 0xe11ce5edUL, 0xf307f2f0UL, 0xfd0efffbUL, 0xa779b492UL, 0xa970b999UL, 0xbb6bae84UL, 0xb562a38fUL, 0x9f5d80beUL, 0x91548db5UL, 0x834f9aa8UL, 0x8d4697a3UL }; static const ulong32 Tks1[] = { 0x00000000UL, 0x0b0e090dUL, 0x161c121aUL, 0x1d121b17UL, 0x2c382434UL, 0x27362d39UL, 0x3a24362eUL, 0x312a3f23UL, 0x58704868UL, 0x537e4165UL, 0x4e6c5a72UL, 0x4562537fUL, 0x74486c5cUL, 0x7f466551UL, 0x62547e46UL, 0x695a774bUL, 0xb0e090d0UL, 0xbbee99ddUL, 0xa6fc82caUL, 0xadf28bc7UL, 0x9cd8b4e4UL, 0x97d6bde9UL, 0x8ac4a6feUL, 0x81caaff3UL, 0xe890d8b8UL, 0xe39ed1b5UL, 0xfe8ccaa2UL, 0xf582c3afUL, 0xc4a8fc8cUL, 0xcfa6f581UL, 0xd2b4ee96UL, 0xd9bae79bUL, 0x7bdb3bbbUL, 0x70d532b6UL, 0x6dc729a1UL, 0x66c920acUL, 0x57e31f8fUL, 0x5ced1682UL, 0x41ff0d95UL, 0x4af10498UL, 0x23ab73d3UL, 0x28a57adeUL, 0x35b761c9UL, 0x3eb968c4UL, 0x0f9357e7UL, 0x049d5eeaUL, 0x198f45fdUL, 0x12814cf0UL, 0xcb3bab6bUL, 0xc035a266UL, 0xdd27b971UL, 0xd629b07cUL, 0xe7038f5fUL, 0xec0d8652UL, 0xf11f9d45UL, 0xfa119448UL, 0x934be303UL, 0x9845ea0eUL, 0x8557f119UL, 0x8e59f814UL, 0xbf73c737UL, 0xb47dce3aUL, 0xa96fd52dUL, 0xa261dc20UL, 0xf6ad766dUL, 0xfda37f60UL, 0xe0b16477UL, 0xebbf6d7aUL, 0xda955259UL, 0xd19b5b54UL, 0xcc894043UL, 0xc787494eUL, 0xaedd3e05UL, 0xa5d33708UL, 0xb8c12c1fUL, 0xb3cf2512UL, 0x82e51a31UL, 0x89eb133cUL, 0x94f9082bUL, 0x9ff70126UL, 0x464de6bdUL, 0x4d43efb0UL, 0x5051f4a7UL, 0x5b5ffdaaUL, 0x6a75c289UL, 0x617bcb84UL, 0x7c69d093UL, 0x7767d99eUL, 0x1e3daed5UL, 0x1533a7d8UL, 0x0821bccfUL, 0x032fb5c2UL, 0x32058ae1UL, 0x390b83ecUL, 0x241998fbUL, 0x2f1791f6UL, 0x8d764dd6UL, 0x867844dbUL, 0x9b6a5fccUL, 0x906456c1UL, 0xa14e69e2UL, 0xaa4060efUL, 0xb7527bf8UL, 0xbc5c72f5UL, 0xd50605beUL, 0xde080cb3UL, 0xc31a17a4UL, 0xc8141ea9UL, 0xf93e218aUL, 0xf2302887UL, 0xef223390UL, 0xe42c3a9dUL, 0x3d96dd06UL, 0x3698d40bUL, 0x2b8acf1cUL, 0x2084c611UL, 0x11aef932UL, 0x1aa0f03fUL, 0x07b2eb28UL, 0x0cbce225UL, 0x65e6956eUL, 0x6ee89c63UL, 0x73fa8774UL, 0x78f48e79UL, 0x49deb15aUL, 0x42d0b857UL, 0x5fc2a340UL, 0x54ccaa4dUL, 0xf741ecdaUL, 0xfc4fe5d7UL, 0xe15dfec0UL, 0xea53f7cdUL, 0xdb79c8eeUL, 0xd077c1e3UL, 0xcd65daf4UL, 0xc66bd3f9UL, 0xaf31a4b2UL, 0xa43fadbfUL, 0xb92db6a8UL, 0xb223bfa5UL, 0x83098086UL, 0x8807898bUL, 0x9515929cUL, 0x9e1b9b91UL, 0x47a17c0aUL, 0x4caf7507UL, 0x51bd6e10UL, 0x5ab3671dUL, 0x6b99583eUL, 0x60975133UL, 0x7d854a24UL, 0x768b4329UL, 0x1fd13462UL, 0x14df3d6fUL, 0x09cd2678UL, 0x02c32f75UL, 0x33e91056UL, 0x38e7195bUL, 0x25f5024cUL, 0x2efb0b41UL, 0x8c9ad761UL, 0x8794de6cUL, 0x9a86c57bUL, 0x9188cc76UL, 0xa0a2f355UL, 0xabacfa58UL, 0xb6bee14fUL, 0xbdb0e842UL, 0xd4ea9f09UL, 0xdfe49604UL, 0xc2f68d13UL, 0xc9f8841eUL, 0xf8d2bb3dUL, 0xf3dcb230UL, 0xeecea927UL, 0xe5c0a02aUL, 0x3c7a47b1UL, 0x37744ebcUL, 0x2a6655abUL, 0x21685ca6UL, 0x10426385UL, 0x1b4c6a88UL, 0x065e719fUL, 0x0d507892UL, 0x640a0fd9UL, 0x6f0406d4UL, 0x72161dc3UL, 0x791814ceUL, 0x48322bedUL, 0x433c22e0UL, 0x5e2e39f7UL, 0x552030faUL, 0x01ec9ab7UL, 0x0ae293baUL, 0x17f088adUL, 0x1cfe81a0UL, 0x2dd4be83UL, 0x26dab78eUL, 0x3bc8ac99UL, 0x30c6a594UL, 0x599cd2dfUL, 0x5292dbd2UL, 0x4f80c0c5UL, 0x448ec9c8UL, 0x75a4f6ebUL, 0x7eaaffe6UL, 0x63b8e4f1UL, 0x68b6edfcUL, 0xb10c0a67UL, 0xba02036aUL, 0xa710187dUL, 0xac1e1170UL, 0x9d342e53UL, 0x963a275eUL, 0x8b283c49UL, 0x80263544UL, 0xe97c420fUL, 0xe2724b02UL, 0xff605015UL, 0xf46e5918UL, 0xc544663bUL, 0xce4a6f36UL, 0xd3587421UL, 0xd8567d2cUL, 0x7a37a10cUL, 0x7139a801UL, 0x6c2bb316UL, 0x6725ba1bUL, 0x560f8538UL, 0x5d018c35UL, 0x40139722UL, 0x4b1d9e2fUL, 0x2247e964UL, 0x2949e069UL, 0x345bfb7eUL, 0x3f55f273UL, 0x0e7fcd50UL, 0x0571c45dUL, 0x1863df4aUL, 0x136dd647UL, 0xcad731dcUL, 0xc1d938d1UL, 0xdccb23c6UL, 0xd7c52acbUL, 0xe6ef15e8UL, 0xede11ce5UL, 0xf0f307f2UL, 0xfbfd0effUL, 0x92a779b4UL, 0x99a970b9UL, 0x84bb6baeUL, 0x8fb562a3UL, 0xbe9f5d80UL, 0xb591548dUL, 0xa8834f9aUL, 0xa38d4697UL }; static const ulong32 Tks2[] = { 0x00000000UL, 0x0d0b0e09UL, 0x1a161c12UL, 0x171d121bUL, 0x342c3824UL, 0x3927362dUL, 0x2e3a2436UL, 0x23312a3fUL, 0x68587048UL, 0x65537e41UL, 0x724e6c5aUL, 0x7f456253UL, 0x5c74486cUL, 0x517f4665UL, 0x4662547eUL, 0x4b695a77UL, 0xd0b0e090UL, 0xddbbee99UL, 0xcaa6fc82UL, 0xc7adf28bUL, 0xe49cd8b4UL, 0xe997d6bdUL, 0xfe8ac4a6UL, 0xf381caafUL, 0xb8e890d8UL, 0xb5e39ed1UL, 0xa2fe8ccaUL, 0xaff582c3UL, 0x8cc4a8fcUL, 0x81cfa6f5UL, 0x96d2b4eeUL, 0x9bd9bae7UL, 0xbb7bdb3bUL, 0xb670d532UL, 0xa16dc729UL, 0xac66c920UL, 0x8f57e31fUL, 0x825ced16UL, 0x9541ff0dUL, 0x984af104UL, 0xd323ab73UL, 0xde28a57aUL, 0xc935b761UL, 0xc43eb968UL, 0xe70f9357UL, 0xea049d5eUL, 0xfd198f45UL, 0xf012814cUL, 0x6bcb3babUL, 0x66c035a2UL, 0x71dd27b9UL, 0x7cd629b0UL, 0x5fe7038fUL, 0x52ec0d86UL, 0x45f11f9dUL, 0x48fa1194UL, 0x03934be3UL, 0x0e9845eaUL, 0x198557f1UL, 0x148e59f8UL, 0x37bf73c7UL, 0x3ab47dceUL, 0x2da96fd5UL, 0x20a261dcUL, 0x6df6ad76UL, 0x60fda37fUL, 0x77e0b164UL, 0x7aebbf6dUL, 0x59da9552UL, 0x54d19b5bUL, 0x43cc8940UL, 0x4ec78749UL, 0x05aedd3eUL, 0x08a5d337UL, 0x1fb8c12cUL, 0x12b3cf25UL, 0x3182e51aUL, 0x3c89eb13UL, 0x2b94f908UL, 0x269ff701UL, 0xbd464de6UL, 0xb04d43efUL, 0xa75051f4UL, 0xaa5b5ffdUL, 0x896a75c2UL, 0x84617bcbUL, 0x937c69d0UL, 0x9e7767d9UL, 0xd51e3daeUL, 0xd81533a7UL, 0xcf0821bcUL, 0xc2032fb5UL, 0xe132058aUL, 0xec390b83UL, 0xfb241998UL, 0xf62f1791UL, 0xd68d764dUL, 0xdb867844UL, 0xcc9b6a5fUL, 0xc1906456UL, 0xe2a14e69UL, 0xefaa4060UL, 0xf8b7527bUL, 0xf5bc5c72UL, 0xbed50605UL, 0xb3de080cUL, 0xa4c31a17UL, 0xa9c8141eUL, 0x8af93e21UL, 0x87f23028UL, 0x90ef2233UL, 0x9de42c3aUL, 0x063d96ddUL, 0x0b3698d4UL, 0x1c2b8acfUL, 0x112084c6UL, 0x3211aef9UL, 0x3f1aa0f0UL, 0x2807b2ebUL, 0x250cbce2UL, 0x6e65e695UL, 0x636ee89cUL, 0x7473fa87UL, 0x7978f48eUL, 0x5a49deb1UL, 0x5742d0b8UL, 0x405fc2a3UL, 0x4d54ccaaUL, 0xdaf741ecUL, 0xd7fc4fe5UL, 0xc0e15dfeUL, 0xcdea53f7UL, 0xeedb79c8UL, 0xe3d077c1UL, 0xf4cd65daUL, 0xf9c66bd3UL, 0xb2af31a4UL, 0xbfa43fadUL, 0xa8b92db6UL, 0xa5b223bfUL, 0x86830980UL, 0x8b880789UL, 0x9c951592UL, 0x919e1b9bUL, 0x0a47a17cUL, 0x074caf75UL, 0x1051bd6eUL, 0x1d5ab367UL, 0x3e6b9958UL, 0x33609751UL, 0x247d854aUL, 0x29768b43UL, 0x621fd134UL, 0x6f14df3dUL, 0x7809cd26UL, 0x7502c32fUL, 0x5633e910UL, 0x5b38e719UL, 0x4c25f502UL, 0x412efb0bUL, 0x618c9ad7UL, 0x6c8794deUL, 0x7b9a86c5UL, 0x769188ccUL, 0x55a0a2f3UL, 0x58abacfaUL, 0x4fb6bee1UL, 0x42bdb0e8UL, 0x09d4ea9fUL, 0x04dfe496UL, 0x13c2f68dUL, 0x1ec9f884UL, 0x3df8d2bbUL, 0x30f3dcb2UL, 0x27eecea9UL, 0x2ae5c0a0UL, 0xb13c7a47UL, 0xbc37744eUL, 0xab2a6655UL, 0xa621685cUL, 0x85104263UL, 0x881b4c6aUL, 0x9f065e71UL, 0x920d5078UL, 0xd9640a0fUL, 0xd46f0406UL, 0xc372161dUL, 0xce791814UL, 0xed48322bUL, 0xe0433c22UL, 0xf75e2e39UL, 0xfa552030UL, 0xb701ec9aUL, 0xba0ae293UL, 0xad17f088UL, 0xa01cfe81UL, 0x832dd4beUL, 0x8e26dab7UL, 0x993bc8acUL, 0x9430c6a5UL, 0xdf599cd2UL, 0xd25292dbUL, 0xc54f80c0UL, 0xc8448ec9UL, 0xeb75a4f6UL, 0xe67eaaffUL, 0xf163b8e4UL, 0xfc68b6edUL, 0x67b10c0aUL, 0x6aba0203UL, 0x7da71018UL, 0x70ac1e11UL, 0x539d342eUL, 0x5e963a27UL, 0x498b283cUL, 0x44802635UL, 0x0fe97c42UL, 0x02e2724bUL, 0x15ff6050UL, 0x18f46e59UL, 0x3bc54466UL, 0x36ce4a6fUL, 0x21d35874UL, 0x2cd8567dUL, 0x0c7a37a1UL, 0x017139a8UL, 0x166c2bb3UL, 0x1b6725baUL, 0x38560f85UL, 0x355d018cUL, 0x22401397UL, 0x2f4b1d9eUL, 0x642247e9UL, 0x692949e0UL, 0x7e345bfbUL, 0x733f55f2UL, 0x500e7fcdUL, 0x5d0571c4UL, 0x4a1863dfUL, 0x47136dd6UL, 0xdccad731UL, 0xd1c1d938UL, 0xc6dccb23UL, 0xcbd7c52aUL, 0xe8e6ef15UL, 0xe5ede11cUL, 0xf2f0f307UL, 0xfffbfd0eUL, 0xb492a779UL, 0xb999a970UL, 0xae84bb6bUL, 0xa38fb562UL, 0x80be9f5dUL, 0x8db59154UL, 0x9aa8834fUL, 0x97a38d46UL }; static const ulong32 Tks3[] = { 0x00000000UL, 0x090d0b0eUL, 0x121a161cUL, 0x1b171d12UL, 0x24342c38UL, 0x2d392736UL, 0x362e3a24UL, 0x3f23312aUL, 0x48685870UL, 0x4165537eUL, 0x5a724e6cUL, 0x537f4562UL, 0x6c5c7448UL, 0x65517f46UL, 0x7e466254UL, 0x774b695aUL, 0x90d0b0e0UL, 0x99ddbbeeUL, 0x82caa6fcUL, 0x8bc7adf2UL, 0xb4e49cd8UL, 0xbde997d6UL, 0xa6fe8ac4UL, 0xaff381caUL, 0xd8b8e890UL, 0xd1b5e39eUL, 0xcaa2fe8cUL, 0xc3aff582UL, 0xfc8cc4a8UL, 0xf581cfa6UL, 0xee96d2b4UL, 0xe79bd9baUL, 0x3bbb7bdbUL, 0x32b670d5UL, 0x29a16dc7UL, 0x20ac66c9UL, 0x1f8f57e3UL, 0x16825cedUL, 0x0d9541ffUL, 0x04984af1UL, 0x73d323abUL, 0x7ade28a5UL, 0x61c935b7UL, 0x68c43eb9UL, 0x57e70f93UL, 0x5eea049dUL, 0x45fd198fUL, 0x4cf01281UL, 0xab6bcb3bUL, 0xa266c035UL, 0xb971dd27UL, 0xb07cd629UL, 0x8f5fe703UL, 0x8652ec0dUL, 0x9d45f11fUL, 0x9448fa11UL, 0xe303934bUL, 0xea0e9845UL, 0xf1198557UL, 0xf8148e59UL, 0xc737bf73UL, 0xce3ab47dUL, 0xd52da96fUL, 0xdc20a261UL, 0x766df6adUL, 0x7f60fda3UL, 0x6477e0b1UL, 0x6d7aebbfUL, 0x5259da95UL, 0x5b54d19bUL, 0x4043cc89UL, 0x494ec787UL, 0x3e05aeddUL, 0x3708a5d3UL, 0x2c1fb8c1UL, 0x2512b3cfUL, 0x1a3182e5UL, 0x133c89ebUL, 0x082b94f9UL, 0x01269ff7UL, 0xe6bd464dUL, 0xefb04d43UL, 0xf4a75051UL, 0xfdaa5b5fUL, 0xc2896a75UL, 0xcb84617bUL, 0xd0937c69UL, 0xd99e7767UL, 0xaed51e3dUL, 0xa7d81533UL, 0xbccf0821UL, 0xb5c2032fUL, 0x8ae13205UL, 0x83ec390bUL, 0x98fb2419UL, 0x91f62f17UL, 0x4dd68d76UL, 0x44db8678UL, 0x5fcc9b6aUL, 0x56c19064UL, 0x69e2a14eUL, 0x60efaa40UL, 0x7bf8b752UL, 0x72f5bc5cUL, 0x05bed506UL, 0x0cb3de08UL, 0x17a4c31aUL, 0x1ea9c814UL, 0x218af93eUL, 0x2887f230UL, 0x3390ef22UL, 0x3a9de42cUL, 0xdd063d96UL, 0xd40b3698UL, 0xcf1c2b8aUL, 0xc6112084UL, 0xf93211aeUL, 0xf03f1aa0UL, 0xeb2807b2UL, 0xe2250cbcUL, 0x956e65e6UL, 0x9c636ee8UL, 0x877473faUL, 0x8e7978f4UL, 0xb15a49deUL, 0xb85742d0UL, 0xa3405fc2UL, 0xaa4d54ccUL, 0xecdaf741UL, 0xe5d7fc4fUL, 0xfec0e15dUL, 0xf7cdea53UL, 0xc8eedb79UL, 0xc1e3d077UL, 0xdaf4cd65UL, 0xd3f9c66bUL, 0xa4b2af31UL, 0xadbfa43fUL, 0xb6a8b92dUL, 0xbfa5b223UL, 0x80868309UL, 0x898b8807UL, 0x929c9515UL, 0x9b919e1bUL, 0x7c0a47a1UL, 0x75074cafUL, 0x6e1051bdUL, 0x671d5ab3UL, 0x583e6b99UL, 0x51336097UL, 0x4a247d85UL, 0x4329768bUL, 0x34621fd1UL, 0x3d6f14dfUL, 0x267809cdUL, 0x2f7502c3UL, 0x105633e9UL, 0x195b38e7UL, 0x024c25f5UL, 0x0b412efbUL, 0xd7618c9aUL, 0xde6c8794UL, 0xc57b9a86UL, 0xcc769188UL, 0xf355a0a2UL, 0xfa58abacUL, 0xe14fb6beUL, 0xe842bdb0UL, 0x9f09d4eaUL, 0x9604dfe4UL, 0x8d13c2f6UL, 0x841ec9f8UL, 0xbb3df8d2UL, 0xb230f3dcUL, 0xa927eeceUL, 0xa02ae5c0UL, 0x47b13c7aUL, 0x4ebc3774UL, 0x55ab2a66UL, 0x5ca62168UL, 0x63851042UL, 0x6a881b4cUL, 0x719f065eUL, 0x78920d50UL, 0x0fd9640aUL, 0x06d46f04UL, 0x1dc37216UL, 0x14ce7918UL, 0x2bed4832UL, 0x22e0433cUL, 0x39f75e2eUL, 0x30fa5520UL, 0x9ab701ecUL, 0x93ba0ae2UL, 0x88ad17f0UL, 0x81a01cfeUL, 0xbe832dd4UL, 0xb78e26daUL, 0xac993bc8UL, 0xa59430c6UL, 0xd2df599cUL, 0xdbd25292UL, 0xc0c54f80UL, 0xc9c8448eUL, 0xf6eb75a4UL, 0xffe67eaaUL, 0xe4f163b8UL, 0xedfc68b6UL, 0x0a67b10cUL, 0x036aba02UL, 0x187da710UL, 0x1170ac1eUL, 0x2e539d34UL, 0x275e963aUL, 0x3c498b28UL, 0x35448026UL, 0x420fe97cUL, 0x4b02e272UL, 0x5015ff60UL, 0x5918f46eUL, 0x663bc544UL, 0x6f36ce4aUL, 0x7421d358UL, 0x7d2cd856UL, 0xa10c7a37UL, 0xa8017139UL, 0xb3166c2bUL, 0xba1b6725UL, 0x8538560fUL, 0x8c355d01UL, 0x97224013UL, 0x9e2f4b1dUL, 0xe9642247UL, 0xe0692949UL, 0xfb7e345bUL, 0xf2733f55UL, 0xcd500e7fUL, 0xc45d0571UL, 0xdf4a1863UL, 0xd647136dUL, 0x31dccad7UL, 0x38d1c1d9UL, 0x23c6dccbUL, 0x2acbd7c5UL, 0x15e8e6efUL, 0x1ce5ede1UL, 0x07f2f0f3UL, 0x0efffbfdUL, 0x79b492a7UL, 0x70b999a9UL, 0x6bae84bbUL, 0x62a38fb5UL, 0x5d80be9fUL, 0x548db591UL, 0x4f9aa883UL, 0x4697a38dUL }; #endif /* SMALL CODE */ static const ulong32 rcon[] = { 0x01000000UL, 0x02000000UL, 0x04000000UL, 0x08000000UL, 0x10000000UL, 0x20000000UL, 0x40000000UL, 0x80000000UL, 0x1B000000UL, 0x36000000UL, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */ }; sks-ecc-0.93/ltc/aes.c0000644000175000017500000005211710715702751013450 0ustar nachonacho/* aes.c (Part of SKS cryptosystem) Primitives for Rijndael (AES) encryption This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Manuel Pancorbo Castro */ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@iahu.ca, http://libtomcrypt.org */ /* AES implementation by Tom St Denis * * Derived from the Public Domain source code by --- * rijndael-alg-fst.c * * @version 3.0 (December 2000) * * Optimised ANSI C code for the Rijndael cipher (now AES) * * @author Vincent Rijmen * @author Antoon Bosselaers * @author Paulo Barreto --- */ #include "mycrypt.h" void burn_stack(unsigned long); #ifdef RIJNDAEL const struct _cipher_descriptor rijndael_desc = { "rijndael", 6, 16, 32, 16, 10, &rijndael_setup, &rijndael_ecb_encrypt, &rijndael_ecb_decrypt, &rijndael_test, &rijndael_keysize }; const struct _cipher_descriptor aes_desc = { "aes", 6, 16, 32, 16, 10, &rijndael_setup, &rijndael_ecb_encrypt, &rijndael_ecb_decrypt, &rijndael_test, &rijndael_keysize }; #ifdef SMALL_CODE static int tables_builded = 0; static ulong32 TE0[256]; static ulong32 TE1[256]; static ulong32 TE2[256]; static ulong32 TE3[256]; static ulong32 Te4[256]; /** The main table is kept visible **/ static ulong32 TD0[256]; static ulong32 TD1[256]; static ulong32 TD2[256]; static ulong32 TD3[256]; static ulong32 Td4[256]; static ulong32 Te4_0[256]; static ulong32 Te4_1[256]; static ulong32 Te4_2[256]; static ulong32 Te4_3[256]; /* static ulong32 Tks0[256]; static ulong32 Tks1[256]; static ulong32 Tks2[256]; static ulong32 Tks3[256]; */ static ulong32 rcon[10] ; #define Te0(x) TE0[x] #define Te1(x) TE1[x] #define Te2(x) TE2[x] #define Te3(x) TE3[x] #define Td0(x) TD0[x] #define Td1(x) TD1[x] #define Td2(x) TD2[x] #define Td3(x) TD3[x] /* #define Te4_0 0x000000FF & Te4 #define Te4_1 0x0000FF00 & Te4 #define Te4_2 0x00FF0000 & Te4 #define Te4_3 0xFF000000 & Te4 */ /* * Code adapted by Manuel Pancorbo Castro for using with LibTomMath * * FIPS-197 compliant AES implementation * * Copyright (C) 2001-2004 Christophe Devine * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define ROTR8(x) ( ( ( x << 24 ) & 0xFFFFFFFF ) | \ ( ( x & 0xFFFFFFFF ) >> 8 ) ) #define XTIME(x) ( ( x << 1 ) ^ ( ( x & 0x80 ) ? 0x1B : 0x00 ) ) #define MUL(x,y) ( ( x && y ) ? pow[(log[x] + log[y]) % 255] : 0 ) static void build_aes_tables(void) { if(tables_builded) return; int i; unsigned char x, y; ulong32 xx, yy; unsigned char pow[256]; unsigned char log[256]; /* compute pow and log tables over GF(2^8) */ for( i = 0, x = 1; i < 256; i++, x ^= XTIME( x ) ) { pow[i] = x; log[x] = i; } /* calculate the round constants */ for( i = 0, x = 1; i < 10; i++, x = XTIME( x ) ) { rcon[i] = (ulong32) x << 24; } /* generate the forward and reverse S-boxes */ Te4[0x00] = 0x63; Td4[0x63] = 0x00; for( i = 1; i < 256; i++ ) { x = pow[255 - log[i]]; y = x; y = ( y << 1 ) | ( y >> 7 ); x ^= y; y = ( y << 1 ) | ( y >> 7 ); x ^= y; y = ( y << 1 ) | ( y >> 7 ); x ^= y; y = ( y << 1 ) | ( y >> 7 ); x ^= y ^ 0x63; Te4[i] = x & 0xFF; Td4[x] = i; } /* generate the forward and reverse tables */ for( i = 0; i < 256; i++ ) { x = xx = Te4[i]; y = XTIME( x ); TE0[i] = (ulong32) ( x ^ y ) ^ ( (ulong32) x << 8 ) ^ ( (ulong32) x << 16 ) ^ ( (ulong32) y << 24 ); TE0[i] &= 0xFFFFFFFF; TE1[i] = ROTR8( TE0[i] ); TE2[i] = ROTR8( TE1[i] ); TE3[i] = ROTR8( TE2[i] ); Te4[i] = (xx ^ (xx << 8) ^ (xx << 16) ^ (xx << 24)) & 0xFFFFFFFF; Te4_0[i] = 0x000000FF & Te4[i]; Te4_1[i] = 0x0000FF00 & Te4[i]; Te4_2[i] = 0x00FF0000 & Te4[i]; Te4_3[i] = 0xFF000000 & Te4[i]; y = yy = Td4[i]; TD0[i] = ( (ulong32) MUL( 0x0B, y ) ) ^ ( (ulong32) MUL( 0x0D, y ) << 8 ) ^ ( (ulong32) MUL( 0x09, y ) << 16 ) ^ ( (ulong32) MUL( 0x0E, y ) << 24 ); TD0[i] &= 0xFFFFFFFF; TD1[i] = ROTR8( TD0[i] ); TD2[i] = ROTR8( TD1[i] ); TD3[i] = ROTR8( TD2[i] ); Td4[i] = (yy ^ (yy << 8) ^ (yy << 16) ^ (yy << 24)) & 0xFFFFFFFF; } #if 0 for( i = 0; i < 256; i++ ){ y = (unsigned char) (Te4[i] % 256); Tks0[i] = TD0[y]; Tks1[i] = TD1[y]; Tks2[i] = TD2[y]; Tks3[i] = TD3[y]; } #endif tables_builded = 1; } #else #include "aes_tab.c" #endif /** SMALL_CODE **/ int rijndael_setup(const unsigned char *key, int keylen, int rounds, symmetric_key *skey) { int i, j; ulong32 temp, *rk, *rrk; _ARGCHK(key != NULL); _ARGCHK(skey != NULL); #ifdef SMALL_CODE if(!tables_builded) build_aes_tables(); #endif if (keylen != 16 && keylen != 24 && keylen != 32) { return CRYPT_INVALID_KEYSIZE; } if (rounds != 0 && rounds != (10 + ((keylen/8)-2)*2)) { return CRYPT_INVALID_ROUNDS; } skey->rijndael.Nr = 10 + ((keylen/8)-2)*2; /* setup the forward key */ i = 0; rk = skey->rijndael.eK; LOAD32H(rk[0], key ); LOAD32H(rk[1], key + 4); LOAD32H(rk[2], key + 8); LOAD32H(rk[3], key + 12); if (keylen == 16) { j = 44; for (;;) { temp = rk[3]; rk[4] = rk[0] ^ (Te4_3[byte(temp, 2)]) ^ (Te4_2[byte(temp, 1)]) ^ (Te4_1[byte(temp, 0)]) ^ (Te4_0[byte(temp, 3)]) ^ rcon[i]; rk[5] = rk[1] ^ rk[4]; rk[6] = rk[2] ^ rk[5]; rk[7] = rk[3] ^ rk[6]; if (++i == 10) { break; } rk += 4; } } else if (keylen == 24) { j = 52; LOAD32H(rk[4], key + 16); LOAD32H(rk[5], key + 20); for (;;) { #ifdef _MSC_VER temp = skey->rijndael.eK[rk - skey->rijndael.eK + 5]; #else temp = rk[5]; #endif rk[ 6] = rk[ 0] ^ (Te4_3[byte(temp, 2)]) ^ (Te4_2[byte(temp, 1)]) ^ (Te4_1[byte(temp, 0)]) ^ (Te4_0[byte(temp, 3)]) ^ rcon[i]; rk[ 7] = rk[ 1] ^ rk[ 6]; rk[ 8] = rk[ 2] ^ rk[ 7]; rk[ 9] = rk[ 3] ^ rk[ 8]; if (++i == 8) { break; } rk[10] = rk[ 4] ^ rk[ 9]; rk[11] = rk[ 5] ^ rk[10]; rk += 6; } } else if (keylen == 32) { j = 60; LOAD32H(rk[4], key + 16); LOAD32H(rk[5], key + 20); LOAD32H(rk[6], key + 24); LOAD32H(rk[7], key + 28); for (;;) { #ifdef _MSC_VER temp = skey->rijndael.eK[rk - skey->rijndael.eK + 7]; #else temp = rk[7]; #endif rk[ 8] = rk[ 0] ^ (Te4_3[byte(temp, 2)]) ^ (Te4_2[byte(temp, 1)]) ^ (Te4_1[byte(temp, 0)]) ^ (Te4_0[byte(temp, 3)]) ^ rcon[i]; rk[ 9] = rk[ 1] ^ rk[ 8]; rk[10] = rk[ 2] ^ rk[ 9]; rk[11] = rk[ 3] ^ rk[10]; if (++i == 7) { break; } temp = rk[11]; rk[12] = rk[ 4] ^ (Te4_3[byte(temp, 3)]) ^ (Te4_2[byte(temp, 2)]) ^ (Te4_1[byte(temp, 1)]) ^ (Te4_0[byte(temp, 0)]); rk[13] = rk[ 5] ^ rk[12]; rk[14] = rk[ 6] ^ rk[13]; rk[15] = rk[ 7] ^ rk[14]; rk += 8; } } else { /* this can't happen */ j = 4; } /* setup the inverse key now */ rk = skey->rijndael.dK; rrk = skey->rijndael.eK + j - 4; /* apply the inverse MixColumn transform to all round keys but the first and the last: */ /* copy first */ *rk++ = *rrk++; *rk++ = *rrk++; *rk++ = *rrk++; *rk = *rrk; rk -= 3; rrk -= 3; for (i = 1; i < skey->rijndael.Nr; i++) { rrk -= 4; rk += 4; #ifdef SMALL_CODE temp = rrk[0]; rk[0] = Td0(255 & Te4[byte(temp, 3)]) ^ Td1(255 & Te4[byte(temp, 2)]) ^ Td2(255 & Te4[byte(temp, 1)]) ^ Td3(255 & Te4[byte(temp, 0)]); temp = rrk[1]; rk[1] = Td0(255 & Te4[byte(temp, 3)]) ^ Td1(255 & Te4[byte(temp, 2)]) ^ Td2(255 & Te4[byte(temp, 1)]) ^ Td3(255 & Te4[byte(temp, 0)]); temp = rrk[2]; rk[2] = Td0(255 & Te4[byte(temp, 3)]) ^ Td1(255 & Te4[byte(temp, 2)]) ^ Td2(255 & Te4[byte(temp, 1)]) ^ Td3(255 & Te4[byte(temp, 0)]); temp = rrk[3]; rk[3] = Td0(255 & Te4[byte(temp, 3)]) ^ Td1(255 & Te4[byte(temp, 2)]) ^ Td2(255 & Te4[byte(temp, 1)]) ^ Td3(255 & Te4[byte(temp, 0)]); #else temp = rrk[0]; rk[0] = Tks0[byte(temp, 3)] ^ Tks1[byte(temp, 2)] ^ Tks2[byte(temp, 1)] ^ Tks3[byte(temp, 0)]; temp = rrk[1]; rk[1] = Tks0[byte(temp, 3)] ^ Tks1[byte(temp, 2)] ^ Tks2[byte(temp, 1)] ^ Tks3[byte(temp, 0)]; temp = rrk[2]; rk[2] = Tks0[byte(temp, 3)] ^ Tks1[byte(temp, 2)] ^ Tks2[byte(temp, 1)] ^ Tks3[byte(temp, 0)]; temp = rrk[3]; rk[3] = Tks0[byte(temp, 3)] ^ Tks1[byte(temp, 2)] ^ Tks2[byte(temp, 1)] ^ Tks3[byte(temp, 0)]; #endif } /* copy last */ rrk -= 4; rk += 4; *rk++ = *rrk++; *rk++ = *rrk++; *rk++ = *rrk++; *rk = *rrk; return CRYPT_OK; } #ifdef CLEAN_STACK static void _rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey) #else void rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey) #endif { ulong32 s0, s1, s2, s3, t0, t1, t2, t3, *rk; int Nr, r; _ARGCHK(pt != NULL); _ARGCHK(ct != NULL); _ARGCHK(skey != NULL); Nr = skey->rijndael.Nr; rk = skey->rijndael.eK; /* * map byte array block to cipher state * and add initial round key: */ LOAD32H(s0, pt ); s0 ^= rk[0]; LOAD32H(s1, pt + 4); s1 ^= rk[1]; LOAD32H(s2, pt + 8); s2 ^= rk[2]; LOAD32H(s3, pt + 12); s3 ^= rk[3]; /* * Nr - 1 full rounds: */ r = Nr >> 1; for (;;) { t0 = Te0(byte(s0, 3)) ^ Te1(byte(s1, 2)) ^ Te2(byte(s2, 1)) ^ Te3(byte(s3, 0)) ^ rk[4]; t1 = Te0(byte(s1, 3)) ^ Te1(byte(s2, 2)) ^ Te2(byte(s3, 1)) ^ Te3(byte(s0, 0)) ^ rk[5]; t2 = Te0(byte(s2, 3)) ^ Te1(byte(s3, 2)) ^ Te2(byte(s0, 1)) ^ Te3(byte(s1, 0)) ^ rk[6]; t3 = Te0(byte(s3, 3)) ^ Te1(byte(s0, 2)) ^ Te2(byte(s1, 1)) ^ Te3(byte(s2, 0)) ^ rk[7]; rk += 8; if (--r == 0) { break; } s0 = Te0(byte(t0, 3)) ^ Te1(byte(t1, 2)) ^ Te2(byte(t2, 1)) ^ Te3(byte(t3, 0)) ^ rk[0]; s1 = Te0(byte(t1, 3)) ^ Te1(byte(t2, 2)) ^ Te2(byte(t3, 1)) ^ Te3(byte(t0, 0)) ^ rk[1]; s2 = Te0(byte(t2, 3)) ^ Te1(byte(t3, 2)) ^ Te2(byte(t0, 1)) ^ Te3(byte(t1, 0)) ^ rk[2]; s3 = Te0(byte(t3, 3)) ^ Te1(byte(t0, 2)) ^ Te2(byte(t1, 1)) ^ Te3(byte(t2, 0)) ^ rk[3]; } /* * apply last round and * map cipher state to byte array block: */ s0 = (Te4_3[(t0 >> 24) ]) ^ (Te4_2[(t1 >> 16) & 0xff]) ^ (Te4_1[(t2 >> 8) & 0xff]) ^ (Te4_0[(t3 ) & 0xff]) ^ rk[0]; STORE32H(s0, ct); s1 = (Te4_3[(t1 >> 24) ]) ^ (Te4_2[(t2 >> 16) & 0xff]) ^ (Te4_1[(t3 >> 8) & 0xff]) ^ (Te4_0[(t0 ) & 0xff]) ^ rk[1]; STORE32H(s1, ct+4); s2 = (Te4_3[(t2 >> 24) ]) ^ (Te4_2[(t3 >> 16) & 0xff]) ^ (Te4_1[(t0 >> 8) & 0xff]) ^ (Te4_0[(t1 ) & 0xff]) ^ rk[2]; STORE32H(s2, ct+8); s3 = (Te4_3[(t3 >> 24) ]) ^ (Te4_2[(t0 >> 16) & 0xff]) ^ (Te4_1[(t1 >> 8) & 0xff]) ^ (Te4_0[(t2 ) & 0xff]) ^ rk[3]; STORE32H(s3, ct+12); } #ifdef CLEAN_STACK void rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey) { _rijndael_ecb_encrypt(pt, ct, skey); burn_stack(sizeof(unsigned long)*8 + sizeof(unsigned long*) + sizeof(int)*2); } #endif #ifdef CLEAN_STACK static void _rijndael_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey) #else void rijndael_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey) #endif { ulong32 s0, s1, s2, s3, t0, t1, t2, t3, *rk; int Nr, r; _ARGCHK(pt != NULL); _ARGCHK(ct != NULL); _ARGCHK(skey != NULL); Nr = skey->rijndael.Nr; rk = skey->rijndael.dK; /* * map byte array block to cipher state * and add initial round key: */ LOAD32H(s0, ct ); s0 ^= rk[0]; LOAD32H(s1, ct + 4); s1 ^= rk[1]; LOAD32H(s2, ct + 8); s2 ^= rk[2]; LOAD32H(s3, ct + 12); s3 ^= rk[3]; /* * Nr - 1 full rounds: */ r = Nr >> 1; for (;;) { t0 = Td0(byte(s0, 3)) ^ Td1(byte(s3, 2)) ^ Td2(byte(s2, 1)) ^ Td3(byte(s1, 0)) ^ rk[4]; t1 = Td0(byte(s1, 3)) ^ Td1(byte(s0, 2)) ^ Td2(byte(s3, 1)) ^ Td3(byte(s2, 0)) ^ rk[5]; t2 = Td0(byte(s2, 3)) ^ Td1(byte(s1, 2)) ^ Td2(byte(s0, 1)) ^ Td3(byte(s3, 0)) ^ rk[6]; t3 = Td0(byte(s3, 3)) ^ Td1(byte(s2, 2)) ^ Td2(byte(s1, 1)) ^ Td3(byte(s0, 0)) ^ rk[7]; rk += 8; if (--r == 0) { break; } s0 = Td0(byte(t0, 3)) ^ Td1(byte(t3, 2)) ^ Td2(byte(t2, 1)) ^ Td3(byte(t1, 0)) ^ rk[0]; s1 = Td0(byte(t1, 3)) ^ Td1(byte(t0, 2)) ^ Td2(byte(t3, 1)) ^ Td3(byte(t2, 0)) ^ rk[1]; s2 = Td0(byte(t2, 3)) ^ Td1(byte(t1, 2)) ^ Td2(byte(t0, 1)) ^ Td3(byte(t3, 0)) ^ rk[2]; s3 = Td0(byte(t3, 3)) ^ Td1(byte(t2, 2)) ^ Td2(byte(t1, 1)) ^ Td3(byte(t0, 0)) ^ rk[3]; } /* * apply last round and * map cipher state to byte array block: */ s0 = (Td4[(t0 >> 24) ] & 0xff000000) ^ (Td4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ (Td4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ (Td4[(t1 ) & 0xff] & 0x000000ff) ^ rk[0]; STORE32H(s0, pt); s1 = (Td4[(t1 >> 24) ] & 0xff000000) ^ (Td4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ (Td4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ (Td4[(t2 ) & 0xff] & 0x000000ff) ^ rk[1]; STORE32H(s1, pt+4); s2 = (Td4[(t2 >> 24) ] & 0xff000000) ^ (Td4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ (Td4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ (Td4[(t3 ) & 0xff] & 0x000000ff) ^ rk[2]; STORE32H(s2, pt+8); s3 = (Td4[(t3 >> 24) ] & 0xff000000) ^ (Td4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ (Td4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ (Td4[(t0 ) & 0xff] & 0x000000ff) ^ rk[3]; STORE32H(s3, pt+12); } #ifdef CLEAN_STACK void rijndael_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey) { _rijndael_ecb_decrypt(ct, pt, skey); burn_stack(sizeof(unsigned long)*8 + sizeof(unsigned long*) + sizeof(int)*2); } #endif int rijndael_test(void) { #ifndef LTC_TEST return CRYPT_NOP; #else int err; static const struct { int keylen; unsigned char key[32], pt[16], ct[16]; } tests[] = { { 16, { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30, 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a } }, { 24, { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }, { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0, 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91 } }, { 32, { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }, { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf, 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 } } }; symmetric_key key; unsigned char tmp[2][16]; int i, y; for (i = 0; i < (int)(sizeof(tests)/sizeof(tests[0])); i++) { zeromem(&key, sizeof(key)); if ((err = rijndael_setup(tests[i].key, tests[i].keylen, 0, &key)) != CRYPT_OK) { return err; } rijndael_ecb_encrypt(tests[i].pt, tmp[0], &key); rijndael_ecb_decrypt(tmp[0], tmp[1], &key); if (memcmp(tmp[0], tests[i].ct, 16) || memcmp(tmp[1], tests[i].pt, 16)) { #if 0 printf("\n\nTest %d failed\n", i); if (memcmp(tmp[0], tests[i].ct, 16)) { printf("CT: "); for (i = 0; i < 16; i++) { printf("%02x ", tmp[0][i]); } printf("\n"); } else { printf("PT: "); for (i = 0; i < 16; i++) { printf("%02x ", tmp[1][i]); } printf("\n"); } #endif return CRYPT_FAIL_TESTVECTOR; } /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */ for (y = 0; y < 16; y++) tmp[0][y] = 0; for (y = 0; y < 1000; y++) rijndael_ecb_encrypt(tmp[0], tmp[0], &key); for (y = 0; y < 1000; y++) rijndael_ecb_decrypt(tmp[0], tmp[0], &key); for (y = 0; y < 16; y++) if (tmp[0][y] != 0) return CRYPT_FAIL_TESTVECTOR; } return CRYPT_OK; #endif } int rijndael_keysize(int *desired_keysize) { _ARGCHK(desired_keysize != NULL); if (*desired_keysize < 16) return CRYPT_INVALID_KEYSIZE; if (*desired_keysize < 24) { *desired_keysize = 16; return CRYPT_OK; } else if (*desired_keysize < 32) { *desired_keysize = 24; return CRYPT_OK; } else { *desired_keysize = 32; return CRYPT_OK; } } #endif sks-ecc-0.93/sks.10000644000175000017500000001213110715702751012624 0ustar nachonacho." Text automatically generated by txt2man-1.4.7 .TH SKS 1 "abril 21, 2006" "sks 0.92" "" .SH NAME \fBsks \- Provides public key encryption/authentication \fB .SH SYNOPSIS .nf .fam C \fBsks\fP \fIcommand\fP [\fIargs\fP] .fam T .fi .SH DESCRIPTION \fBsks\fP is a public key application for encryption/authentication, based on Elliptic Curve Cryptografy (ECC). Its minimalist design points to simple, light, fast, easy to use and multiplatform product, unencumbered by patents that is indeed distributed under GPL. All these features are given along with high quality cryptografy. .PP Its cryptografic elements are: .IP \(bu 3 Public key module: elliptic curve over GF (2^191) .IP \(bu 3 Simmetric key module: AES 192-bits key, with CTR mode .IP \(bu 3 Hash (for signatures, HMAC and passwords): TIGER (192 bits) .IP \(bu 3 PRNG module: /dev/urandom. User can provide her own entropy source .SH OPTIONS .TP .B \fB\-l\fP Shows license terms. .PP Commands in interactive mode .TP .B \fB\-c\fP|\fB-C\fP \fIpfile\fP \fIcfile\fP Ciphers conventionally \fIpfile\fP and outputs \fIcfile\fP. Uppercase precompress \fIpfile\fP. Password is asked. .TP .B \fB\-e\fP|\fB-E\fP \fIpfile\fP \fIcfile\fP [\fIkeyid\fP] [\.\.\.] Ciphers \fIpfile\fP with public \fBkey\fP(s) identified by \fIkeyid\fP(s). Output is driven to \fIcfile\fP. Uppercase precompress \fIpfile\fP. .TP .B \fB\-d\fP \fIcfile\fP \fIpfile\fP Deciphers \fIcfile\fP onto \fIpfile\fP, whatever the ciphering mode was. Password is asked. .TP .B \fB\-s\fP \fIpfile\fP \fIdsign\fP Signs \fIpfile\fP and outputs detached signature to \fIdsign\fP. Password is asked. .TP .B \fB\-S\fP \fIpfile\fP Signs printable \fIpfile\fP and outputs through stdout the clearsigned text. Password is asked. .TP .B \fB\-v\fP \fIpfile\fP \fIdsign\fP Verifies that \fIdsign\fP is a valid signature of \fIpfile\fP. A verify report is output to stderr. If verification is OK, date and key id. of signer are given. .TP .B \fB\-V\fP \fIpfile\fP Verifies clearsigned texts on \fIpfile\fP and outputs through stdout the original texts. Verify report are output to stderr. Wheather a good verification is found, date and key id. of signer are given. .TP .B \fB\-r\fP \fIpfile\fP [\.\.\.] Outputs the TIGER-hash of given \fIpfile\fP(s), in a 'md5sum' fashion. .PP Commands in filter mode. Text filter is introduced by \fB\-f\fP. Binary filter is introduced by \fB-b\fP .TP .B \fB\-fc\fP|\fB-fC\fP|\fB-bc\fP|\fB-bC\fP "\fIpassw\fP" Ciphers conventionally stdin with password string \fIpassw\fP, and gives output through stdout. Uppercase precompress input. .TP .B \fB\-fe\fP|\fB-fE\fP|\fB-be\fP|\fB-bE\fP [\fIkeyid\fP] [\.\.\.] Ciphers stdin with \fBpublic\fP(s) \fBkey\fP(s) identified by \fIkeyid\fP(s). Output is driven to stdout. Uppercase precompress input. .TP .B \fB\-fd\fP|\fB-bd\fP "\fIpassw\fP" Deciphers stdin onto stdout by means of password string \fIpassw\fP, whatever the ciphering mode was. .TP .B \fB\-fS\fP "\fIpassw\fP" Signs stdin with password string \fIpassw\fP, and outputs through stdout the clearsigned text. .TP .B \fB\-fV\fP Verifies clearsigned texts on stdin and outputs through stdout the original texts. Verify reports are output to stderr. Wheather a good verification is found, date and key id. of signer are given. .PP Commands to manage keyring. .TP .B \fB\-kg\fP Public/private key generation. It asks for a descriptive identifier and then asks for a password. Both can be input in a pipe through stdin: the first line is taken as the identifier and the second as the password. The public key is stored in keyring and is output to stdout. The private key is not stored. .TP .B \fB\-ki\fP \fIkeyfile\fP Imports all keys in \fIkeyfile\fP. Alternatively, \fIkeyfile\fP can be piped through stdin. .TP .B \fB\-kd\fP \fInumid\fP Deletes key identified by hexadecimal id. \fInumid\fP. .TP .B \fB\-kl\fP [\fIkeyid\fP] [\.\.\.] Lists the hexadecimal and description ids. of keys matched by \fIkeyid\fP(s). .TP .B \fB\-kf\fP [\fIkeyid\fP] [\.\.\.] List the fingerprint of keys matched by \fIkeyid\fP(s). Fingerprint is given in base 36, with ICAO alfabet. .TP .B \fB\-ke\fP [\fIkeyid\fP] [\.\.\.] Exports the keys matched by \fIkeyid\fP(s) through stdout. .SH HINTS All files are parsed in a streamish almost unbuffered mode. This means that in interactive mode, \fIpfile\fP and \fIcfile\fP must not coincide. Unpredictible results may occur otherwise. .PP All keys that matches the patterns given by \fIkeyid\fP parameters are selected. \fIkeyid\fP(s) can match partially hexadecimal and/or description identifiers. If no \fIkeyid\fP is given, all keys will be selected. Exception is \fB\-kd\fP \fIcommand\fP, that only admits one hexadecimal pattern that completely matches the target key hexadecimal id. .SH AUTHOR Written by Manuel Pancorbo Castro . .SH BUGS Report bugs to . .SH COPYRIGHT Copyright © 2004-2006 M. Pancorbo \- All Rights Reserved This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, Inc. .SH SEE ALSO Complete manual and design notes (in spanish): .PP .nf .fam C http://sks.merseine.nu sks-ecc-0.93/sks.c0000755000175000017500000005033510715702751012721 0ustar nachonacho/* SKS, by M.Pancorbo version 0.93 Changed math lib to "tomfastmath" who gives full-word alignment for the unit container (so, the number of bits/coefficients a unit has is actually 32 or 64 instead of 28 or 60). General improvement of 'gflib' with noteworthy performance gain. Among others, Karatsuba's techniques was introduced. Also, its code was a bit cleaned up. version 0.92c Corrected a bug when compiled in a 64-bit box. version 0.92b Corrected a bug when trying to encrypt small files. Now, gcc does not complain about rigourous warnings. Conversion UTF-8 -> iso-8859-1 has been avoided in linux version 0.92 Changed 'get_entropy'. Now it will use the prng-file, even with DEVRANDOM. In this case, the content of prng-file is XOR-ed with the output of the random device before hashing. The prng-file is restored/created at the end of the process. With no DEVRANDOM, 'get_entropy' makes the work as usual. LTM 'updated' to 0.35 and 'zlib' to 1.2.2 Improved 'gfMultiply' and 'gfSquare' functions; also 'ecMultiply' is a bit improved by using Minimal Average Weight representations. Gained a lot of performance! version 0.91 Changed point multiplication algorithm. Projective coordinates are introduced and pre-calculation of 16 first values. A bit of performance has been gained. version 0.90 Now, HMAC and encrypt keys are different. Backward compatibility is guaranteed version 0.86 Added binary filtering by '-b' flag. Only for encryption version 0.85 Changed 'get_entropy' when it uses no DEVRANDOM. Now, the junk post-buffer is saved in file and serves as initial junk buffer for further entropy requierements version 0.84 Now, fingerprint uses the less significant base-36 digits version 0.83 Improving of makefiles version 0.82 Stream decryption (-fd) accepts various blocks of encrypted text in the same stream. It applies the same input key to all of them. It only outputs the blocks with matching key after decryption. version 0.81 Source files rearranged version 0.80 Changed field to GF(2^191). Changed computation of key id. Added public key integrity check version 0.71 Added automatic UTF-8 -> iso-8859-1 conversion for error output. Also added iso-8859-1 -> CP851 conv. for DOS/Windows version 0.70 Added 'salt' to passwords. Passwords are pasted over a table containig first 2048 bits of PI; the remaining digits after pasting serve as 'salt'; the full buffer is hashed. version 0.60 AES and TIGER now builds their tables at "*_init()" first call. Longint numbers are now written in UTF-like fashion. version 0.50 Added 'TIGER' hash (instead of SHA256) P.K definition changes; old keys does not work version 0.40 Added compression (zlib) in a rough way (to be improved) Slight redefinition of interface version 0.30 First working application Public-Key cryptographic application PK-module: elliptic curve on GF(2^191), 95-bit strength (since version 0.80) Enc/dec: symmetric key: k·Q / public msg.: k·P = k·(d·Q) k: random multiplier / Q: point curve / P: public key, d: priv. key Signature DSA signature r-s: r = (k·Q)x, s = (k)·((m + d.r)^-1) Q: point curve / d: priv. key / m: MAC / k: random multiplier Hash: TIGER, 192 bits (firstly, sha256) Sym. mod.: CRT-aes128 -> C_i = P_i ^ AES128(K, IV + i); PRNG: /dev/random, wincrypt or ANSI-RNG Copyright (C) 2004-2007 Manuel Pancorbo Castro This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Manuel Pancorbo Castro */ #include "mycrypt.h" #include "binasc.h" #include "sks.h" #if (SKS_LANG==ES) #include "sks_msg_es.h" #else #include "sks_msg_en.h" #endif const char begin_armour [] = "###"; const char end_clearsign [] = "###-------------------------SKS SIG--------------------------###\n"; const char end_armour [] = "###-------------------------SKS CRYPT------------------------###\n\n"; extern keyring default_kr; const unsigned long pubkey_mode_id = 0x9e37799b; /** First 32 bits of golden ratio **/ const unsigned long symkey_mode_id = 0xc90fdaa2; /** First 32 bits of PI **/ ERROR do_make_pubkey(FILE *in, PubKey copy) { /* stores public key into keyring */ PrivKey priv; ERROR err; int coincid = 0; char *pattern[2]; keychain a; assert(in != NULL); if(copy == NULL){ get_text(in, a.lab, CHCONV(ask_label)); if(in == stdin) strcat(a.lab, "\n"); } while(1){ if((err = get_privkey(in, priv, CHCONV(ask_passw)))) return err; if(!eccMakePublicKey(a.val, priv)){ break;} else {fputs(CHCONV(err_improper_privkey), stderr);} } zerokey(priv); if(copy == NULL){ /* Put in keyring (rightly in file) */ /** Look for coincidences in actual keyring **/ int i; for(i = 0; i < default_kr.N; ++i){ if(!memcmp(a.val, default_kr.vector[i].val, KEY_SIZE)){ coincid = 1; break; } } get_keyid(a.val, &(a.id)); if(coincid){ fprintf(stderr, CHCONV(msg_key_exists)); fprintf(stderr, " [%08lx]: ", a.id); fputs(default_kr.vector[i].lab, stderr); fputs("\n", stderr); } else /*(coincid == 0)*/ { /** Add to keyring **/ add_to_keyring(&default_kr, &a ); /** Add to file **/ write_keyring(); pattern[1] = NULL; pattern[0] = &(a.lab[0]); search_pubkey(&default_kr, NULL, pattern, stdout, 'e'); } } else memcpy(copy, a.val, KEY_SIZE); burn_stack(500); return 0; } ERROR do_signature(FILE *f_inp, FILE *f_out, FILE *f_key, char **pattern) { PrivKey priv; vlPoint session, mac; time_t now; sgPair sig; ERROR err; unsigned long int id; int only_hash = 0; /** 1st, get the input priv. or pub. key and check **/ if(f_key != NULL){ get_privkey(f_key, priv, CHCONV(ask_passw)); /** Straightly get priv. key **/ } else if (pattern != NULL){ hash_password(pattern[0], priv); } else{ only_hash = 1; } if(!only_hash){ PubKey pub; int i, match = 0; /** 3. Get pub. key and id. **/ eccMakePublicKey(pub, priv); get_keyid(pub, &id); /** 3.b Checks if it matchs with some public key in keyring **/ if((err = load_keyring(NULL, &default_kr))){goto DO_SIGNATURE_BYE;} for(i = 0; i < default_kr.N; ++i){ if(id == default_kr.vector[i].id){ fprintf(stderr, "%s:", msg_sign_key); match = 1; break; } } fprintf(stderr, " [%08lx]\n", id); /** Anyway, go on **/ if(!match) fputs(msg_no_sign_key, stderr); } /** 4. Hash the input file **/ if(f_out != stdout){ /* operation == 's' or 'r' */ hash_binary_file(f_inp); } else{ /* operation == 'S' */ fprintf(f_out, "%s\n", begin_armour); hash_ascii_text(f_inp, f_out, 1); fputs(end_clearsign,f_out); } if(only_hash){ int i; hash_time(mac, 0L); /** Time = 0 means no hash_time. Only closes hash and returns **/ for(i = 0; i < HASH_SIZE; ++i){ fprintf(stdout, "%02x", (unsigned char) mac[i]); } return 0; } /** 5. Get the time, hash it and harvest the result **/ now = time(NULL); hash_time(mac, now); /** "mac" has the hash-concatenation of file+time **/ /** 6. Sign it! **/ do{ if(!get_entropy(session, KEY_SIZE)){ err = -1; goto DO_SIGNATURE_BYE;} err = eccSign(priv, session, mac, &sig); } while (err); /** 7. Output it **/ write_longint(f_out, id, 0); /** First, key id. **/ write_timestamp(f_out, now); write_signature(f_out, &sig); DO_SIGNATURE_BYE: zerokey(priv); burn_stack(200); return err; } ERROR do_verify(int operation, FILE *f_inp, FILE *f_out, FILE *f_sec) { vlPoint mc; sgPair sig; ERROR err; int ver = 0, coincid, *index;; time_t now; unsigned long int id; char idstring[16], *pattern[2]; FILE *sfile; /** 0. Load key ring **/ if((err = load_keyring(NULL, &default_kr))) return err; /** 1. Hash the input file & read key id., timestamp and signature **/ if(operation == 'v'){ hash_binary_file(/*c,*/ f_inp); sfile = f_sec; } else{ /* operation == 'V' */ if((err = position(f_inp, begin_armour))){ fputs( CHCONV(err_clearsig_header_not_found), stderr ); return err; } hash_ascii_text( f_inp, f_out, 0); sfile = f_inp; } read_longint(sfile, &id, 0); read_timestamp(sfile, &now); read_signature(sfile, &sig, 0); hash_time(mc, now); /** "mc" has the hash-concatenation of file+time **/ /** 2. Look for key in keyring **/ sprintf(idstring, "%08lx", id); pattern[0] = &(idstring[0]); pattern[1] = NULL; index = malloc(default_kr.N * sizeof(int)); coincid = search_pubkey(&default_kr, index, pattern, stderr, 'l'); if(coincid == -1) return -1; else if (coincid == 0){ fprintf(stderr, "[%08lx]: %s", id, CHCONV(err_no_key)); return -1; } /** 3. Check signature **/ while(coincid){ /** Normally, coincid = 1 **/ ver |= eccVerify(default_kr.vector[index[coincid - 1]].val, mc, &sig); if(ver) break; --coincid; } free(index); if(!ver){ fputs(CHCONV(err_signature), stderr); err = -3; } else{ char buf[SMALL_BUF]; fputs(CHCONV(msg_signature_verifies), stderr); /*strftime(buf, SMALL_BUF, "%F, %R", gmtime(&now));*/ strftime(buf, SMALL_BUF, "%Y-%m-%d, %H:%M", gmtime(&now)); fputs(buf, stderr); /*fputs(ctime(&now), stderr); */ fputs("\n", stderr); err = 0; } burn_stack(200); return err; } ERROR do_encrypt(FILE *f_inp, FILE *f_out, FILE *f_key, char **pattern, int ciph_mode) { vlPoint session, *msg; PubKey *pub; int sym_mode, binmode, coincid, i, *index; ERROR err = 0; /** 0. Load key ring **/ if((err = load_keyring(NULL, &default_kr))) return err; /** 1. Write the header **/ binmode = (ciph_mode & BINARY_FLAG); /*(f_inp == stdin)? 0: 1;*/ if(!binmode) fprintf(f_out, "%s\n", begin_armour); sym_mode = ciph_mode & SYM_MODE; /*ciph_mode = ciph_mode & 0xff;*/ /** 2. get the input pub. key **/ if(sym_mode == PK_MODE){ /** public-key mode **/ fputs(CHCONV(msg_elected_keys), stderr); /** Firstly, identify file as pk-encrypted by 'sks' **/ write_longint(f_out, pubkey_mode_id, binmode); index = malloc(default_kr.N * sizeof(int)); coincid = search_pubkey(&default_kr, /*&pub*/ index, pattern, stderr, 'l'); if(coincid < 0) return -1; /** This cannot happen **/ if(coincid == 0) {fputs(CHCONV(err_no_key), stderr); return -1;} write_longint(f_out, (long) coincid /*pub.N*/, binmode); pub = malloc(coincid * sizeof(PubKey)); msg = malloc(coincid * sizeof(PubKey)); for(i = 0; i < /*pub.N*/ coincid; ++i){ memcpy(pub[i], default_kr.vector[index[i]].val, KEY_SIZE); write_longint(f_out, default_kr.vector[index[i]].id, binmode); } /** 3. random junk **/ if(!get_entropy(session, KEY_SIZE)) return -1; /** 4. encode secret **/ eccEncode(pub /*.val*/, msg /*.val*/, session, /*pub.N*/ coincid); /** 5. Write the coded secrets **/ for(i = 0; i < /*msg.N*/ coincid; ++i){ fwritePlus( msg[i], 1, KEY_SIZE, f_out, binmode); } free(pub); free(msg); free(index); } else{ /** Symmetric mode **/ if(f_key != NULL){ if((err = get_privkey(f_key, session, CHCONV(ask_passw)))) return err; } else if(pattern != NULL){ if((err = hash_password(pattern[0], session))) return err; } else fputs("This cannot happen!!\n", stderr); hash_binary(session, session, KEY_SIZE); /** One more hashing **/ write_longint(f_out, symkey_mode_id, binmode); } /** 6. Call sym. cipher **/ err = sym_encrypt(f_inp, f_out, session, ciph_mode); zerokey(session); /** 7. Write termination and bye **/ if(!binmode) fputs(end_armour,f_out); burn_stack(200); return err; } ERROR do_decrypt(FILE *f_inp, FILE *f_out, FILE *f_key, char **passw, int binmode) { PrivKey priv; ecPoint msg; vlPoint session; char buf[SMALL_BUF]; int size, i, index = -1, /*binmode, */ found_armour = 0, found_id = 0, found_key = 0, got_priv = 0; unsigned long int nkeys, id, prov_id = 0; ERROR err = 0; /** 1. Read the header **/ /*binmode = (f_inp == stdin)? 0: 1; */ DO_DECRYPT_CONTINUE: if(!binmode){ if((position(f_inp, begin_armour))){ /*fputs( CHCONV(err_clearsig_header_not_found), stderr ); return err; */ goto DO_DECRYPT_ERROR; /*break;*/ } if(!found_armour){ ++found_armour; } } /** 2. get the priv. key **/ if(f_inp == stdin){ if(!got_priv){ hash_password(passw[0], priv); got_priv = 1; } } else{ get_privkey(f_key, priv, CHCONV(ask_passw)); } read_longint(f_inp, &id, binmode); /*fprintf(stderr, "Identificador: %lx\n", id);*/ if (id == pubkey_mode_id){ ++found_id; /** 3. Read the header data **/ read_longint(f_inp, &nkeys, binmode); /** 4. Make the pub. key for provided priv. key **/ if(prov_id == 0){ eccMakePublicKey(msg, priv); /** 'msg' is provisional pub. key **/ get_keyid(msg, &prov_id); zerokey(msg); } /** 5. Check with in-file pub. keys **/ index = -1; for(i = 0; i < nkeys; ++i){ read_longint(f_inp, &id, binmode); fprintf(stderr, "[%08lx]: ", id); if(id == prov_id){ index = i; fputs("*", stderr); } fputs("\n", stderr); } if(index == -1){ fputs(CHCONV(err_no_key), stderr); /*return -1;*/ err = -1; if(!binmode){ while(!feof(f_inp)){ fgets(buf, SMALL_BUF, f_inp); /*fprintf(stderr, "Línea: %s\n", buf);*/ if(!strncasecmp(buf, end_armour, strlen(end_armour) - 2)) break; } burnBinasc(); goto DO_DECRYPT_CONTINUE; } else return -1; } ++found_key; /** 6. Read the encoded secret **/ for(i = 0; i < nkeys; ++i){ size = KEY_SIZE; freadPlus(buf, 1, size, f_inp, binmode); if(i == index) memcpy(msg, buf, size); } /** 7. Decode secret **/ eccDecode(priv, msg, session); zerokey(msg); } else if (id == symkey_mode_id){ ++found_id; hash_binary(session, priv, KEY_SIZE); } else{ err = -1; /*goto DO_DECRYPT_ERROR;*/ } /** 8. Call sym. cipher and bye **/ if(found_key > 1) fputs("\n\t\t* * *\n", f_out); err = sym_decrypt(f_inp, f_out, session, binmode); zerokey(session); if(err) fputs(CHCONV(err_data_corrupted), stderr); if(!binmode){ zeromem(buf, SMALL_BUF); fgets(buf, SMALL_BUF, f_inp); /*fprintf(stderr, "Resto de fichero: - %s\n", buf);*/ goto DO_DECRYPT_CONTINUE; } DO_DECRYPT_ERROR: zerokey(priv); if(!found_armour && !binmode){ fputs( CHCONV(err_clearsig_header_not_found), stderr ); } else if(!found_id && err){ fputs(CHCONV(err_bad_encrypted_file), stderr); } /*else if(!found_key && err){ fputs(CHCONV(err_no_key), stderr); }*/ else if(!binmode){ fprintf(stderr, "%s%d\n", CHCONV(msg_num_decrypt_messages), found_key); } burn_stack(200); return err; } int main( int argc, char ** argv/*, char *envp[] */) { int err = 0, operation, filter=0, binary=BINARY_FLAG; FILE * f_key = NULL, * f_inp, * f_out, *f_sec = NULL; char openForRead [3] = "rb"; char openForWrite [3] = "wb"; /*char openKey[3] = "r";*/ char **pattern = NULL; /** I've blocked this checking until charset conversion is improved **/ /*test_charset();*/ /*if((err = load_keyring(NULL, &default_kr))) return err;*/ if ( argc<2 || argv[1][0] != '-') { error: if(filter) goto filterError; fputs( CHCONV( manual), stderr); /**err = 1; goto adios;**/ return 5; } operation = argv[1][1]; if(('f' == operation) || ('b' == operation)) { int pos = 2; if ('f' == operation){ filter = 1; binary = 0; } else{ filter = 2; } operation = argv[1][pos]; if(0 == argv[1][pos]){ filterError: fputs(CHCONV(filterManual), stderr); err = 1; goto adios; } } else if ( operation == 'l' ){ fputs(CHCONV(gplDisclaimer), stderr); goto adios; } else if ( operation == 'k' ){ if((err = load_keyring(NULL, &default_kr))) return err; if('g' == argv[1][2]){ if((err = do_make_pubkey(stdin, NULL))){ fputs(CHCONV(err_key), stderr); goto adios; } search_pubkey(&default_kr, NULL, NULL, stderr, 'l'); } else if(('e' == argv[1][2]) || ('l' == argv[1][2]) || ('f' == argv[1][2])){ if (argc > 2) search_pubkey(&default_kr, NULL, argv + 2, stdout, argv[1][2]); else search_pubkey(&default_kr, NULL, NULL, stdout, argv[1][2]); } else if('i' == argv[1][2]){ if(argc == 3){ if((f_inp = chkopen(argv[2], openForRead)) == NULL) {err = -1; goto adios;} } else f_inp = stdin; err = import_keyring(f_inp); } else if('d' == argv[1][2]){ char *num; if(argc == 3) num = argv[2]; else num = NULL; if((err = delete_element(num))) fputs(CHCONV(err_no_key), stderr); } else{ fputs(CHCONV(keyManual), stderr); char buf[SMALL_BUF]; get_full_path(KEYRING, buf); fprintf(stderr, " %s: %s\n", keyfile_title, buf); err = 1; } goto adios; } else if (argv[1][2] != 0) goto error; /** Check expected parameters and assign streams **/ if(1 == filter){ if((operation == 'e') || (operation == 'E') ){ if(argc < 2) goto error; else if(argc == 2) pattern = NULL; else pattern = argv + 2; } else if((operation != 'd') && (operation != 'D') && (operation != 'S') && (operation != 'V') && (operation != 'c') && (operation != 'C') ){ goto error; } else if(operation != 'V'){ if(argc < 3) goto error; pattern = argv + 2; } f_inp = stdin; f_out = stdout; f_key = NULL; } else if(2 == filter){ if((operation == 'e') || (operation == 'E') ){ if(argc < 2) goto error; else if(argc == 2) pattern = NULL; else pattern = argv + 2; } else if((operation != 'd') && (operation != 'D') && (operation != 'c') && (operation != 'C') ){ goto error; } else{ if(argc < 3) goto error; pattern = argv + 2; } f_inp = stdin; f_out = stdout; f_key = NULL; } else{ if((operation == 'S') || (operation == 'V')){ if(argc != 3) goto error; f_out = stdout; f_key = stdin; } else if(operation == 'v'){ if(argc != 4) goto error; if((f_sec = chkopen(argv[3], openForRead)) == NULL){err = -1; goto adios;} f_out = NULL; } else if((operation == 'c') ||(operation == 'C') || (operation == 'd') || (operation == 'D') ||(operation == 's') ) { if(argc != 4) goto error; f_key = stdin; if((f_out = chkopen(argv[3], openForWrite)) == NULL){err = -1; goto adios;} pattern = NULL; } else if(operation == 'r'){ if(argc < 3) goto error; f_out = NULL; f_key = NULL; pattern = NULL; } else if ((operation == 'e') || (operation == 'E') ) { if(argc < 4) goto error; f_key = NULL; if((f_out = chkopen(argv[3], openForWrite)) == NULL){err = -1; goto adios;} if(argc == 4) pattern = NULL; else pattern = argv + 4; } else goto error; if((f_inp = chkopen(argv[2], openForRead)) == NULL){err = -1; goto adios;} } /**** Operations ****/ /** SIGN **/ if((operation == 's') || (operation == 'S') ){ err = do_signature(f_inp, f_out, f_key, pattern); } /** HASH **/ else if(operation == 'r'){ int i; for( i = 2; i < argc; ++i){ if((f_inp = chkopen(argv[i], openForRead)) == NULL){err = -1; continue;} if((err = do_signature(f_inp, f_out, f_key, pattern))) goto adios; fclose(f_inp); fprintf(stdout, " %s\n", argv[i]); } } /** VERIFY **/ else if((operation == 'v') || (operation == 'V')) err = do_verify(operation, f_inp, f_out, f_sec); /** CRYPTO **/ else if(operation == 'e') {err = do_encrypt(f_inp, f_out, f_key, pattern, PK_MODE | AES128_CTR2 | binary);} else if(operation == 'E') {err = do_encrypt(f_inp, f_out, f_key, pattern, PK_MODE | AES128_CTR2 | COMPRESS_FLAG | binary);} else if((operation == 'd') || (operation == 'D') ) {err = do_decrypt(f_inp, f_out, f_key, pattern, binary);} /** SYMETRIC OPERATIONS **/ else if(operation == 'c') {err = do_encrypt(f_inp, f_out, f_key, pattern, SYM_MODE | AES128_CTR2 | binary);} else if(operation == 'C') {err = do_encrypt(f_inp, f_out, f_key, pattern, SYM_MODE | AES128_CTR2 | COMPRESS_FLAG | binary);} /** This cannot happen **/ else goto error; adios: eccQuit(); close_keyring(&default_kr); burn_stack(2000); burnBinasc(); return err; } sks-ecc-0.93/sks.h0000644000175000017500000001036210715702751012717 0ustar nachonacho/* sks.h Copyright (C) 2004-2007 Manuel Pancorbo Castro This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Manuel Pancorbo Castro */ #ifndef __SKS_H #define __SKS_H #define PROGRAM_NAME "SKS" #define COPYRIGHT \ PROGRAM_NAME " v" VERSION " Copyright (C) 2004-2006 Manuel Pancorbo Castro\n" #ifdef LINUX #include #define HOME_VAR "HOME" #define KEYRING "/.skspkr" #define PRNGFILE "/.sksprng" #elif defined WIN32 #define HOME_VAR "APPDATA" #define KEY_DIR "\\SKS" #define KEYRING "\\pubkeys.txt" #define PRNGFILE "\\prng.bin" #else #error "WIN32 or LINUX must be defined" #endif /*? LINUX*/ #include "eccrypt.h" #define HASH_SIZE GF_SIZE /* 32 */ #define BLOCK_SIZE 16 #define HMAC_SIZE 20 /* Less or equal than HASH_SIZE */ #define PASSWD_SIZE 0x100 #define KEY_SIZE GF_SIZE #define SMALL_BUF 0x100 #define MEDIUM_BUF 0x4000 #define LARGE_BUF 0x40000 #define MAX_ALLOC_SIZE 0x100000L /** 1 Mbyte **/ #define DEFAULT_COMP_LEVEL 9 /** From 1-9 **/ /** ** Internal identifiers. No RCF, ISO, NIST recommendation at all **/ #define SHA256_CTR (0x7F) /** Actually not used **/ #define AES128_CTR (0x71) #define AES128_CTR2 (0x73) /** As AES128_CTR but uses different keys for encrytion and HMAC **/ #define COMPRESS_FLAG (0x80) #define BINARY_FLAG (0x200) #define PK_MODE 0 #define SYM_MODE 0x100 typedef struct { char lab[SMALL_BUF]; PubKey val; unsigned long int id; } keychain; typedef struct{ keychain *vector, *actual; int N; } keyring; typedef unsigned char hashout[HASH_SIZE]; typedef unsigned char byte; /** Input functions **/ ERROR get_text(FILE *inp, char *frase, const char *msg); ERROR get_privkey(FILE *inp, PrivKey p, const char *msg); /** Hash functions **/ ERROR hash_binary(byte *buf, byte *bin, size_t len); ERROR hash_binary_file( FILE *inp); ERROR hash_password(char *, PrivKey); ERROR hash_ascii_text( FILE * f_inp, FILE * f_out, int write); ERROR hash_time (vlPoint c, time_t t); /** Entropy function **/ int get_entropy(unsigned char *seed, size_t nbytes); /** AES cipher functions **/ int aes_close(byte *, byte *, int); ERROR aes_init(byte *, byte *, unsigned int, byte *); ERROR aes_process(byte *, int, int); ERROR sym_encrypt(FILE *, FILE *, PubKey, int); ERROR sym_decrypt(FILE *, FILE *, PubKey, int); /** Keyring functions **/ FILE * chkopen( char * s, char * mode ); void get_full_path(char * name, char * buf); FILE * open_keyring(char * mode ); FILE * open_prngfile(void); ERROR write_pubkey(FILE *, keychain *); ERROR get_pubkey(FILE *, keychain *); ERROR get_keyid(PubKey key, unsigned long *id); ERROR new_key_chain(keyring *kr); void close_keyring(keyring *kr); ERROR add_to_keyring(keyring *kr, keychain *); ERROR load_keyring(FILE *inp, keyring *kr); ERROR write_keyring(); int search_pubkey(keyring *, int *, char **, FILE *, int); ERROR import_keyring(FILE *inp); ERROR delete_element(char *idstring); /** Most utility functions **/ void write_longint(FILE *ptr, unsigned long int x, int binmode); int read_longint(FILE *ptr, unsigned long int *x, int binmode); #define write_timestamp(A, B) write_longint(A, (unsigned long int )B, 0) #define read_timestamp(A, B) read_longint(A, (unsigned long int *)B, 0) ERROR write_signature(FILE *ptr, sgPair *sig); ERROR read_signature(FILE *ptr, sgPair *sig, int binmode); int position(FILE * ,/* FILE *,*/ const char *); int str_match(char *s1, char *s2); ERROR fputs_base36(PubKey a, FILE *out); void burn_stack(unsigned long len); void test_charset(); char * utf8_to_latin1( char *); #define CHCONV(A) utf8_to_latin1(A) #define zerokey(A) memset(A, 0, KEY_SIZE) enum { ES = 0, EN }; #endif /* ? _SKS_H */ sks-ecc-0.93/sks_msg_en.h0000644000175000017500000001246010715702751014250 0ustar nachonacho char manual /*:)*/ [] = COPYRIGHT PROGRAM_NAME " comes with ABSOLUTELY NO WARRANTY; for details\n" "type `sks -l'. This is free software, and you are welcome\n" "to redistribute it under certain conditions; type `sks -l'\n" "for details.\n\n" "Usage:\n" " conventional encrytion\n" " -c plain cipher < password\n" " -C (with compression)\n" " public-key encryption\n" " -e plain cipher [id 1] [id 2] ... [id n]*\n" " -E (with compression)\n" " decryption (all cases)\n" " -d cipher plain < password\n" " sign/verify/hash\n" " -s plain signature < password\n" " -S text < password > clearsigned-text\n" " -v plain signature\n" " -V clearsigned-text >text\n" " -r file1 file2 ... file-n > hexadecimal hash (TIGER)\n" " -f[operation] [type " PROGRAM_NAME " -f for details]\n" " -b[operation] [type " PROGRAM_NAME " -b for details]\n" " -k[operation] [type " PROGRAM_NAME " -k for details]\n" " (*) All keys that fulfill any pattern will be elected.\n" " No pattern means all keys\n"; char filterManual [] = COPYRIGHT "\n" "Usage [ascii filter sub-mode]:\n" " conventional encrytion\n" " -fc \"password\" ascii-cipher\n" " -fC (with compression)\n" " public-key encryption\n" " -fe [id 1] [id 2] ... [id n]* ascii-cipher\n" " -fE (with compression)\n" " decryption (all cases)\n" " -fd \"password\" plain\n" " sign/verify\n" " -fS \"password\" clearsigned-text\n" " -fV text\n" "[ascii filter sub-mode]:\n" " conventional encrytion\n" " -bc \"password\" cipher\n" " -bC (with compression)\n" " public-key encryption\n" " -be [id 1] [id 2] ... [id n]* cipher\n" " -bE (with compression)\n" " decryption (all cases)\n" " -bd \"password\" plain\n" " (*) All keys that fulfill any id. pattern will be elected.\n" " No pattern means all keys\n"; char keyManual [] = COPYRIGHT "\n" "Usage [key sub-mode]:\n" " key generation\n" " -kg < key id. / key passw. > key \n" " key listing\n" " -kl [id 1] [id 2] ... [id n]* > list\n" " fingerprint key listing (base-36, ICAO mode)\n" " -kf [id 1] [id 2] ... [id n]* > list\n" " key export\n" " -ke [id 1] [id 2] ... [id n]* > keys\n" " key import\n" " -ki keyfile < keyfile (alternatively)\n" " delete key\n" " -kd number_id < number_id (alternatively)\n" " (*) All keys that fulfill any pattern will be elected.\n" " No pattern means all keys\n"; char gplDisclaimer [] = "\n" "This program is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU General Public License\n" "as published by the Free Software Foundation; either version 2\n" "of the License, or (at your option) any later version.\n\n" "This program is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "GNU General Public License for more details.\n\n" "You should have received a copy of the GNU General Public License\n" "along with this program; if not, write to the Free Software\n" "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"; char keyfile_title [] = PROGRAM_NAME ". Keyfile"; char confirm_passw[] = PROGRAM_NAME ". Confirm password...\n"; char ask_passw[] = PROGRAM_NAME ". Input your password: "; char ask_label[] = PROGRAM_NAME ". Input identifying label: "; char ask_idnum[] = PROGRAM_NAME ". Input one numeric id.: "; char err_output [] = PROGRAM_NAME ", error writing output, disk full?\n"; char err_open_failed [] = PROGRAM_NAME ", error: failed to open "; char err_bad_public_key [] = PROGRAM_NAME ", error: public key must start with: "; char err_corr_public_key [] = PROGRAM_NAME ", error: public key corrupted\n"; char err_bad_encrypted_file [] = PROGRAM_NAME ", error: bad encrypted file\n"; char err_bad_mac [] = PROGRAM_NAME ", error: bad authentication code\n"; char err_data_corrupted [] = PROGRAM_NAME ", error: data corrupted\n"; char err_signature [] = PROGRAM_NAME ", error: signature did not verify\n"; char err_bad_keyring [] = PROGRAM_NAME ", error: not formatted keyring\n"; char err_no_key [] = PROGRAM_NAME ", error: no key matching\n"; char err_decrypt [] = PROGRAM_NAME ", error: decryption failed\n"; char err_key[] = PROGRAM_NAME ", error: key generation failed\n"; char err_improper_privkey [] = PROGRAM_NAME ", error: your password provided improper private key. Please enter another password\n"; char err_clearsig_header_not_found [] = PROGRAM_NAME ", error: clearsignature header \"###\" not found\n"; char msg_elected_keys [] = PROGRAM_NAME ". Elected keys:\n"; char msg_signature_verifies [] = PROGRAM_NAME " OK. signature made at: "; char msg_key_exists [] = PROGRAM_NAME ". Key exists in actual keyring with following id.:\n\n"; char msg_added_key [] = PROGRAM_NAME " *** Added key..."; char msg_deleted_key [] = PROGRAM_NAME " *** Deleted key\n\n"; char msg_sign_key [] = PROGRAM_NAME ". Signing key"; char msg_num_decrypt_messages[] = PROGRAM_NAME ". Number of decrypted messages: "; char msg_no_sign_key [] = PROGRAM_NAME ". The input password does not correspond to any key in keyring\n" "Anyway, signing goes on\n"; sks-ecc-0.93/sks_msg_es.h0000644000175000017500000001371310715702751014257 0ustar nachonacho/* * Spanish manual in UTF-8 codification * Manual en español (UTF8) */ char manual /*:)*/ [] = COPYRIGHT PROGRAM_NAME " se suministra sin NINGUNA GARANTÃA; para más detalles,\n" "ejecuta `sks -l'. Esto es software libre, y su distribución\n" "está permitida bajo ciertas condiciones; ejecuta `sks -l'\n" "para más detalles.\n\n" "Modo de uso:\n" " cifrado convencional\n" " -c claro cifrado < contraseña \n" " -C (compresión previa de datos)\n" " cifrado de clave pública\n" " -e claro cifrado [id 1] [id 2] ... [id n]* \n" " -E (compresión previa de datos)\n" " descifrar (todos los casos)\n" " -d cifrado claro < contraseña\n" " firmar/verificar/resumir\n" " -s claro firma < contraseña\n" " -S texto < contraseña > texto-firmado\n" " -v claro firma\n" " -V texto-firmado >texto\n" " -r fichero1 fichero2 ... fichero-n > resumen hexadecimal (TIGER)\n" " -f[operación] [introduce " PROGRAM_NAME " -f para más detalles]\n" " -b[operación] [introduce " PROGRAM_NAME " -b para más detalles]\n" " -k[operación] [introduce " PROGRAM_NAME " -k para más detalles]\n" " (*) Será seleccionada toda clave que contenga cualquier identificador\n" " La ausencia de identificador selecciona todas las claves\n"; char filterManual [] = COPYRIGHT "\n" "Modo de uso [filtrado ascii]:\n" " cifrado convencional\n" " -fc \"contraseña\" cifrado-ascii\n" " -fC (compresión previa de datos)\n" " cifrado de clave pública\n" " -fe [id 1] [id 2] ... [id n]* cifrado-ascii\n" " -fE (compresión previa de datos)\n" " descifrar (todos casos)\n" " -fd \"contraseña\" claro\n" " firmar/verificar\n" " -fS \"contraseña\" texto-firmado\n" " -fV texto\n" "[filtrado binario]:\n" " cifrado convencional\n" " -bc \"contraseña\" cifrado\n" " -bC (compresión previa de datos)\n" " cifrado de clave pública\n" " -be [id 1] [id 2] ... [id n]* cifrado\n" " -bE (compresión previa de datos)\n" " descifrar (todos casos)\n" " -bd \"contraseña\" claro\n" " (*) Será seleccionada toda clave que contenga cualquier identificador\n" " La ausencia de identificador selecciona todas las claves\n"; char keyManual [] = COPYRIGHT "\n" "Modo de uso [gestión de claves]:\n" " generación de clave\n" " -kg < id. de clave / contraseña > clave\n" " listado de claves\n" " -kl [id 1] [id 2] ... [id n]* > lista\n" " listado base-36 de claves (huella digital en modo ICAO)\n" " -kf [id 1] [id 2] ... [id n]* > lista\n" " exportación de claves\n" " -ke [id 1] [id 2] ... [id n]* > claves\n" " importación de claves\n" " -ki fichero-de-claves < fichero-de-claves (alternativamente)\n" " borrar clave\n" " -kd id.-numérico < id.-numérico (alternativamente)\n" " (*) Será seleccionada toda clave que contenga cualquier identificador\n" " La ausencia de identificador selecciona todas las claves\n"; char gplDisclaimer [] ="\n" "Este programa es software libre; puedes redistruirlo y/o\n" "modificarlo bajo los términos de la Licencia Pública General GNU,\n" "tal y como está publicada por la Free Software Foundation; ya sea la\n" "versión 2 de la Licencia, o (a tu elección) cualquier versión\n" "posterior.\n\n" "Este programa se distribuye con la intención de ser útil, pero SIN\n" "NINGUNA GARANTÃA; incluso sin la garantía implícita de USABILIDAD O\n" "UTILIDAD PARA UN FIN PARTICULAR. Véase la Licencia Pública General GNU\n" "para más detalles.\n\n" "Deberías haber recibido una copia de la Licencia Pública General\n" "GNU junto a este programa; si no es así, escribe a la Free Software\n" "Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, EEUU.\n"; char keyfile_title [] = PROGRAM_NAME ". Fichero de claves"; char confirm_passw[] = PROGRAM_NAME ". Confirma contraseña...\n"; char ask_passw[] = PROGRAM_NAME ". Introduce tu contraseña: "; char ask_label[] = PROGRAM_NAME ". Introduce etiqueta identificadora: "; char ask_idnum[] = PROGRAM_NAME ". Introduce un id. numérico: "; char err_output [] = PROGRAM_NAME ", error de escritura, ¿disco lleno?\n"; char err_open_failed [] = PROGRAM_NAME ", error: fallo al abrir "; char err_bad_public_key [] = PROGRAM_NAME ", error: la clave pública debe comenzar por: "; char err_corr_public_key [] = PROGRAM_NAME ", error: la clave pública puede estar dañada\n"; char err_bad_encrypted_file [] = PROGRAM_NAME ", error: fichero mal cifrado\n"; char err_bad_mac [] = PROGRAM_NAME ", error: falló autenticación\n"; char err_data_corrupted [] = PROGRAM_NAME ", error: datos corruptos\n"; char err_signature [] = PROGRAM_NAME ", error: firma no verificable\n"; char err_bad_keyring [] = PROGRAM_NAME ", error: anillo de claves erróneo\n"; char err_no_key [] = PROGRAM_NAME ", error: no se encuentra clave\n"; char err_decrypt [] = PROGRAM_NAME ", error: falló descifrado\n"; char err_key[] = PROGRAM_NAME ", error: falló generación de clave\n"; char err_improper_privkey [] = PROGRAM_NAME ", error: la contraseña genera una clave privada inapropiada; por favor, elige otra contraseña\n"; char err_clearsig_header_not_found [] = PROGRAM_NAME ", error: no se encuentra la cabecera de firma \"###\"\n"; char msg_elected_keys [] = PROGRAM_NAME ". Claves seleccionadas:\n"; char msg_signature_verifies [] = PROGRAM_NAME ". Firma correcta realizada en: "; char msg_key_exists [] = PROGRAM_NAME ". Esta clave existe en el anillo actual con el siguiente id.:\n"; char msg_added_key [] = PROGRAM_NAME " *** Clave añadida..."; char msg_deleted_key [] = PROGRAM_NAME " *** Clave borrada\n\n"; char msg_sign_key [] = PROGRAM_NAME ". Clave de firma"; char msg_num_decrypt_messages[] = PROGRAM_NAME ". Número de mensajes descifrados: "; char msg_no_sign_key [] = PROGRAM_NAME ". La contraseña introducida no se corresponde con ninguna clave del anillo\n" "El proceso de firma continúa\n"; sks-ecc-0.93/skspkr0000755000175000017500000000071510715702751013212 0ustar nachonacho-----SKS KEY----- key: 8V8p0Kw0yp/1PWnb5rclFT694WDjScEi4hrP Prueba -----SKS KEY----- key: bOKoAFmL259zVgL1BUBHkv0Csy5a5ZHCpIbj Hola Mundo /hola mundo/ -----SKS KEY----- key: xkrhNQDF7OaJU5mCb5yLMjZoEF8GqXhXUDoC Hello World /hello world/ -----SKS KEY----- key: il8XBZKD5ZdRsmVtvVE22qK+ZjWA4YzCHL4l Jose Luis Torrente /amiguete/ -----SKS KEY----- key: Aa86V48h3xy+5uoQIzXgiKCBSQN3gm7WqEzh Manuel Pancorbo Castro sks-ecc-0.93/skstest.c0000644000175000017500000001524710715702751013621 0ustar nachonacho/* **** */ #include #include "mycrypt.h" #include "sks.h" /*#include "ec_mpcrypt.h"*/ #ifdef LANG_ES #include "sks_msg_es.h" #else #include "sks_msg_en.h" #endif #define eccRandom(A) get_entropy(A, GF_SIZE) int ec_cryptCheck(int test_count) { int i, crypt_fail = 0, sign_fail = 0; clock_t elapsed_crypt = 0L, elapsed_sign = 0L, elapsed_key = 0L; PubKey pub; PrivKey priv; vlPoint sec1, sec2, msg; sgPair sig; ecPoint cod; eccInit(); srand ((unsigned)(time(NULL) % 65521U)); fprintf(stderr, " Encryption based on Elliptic Curve Group. GF(2^%d)\n", GF_M); fprintf(stderr, " Bits per digit: %d\n", DIGIT_BIT); fprintf(stderr, " Checking %d times...\n", test_count); for(i = 0; i < test_count; ++i){ /** Make key **/ eccRandom(priv); elapsed_key -= clock(); eccMakePublicKey(pub, priv); elapsed_key += clock(); /** crypt/decrypt **/ eccRandom(sec1); elapsed_crypt -= clock(); eccEncode(&pub, &cod, sec1, 1); eccDecode(priv, cod, sec2); elapsed_crypt += clock(); if(memcmp(sec1, sec2, GF_SIZE)){ crypt_fail++; #ifdef DEBUG eccPrint("sec1", sec1); eccPrint("sec2", sec2); #endif } /** sign/verify **/ eccRandom(msg); int ver; do{ eccRandom(sec1); elapsed_sign -= clock(); ver = eccSign(priv, sec1, msg, &sig); elapsed_sign += clock(); } while(ver); elapsed_sign -= clock(); ver = eccVerify(pub, msg, &sig); elapsed_sign += clock(); if(!ver) sign_fail++; } printf (" Done.\n Encrypt-Decrypt time: %.3f s/cicle.\n", (float)elapsed_crypt/CLOCKS_PER_SEC/(test_count)); printf (" Sign/Verify time: %.3f s/cicle.\n", (float)elapsed_sign/CLOCKS_PER_SEC/(test_count)); printf (" Key generation time: %.3f s/key.\n", (float)elapsed_key/CLOCKS_PER_SEC/(test_count)); if (crypt_fail) printf (" ---> %d fails in encryption/decryption <---\n", crypt_fail); if (sign_fail) printf (" ---> %d fails in signing /verifying <---\n", sign_fail); eccQuit(); return crypt_fail | sign_fail; } int myaes_test(void) { int err; static const struct { int keylen; unsigned char key[32], pt[16], ct[16]; } tests[] = { { 16, { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, { 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30, 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a } }, { 24, { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }, { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, { 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0, 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91 } }, { 32, { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }, { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf, 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 } } }; symmetric_key key; unsigned char tmp[2][16]; int i, y; for (i = 0; i < (int)(sizeof(tests)/sizeof(tests[0])); i++) { zeromem(&key, sizeof(key)); if ((err = rijndael_setup(tests[i].key, tests[i].keylen, 0, &key)) != CRYPT_OK) { return err; } rijndael_ecb_encrypt(tests[i].pt, tmp[0], &key); rijndael_ecb_decrypt(tmp[0], tmp[1], &key); if (memcmp(tmp[0], tests[i].ct, 16) || memcmp(tmp[1], tests[i].pt, 16)) { return CRYPT_FAIL_TESTVECTOR; } /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */ for (y = 0; y < 16; y++) tmp[0][y] = 0; for (y = 0; y < 1000; y++) rijndael_ecb_encrypt(tmp[0], tmp[0], &key); for (y = 0; y < 1000; y++) rijndael_ecb_decrypt(tmp[0], tmp[0], &key); for (y = 0; y < 16; y++) if (tmp[0][y] != 0) return CRYPT_FAIL_TESTVECTOR; } return CRYPT_OK; } int mytiger_test(void) { static const struct { char *msg; unsigned char hash[24]; } tests[] = { { "", { 0x32, 0x93, 0xac, 0x63, 0x0c, 0x13, 0xf0, 0x24, 0x5f, 0x92, 0xbb, 0xb1, 0x76, 0x6e, 0x16, 0x16, 0x7a, 0x4e, 0x58, 0x49, 0x2d, 0xde, 0x73, 0xf3 } }, { "abc", { 0x2a, 0xab, 0x14, 0x84, 0xe8, 0xc1, 0x58, 0xf2, 0xbf, 0xb8, 0xc5, 0xff, 0x41, 0xb5, 0x7a, 0x52, 0x51, 0x29, 0x13, 0x1c, 0x95, 0x7b, 0x5f, 0x93 } }, { "Tiger", { 0xdd, 0x00, 0x23, 0x07, 0x99, 0xf5, 0x00, 0x9f, 0xec, 0x6d, 0xeb, 0xc8, 0x38, 0xbb, 0x6a, 0x27, 0xdf, 0x2b, 0x9d, 0x6f, 0x11, 0x0c, 0x79, 0x37 } }, { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-", { 0xf7, 0x1c, 0x85, 0x83, 0x90, 0x2a, 0xfb, 0x87, 0x9e, 0xdf, 0xe6, 0x10, 0xf8, 0x2c, 0x0d, 0x47, 0x86, 0xa3, 0xa5, 0x34, 0x50, 0x44, 0x86, 0xb5 } }, { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-", { 0xc5, 0x40, 0x34, 0xe5, 0xb4, 0x3e, 0xb8, 0x00, 0x58, 0x48, 0xa7, 0xe0, 0xae, 0x6a, 0xac, 0x76, 0xe4, 0xff, 0x59, 0x0a, 0xe7, 0x15, 0xfd, 0x25 } }, }; int i; unsigned char tmp[24]; hash_state md; for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) { tiger_init(&md); tiger_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg)); tiger_done(&md, tmp); if (memcmp(tmp, tests[i].hash, 24) != 0) { return CRYPT_FAIL_TESTVECTOR; } } return CRYPT_OK; } int entropy_test() { int n = 256, chunk = 16; unsigned char buf[16]; while(n){ int i = chunk; if(!get_entropy(buf, chunk)) return 1; fputs("\t", stdout); while(i--) printf("%02x", buf[i]); puts(""); n -= chunk; } return 0; } int main() { int exit_code = 0; puts("PRNG Test starts..."); if (entropy_test()){ printf("PRNG Test fails.\n"); exit_code |= 8; } else { printf("PRNG Test good.\n"); } puts("ECC Test starts..."); if (ec_cryptCheck(5)){ printf("ECC Test fails.\n"); exit_code |= 4; } else { printf("ECC Test good.\n"); } if (myaes_test() != CRYPT_OK){ printf("AES Test fails.\n"); exit_code |= 1; } else { printf("AES Test good.\n"); } if (mytiger_test() != CRYPT_OK){ printf("TIGER Test fails.\n"); exit_code |= 2; } else { printf("TIGER Test good.\n"); } exit(exit_code); } sks-ecc-0.93/symcrypt.c0000644000175000017500000002226710715702751014013 0ustar nachonacho/* symcrypt.c Symmetric encryption functions of 'sks' project Copyright (C) 2004-2007 Manuel Pancorbo Castro This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Manuel Pancorbo Castro */ #include #include #include #include "mycrypt.h" #include "binasc.h" #include "sks.h" extern char err_data_corrupted[]; extern char err_bad_mac[]; /** The password salt is partially reused to split the key into HMAC and encrypt keys **/ extern unsigned char salt[]; /** ** AES_Cipher functions. 'aes_process' works in CTR mode. MAC is included **/ static byte IV[BLOCK_SIZE], IV2[BLOCK_SIZE]; static symmetric_key aes_key; static int aes_init_flag = 0; static hash_state hmac; static int block_index = 0; int aes_close(byte *hmacout, byte *hmac_key, int tlen) { assert(aes_init_flag); byte opad[2*HASH_SIZE]; hashout c; memset(opad, 0x5c, HASH_SIZE); int i = HASH_SIZE; while(i) { opad[i] ^= hmac_key[i]; --i; } tiger_done(&hmac, &opad[HASH_SIZE]); hash_binary(c, opad, 2*HASH_SIZE); tlen = ((tlen > HASH_SIZE) || (tlen < 0 ))? HASH_SIZE: tlen; memcpy(hmacout, c, tlen); zeromem(IV, BLOCK_SIZE); zeromem(IV2, BLOCK_SIZE); zeromem(&aes_key, sizeof(aes_key)); zeromem(hmac_key, KEY_SIZE); /*zeromem(&hmac, sizeof(hash_state));*/ zeromem(opad, 2*HASH_SIZE); aes_init_flag = 0; block_index = 0; return tlen; } ERROR aes_init(byte *hmac_key, byte *crypt_key, unsigned int ksize, byte *iv) { assert(HASH_SIZE == KEY_SIZE); int bsize = BLOCK_SIZE; byte ipad[HASH_SIZE]; assert ((hmac_key != NULL) && (crypt_key != NULL) && (iv != NULL) && !aes_init_flag); /* Already initialized! **/ /** Check input iv **/ zeromem(IV, bsize); if(!memcmp(IV, iv, bsize)){ /** If null, then build it **/ if(!(bsize = get_entropy(iv, bsize))) return -1; } memcpy(IV, iv, bsize); /** copy in local iv **/ /** HMAC setup **/ tiger_init(&hmac); memset(ipad, 0x36, HASH_SIZE); int i = HASH_SIZE; while(i) { ipad[i] ^= hmac_key[i]; --i; } if((tiger_process(&hmac, ipad, HASH_SIZE)) != CRYPT_OK) return -1; zeromem(ipad, HASH_SIZE); /** Key setup **/ if((aes_setup(crypt_key, ksize, 0, &aes_key)) != CRYPT_OK){ zeromem(crypt_key, ksize); return -1; } aes_init_flag = 1; return CRYPT_OK; } ERROR aes_process(byte *dest, register int n, int mode) /** 'dest' must contain data **/ { assert((dest != NULL) && aes_init_flag); int j, len = n; /*static int k = 0;*/ static byte *bp = NULL; byte *pt = dest; /** HMAC **/ if(!mode) /** mode == 0 means encryption **/ if((tiger_process(&hmac, dest, len)) != CRYPT_OK) return -1; /** Encrypt **/ while(n){ if(!block_index){ aes_ecb_encrypt(IV, IV2, &aes_key); bp = IV2; block_index = BLOCK_SIZE; /** Increase counter for next time **/ for(j = 0; j < BLOCK_SIZE; ++j) if (++IV[j]) break; } for(; (block_index) && (n); --block_index, --n) *pt++ ^= *bp++; } /** HMAC **/ if(mode) /** mode != 0 means decryption **/ if((tiger_process(&hmac, dest, len)) != CRYPT_OK) return -1; return CRYPT_OK; } ERROR sym_encrypt(FILE *f_inp, FILE *f_out, PubKey key_space, int mode) { unsigned int i, binmode, ksize, bsize = BLOCK_SIZE, cipher_mode, comp_level = 0; unsigned int n, insize, outsize; unsigned char IV[BLOCK_SIZE], *inBuf = NULL, *outBuf = NULL, hmac_key[HASH_SIZE], crypt_key[KEY_SIZE], buf[64]; ERROR err = 0; ksize = KEY_SIZE; /** Set cipher and compress **/ cipher_mode = mode & 0x7f; if(mode & 0x80) comp_level = DEFAULT_COMP_LEVEL; zeromem(hmac_key, HASH_SIZE); zeromem(crypt_key, ksize); if(cipher_mode == AES128_CTR){ /** Backward compatibility HMAC-key == crypt-key **/ memcpy(hmac_key, key_space, ksize); memcpy(crypt_key, key_space, ksize); } else if(cipher_mode == AES128_CTR2){ /** HMAC and encrypt keys are different **/ /** process encrypt key = hash(key | PI(0_128) **/ zeromem(buf, 64); memcpy(buf, key_space, ksize); memcpy(buf + ksize, salt, 32); /** Added first 32*8 bits of PI **/ hash_binary(crypt_key, buf, 32 + ksize); /** process hmac key = hask(key | PI(128_256)**/ zeromem(buf, 64); memcpy(buf, key_space, ksize); memcpy(buf + ksize, salt + 32, 32); /** Added next 32*8 bits of PI **/ hash_binary(hmac_key, buf, 32 + ksize); zeromem(buf, 64); } else return -1; zeromem(key_space, ksize); zeromem(IV, bsize); if((aes_init(hmac_key, crypt_key, ksize, IV)) != CRYPT_OK) return -1; zeromem(crypt_key, ksize); /** Set buffer size and binmode **/ binmode = (mode & BINARY_FLAG); if(f_inp == stdin){ /*binmode = 0;*/ insize = LARGE_BUF; } else{ struct stat f; /*binmode = 1;*/ fstat(fileno(f_inp), &f); insize = ((comp_level) && (f.st_size < LARGE_BUF/*MAX_ALLOC_SIZE*/))? f.st_size + 1: LARGE_BUF; while((f.st_size % insize) == 0L) ++insize; } outsize = insize + insize/1000 + 13; if((inBuf = malloc(insize)) == NULL) {err = -1; goto SYM_ENCRYPT_BYE_3;} /** Write cipher identifier **/ fputcPlus(cipher_mode, f_out, binmode); /** Compression info **/ fputcPlus(comp_level, f_out, binmode); /* Put IV */ fwritePlus(IV, 1, bsize, f_out, binmode); /* Put input size */ write_longint(f_out, insize, binmode); if(comp_level){ if((outBuf = malloc(outsize)) == NULL) {err = -1; goto SYM_ENCRYPT_BYE_2;} } else outBuf = inBuf; /** If no compress, perform op. inline **/ /** Starts the play **/ while(!feof(f_inp)){ n = fread(inBuf, 1, insize, f_inp); /** Compression **/ if(comp_level && n){ uLongf len = outsize; if((i = compress2(outBuf, &len, inBuf, n, comp_level))){ break; } n = len; } write_longint(f_out, n, binmode); /** Encryption **/ if(aes_process(outBuf, n, 0) != CRYPT_OK) {err = -1; goto SYM_ENCRYPT_BYE_1;} fwritePlus(outBuf, 1, n, f_out, binmode); } n = aes_close(outBuf, hmac_key, HMAC_SIZE); write_longint(f_out, n + 1, binmode); /** The trick!: put false length n+1 **/ fwritePlus(outBuf, 1, n, f_out, binmode); if(!binmode) flushArmour(f_out); SYM_ENCRYPT_BYE_1: if (comp_level) zeromem(outBuf, outsize), free(outBuf); SYM_ENCRYPT_BYE_2: zeromem(inBuf, insize), free(inBuf); SYM_ENCRYPT_BYE_3: zerokey(hmac_key); burn_stack(200); burnBinasc(); return err; } ERROR sym_decrypt(FILE *f_inp, FILE *f_out, PubKey key_space, int binmode) { unsigned int /*binmode,*/ ksize, bsize = BLOCK_SIZE, comp_flag, auth_flag = 0; unsigned long int n, insize, outsize; unsigned char IV[BLOCK_SIZE], check[HMAC_SIZE], *inBuf = NULL, *outBuf = NULL, c[2], hmac_key[HASH_SIZE], crypt_key[KEY_SIZE], buf[64]; ERROR err = 0; /*binmode = (f_inp == stdin)? 0: 1;*/ freadPlus(c, 1, 2, f_inp, binmode); ksize = KEY_SIZE; zeromem(hmac_key, HASH_SIZE); zeromem(crypt_key, ksize); if(c[0] == AES128_CTR){ /* Only one cipher is considered (at the moment) **/ memcpy(hmac_key, key_space, ksize); memcpy(crypt_key, key_space, ksize); } else if(c[0] == AES128_CTR2){ /** HMAC and encrypt keys are different **/ /** process encrypt key **/ zeromem(buf, 64); memcpy(buf, key_space, ksize); memcpy(buf + ksize, salt, 32); /** Added first 32*8 bits of PI **/ hash_binary(crypt_key, buf, 32 + ksize); /** process hmac key **/ zeromem(buf, 64); memcpy(buf, key_space, ksize); memcpy(buf + ksize, salt + 32, 32); /** Added next 32*8 bits of PI **/ hash_binary(hmac_key, buf, 32 + ksize); zeromem(buf, 64); } else return -1; zeromem(key_space, ksize); freadPlus(IV, 1, bsize, f_inp, binmode); aes_init(hmac_key, crypt_key, ksize, IV); zeromem(crypt_key, ksize); /** Look for compression **/ comp_flag = c[1]; /** Starts the play **/ read_longint(f_inp, &outsize, binmode); if(!comp_flag){ if((inBuf = malloc(outsize)) == NULL){err = -1; goto SYM_DECRYPT_BYE_2;} outBuf = inBuf; } else if((outBuf = malloc(outsize)) == NULL){err = -1; goto SYM_DECRYPT_BYE_1;} while(!feof(f_inp)){ if(!read_longint(f_inp, &insize, binmode)) break; if(comp_flag){ inBuf = realloc(inBuf, insize); } n = freadPlus(inBuf, 1, insize, f_inp, binmode); if((insize == n + 1 )) break; /** Decrypt **/ aes_process(inBuf, n, 1); if(comp_flag){ uLongf len = outsize; if(Z_DATA_ERROR == uncompress(outBuf, &len, inBuf, insize)){ fputs(CHCONV(err_data_corrupted), stderr); auth_flag = 0; break; } n = len; } fwrite(outBuf, 1, n, f_out); } aes_close(check, hmac_key, HMAC_SIZE); /** Compare MACs **/ auth_flag |= !memcmp(check, inBuf, HMAC_SIZE); if(!auth_flag) fputs(CHCONV(err_bad_mac), stderr); zeromem(outBuf, outsize); free(outBuf); SYM_DECRYPT_BYE_1: if(comp_flag) free(inBuf); SYM_DECRYPT_BYE_2: zerokey(hmac_key); burn_stack(200); burnBinasc(); return err; } sks-ecc-0.93/tfm/0000755000175000017500000000000010715702751012532 5ustar nachonachosks-ecc-0.93/tfm/tfm.h0000644000175000017500000003364710715702751013506 0ustar nachonacho/* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #ifndef TFM_H_ #define TFM_H_ #include #include #include #include #include #ifndef MIN #define MIN(x,y) ((x)<(y)?(x):(y)) #endif #ifndef MAX #define MAX(x,y) ((x)>(y)?(x):(y)) #endif /* externally define this symbol to ignore the default settings, useful for changing the build from the make process */ #ifndef TFM_ALREADY_SET /* do we want the large set of small multiplications ? Enable these if you are going to be doing a lot of small (<= 16 digit) multiplications say in ECC Or if you're on a 64-bit machine doing RSA as a 1024-bit integer == 16 digits ;-) */ #define TFM_SMALL_SET /* do we want huge code Enable these if you are doing 20, 24, 28, 32, 48, 64 digit multiplications (useful for RSA) Less important on 64-bit machines as 32 digits == 2048 bits */ #define TFM_MUL3 #define TFM_MUL4 #if 0 #define TFM_MUL6 #define TFM_MUL7 #define TFM_MUL8 #define TFM_MUL9 #define TFM_MUL12 #define TFM_MUL17 #define TFM_MUL20 #define TFM_MUL24 #define TFM_MUL28 #define TFM_MUL32 #define TFM_MUL48 #define TFM_MUL64 #endif #define TFM_SQR3 #define TFM_SQR4 #if 0 #define TFM_SQR6 #define TFM_SQR7 #define TFM_SQR8 #define TFM_SQR9 #define TFM_SQR12 #define TFM_SQR17 #define TFM_SQR20 #define TFM_SQR24 #define TFM_SQR28 #define TFM_SQR32 #define TFM_SQR48 #define TFM_SQR64 #endif /* do we want some overflow checks Not required if you make sure your numbers are within range (e.g. by default a modulus for fp_exptmod() can only be upto 2048 bits long) */ /* #define TFM_CHECK */ /* Is the target a P4 Prescott */ /* #define TFM_PRESCOTT */ /* Do we want timing resistant fp_exptmod() ? * This makes it slower but also timing invariant with respect to the exponent */ /* #define TFM_TIMING_RESISTANT */ #endif /* Max size of any number in bits. Basically the largest size you will be multiplying * should be half [or smaller] of FP_MAX_SIZE-four_digit * * You can externally define this or it defaults to 4096-bits [allowing multiplications upto 2048x2048 bits ] */ #ifndef FP_MAX_SIZE #define FP_MAX_SIZE 1024 #endif /* will this lib work? */ #if (CHAR_BIT & 7) #error CHAR_BIT must be a multiple of eight. #endif #if FP_MAX_SIZE % CHAR_BIT #error FP_MAX_SIZE must be a multiple of CHAR_BIT #endif /* autodetect x86-64 and make sure we are using 64-bit digits with x86-64 asm */ #if defined(__x86_64__) #if defined(TFM_X86) || defined(TFM_SSE2) || defined(TFM_ARM) #error x86-64 detected, x86-32/SSE2/ARM optimizations are not valid! #endif #if !defined(TFM_X86_64) && !defined(TFM_NO_ASM) #define TFM_X86_64 #endif #endif #if defined(TFM_X86_64) #if !defined(FP_64BIT) #define FP_64BIT #endif #endif /* try to detect x86-32 */ #if defined(__i386__) && !defined(TFM_SSE2) #if defined(TFM_X86_64) || defined(TFM_ARM) #error x86-32 detected, x86-64/ARM optimizations are not valid! #endif #if !defined(TFM_X86) && !defined(TFM_NO_ASM) #define TFM_X86 #endif #endif /* make sure we're 32-bit for x86-32/sse/arm/ppc32 */ #if (defined(TFM_X86) || defined(TFM_SSE2) || defined(TFM_ARM) || defined(TFM_PPC32)) && defined(FP_64BIT) #warning x86-32, SSE2 and ARM, PPC32 optimizations require 32-bit digits (undefining) #undef FP_64BIT #endif /* multi asms? */ #ifdef TFM_X86 #define TFM_ASM #endif #ifdef TFM_X86_64 #ifdef TFM_ASM #error TFM_ASM already defined! #endif #define TFM_ASM #endif #ifdef TFM_SSE2 #ifdef TFM_ASM #error TFM_ASM already defined! #endif #define TFM_ASM #endif #ifdef TFM_ARM #ifdef TFM_ASM #error TFM_ASM already defined! #endif #define TFM_ASM #endif #ifdef TFM_PPC32 #ifdef TFM_ASM #error TFM_ASM already defined! #endif #define TFM_ASM #endif #ifdef TFM_PPC64 #ifdef TFM_ASM #error TFM_ASM already defined! #endif #define TFM_ASM #endif #ifdef TFM_AVR32 #ifdef TFM_ASM #error TFM_ASM already defined! #endif #define TFM_ASM #endif /* we want no asm? */ #ifdef TFM_NO_ASM #undef TFM_X86 #undef TFM_X86_64 #undef TFM_SSE2 #undef TFM_ARM #undef TFM_PPC32 #undef TFM_PPC64 #undef TFM_AVR32 #undef TFM_ASM #endif /* ECC helpers */ #ifdef TFM_ECC192 #ifdef FP_64BIT #define TFM_MUL3 #define TFM_SQR3 #else #define TFM_MUL6 #define TFM_SQR6 #endif #endif #ifdef TFM_ECC224 #ifdef FP_64BIT #define TFM_MUL4 #define TFM_SQR4 #else #define TFM_MUL7 #define TFM_SQR7 #endif #endif #ifdef TFM_ECC256 #ifdef FP_64BIT #define TFM_MUL4 #define TFM_SQR4 #else #define TFM_MUL8 #define TFM_SQR8 #endif #endif #ifdef TFM_ECC384 #ifdef FP_64BIT #define TFM_MUL6 #define TFM_SQR6 #else #define TFM_MUL12 #define TFM_SQR12 #endif #endif #ifdef TFM_ECC521 #ifdef FP_64BIT #define TFM_MUL9 #define TFM_SQR9 #else #define TFM_MUL17 #define TFM_SQR17 #endif #endif /* some default configurations. */ #if defined(FP_64BIT) /* for GCC only on supported platforms */ #ifndef CRYPT typedef unsigned long ulong64; #endif typedef ulong64 fp_digit; typedef unsigned long fp_word __attribute__ ((mode(TI))); #else /* this is to make porting into LibTomCrypt easier :-) */ #ifndef CRYPT #if defined(_MSC_VER) || defined(__BORLANDC__) typedef unsigned __int64 ulong64; typedef signed __int64 long64; #else typedef unsigned long long ulong64; typedef signed long long long64; #endif #endif typedef unsigned long fp_digit; typedef ulong64 fp_word; #endif /* # of digits this is */ #define DIGIT_BIT ((int)((CHAR_BIT) * sizeof(fp_digit))) #define FP_MASK (fp_digit)(-1) #define FP_SIZE (FP_MAX_SIZE/DIGIT_BIT) /* signs */ #define FP_ZPOS 0 #define FP_NEG 1 /* return codes */ #define FP_OKAY 0 #define FP_VAL 1 #define FP_MEM 2 /* equalities */ #define FP_LT -1 /* less than */ #define FP_EQ 0 /* equal to */ #define FP_GT 1 /* greater than */ /* replies */ #define FP_YES 1 /* yes response */ #define FP_NO 0 /* no response */ /* a FP type */ typedef struct { fp_digit dp[FP_SIZE]; int used, sign; } fp_int; /* functions */ /* returns a TFM ident string useful for debugging... */ const char *fp_ident(void); /* initialize [or zero] an fp int */ #define fp_init(a) (void)memset((a), 0, sizeof(fp_int)) #define fp_zero(a) fp_init(a) /* zero/even/odd ? */ #define fp_iszero(a) (((a)->used == 0) ? FP_YES : FP_NO) #define fp_iseven(a) (((a)->used >= 0 && (((a)->dp[0] & 1) == 0)) ? FP_YES : FP_NO) #define fp_isodd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? FP_YES : FP_NO) /* set to a small digit */ void fp_set(fp_int *a, fp_digit b); /* copy from a to b */ #define fp_copy(a, b) (void)(((a) != (b)) && memcpy((b), (a), sizeof(fp_int))) #define fp_init_copy(a, b) fp_copy(b, a) /* clamp digits */ #define fp_clamp(a) { while ((a)->used && (a)->dp[(a)->used-1] == 0) --((a)->used); (a)->sign = (a)->used ? (a)->sign : FP_ZPOS; } /* negate and absolute */ #define fp_neg(a, b) { fp_copy(a, b); (b)->sign ^= 1; fp_clamp(b); } #define fp_abs(a, b) { fp_copy(a, b); (b)->sign = 0; } /* right shift x digits */ void fp_rshd(fp_int *a, int x); /* left shift x digits */ void fp_lshd(fp_int *a, int x); /* signed comparison */ int fp_cmp(fp_int *a, fp_int *b); /* unsigned comparison */ int fp_cmp_mag(fp_int *a, fp_int *b); /* power of 2 operations */ void fp_div_2d(fp_int *a, int b, fp_int *c, fp_int *d); void fp_mod_2d(fp_int *a, int b, fp_int *c); void fp_mul_2d(fp_int *a, int b, fp_int *c); void fp_2expt (fp_int *a, int b); void fp_mul_2(fp_int *a, fp_int *c); void fp_div_2(fp_int *a, fp_int *c); /* Counts the number of lsbs which are zero before the first zero bit */ int fp_cnt_lsb(fp_int *a); /* c = a + b */ void fp_add(fp_int *a, fp_int *b, fp_int *c); /* c = a - b */ void fp_sub(fp_int *a, fp_int *b, fp_int *c); /* c = a * b */ void fp_mul(fp_int *a, fp_int *b, fp_int *c); /* b = a*a */ void fp_sqr(fp_int *a, fp_int *b); /* a/b => cb + d == a */ int fp_div(fp_int *a, fp_int *b, fp_int *c, fp_int *d); /* c = a mod b, 0 <= c < b */ int fp_mod(fp_int *a, fp_int *b, fp_int *c); /* compare against a single digit */ int fp_cmp_d(fp_int *a, fp_digit b); /* c = a + b */ void fp_add_d(fp_int *a, fp_digit b, fp_int *c); /* c = a - b */ void fp_sub_d(fp_int *a, fp_digit b, fp_int *c); /* c = a * b */ void fp_mul_d(fp_int *a, fp_digit b, fp_int *c); /* a/b => cb + d == a */ int fp_div_d(fp_int *a, fp_digit b, fp_int *c, fp_digit *d); /* c = a mod b, 0 <= c < b */ int fp_mod_d(fp_int *a, fp_digit b, fp_digit *c); /* ---> number theory <--- */ /* d = a + b (mod c) */ int fp_addmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d); /* d = a - b (mod c) */ int fp_submod(fp_int *a, fp_int *b, fp_int *c, fp_int *d); /* d = a * b (mod c) */ int fp_mulmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d); /* c = a * a (mod b) */ int fp_sqrmod(fp_int *a, fp_int *b, fp_int *c); /* c = 1/a (mod b) */ int fp_invmod(fp_int *a, fp_int *b, fp_int *c); /* c = (a, b) */ void fp_gcd(fp_int *a, fp_int *b, fp_int *c); /* c = [a, b] */ void fp_lcm(fp_int *a, fp_int *b, fp_int *c); /* setups the montgomery reduction */ int fp_montgomery_setup(fp_int *a, fp_digit *mp); /* computes a = B**n mod b without division or multiplication useful for * normalizing numbers in a Montgomery system. */ void fp_montgomery_calc_normalization(fp_int *a, fp_int *b); /* computes x/R == x (mod N) via Montgomery Reduction */ void fp_montgomery_reduce(fp_int *a, fp_int *m, fp_digit mp); /* d = a**b (mod c) */ int fp_exptmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d); /* primality stuff */ /* perform a Miller-Rabin test of a to the base b and store result in "result" */ void fp_prime_miller_rabin (fp_int * a, fp_int * b, int *result); /* 256 trial divisions + 8 Miller-Rabins, returns FP_YES if probable prime */ int fp_isprime(fp_int *a); /* Primality generation flags */ #define TFM_PRIME_BBS 0x0001 /* BBS style prime */ #define TFM_PRIME_SAFE 0x0002 /* Safe prime (p-1)/2 == prime */ #define TFM_PRIME_2MSB_OFF 0x0004 /* force 2nd MSB to 0 */ #define TFM_PRIME_2MSB_ON 0x0008 /* force 2nd MSB to 1 */ /* callback for fp_prime_random, should fill dst with random bytes and return how many read [upto len] */ typedef int tfm_prime_callback(unsigned char *dst, int len, void *dat); #define fp_prime_random(a, t, size, bbs, cb, dat) fp_prime_random_ex(a, t, ((size) * 8) + 1, (bbs==1)?TFM_PRIME_BBS:0, cb, dat) int fp_prime_random_ex(fp_int *a, int t, int size, int flags, tfm_prime_callback cb, void *dat); /* radix conersions */ int fp_count_bits(fp_int *a); int fp_unsigned_bin_size(fp_int *a); void fp_read_unsigned_bin(fp_int *a, unsigned char *b, int c); void fp_to_unsigned_bin(fp_int *a, unsigned char *b); int fp_signed_bin_size(fp_int *a); void fp_read_signed_bin(fp_int *a, unsigned char *b, int c); void fp_to_signed_bin(fp_int *a, unsigned char *b); int fp_read_radix(fp_int *a, char *str, int radix); int fp_toradix(fp_int *a, char *str, int radix); int fp_toradix_n(fp_int * a, char *str, int radix, int maxlen); /* VARIOUS LOW LEVEL STUFFS */ void s_fp_add(fp_int *a, fp_int *b, fp_int *c); void s_fp_sub(fp_int *a, fp_int *b, fp_int *c); void fp_reverse(unsigned char *s, int len); void fp_mul_comba(fp_int *A, fp_int *B, fp_int *C); #ifdef TFM_SMALL_SET void fp_mul_comba_small(fp_int *A, fp_int *B, fp_int *C); #endif #ifdef TFM_MUL3 void fp_mul_comba3(fp_int *A, fp_int *B, fp_int *C); #endif #ifdef TFM_MUL4 void fp_mul_comba4(fp_int *A, fp_int *B, fp_int *C); #endif #ifdef TFM_MUL6 void fp_mul_comba6(fp_int *A, fp_int *B, fp_int *C); #endif #ifdef TFM_MUL7 void fp_mul_comba7(fp_int *A, fp_int *B, fp_int *C); #endif #ifdef TFM_MUL8 void fp_mul_comba8(fp_int *A, fp_int *B, fp_int *C); #endif #ifdef TFM_MUL9 void fp_mul_comba9(fp_int *A, fp_int *B, fp_int *C); #endif #ifdef TFM_MUL12 void fp_mul_comba12(fp_int *A, fp_int *B, fp_int *C); #endif #ifdef TFM_MUL17 void fp_mul_comba17(fp_int *A, fp_int *B, fp_int *C); #endif #ifdef TFM_MUL20 void fp_mul_comba20(fp_int *A, fp_int *B, fp_int *C); #endif #ifdef TFM_MUL24 void fp_mul_comba24(fp_int *A, fp_int *B, fp_int *C); #endif #ifdef TFM_MUL28 void fp_mul_comba28(fp_int *A, fp_int *B, fp_int *C); #endif #ifdef TFM_MUL32 void fp_mul_comba32(fp_int *A, fp_int *B, fp_int *C); #endif #ifdef TFM_MUL48 void fp_mul_comba48(fp_int *A, fp_int *B, fp_int *C); #endif #ifdef TFM_MUL64 void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C); #endif void fp_sqr_comba(fp_int *A, fp_int *B); #ifdef TFM_SMALL_SET void fp_sqr_comba_small(fp_int *A, fp_int *B); #endif #ifdef TFM_SQR3 void fp_sqr_comba3(fp_int *A, fp_int *B); #endif #ifdef TFM_SQR4 void fp_sqr_comba4(fp_int *A, fp_int *B); #endif #ifdef TFM_SQR6 void fp_sqr_comba6(fp_int *A, fp_int *B); #endif #ifdef TFM_SQR7 void fp_sqr_comba7(fp_int *A, fp_int *B); #endif #ifdef TFM_SQR8 void fp_sqr_comba8(fp_int *A, fp_int *B); #endif #ifdef TFM_SQR9 void fp_sqr_comba9(fp_int *A, fp_int *B); #endif #ifdef TFM_SQR12 void fp_sqr_comba12(fp_int *A, fp_int *B); #endif #ifdef TFM_SQR17 void fp_sqr_comba17(fp_int *A, fp_int *B); #endif #ifdef TFM_SQR20 void fp_sqr_comba20(fp_int *A, fp_int *B); #endif #ifdef TFM_SQR24 void fp_sqr_comba24(fp_int *A, fp_int *B); #endif #ifdef TFM_SQR28 void fp_sqr_comba28(fp_int *A, fp_int *B); #endif #ifdef TFM_SQR32 void fp_sqr_comba32(fp_int *A, fp_int *B); #endif #ifdef TFM_SQR48 void fp_sqr_comba48(fp_int *A, fp_int *B); #endif #ifdef TFM_SQR64 void fp_sqr_comba64(fp_int *A, fp_int *B); #endif extern const char *fp_s_rmap; #endif /* $Source: /cvs/libtom/tomsfastmath/src/headers/tfm.h,v $ */ /* $Revision: 1.3 $ */ /* $Date: 2007/02/27 02:38:44 $ */ sks-ecc-0.93/tfm/mpi.c0000644000175000017500000253574210715702751013505 0ustar nachonacho/* Start: src/addsub/fp_add.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include void fp_add(fp_int *a, fp_int *b, fp_int *c) { int sa, sb; /* get sign of both inputs */ sa = a->sign; sb = b->sign; /* handle two cases, not four */ if (sa == sb) { /* both positive or both negative */ /* add their magnitudes, copy the sign */ c->sign = sa; s_fp_add (a, b, c); } else { /* one positive, the other negative */ /* subtract the one with the greater magnitude from */ /* the one of the lesser magnitude. The result gets */ /* the sign of the one with the greater magnitude. */ if (fp_cmp_mag (a, b) == FP_LT) { c->sign = sb; s_fp_sub (b, a, c); } else { c->sign = sa; s_fp_sub (a, b, c); } } } /* $Source: /cvs/libtom/tomsfastmath/src/addsub/fp_add.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/addsub/fp_add.c */ /* Start: src/addsub/fp_add_d.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* c = a + b */ void fp_add_d(fp_int *a, fp_digit b, fp_int *c) { fp_int tmp; fp_set(&tmp, b); fp_add(a,&tmp,c); } /* $Source: /cvs/libtom/tomsfastmath/src/addsub/fp_add_d.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/addsub/fp_add_d.c */ /* Start: src/addsub/fp_addmod.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* d = a + b (mod c) */ int fp_addmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d) { fp_int tmp; fp_zero(&tmp); fp_add(a, b, &tmp); return fp_mod(&tmp, c, d); } /* $Source: /cvs/libtom/tomsfastmath/src/addsub/fp_addmod.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/addsub/fp_addmod.c */ /* Start: src/addsub/fp_cmp.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include int fp_cmp(fp_int *a, fp_int *b) { if (a->sign == FP_NEG && b->sign == FP_ZPOS) { return FP_LT; } else if (a->sign == FP_ZPOS && b->sign == FP_NEG) { return FP_GT; } else { /* compare digits */ if (a->sign == FP_NEG) { /* if negative compare opposite direction */ return fp_cmp_mag(b, a); } else { return fp_cmp_mag(a, b); } } } /* $Source: /cvs/libtom/tomsfastmath/src/addsub/fp_cmp.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/addsub/fp_cmp.c */ /* Start: src/addsub/fp_cmp_d.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* compare against a single digit */ int fp_cmp_d(fp_int *a, fp_digit b) { /* compare based on sign */ if ((b && a->used == 0) || a->sign == FP_NEG) { return FP_LT; } /* compare based on magnitude */ if (a->used > 1) { return FP_GT; } /* compare the only digit of a to b */ if (a->dp[0] > b) { return FP_GT; } else if (a->dp[0] < b) { return FP_LT; } else { return FP_EQ; } } /* $Source: /cvs/libtom/tomsfastmath/src/addsub/fp_cmp_d.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/addsub/fp_cmp_d.c */ /* Start: src/addsub/fp_cmp_mag.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include int fp_cmp_mag(fp_int *a, fp_int *b) { int x; if (a->used > b->used) { return FP_GT; } else if (a->used < b->used) { return FP_LT; } else { for (x = a->used - 1; x >= 0; x--) { if (a->dp[x] > b->dp[x]) { return FP_GT; } else if (a->dp[x] < b->dp[x]) { return FP_LT; } } } return FP_EQ; } /* $Source: /cvs/libtom/tomsfastmath/src/addsub/fp_cmp_mag.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/addsub/fp_cmp_mag.c */ /* Start: src/addsub/fp_sub.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* c = a - b */ void fp_sub(fp_int *a, fp_int *b, fp_int *c) { int sa, sb; sa = a->sign; sb = b->sign; if (sa != sb) { /* subtract a negative from a positive, OR */ /* subtract a positive from a negative. */ /* In either case, ADD their magnitudes, */ /* and use the sign of the first number. */ c->sign = sa; s_fp_add (a, b, c); } else { /* subtract a positive from a positive, OR */ /* subtract a negative from a negative. */ /* First, take the difference between their */ /* magnitudes, then... */ if (fp_cmp_mag (a, b) != FP_LT) { /* Copy the sign from the first */ c->sign = sa; /* The first has a larger or equal magnitude */ s_fp_sub (a, b, c); } else { /* The result has the *opposite* sign from */ /* the first number. */ c->sign = (sa == FP_ZPOS) ? FP_NEG : FP_ZPOS; /* The second has a larger magnitude */ s_fp_sub (b, a, c); } } } /* $Source: /cvs/libtom/tomsfastmath/src/addsub/fp_sub.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/addsub/fp_sub.c */ /* Start: src/addsub/fp_sub_d.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* c = a - b */ void fp_sub_d(fp_int *a, fp_digit b, fp_int *c) { fp_int tmp; fp_set(&tmp, b); fp_sub(a, &tmp, c); } /* $Source: /cvs/libtom/tomsfastmath/src/addsub/fp_sub_d.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/addsub/fp_sub_d.c */ /* Start: src/addsub/fp_submod.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* d = a - b (mod c) */ int fp_submod(fp_int *a, fp_int *b, fp_int *c, fp_int *d) { fp_int tmp; fp_zero(&tmp); fp_sub(a, b, &tmp); return fp_mod(&tmp, c, d); } /* $Source: /cvs/libtom/tomsfastmath/src/addsub/fp_submod.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/addsub/fp_submod.c */ /* Start: src/addsub/s_fp_add.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* unsigned addition */ void s_fp_add(fp_int *a, fp_int *b, fp_int *c) { int x, y, oldused; register fp_word t; y = MAX(a->used, b->used); oldused = c->used; c->used = y; t = 0; for (x = 0; x < y; x++) { t += ((fp_word)a->dp[x]) + ((fp_word)b->dp[x]); c->dp[x] = (fp_digit)t; t >>= DIGIT_BIT; } if (t != 0 && x < FP_SIZE) { c->dp[c->used++] = (fp_digit)t; ++x; } c->used = x; for (; x < oldused; x++) { c->dp[x] = 0; } fp_clamp(c); } /* $Source: /cvs/libtom/tomsfastmath/src/addsub/s_fp_add.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/addsub/s_fp_add.c */ /* Start: src/addsub/s_fp_sub.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* unsigned subtraction ||a|| >= ||b|| ALWAYS! */ void s_fp_sub(fp_int *a, fp_int *b, fp_int *c) { int x, oldbused, oldused; fp_word t; oldused = c->used; oldbused = b->used; c->used = a->used; t = 0; for (x = 0; x < oldbused; x++) { t = ((fp_word)a->dp[x]) - (((fp_word)b->dp[x]) + t); c->dp[x] = (fp_digit)t; t = (t >> DIGIT_BIT)&1; } for (; x < a->used; x++) { t = ((fp_word)a->dp[x]) - t; c->dp[x] = (fp_digit)t; t = (t >> DIGIT_BIT); } for (; x < oldused; x++) { c->dp[x] = 0; } fp_clamp(c); } /* $Source: /cvs/libtom/tomsfastmath/src/addsub/s_fp_sub.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/addsub/s_fp_sub.c */ /* Start: src/bin/fp_radix_size.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include int fp_radix_size(fp_int *a, int radix, int *size) { int digs; fp_int t; fp_digit d; *size = 0; /* check range of the radix */ if (radix < 2 || radix > 64) { return FP_VAL; } /* quick out if its zero */ if (fp_iszero(a) == 1) { *size = 2; return FP_OKAY; } fp_init_copy(&t, a); /* if it is negative output a - */ if (t.sign == FP_NEG) { (*size)++; t.sign = FP_ZPOS; } digs = 0; while (fp_iszero (&t) == FP_NO) { fp_div_d (&t, (fp_digit) radix, &t, &d); (*size)++; } /* append a NULL so the string is properly terminated */ (*size)++; return FP_OKAY; } /* $Source: /cvs/libtom/tomsfastmath/src/bin/fp_radix_size.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/bin/fp_radix_size.c */ /* Start: src/bin/fp_read_radix.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include int fp_read_radix(fp_int *a, char *str, int radix) { int y, neg; char ch; /* make sure the radix is ok */ if (radix < 2 || radix > 64) { return FP_VAL; } /* if the leading digit is a * minus set the sign to negative. */ if (*str == '-') { ++str; neg = FP_NEG; } else { neg = FP_ZPOS; } /* set the integer to the default of zero */ fp_zero (a); /* process each digit of the string */ while (*str) { /* if the radix < 36 the conversion is case insensitive * this allows numbers like 1AB and 1ab to represent the same value * [e.g. in hex] */ ch = (char) ((radix < 36) ? toupper (*str) : *str); for (y = 0; y < 64; y++) { if (ch == fp_s_rmap[y]) { break; } } /* if the char was found in the map * and is less than the given radix add it * to the number, otherwise exit the loop. */ if (y < radix) { fp_mul_d (a, (fp_digit) radix, a); fp_add_d (a, (fp_digit) y, a); } else { break; } ++str; } /* set the sign only if a != 0 */ if (fp_iszero(a) != FP_YES) { a->sign = neg; } return FP_OKAY; } /* $Source: /cvs/libtom/tomsfastmath/src/bin/fp_read_radix.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/bin/fp_read_radix.c */ /* Start: src/bin/fp_read_signed_bin.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include void fp_read_signed_bin(fp_int *a, unsigned char *b, int c) { /* read magnitude */ fp_read_unsigned_bin (a, b + 1, c - 1); /* first byte is 0 for positive, non-zero for negative */ if (b[0] == 0) { a->sign = FP_ZPOS; } else { a->sign = FP_NEG; } } /* $Source: /cvs/libtom/tomsfastmath/src/bin/fp_read_signed_bin.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/bin/fp_read_signed_bin.c */ /* Start: src/bin/fp_read_unsigned_bin.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include void fp_read_unsigned_bin(fp_int *a, unsigned char *b, int c) { /* zero the int */ fp_zero (a); /* If we know the endianness of this architecture, and we're using 32-bit fp_digits, we can optimize this */ #if (defined(ENDIAN_LITTLE) || defined(ENDIAN_BIG)) && !defined(FP_64BIT) /* But not for both simultaneously */ #if defined(ENDIAN_LITTLE) && defined(ENDIAN_BIG) #error Both ENDIAN_LITTLE and ENDIAN_BIG defined. #endif { unsigned char *pd = (unsigned char *)a->dp; if ((unsigned)c > (FP_SIZE * sizeof(fp_digit))) { int excess = c - (FP_SIZE * sizeof(fp_digit)); c -= excess; b += excess; } a->used = (c + sizeof(fp_digit) - 1)/sizeof(fp_digit); /* read the bytes in */ #ifdef ENDIAN_BIG { /* Use Duff's device to unroll the loop. */ int idx = (c - 1) & ~3; switch (c % 4) { case 0: do { pd[idx+0] = *b++; case 3: pd[idx+1] = *b++; case 2: pd[idx+2] = *b++; case 1: pd[idx+3] = *b++; idx -= 4; } while ((c -= 4) > 0); } } #else for (c -= 1; c >= 0; c -= 1) { pd[c] = *b++; } #endif } #else /* read the bytes in */ for (; c > 0; c--) { fp_mul_2d (a, 8, a); a->dp[0] |= *b++; a->used += 1; } #endif fp_clamp (a); } /* $Source: /cvs/libtom/tomsfastmath/src/bin/fp_read_unsigned_bin.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/17 02:58:19 $ */ /* End: src/bin/fp_read_unsigned_bin.c */ /* Start: src/bin/fp_reverse.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* reverse an array, used for radix code */ void fp_reverse (unsigned char *s, int len) { int ix, iy; unsigned char t; ix = 0; iy = len - 1; while (ix < iy) { t = s[ix]; s[ix] = s[iy]; s[iy] = t; ++ix; --iy; } } /* $Source: /cvs/libtom/tomsfastmath/src/bin/fp_reverse.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/27 02:38:44 $ */ /* End: src/bin/fp_reverse.c */ /* Start: src/bin/fp_s_rmap.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* chars used in radix conversions */ const char *fp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"; /* $Source: /cvs/libtom/tomsfastmath/src/bin/fp_s_rmap.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/bin/fp_s_rmap.c */ /* Start: src/bin/fp_signed_bin_size.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include int fp_signed_bin_size(fp_int *a) { return 1 + fp_unsigned_bin_size (a); } /* $Source: /cvs/libtom/tomsfastmath/src/bin/fp_signed_bin_size.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/bin/fp_signed_bin_size.c */ /* Start: src/bin/fp_to_signed_bin.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include void fp_to_signed_bin(fp_int *a, unsigned char *b) { fp_to_unsigned_bin (a, b + 1); b[0] = (unsigned char) ((a->sign == FP_ZPOS) ? 0 : 1); } /* $Source: /cvs/libtom/tomsfastmath/src/bin/fp_to_signed_bin.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/bin/fp_to_signed_bin.c */ /* Start: src/bin/fp_to_unsigned_bin.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include void fp_to_unsigned_bin(fp_int *a, unsigned char *b) { int x; fp_int t; fp_init_copy(&t, a); x = 0; while (fp_iszero (&t) == FP_NO) { b[x++] = (unsigned char) (t.dp[0] & 255); fp_div_2d (&t, 8, &t, NULL); } fp_reverse (b, x); } /* $Source: /cvs/libtom/tomsfastmath/src/bin/fp_to_unsigned_bin.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/27 02:38:44 $ */ /* End: src/bin/fp_to_unsigned_bin.c */ /* Start: src/bin/fp_toradix.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include int fp_toradix(fp_int *a, char *str, int radix) { int digs; fp_int t; fp_digit d; char *_s = str; /* check range of the radix */ if (radix < 2 || radix > 64) { return FP_VAL; } /* quick out if its zero */ if (fp_iszero(a) == 1) { *str++ = '0'; *str = '\0'; return FP_OKAY; } fp_init_copy(&t, a); /* if it is negative output a - */ if (t.sign == FP_NEG) { ++_s; *str++ = '-'; t.sign = FP_ZPOS; } digs = 0; while (fp_iszero (&t) == FP_NO) { fp_div_d (&t, (fp_digit) radix, &t, &d); *str++ = fp_s_rmap[d]; ++digs; } /* reverse the digits of the string. In this case _s points * to the first digit [exluding the sign] of the number] */ fp_reverse ((unsigned char *)_s, digs); /* append a NULL so the string is properly terminated */ *str = '\0'; return FP_OKAY; } /* $Source: /cvs/libtom/tomsfastmath/src/bin/fp_toradix.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/27 02:38:44 $ */ /* End: src/bin/fp_toradix.c */ /* Start: src/bin/fp_unsigned_bin_size.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include int fp_unsigned_bin_size(fp_int *a) { int size = fp_count_bits (a); return (size / 8 + ((size & 7) != 0 ? 1 : 0)); } /* $Source: /cvs/libtom/tomsfastmath/src/bin/fp_unsigned_bin_size.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/bin/fp_unsigned_bin_size.c */ /* Start: src/bit/fp_cnt_lsb.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include static const int lnz[16] = { 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 }; /* Counts the number of lsbs which are zero before the first zero bit */ int fp_cnt_lsb(fp_int *a) { int x; fp_digit q, qq; /* easy out */ if (fp_iszero(a) == 1) { return 0; } /* scan lower digits until non-zero */ for (x = 0; x < a->used && a->dp[x] == 0; x++); q = a->dp[x]; x *= DIGIT_BIT; /* now scan this digit until a 1 is found */ if ((q & 1) == 0) { do { qq = q & 15; x += lnz[qq]; q >>= 4; } while (qq == 0); } return x; } /* $Source: /cvs/libtom/tomsfastmath/src/bit/fp_cnt_lsb.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/bit/fp_cnt_lsb.c */ /* Start: src/bit/fp_count_bits.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include int fp_count_bits (fp_int * a) { int r; fp_digit q; /* shortcut */ if (a->used == 0) { return 0; } /* get number of digits and add that */ r = (a->used - 1) * DIGIT_BIT; /* take the last digit and count the bits in it */ q = a->dp[a->used - 1]; while (q > ((fp_digit) 0)) { ++r; q >>= ((fp_digit) 1); } return r; } /* $Source: /cvs/libtom/tomsfastmath/src/bit/fp_count_bits.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/bit/fp_count_bits.c */ /* Start: src/bit/fp_div_2.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* b = a/2 */ void fp_div_2(fp_int * a, fp_int * b) { int x, oldused; oldused = b->used; b->used = a->used; { register fp_digit r, rr, *tmpa, *tmpb; /* source alias */ tmpa = a->dp + b->used - 1; /* dest alias */ tmpb = b->dp + b->used - 1; /* carry */ r = 0; for (x = b->used - 1; x >= 0; x--) { /* get the carry for the next iteration */ rr = *tmpa & 1; /* shift the current digit, add in carry and store */ *tmpb-- = (*tmpa-- >> 1) | (r << (DIGIT_BIT - 1)); /* forward carry to next iteration */ r = rr; } /* zero excess digits */ tmpb = b->dp + b->used; for (x = b->used; x < oldused; x++) { *tmpb++ = 0; } } b->sign = a->sign; fp_clamp (b); } /* $Source: /cvs/libtom/tomsfastmath/src/bit/fp_div_2.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/bit/fp_div_2.c */ /* Start: src/bit/fp_div_2d.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* c = a / 2**b */ void fp_div_2d(fp_int *a, int b, fp_int *c, fp_int *d) { fp_digit D, r, rr; int x; fp_int t; /* if the shift count is <= 0 then we do no work */ if (b <= 0) { fp_copy (a, c); if (d != NULL) { fp_zero (d); } return; } fp_init(&t); /* get the remainder */ if (d != NULL) { fp_mod_2d (a, b, &t); } /* copy */ fp_copy(a, c); /* shift by as many digits in the bit count */ if (b >= (int)DIGIT_BIT) { fp_rshd (c, b / DIGIT_BIT); } /* shift any bit count < DIGIT_BIT */ D = (fp_digit) (b % DIGIT_BIT); if (D != 0) { register fp_digit *tmpc, mask, shift; /* mask */ mask = (((fp_digit)1) << D) - 1; /* shift for lsb */ shift = DIGIT_BIT - D; /* alias */ tmpc = c->dp + (c->used - 1); /* carry */ r = 0; for (x = c->used - 1; x >= 0; x--) { /* get the lower bits of this word in a temp */ rr = *tmpc & mask; /* shift the current word and mix in the carry bits from the previous word */ *tmpc = (*tmpc >> D) | (r << shift); --tmpc; /* set the carry to the carry bits of the current word found above */ r = rr; } } fp_clamp (c); if (d != NULL) { fp_copy (&t, d); } } /* $Source: /cvs/libtom/tomsfastmath/src/bit/fp_div_2d.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/bit/fp_div_2d.c */ /* Start: src/bit/fp_lshd.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include void fp_lshd(fp_int *a, int x) { int y; /* move up and truncate as required */ y = MIN(a->used + x - 1, (int)(FP_SIZE-1)); /* store new size */ a->used = y + 1; /* move digits */ for (; y >= x; y--) { a->dp[y] = a->dp[y-x]; } /* zero lower digits */ for (; y >= 0; y--) { a->dp[y] = 0; } /* clamp digits */ fp_clamp(a); } /* $Source: /cvs/libtom/tomsfastmath/src/bit/fp_lshd.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/bit/fp_lshd.c */ /* Start: src/bit/fp_mod_2d.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* c = a mod 2**d */ void fp_mod_2d(fp_int *a, int b, fp_int *c) { int x; /* zero if count less than or equal to zero */ if (b <= 0) { fp_zero(c); return; } /* get copy of input */ fp_copy(a, c); /* if 2**d is larger than we just return */ if (b >= (DIGIT_BIT * a->used)) { return; } /* zero digits above the last digit of the modulus */ for (x = (b / DIGIT_BIT) + ((b % DIGIT_BIT) == 0 ? 0 : 1); x < c->used; x++) { c->dp[x] = 0; } /* clear the digit that is not completely outside/inside the modulus */ c->dp[b / DIGIT_BIT] &= ~((fp_digit)0) >> (DIGIT_BIT - b); fp_clamp (c); } /* $Source: /cvs/libtom/tomsfastmath/src/bit/fp_mod_2d.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/bit/fp_mod_2d.c */ /* Start: src/bit/fp_rshd.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include void fp_rshd(fp_int *a, int x) { int y; /* too many digits just zero and return */ if (x >= a->used) { fp_zero(a); return; } /* shift */ for (y = 0; y < a->used - x; y++) { a->dp[y] = a->dp[y+x]; } /* zero rest */ for (; y < a->used; y++) { a->dp[y] = 0; } /* decrement count */ a->used -= x; fp_clamp(a); } /* $Source: /cvs/libtom/tomsfastmath/src/bit/fp_rshd.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/bit/fp_rshd.c */ /* Start: src/divide/fp_div.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* a/b => cb + d == a */ int fp_div(fp_int *a, fp_int *b, fp_int *c, fp_int *d) { fp_int q, x, y, t1, t2; int n, t, i, norm, neg; /* is divisor zero ? */ if (fp_iszero (b) == 1) { return FP_VAL; } /* if a < b then q=0, r = a */ if (fp_cmp_mag (a, b) == FP_LT) { if (d != NULL) { fp_copy (a, d); } if (c != NULL) { fp_zero (c); } return FP_OKAY; } fp_init(&q); q.used = a->used + 2; fp_init(&t1); fp_init(&t2); fp_init_copy(&x, a); fp_init_copy(&y, b); /* fix the sign */ neg = (a->sign == b->sign) ? FP_ZPOS : FP_NEG; x.sign = y.sign = FP_ZPOS; /* normalize both x and y, ensure that y >= b/2, [b == 2**DIGIT_BIT] */ norm = fp_count_bits(&y) % DIGIT_BIT; if (norm < (int)(DIGIT_BIT-1)) { norm = (DIGIT_BIT-1) - norm; fp_mul_2d (&x, norm, &x); fp_mul_2d (&y, norm, &y); } else { norm = 0; } /* note hac does 0 based, so if used==5 then its 0,1,2,3,4, e.g. use 4 */ n = x.used - 1; t = y.used - 1; /* while (x >= y*b**n-t) do { q[n-t] += 1; x -= y*b**{n-t} } */ fp_lshd (&y, n - t); /* y = y*b**{n-t} */ while (fp_cmp (&x, &y) != FP_LT) { ++(q.dp[n - t]); fp_sub (&x, &y, &x); } /* reset y by shifting it back down */ fp_rshd (&y, n - t); /* step 3. for i from n down to (t + 1) */ for (i = n; i >= (t + 1); i--) { if (i > x.used) { continue; } /* step 3.1 if xi == yt then set q{i-t-1} to b-1, * otherwise set q{i-t-1} to (xi*b + x{i-1})/yt */ if (x.dp[i] == y.dp[t]) { q.dp[i - t - 1] = ((((fp_word)1) << DIGIT_BIT) - 1); } else { fp_word tmp; tmp = ((fp_word) x.dp[i]) << ((fp_word) DIGIT_BIT); tmp |= ((fp_word) x.dp[i - 1]); tmp /= ((fp_word) y.dp[t]); q.dp[i - t - 1] = (fp_digit) (tmp); } /* while (q{i-t-1} * (yt * b + y{t-1})) > xi * b**2 + xi-1 * b + xi-2 do q{i-t-1} -= 1; */ q.dp[i - t - 1] = (q.dp[i - t - 1] + 1); do { q.dp[i - t - 1] = (q.dp[i - t - 1] - 1); /* find left hand */ fp_zero (&t1); t1.dp[0] = (t - 1 < 0) ? 0 : y.dp[t - 1]; t1.dp[1] = y.dp[t]; t1.used = 2; fp_mul_d (&t1, q.dp[i - t - 1], &t1); /* find right hand */ t2.dp[0] = (i - 2 < 0) ? 0 : x.dp[i - 2]; t2.dp[1] = (i - 1 < 0) ? 0 : x.dp[i - 1]; t2.dp[2] = x.dp[i]; t2.used = 3; } while (fp_cmp_mag(&t1, &t2) == FP_GT); /* step 3.3 x = x - q{i-t-1} * y * b**{i-t-1} */ fp_mul_d (&y, q.dp[i - t - 1], &t1); fp_lshd (&t1, i - t - 1); fp_sub (&x, &t1, &x); /* if x < 0 then { x = x + y*b**{i-t-1}; q{i-t-1} -= 1; } */ if (x.sign == FP_NEG) { fp_copy (&y, &t1); fp_lshd (&t1, i - t - 1); fp_add (&x, &t1, &x); q.dp[i - t - 1] = q.dp[i - t - 1] - 1; } } /* now q is the quotient and x is the remainder * [which we have to normalize] */ /* get sign before writing to c */ x.sign = x.used == 0 ? FP_ZPOS : a->sign; if (c != NULL) { fp_clamp (&q); fp_copy (&q, c); c->sign = neg; } if (d != NULL) { fp_div_2d (&x, norm, &x, NULL); /* the following is a kludge, essentially we were seeing the right remainder but with excess digits that should have been zero */ for (i = b->used; i < x.used; i++) { x.dp[i] = 0; } fp_clamp(&x); fp_copy (&x, d); } return FP_OKAY; } /* $Source: /cvs/libtom/tomsfastmath/src/divide/fp_div.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/divide/fp_div.c */ /* Start: src/divide/fp_div_d.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include static int s_is_power_of_two(fp_digit b, int *p) { int x; /* fast return if no power of two */ if ((b==0) || (b & (b-1))) { return 0; } for (x = 0; x < DIGIT_BIT; x++) { if (b == (((fp_digit)1)< cb + d == a */ int fp_div_d(fp_int *a, fp_digit b, fp_int *c, fp_digit *d) { fp_int q; fp_word w; fp_digit t; int ix; /* cannot divide by zero */ if (b == 0) { return FP_VAL; } /* quick outs */ if (b == 1 || fp_iszero(a) == 1) { if (d != NULL) { *d = 0; } if (c != NULL) { fp_copy(a, c); } return FP_OKAY; } /* power of two ? */ if (s_is_power_of_two(b, &ix) == 1) { if (d != NULL) { *d = a->dp[0] & ((((fp_digit)1)<used; q.sign = a->sign; w = 0; for (ix = a->used - 1; ix >= 0; ix--) { w = (w << ((fp_word)DIGIT_BIT)) | ((fp_word)a->dp[ix]); if (w >= b) { t = (fp_digit)(w / b); w -= ((fp_word)t) * ((fp_word)b); } else { t = 0; } q.dp[ix] = (fp_digit)t; } if (d != NULL) { *d = (fp_digit)w; } if (c != NULL) { fp_clamp(&q); fp_copy(&q, c); } return FP_OKAY; } /* $Source: /cvs/libtom/tomsfastmath/src/divide/fp_div_d.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/01/12 15:13:54 $ */ /* End: src/divide/fp_div_d.c */ /* Start: src/divide/fp_mod.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* c = a mod b, 0 <= c < b */ int fp_mod(fp_int *a, fp_int *b, fp_int *c) { fp_int t; int err; fp_zero(&t); if ((err = fp_div(a, b, NULL, &t)) != FP_OKAY) { return err; } if (t.sign != b->sign) { fp_add(&t, b, c); } else { fp_copy(&t, c); } return FP_OKAY; } /* $Source: /cvs/libtom/tomsfastmath/src/divide/fp_mod.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/divide/fp_mod.c */ /* Start: src/divide/fp_mod_d.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* c = a mod b, 0 <= c < b */ int fp_mod_d(fp_int *a, fp_digit b, fp_digit *c) { return fp_div_d(a, b, NULL, c); } /* $Source: /cvs/libtom/tomsfastmath/src/divide/fp_mod_d.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/divide/fp_mod_d.c */ /* Start: src/exptmod/fp_2expt.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* computes a = 2**b */ void fp_2expt(fp_int *a, int b) { int z; /* zero a as per default */ fp_zero (a); if (b < 0) { return; } z = b / DIGIT_BIT; if (z >= FP_SIZE) { return; } /* set the used count of where the bit will go */ a->used = z + 1; /* put the single bit in its place */ a->dp[z] = ((fp_digit)1) << (b % DIGIT_BIT); } /* $Source: /cvs/libtom/tomsfastmath/src/exptmod/fp_2expt.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/exptmod/fp_2expt.c */ /* Start: src/exptmod/fp_exptmod.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include #ifdef TFM_TIMING_RESISTANT /* timing resistant montgomery ladder based exptmod Based on work by Marc Joye, Sung-Ming Yen, "The Montgomery Powering Ladder", Cryptographic Hardware and Embedded Systems, CHES 2002 */ static int _fp_exptmod(fp_int * G, fp_int * X, fp_int * P, fp_int * Y) { fp_int R[2]; fp_digit buf, mp; int err, bitcnt, digidx, y; /* now setup montgomery */ if ((err = fp_montgomery_setup (P, &mp)) != FP_OKAY) { return err; } fp_init(&R[0]); fp_init(&R[1]); /* now we need R mod m */ fp_montgomery_calc_normalization (&R[0], P); /* now set R[0][1] to G * R mod m */ if (fp_cmp_mag(P, G) != FP_GT) { /* G > P so we reduce it first */ fp_mod(G, P, &R[1]); } else { fp_copy(G, &R[1]); } fp_mulmod (&R[1], &R[0], P, &R[1]); /* for j = t-1 downto 0 do r_!k = R0*R1; r_k = r_k^2 */ /* set initial mode and bit cnt */ bitcnt = 1; buf = 0; digidx = X->used - 1; for (;;) { /* grab next digit as required */ if (--bitcnt == 0) { /* if digidx == -1 we are out of digits so break */ if (digidx == -1) { break; } /* read next digit and reset bitcnt */ buf = X->dp[digidx--]; bitcnt = (int)DIGIT_BIT; } /* grab the next msb from the exponent */ y = (fp_digit)(buf >> (DIGIT_BIT - 1)) & 1; buf <<= (fp_digit)1; /* do ops */ fp_mul(&R[0], &R[1], &R[y^1]); fp_montgomery_reduce(&R[y^1], P, mp); fp_sqr(&R[y], &R[y]); fp_montgomery_reduce(&R[y], P, mp); } fp_montgomery_reduce(&R[0], P, mp); fp_copy(&R[0], Y); return FP_OKAY; } #else /* y = g**x (mod b) * Some restrictions... x must be positive and < b */ static int _fp_exptmod(fp_int * G, fp_int * X, fp_int * P, fp_int * Y) { fp_int M[64], res; fp_digit buf, mp; int err, bitbuf, bitcpy, bitcnt, mode, digidx, x, y, winsize; /* find window size */ x = fp_count_bits (X); if (x <= 21) { winsize = 1; } else if (x <= 36) { winsize = 3; } else if (x <= 140) { winsize = 4; } else if (x <= 450) { winsize = 5; } else { winsize = 6; } /* init M array */ memset(M, 0, sizeof(M)); /* now setup montgomery */ if ((err = fp_montgomery_setup (P, &mp)) != FP_OKAY) { return err; } /* setup result */ fp_init(&res); /* create M table * * The M table contains powers of the input base, e.g. M[x] = G^x mod P * * The first half of the table is not computed though accept for M[0] and M[1] */ /* now we need R mod m */ fp_montgomery_calc_normalization (&res, P); /* now set M[1] to G * R mod m */ if (fp_cmp_mag(P, G) != FP_GT) { /* G > P so we reduce it first */ fp_mod(G, P, &M[1]); } else { fp_copy(G, &M[1]); } fp_mulmod (&M[1], &res, P, &M[1]); /* compute the value at M[1<<(winsize-1)] by squaring M[1] (winsize-1) times */ fp_copy (&M[1], &M[1 << (winsize - 1)]); for (x = 0; x < (winsize - 1); x++) { fp_sqr (&M[1 << (winsize - 1)], &M[1 << (winsize - 1)]); fp_montgomery_reduce (&M[1 << (winsize - 1)], P, mp); } /* create upper table */ for (x = (1 << (winsize - 1)) + 1; x < (1 << winsize); x++) { fp_mul(&M[x - 1], &M[1], &M[x]); fp_montgomery_reduce(&M[x], P, mp); } /* set initial mode and bit cnt */ mode = 0; bitcnt = 1; buf = 0; digidx = X->used - 1; bitcpy = 0; bitbuf = 0; for (;;) { /* grab next digit as required */ if (--bitcnt == 0) { /* if digidx == -1 we are out of digits so break */ if (digidx == -1) { break; } /* read next digit and reset bitcnt */ buf = X->dp[digidx--]; bitcnt = (int)DIGIT_BIT; } /* grab the next msb from the exponent */ y = (fp_digit)(buf >> (DIGIT_BIT - 1)) & 1; buf <<= (fp_digit)1; /* if the bit is zero and mode == 0 then we ignore it * These represent the leading zero bits before the first 1 bit * in the exponent. Technically this opt is not required but it * does lower the # of trivial squaring/reductions used */ if (mode == 0 && y == 0) { continue; } /* if the bit is zero and mode == 1 then we square */ if (mode == 1 && y == 0) { fp_sqr(&res, &res); fp_montgomery_reduce(&res, P, mp); continue; } /* else we add it to the window */ bitbuf |= (y << (winsize - ++bitcpy)); mode = 2; if (bitcpy == winsize) { /* ok window is filled so square as required and multiply */ /* square first */ for (x = 0; x < winsize; x++) { fp_sqr(&res, &res); fp_montgomery_reduce(&res, P, mp); } /* then multiply */ fp_mul(&res, &M[bitbuf], &res); fp_montgomery_reduce(&res, P, mp); /* empty window and reset */ bitcpy = 0; bitbuf = 0; mode = 1; } } /* if bits remain then square/multiply */ if (mode == 2 && bitcpy > 0) { /* square then multiply if the bit is set */ for (x = 0; x < bitcpy; x++) { fp_sqr(&res, &res); fp_montgomery_reduce(&res, P, mp); /* get next bit of the window */ bitbuf <<= 1; if ((bitbuf & (1 << winsize)) != 0) { /* then multiply */ fp_mul(&res, &M[1], &res); fp_montgomery_reduce(&res, P, mp); } } } /* fixup result if Montgomery reduction is used * recall that any value in a Montgomery system is * actually multiplied by R mod n. So we have * to reduce one more time to cancel out the factor * of R. */ fp_montgomery_reduce(&res, P, mp); /* swap res with Y */ fp_copy (&res, Y); return FP_OKAY; } #endif int fp_exptmod(fp_int * G, fp_int * X, fp_int * P, fp_int * Y) { fp_int tmp; int err; #ifdef TFM_CHECK /* prevent overflows */ if (P->used > (FP_SIZE/2)) { return FP_VAL; } #endif /* is X negative? */ if (X->sign == FP_NEG) { /* yes, copy G and invmod it */ fp_copy(G, &tmp); if ((err = fp_invmod(&tmp, P, &tmp)) != FP_OKAY) { return err; } X->sign = FP_ZPOS; err = _fp_exptmod(&tmp, X, P, Y); if (X != Y) { X->sign = FP_NEG; } return err; } else { /* Positive exponent so just exptmod */ return _fp_exptmod(G, X, P, Y); } } /* $Source: /cvs/libtom/tomsfastmath/src/exptmod/fp_exptmod.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/exptmod/fp_exptmod.c */ /* Start: src/misc/fp_ident.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include "tfm.h" const char *fp_ident(void) { static char buf[1024]; memset(buf, 0, sizeof(buf)); snprintf(buf, sizeof(buf)-1, "TomsFastMath (%s)\n" "\n" "Sizeofs\n" "\tfp_digit = %u\n" "\tfp_word = %u\n" "\n" "FP_MAX_SIZE = %u\n" "\n" "Defines: \n" #ifdef __i386__ " __i386__ " #endif #ifdef __x86_64__ " __x86_64__ " #endif #ifdef TFM_X86 " TFM_X86 " #endif #ifdef TFM_X86_64 " TFM_X86_64 " #endif #ifdef TFM_SSE2 " TFM_SSE2 " #endif #ifdef TFM_ARM " TFM_ARM " #endif #ifdef TFM_PPC32 " TFM_PPC32 " #endif #ifdef TFM_AVR32 " TFM_AVR32 " #endif #ifdef TFM_ECC192 " TFM_ECC192 " #endif #ifdef TFM_ECC224 " TFM_ECC224 " #endif #ifdef TFM_ECC384 " TFM_ECC384 " #endif #ifdef TFM_ECC521 " TFM_ECC521 " #endif #ifdef TFM_NO_ASM " TFM_NO_ASM " #endif #ifdef FP_64BIT " FP_64BIT " #endif #ifdef TFM_HUGE " TFM_HUGE " #endif "\n", __DATE__, sizeof(fp_digit), sizeof(fp_word), FP_MAX_SIZE); if (sizeof(fp_digit) == sizeof(fp_word)) { strncat(buf, "WARNING: sizeof(fp_digit) == sizeof(fp_word), this build is likely to not work properly.\n", sizeof(buf)-1); } return buf; } #ifdef STANDALONE int main(void) { printf("%s\n", fp_ident()); return 0; } #endif /* $Source: /cvs/libtom/tomsfastmath/src/misc/fp_ident.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/misc/fp_ident.c */ /* Start: src/misc/fp_set.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include void fp_set(fp_int *a, fp_digit b) { fp_zero(a); a->dp[0] = b; a->used = a->dp[0] ? 1 : 0; } /* $Source: /cvs/libtom/tomsfastmath/src/misc/fp_set.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/misc/fp_set.c */ /* Start: src/mont/fp_montgomery_calc_normalization.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* computes a = B**n mod b without division or multiplication useful for * normalizing numbers in a Montgomery system. */ void fp_montgomery_calc_normalization(fp_int *a, fp_int *b) { int x, bits; /* how many bits of last digit does b use */ bits = fp_count_bits (b) % DIGIT_BIT; if (!bits) bits = DIGIT_BIT; /* compute A = B^(n-1) * 2^(bits-1) */ if (b->used > 1) { fp_2expt (a, (b->used - 1) * DIGIT_BIT + bits - 1); } else { fp_set(a, 1); bits = 1; } /* now compute C = A * B mod b */ for (x = bits - 1; x < (int)DIGIT_BIT; x++) { fp_mul_2 (a, a); if (fp_cmp_mag (a, b) != FP_LT) { s_fp_sub (a, b, a); } } } /* $Source: /cvs/libtom/tomsfastmath/src/mont/fp_montgomery_calc_normalization.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/mont/fp_montgomery_calc_normalization.c */ /* Start: src/mont/fp_montgomery_reduce.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /******************************************************************/ #if defined(TFM_X86) && !defined(TFM_SSE2) /* x86-32 code */ #define MONT_START #define MONT_FINI #define LOOP_END #define LOOP_START \ mu = c[x] * mp #define INNERMUL \ asm( \ "movl %5,%%eax \n\t" \ "mull %4 \n\t" \ "addl %1,%%eax \n\t" \ "adcl $0,%%edx \n\t" \ "addl %%eax,%0 \n\t" \ "adcl $0,%%edx \n\t" \ "movl %%edx,%1 \n\t" \ :"=g"(_c[LO]), "=r"(cy) \ :"0"(_c[LO]), "1"(cy), "g"(mu), "g"(*tmpm++) \ : "%eax", "%edx", "%cc") #define PROPCARRY \ asm( \ "addl %1,%0 \n\t" \ "setb %%al \n\t" \ "movzbl %%al,%1 \n\t" \ :"=g"(_c[LO]), "=r"(cy) \ :"0"(_c[LO]), "1"(cy) \ : "%eax", "%cc") /******************************************************************/ #elif defined(TFM_X86_64) /* x86-64 code */ #define MONT_START #define MONT_FINI #define LOOP_END #define LOOP_START \ mu = c[x] * mp #define INNERMUL \ asm( \ "movq %5,%%rax \n\t" \ "mulq %4 \n\t" \ "addq %1,%%rax \n\t" \ "adcq $0,%%rdx \n\t" \ "addq %%rax,%0 \n\t" \ "adcq $0,%%rdx \n\t" \ "movq %%rdx,%1 \n\t" \ :"=g"(_c[LO]), "=r"(cy) \ :"0"(_c[LO]), "1"(cy), "r"(mu), "r"(*tmpm++) \ : "%rax", "%rdx", "%cc") #define INNERMUL8 \ asm( \ "movq 0(%5),%%rax \n\t" \ "movq 0(%2),%%r10 \n\t" \ "movq 0x8(%5),%%r11 \n\t" \ "mulq %4 \n\t" \ "addq %%r10,%%rax \n\t" \ "adcq $0,%%rdx \n\t" \ "movq 0x8(%2),%%r10 \n\t" \ "addq %3,%%rax \n\t" \ "adcq $0,%%rdx \n\t" \ "movq %%rax,0(%0) \n\t" \ "movq %%rdx,%1 \n\t" \ \ "movq %%r11,%%rax \n\t" \ "movq 0x10(%5),%%r11 \n\t" \ "mulq %4 \n\t" \ "addq %%r10,%%rax \n\t" \ "adcq $0,%%rdx \n\t" \ "movq 0x10(%2),%%r10 \n\t" \ "addq %3,%%rax \n\t" \ "adcq $0,%%rdx \n\t" \ "movq %%rax,0x8(%0) \n\t" \ "movq %%rdx,%1 \n\t" \ \ "movq %%r11,%%rax \n\t" \ "movq 0x18(%5),%%r11 \n\t" \ "mulq %4 \n\t" \ "addq %%r10,%%rax \n\t" \ "adcq $0,%%rdx \n\t" \ "movq 0x18(%2),%%r10 \n\t" \ "addq %3,%%rax \n\t" \ "adcq $0,%%rdx \n\t" \ "movq %%rax,0x10(%0) \n\t" \ "movq %%rdx,%1 \n\t" \ \ "movq %%r11,%%rax \n\t" \ "movq 0x20(%5),%%r11 \n\t" \ "mulq %4 \n\t" \ "addq %%r10,%%rax \n\t" \ "adcq $0,%%rdx \n\t" \ "movq 0x20(%2),%%r10 \n\t" \ "addq %3,%%rax \n\t" \ "adcq $0,%%rdx \n\t" \ "movq %%rax,0x18(%0) \n\t" \ "movq %%rdx,%1 \n\t" \ \ "movq %%r11,%%rax \n\t" \ "movq 0x28(%5),%%r11 \n\t" \ "mulq %4 \n\t" \ "addq %%r10,%%rax \n\t" \ "adcq $0,%%rdx \n\t" \ "movq 0x28(%2),%%r10 \n\t" \ "addq %3,%%rax \n\t" \ "adcq $0,%%rdx \n\t" \ "movq %%rax,0x20(%0) \n\t" \ "movq %%rdx,%1 \n\t" \ \ "movq %%r11,%%rax \n\t" \ "movq 0x30(%5),%%r11 \n\t" \ "mulq %4 \n\t" \ "addq %%r10,%%rax \n\t" \ "adcq $0,%%rdx \n\t" \ "movq 0x30(%2),%%r10 \n\t" \ "addq %3,%%rax \n\t" \ "adcq $0,%%rdx \n\t" \ "movq %%rax,0x28(%0) \n\t" \ "movq %%rdx,%1 \n\t" \ \ "movq %%r11,%%rax \n\t" \ "movq 0x38(%5),%%r11 \n\t" \ "mulq %4 \n\t" \ "addq %%r10,%%rax \n\t" \ "adcq $0,%%rdx \n\t" \ "movq 0x38(%2),%%r10 \n\t" \ "addq %3,%%rax \n\t" \ "adcq $0,%%rdx \n\t" \ "movq %%rax,0x30(%0) \n\t" \ "movq %%rdx,%1 \n\t" \ \ "movq %%r11,%%rax \n\t" \ "mulq %4 \n\t" \ "addq %%r10,%%rax \n\t" \ "adcq $0,%%rdx \n\t" \ "addq %3,%%rax \n\t" \ "adcq $0,%%rdx \n\t" \ "movq %%rax,0x38(%0) \n\t" \ "movq %%rdx,%1 \n\t" \ \ :"=r"(_c), "=r"(cy) \ : "0"(_c), "1"(cy), "g"(mu), "r"(tmpm)\ : "%rax", "%rdx", "%r10", "%r11", "%cc") #define PROPCARRY \ asm( \ "addq %1,%0 \n\t" \ "setb %%al \n\t" \ "movzbq %%al,%1 \n\t" \ :"=g"(_c[LO]), "=r"(cy) \ :"0"(_c[LO]), "1"(cy) \ : "%rax", "%cc") /******************************************************************/ #elif defined(TFM_SSE2) /* SSE2 code (assumes 32-bit fp_digits) */ /* XMM register assignments: * xmm0 *tmpm++, then Mu * (*tmpm++) * xmm1 c[x], then Mu * xmm2 mp * xmm3 cy * xmm4 _c[LO] */ #define MONT_START \ asm("movd %0,%%mm2"::"g"(mp)) #define MONT_FINI \ asm("emms") #define LOOP_START \ asm( \ "movd %0,%%mm1 \n\t" \ "pxor %%mm3,%%mm3 \n\t" \ "pmuludq %%mm2,%%mm1 \n\t" \ :: "g"(c[x])) /* pmuludq on mmx registers does a 32x32->64 multiply. */ #define INNERMUL \ asm( \ "movd %1,%%mm4 \n\t" \ "movd %2,%%mm0 \n\t" \ "paddq %%mm4,%%mm3 \n\t" \ "pmuludq %%mm1,%%mm0 \n\t" \ "paddq %%mm0,%%mm3 \n\t" \ "movd %%mm3,%0 \n\t" \ "psrlq $32, %%mm3 \n\t" \ :"=g"(_c[LO]) : "0"(_c[LO]), "g"(*tmpm++) ); #define INNERMUL8 \ asm( \ "movd 0(%1),%%mm4 \n\t" \ "movd 0(%2),%%mm0 \n\t" \ "paddq %%mm4,%%mm3 \n\t" \ "pmuludq %%mm1,%%mm0 \n\t" \ "movd 4(%2),%%mm5 \n\t" \ "paddq %%mm0,%%mm3 \n\t" \ "movd 4(%1),%%mm6 \n\t" \ "movd %%mm3,0(%0) \n\t" \ "psrlq $32, %%mm3 \n\t" \ \ "paddq %%mm6,%%mm3 \n\t" \ "pmuludq %%mm1,%%mm5 \n\t" \ "movd 8(%2),%%mm6 \n\t" \ "paddq %%mm5,%%mm3 \n\t" \ "movd 8(%1),%%mm7 \n\t" \ "movd %%mm3,4(%0) \n\t" \ "psrlq $32, %%mm3 \n\t" \ \ "paddq %%mm7,%%mm3 \n\t" \ "pmuludq %%mm1,%%mm6 \n\t" \ "movd 12(%2),%%mm7 \n\t" \ "paddq %%mm6,%%mm3 \n\t" \ "movd 12(%1),%%mm5 \n\t" \ "movd %%mm3,8(%0) \n\t" \ "psrlq $32, %%mm3 \n\t" \ \ "paddq %%mm5,%%mm3 \n\t" \ "pmuludq %%mm1,%%mm7 \n\t" \ "movd 16(%2),%%mm5 \n\t" \ "paddq %%mm7,%%mm3 \n\t" \ "movd 16(%1),%%mm6 \n\t" \ "movd %%mm3,12(%0) \n\t" \ "psrlq $32, %%mm3 \n\t" \ \ "paddq %%mm6,%%mm3 \n\t" \ "pmuludq %%mm1,%%mm5 \n\t" \ "movd 20(%2),%%mm6 \n\t" \ "paddq %%mm5,%%mm3 \n\t" \ "movd 20(%1),%%mm7 \n\t" \ "movd %%mm3,16(%0) \n\t" \ "psrlq $32, %%mm3 \n\t" \ \ "paddq %%mm7,%%mm3 \n\t" \ "pmuludq %%mm1,%%mm6 \n\t" \ "movd 24(%2),%%mm7 \n\t" \ "paddq %%mm6,%%mm3 \n\t" \ "movd 24(%1),%%mm5 \n\t" \ "movd %%mm3,20(%0) \n\t" \ "psrlq $32, %%mm3 \n\t" \ \ "paddq %%mm5,%%mm3 \n\t" \ "pmuludq %%mm1,%%mm7 \n\t" \ "movd 28(%2),%%mm5 \n\t" \ "paddq %%mm7,%%mm3 \n\t" \ "movd 28(%1),%%mm6 \n\t" \ "movd %%mm3,24(%0) \n\t" \ "psrlq $32, %%mm3 \n\t" \ \ "paddq %%mm6,%%mm3 \n\t" \ "pmuludq %%mm1,%%mm5 \n\t" \ "paddq %%mm5,%%mm3 \n\t" \ "movd %%mm3,28(%0) \n\t" \ "psrlq $32, %%mm3 \n\t" \ :"=r"(_c) : "0"(_c), "g"(tmpm) ); #define LOOP_END \ asm( "movd %%mm3,%0 \n" :"=r"(cy)) #define PROPCARRY \ asm( \ "addl %1,%0 \n\t" \ "setb %%al \n\t" \ "movzbl %%al,%1 \n\t" \ :"=g"(_c[LO]), "=r"(cy) \ :"0"(_c[LO]), "1"(cy) \ : "%eax", "%cc") /******************************************************************/ #elif defined(TFM_ARM) /* ARMv4 code */ #define MONT_START #define MONT_FINI #define LOOP_END #define LOOP_START \ mu = c[x] * mp #define INNERMUL \ asm( \ " LDR r0,%1 \n\t" \ " ADDS r0,r0,%0 \n\t" \ " MOVCS %0,#1 \n\t" \ " MOVCC %0,#0 \n\t" \ " UMLAL r0,%0,%3,%4 \n\t" \ " STR r0,%1 \n\t" \ :"=r"(cy),"=m"(_c[0]):"0"(cy),"r"(mu),"r"(*tmpm++),"1"(_c[0]):"r0","%cc"); #define PROPCARRY \ asm( \ " LDR r0,%1 \n\t" \ " ADDS r0,r0,%0 \n\t" \ " STR r0,%1 \n\t" \ " MOVCS %0,#1 \n\t" \ " MOVCC %0,#0 \n\t" \ :"=r"(cy),"=m"(_c[0]):"0"(cy),"1"(_c[0]):"r0","%cc"); /******************************************************************/ #elif defined(TFM_PPC32) /* PPC32 */ #define MONT_START #define MONT_FINI #define LOOP_END #define LOOP_START \ mu = c[x] * mp #define INNERMUL \ asm( \ " mullw 16,%3,%4 \n\t" \ " mulhwu 17,%3,%4 \n\t" \ " addc 16,16,%0 \n\t" \ " addze 17,17 \n\t" \ " lwz 18,%1 \n\t" \ " addc 16,16,18 \n\t" \ " addze %0,17 \n\t" \ " stw 16,%1 \n\t" \ :"=r"(cy),"=m"(_c[0]):"0"(cy),"r"(mu),"r"(tmpm[0]),"1"(_c[0]):"16", "17", "18","%cc"); ++tmpm; #define PROPCARRY \ asm( \ " lwz 16,%1 \n\t" \ " addc 16,16,%0 \n\t" \ " stw 16,%1 \n\t" \ " xor %0,%0,%0 \n\t" \ " addze %0,%0 \n\t" \ :"=r"(cy),"=m"(_c[0]):"0"(cy),"1"(_c[0]):"16","%cc"); /******************************************************************/ #elif defined(TFM_PPC64) /* PPC64 */ #define MONT_START #define MONT_FINI #define LOOP_END #define LOOP_START \ mu = c[x] * mp #define INNERMUL \ asm( \ " mulld r16,%3,%4 \n\t" \ " mulhdu r17,%3,%4 \n\t" \ " addc r16,16,%0 \n\t" \ " addze r17,r17 \n\t" \ " ldx r18,0,%1 \n\t" \ " addc r16,r16,r18 \n\t" \ " addze %0,r17 \n\t" \ " sdx r16,0,%1 \n\t" \ :"=r"(cy),"=m"(_c[0]):"0"(cy),"r"(mu),"r"(tmpm[0]),"1"(_c[0]):"r16", "r17", "r18","%cc"); ++tmpm; #define PROPCARRY \ asm( \ " ldx r16,0,%1 \n\t" \ " addc r16,r16,%0 \n\t" \ " sdx r16,0,%1 \n\t" \ " xor %0,%0,%0 \n\t" \ " addze %0,%0 \n\t" \ :"=r"(cy),"=m"(_c[0]):"0"(cy),"1"(_c[0]):"r16","%cc"); /******************************************************************/ #elif defined(TFM_AVR32) /* AVR32 */ #define MONT_START #define MONT_FINI #define LOOP_END #define LOOP_START \ mu = c[x] * mp #define INNERMUL \ asm( \ " ld.w r2,%1 \n\t" \ " add r2,%0 \n\t" \ " eor r3,r3 \n\t" \ " acr r3 \n\t" \ " macu.d r2,%3,%4 \n\t" \ " st.w %1,r2 \n\t" \ " mov %0,r3 \n\t" \ :"=r"(cy),"=r"(_c):"0"(cy),"r"(mu),"r"(*tmpm++),"1"(_c):"r2","r3"); #define PROPCARRY \ asm( \ " ld.w r2,%1 \n\t" \ " add r2,%0 \n\t" \ " st.w %1,r2 \n\t" \ " eor %0,%0 \n\t" \ " acr %0 \n\t" \ :"=r"(cy),"=r"(&_c[0]):"0"(cy),"1"(&_c[0]):"r2","%cc"); /******************************************************************/ #elif defined(TFM_MIPS) /* MIPS */ #define MONT_START #define MONT_FINI #define LOOP_END #define LOOP_START \ mu = c[x] * mp #define INNERMUL \ asm( \ " multu %3,%4 \n\t" \ " mflo $12 \n\t" \ " mfhi $13 \n\t" \ " addu $12,$12,%0 \n\t" \ " sltu $10,$12,%0 \n\t" \ " addu $13,$13,$10 \n\t" \ " lw $10,%1 \n\t" \ " addu $12,$12,$10 \n\t" \ " sltu $10,$12,$10 \n\t" \ " addu %0,$13,$10 \n\t" \ " sw $12,%1 \n\t" \ :"=r"(cy),"=m"(_c[0]):"0"(cy),"r"(mu),"r"(tmpm[0]),"1"(_c[0]):"$10","$12","$13"); ++tmpm; #define PROPCARRY \ asm( \ " lw $10,%1 \n\t" \ " addu $10,$10,%0 \n\t" \ " sw $10,%1 \n\t" \ " sltu %0,$10,%0 \n\t" \ :"=r"(cy),"=m"(_c[0]):"0"(cy),"1"(_c[0]):"$10"); /******************************************************************/ #else /* ISO C code */ #define MONT_START #define MONT_FINI #define LOOP_END #define LOOP_START \ mu = c[x] * mp #define INNERMUL \ do { fp_word t; \ _c[0] = t = ((fp_word)_c[0] + (fp_word)cy) + \ (((fp_word)mu) * ((fp_word)*tmpm++)); \ cy = (t >> DIGIT_BIT); \ } while (0) #define PROPCARRY \ do { fp_digit t = _c[0] += cy; cy = (t < cy); } while (0) #endif /******************************************************************/ #define LO 0 #ifdef TFM_SMALL_MONT_SET #include "fp_mont_small.i" #endif /* computes x/R == x (mod N) via Montgomery Reduction */ void fp_montgomery_reduce(fp_int *a, fp_int *m, fp_digit mp) { fp_digit c[FP_SIZE], *_c, *tmpm, mu; int oldused, x, y, pa; /* bail if too large */ if (m->used > (FP_SIZE/2)) { return; } #ifdef TFM_SMALL_MONT_SET if (m->used <= 16) { fp_montgomery_reduce_small(a, m, mp); return; } #endif #if defined(USE_MEMSET) /* now zero the buff */ memset(c, 0, sizeof c); #endif pa = m->used; /* copy the input */ oldused = a->used; for (x = 0; x < oldused; x++) { c[x] = a->dp[x]; } #if !defined(USE_MEMSET) for (; x < 2*pa+1; x++) { c[x] = 0; } #endif MONT_START; for (x = 0; x < pa; x++) { fp_digit cy = 0; /* get Mu for this round */ LOOP_START; _c = c + x; tmpm = m->dp; y = 0; #if (defined(TFM_SSE2) || defined(TFM_X86_64)) for (; y < (pa & ~7); y += 8) { INNERMUL8; _c += 8; tmpm += 8; } #endif for (; y < pa; y++) { INNERMUL; ++_c; } LOOP_END; while (cy) { PROPCARRY; ++_c; } } /* now copy out */ _c = c + pa; tmpm = a->dp; for (x = 0; x < pa+1; x++) { *tmpm++ = *_c++; } for (; x < oldused; x++) { *tmpm++ = 0; } MONT_FINI; a->used = pa+1; fp_clamp(a); /* if A >= m then A = A - m */ if (fp_cmp_mag (a, m) != FP_LT) { s_fp_sub (a, m, a); } } /* $Source: /cvs/libtom/tomsfastmath/src/mont/fp_montgomery_reduce.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/03/14 23:47:42 $ */ /* End: src/mont/fp_montgomery_reduce.c */ /* Start: src/mont/fp_montgomery_setup.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* setups the montgomery reduction */ int fp_montgomery_setup(fp_int *a, fp_digit *rho) { fp_digit x, b; /* fast inversion mod 2**k * * Based on the fact that * * XA = 1 (mod 2**n) => (X(2-XA)) A = 1 (mod 2**2n) * => 2*X*A - X*X*A*A = 1 * => 2*(1) - (1) = 1 */ b = a->dp[0]; if ((b & 1) == 0) { return FP_VAL; } x = (((b + 2) & 4) << 1) + b; /* here x*a==1 mod 2**4 */ x *= 2 - b * x; /* here x*a==1 mod 2**8 */ x *= 2 - b * x; /* here x*a==1 mod 2**16 */ x *= 2 - b * x; /* here x*a==1 mod 2**32 */ #ifdef FP_64BIT x *= 2 - b * x; /* here x*a==1 mod 2**64 */ #endif /* rho = -1/m mod b */ *rho = (((fp_word) 1 << ((fp_word) DIGIT_BIT)) - ((fp_word)x)); return FP_OKAY; } /* $Source: /cvs/libtom/tomsfastmath/src/mont/fp_montgomery_setup.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/mont/fp_montgomery_setup.c */ /* Start: src/mul/fp_mul.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* c = a * b */ void fp_mul(fp_int *A, fp_int *B, fp_int *C) { int y, yy; /* call generic if we're out of range */ if (A->used + B->used > FP_SIZE) { fp_mul_comba(A, B, C); return ; } y = MAX(A->used, B->used); yy = MIN(A->used, B->used); /* pick a comba (unrolled 4/8/16/32 x or rolled) based on the size of the largest input. We also want to avoid doing excess mults if the inputs are not close to the next power of two. That is, for example, if say y=17 then we would do (32-17)^2 = 225 unneeded multiplications */ #ifdef TFM_MUL3 if (y <= 3) { fp_mul_comba3(A,B,C); return; } #endif #ifdef TFM_MUL4 if (y == 4) { fp_mul_comba4(A,B,C); return; } #endif #ifdef TFM_MUL6 if (y <= 6) { fp_mul_comba6(A,B,C); return; } #endif #ifdef TFM_MUL7 if (y == 7) { fp_mul_comba7(A,B,C); return; } #endif #ifdef TFM_MUL8 if (y == 8) { fp_mul_comba8(A,B,C); return; } #endif #ifdef TFM_MUL9 if (y == 9) { fp_mul_comba9(A,B,C); return; } #endif #ifdef TFM_MUL12 if (y <= 12) { fp_mul_comba12(A,B,C); return; } #endif #ifdef TFM_MUL17 if (y <= 17) { fp_mul_comba17(A,B,C); return; } #endif #ifdef TFM_SMALL_SET if (y <= 16) { fp_mul_comba_small(A,B,C); return; } #endif #if defined(TFM_MUL20) if (y <= 20) { fp_mul_comba20(A,B,C); return; } #endif #if defined(TFM_MUL24) if (yy >= 16 && y <= 24) { fp_mul_comba24(A,B,C); return; } #endif #if defined(TFM_MUL28) if (yy >= 20 && y <= 28) { fp_mul_comba28(A,B,C); return; } #endif #if defined(TFM_MUL32) if (yy >= 24 && y <= 32) { fp_mul_comba32(A,B,C); return; } #endif #if defined(TFM_MUL48) if (yy >= 40 && y <= 48) { fp_mul_comba48(A,B,C); return; } #endif #if defined(TFM_MUL64) if (yy >= 56 && y <= 64) { fp_mul_comba64(A,B,C); return; } #endif fp_mul_comba(A,B,C); } /* $Source: /cvs/libtom/tomsfastmath/src/mul/fp_mul.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/mul/fp_mul.c */ /* Start: src/mul/fp_mul_2.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include void fp_mul_2(fp_int * a, fp_int * b) { int x, oldused; oldused = b->used; b->used = a->used; { register fp_digit r, rr, *tmpa, *tmpb; /* alias for source */ tmpa = a->dp; /* alias for dest */ tmpb = b->dp; /* carry */ r = 0; for (x = 0; x < a->used; x++) { /* get what will be the *next* carry bit from the * MSB of the current digit */ rr = *tmpa >> ((fp_digit)(DIGIT_BIT - 1)); /* now shift up this digit, add in the carry [from the previous] */ *tmpb++ = ((*tmpa++ << ((fp_digit)1)) | r); /* copy the carry that would be from the source * digit into the next iteration */ r = rr; } /* new leading digit? */ if (r != 0 && b->used != (FP_SIZE-1)) { /* add a MSB which is always 1 at this point */ *tmpb = 1; ++(b->used); } /* now zero any excess digits on the destination * that we didn't write to */ tmpb = b->dp + b->used; for (x = b->used; x < oldused; x++) { *tmpb++ = 0; } } b->sign = a->sign; } /* $Source: /cvs/libtom/tomsfastmath/src/mul/fp_mul_2.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/mul/fp_mul_2.c */ /* Start: src/mul/fp_mul_2d.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* c = a * 2**d */ void fp_mul_2d(fp_int *a, int b, fp_int *c) { fp_digit carry, carrytmp, shift; int x; /* copy it */ fp_copy(a, c); /* handle whole digits */ if (b >= DIGIT_BIT) { fp_lshd(c, b/DIGIT_BIT); } b %= DIGIT_BIT; /* shift the digits */ if (b != 0) { carry = 0; shift = DIGIT_BIT - b; for (x = 0; x < c->used; x++) { carrytmp = c->dp[x] >> shift; c->dp[x] = (c->dp[x] << b) + carry; carry = carrytmp; } /* store last carry if room */ if (carry && x < FP_SIZE) { c->dp[c->used++] = carry; } } fp_clamp(c); } /* $Source: /cvs/libtom/tomsfastmath/src/mul/fp_mul_2d.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/mul/fp_mul_2d.c */ /* Start: src/mul/fp_mul_comba.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ /* About this file... */ #include #if defined(TFM_PRESCOTT) && defined(TFM_SSE2) #undef TFM_SSE2 #define TFM_X86 #endif /* these are the combas. Worship them. */ #if defined(TFM_X86) /* Generic x86 optimized code */ /* anything you need at the start */ #define COMBA_START /* clear the chaining variables */ #define COMBA_CLEAR \ c0 = c1 = c2 = 0; /* forward the carry to the next digit */ #define COMBA_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); /* store the first sum */ #define COMBA_STORE(x) \ x = c0; /* store the second sum [carry] */ #define COMBA_STORE2(x) \ x = c1; /* anything you need at the end */ #define COMBA_FINI /* this should multiply i and j */ #define MULADD(i, j) \ asm( \ "movl %6,%%eax \n\t" \ "mull %7 \n\t" \ "addl %%eax,%0 \n\t" \ "adcl %%edx,%1 \n\t" \ "adcl $0,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "m"(i), "m"(j) :"%eax","%edx","%cc"); #elif defined(TFM_X86_64) /* x86-64 optimized */ /* anything you need at the start */ #define COMBA_START /* clear the chaining variables */ #define COMBA_CLEAR \ c0 = c1 = c2 = 0; /* forward the carry to the next digit */ #define COMBA_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); /* store the first sum */ #define COMBA_STORE(x) \ x = c0; /* store the second sum [carry] */ #define COMBA_STORE2(x) \ x = c1; /* anything you need at the end */ #define COMBA_FINI /* this should multiply i and j */ #define MULADD(i, j) \ asm ( \ "movq %6,%%rax \n\t" \ "mulq %7 \n\t" \ "addq %%rax,%0 \n\t" \ "adcq %%rdx,%1 \n\t" \ "adcq $0,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "g"(i), "g"(j) :"%rax","%rdx","%cc"); #elif defined(TFM_SSE2) /* use SSE2 optimizations */ /* anything you need at the start */ #define COMBA_START /* clear the chaining variables */ #define COMBA_CLEAR \ c0 = c1 = c2 = 0; /* forward the carry to the next digit */ #define COMBA_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); /* store the first sum */ #define COMBA_STORE(x) \ x = c0; /* store the second sum [carry] */ #define COMBA_STORE2(x) \ x = c1; /* anything you need at the end */ #define COMBA_FINI \ asm("emms"); /* this should multiply i and j */ #define MULADD(i, j) \ asm( \ "movd %6,%%mm0 \n\t" \ "movd %7,%%mm1 \n\t" \ "pmuludq %%mm1,%%mm0\n\t" \ "movd %%mm0,%%eax \n\t" \ "psrlq $32,%%mm0 \n\t" \ "addl %%eax,%0 \n\t" \ "movd %%mm0,%%eax \n\t" \ "adcl %%eax,%1 \n\t" \ "adcl $0,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "m"(i), "m"(j) :"%eax","%cc"); #elif defined(TFM_ARM) /* ARM code */ #define COMBA_START #define COMBA_CLEAR \ c0 = c1 = c2 = 0; #define COMBA_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); #define COMBA_STORE(x) \ x = c0; #define COMBA_STORE2(x) \ x = c1; #define COMBA_FINI #define MULADD(i, j) \ asm( \ " UMULL r0,r1,%6,%7 \n\t" \ " ADDS %0,%0,r0 \n\t" \ " ADCS %1,%1,r1 \n\t" \ " ADC %2,%2,#0 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2) : "0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j) : "r0", "r1", "%cc"); #elif defined(TFM_PPC32) /* For 32-bit PPC */ #define COMBA_START #define COMBA_CLEAR \ c0 = c1 = c2 = 0; #define COMBA_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); #define COMBA_STORE(x) \ x = c0; #define COMBA_STORE2(x) \ x = c1; #define COMBA_FINI /* untested: will mulhwu change the flags? Docs say no */ #define MULADD(i, j) \ asm( \ " mullw 16,%6,%7 \n\t" \ " addc %0,%0,16 \n\t" \ " mulhwu 16,%6,%7 \n\t" \ " adde %1,%1,16 \n\t" \ " addze %2,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j):"16"); #elif defined(TFM_PPC64) /* For 64-bit PPC */ #define COMBA_START #define COMBA_CLEAR \ c0 = c1 = c2 = 0; #define COMBA_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); #define COMBA_STORE(x) \ x = c0; #define COMBA_STORE2(x) \ x = c1; #define COMBA_FINI /* untested: will mulhdu change the flags? Docs say no */ #define MULADD(i, j) \ asm( \ " mulld r16,%6,%7 \n\t" \ " addc %0,%0,16 \n\t" \ " mulhdu r16,%6,%7 \n\t" \ " adde %1,%1,16 \n\t" \ " addze %2,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j):"r16"); #elif defined(TFM_AVR32) /* ISO C code */ #define COMBA_START #define COMBA_CLEAR \ c0 = c1 = c2 = 0; #define COMBA_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); #define COMBA_STORE(x) \ x = c0; #define COMBA_STORE2(x) \ x = c1; #define COMBA_FINI #define MULADD(i, j) \ asm( \ " mulu.d r2,%6,%7 \n\t"\ " add %0,r2 \n\t"\ " adc %1,%1,r3 \n\t"\ " acr %2 \n\t"\ :"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j):"r2","r3"); #elif defined(TFM_MIPS) #define COMBA_START #define COMBA_CLEAR \ c0 = c1 = c2 = 0; #define COMBA_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); #define COMBA_STORE(x) \ x = c0; #define COMBA_STORE2(x) \ x = c1; #define COMBA_FINI #define MULADD(i, j) \ asm( \ " multu %6,%7 \n\t" \ " mflo $12 \n\t" \ " mfhi $13 \n\t" \ " addu %0,%0,$12 \n\t" \ " sltu $12,%0,$12 \n\t" \ " addu %1,%1,$13 \n\t" \ " sltu $13,%1,$13 \n\t" \ " addu %1,%1,$12 \n\t" \ " sltu $12,%1,$12 \n\t" \ " addu %2,%2,$13 \n\t" \ " addu %2,%2,$12 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j):"$12","$13"); #else /* ISO C code */ #define COMBA_START #define COMBA_CLEAR \ c0 = c1 = c2 = 0; #define COMBA_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); #define COMBA_STORE(x) \ x = c0; #define COMBA_STORE2(x) \ x = c1; #define COMBA_FINI #define MULADD(i, j) \ do { fp_word t; \ t = (fp_word)c0 + ((fp_word)i) * ((fp_word)j); c0 = t; \ t = (fp_word)c1 + (t >> DIGIT_BIT); c1 = t; c2 += t >> DIGIT_BIT; \ } while (0); #endif #ifndef TFM_DEFINES /* generic PxQ multiplier */ void fp_mul_comba(fp_int *A, fp_int *B, fp_int *C) { int ix, iy, iz, tx, ty, pa; fp_digit c0, c1, c2, *tmpx, *tmpy; fp_int tmp, *dst; COMBA_START; COMBA_CLEAR; /* get size of output and trim */ pa = A->used + B->used; if (pa >= FP_SIZE) { pa = FP_SIZE-1; } if (A == C || B == C) { fp_zero(&tmp); dst = &tmp; } else { fp_zero(C); dst = C; } for (ix = 0; ix < pa; ix++) { /* get offsets into the two bignums */ ty = MIN(ix, B->used-1); tx = ix - ty; /* setup temp aliases */ tmpx = A->dp + tx; tmpy = B->dp + ty; /* this is the number of times the loop will iterrate, essentially its while (tx++ < a->used && ty-- >= 0) { ... } */ iy = MIN(A->used-tx, ty+1); /* execute loop */ COMBA_FORWARD; for (iz = 0; iz < iy; ++iz) { MULADD(*tmpx++, *tmpy--); } /* store term */ COMBA_STORE(dst->dp[ix]); } COMBA_FINI; dst->used = pa; dst->sign = A->sign ^ B->sign; fp_clamp(dst); fp_copy(dst, C); } #endif /* $Source: /cvs/libtom/tomsfastmath/src/mul/fp_mul_comba.c,v $ */ /* $Revision: 1.4 $ */ /* $Date: 2007/03/14 23:47:42 $ */ /* End: src/mul/fp_mul_comba.c */ /* Start: src/mul/fp_mul_comba_12.c */ #define TFM_DEFINES //#include "fp_mul_comba.c" #ifdef TFM_MUL12 void fp_mul_comba12(fp_int *A, fp_int *B, fp_int *C) { fp_digit c0, c1, c2, at[24]; memcpy(at, A->dp, 12 * sizeof(fp_digit)); memcpy(at+12, B->dp, 12 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[12]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[13]); MULADD(at[1], at[12]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[14]); MULADD(at[1], at[13]); MULADD(at[2], at[12]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[15]); MULADD(at[1], at[14]); MULADD(at[2], at[13]); MULADD(at[3], at[12]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[16]); MULADD(at[1], at[15]); MULADD(at[2], at[14]); MULADD(at[3], at[13]); MULADD(at[4], at[12]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[17]); MULADD(at[1], at[16]); MULADD(at[2], at[15]); MULADD(at[3], at[14]); MULADD(at[4], at[13]); MULADD(at[5], at[12]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[18]); MULADD(at[1], at[17]); MULADD(at[2], at[16]); MULADD(at[3], at[15]); MULADD(at[4], at[14]); MULADD(at[5], at[13]); MULADD(at[6], at[12]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[19]); MULADD(at[1], at[18]); MULADD(at[2], at[17]); MULADD(at[3], at[16]); MULADD(at[4], at[15]); MULADD(at[5], at[14]); MULADD(at[6], at[13]); MULADD(at[7], at[12]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[0], at[20]); MULADD(at[1], at[19]); MULADD(at[2], at[18]); MULADD(at[3], at[17]); MULADD(at[4], at[16]); MULADD(at[5], at[15]); MULADD(at[6], at[14]); MULADD(at[7], at[13]); MULADD(at[8], at[12]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[0], at[21]); MULADD(at[1], at[20]); MULADD(at[2], at[19]); MULADD(at[3], at[18]); MULADD(at[4], at[17]); MULADD(at[5], at[16]); MULADD(at[6], at[15]); MULADD(at[7], at[14]); MULADD(at[8], at[13]); MULADD(at[9], at[12]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[0], at[22]); MULADD(at[1], at[21]); MULADD(at[2], at[20]); MULADD(at[3], at[19]); MULADD(at[4], at[18]); MULADD(at[5], at[17]); MULADD(at[6], at[16]); MULADD(at[7], at[15]); MULADD(at[8], at[14]); MULADD(at[9], at[13]); MULADD(at[10], at[12]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[0], at[23]); MULADD(at[1], at[22]); MULADD(at[2], at[21]); MULADD(at[3], at[20]); MULADD(at[4], at[19]); MULADD(at[5], at[18]); MULADD(at[6], at[17]); MULADD(at[7], at[16]); MULADD(at[8], at[15]); MULADD(at[9], at[14]); MULADD(at[10], at[13]); MULADD(at[11], at[12]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[1], at[23]); MULADD(at[2], at[22]); MULADD(at[3], at[21]); MULADD(at[4], at[20]); MULADD(at[5], at[19]); MULADD(at[6], at[18]); MULADD(at[7], at[17]); MULADD(at[8], at[16]); MULADD(at[9], at[15]); MULADD(at[10], at[14]); MULADD(at[11], at[13]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[2], at[23]); MULADD(at[3], at[22]); MULADD(at[4], at[21]); MULADD(at[5], at[20]); MULADD(at[6], at[19]); MULADD(at[7], at[18]); MULADD(at[8], at[17]); MULADD(at[9], at[16]); MULADD(at[10], at[15]); MULADD(at[11], at[14]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[3], at[23]); MULADD(at[4], at[22]); MULADD(at[5], at[21]); MULADD(at[6], at[20]); MULADD(at[7], at[19]); MULADD(at[8], at[18]); MULADD(at[9], at[17]); MULADD(at[10], at[16]); MULADD(at[11], at[15]); COMBA_STORE(C->dp[14]); /* 15 */ COMBA_FORWARD; MULADD(at[4], at[23]); MULADD(at[5], at[22]); MULADD(at[6], at[21]); MULADD(at[7], at[20]); MULADD(at[8], at[19]); MULADD(at[9], at[18]); MULADD(at[10], at[17]); MULADD(at[11], at[16]); COMBA_STORE(C->dp[15]); /* 16 */ COMBA_FORWARD; MULADD(at[5], at[23]); MULADD(at[6], at[22]); MULADD(at[7], at[21]); MULADD(at[8], at[20]); MULADD(at[9], at[19]); MULADD(at[10], at[18]); MULADD(at[11], at[17]); COMBA_STORE(C->dp[16]); /* 17 */ COMBA_FORWARD; MULADD(at[6], at[23]); MULADD(at[7], at[22]); MULADD(at[8], at[21]); MULADD(at[9], at[20]); MULADD(at[10], at[19]); MULADD(at[11], at[18]); COMBA_STORE(C->dp[17]); /* 18 */ COMBA_FORWARD; MULADD(at[7], at[23]); MULADD(at[8], at[22]); MULADD(at[9], at[21]); MULADD(at[10], at[20]); MULADD(at[11], at[19]); COMBA_STORE(C->dp[18]); /* 19 */ COMBA_FORWARD; MULADD(at[8], at[23]); MULADD(at[9], at[22]); MULADD(at[10], at[21]); MULADD(at[11], at[20]); COMBA_STORE(C->dp[19]); /* 20 */ COMBA_FORWARD; MULADD(at[9], at[23]); MULADD(at[10], at[22]); MULADD(at[11], at[21]); COMBA_STORE(C->dp[20]); /* 21 */ COMBA_FORWARD; MULADD(at[10], at[23]); MULADD(at[11], at[22]); COMBA_STORE(C->dp[21]); /* 22 */ COMBA_FORWARD; MULADD(at[11], at[23]); COMBA_STORE(C->dp[22]); COMBA_STORE2(C->dp[23]); C->used = 24; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; } #endif /* End: src/mul/fp_mul_comba_12.c */ /* Start: src/mul/fp_mul_comba_17.c */ #define TFM_DEFINES //#include "fp_mul_comba.c" #ifdef TFM_MUL17 void fp_mul_comba17(fp_int *A, fp_int *B, fp_int *C) { fp_digit c0, c1, c2, at[34]; memcpy(at, A->dp, 17 * sizeof(fp_digit)); memcpy(at+17, B->dp, 17 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[17]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[18]); MULADD(at[1], at[17]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[19]); MULADD(at[1], at[18]); MULADD(at[2], at[17]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[20]); MULADD(at[1], at[19]); MULADD(at[2], at[18]); MULADD(at[3], at[17]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[21]); MULADD(at[1], at[20]); MULADD(at[2], at[19]); MULADD(at[3], at[18]); MULADD(at[4], at[17]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[22]); MULADD(at[1], at[21]); MULADD(at[2], at[20]); MULADD(at[3], at[19]); MULADD(at[4], at[18]); MULADD(at[5], at[17]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[23]); MULADD(at[1], at[22]); MULADD(at[2], at[21]); MULADD(at[3], at[20]); MULADD(at[4], at[19]); MULADD(at[5], at[18]); MULADD(at[6], at[17]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[24]); MULADD(at[1], at[23]); MULADD(at[2], at[22]); MULADD(at[3], at[21]); MULADD(at[4], at[20]); MULADD(at[5], at[19]); MULADD(at[6], at[18]); MULADD(at[7], at[17]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[0], at[25]); MULADD(at[1], at[24]); MULADD(at[2], at[23]); MULADD(at[3], at[22]); MULADD(at[4], at[21]); MULADD(at[5], at[20]); MULADD(at[6], at[19]); MULADD(at[7], at[18]); MULADD(at[8], at[17]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[0], at[26]); MULADD(at[1], at[25]); MULADD(at[2], at[24]); MULADD(at[3], at[23]); MULADD(at[4], at[22]); MULADD(at[5], at[21]); MULADD(at[6], at[20]); MULADD(at[7], at[19]); MULADD(at[8], at[18]); MULADD(at[9], at[17]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[0], at[27]); MULADD(at[1], at[26]); MULADD(at[2], at[25]); MULADD(at[3], at[24]); MULADD(at[4], at[23]); MULADD(at[5], at[22]); MULADD(at[6], at[21]); MULADD(at[7], at[20]); MULADD(at[8], at[19]); MULADD(at[9], at[18]); MULADD(at[10], at[17]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[0], at[28]); MULADD(at[1], at[27]); MULADD(at[2], at[26]); MULADD(at[3], at[25]); MULADD(at[4], at[24]); MULADD(at[5], at[23]); MULADD(at[6], at[22]); MULADD(at[7], at[21]); MULADD(at[8], at[20]); MULADD(at[9], at[19]); MULADD(at[10], at[18]); MULADD(at[11], at[17]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[0], at[29]); MULADD(at[1], at[28]); MULADD(at[2], at[27]); MULADD(at[3], at[26]); MULADD(at[4], at[25]); MULADD(at[5], at[24]); MULADD(at[6], at[23]); MULADD(at[7], at[22]); MULADD(at[8], at[21]); MULADD(at[9], at[20]); MULADD(at[10], at[19]); MULADD(at[11], at[18]); MULADD(at[12], at[17]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[0], at[30]); MULADD(at[1], at[29]); MULADD(at[2], at[28]); MULADD(at[3], at[27]); MULADD(at[4], at[26]); MULADD(at[5], at[25]); MULADD(at[6], at[24]); MULADD(at[7], at[23]); MULADD(at[8], at[22]); MULADD(at[9], at[21]); MULADD(at[10], at[20]); MULADD(at[11], at[19]); MULADD(at[12], at[18]); MULADD(at[13], at[17]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[0], at[31]); MULADD(at[1], at[30]); MULADD(at[2], at[29]); MULADD(at[3], at[28]); MULADD(at[4], at[27]); MULADD(at[5], at[26]); MULADD(at[6], at[25]); MULADD(at[7], at[24]); MULADD(at[8], at[23]); MULADD(at[9], at[22]); MULADD(at[10], at[21]); MULADD(at[11], at[20]); MULADD(at[12], at[19]); MULADD(at[13], at[18]); MULADD(at[14], at[17]); COMBA_STORE(C->dp[14]); /* 15 */ COMBA_FORWARD; MULADD(at[0], at[32]); MULADD(at[1], at[31]); MULADD(at[2], at[30]); MULADD(at[3], at[29]); MULADD(at[4], at[28]); MULADD(at[5], at[27]); MULADD(at[6], at[26]); MULADD(at[7], at[25]); MULADD(at[8], at[24]); MULADD(at[9], at[23]); MULADD(at[10], at[22]); MULADD(at[11], at[21]); MULADD(at[12], at[20]); MULADD(at[13], at[19]); MULADD(at[14], at[18]); MULADD(at[15], at[17]); COMBA_STORE(C->dp[15]); /* 16 */ COMBA_FORWARD; MULADD(at[0], at[33]); MULADD(at[1], at[32]); MULADD(at[2], at[31]); MULADD(at[3], at[30]); MULADD(at[4], at[29]); MULADD(at[5], at[28]); MULADD(at[6], at[27]); MULADD(at[7], at[26]); MULADD(at[8], at[25]); MULADD(at[9], at[24]); MULADD(at[10], at[23]); MULADD(at[11], at[22]); MULADD(at[12], at[21]); MULADD(at[13], at[20]); MULADD(at[14], at[19]); MULADD(at[15], at[18]); MULADD(at[16], at[17]); COMBA_STORE(C->dp[16]); /* 17 */ COMBA_FORWARD; MULADD(at[1], at[33]); MULADD(at[2], at[32]); MULADD(at[3], at[31]); MULADD(at[4], at[30]); MULADD(at[5], at[29]); MULADD(at[6], at[28]); MULADD(at[7], at[27]); MULADD(at[8], at[26]); MULADD(at[9], at[25]); MULADD(at[10], at[24]); MULADD(at[11], at[23]); MULADD(at[12], at[22]); MULADD(at[13], at[21]); MULADD(at[14], at[20]); MULADD(at[15], at[19]); MULADD(at[16], at[18]); COMBA_STORE(C->dp[17]); /* 18 */ COMBA_FORWARD; MULADD(at[2], at[33]); MULADD(at[3], at[32]); MULADD(at[4], at[31]); MULADD(at[5], at[30]); MULADD(at[6], at[29]); MULADD(at[7], at[28]); MULADD(at[8], at[27]); MULADD(at[9], at[26]); MULADD(at[10], at[25]); MULADD(at[11], at[24]); MULADD(at[12], at[23]); MULADD(at[13], at[22]); MULADD(at[14], at[21]); MULADD(at[15], at[20]); MULADD(at[16], at[19]); COMBA_STORE(C->dp[18]); /* 19 */ COMBA_FORWARD; MULADD(at[3], at[33]); MULADD(at[4], at[32]); MULADD(at[5], at[31]); MULADD(at[6], at[30]); MULADD(at[7], at[29]); MULADD(at[8], at[28]); MULADD(at[9], at[27]); MULADD(at[10], at[26]); MULADD(at[11], at[25]); MULADD(at[12], at[24]); MULADD(at[13], at[23]); MULADD(at[14], at[22]); MULADD(at[15], at[21]); MULADD(at[16], at[20]); COMBA_STORE(C->dp[19]); /* 20 */ COMBA_FORWARD; MULADD(at[4], at[33]); MULADD(at[5], at[32]); MULADD(at[6], at[31]); MULADD(at[7], at[30]); MULADD(at[8], at[29]); MULADD(at[9], at[28]); MULADD(at[10], at[27]); MULADD(at[11], at[26]); MULADD(at[12], at[25]); MULADD(at[13], at[24]); MULADD(at[14], at[23]); MULADD(at[15], at[22]); MULADD(at[16], at[21]); COMBA_STORE(C->dp[20]); /* 21 */ COMBA_FORWARD; MULADD(at[5], at[33]); MULADD(at[6], at[32]); MULADD(at[7], at[31]); MULADD(at[8], at[30]); MULADD(at[9], at[29]); MULADD(at[10], at[28]); MULADD(at[11], at[27]); MULADD(at[12], at[26]); MULADD(at[13], at[25]); MULADD(at[14], at[24]); MULADD(at[15], at[23]); MULADD(at[16], at[22]); COMBA_STORE(C->dp[21]); /* 22 */ COMBA_FORWARD; MULADD(at[6], at[33]); MULADD(at[7], at[32]); MULADD(at[8], at[31]); MULADD(at[9], at[30]); MULADD(at[10], at[29]); MULADD(at[11], at[28]); MULADD(at[12], at[27]); MULADD(at[13], at[26]); MULADD(at[14], at[25]); MULADD(at[15], at[24]); MULADD(at[16], at[23]); COMBA_STORE(C->dp[22]); /* 23 */ COMBA_FORWARD; MULADD(at[7], at[33]); MULADD(at[8], at[32]); MULADD(at[9], at[31]); MULADD(at[10], at[30]); MULADD(at[11], at[29]); MULADD(at[12], at[28]); MULADD(at[13], at[27]); MULADD(at[14], at[26]); MULADD(at[15], at[25]); MULADD(at[16], at[24]); COMBA_STORE(C->dp[23]); /* 24 */ COMBA_FORWARD; MULADD(at[8], at[33]); MULADD(at[9], at[32]); MULADD(at[10], at[31]); MULADD(at[11], at[30]); MULADD(at[12], at[29]); MULADD(at[13], at[28]); MULADD(at[14], at[27]); MULADD(at[15], at[26]); MULADD(at[16], at[25]); COMBA_STORE(C->dp[24]); /* 25 */ COMBA_FORWARD; MULADD(at[9], at[33]); MULADD(at[10], at[32]); MULADD(at[11], at[31]); MULADD(at[12], at[30]); MULADD(at[13], at[29]); MULADD(at[14], at[28]); MULADD(at[15], at[27]); MULADD(at[16], at[26]); COMBA_STORE(C->dp[25]); /* 26 */ COMBA_FORWARD; MULADD(at[10], at[33]); MULADD(at[11], at[32]); MULADD(at[12], at[31]); MULADD(at[13], at[30]); MULADD(at[14], at[29]); MULADD(at[15], at[28]); MULADD(at[16], at[27]); COMBA_STORE(C->dp[26]); /* 27 */ COMBA_FORWARD; MULADD(at[11], at[33]); MULADD(at[12], at[32]); MULADD(at[13], at[31]); MULADD(at[14], at[30]); MULADD(at[15], at[29]); MULADD(at[16], at[28]); COMBA_STORE(C->dp[27]); /* 28 */ COMBA_FORWARD; MULADD(at[12], at[33]); MULADD(at[13], at[32]); MULADD(at[14], at[31]); MULADD(at[15], at[30]); MULADD(at[16], at[29]); COMBA_STORE(C->dp[28]); /* 29 */ COMBA_FORWARD; MULADD(at[13], at[33]); MULADD(at[14], at[32]); MULADD(at[15], at[31]); MULADD(at[16], at[30]); COMBA_STORE(C->dp[29]); /* 30 */ COMBA_FORWARD; MULADD(at[14], at[33]); MULADD(at[15], at[32]); MULADD(at[16], at[31]); COMBA_STORE(C->dp[30]); /* 31 */ COMBA_FORWARD; MULADD(at[15], at[33]); MULADD(at[16], at[32]); COMBA_STORE(C->dp[31]); /* 32 */ COMBA_FORWARD; MULADD(at[16], at[33]); COMBA_STORE(C->dp[32]); COMBA_STORE2(C->dp[33]); C->used = 34; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; } #endif /* End: src/mul/fp_mul_comba_17.c */ /* Start: src/mul/fp_mul_comba_20.c */ #define TFM_DEFINES //#include "fp_mul_comba.c" #ifdef TFM_MUL20 void fp_mul_comba20(fp_int *A, fp_int *B, fp_int *C) { fp_digit c0, c1, c2, at[40]; memcpy(at, A->dp, 20 * sizeof(fp_digit)); memcpy(at+20, B->dp, 20 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[20]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[21]); MULADD(at[1], at[20]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[22]); MULADD(at[1], at[21]); MULADD(at[2], at[20]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[23]); MULADD(at[1], at[22]); MULADD(at[2], at[21]); MULADD(at[3], at[20]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[24]); MULADD(at[1], at[23]); MULADD(at[2], at[22]); MULADD(at[3], at[21]); MULADD(at[4], at[20]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[25]); MULADD(at[1], at[24]); MULADD(at[2], at[23]); MULADD(at[3], at[22]); MULADD(at[4], at[21]); MULADD(at[5], at[20]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[26]); MULADD(at[1], at[25]); MULADD(at[2], at[24]); MULADD(at[3], at[23]); MULADD(at[4], at[22]); MULADD(at[5], at[21]); MULADD(at[6], at[20]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[27]); MULADD(at[1], at[26]); MULADD(at[2], at[25]); MULADD(at[3], at[24]); MULADD(at[4], at[23]); MULADD(at[5], at[22]); MULADD(at[6], at[21]); MULADD(at[7], at[20]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[0], at[28]); MULADD(at[1], at[27]); MULADD(at[2], at[26]); MULADD(at[3], at[25]); MULADD(at[4], at[24]); MULADD(at[5], at[23]); MULADD(at[6], at[22]); MULADD(at[7], at[21]); MULADD(at[8], at[20]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[0], at[29]); MULADD(at[1], at[28]); MULADD(at[2], at[27]); MULADD(at[3], at[26]); MULADD(at[4], at[25]); MULADD(at[5], at[24]); MULADD(at[6], at[23]); MULADD(at[7], at[22]); MULADD(at[8], at[21]); MULADD(at[9], at[20]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[0], at[30]); MULADD(at[1], at[29]); MULADD(at[2], at[28]); MULADD(at[3], at[27]); MULADD(at[4], at[26]); MULADD(at[5], at[25]); MULADD(at[6], at[24]); MULADD(at[7], at[23]); MULADD(at[8], at[22]); MULADD(at[9], at[21]); MULADD(at[10], at[20]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[0], at[31]); MULADD(at[1], at[30]); MULADD(at[2], at[29]); MULADD(at[3], at[28]); MULADD(at[4], at[27]); MULADD(at[5], at[26]); MULADD(at[6], at[25]); MULADD(at[7], at[24]); MULADD(at[8], at[23]); MULADD(at[9], at[22]); MULADD(at[10], at[21]); MULADD(at[11], at[20]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[0], at[32]); MULADD(at[1], at[31]); MULADD(at[2], at[30]); MULADD(at[3], at[29]); MULADD(at[4], at[28]); MULADD(at[5], at[27]); MULADD(at[6], at[26]); MULADD(at[7], at[25]); MULADD(at[8], at[24]); MULADD(at[9], at[23]); MULADD(at[10], at[22]); MULADD(at[11], at[21]); MULADD(at[12], at[20]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[0], at[33]); MULADD(at[1], at[32]); MULADD(at[2], at[31]); MULADD(at[3], at[30]); MULADD(at[4], at[29]); MULADD(at[5], at[28]); MULADD(at[6], at[27]); MULADD(at[7], at[26]); MULADD(at[8], at[25]); MULADD(at[9], at[24]); MULADD(at[10], at[23]); MULADD(at[11], at[22]); MULADD(at[12], at[21]); MULADD(at[13], at[20]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[0], at[34]); MULADD(at[1], at[33]); MULADD(at[2], at[32]); MULADD(at[3], at[31]); MULADD(at[4], at[30]); MULADD(at[5], at[29]); MULADD(at[6], at[28]); MULADD(at[7], at[27]); MULADD(at[8], at[26]); MULADD(at[9], at[25]); MULADD(at[10], at[24]); MULADD(at[11], at[23]); MULADD(at[12], at[22]); MULADD(at[13], at[21]); MULADD(at[14], at[20]); COMBA_STORE(C->dp[14]); /* 15 */ COMBA_FORWARD; MULADD(at[0], at[35]); MULADD(at[1], at[34]); MULADD(at[2], at[33]); MULADD(at[3], at[32]); MULADD(at[4], at[31]); MULADD(at[5], at[30]); MULADD(at[6], at[29]); MULADD(at[7], at[28]); MULADD(at[8], at[27]); MULADD(at[9], at[26]); MULADD(at[10], at[25]); MULADD(at[11], at[24]); MULADD(at[12], at[23]); MULADD(at[13], at[22]); MULADD(at[14], at[21]); MULADD(at[15], at[20]); COMBA_STORE(C->dp[15]); /* 16 */ COMBA_FORWARD; MULADD(at[0], at[36]); MULADD(at[1], at[35]); MULADD(at[2], at[34]); MULADD(at[3], at[33]); MULADD(at[4], at[32]); MULADD(at[5], at[31]); MULADD(at[6], at[30]); MULADD(at[7], at[29]); MULADD(at[8], at[28]); MULADD(at[9], at[27]); MULADD(at[10], at[26]); MULADD(at[11], at[25]); MULADD(at[12], at[24]); MULADD(at[13], at[23]); MULADD(at[14], at[22]); MULADD(at[15], at[21]); MULADD(at[16], at[20]); COMBA_STORE(C->dp[16]); /* 17 */ COMBA_FORWARD; MULADD(at[0], at[37]); MULADD(at[1], at[36]); MULADD(at[2], at[35]); MULADD(at[3], at[34]); MULADD(at[4], at[33]); MULADD(at[5], at[32]); MULADD(at[6], at[31]); MULADD(at[7], at[30]); MULADD(at[8], at[29]); MULADD(at[9], at[28]); MULADD(at[10], at[27]); MULADD(at[11], at[26]); MULADD(at[12], at[25]); MULADD(at[13], at[24]); MULADD(at[14], at[23]); MULADD(at[15], at[22]); MULADD(at[16], at[21]); MULADD(at[17], at[20]); COMBA_STORE(C->dp[17]); /* 18 */ COMBA_FORWARD; MULADD(at[0], at[38]); MULADD(at[1], at[37]); MULADD(at[2], at[36]); MULADD(at[3], at[35]); MULADD(at[4], at[34]); MULADD(at[5], at[33]); MULADD(at[6], at[32]); MULADD(at[7], at[31]); MULADD(at[8], at[30]); MULADD(at[9], at[29]); MULADD(at[10], at[28]); MULADD(at[11], at[27]); MULADD(at[12], at[26]); MULADD(at[13], at[25]); MULADD(at[14], at[24]); MULADD(at[15], at[23]); MULADD(at[16], at[22]); MULADD(at[17], at[21]); MULADD(at[18], at[20]); COMBA_STORE(C->dp[18]); /* 19 */ COMBA_FORWARD; MULADD(at[0], at[39]); MULADD(at[1], at[38]); MULADD(at[2], at[37]); MULADD(at[3], at[36]); MULADD(at[4], at[35]); MULADD(at[5], at[34]); MULADD(at[6], at[33]); MULADD(at[7], at[32]); MULADD(at[8], at[31]); MULADD(at[9], at[30]); MULADD(at[10], at[29]); MULADD(at[11], at[28]); MULADD(at[12], at[27]); MULADD(at[13], at[26]); MULADD(at[14], at[25]); MULADD(at[15], at[24]); MULADD(at[16], at[23]); MULADD(at[17], at[22]); MULADD(at[18], at[21]); MULADD(at[19], at[20]); COMBA_STORE(C->dp[19]); /* 20 */ COMBA_FORWARD; MULADD(at[1], at[39]); MULADD(at[2], at[38]); MULADD(at[3], at[37]); MULADD(at[4], at[36]); MULADD(at[5], at[35]); MULADD(at[6], at[34]); MULADD(at[7], at[33]); MULADD(at[8], at[32]); MULADD(at[9], at[31]); MULADD(at[10], at[30]); MULADD(at[11], at[29]); MULADD(at[12], at[28]); MULADD(at[13], at[27]); MULADD(at[14], at[26]); MULADD(at[15], at[25]); MULADD(at[16], at[24]); MULADD(at[17], at[23]); MULADD(at[18], at[22]); MULADD(at[19], at[21]); COMBA_STORE(C->dp[20]); /* 21 */ COMBA_FORWARD; MULADD(at[2], at[39]); MULADD(at[3], at[38]); MULADD(at[4], at[37]); MULADD(at[5], at[36]); MULADD(at[6], at[35]); MULADD(at[7], at[34]); MULADD(at[8], at[33]); MULADD(at[9], at[32]); MULADD(at[10], at[31]); MULADD(at[11], at[30]); MULADD(at[12], at[29]); MULADD(at[13], at[28]); MULADD(at[14], at[27]); MULADD(at[15], at[26]); MULADD(at[16], at[25]); MULADD(at[17], at[24]); MULADD(at[18], at[23]); MULADD(at[19], at[22]); COMBA_STORE(C->dp[21]); /* 22 */ COMBA_FORWARD; MULADD(at[3], at[39]); MULADD(at[4], at[38]); MULADD(at[5], at[37]); MULADD(at[6], at[36]); MULADD(at[7], at[35]); MULADD(at[8], at[34]); MULADD(at[9], at[33]); MULADD(at[10], at[32]); MULADD(at[11], at[31]); MULADD(at[12], at[30]); MULADD(at[13], at[29]); MULADD(at[14], at[28]); MULADD(at[15], at[27]); MULADD(at[16], at[26]); MULADD(at[17], at[25]); MULADD(at[18], at[24]); MULADD(at[19], at[23]); COMBA_STORE(C->dp[22]); /* 23 */ COMBA_FORWARD; MULADD(at[4], at[39]); MULADD(at[5], at[38]); MULADD(at[6], at[37]); MULADD(at[7], at[36]); MULADD(at[8], at[35]); MULADD(at[9], at[34]); MULADD(at[10], at[33]); MULADD(at[11], at[32]); MULADD(at[12], at[31]); MULADD(at[13], at[30]); MULADD(at[14], at[29]); MULADD(at[15], at[28]); MULADD(at[16], at[27]); MULADD(at[17], at[26]); MULADD(at[18], at[25]); MULADD(at[19], at[24]); COMBA_STORE(C->dp[23]); /* 24 */ COMBA_FORWARD; MULADD(at[5], at[39]); MULADD(at[6], at[38]); MULADD(at[7], at[37]); MULADD(at[8], at[36]); MULADD(at[9], at[35]); MULADD(at[10], at[34]); MULADD(at[11], at[33]); MULADD(at[12], at[32]); MULADD(at[13], at[31]); MULADD(at[14], at[30]); MULADD(at[15], at[29]); MULADD(at[16], at[28]); MULADD(at[17], at[27]); MULADD(at[18], at[26]); MULADD(at[19], at[25]); COMBA_STORE(C->dp[24]); /* 25 */ COMBA_FORWARD; MULADD(at[6], at[39]); MULADD(at[7], at[38]); MULADD(at[8], at[37]); MULADD(at[9], at[36]); MULADD(at[10], at[35]); MULADD(at[11], at[34]); MULADD(at[12], at[33]); MULADD(at[13], at[32]); MULADD(at[14], at[31]); MULADD(at[15], at[30]); MULADD(at[16], at[29]); MULADD(at[17], at[28]); MULADD(at[18], at[27]); MULADD(at[19], at[26]); COMBA_STORE(C->dp[25]); /* 26 */ COMBA_FORWARD; MULADD(at[7], at[39]); MULADD(at[8], at[38]); MULADD(at[9], at[37]); MULADD(at[10], at[36]); MULADD(at[11], at[35]); MULADD(at[12], at[34]); MULADD(at[13], at[33]); MULADD(at[14], at[32]); MULADD(at[15], at[31]); MULADD(at[16], at[30]); MULADD(at[17], at[29]); MULADD(at[18], at[28]); MULADD(at[19], at[27]); COMBA_STORE(C->dp[26]); /* 27 */ COMBA_FORWARD; MULADD(at[8], at[39]); MULADD(at[9], at[38]); MULADD(at[10], at[37]); MULADD(at[11], at[36]); MULADD(at[12], at[35]); MULADD(at[13], at[34]); MULADD(at[14], at[33]); MULADD(at[15], at[32]); MULADD(at[16], at[31]); MULADD(at[17], at[30]); MULADD(at[18], at[29]); MULADD(at[19], at[28]); COMBA_STORE(C->dp[27]); /* 28 */ COMBA_FORWARD; MULADD(at[9], at[39]); MULADD(at[10], at[38]); MULADD(at[11], at[37]); MULADD(at[12], at[36]); MULADD(at[13], at[35]); MULADD(at[14], at[34]); MULADD(at[15], at[33]); MULADD(at[16], at[32]); MULADD(at[17], at[31]); MULADD(at[18], at[30]); MULADD(at[19], at[29]); COMBA_STORE(C->dp[28]); /* 29 */ COMBA_FORWARD; MULADD(at[10], at[39]); MULADD(at[11], at[38]); MULADD(at[12], at[37]); MULADD(at[13], at[36]); MULADD(at[14], at[35]); MULADD(at[15], at[34]); MULADD(at[16], at[33]); MULADD(at[17], at[32]); MULADD(at[18], at[31]); MULADD(at[19], at[30]); COMBA_STORE(C->dp[29]); /* 30 */ COMBA_FORWARD; MULADD(at[11], at[39]); MULADD(at[12], at[38]); MULADD(at[13], at[37]); MULADD(at[14], at[36]); MULADD(at[15], at[35]); MULADD(at[16], at[34]); MULADD(at[17], at[33]); MULADD(at[18], at[32]); MULADD(at[19], at[31]); COMBA_STORE(C->dp[30]); /* 31 */ COMBA_FORWARD; MULADD(at[12], at[39]); MULADD(at[13], at[38]); MULADD(at[14], at[37]); MULADD(at[15], at[36]); MULADD(at[16], at[35]); MULADD(at[17], at[34]); MULADD(at[18], at[33]); MULADD(at[19], at[32]); COMBA_STORE(C->dp[31]); /* 32 */ COMBA_FORWARD; MULADD(at[13], at[39]); MULADD(at[14], at[38]); MULADD(at[15], at[37]); MULADD(at[16], at[36]); MULADD(at[17], at[35]); MULADD(at[18], at[34]); MULADD(at[19], at[33]); COMBA_STORE(C->dp[32]); /* 33 */ COMBA_FORWARD; MULADD(at[14], at[39]); MULADD(at[15], at[38]); MULADD(at[16], at[37]); MULADD(at[17], at[36]); MULADD(at[18], at[35]); MULADD(at[19], at[34]); COMBA_STORE(C->dp[33]); /* 34 */ COMBA_FORWARD; MULADD(at[15], at[39]); MULADD(at[16], at[38]); MULADD(at[17], at[37]); MULADD(at[18], at[36]); MULADD(at[19], at[35]); COMBA_STORE(C->dp[34]); /* 35 */ COMBA_FORWARD; MULADD(at[16], at[39]); MULADD(at[17], at[38]); MULADD(at[18], at[37]); MULADD(at[19], at[36]); COMBA_STORE(C->dp[35]); /* 36 */ COMBA_FORWARD; MULADD(at[17], at[39]); MULADD(at[18], at[38]); MULADD(at[19], at[37]); COMBA_STORE(C->dp[36]); /* 37 */ COMBA_FORWARD; MULADD(at[18], at[39]); MULADD(at[19], at[38]); COMBA_STORE(C->dp[37]); /* 38 */ COMBA_FORWARD; MULADD(at[19], at[39]); COMBA_STORE(C->dp[38]); COMBA_STORE2(C->dp[39]); C->used = 40; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; } #endif /* End: src/mul/fp_mul_comba_20.c */ /* Start: src/mul/fp_mul_comba_24.c */ #define TFM_DEFINES //#include "fp_mul_comba.c" #ifdef TFM_MUL24 void fp_mul_comba24(fp_int *A, fp_int *B, fp_int *C) { fp_digit c0, c1, c2, at[48]; memcpy(at, A->dp, 24 * sizeof(fp_digit)); memcpy(at+24, B->dp, 24 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[24]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[25]); MULADD(at[1], at[24]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[26]); MULADD(at[1], at[25]); MULADD(at[2], at[24]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[27]); MULADD(at[1], at[26]); MULADD(at[2], at[25]); MULADD(at[3], at[24]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[28]); MULADD(at[1], at[27]); MULADD(at[2], at[26]); MULADD(at[3], at[25]); MULADD(at[4], at[24]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[29]); MULADD(at[1], at[28]); MULADD(at[2], at[27]); MULADD(at[3], at[26]); MULADD(at[4], at[25]); MULADD(at[5], at[24]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[30]); MULADD(at[1], at[29]); MULADD(at[2], at[28]); MULADD(at[3], at[27]); MULADD(at[4], at[26]); MULADD(at[5], at[25]); MULADD(at[6], at[24]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[31]); MULADD(at[1], at[30]); MULADD(at[2], at[29]); MULADD(at[3], at[28]); MULADD(at[4], at[27]); MULADD(at[5], at[26]); MULADD(at[6], at[25]); MULADD(at[7], at[24]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[0], at[32]); MULADD(at[1], at[31]); MULADD(at[2], at[30]); MULADD(at[3], at[29]); MULADD(at[4], at[28]); MULADD(at[5], at[27]); MULADD(at[6], at[26]); MULADD(at[7], at[25]); MULADD(at[8], at[24]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[0], at[33]); MULADD(at[1], at[32]); MULADD(at[2], at[31]); MULADD(at[3], at[30]); MULADD(at[4], at[29]); MULADD(at[5], at[28]); MULADD(at[6], at[27]); MULADD(at[7], at[26]); MULADD(at[8], at[25]); MULADD(at[9], at[24]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[0], at[34]); MULADD(at[1], at[33]); MULADD(at[2], at[32]); MULADD(at[3], at[31]); MULADD(at[4], at[30]); MULADD(at[5], at[29]); MULADD(at[6], at[28]); MULADD(at[7], at[27]); MULADD(at[8], at[26]); MULADD(at[9], at[25]); MULADD(at[10], at[24]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[0], at[35]); MULADD(at[1], at[34]); MULADD(at[2], at[33]); MULADD(at[3], at[32]); MULADD(at[4], at[31]); MULADD(at[5], at[30]); MULADD(at[6], at[29]); MULADD(at[7], at[28]); MULADD(at[8], at[27]); MULADD(at[9], at[26]); MULADD(at[10], at[25]); MULADD(at[11], at[24]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[0], at[36]); MULADD(at[1], at[35]); MULADD(at[2], at[34]); MULADD(at[3], at[33]); MULADD(at[4], at[32]); MULADD(at[5], at[31]); MULADD(at[6], at[30]); MULADD(at[7], at[29]); MULADD(at[8], at[28]); MULADD(at[9], at[27]); MULADD(at[10], at[26]); MULADD(at[11], at[25]); MULADD(at[12], at[24]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[0], at[37]); MULADD(at[1], at[36]); MULADD(at[2], at[35]); MULADD(at[3], at[34]); MULADD(at[4], at[33]); MULADD(at[5], at[32]); MULADD(at[6], at[31]); MULADD(at[7], at[30]); MULADD(at[8], at[29]); MULADD(at[9], at[28]); MULADD(at[10], at[27]); MULADD(at[11], at[26]); MULADD(at[12], at[25]); MULADD(at[13], at[24]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[0], at[38]); MULADD(at[1], at[37]); MULADD(at[2], at[36]); MULADD(at[3], at[35]); MULADD(at[4], at[34]); MULADD(at[5], at[33]); MULADD(at[6], at[32]); MULADD(at[7], at[31]); MULADD(at[8], at[30]); MULADD(at[9], at[29]); MULADD(at[10], at[28]); MULADD(at[11], at[27]); MULADD(at[12], at[26]); MULADD(at[13], at[25]); MULADD(at[14], at[24]); COMBA_STORE(C->dp[14]); /* 15 */ COMBA_FORWARD; MULADD(at[0], at[39]); MULADD(at[1], at[38]); MULADD(at[2], at[37]); MULADD(at[3], at[36]); MULADD(at[4], at[35]); MULADD(at[5], at[34]); MULADD(at[6], at[33]); MULADD(at[7], at[32]); MULADD(at[8], at[31]); MULADD(at[9], at[30]); MULADD(at[10], at[29]); MULADD(at[11], at[28]); MULADD(at[12], at[27]); MULADD(at[13], at[26]); MULADD(at[14], at[25]); MULADD(at[15], at[24]); COMBA_STORE(C->dp[15]); /* 16 */ COMBA_FORWARD; MULADD(at[0], at[40]); MULADD(at[1], at[39]); MULADD(at[2], at[38]); MULADD(at[3], at[37]); MULADD(at[4], at[36]); MULADD(at[5], at[35]); MULADD(at[6], at[34]); MULADD(at[7], at[33]); MULADD(at[8], at[32]); MULADD(at[9], at[31]); MULADD(at[10], at[30]); MULADD(at[11], at[29]); MULADD(at[12], at[28]); MULADD(at[13], at[27]); MULADD(at[14], at[26]); MULADD(at[15], at[25]); MULADD(at[16], at[24]); COMBA_STORE(C->dp[16]); /* 17 */ COMBA_FORWARD; MULADD(at[0], at[41]); MULADD(at[1], at[40]); MULADD(at[2], at[39]); MULADD(at[3], at[38]); MULADD(at[4], at[37]); MULADD(at[5], at[36]); MULADD(at[6], at[35]); MULADD(at[7], at[34]); MULADD(at[8], at[33]); MULADD(at[9], at[32]); MULADD(at[10], at[31]); MULADD(at[11], at[30]); MULADD(at[12], at[29]); MULADD(at[13], at[28]); MULADD(at[14], at[27]); MULADD(at[15], at[26]); MULADD(at[16], at[25]); MULADD(at[17], at[24]); COMBA_STORE(C->dp[17]); /* 18 */ COMBA_FORWARD; MULADD(at[0], at[42]); MULADD(at[1], at[41]); MULADD(at[2], at[40]); MULADD(at[3], at[39]); MULADD(at[4], at[38]); MULADD(at[5], at[37]); MULADD(at[6], at[36]); MULADD(at[7], at[35]); MULADD(at[8], at[34]); MULADD(at[9], at[33]); MULADD(at[10], at[32]); MULADD(at[11], at[31]); MULADD(at[12], at[30]); MULADD(at[13], at[29]); MULADD(at[14], at[28]); MULADD(at[15], at[27]); MULADD(at[16], at[26]); MULADD(at[17], at[25]); MULADD(at[18], at[24]); COMBA_STORE(C->dp[18]); /* 19 */ COMBA_FORWARD; MULADD(at[0], at[43]); MULADD(at[1], at[42]); MULADD(at[2], at[41]); MULADD(at[3], at[40]); MULADD(at[4], at[39]); MULADD(at[5], at[38]); MULADD(at[6], at[37]); MULADD(at[7], at[36]); MULADD(at[8], at[35]); MULADD(at[9], at[34]); MULADD(at[10], at[33]); MULADD(at[11], at[32]); MULADD(at[12], at[31]); MULADD(at[13], at[30]); MULADD(at[14], at[29]); MULADD(at[15], at[28]); MULADD(at[16], at[27]); MULADD(at[17], at[26]); MULADD(at[18], at[25]); MULADD(at[19], at[24]); COMBA_STORE(C->dp[19]); /* 20 */ COMBA_FORWARD; MULADD(at[0], at[44]); MULADD(at[1], at[43]); MULADD(at[2], at[42]); MULADD(at[3], at[41]); MULADD(at[4], at[40]); MULADD(at[5], at[39]); MULADD(at[6], at[38]); MULADD(at[7], at[37]); MULADD(at[8], at[36]); MULADD(at[9], at[35]); MULADD(at[10], at[34]); MULADD(at[11], at[33]); MULADD(at[12], at[32]); MULADD(at[13], at[31]); MULADD(at[14], at[30]); MULADD(at[15], at[29]); MULADD(at[16], at[28]); MULADD(at[17], at[27]); MULADD(at[18], at[26]); MULADD(at[19], at[25]); MULADD(at[20], at[24]); COMBA_STORE(C->dp[20]); /* 21 */ COMBA_FORWARD; MULADD(at[0], at[45]); MULADD(at[1], at[44]); MULADD(at[2], at[43]); MULADD(at[3], at[42]); MULADD(at[4], at[41]); MULADD(at[5], at[40]); MULADD(at[6], at[39]); MULADD(at[7], at[38]); MULADD(at[8], at[37]); MULADD(at[9], at[36]); MULADD(at[10], at[35]); MULADD(at[11], at[34]); MULADD(at[12], at[33]); MULADD(at[13], at[32]); MULADD(at[14], at[31]); MULADD(at[15], at[30]); MULADD(at[16], at[29]); MULADD(at[17], at[28]); MULADD(at[18], at[27]); MULADD(at[19], at[26]); MULADD(at[20], at[25]); MULADD(at[21], at[24]); COMBA_STORE(C->dp[21]); /* 22 */ COMBA_FORWARD; MULADD(at[0], at[46]); MULADD(at[1], at[45]); MULADD(at[2], at[44]); MULADD(at[3], at[43]); MULADD(at[4], at[42]); MULADD(at[5], at[41]); MULADD(at[6], at[40]); MULADD(at[7], at[39]); MULADD(at[8], at[38]); MULADD(at[9], at[37]); MULADD(at[10], at[36]); MULADD(at[11], at[35]); MULADD(at[12], at[34]); MULADD(at[13], at[33]); MULADD(at[14], at[32]); MULADD(at[15], at[31]); MULADD(at[16], at[30]); MULADD(at[17], at[29]); MULADD(at[18], at[28]); MULADD(at[19], at[27]); MULADD(at[20], at[26]); MULADD(at[21], at[25]); MULADD(at[22], at[24]); COMBA_STORE(C->dp[22]); /* 23 */ COMBA_FORWARD; MULADD(at[0], at[47]); MULADD(at[1], at[46]); MULADD(at[2], at[45]); MULADD(at[3], at[44]); MULADD(at[4], at[43]); MULADD(at[5], at[42]); MULADD(at[6], at[41]); MULADD(at[7], at[40]); MULADD(at[8], at[39]); MULADD(at[9], at[38]); MULADD(at[10], at[37]); MULADD(at[11], at[36]); MULADD(at[12], at[35]); MULADD(at[13], at[34]); MULADD(at[14], at[33]); MULADD(at[15], at[32]); MULADD(at[16], at[31]); MULADD(at[17], at[30]); MULADD(at[18], at[29]); MULADD(at[19], at[28]); MULADD(at[20], at[27]); MULADD(at[21], at[26]); MULADD(at[22], at[25]); MULADD(at[23], at[24]); COMBA_STORE(C->dp[23]); /* 24 */ COMBA_FORWARD; MULADD(at[1], at[47]); MULADD(at[2], at[46]); MULADD(at[3], at[45]); MULADD(at[4], at[44]); MULADD(at[5], at[43]); MULADD(at[6], at[42]); MULADD(at[7], at[41]); MULADD(at[8], at[40]); MULADD(at[9], at[39]); MULADD(at[10], at[38]); MULADD(at[11], at[37]); MULADD(at[12], at[36]); MULADD(at[13], at[35]); MULADD(at[14], at[34]); MULADD(at[15], at[33]); MULADD(at[16], at[32]); MULADD(at[17], at[31]); MULADD(at[18], at[30]); MULADD(at[19], at[29]); MULADD(at[20], at[28]); MULADD(at[21], at[27]); MULADD(at[22], at[26]); MULADD(at[23], at[25]); COMBA_STORE(C->dp[24]); /* 25 */ COMBA_FORWARD; MULADD(at[2], at[47]); MULADD(at[3], at[46]); MULADD(at[4], at[45]); MULADD(at[5], at[44]); MULADD(at[6], at[43]); MULADD(at[7], at[42]); MULADD(at[8], at[41]); MULADD(at[9], at[40]); MULADD(at[10], at[39]); MULADD(at[11], at[38]); MULADD(at[12], at[37]); MULADD(at[13], at[36]); MULADD(at[14], at[35]); MULADD(at[15], at[34]); MULADD(at[16], at[33]); MULADD(at[17], at[32]); MULADD(at[18], at[31]); MULADD(at[19], at[30]); MULADD(at[20], at[29]); MULADD(at[21], at[28]); MULADD(at[22], at[27]); MULADD(at[23], at[26]); COMBA_STORE(C->dp[25]); /* 26 */ COMBA_FORWARD; MULADD(at[3], at[47]); MULADD(at[4], at[46]); MULADD(at[5], at[45]); MULADD(at[6], at[44]); MULADD(at[7], at[43]); MULADD(at[8], at[42]); MULADD(at[9], at[41]); MULADD(at[10], at[40]); MULADD(at[11], at[39]); MULADD(at[12], at[38]); MULADD(at[13], at[37]); MULADD(at[14], at[36]); MULADD(at[15], at[35]); MULADD(at[16], at[34]); MULADD(at[17], at[33]); MULADD(at[18], at[32]); MULADD(at[19], at[31]); MULADD(at[20], at[30]); MULADD(at[21], at[29]); MULADD(at[22], at[28]); MULADD(at[23], at[27]); COMBA_STORE(C->dp[26]); /* 27 */ COMBA_FORWARD; MULADD(at[4], at[47]); MULADD(at[5], at[46]); MULADD(at[6], at[45]); MULADD(at[7], at[44]); MULADD(at[8], at[43]); MULADD(at[9], at[42]); MULADD(at[10], at[41]); MULADD(at[11], at[40]); MULADD(at[12], at[39]); MULADD(at[13], at[38]); MULADD(at[14], at[37]); MULADD(at[15], at[36]); MULADD(at[16], at[35]); MULADD(at[17], at[34]); MULADD(at[18], at[33]); MULADD(at[19], at[32]); MULADD(at[20], at[31]); MULADD(at[21], at[30]); MULADD(at[22], at[29]); MULADD(at[23], at[28]); COMBA_STORE(C->dp[27]); /* 28 */ COMBA_FORWARD; MULADD(at[5], at[47]); MULADD(at[6], at[46]); MULADD(at[7], at[45]); MULADD(at[8], at[44]); MULADD(at[9], at[43]); MULADD(at[10], at[42]); MULADD(at[11], at[41]); MULADD(at[12], at[40]); MULADD(at[13], at[39]); MULADD(at[14], at[38]); MULADD(at[15], at[37]); MULADD(at[16], at[36]); MULADD(at[17], at[35]); MULADD(at[18], at[34]); MULADD(at[19], at[33]); MULADD(at[20], at[32]); MULADD(at[21], at[31]); MULADD(at[22], at[30]); MULADD(at[23], at[29]); COMBA_STORE(C->dp[28]); /* 29 */ COMBA_FORWARD; MULADD(at[6], at[47]); MULADD(at[7], at[46]); MULADD(at[8], at[45]); MULADD(at[9], at[44]); MULADD(at[10], at[43]); MULADD(at[11], at[42]); MULADD(at[12], at[41]); MULADD(at[13], at[40]); MULADD(at[14], at[39]); MULADD(at[15], at[38]); MULADD(at[16], at[37]); MULADD(at[17], at[36]); MULADD(at[18], at[35]); MULADD(at[19], at[34]); MULADD(at[20], at[33]); MULADD(at[21], at[32]); MULADD(at[22], at[31]); MULADD(at[23], at[30]); COMBA_STORE(C->dp[29]); /* 30 */ COMBA_FORWARD; MULADD(at[7], at[47]); MULADD(at[8], at[46]); MULADD(at[9], at[45]); MULADD(at[10], at[44]); MULADD(at[11], at[43]); MULADD(at[12], at[42]); MULADD(at[13], at[41]); MULADD(at[14], at[40]); MULADD(at[15], at[39]); MULADD(at[16], at[38]); MULADD(at[17], at[37]); MULADD(at[18], at[36]); MULADD(at[19], at[35]); MULADD(at[20], at[34]); MULADD(at[21], at[33]); MULADD(at[22], at[32]); MULADD(at[23], at[31]); COMBA_STORE(C->dp[30]); /* 31 */ COMBA_FORWARD; MULADD(at[8], at[47]); MULADD(at[9], at[46]); MULADD(at[10], at[45]); MULADD(at[11], at[44]); MULADD(at[12], at[43]); MULADD(at[13], at[42]); MULADD(at[14], at[41]); MULADD(at[15], at[40]); MULADD(at[16], at[39]); MULADD(at[17], at[38]); MULADD(at[18], at[37]); MULADD(at[19], at[36]); MULADD(at[20], at[35]); MULADD(at[21], at[34]); MULADD(at[22], at[33]); MULADD(at[23], at[32]); COMBA_STORE(C->dp[31]); /* 32 */ COMBA_FORWARD; MULADD(at[9], at[47]); MULADD(at[10], at[46]); MULADD(at[11], at[45]); MULADD(at[12], at[44]); MULADD(at[13], at[43]); MULADD(at[14], at[42]); MULADD(at[15], at[41]); MULADD(at[16], at[40]); MULADD(at[17], at[39]); MULADD(at[18], at[38]); MULADD(at[19], at[37]); MULADD(at[20], at[36]); MULADD(at[21], at[35]); MULADD(at[22], at[34]); MULADD(at[23], at[33]); COMBA_STORE(C->dp[32]); /* 33 */ COMBA_FORWARD; MULADD(at[10], at[47]); MULADD(at[11], at[46]); MULADD(at[12], at[45]); MULADD(at[13], at[44]); MULADD(at[14], at[43]); MULADD(at[15], at[42]); MULADD(at[16], at[41]); MULADD(at[17], at[40]); MULADD(at[18], at[39]); MULADD(at[19], at[38]); MULADD(at[20], at[37]); MULADD(at[21], at[36]); MULADD(at[22], at[35]); MULADD(at[23], at[34]); COMBA_STORE(C->dp[33]); /* 34 */ COMBA_FORWARD; MULADD(at[11], at[47]); MULADD(at[12], at[46]); MULADD(at[13], at[45]); MULADD(at[14], at[44]); MULADD(at[15], at[43]); MULADD(at[16], at[42]); MULADD(at[17], at[41]); MULADD(at[18], at[40]); MULADD(at[19], at[39]); MULADD(at[20], at[38]); MULADD(at[21], at[37]); MULADD(at[22], at[36]); MULADD(at[23], at[35]); COMBA_STORE(C->dp[34]); /* 35 */ COMBA_FORWARD; MULADD(at[12], at[47]); MULADD(at[13], at[46]); MULADD(at[14], at[45]); MULADD(at[15], at[44]); MULADD(at[16], at[43]); MULADD(at[17], at[42]); MULADD(at[18], at[41]); MULADD(at[19], at[40]); MULADD(at[20], at[39]); MULADD(at[21], at[38]); MULADD(at[22], at[37]); MULADD(at[23], at[36]); COMBA_STORE(C->dp[35]); /* 36 */ COMBA_FORWARD; MULADD(at[13], at[47]); MULADD(at[14], at[46]); MULADD(at[15], at[45]); MULADD(at[16], at[44]); MULADD(at[17], at[43]); MULADD(at[18], at[42]); MULADD(at[19], at[41]); MULADD(at[20], at[40]); MULADD(at[21], at[39]); MULADD(at[22], at[38]); MULADD(at[23], at[37]); COMBA_STORE(C->dp[36]); /* 37 */ COMBA_FORWARD; MULADD(at[14], at[47]); MULADD(at[15], at[46]); MULADD(at[16], at[45]); MULADD(at[17], at[44]); MULADD(at[18], at[43]); MULADD(at[19], at[42]); MULADD(at[20], at[41]); MULADD(at[21], at[40]); MULADD(at[22], at[39]); MULADD(at[23], at[38]); COMBA_STORE(C->dp[37]); /* 38 */ COMBA_FORWARD; MULADD(at[15], at[47]); MULADD(at[16], at[46]); MULADD(at[17], at[45]); MULADD(at[18], at[44]); MULADD(at[19], at[43]); MULADD(at[20], at[42]); MULADD(at[21], at[41]); MULADD(at[22], at[40]); MULADD(at[23], at[39]); COMBA_STORE(C->dp[38]); /* 39 */ COMBA_FORWARD; MULADD(at[16], at[47]); MULADD(at[17], at[46]); MULADD(at[18], at[45]); MULADD(at[19], at[44]); MULADD(at[20], at[43]); MULADD(at[21], at[42]); MULADD(at[22], at[41]); MULADD(at[23], at[40]); COMBA_STORE(C->dp[39]); /* 40 */ COMBA_FORWARD; MULADD(at[17], at[47]); MULADD(at[18], at[46]); MULADD(at[19], at[45]); MULADD(at[20], at[44]); MULADD(at[21], at[43]); MULADD(at[22], at[42]); MULADD(at[23], at[41]); COMBA_STORE(C->dp[40]); /* 41 */ COMBA_FORWARD; MULADD(at[18], at[47]); MULADD(at[19], at[46]); MULADD(at[20], at[45]); MULADD(at[21], at[44]); MULADD(at[22], at[43]); MULADD(at[23], at[42]); COMBA_STORE(C->dp[41]); /* 42 */ COMBA_FORWARD; MULADD(at[19], at[47]); MULADD(at[20], at[46]); MULADD(at[21], at[45]); MULADD(at[22], at[44]); MULADD(at[23], at[43]); COMBA_STORE(C->dp[42]); /* 43 */ COMBA_FORWARD; MULADD(at[20], at[47]); MULADD(at[21], at[46]); MULADD(at[22], at[45]); MULADD(at[23], at[44]); COMBA_STORE(C->dp[43]); /* 44 */ COMBA_FORWARD; MULADD(at[21], at[47]); MULADD(at[22], at[46]); MULADD(at[23], at[45]); COMBA_STORE(C->dp[44]); /* 45 */ COMBA_FORWARD; MULADD(at[22], at[47]); MULADD(at[23], at[46]); COMBA_STORE(C->dp[45]); /* 46 */ COMBA_FORWARD; MULADD(at[23], at[47]); COMBA_STORE(C->dp[46]); COMBA_STORE2(C->dp[47]); C->used = 48; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; } #endif /* End: src/mul/fp_mul_comba_24.c */ /* Start: src/mul/fp_mul_comba_28.c */ #define TFM_DEFINES //#include "fp_mul_comba.c" #ifdef TFM_MUL28 void fp_mul_comba28(fp_int *A, fp_int *B, fp_int *C) { fp_digit c0, c1, c2, at[56]; memcpy(at, A->dp, 28 * sizeof(fp_digit)); memcpy(at+28, B->dp, 28 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[28]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[29]); MULADD(at[1], at[28]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[30]); MULADD(at[1], at[29]); MULADD(at[2], at[28]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[31]); MULADD(at[1], at[30]); MULADD(at[2], at[29]); MULADD(at[3], at[28]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[32]); MULADD(at[1], at[31]); MULADD(at[2], at[30]); MULADD(at[3], at[29]); MULADD(at[4], at[28]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[33]); MULADD(at[1], at[32]); MULADD(at[2], at[31]); MULADD(at[3], at[30]); MULADD(at[4], at[29]); MULADD(at[5], at[28]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[34]); MULADD(at[1], at[33]); MULADD(at[2], at[32]); MULADD(at[3], at[31]); MULADD(at[4], at[30]); MULADD(at[5], at[29]); MULADD(at[6], at[28]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[35]); MULADD(at[1], at[34]); MULADD(at[2], at[33]); MULADD(at[3], at[32]); MULADD(at[4], at[31]); MULADD(at[5], at[30]); MULADD(at[6], at[29]); MULADD(at[7], at[28]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[0], at[36]); MULADD(at[1], at[35]); MULADD(at[2], at[34]); MULADD(at[3], at[33]); MULADD(at[4], at[32]); MULADD(at[5], at[31]); MULADD(at[6], at[30]); MULADD(at[7], at[29]); MULADD(at[8], at[28]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[0], at[37]); MULADD(at[1], at[36]); MULADD(at[2], at[35]); MULADD(at[3], at[34]); MULADD(at[4], at[33]); MULADD(at[5], at[32]); MULADD(at[6], at[31]); MULADD(at[7], at[30]); MULADD(at[8], at[29]); MULADD(at[9], at[28]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[0], at[38]); MULADD(at[1], at[37]); MULADD(at[2], at[36]); MULADD(at[3], at[35]); MULADD(at[4], at[34]); MULADD(at[5], at[33]); MULADD(at[6], at[32]); MULADD(at[7], at[31]); MULADD(at[8], at[30]); MULADD(at[9], at[29]); MULADD(at[10], at[28]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[0], at[39]); MULADD(at[1], at[38]); MULADD(at[2], at[37]); MULADD(at[3], at[36]); MULADD(at[4], at[35]); MULADD(at[5], at[34]); MULADD(at[6], at[33]); MULADD(at[7], at[32]); MULADD(at[8], at[31]); MULADD(at[9], at[30]); MULADD(at[10], at[29]); MULADD(at[11], at[28]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[0], at[40]); MULADD(at[1], at[39]); MULADD(at[2], at[38]); MULADD(at[3], at[37]); MULADD(at[4], at[36]); MULADD(at[5], at[35]); MULADD(at[6], at[34]); MULADD(at[7], at[33]); MULADD(at[8], at[32]); MULADD(at[9], at[31]); MULADD(at[10], at[30]); MULADD(at[11], at[29]); MULADD(at[12], at[28]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[0], at[41]); MULADD(at[1], at[40]); MULADD(at[2], at[39]); MULADD(at[3], at[38]); MULADD(at[4], at[37]); MULADD(at[5], at[36]); MULADD(at[6], at[35]); MULADD(at[7], at[34]); MULADD(at[8], at[33]); MULADD(at[9], at[32]); MULADD(at[10], at[31]); MULADD(at[11], at[30]); MULADD(at[12], at[29]); MULADD(at[13], at[28]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[0], at[42]); MULADD(at[1], at[41]); MULADD(at[2], at[40]); MULADD(at[3], at[39]); MULADD(at[4], at[38]); MULADD(at[5], at[37]); MULADD(at[6], at[36]); MULADD(at[7], at[35]); MULADD(at[8], at[34]); MULADD(at[9], at[33]); MULADD(at[10], at[32]); MULADD(at[11], at[31]); MULADD(at[12], at[30]); MULADD(at[13], at[29]); MULADD(at[14], at[28]); COMBA_STORE(C->dp[14]); /* 15 */ COMBA_FORWARD; MULADD(at[0], at[43]); MULADD(at[1], at[42]); MULADD(at[2], at[41]); MULADD(at[3], at[40]); MULADD(at[4], at[39]); MULADD(at[5], at[38]); MULADD(at[6], at[37]); MULADD(at[7], at[36]); MULADD(at[8], at[35]); MULADD(at[9], at[34]); MULADD(at[10], at[33]); MULADD(at[11], at[32]); MULADD(at[12], at[31]); MULADD(at[13], at[30]); MULADD(at[14], at[29]); MULADD(at[15], at[28]); COMBA_STORE(C->dp[15]); /* 16 */ COMBA_FORWARD; MULADD(at[0], at[44]); MULADD(at[1], at[43]); MULADD(at[2], at[42]); MULADD(at[3], at[41]); MULADD(at[4], at[40]); MULADD(at[5], at[39]); MULADD(at[6], at[38]); MULADD(at[7], at[37]); MULADD(at[8], at[36]); MULADD(at[9], at[35]); MULADD(at[10], at[34]); MULADD(at[11], at[33]); MULADD(at[12], at[32]); MULADD(at[13], at[31]); MULADD(at[14], at[30]); MULADD(at[15], at[29]); MULADD(at[16], at[28]); COMBA_STORE(C->dp[16]); /* 17 */ COMBA_FORWARD; MULADD(at[0], at[45]); MULADD(at[1], at[44]); MULADD(at[2], at[43]); MULADD(at[3], at[42]); MULADD(at[4], at[41]); MULADD(at[5], at[40]); MULADD(at[6], at[39]); MULADD(at[7], at[38]); MULADD(at[8], at[37]); MULADD(at[9], at[36]); MULADD(at[10], at[35]); MULADD(at[11], at[34]); MULADD(at[12], at[33]); MULADD(at[13], at[32]); MULADD(at[14], at[31]); MULADD(at[15], at[30]); MULADD(at[16], at[29]); MULADD(at[17], at[28]); COMBA_STORE(C->dp[17]); /* 18 */ COMBA_FORWARD; MULADD(at[0], at[46]); MULADD(at[1], at[45]); MULADD(at[2], at[44]); MULADD(at[3], at[43]); MULADD(at[4], at[42]); MULADD(at[5], at[41]); MULADD(at[6], at[40]); MULADD(at[7], at[39]); MULADD(at[8], at[38]); MULADD(at[9], at[37]); MULADD(at[10], at[36]); MULADD(at[11], at[35]); MULADD(at[12], at[34]); MULADD(at[13], at[33]); MULADD(at[14], at[32]); MULADD(at[15], at[31]); MULADD(at[16], at[30]); MULADD(at[17], at[29]); MULADD(at[18], at[28]); COMBA_STORE(C->dp[18]); /* 19 */ COMBA_FORWARD; MULADD(at[0], at[47]); MULADD(at[1], at[46]); MULADD(at[2], at[45]); MULADD(at[3], at[44]); MULADD(at[4], at[43]); MULADD(at[5], at[42]); MULADD(at[6], at[41]); MULADD(at[7], at[40]); MULADD(at[8], at[39]); MULADD(at[9], at[38]); MULADD(at[10], at[37]); MULADD(at[11], at[36]); MULADD(at[12], at[35]); MULADD(at[13], at[34]); MULADD(at[14], at[33]); MULADD(at[15], at[32]); MULADD(at[16], at[31]); MULADD(at[17], at[30]); MULADD(at[18], at[29]); MULADD(at[19], at[28]); COMBA_STORE(C->dp[19]); /* 20 */ COMBA_FORWARD; MULADD(at[0], at[48]); MULADD(at[1], at[47]); MULADD(at[2], at[46]); MULADD(at[3], at[45]); MULADD(at[4], at[44]); MULADD(at[5], at[43]); MULADD(at[6], at[42]); MULADD(at[7], at[41]); MULADD(at[8], at[40]); MULADD(at[9], at[39]); MULADD(at[10], at[38]); MULADD(at[11], at[37]); MULADD(at[12], at[36]); MULADD(at[13], at[35]); MULADD(at[14], at[34]); MULADD(at[15], at[33]); MULADD(at[16], at[32]); MULADD(at[17], at[31]); MULADD(at[18], at[30]); MULADD(at[19], at[29]); MULADD(at[20], at[28]); COMBA_STORE(C->dp[20]); /* 21 */ COMBA_FORWARD; MULADD(at[0], at[49]); MULADD(at[1], at[48]); MULADD(at[2], at[47]); MULADD(at[3], at[46]); MULADD(at[4], at[45]); MULADD(at[5], at[44]); MULADD(at[6], at[43]); MULADD(at[7], at[42]); MULADD(at[8], at[41]); MULADD(at[9], at[40]); MULADD(at[10], at[39]); MULADD(at[11], at[38]); MULADD(at[12], at[37]); MULADD(at[13], at[36]); MULADD(at[14], at[35]); MULADD(at[15], at[34]); MULADD(at[16], at[33]); MULADD(at[17], at[32]); MULADD(at[18], at[31]); MULADD(at[19], at[30]); MULADD(at[20], at[29]); MULADD(at[21], at[28]); COMBA_STORE(C->dp[21]); /* 22 */ COMBA_FORWARD; MULADD(at[0], at[50]); MULADD(at[1], at[49]); MULADD(at[2], at[48]); MULADD(at[3], at[47]); MULADD(at[4], at[46]); MULADD(at[5], at[45]); MULADD(at[6], at[44]); MULADD(at[7], at[43]); MULADD(at[8], at[42]); MULADD(at[9], at[41]); MULADD(at[10], at[40]); MULADD(at[11], at[39]); MULADD(at[12], at[38]); MULADD(at[13], at[37]); MULADD(at[14], at[36]); MULADD(at[15], at[35]); MULADD(at[16], at[34]); MULADD(at[17], at[33]); MULADD(at[18], at[32]); MULADD(at[19], at[31]); MULADD(at[20], at[30]); MULADD(at[21], at[29]); MULADD(at[22], at[28]); COMBA_STORE(C->dp[22]); /* 23 */ COMBA_FORWARD; MULADD(at[0], at[51]); MULADD(at[1], at[50]); MULADD(at[2], at[49]); MULADD(at[3], at[48]); MULADD(at[4], at[47]); MULADD(at[5], at[46]); MULADD(at[6], at[45]); MULADD(at[7], at[44]); MULADD(at[8], at[43]); MULADD(at[9], at[42]); MULADD(at[10], at[41]); MULADD(at[11], at[40]); MULADD(at[12], at[39]); MULADD(at[13], at[38]); MULADD(at[14], at[37]); MULADD(at[15], at[36]); MULADD(at[16], at[35]); MULADD(at[17], at[34]); MULADD(at[18], at[33]); MULADD(at[19], at[32]); MULADD(at[20], at[31]); MULADD(at[21], at[30]); MULADD(at[22], at[29]); MULADD(at[23], at[28]); COMBA_STORE(C->dp[23]); /* 24 */ COMBA_FORWARD; MULADD(at[0], at[52]); MULADD(at[1], at[51]); MULADD(at[2], at[50]); MULADD(at[3], at[49]); MULADD(at[4], at[48]); MULADD(at[5], at[47]); MULADD(at[6], at[46]); MULADD(at[7], at[45]); MULADD(at[8], at[44]); MULADD(at[9], at[43]); MULADD(at[10], at[42]); MULADD(at[11], at[41]); MULADD(at[12], at[40]); MULADD(at[13], at[39]); MULADD(at[14], at[38]); MULADD(at[15], at[37]); MULADD(at[16], at[36]); MULADD(at[17], at[35]); MULADD(at[18], at[34]); MULADD(at[19], at[33]); MULADD(at[20], at[32]); MULADD(at[21], at[31]); MULADD(at[22], at[30]); MULADD(at[23], at[29]); MULADD(at[24], at[28]); COMBA_STORE(C->dp[24]); /* 25 */ COMBA_FORWARD; MULADD(at[0], at[53]); MULADD(at[1], at[52]); MULADD(at[2], at[51]); MULADD(at[3], at[50]); MULADD(at[4], at[49]); MULADD(at[5], at[48]); MULADD(at[6], at[47]); MULADD(at[7], at[46]); MULADD(at[8], at[45]); MULADD(at[9], at[44]); MULADD(at[10], at[43]); MULADD(at[11], at[42]); MULADD(at[12], at[41]); MULADD(at[13], at[40]); MULADD(at[14], at[39]); MULADD(at[15], at[38]); MULADD(at[16], at[37]); MULADD(at[17], at[36]); MULADD(at[18], at[35]); MULADD(at[19], at[34]); MULADD(at[20], at[33]); MULADD(at[21], at[32]); MULADD(at[22], at[31]); MULADD(at[23], at[30]); MULADD(at[24], at[29]); MULADD(at[25], at[28]); COMBA_STORE(C->dp[25]); /* 26 */ COMBA_FORWARD; MULADD(at[0], at[54]); MULADD(at[1], at[53]); MULADD(at[2], at[52]); MULADD(at[3], at[51]); MULADD(at[4], at[50]); MULADD(at[5], at[49]); MULADD(at[6], at[48]); MULADD(at[7], at[47]); MULADD(at[8], at[46]); MULADD(at[9], at[45]); MULADD(at[10], at[44]); MULADD(at[11], at[43]); MULADD(at[12], at[42]); MULADD(at[13], at[41]); MULADD(at[14], at[40]); MULADD(at[15], at[39]); MULADD(at[16], at[38]); MULADD(at[17], at[37]); MULADD(at[18], at[36]); MULADD(at[19], at[35]); MULADD(at[20], at[34]); MULADD(at[21], at[33]); MULADD(at[22], at[32]); MULADD(at[23], at[31]); MULADD(at[24], at[30]); MULADD(at[25], at[29]); MULADD(at[26], at[28]); COMBA_STORE(C->dp[26]); /* 27 */ COMBA_FORWARD; MULADD(at[0], at[55]); MULADD(at[1], at[54]); MULADD(at[2], at[53]); MULADD(at[3], at[52]); MULADD(at[4], at[51]); MULADD(at[5], at[50]); MULADD(at[6], at[49]); MULADD(at[7], at[48]); MULADD(at[8], at[47]); MULADD(at[9], at[46]); MULADD(at[10], at[45]); MULADD(at[11], at[44]); MULADD(at[12], at[43]); MULADD(at[13], at[42]); MULADD(at[14], at[41]); MULADD(at[15], at[40]); MULADD(at[16], at[39]); MULADD(at[17], at[38]); MULADD(at[18], at[37]); MULADD(at[19], at[36]); MULADD(at[20], at[35]); MULADD(at[21], at[34]); MULADD(at[22], at[33]); MULADD(at[23], at[32]); MULADD(at[24], at[31]); MULADD(at[25], at[30]); MULADD(at[26], at[29]); MULADD(at[27], at[28]); COMBA_STORE(C->dp[27]); /* 28 */ COMBA_FORWARD; MULADD(at[1], at[55]); MULADD(at[2], at[54]); MULADD(at[3], at[53]); MULADD(at[4], at[52]); MULADD(at[5], at[51]); MULADD(at[6], at[50]); MULADD(at[7], at[49]); MULADD(at[8], at[48]); MULADD(at[9], at[47]); MULADD(at[10], at[46]); MULADD(at[11], at[45]); MULADD(at[12], at[44]); MULADD(at[13], at[43]); MULADD(at[14], at[42]); MULADD(at[15], at[41]); MULADD(at[16], at[40]); MULADD(at[17], at[39]); MULADD(at[18], at[38]); MULADD(at[19], at[37]); MULADD(at[20], at[36]); MULADD(at[21], at[35]); MULADD(at[22], at[34]); MULADD(at[23], at[33]); MULADD(at[24], at[32]); MULADD(at[25], at[31]); MULADD(at[26], at[30]); MULADD(at[27], at[29]); COMBA_STORE(C->dp[28]); /* 29 */ COMBA_FORWARD; MULADD(at[2], at[55]); MULADD(at[3], at[54]); MULADD(at[4], at[53]); MULADD(at[5], at[52]); MULADD(at[6], at[51]); MULADD(at[7], at[50]); MULADD(at[8], at[49]); MULADD(at[9], at[48]); MULADD(at[10], at[47]); MULADD(at[11], at[46]); MULADD(at[12], at[45]); MULADD(at[13], at[44]); MULADD(at[14], at[43]); MULADD(at[15], at[42]); MULADD(at[16], at[41]); MULADD(at[17], at[40]); MULADD(at[18], at[39]); MULADD(at[19], at[38]); MULADD(at[20], at[37]); MULADD(at[21], at[36]); MULADD(at[22], at[35]); MULADD(at[23], at[34]); MULADD(at[24], at[33]); MULADD(at[25], at[32]); MULADD(at[26], at[31]); MULADD(at[27], at[30]); COMBA_STORE(C->dp[29]); /* 30 */ COMBA_FORWARD; MULADD(at[3], at[55]); MULADD(at[4], at[54]); MULADD(at[5], at[53]); MULADD(at[6], at[52]); MULADD(at[7], at[51]); MULADD(at[8], at[50]); MULADD(at[9], at[49]); MULADD(at[10], at[48]); MULADD(at[11], at[47]); MULADD(at[12], at[46]); MULADD(at[13], at[45]); MULADD(at[14], at[44]); MULADD(at[15], at[43]); MULADD(at[16], at[42]); MULADD(at[17], at[41]); MULADD(at[18], at[40]); MULADD(at[19], at[39]); MULADD(at[20], at[38]); MULADD(at[21], at[37]); MULADD(at[22], at[36]); MULADD(at[23], at[35]); MULADD(at[24], at[34]); MULADD(at[25], at[33]); MULADD(at[26], at[32]); MULADD(at[27], at[31]); COMBA_STORE(C->dp[30]); /* 31 */ COMBA_FORWARD; MULADD(at[4], at[55]); MULADD(at[5], at[54]); MULADD(at[6], at[53]); MULADD(at[7], at[52]); MULADD(at[8], at[51]); MULADD(at[9], at[50]); MULADD(at[10], at[49]); MULADD(at[11], at[48]); MULADD(at[12], at[47]); MULADD(at[13], at[46]); MULADD(at[14], at[45]); MULADD(at[15], at[44]); MULADD(at[16], at[43]); MULADD(at[17], at[42]); MULADD(at[18], at[41]); MULADD(at[19], at[40]); MULADD(at[20], at[39]); MULADD(at[21], at[38]); MULADD(at[22], at[37]); MULADD(at[23], at[36]); MULADD(at[24], at[35]); MULADD(at[25], at[34]); MULADD(at[26], at[33]); MULADD(at[27], at[32]); COMBA_STORE(C->dp[31]); /* 32 */ COMBA_FORWARD; MULADD(at[5], at[55]); MULADD(at[6], at[54]); MULADD(at[7], at[53]); MULADD(at[8], at[52]); MULADD(at[9], at[51]); MULADD(at[10], at[50]); MULADD(at[11], at[49]); MULADD(at[12], at[48]); MULADD(at[13], at[47]); MULADD(at[14], at[46]); MULADD(at[15], at[45]); MULADD(at[16], at[44]); MULADD(at[17], at[43]); MULADD(at[18], at[42]); MULADD(at[19], at[41]); MULADD(at[20], at[40]); MULADD(at[21], at[39]); MULADD(at[22], at[38]); MULADD(at[23], at[37]); MULADD(at[24], at[36]); MULADD(at[25], at[35]); MULADD(at[26], at[34]); MULADD(at[27], at[33]); COMBA_STORE(C->dp[32]); /* 33 */ COMBA_FORWARD; MULADD(at[6], at[55]); MULADD(at[7], at[54]); MULADD(at[8], at[53]); MULADD(at[9], at[52]); MULADD(at[10], at[51]); MULADD(at[11], at[50]); MULADD(at[12], at[49]); MULADD(at[13], at[48]); MULADD(at[14], at[47]); MULADD(at[15], at[46]); MULADD(at[16], at[45]); MULADD(at[17], at[44]); MULADD(at[18], at[43]); MULADD(at[19], at[42]); MULADD(at[20], at[41]); MULADD(at[21], at[40]); MULADD(at[22], at[39]); MULADD(at[23], at[38]); MULADD(at[24], at[37]); MULADD(at[25], at[36]); MULADD(at[26], at[35]); MULADD(at[27], at[34]); COMBA_STORE(C->dp[33]); /* 34 */ COMBA_FORWARD; MULADD(at[7], at[55]); MULADD(at[8], at[54]); MULADD(at[9], at[53]); MULADD(at[10], at[52]); MULADD(at[11], at[51]); MULADD(at[12], at[50]); MULADD(at[13], at[49]); MULADD(at[14], at[48]); MULADD(at[15], at[47]); MULADD(at[16], at[46]); MULADD(at[17], at[45]); MULADD(at[18], at[44]); MULADD(at[19], at[43]); MULADD(at[20], at[42]); MULADD(at[21], at[41]); MULADD(at[22], at[40]); MULADD(at[23], at[39]); MULADD(at[24], at[38]); MULADD(at[25], at[37]); MULADD(at[26], at[36]); MULADD(at[27], at[35]); COMBA_STORE(C->dp[34]); /* 35 */ COMBA_FORWARD; MULADD(at[8], at[55]); MULADD(at[9], at[54]); MULADD(at[10], at[53]); MULADD(at[11], at[52]); MULADD(at[12], at[51]); MULADD(at[13], at[50]); MULADD(at[14], at[49]); MULADD(at[15], at[48]); MULADD(at[16], at[47]); MULADD(at[17], at[46]); MULADD(at[18], at[45]); MULADD(at[19], at[44]); MULADD(at[20], at[43]); MULADD(at[21], at[42]); MULADD(at[22], at[41]); MULADD(at[23], at[40]); MULADD(at[24], at[39]); MULADD(at[25], at[38]); MULADD(at[26], at[37]); MULADD(at[27], at[36]); COMBA_STORE(C->dp[35]); /* 36 */ COMBA_FORWARD; MULADD(at[9], at[55]); MULADD(at[10], at[54]); MULADD(at[11], at[53]); MULADD(at[12], at[52]); MULADD(at[13], at[51]); MULADD(at[14], at[50]); MULADD(at[15], at[49]); MULADD(at[16], at[48]); MULADD(at[17], at[47]); MULADD(at[18], at[46]); MULADD(at[19], at[45]); MULADD(at[20], at[44]); MULADD(at[21], at[43]); MULADD(at[22], at[42]); MULADD(at[23], at[41]); MULADD(at[24], at[40]); MULADD(at[25], at[39]); MULADD(at[26], at[38]); MULADD(at[27], at[37]); COMBA_STORE(C->dp[36]); /* 37 */ COMBA_FORWARD; MULADD(at[10], at[55]); MULADD(at[11], at[54]); MULADD(at[12], at[53]); MULADD(at[13], at[52]); MULADD(at[14], at[51]); MULADD(at[15], at[50]); MULADD(at[16], at[49]); MULADD(at[17], at[48]); MULADD(at[18], at[47]); MULADD(at[19], at[46]); MULADD(at[20], at[45]); MULADD(at[21], at[44]); MULADD(at[22], at[43]); MULADD(at[23], at[42]); MULADD(at[24], at[41]); MULADD(at[25], at[40]); MULADD(at[26], at[39]); MULADD(at[27], at[38]); COMBA_STORE(C->dp[37]); /* 38 */ COMBA_FORWARD; MULADD(at[11], at[55]); MULADD(at[12], at[54]); MULADD(at[13], at[53]); MULADD(at[14], at[52]); MULADD(at[15], at[51]); MULADD(at[16], at[50]); MULADD(at[17], at[49]); MULADD(at[18], at[48]); MULADD(at[19], at[47]); MULADD(at[20], at[46]); MULADD(at[21], at[45]); MULADD(at[22], at[44]); MULADD(at[23], at[43]); MULADD(at[24], at[42]); MULADD(at[25], at[41]); MULADD(at[26], at[40]); MULADD(at[27], at[39]); COMBA_STORE(C->dp[38]); /* 39 */ COMBA_FORWARD; MULADD(at[12], at[55]); MULADD(at[13], at[54]); MULADD(at[14], at[53]); MULADD(at[15], at[52]); MULADD(at[16], at[51]); MULADD(at[17], at[50]); MULADD(at[18], at[49]); MULADD(at[19], at[48]); MULADD(at[20], at[47]); MULADD(at[21], at[46]); MULADD(at[22], at[45]); MULADD(at[23], at[44]); MULADD(at[24], at[43]); MULADD(at[25], at[42]); MULADD(at[26], at[41]); MULADD(at[27], at[40]); COMBA_STORE(C->dp[39]); /* 40 */ COMBA_FORWARD; MULADD(at[13], at[55]); MULADD(at[14], at[54]); MULADD(at[15], at[53]); MULADD(at[16], at[52]); MULADD(at[17], at[51]); MULADD(at[18], at[50]); MULADD(at[19], at[49]); MULADD(at[20], at[48]); MULADD(at[21], at[47]); MULADD(at[22], at[46]); MULADD(at[23], at[45]); MULADD(at[24], at[44]); MULADD(at[25], at[43]); MULADD(at[26], at[42]); MULADD(at[27], at[41]); COMBA_STORE(C->dp[40]); /* 41 */ COMBA_FORWARD; MULADD(at[14], at[55]); MULADD(at[15], at[54]); MULADD(at[16], at[53]); MULADD(at[17], at[52]); MULADD(at[18], at[51]); MULADD(at[19], at[50]); MULADD(at[20], at[49]); MULADD(at[21], at[48]); MULADD(at[22], at[47]); MULADD(at[23], at[46]); MULADD(at[24], at[45]); MULADD(at[25], at[44]); MULADD(at[26], at[43]); MULADD(at[27], at[42]); COMBA_STORE(C->dp[41]); /* 42 */ COMBA_FORWARD; MULADD(at[15], at[55]); MULADD(at[16], at[54]); MULADD(at[17], at[53]); MULADD(at[18], at[52]); MULADD(at[19], at[51]); MULADD(at[20], at[50]); MULADD(at[21], at[49]); MULADD(at[22], at[48]); MULADD(at[23], at[47]); MULADD(at[24], at[46]); MULADD(at[25], at[45]); MULADD(at[26], at[44]); MULADD(at[27], at[43]); COMBA_STORE(C->dp[42]); /* 43 */ COMBA_FORWARD; MULADD(at[16], at[55]); MULADD(at[17], at[54]); MULADD(at[18], at[53]); MULADD(at[19], at[52]); MULADD(at[20], at[51]); MULADD(at[21], at[50]); MULADD(at[22], at[49]); MULADD(at[23], at[48]); MULADD(at[24], at[47]); MULADD(at[25], at[46]); MULADD(at[26], at[45]); MULADD(at[27], at[44]); COMBA_STORE(C->dp[43]); /* 44 */ COMBA_FORWARD; MULADD(at[17], at[55]); MULADD(at[18], at[54]); MULADD(at[19], at[53]); MULADD(at[20], at[52]); MULADD(at[21], at[51]); MULADD(at[22], at[50]); MULADD(at[23], at[49]); MULADD(at[24], at[48]); MULADD(at[25], at[47]); MULADD(at[26], at[46]); MULADD(at[27], at[45]); COMBA_STORE(C->dp[44]); /* 45 */ COMBA_FORWARD; MULADD(at[18], at[55]); MULADD(at[19], at[54]); MULADD(at[20], at[53]); MULADD(at[21], at[52]); MULADD(at[22], at[51]); MULADD(at[23], at[50]); MULADD(at[24], at[49]); MULADD(at[25], at[48]); MULADD(at[26], at[47]); MULADD(at[27], at[46]); COMBA_STORE(C->dp[45]); /* 46 */ COMBA_FORWARD; MULADD(at[19], at[55]); MULADD(at[20], at[54]); MULADD(at[21], at[53]); MULADD(at[22], at[52]); MULADD(at[23], at[51]); MULADD(at[24], at[50]); MULADD(at[25], at[49]); MULADD(at[26], at[48]); MULADD(at[27], at[47]); COMBA_STORE(C->dp[46]); /* 47 */ COMBA_FORWARD; MULADD(at[20], at[55]); MULADD(at[21], at[54]); MULADD(at[22], at[53]); MULADD(at[23], at[52]); MULADD(at[24], at[51]); MULADD(at[25], at[50]); MULADD(at[26], at[49]); MULADD(at[27], at[48]); COMBA_STORE(C->dp[47]); /* 48 */ COMBA_FORWARD; MULADD(at[21], at[55]); MULADD(at[22], at[54]); MULADD(at[23], at[53]); MULADD(at[24], at[52]); MULADD(at[25], at[51]); MULADD(at[26], at[50]); MULADD(at[27], at[49]); COMBA_STORE(C->dp[48]); /* 49 */ COMBA_FORWARD; MULADD(at[22], at[55]); MULADD(at[23], at[54]); MULADD(at[24], at[53]); MULADD(at[25], at[52]); MULADD(at[26], at[51]); MULADD(at[27], at[50]); COMBA_STORE(C->dp[49]); /* 50 */ COMBA_FORWARD; MULADD(at[23], at[55]); MULADD(at[24], at[54]); MULADD(at[25], at[53]); MULADD(at[26], at[52]); MULADD(at[27], at[51]); COMBA_STORE(C->dp[50]); /* 51 */ COMBA_FORWARD; MULADD(at[24], at[55]); MULADD(at[25], at[54]); MULADD(at[26], at[53]); MULADD(at[27], at[52]); COMBA_STORE(C->dp[51]); /* 52 */ COMBA_FORWARD; MULADD(at[25], at[55]); MULADD(at[26], at[54]); MULADD(at[27], at[53]); COMBA_STORE(C->dp[52]); /* 53 */ COMBA_FORWARD; MULADD(at[26], at[55]); MULADD(at[27], at[54]); COMBA_STORE(C->dp[53]); /* 54 */ COMBA_FORWARD; MULADD(at[27], at[55]); COMBA_STORE(C->dp[54]); COMBA_STORE2(C->dp[55]); C->used = 56; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; } #endif /* End: src/mul/fp_mul_comba_28.c */ /* Start: src/mul/fp_mul_comba_3.c */ #define TFM_DEFINES //#include "fp_mul_comba.c" #ifdef TFM_MUL3 void fp_mul_comba3(fp_int *A, fp_int *B, fp_int *C) { fp_digit c0, c1, c2, at[6]; memcpy(at, A->dp, 3 * sizeof(fp_digit)); memcpy(at+3, B->dp, 3 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[3]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[4]); MULADD(at[1], at[3]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[5]); MULADD(at[1], at[4]); MULADD(at[2], at[3]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[1], at[5]); MULADD(at[2], at[4]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[2], at[5]); COMBA_STORE(C->dp[4]); COMBA_STORE2(C->dp[5]); C->used = 6; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; } #endif /* End: src/mul/fp_mul_comba_3.c */ /* Start: src/mul/fp_mul_comba_32.c */ #define TFM_DEFINES //#include "fp_mul_comba.c" #ifdef TFM_MUL32 void fp_mul_comba32(fp_int *A, fp_int *B, fp_int *C) { fp_digit c0, c1, c2, at[64]; int out_size; out_size = A->used + B->used; memcpy(at, A->dp, 32 * sizeof(fp_digit)); memcpy(at+32, B->dp, 32 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[32]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[33]); MULADD(at[1], at[32]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[34]); MULADD(at[1], at[33]); MULADD(at[2], at[32]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[35]); MULADD(at[1], at[34]); MULADD(at[2], at[33]); MULADD(at[3], at[32]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[36]); MULADD(at[1], at[35]); MULADD(at[2], at[34]); MULADD(at[3], at[33]); MULADD(at[4], at[32]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[37]); MULADD(at[1], at[36]); MULADD(at[2], at[35]); MULADD(at[3], at[34]); MULADD(at[4], at[33]); MULADD(at[5], at[32]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[38]); MULADD(at[1], at[37]); MULADD(at[2], at[36]); MULADD(at[3], at[35]); MULADD(at[4], at[34]); MULADD(at[5], at[33]); MULADD(at[6], at[32]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[39]); MULADD(at[1], at[38]); MULADD(at[2], at[37]); MULADD(at[3], at[36]); MULADD(at[4], at[35]); MULADD(at[5], at[34]); MULADD(at[6], at[33]); MULADD(at[7], at[32]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[0], at[40]); MULADD(at[1], at[39]); MULADD(at[2], at[38]); MULADD(at[3], at[37]); MULADD(at[4], at[36]); MULADD(at[5], at[35]); MULADD(at[6], at[34]); MULADD(at[7], at[33]); MULADD(at[8], at[32]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[0], at[41]); MULADD(at[1], at[40]); MULADD(at[2], at[39]); MULADD(at[3], at[38]); MULADD(at[4], at[37]); MULADD(at[5], at[36]); MULADD(at[6], at[35]); MULADD(at[7], at[34]); MULADD(at[8], at[33]); MULADD(at[9], at[32]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[0], at[42]); MULADD(at[1], at[41]); MULADD(at[2], at[40]); MULADD(at[3], at[39]); MULADD(at[4], at[38]); MULADD(at[5], at[37]); MULADD(at[6], at[36]); MULADD(at[7], at[35]); MULADD(at[8], at[34]); MULADD(at[9], at[33]); MULADD(at[10], at[32]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[0], at[43]); MULADD(at[1], at[42]); MULADD(at[2], at[41]); MULADD(at[3], at[40]); MULADD(at[4], at[39]); MULADD(at[5], at[38]); MULADD(at[6], at[37]); MULADD(at[7], at[36]); MULADD(at[8], at[35]); MULADD(at[9], at[34]); MULADD(at[10], at[33]); MULADD(at[11], at[32]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[0], at[44]); MULADD(at[1], at[43]); MULADD(at[2], at[42]); MULADD(at[3], at[41]); MULADD(at[4], at[40]); MULADD(at[5], at[39]); MULADD(at[6], at[38]); MULADD(at[7], at[37]); MULADD(at[8], at[36]); MULADD(at[9], at[35]); MULADD(at[10], at[34]); MULADD(at[11], at[33]); MULADD(at[12], at[32]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[0], at[45]); MULADD(at[1], at[44]); MULADD(at[2], at[43]); MULADD(at[3], at[42]); MULADD(at[4], at[41]); MULADD(at[5], at[40]); MULADD(at[6], at[39]); MULADD(at[7], at[38]); MULADD(at[8], at[37]); MULADD(at[9], at[36]); MULADD(at[10], at[35]); MULADD(at[11], at[34]); MULADD(at[12], at[33]); MULADD(at[13], at[32]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[0], at[46]); MULADD(at[1], at[45]); MULADD(at[2], at[44]); MULADD(at[3], at[43]); MULADD(at[4], at[42]); MULADD(at[5], at[41]); MULADD(at[6], at[40]); MULADD(at[7], at[39]); MULADD(at[8], at[38]); MULADD(at[9], at[37]); MULADD(at[10], at[36]); MULADD(at[11], at[35]); MULADD(at[12], at[34]); MULADD(at[13], at[33]); MULADD(at[14], at[32]); COMBA_STORE(C->dp[14]); /* 15 */ COMBA_FORWARD; MULADD(at[0], at[47]); MULADD(at[1], at[46]); MULADD(at[2], at[45]); MULADD(at[3], at[44]); MULADD(at[4], at[43]); MULADD(at[5], at[42]); MULADD(at[6], at[41]); MULADD(at[7], at[40]); MULADD(at[8], at[39]); MULADD(at[9], at[38]); MULADD(at[10], at[37]); MULADD(at[11], at[36]); MULADD(at[12], at[35]); MULADD(at[13], at[34]); MULADD(at[14], at[33]); MULADD(at[15], at[32]); COMBA_STORE(C->dp[15]); /* 16 */ COMBA_FORWARD; MULADD(at[0], at[48]); MULADD(at[1], at[47]); MULADD(at[2], at[46]); MULADD(at[3], at[45]); MULADD(at[4], at[44]); MULADD(at[5], at[43]); MULADD(at[6], at[42]); MULADD(at[7], at[41]); MULADD(at[8], at[40]); MULADD(at[9], at[39]); MULADD(at[10], at[38]); MULADD(at[11], at[37]); MULADD(at[12], at[36]); MULADD(at[13], at[35]); MULADD(at[14], at[34]); MULADD(at[15], at[33]); MULADD(at[16], at[32]); COMBA_STORE(C->dp[16]); /* 17 */ COMBA_FORWARD; MULADD(at[0], at[49]); MULADD(at[1], at[48]); MULADD(at[2], at[47]); MULADD(at[3], at[46]); MULADD(at[4], at[45]); MULADD(at[5], at[44]); MULADD(at[6], at[43]); MULADD(at[7], at[42]); MULADD(at[8], at[41]); MULADD(at[9], at[40]); MULADD(at[10], at[39]); MULADD(at[11], at[38]); MULADD(at[12], at[37]); MULADD(at[13], at[36]); MULADD(at[14], at[35]); MULADD(at[15], at[34]); MULADD(at[16], at[33]); MULADD(at[17], at[32]); COMBA_STORE(C->dp[17]); /* 18 */ COMBA_FORWARD; MULADD(at[0], at[50]); MULADD(at[1], at[49]); MULADD(at[2], at[48]); MULADD(at[3], at[47]); MULADD(at[4], at[46]); MULADD(at[5], at[45]); MULADD(at[6], at[44]); MULADD(at[7], at[43]); MULADD(at[8], at[42]); MULADD(at[9], at[41]); MULADD(at[10], at[40]); MULADD(at[11], at[39]); MULADD(at[12], at[38]); MULADD(at[13], at[37]); MULADD(at[14], at[36]); MULADD(at[15], at[35]); MULADD(at[16], at[34]); MULADD(at[17], at[33]); MULADD(at[18], at[32]); COMBA_STORE(C->dp[18]); /* 19 */ COMBA_FORWARD; MULADD(at[0], at[51]); MULADD(at[1], at[50]); MULADD(at[2], at[49]); MULADD(at[3], at[48]); MULADD(at[4], at[47]); MULADD(at[5], at[46]); MULADD(at[6], at[45]); MULADD(at[7], at[44]); MULADD(at[8], at[43]); MULADD(at[9], at[42]); MULADD(at[10], at[41]); MULADD(at[11], at[40]); MULADD(at[12], at[39]); MULADD(at[13], at[38]); MULADD(at[14], at[37]); MULADD(at[15], at[36]); MULADD(at[16], at[35]); MULADD(at[17], at[34]); MULADD(at[18], at[33]); MULADD(at[19], at[32]); COMBA_STORE(C->dp[19]); /* 20 */ COMBA_FORWARD; MULADD(at[0], at[52]); MULADD(at[1], at[51]); MULADD(at[2], at[50]); MULADD(at[3], at[49]); MULADD(at[4], at[48]); MULADD(at[5], at[47]); MULADD(at[6], at[46]); MULADD(at[7], at[45]); MULADD(at[8], at[44]); MULADD(at[9], at[43]); MULADD(at[10], at[42]); MULADD(at[11], at[41]); MULADD(at[12], at[40]); MULADD(at[13], at[39]); MULADD(at[14], at[38]); MULADD(at[15], at[37]); MULADD(at[16], at[36]); MULADD(at[17], at[35]); MULADD(at[18], at[34]); MULADD(at[19], at[33]); MULADD(at[20], at[32]); COMBA_STORE(C->dp[20]); /* 21 */ COMBA_FORWARD; MULADD(at[0], at[53]); MULADD(at[1], at[52]); MULADD(at[2], at[51]); MULADD(at[3], at[50]); MULADD(at[4], at[49]); MULADD(at[5], at[48]); MULADD(at[6], at[47]); MULADD(at[7], at[46]); MULADD(at[8], at[45]); MULADD(at[9], at[44]); MULADD(at[10], at[43]); MULADD(at[11], at[42]); MULADD(at[12], at[41]); MULADD(at[13], at[40]); MULADD(at[14], at[39]); MULADD(at[15], at[38]); MULADD(at[16], at[37]); MULADD(at[17], at[36]); MULADD(at[18], at[35]); MULADD(at[19], at[34]); MULADD(at[20], at[33]); MULADD(at[21], at[32]); COMBA_STORE(C->dp[21]); /* 22 */ COMBA_FORWARD; MULADD(at[0], at[54]); MULADD(at[1], at[53]); MULADD(at[2], at[52]); MULADD(at[3], at[51]); MULADD(at[4], at[50]); MULADD(at[5], at[49]); MULADD(at[6], at[48]); MULADD(at[7], at[47]); MULADD(at[8], at[46]); MULADD(at[9], at[45]); MULADD(at[10], at[44]); MULADD(at[11], at[43]); MULADD(at[12], at[42]); MULADD(at[13], at[41]); MULADD(at[14], at[40]); MULADD(at[15], at[39]); MULADD(at[16], at[38]); MULADD(at[17], at[37]); MULADD(at[18], at[36]); MULADD(at[19], at[35]); MULADD(at[20], at[34]); MULADD(at[21], at[33]); MULADD(at[22], at[32]); COMBA_STORE(C->dp[22]); /* 23 */ COMBA_FORWARD; MULADD(at[0], at[55]); MULADD(at[1], at[54]); MULADD(at[2], at[53]); MULADD(at[3], at[52]); MULADD(at[4], at[51]); MULADD(at[5], at[50]); MULADD(at[6], at[49]); MULADD(at[7], at[48]); MULADD(at[8], at[47]); MULADD(at[9], at[46]); MULADD(at[10], at[45]); MULADD(at[11], at[44]); MULADD(at[12], at[43]); MULADD(at[13], at[42]); MULADD(at[14], at[41]); MULADD(at[15], at[40]); MULADD(at[16], at[39]); MULADD(at[17], at[38]); MULADD(at[18], at[37]); MULADD(at[19], at[36]); MULADD(at[20], at[35]); MULADD(at[21], at[34]); MULADD(at[22], at[33]); MULADD(at[23], at[32]); COMBA_STORE(C->dp[23]); /* 24 */ COMBA_FORWARD; MULADD(at[0], at[56]); MULADD(at[1], at[55]); MULADD(at[2], at[54]); MULADD(at[3], at[53]); MULADD(at[4], at[52]); MULADD(at[5], at[51]); MULADD(at[6], at[50]); MULADD(at[7], at[49]); MULADD(at[8], at[48]); MULADD(at[9], at[47]); MULADD(at[10], at[46]); MULADD(at[11], at[45]); MULADD(at[12], at[44]); MULADD(at[13], at[43]); MULADD(at[14], at[42]); MULADD(at[15], at[41]); MULADD(at[16], at[40]); MULADD(at[17], at[39]); MULADD(at[18], at[38]); MULADD(at[19], at[37]); MULADD(at[20], at[36]); MULADD(at[21], at[35]); MULADD(at[22], at[34]); MULADD(at[23], at[33]); MULADD(at[24], at[32]); COMBA_STORE(C->dp[24]); /* 25 */ COMBA_FORWARD; MULADD(at[0], at[57]); MULADD(at[1], at[56]); MULADD(at[2], at[55]); MULADD(at[3], at[54]); MULADD(at[4], at[53]); MULADD(at[5], at[52]); MULADD(at[6], at[51]); MULADD(at[7], at[50]); MULADD(at[8], at[49]); MULADD(at[9], at[48]); MULADD(at[10], at[47]); MULADD(at[11], at[46]); MULADD(at[12], at[45]); MULADD(at[13], at[44]); MULADD(at[14], at[43]); MULADD(at[15], at[42]); MULADD(at[16], at[41]); MULADD(at[17], at[40]); MULADD(at[18], at[39]); MULADD(at[19], at[38]); MULADD(at[20], at[37]); MULADD(at[21], at[36]); MULADD(at[22], at[35]); MULADD(at[23], at[34]); MULADD(at[24], at[33]); MULADD(at[25], at[32]); COMBA_STORE(C->dp[25]); /* 26 */ COMBA_FORWARD; MULADD(at[0], at[58]); MULADD(at[1], at[57]); MULADD(at[2], at[56]); MULADD(at[3], at[55]); MULADD(at[4], at[54]); MULADD(at[5], at[53]); MULADD(at[6], at[52]); MULADD(at[7], at[51]); MULADD(at[8], at[50]); MULADD(at[9], at[49]); MULADD(at[10], at[48]); MULADD(at[11], at[47]); MULADD(at[12], at[46]); MULADD(at[13], at[45]); MULADD(at[14], at[44]); MULADD(at[15], at[43]); MULADD(at[16], at[42]); MULADD(at[17], at[41]); MULADD(at[18], at[40]); MULADD(at[19], at[39]); MULADD(at[20], at[38]); MULADD(at[21], at[37]); MULADD(at[22], at[36]); MULADD(at[23], at[35]); MULADD(at[24], at[34]); MULADD(at[25], at[33]); MULADD(at[26], at[32]); COMBA_STORE(C->dp[26]); /* 27 */ COMBA_FORWARD; MULADD(at[0], at[59]); MULADD(at[1], at[58]); MULADD(at[2], at[57]); MULADD(at[3], at[56]); MULADD(at[4], at[55]); MULADD(at[5], at[54]); MULADD(at[6], at[53]); MULADD(at[7], at[52]); MULADD(at[8], at[51]); MULADD(at[9], at[50]); MULADD(at[10], at[49]); MULADD(at[11], at[48]); MULADD(at[12], at[47]); MULADD(at[13], at[46]); MULADD(at[14], at[45]); MULADD(at[15], at[44]); MULADD(at[16], at[43]); MULADD(at[17], at[42]); MULADD(at[18], at[41]); MULADD(at[19], at[40]); MULADD(at[20], at[39]); MULADD(at[21], at[38]); MULADD(at[22], at[37]); MULADD(at[23], at[36]); MULADD(at[24], at[35]); MULADD(at[25], at[34]); MULADD(at[26], at[33]); MULADD(at[27], at[32]); COMBA_STORE(C->dp[27]); /* 28 */ COMBA_FORWARD; MULADD(at[0], at[60]); MULADD(at[1], at[59]); MULADD(at[2], at[58]); MULADD(at[3], at[57]); MULADD(at[4], at[56]); MULADD(at[5], at[55]); MULADD(at[6], at[54]); MULADD(at[7], at[53]); MULADD(at[8], at[52]); MULADD(at[9], at[51]); MULADD(at[10], at[50]); MULADD(at[11], at[49]); MULADD(at[12], at[48]); MULADD(at[13], at[47]); MULADD(at[14], at[46]); MULADD(at[15], at[45]); MULADD(at[16], at[44]); MULADD(at[17], at[43]); MULADD(at[18], at[42]); MULADD(at[19], at[41]); MULADD(at[20], at[40]); MULADD(at[21], at[39]); MULADD(at[22], at[38]); MULADD(at[23], at[37]); MULADD(at[24], at[36]); MULADD(at[25], at[35]); MULADD(at[26], at[34]); MULADD(at[27], at[33]); MULADD(at[28], at[32]); COMBA_STORE(C->dp[28]); /* 29 */ COMBA_FORWARD; MULADD(at[0], at[61]); MULADD(at[1], at[60]); MULADD(at[2], at[59]); MULADD(at[3], at[58]); MULADD(at[4], at[57]); MULADD(at[5], at[56]); MULADD(at[6], at[55]); MULADD(at[7], at[54]); MULADD(at[8], at[53]); MULADD(at[9], at[52]); MULADD(at[10], at[51]); MULADD(at[11], at[50]); MULADD(at[12], at[49]); MULADD(at[13], at[48]); MULADD(at[14], at[47]); MULADD(at[15], at[46]); MULADD(at[16], at[45]); MULADD(at[17], at[44]); MULADD(at[18], at[43]); MULADD(at[19], at[42]); MULADD(at[20], at[41]); MULADD(at[21], at[40]); MULADD(at[22], at[39]); MULADD(at[23], at[38]); MULADD(at[24], at[37]); MULADD(at[25], at[36]); MULADD(at[26], at[35]); MULADD(at[27], at[34]); MULADD(at[28], at[33]); MULADD(at[29], at[32]); COMBA_STORE(C->dp[29]); /* 30 */ COMBA_FORWARD; MULADD(at[0], at[62]); MULADD(at[1], at[61]); MULADD(at[2], at[60]); MULADD(at[3], at[59]); MULADD(at[4], at[58]); MULADD(at[5], at[57]); MULADD(at[6], at[56]); MULADD(at[7], at[55]); MULADD(at[8], at[54]); MULADD(at[9], at[53]); MULADD(at[10], at[52]); MULADD(at[11], at[51]); MULADD(at[12], at[50]); MULADD(at[13], at[49]); MULADD(at[14], at[48]); MULADD(at[15], at[47]); MULADD(at[16], at[46]); MULADD(at[17], at[45]); MULADD(at[18], at[44]); MULADD(at[19], at[43]); MULADD(at[20], at[42]); MULADD(at[21], at[41]); MULADD(at[22], at[40]); MULADD(at[23], at[39]); MULADD(at[24], at[38]); MULADD(at[25], at[37]); MULADD(at[26], at[36]); MULADD(at[27], at[35]); MULADD(at[28], at[34]); MULADD(at[29], at[33]); MULADD(at[30], at[32]); COMBA_STORE(C->dp[30]); /* 31 */ COMBA_FORWARD; MULADD(at[0], at[63]); MULADD(at[1], at[62]); MULADD(at[2], at[61]); MULADD(at[3], at[60]); MULADD(at[4], at[59]); MULADD(at[5], at[58]); MULADD(at[6], at[57]); MULADD(at[7], at[56]); MULADD(at[8], at[55]); MULADD(at[9], at[54]); MULADD(at[10], at[53]); MULADD(at[11], at[52]); MULADD(at[12], at[51]); MULADD(at[13], at[50]); MULADD(at[14], at[49]); MULADD(at[15], at[48]); MULADD(at[16], at[47]); MULADD(at[17], at[46]); MULADD(at[18], at[45]); MULADD(at[19], at[44]); MULADD(at[20], at[43]); MULADD(at[21], at[42]); MULADD(at[22], at[41]); MULADD(at[23], at[40]); MULADD(at[24], at[39]); MULADD(at[25], at[38]); MULADD(at[26], at[37]); MULADD(at[27], at[36]); MULADD(at[28], at[35]); MULADD(at[29], at[34]); MULADD(at[30], at[33]); MULADD(at[31], at[32]); COMBA_STORE(C->dp[31]); /* 32 */ COMBA_FORWARD; MULADD(at[1], at[63]); MULADD(at[2], at[62]); MULADD(at[3], at[61]); MULADD(at[4], at[60]); MULADD(at[5], at[59]); MULADD(at[6], at[58]); MULADD(at[7], at[57]); MULADD(at[8], at[56]); MULADD(at[9], at[55]); MULADD(at[10], at[54]); MULADD(at[11], at[53]); MULADD(at[12], at[52]); MULADD(at[13], at[51]); MULADD(at[14], at[50]); MULADD(at[15], at[49]); MULADD(at[16], at[48]); MULADD(at[17], at[47]); MULADD(at[18], at[46]); MULADD(at[19], at[45]); MULADD(at[20], at[44]); MULADD(at[21], at[43]); MULADD(at[22], at[42]); MULADD(at[23], at[41]); MULADD(at[24], at[40]); MULADD(at[25], at[39]); MULADD(at[26], at[38]); MULADD(at[27], at[37]); MULADD(at[28], at[36]); MULADD(at[29], at[35]); MULADD(at[30], at[34]); MULADD(at[31], at[33]); COMBA_STORE(C->dp[32]); /* 33 */ COMBA_FORWARD; MULADD(at[2], at[63]); MULADD(at[3], at[62]); MULADD(at[4], at[61]); MULADD(at[5], at[60]); MULADD(at[6], at[59]); MULADD(at[7], at[58]); MULADD(at[8], at[57]); MULADD(at[9], at[56]); MULADD(at[10], at[55]); MULADD(at[11], at[54]); MULADD(at[12], at[53]); MULADD(at[13], at[52]); MULADD(at[14], at[51]); MULADD(at[15], at[50]); MULADD(at[16], at[49]); MULADD(at[17], at[48]); MULADD(at[18], at[47]); MULADD(at[19], at[46]); MULADD(at[20], at[45]); MULADD(at[21], at[44]); MULADD(at[22], at[43]); MULADD(at[23], at[42]); MULADD(at[24], at[41]); MULADD(at[25], at[40]); MULADD(at[26], at[39]); MULADD(at[27], at[38]); MULADD(at[28], at[37]); MULADD(at[29], at[36]); MULADD(at[30], at[35]); MULADD(at[31], at[34]); COMBA_STORE(C->dp[33]); /* 34 */ COMBA_FORWARD; MULADD(at[3], at[63]); MULADD(at[4], at[62]); MULADD(at[5], at[61]); MULADD(at[6], at[60]); MULADD(at[7], at[59]); MULADD(at[8], at[58]); MULADD(at[9], at[57]); MULADD(at[10], at[56]); MULADD(at[11], at[55]); MULADD(at[12], at[54]); MULADD(at[13], at[53]); MULADD(at[14], at[52]); MULADD(at[15], at[51]); MULADD(at[16], at[50]); MULADD(at[17], at[49]); MULADD(at[18], at[48]); MULADD(at[19], at[47]); MULADD(at[20], at[46]); MULADD(at[21], at[45]); MULADD(at[22], at[44]); MULADD(at[23], at[43]); MULADD(at[24], at[42]); MULADD(at[25], at[41]); MULADD(at[26], at[40]); MULADD(at[27], at[39]); MULADD(at[28], at[38]); MULADD(at[29], at[37]); MULADD(at[30], at[36]); MULADD(at[31], at[35]); COMBA_STORE(C->dp[34]); /* 35 */ COMBA_FORWARD; MULADD(at[4], at[63]); MULADD(at[5], at[62]); MULADD(at[6], at[61]); MULADD(at[7], at[60]); MULADD(at[8], at[59]); MULADD(at[9], at[58]); MULADD(at[10], at[57]); MULADD(at[11], at[56]); MULADD(at[12], at[55]); MULADD(at[13], at[54]); MULADD(at[14], at[53]); MULADD(at[15], at[52]); MULADD(at[16], at[51]); MULADD(at[17], at[50]); MULADD(at[18], at[49]); MULADD(at[19], at[48]); MULADD(at[20], at[47]); MULADD(at[21], at[46]); MULADD(at[22], at[45]); MULADD(at[23], at[44]); MULADD(at[24], at[43]); MULADD(at[25], at[42]); MULADD(at[26], at[41]); MULADD(at[27], at[40]); MULADD(at[28], at[39]); MULADD(at[29], at[38]); MULADD(at[30], at[37]); MULADD(at[31], at[36]); COMBA_STORE(C->dp[35]); /* 36 */ COMBA_FORWARD; MULADD(at[5], at[63]); MULADD(at[6], at[62]); MULADD(at[7], at[61]); MULADD(at[8], at[60]); MULADD(at[9], at[59]); MULADD(at[10], at[58]); MULADD(at[11], at[57]); MULADD(at[12], at[56]); MULADD(at[13], at[55]); MULADD(at[14], at[54]); MULADD(at[15], at[53]); MULADD(at[16], at[52]); MULADD(at[17], at[51]); MULADD(at[18], at[50]); MULADD(at[19], at[49]); MULADD(at[20], at[48]); MULADD(at[21], at[47]); MULADD(at[22], at[46]); MULADD(at[23], at[45]); MULADD(at[24], at[44]); MULADD(at[25], at[43]); MULADD(at[26], at[42]); MULADD(at[27], at[41]); MULADD(at[28], at[40]); MULADD(at[29], at[39]); MULADD(at[30], at[38]); MULADD(at[31], at[37]); COMBA_STORE(C->dp[36]); /* 37 */ COMBA_FORWARD; MULADD(at[6], at[63]); MULADD(at[7], at[62]); MULADD(at[8], at[61]); MULADD(at[9], at[60]); MULADD(at[10], at[59]); MULADD(at[11], at[58]); MULADD(at[12], at[57]); MULADD(at[13], at[56]); MULADD(at[14], at[55]); MULADD(at[15], at[54]); MULADD(at[16], at[53]); MULADD(at[17], at[52]); MULADD(at[18], at[51]); MULADD(at[19], at[50]); MULADD(at[20], at[49]); MULADD(at[21], at[48]); MULADD(at[22], at[47]); MULADD(at[23], at[46]); MULADD(at[24], at[45]); MULADD(at[25], at[44]); MULADD(at[26], at[43]); MULADD(at[27], at[42]); MULADD(at[28], at[41]); MULADD(at[29], at[40]); MULADD(at[30], at[39]); MULADD(at[31], at[38]); COMBA_STORE(C->dp[37]); /* 38 */ COMBA_FORWARD; MULADD(at[7], at[63]); MULADD(at[8], at[62]); MULADD(at[9], at[61]); MULADD(at[10], at[60]); MULADD(at[11], at[59]); MULADD(at[12], at[58]); MULADD(at[13], at[57]); MULADD(at[14], at[56]); MULADD(at[15], at[55]); MULADD(at[16], at[54]); MULADD(at[17], at[53]); MULADD(at[18], at[52]); MULADD(at[19], at[51]); MULADD(at[20], at[50]); MULADD(at[21], at[49]); MULADD(at[22], at[48]); MULADD(at[23], at[47]); MULADD(at[24], at[46]); MULADD(at[25], at[45]); MULADD(at[26], at[44]); MULADD(at[27], at[43]); MULADD(at[28], at[42]); MULADD(at[29], at[41]); MULADD(at[30], at[40]); MULADD(at[31], at[39]); COMBA_STORE(C->dp[38]); /* early out at 40 digits, 40*32==1280, or two 640 bit operands */ if (out_size <= 40) { COMBA_STORE2(C->dp[39]); C->used = 40; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; } /* 39 */ COMBA_FORWARD; MULADD(at[8], at[63]); MULADD(at[9], at[62]); MULADD(at[10], at[61]); MULADD(at[11], at[60]); MULADD(at[12], at[59]); MULADD(at[13], at[58]); MULADD(at[14], at[57]); MULADD(at[15], at[56]); MULADD(at[16], at[55]); MULADD(at[17], at[54]); MULADD(at[18], at[53]); MULADD(at[19], at[52]); MULADD(at[20], at[51]); MULADD(at[21], at[50]); MULADD(at[22], at[49]); MULADD(at[23], at[48]); MULADD(at[24], at[47]); MULADD(at[25], at[46]); MULADD(at[26], at[45]); MULADD(at[27], at[44]); MULADD(at[28], at[43]); MULADD(at[29], at[42]); MULADD(at[30], at[41]); MULADD(at[31], at[40]); COMBA_STORE(C->dp[39]); /* 40 */ COMBA_FORWARD; MULADD(at[9], at[63]); MULADD(at[10], at[62]); MULADD(at[11], at[61]); MULADD(at[12], at[60]); MULADD(at[13], at[59]); MULADD(at[14], at[58]); MULADD(at[15], at[57]); MULADD(at[16], at[56]); MULADD(at[17], at[55]); MULADD(at[18], at[54]); MULADD(at[19], at[53]); MULADD(at[20], at[52]); MULADD(at[21], at[51]); MULADD(at[22], at[50]); MULADD(at[23], at[49]); MULADD(at[24], at[48]); MULADD(at[25], at[47]); MULADD(at[26], at[46]); MULADD(at[27], at[45]); MULADD(at[28], at[44]); MULADD(at[29], at[43]); MULADD(at[30], at[42]); MULADD(at[31], at[41]); COMBA_STORE(C->dp[40]); /* 41 */ COMBA_FORWARD; MULADD(at[10], at[63]); MULADD(at[11], at[62]); MULADD(at[12], at[61]); MULADD(at[13], at[60]); MULADD(at[14], at[59]); MULADD(at[15], at[58]); MULADD(at[16], at[57]); MULADD(at[17], at[56]); MULADD(at[18], at[55]); MULADD(at[19], at[54]); MULADD(at[20], at[53]); MULADD(at[21], at[52]); MULADD(at[22], at[51]); MULADD(at[23], at[50]); MULADD(at[24], at[49]); MULADD(at[25], at[48]); MULADD(at[26], at[47]); MULADD(at[27], at[46]); MULADD(at[28], at[45]); MULADD(at[29], at[44]); MULADD(at[30], at[43]); MULADD(at[31], at[42]); COMBA_STORE(C->dp[41]); /* 42 */ COMBA_FORWARD; MULADD(at[11], at[63]); MULADD(at[12], at[62]); MULADD(at[13], at[61]); MULADD(at[14], at[60]); MULADD(at[15], at[59]); MULADD(at[16], at[58]); MULADD(at[17], at[57]); MULADD(at[18], at[56]); MULADD(at[19], at[55]); MULADD(at[20], at[54]); MULADD(at[21], at[53]); MULADD(at[22], at[52]); MULADD(at[23], at[51]); MULADD(at[24], at[50]); MULADD(at[25], at[49]); MULADD(at[26], at[48]); MULADD(at[27], at[47]); MULADD(at[28], at[46]); MULADD(at[29], at[45]); MULADD(at[30], at[44]); MULADD(at[31], at[43]); COMBA_STORE(C->dp[42]); /* 43 */ COMBA_FORWARD; MULADD(at[12], at[63]); MULADD(at[13], at[62]); MULADD(at[14], at[61]); MULADD(at[15], at[60]); MULADD(at[16], at[59]); MULADD(at[17], at[58]); MULADD(at[18], at[57]); MULADD(at[19], at[56]); MULADD(at[20], at[55]); MULADD(at[21], at[54]); MULADD(at[22], at[53]); MULADD(at[23], at[52]); MULADD(at[24], at[51]); MULADD(at[25], at[50]); MULADD(at[26], at[49]); MULADD(at[27], at[48]); MULADD(at[28], at[47]); MULADD(at[29], at[46]); MULADD(at[30], at[45]); MULADD(at[31], at[44]); COMBA_STORE(C->dp[43]); /* 44 */ COMBA_FORWARD; MULADD(at[13], at[63]); MULADD(at[14], at[62]); MULADD(at[15], at[61]); MULADD(at[16], at[60]); MULADD(at[17], at[59]); MULADD(at[18], at[58]); MULADD(at[19], at[57]); MULADD(at[20], at[56]); MULADD(at[21], at[55]); MULADD(at[22], at[54]); MULADD(at[23], at[53]); MULADD(at[24], at[52]); MULADD(at[25], at[51]); MULADD(at[26], at[50]); MULADD(at[27], at[49]); MULADD(at[28], at[48]); MULADD(at[29], at[47]); MULADD(at[30], at[46]); MULADD(at[31], at[45]); COMBA_STORE(C->dp[44]); /* 45 */ COMBA_FORWARD; MULADD(at[14], at[63]); MULADD(at[15], at[62]); MULADD(at[16], at[61]); MULADD(at[17], at[60]); MULADD(at[18], at[59]); MULADD(at[19], at[58]); MULADD(at[20], at[57]); MULADD(at[21], at[56]); MULADD(at[22], at[55]); MULADD(at[23], at[54]); MULADD(at[24], at[53]); MULADD(at[25], at[52]); MULADD(at[26], at[51]); MULADD(at[27], at[50]); MULADD(at[28], at[49]); MULADD(at[29], at[48]); MULADD(at[30], at[47]); MULADD(at[31], at[46]); COMBA_STORE(C->dp[45]); /* 46 */ COMBA_FORWARD; MULADD(at[15], at[63]); MULADD(at[16], at[62]); MULADD(at[17], at[61]); MULADD(at[18], at[60]); MULADD(at[19], at[59]); MULADD(at[20], at[58]); MULADD(at[21], at[57]); MULADD(at[22], at[56]); MULADD(at[23], at[55]); MULADD(at[24], at[54]); MULADD(at[25], at[53]); MULADD(at[26], at[52]); MULADD(at[27], at[51]); MULADD(at[28], at[50]); MULADD(at[29], at[49]); MULADD(at[30], at[48]); MULADD(at[31], at[47]); COMBA_STORE(C->dp[46]); /* early out at 48 digits, 48*32==1536, or two 768 bit operands */ if (out_size <= 48) { COMBA_STORE2(C->dp[47]); C->used = 48; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; } /* 47 */ COMBA_FORWARD; MULADD(at[16], at[63]); MULADD(at[17], at[62]); MULADD(at[18], at[61]); MULADD(at[19], at[60]); MULADD(at[20], at[59]); MULADD(at[21], at[58]); MULADD(at[22], at[57]); MULADD(at[23], at[56]); MULADD(at[24], at[55]); MULADD(at[25], at[54]); MULADD(at[26], at[53]); MULADD(at[27], at[52]); MULADD(at[28], at[51]); MULADD(at[29], at[50]); MULADD(at[30], at[49]); MULADD(at[31], at[48]); COMBA_STORE(C->dp[47]); /* 48 */ COMBA_FORWARD; MULADD(at[17], at[63]); MULADD(at[18], at[62]); MULADD(at[19], at[61]); MULADD(at[20], at[60]); MULADD(at[21], at[59]); MULADD(at[22], at[58]); MULADD(at[23], at[57]); MULADD(at[24], at[56]); MULADD(at[25], at[55]); MULADD(at[26], at[54]); MULADD(at[27], at[53]); MULADD(at[28], at[52]); MULADD(at[29], at[51]); MULADD(at[30], at[50]); MULADD(at[31], at[49]); COMBA_STORE(C->dp[48]); /* 49 */ COMBA_FORWARD; MULADD(at[18], at[63]); MULADD(at[19], at[62]); MULADD(at[20], at[61]); MULADD(at[21], at[60]); MULADD(at[22], at[59]); MULADD(at[23], at[58]); MULADD(at[24], at[57]); MULADD(at[25], at[56]); MULADD(at[26], at[55]); MULADD(at[27], at[54]); MULADD(at[28], at[53]); MULADD(at[29], at[52]); MULADD(at[30], at[51]); MULADD(at[31], at[50]); COMBA_STORE(C->dp[49]); /* 50 */ COMBA_FORWARD; MULADD(at[19], at[63]); MULADD(at[20], at[62]); MULADD(at[21], at[61]); MULADD(at[22], at[60]); MULADD(at[23], at[59]); MULADD(at[24], at[58]); MULADD(at[25], at[57]); MULADD(at[26], at[56]); MULADD(at[27], at[55]); MULADD(at[28], at[54]); MULADD(at[29], at[53]); MULADD(at[30], at[52]); MULADD(at[31], at[51]); COMBA_STORE(C->dp[50]); /* 51 */ COMBA_FORWARD; MULADD(at[20], at[63]); MULADD(at[21], at[62]); MULADD(at[22], at[61]); MULADD(at[23], at[60]); MULADD(at[24], at[59]); MULADD(at[25], at[58]); MULADD(at[26], at[57]); MULADD(at[27], at[56]); MULADD(at[28], at[55]); MULADD(at[29], at[54]); MULADD(at[30], at[53]); MULADD(at[31], at[52]); COMBA_STORE(C->dp[51]); /* 52 */ COMBA_FORWARD; MULADD(at[21], at[63]); MULADD(at[22], at[62]); MULADD(at[23], at[61]); MULADD(at[24], at[60]); MULADD(at[25], at[59]); MULADD(at[26], at[58]); MULADD(at[27], at[57]); MULADD(at[28], at[56]); MULADD(at[29], at[55]); MULADD(at[30], at[54]); MULADD(at[31], at[53]); COMBA_STORE(C->dp[52]); /* 53 */ COMBA_FORWARD; MULADD(at[22], at[63]); MULADD(at[23], at[62]); MULADD(at[24], at[61]); MULADD(at[25], at[60]); MULADD(at[26], at[59]); MULADD(at[27], at[58]); MULADD(at[28], at[57]); MULADD(at[29], at[56]); MULADD(at[30], at[55]); MULADD(at[31], at[54]); COMBA_STORE(C->dp[53]); /* 54 */ COMBA_FORWARD; MULADD(at[23], at[63]); MULADD(at[24], at[62]); MULADD(at[25], at[61]); MULADD(at[26], at[60]); MULADD(at[27], at[59]); MULADD(at[28], at[58]); MULADD(at[29], at[57]); MULADD(at[30], at[56]); MULADD(at[31], at[55]); COMBA_STORE(C->dp[54]); /* early out at 56 digits, 56*32==1792, or two 896 bit operands */ if (out_size <= 56) { COMBA_STORE2(C->dp[55]); C->used = 56; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; return; } /* 55 */ COMBA_FORWARD; MULADD(at[24], at[63]); MULADD(at[25], at[62]); MULADD(at[26], at[61]); MULADD(at[27], at[60]); MULADD(at[28], at[59]); MULADD(at[29], at[58]); MULADD(at[30], at[57]); MULADD(at[31], at[56]); COMBA_STORE(C->dp[55]); /* 56 */ COMBA_FORWARD; MULADD(at[25], at[63]); MULADD(at[26], at[62]); MULADD(at[27], at[61]); MULADD(at[28], at[60]); MULADD(at[29], at[59]); MULADD(at[30], at[58]); MULADD(at[31], at[57]); COMBA_STORE(C->dp[56]); /* 57 */ COMBA_FORWARD; MULADD(at[26], at[63]); MULADD(at[27], at[62]); MULADD(at[28], at[61]); MULADD(at[29], at[60]); MULADD(at[30], at[59]); MULADD(at[31], at[58]); COMBA_STORE(C->dp[57]); /* 58 */ COMBA_FORWARD; MULADD(at[27], at[63]); MULADD(at[28], at[62]); MULADD(at[29], at[61]); MULADD(at[30], at[60]); MULADD(at[31], at[59]); COMBA_STORE(C->dp[58]); /* 59 */ COMBA_FORWARD; MULADD(at[28], at[63]); MULADD(at[29], at[62]); MULADD(at[30], at[61]); MULADD(at[31], at[60]); COMBA_STORE(C->dp[59]); /* 60 */ COMBA_FORWARD; MULADD(at[29], at[63]); MULADD(at[30], at[62]); MULADD(at[31], at[61]); COMBA_STORE(C->dp[60]); /* 61 */ COMBA_FORWARD; MULADD(at[30], at[63]); MULADD(at[31], at[62]); COMBA_STORE(C->dp[61]); /* 62 */ COMBA_FORWARD; MULADD(at[31], at[63]); COMBA_STORE(C->dp[62]); COMBA_STORE2(C->dp[63]); C->used = 64; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; } #endif /* End: src/mul/fp_mul_comba_32.c */ /* Start: src/mul/fp_mul_comba_4.c */ #define TFM_DEFINES //#include "fp_mul_comba.c" #ifdef TFM_MUL4 void fp_mul_comba4(fp_int *A, fp_int *B, fp_int *C) { fp_digit c0, c1, c2, at[8]; memcpy(at, A->dp, 4 * sizeof(fp_digit)); memcpy(at+4, B->dp, 4 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[4]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[5]); MULADD(at[1], at[4]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[6]); MULADD(at[1], at[5]); MULADD(at[2], at[4]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[7]); MULADD(at[1], at[6]); MULADD(at[2], at[5]); MULADD(at[3], at[4]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[1], at[7]); MULADD(at[2], at[6]); MULADD(at[3], at[5]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[2], at[7]); MULADD(at[3], at[6]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[3], at[7]); COMBA_STORE(C->dp[6]); COMBA_STORE2(C->dp[7]); C->used = 8; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; } #endif /* End: src/mul/fp_mul_comba_4.c */ /* Start: src/mul/fp_mul_comba_48.c */ #define TFM_DEFINES //#include "fp_mul_comba.c" #ifdef TFM_MUL48 void fp_mul_comba48(fp_int *A, fp_int *B, fp_int *C) { fp_digit c0, c1, c2, at[96]; memcpy(at, A->dp, 48 * sizeof(fp_digit)); memcpy(at+48, B->dp, 48 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[48]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[49]); MULADD(at[1], at[48]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[50]); MULADD(at[1], at[49]); MULADD(at[2], at[48]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[51]); MULADD(at[1], at[50]); MULADD(at[2], at[49]); MULADD(at[3], at[48]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[52]); MULADD(at[1], at[51]); MULADD(at[2], at[50]); MULADD(at[3], at[49]); MULADD(at[4], at[48]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[53]); MULADD(at[1], at[52]); MULADD(at[2], at[51]); MULADD(at[3], at[50]); MULADD(at[4], at[49]); MULADD(at[5], at[48]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[54]); MULADD(at[1], at[53]); MULADD(at[2], at[52]); MULADD(at[3], at[51]); MULADD(at[4], at[50]); MULADD(at[5], at[49]); MULADD(at[6], at[48]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[55]); MULADD(at[1], at[54]); MULADD(at[2], at[53]); MULADD(at[3], at[52]); MULADD(at[4], at[51]); MULADD(at[5], at[50]); MULADD(at[6], at[49]); MULADD(at[7], at[48]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[0], at[56]); MULADD(at[1], at[55]); MULADD(at[2], at[54]); MULADD(at[3], at[53]); MULADD(at[4], at[52]); MULADD(at[5], at[51]); MULADD(at[6], at[50]); MULADD(at[7], at[49]); MULADD(at[8], at[48]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[0], at[57]); MULADD(at[1], at[56]); MULADD(at[2], at[55]); MULADD(at[3], at[54]); MULADD(at[4], at[53]); MULADD(at[5], at[52]); MULADD(at[6], at[51]); MULADD(at[7], at[50]); MULADD(at[8], at[49]); MULADD(at[9], at[48]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[0], at[58]); MULADD(at[1], at[57]); MULADD(at[2], at[56]); MULADD(at[3], at[55]); MULADD(at[4], at[54]); MULADD(at[5], at[53]); MULADD(at[6], at[52]); MULADD(at[7], at[51]); MULADD(at[8], at[50]); MULADD(at[9], at[49]); MULADD(at[10], at[48]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[0], at[59]); MULADD(at[1], at[58]); MULADD(at[2], at[57]); MULADD(at[3], at[56]); MULADD(at[4], at[55]); MULADD(at[5], at[54]); MULADD(at[6], at[53]); MULADD(at[7], at[52]); MULADD(at[8], at[51]); MULADD(at[9], at[50]); MULADD(at[10], at[49]); MULADD(at[11], at[48]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[0], at[60]); MULADD(at[1], at[59]); MULADD(at[2], at[58]); MULADD(at[3], at[57]); MULADD(at[4], at[56]); MULADD(at[5], at[55]); MULADD(at[6], at[54]); MULADD(at[7], at[53]); MULADD(at[8], at[52]); MULADD(at[9], at[51]); MULADD(at[10], at[50]); MULADD(at[11], at[49]); MULADD(at[12], at[48]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[0], at[61]); MULADD(at[1], at[60]); MULADD(at[2], at[59]); MULADD(at[3], at[58]); MULADD(at[4], at[57]); MULADD(at[5], at[56]); MULADD(at[6], at[55]); MULADD(at[7], at[54]); MULADD(at[8], at[53]); MULADD(at[9], at[52]); MULADD(at[10], at[51]); MULADD(at[11], at[50]); MULADD(at[12], at[49]); MULADD(at[13], at[48]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[0], at[62]); MULADD(at[1], at[61]); MULADD(at[2], at[60]); MULADD(at[3], at[59]); MULADD(at[4], at[58]); MULADD(at[5], at[57]); MULADD(at[6], at[56]); MULADD(at[7], at[55]); MULADD(at[8], at[54]); MULADD(at[9], at[53]); MULADD(at[10], at[52]); MULADD(at[11], at[51]); MULADD(at[12], at[50]); MULADD(at[13], at[49]); MULADD(at[14], at[48]); COMBA_STORE(C->dp[14]); /* 15 */ COMBA_FORWARD; MULADD(at[0], at[63]); MULADD(at[1], at[62]); MULADD(at[2], at[61]); MULADD(at[3], at[60]); MULADD(at[4], at[59]); MULADD(at[5], at[58]); MULADD(at[6], at[57]); MULADD(at[7], at[56]); MULADD(at[8], at[55]); MULADD(at[9], at[54]); MULADD(at[10], at[53]); MULADD(at[11], at[52]); MULADD(at[12], at[51]); MULADD(at[13], at[50]); MULADD(at[14], at[49]); MULADD(at[15], at[48]); COMBA_STORE(C->dp[15]); /* 16 */ COMBA_FORWARD; MULADD(at[0], at[64]); MULADD(at[1], at[63]); MULADD(at[2], at[62]); MULADD(at[3], at[61]); MULADD(at[4], at[60]); MULADD(at[5], at[59]); MULADD(at[6], at[58]); MULADD(at[7], at[57]); MULADD(at[8], at[56]); MULADD(at[9], at[55]); MULADD(at[10], at[54]); MULADD(at[11], at[53]); MULADD(at[12], at[52]); MULADD(at[13], at[51]); MULADD(at[14], at[50]); MULADD(at[15], at[49]); MULADD(at[16], at[48]); COMBA_STORE(C->dp[16]); /* 17 */ COMBA_FORWARD; MULADD(at[0], at[65]); MULADD(at[1], at[64]); MULADD(at[2], at[63]); MULADD(at[3], at[62]); MULADD(at[4], at[61]); MULADD(at[5], at[60]); MULADD(at[6], at[59]); MULADD(at[7], at[58]); MULADD(at[8], at[57]); MULADD(at[9], at[56]); MULADD(at[10], at[55]); MULADD(at[11], at[54]); MULADD(at[12], at[53]); MULADD(at[13], at[52]); MULADD(at[14], at[51]); MULADD(at[15], at[50]); MULADD(at[16], at[49]); MULADD(at[17], at[48]); COMBA_STORE(C->dp[17]); /* 18 */ COMBA_FORWARD; MULADD(at[0], at[66]); MULADD(at[1], at[65]); MULADD(at[2], at[64]); MULADD(at[3], at[63]); MULADD(at[4], at[62]); MULADD(at[5], at[61]); MULADD(at[6], at[60]); MULADD(at[7], at[59]); MULADD(at[8], at[58]); MULADD(at[9], at[57]); MULADD(at[10], at[56]); MULADD(at[11], at[55]); MULADD(at[12], at[54]); MULADD(at[13], at[53]); MULADD(at[14], at[52]); MULADD(at[15], at[51]); MULADD(at[16], at[50]); MULADD(at[17], at[49]); MULADD(at[18], at[48]); COMBA_STORE(C->dp[18]); /* 19 */ COMBA_FORWARD; MULADD(at[0], at[67]); MULADD(at[1], at[66]); MULADD(at[2], at[65]); MULADD(at[3], at[64]); MULADD(at[4], at[63]); MULADD(at[5], at[62]); MULADD(at[6], at[61]); MULADD(at[7], at[60]); MULADD(at[8], at[59]); MULADD(at[9], at[58]); MULADD(at[10], at[57]); MULADD(at[11], at[56]); MULADD(at[12], at[55]); MULADD(at[13], at[54]); MULADD(at[14], at[53]); MULADD(at[15], at[52]); MULADD(at[16], at[51]); MULADD(at[17], at[50]); MULADD(at[18], at[49]); MULADD(at[19], at[48]); COMBA_STORE(C->dp[19]); /* 20 */ COMBA_FORWARD; MULADD(at[0], at[68]); MULADD(at[1], at[67]); MULADD(at[2], at[66]); MULADD(at[3], at[65]); MULADD(at[4], at[64]); MULADD(at[5], at[63]); MULADD(at[6], at[62]); MULADD(at[7], at[61]); MULADD(at[8], at[60]); MULADD(at[9], at[59]); MULADD(at[10], at[58]); MULADD(at[11], at[57]); MULADD(at[12], at[56]); MULADD(at[13], at[55]); MULADD(at[14], at[54]); MULADD(at[15], at[53]); MULADD(at[16], at[52]); MULADD(at[17], at[51]); MULADD(at[18], at[50]); MULADD(at[19], at[49]); MULADD(at[20], at[48]); COMBA_STORE(C->dp[20]); /* 21 */ COMBA_FORWARD; MULADD(at[0], at[69]); MULADD(at[1], at[68]); MULADD(at[2], at[67]); MULADD(at[3], at[66]); MULADD(at[4], at[65]); MULADD(at[5], at[64]); MULADD(at[6], at[63]); MULADD(at[7], at[62]); MULADD(at[8], at[61]); MULADD(at[9], at[60]); MULADD(at[10], at[59]); MULADD(at[11], at[58]); MULADD(at[12], at[57]); MULADD(at[13], at[56]); MULADD(at[14], at[55]); MULADD(at[15], at[54]); MULADD(at[16], at[53]); MULADD(at[17], at[52]); MULADD(at[18], at[51]); MULADD(at[19], at[50]); MULADD(at[20], at[49]); MULADD(at[21], at[48]); COMBA_STORE(C->dp[21]); /* 22 */ COMBA_FORWARD; MULADD(at[0], at[70]); MULADD(at[1], at[69]); MULADD(at[2], at[68]); MULADD(at[3], at[67]); MULADD(at[4], at[66]); MULADD(at[5], at[65]); MULADD(at[6], at[64]); MULADD(at[7], at[63]); MULADD(at[8], at[62]); MULADD(at[9], at[61]); MULADD(at[10], at[60]); MULADD(at[11], at[59]); MULADD(at[12], at[58]); MULADD(at[13], at[57]); MULADD(at[14], at[56]); MULADD(at[15], at[55]); MULADD(at[16], at[54]); MULADD(at[17], at[53]); MULADD(at[18], at[52]); MULADD(at[19], at[51]); MULADD(at[20], at[50]); MULADD(at[21], at[49]); MULADD(at[22], at[48]); COMBA_STORE(C->dp[22]); /* 23 */ COMBA_FORWARD; MULADD(at[0], at[71]); MULADD(at[1], at[70]); MULADD(at[2], at[69]); MULADD(at[3], at[68]); MULADD(at[4], at[67]); MULADD(at[5], at[66]); MULADD(at[6], at[65]); MULADD(at[7], at[64]); MULADD(at[8], at[63]); MULADD(at[9], at[62]); MULADD(at[10], at[61]); MULADD(at[11], at[60]); MULADD(at[12], at[59]); MULADD(at[13], at[58]); MULADD(at[14], at[57]); MULADD(at[15], at[56]); MULADD(at[16], at[55]); MULADD(at[17], at[54]); MULADD(at[18], at[53]); MULADD(at[19], at[52]); MULADD(at[20], at[51]); MULADD(at[21], at[50]); MULADD(at[22], at[49]); MULADD(at[23], at[48]); COMBA_STORE(C->dp[23]); /* 24 */ COMBA_FORWARD; MULADD(at[0], at[72]); MULADD(at[1], at[71]); MULADD(at[2], at[70]); MULADD(at[3], at[69]); MULADD(at[4], at[68]); MULADD(at[5], at[67]); MULADD(at[6], at[66]); MULADD(at[7], at[65]); MULADD(at[8], at[64]); MULADD(at[9], at[63]); MULADD(at[10], at[62]); MULADD(at[11], at[61]); MULADD(at[12], at[60]); MULADD(at[13], at[59]); MULADD(at[14], at[58]); MULADD(at[15], at[57]); MULADD(at[16], at[56]); MULADD(at[17], at[55]); MULADD(at[18], at[54]); MULADD(at[19], at[53]); MULADD(at[20], at[52]); MULADD(at[21], at[51]); MULADD(at[22], at[50]); MULADD(at[23], at[49]); MULADD(at[24], at[48]); COMBA_STORE(C->dp[24]); /* 25 */ COMBA_FORWARD; MULADD(at[0], at[73]); MULADD(at[1], at[72]); MULADD(at[2], at[71]); MULADD(at[3], at[70]); MULADD(at[4], at[69]); MULADD(at[5], at[68]); MULADD(at[6], at[67]); MULADD(at[7], at[66]); MULADD(at[8], at[65]); MULADD(at[9], at[64]); MULADD(at[10], at[63]); MULADD(at[11], at[62]); MULADD(at[12], at[61]); MULADD(at[13], at[60]); MULADD(at[14], at[59]); MULADD(at[15], at[58]); MULADD(at[16], at[57]); MULADD(at[17], at[56]); MULADD(at[18], at[55]); MULADD(at[19], at[54]); MULADD(at[20], at[53]); MULADD(at[21], at[52]); MULADD(at[22], at[51]); MULADD(at[23], at[50]); MULADD(at[24], at[49]); MULADD(at[25], at[48]); COMBA_STORE(C->dp[25]); /* 26 */ COMBA_FORWARD; MULADD(at[0], at[74]); MULADD(at[1], at[73]); MULADD(at[2], at[72]); MULADD(at[3], at[71]); MULADD(at[4], at[70]); MULADD(at[5], at[69]); MULADD(at[6], at[68]); MULADD(at[7], at[67]); MULADD(at[8], at[66]); MULADD(at[9], at[65]); MULADD(at[10], at[64]); MULADD(at[11], at[63]); MULADD(at[12], at[62]); MULADD(at[13], at[61]); MULADD(at[14], at[60]); MULADD(at[15], at[59]); MULADD(at[16], at[58]); MULADD(at[17], at[57]); MULADD(at[18], at[56]); MULADD(at[19], at[55]); MULADD(at[20], at[54]); MULADD(at[21], at[53]); MULADD(at[22], at[52]); MULADD(at[23], at[51]); MULADD(at[24], at[50]); MULADD(at[25], at[49]); MULADD(at[26], at[48]); COMBA_STORE(C->dp[26]); /* 27 */ COMBA_FORWARD; MULADD(at[0], at[75]); MULADD(at[1], at[74]); MULADD(at[2], at[73]); MULADD(at[3], at[72]); MULADD(at[4], at[71]); MULADD(at[5], at[70]); MULADD(at[6], at[69]); MULADD(at[7], at[68]); MULADD(at[8], at[67]); MULADD(at[9], at[66]); MULADD(at[10], at[65]); MULADD(at[11], at[64]); MULADD(at[12], at[63]); MULADD(at[13], at[62]); MULADD(at[14], at[61]); MULADD(at[15], at[60]); MULADD(at[16], at[59]); MULADD(at[17], at[58]); MULADD(at[18], at[57]); MULADD(at[19], at[56]); MULADD(at[20], at[55]); MULADD(at[21], at[54]); MULADD(at[22], at[53]); MULADD(at[23], at[52]); MULADD(at[24], at[51]); MULADD(at[25], at[50]); MULADD(at[26], at[49]); MULADD(at[27], at[48]); COMBA_STORE(C->dp[27]); /* 28 */ COMBA_FORWARD; MULADD(at[0], at[76]); MULADD(at[1], at[75]); MULADD(at[2], at[74]); MULADD(at[3], at[73]); MULADD(at[4], at[72]); MULADD(at[5], at[71]); MULADD(at[6], at[70]); MULADD(at[7], at[69]); MULADD(at[8], at[68]); MULADD(at[9], at[67]); MULADD(at[10], at[66]); MULADD(at[11], at[65]); MULADD(at[12], at[64]); MULADD(at[13], at[63]); MULADD(at[14], at[62]); MULADD(at[15], at[61]); MULADD(at[16], at[60]); MULADD(at[17], at[59]); MULADD(at[18], at[58]); MULADD(at[19], at[57]); MULADD(at[20], at[56]); MULADD(at[21], at[55]); MULADD(at[22], at[54]); MULADD(at[23], at[53]); MULADD(at[24], at[52]); MULADD(at[25], at[51]); MULADD(at[26], at[50]); MULADD(at[27], at[49]); MULADD(at[28], at[48]); COMBA_STORE(C->dp[28]); /* 29 */ COMBA_FORWARD; MULADD(at[0], at[77]); MULADD(at[1], at[76]); MULADD(at[2], at[75]); MULADD(at[3], at[74]); MULADD(at[4], at[73]); MULADD(at[5], at[72]); MULADD(at[6], at[71]); MULADD(at[7], at[70]); MULADD(at[8], at[69]); MULADD(at[9], at[68]); MULADD(at[10], at[67]); MULADD(at[11], at[66]); MULADD(at[12], at[65]); MULADD(at[13], at[64]); MULADD(at[14], at[63]); MULADD(at[15], at[62]); MULADD(at[16], at[61]); MULADD(at[17], at[60]); MULADD(at[18], at[59]); MULADD(at[19], at[58]); MULADD(at[20], at[57]); MULADD(at[21], at[56]); MULADD(at[22], at[55]); MULADD(at[23], at[54]); MULADD(at[24], at[53]); MULADD(at[25], at[52]); MULADD(at[26], at[51]); MULADD(at[27], at[50]); MULADD(at[28], at[49]); MULADD(at[29], at[48]); COMBA_STORE(C->dp[29]); /* 30 */ COMBA_FORWARD; MULADD(at[0], at[78]); MULADD(at[1], at[77]); MULADD(at[2], at[76]); MULADD(at[3], at[75]); MULADD(at[4], at[74]); MULADD(at[5], at[73]); MULADD(at[6], at[72]); MULADD(at[7], at[71]); MULADD(at[8], at[70]); MULADD(at[9], at[69]); MULADD(at[10], at[68]); MULADD(at[11], at[67]); MULADD(at[12], at[66]); MULADD(at[13], at[65]); MULADD(at[14], at[64]); MULADD(at[15], at[63]); MULADD(at[16], at[62]); MULADD(at[17], at[61]); MULADD(at[18], at[60]); MULADD(at[19], at[59]); MULADD(at[20], at[58]); MULADD(at[21], at[57]); MULADD(at[22], at[56]); MULADD(at[23], at[55]); MULADD(at[24], at[54]); MULADD(at[25], at[53]); MULADD(at[26], at[52]); MULADD(at[27], at[51]); MULADD(at[28], at[50]); MULADD(at[29], at[49]); MULADD(at[30], at[48]); COMBA_STORE(C->dp[30]); /* 31 */ COMBA_FORWARD; MULADD(at[0], at[79]); MULADD(at[1], at[78]); MULADD(at[2], at[77]); MULADD(at[3], at[76]); MULADD(at[4], at[75]); MULADD(at[5], at[74]); MULADD(at[6], at[73]); MULADD(at[7], at[72]); MULADD(at[8], at[71]); MULADD(at[9], at[70]); MULADD(at[10], at[69]); MULADD(at[11], at[68]); MULADD(at[12], at[67]); MULADD(at[13], at[66]); MULADD(at[14], at[65]); MULADD(at[15], at[64]); MULADD(at[16], at[63]); MULADD(at[17], at[62]); MULADD(at[18], at[61]); MULADD(at[19], at[60]); MULADD(at[20], at[59]); MULADD(at[21], at[58]); MULADD(at[22], at[57]); MULADD(at[23], at[56]); MULADD(at[24], at[55]); MULADD(at[25], at[54]); MULADD(at[26], at[53]); MULADD(at[27], at[52]); MULADD(at[28], at[51]); MULADD(at[29], at[50]); MULADD(at[30], at[49]); MULADD(at[31], at[48]); COMBA_STORE(C->dp[31]); /* 32 */ COMBA_FORWARD; MULADD(at[0], at[80]); MULADD(at[1], at[79]); MULADD(at[2], at[78]); MULADD(at[3], at[77]); MULADD(at[4], at[76]); MULADD(at[5], at[75]); MULADD(at[6], at[74]); MULADD(at[7], at[73]); MULADD(at[8], at[72]); MULADD(at[9], at[71]); MULADD(at[10], at[70]); MULADD(at[11], at[69]); MULADD(at[12], at[68]); MULADD(at[13], at[67]); MULADD(at[14], at[66]); MULADD(at[15], at[65]); MULADD(at[16], at[64]); MULADD(at[17], at[63]); MULADD(at[18], at[62]); MULADD(at[19], at[61]); MULADD(at[20], at[60]); MULADD(at[21], at[59]); MULADD(at[22], at[58]); MULADD(at[23], at[57]); MULADD(at[24], at[56]); MULADD(at[25], at[55]); MULADD(at[26], at[54]); MULADD(at[27], at[53]); MULADD(at[28], at[52]); MULADD(at[29], at[51]); MULADD(at[30], at[50]); MULADD(at[31], at[49]); MULADD(at[32], at[48]); COMBA_STORE(C->dp[32]); /* 33 */ COMBA_FORWARD; MULADD(at[0], at[81]); MULADD(at[1], at[80]); MULADD(at[2], at[79]); MULADD(at[3], at[78]); MULADD(at[4], at[77]); MULADD(at[5], at[76]); MULADD(at[6], at[75]); MULADD(at[7], at[74]); MULADD(at[8], at[73]); MULADD(at[9], at[72]); MULADD(at[10], at[71]); MULADD(at[11], at[70]); MULADD(at[12], at[69]); MULADD(at[13], at[68]); MULADD(at[14], at[67]); MULADD(at[15], at[66]); MULADD(at[16], at[65]); MULADD(at[17], at[64]); MULADD(at[18], at[63]); MULADD(at[19], at[62]); MULADD(at[20], at[61]); MULADD(at[21], at[60]); MULADD(at[22], at[59]); MULADD(at[23], at[58]); MULADD(at[24], at[57]); MULADD(at[25], at[56]); MULADD(at[26], at[55]); MULADD(at[27], at[54]); MULADD(at[28], at[53]); MULADD(at[29], at[52]); MULADD(at[30], at[51]); MULADD(at[31], at[50]); MULADD(at[32], at[49]); MULADD(at[33], at[48]); COMBA_STORE(C->dp[33]); /* 34 */ COMBA_FORWARD; MULADD(at[0], at[82]); MULADD(at[1], at[81]); MULADD(at[2], at[80]); MULADD(at[3], at[79]); MULADD(at[4], at[78]); MULADD(at[5], at[77]); MULADD(at[6], at[76]); MULADD(at[7], at[75]); MULADD(at[8], at[74]); MULADD(at[9], at[73]); MULADD(at[10], at[72]); MULADD(at[11], at[71]); MULADD(at[12], at[70]); MULADD(at[13], at[69]); MULADD(at[14], at[68]); MULADD(at[15], at[67]); MULADD(at[16], at[66]); MULADD(at[17], at[65]); MULADD(at[18], at[64]); MULADD(at[19], at[63]); MULADD(at[20], at[62]); MULADD(at[21], at[61]); MULADD(at[22], at[60]); MULADD(at[23], at[59]); MULADD(at[24], at[58]); MULADD(at[25], at[57]); MULADD(at[26], at[56]); MULADD(at[27], at[55]); MULADD(at[28], at[54]); MULADD(at[29], at[53]); MULADD(at[30], at[52]); MULADD(at[31], at[51]); MULADD(at[32], at[50]); MULADD(at[33], at[49]); MULADD(at[34], at[48]); COMBA_STORE(C->dp[34]); /* 35 */ COMBA_FORWARD; MULADD(at[0], at[83]); MULADD(at[1], at[82]); MULADD(at[2], at[81]); MULADD(at[3], at[80]); MULADD(at[4], at[79]); MULADD(at[5], at[78]); MULADD(at[6], at[77]); MULADD(at[7], at[76]); MULADD(at[8], at[75]); MULADD(at[9], at[74]); MULADD(at[10], at[73]); MULADD(at[11], at[72]); MULADD(at[12], at[71]); MULADD(at[13], at[70]); MULADD(at[14], at[69]); MULADD(at[15], at[68]); MULADD(at[16], at[67]); MULADD(at[17], at[66]); MULADD(at[18], at[65]); MULADD(at[19], at[64]); MULADD(at[20], at[63]); MULADD(at[21], at[62]); MULADD(at[22], at[61]); MULADD(at[23], at[60]); MULADD(at[24], at[59]); MULADD(at[25], at[58]); MULADD(at[26], at[57]); MULADD(at[27], at[56]); MULADD(at[28], at[55]); MULADD(at[29], at[54]); MULADD(at[30], at[53]); MULADD(at[31], at[52]); MULADD(at[32], at[51]); MULADD(at[33], at[50]); MULADD(at[34], at[49]); MULADD(at[35], at[48]); COMBA_STORE(C->dp[35]); /* 36 */ COMBA_FORWARD; MULADD(at[0], at[84]); MULADD(at[1], at[83]); MULADD(at[2], at[82]); MULADD(at[3], at[81]); MULADD(at[4], at[80]); MULADD(at[5], at[79]); MULADD(at[6], at[78]); MULADD(at[7], at[77]); MULADD(at[8], at[76]); MULADD(at[9], at[75]); MULADD(at[10], at[74]); MULADD(at[11], at[73]); MULADD(at[12], at[72]); MULADD(at[13], at[71]); MULADD(at[14], at[70]); MULADD(at[15], at[69]); MULADD(at[16], at[68]); MULADD(at[17], at[67]); MULADD(at[18], at[66]); MULADD(at[19], at[65]); MULADD(at[20], at[64]); MULADD(at[21], at[63]); MULADD(at[22], at[62]); MULADD(at[23], at[61]); MULADD(at[24], at[60]); MULADD(at[25], at[59]); MULADD(at[26], at[58]); MULADD(at[27], at[57]); MULADD(at[28], at[56]); MULADD(at[29], at[55]); MULADD(at[30], at[54]); MULADD(at[31], at[53]); MULADD(at[32], at[52]); MULADD(at[33], at[51]); MULADD(at[34], at[50]); MULADD(at[35], at[49]); MULADD(at[36], at[48]); COMBA_STORE(C->dp[36]); /* 37 */ COMBA_FORWARD; MULADD(at[0], at[85]); MULADD(at[1], at[84]); MULADD(at[2], at[83]); MULADD(at[3], at[82]); MULADD(at[4], at[81]); MULADD(at[5], at[80]); MULADD(at[6], at[79]); MULADD(at[7], at[78]); MULADD(at[8], at[77]); MULADD(at[9], at[76]); MULADD(at[10], at[75]); MULADD(at[11], at[74]); MULADD(at[12], at[73]); MULADD(at[13], at[72]); MULADD(at[14], at[71]); MULADD(at[15], at[70]); MULADD(at[16], at[69]); MULADD(at[17], at[68]); MULADD(at[18], at[67]); MULADD(at[19], at[66]); MULADD(at[20], at[65]); MULADD(at[21], at[64]); MULADD(at[22], at[63]); MULADD(at[23], at[62]); MULADD(at[24], at[61]); MULADD(at[25], at[60]); MULADD(at[26], at[59]); MULADD(at[27], at[58]); MULADD(at[28], at[57]); MULADD(at[29], at[56]); MULADD(at[30], at[55]); MULADD(at[31], at[54]); MULADD(at[32], at[53]); MULADD(at[33], at[52]); MULADD(at[34], at[51]); MULADD(at[35], at[50]); MULADD(at[36], at[49]); MULADD(at[37], at[48]); COMBA_STORE(C->dp[37]); /* 38 */ COMBA_FORWARD; MULADD(at[0], at[86]); MULADD(at[1], at[85]); MULADD(at[2], at[84]); MULADD(at[3], at[83]); MULADD(at[4], at[82]); MULADD(at[5], at[81]); MULADD(at[6], at[80]); MULADD(at[7], at[79]); MULADD(at[8], at[78]); MULADD(at[9], at[77]); MULADD(at[10], at[76]); MULADD(at[11], at[75]); MULADD(at[12], at[74]); MULADD(at[13], at[73]); MULADD(at[14], at[72]); MULADD(at[15], at[71]); MULADD(at[16], at[70]); MULADD(at[17], at[69]); MULADD(at[18], at[68]); MULADD(at[19], at[67]); MULADD(at[20], at[66]); MULADD(at[21], at[65]); MULADD(at[22], at[64]); MULADD(at[23], at[63]); MULADD(at[24], at[62]); MULADD(at[25], at[61]); MULADD(at[26], at[60]); MULADD(at[27], at[59]); MULADD(at[28], at[58]); MULADD(at[29], at[57]); MULADD(at[30], at[56]); MULADD(at[31], at[55]); MULADD(at[32], at[54]); MULADD(at[33], at[53]); MULADD(at[34], at[52]); MULADD(at[35], at[51]); MULADD(at[36], at[50]); MULADD(at[37], at[49]); MULADD(at[38], at[48]); COMBA_STORE(C->dp[38]); /* 39 */ COMBA_FORWARD; MULADD(at[0], at[87]); MULADD(at[1], at[86]); MULADD(at[2], at[85]); MULADD(at[3], at[84]); MULADD(at[4], at[83]); MULADD(at[5], at[82]); MULADD(at[6], at[81]); MULADD(at[7], at[80]); MULADD(at[8], at[79]); MULADD(at[9], at[78]); MULADD(at[10], at[77]); MULADD(at[11], at[76]); MULADD(at[12], at[75]); MULADD(at[13], at[74]); MULADD(at[14], at[73]); MULADD(at[15], at[72]); MULADD(at[16], at[71]); MULADD(at[17], at[70]); MULADD(at[18], at[69]); MULADD(at[19], at[68]); MULADD(at[20], at[67]); MULADD(at[21], at[66]); MULADD(at[22], at[65]); MULADD(at[23], at[64]); MULADD(at[24], at[63]); MULADD(at[25], at[62]); MULADD(at[26], at[61]); MULADD(at[27], at[60]); MULADD(at[28], at[59]); MULADD(at[29], at[58]); MULADD(at[30], at[57]); MULADD(at[31], at[56]); MULADD(at[32], at[55]); MULADD(at[33], at[54]); MULADD(at[34], at[53]); MULADD(at[35], at[52]); MULADD(at[36], at[51]); MULADD(at[37], at[50]); MULADD(at[38], at[49]); MULADD(at[39], at[48]); COMBA_STORE(C->dp[39]); /* 40 */ COMBA_FORWARD; MULADD(at[0], at[88]); MULADD(at[1], at[87]); MULADD(at[2], at[86]); MULADD(at[3], at[85]); MULADD(at[4], at[84]); MULADD(at[5], at[83]); MULADD(at[6], at[82]); MULADD(at[7], at[81]); MULADD(at[8], at[80]); MULADD(at[9], at[79]); MULADD(at[10], at[78]); MULADD(at[11], at[77]); MULADD(at[12], at[76]); MULADD(at[13], at[75]); MULADD(at[14], at[74]); MULADD(at[15], at[73]); MULADD(at[16], at[72]); MULADD(at[17], at[71]); MULADD(at[18], at[70]); MULADD(at[19], at[69]); MULADD(at[20], at[68]); MULADD(at[21], at[67]); MULADD(at[22], at[66]); MULADD(at[23], at[65]); MULADD(at[24], at[64]); MULADD(at[25], at[63]); MULADD(at[26], at[62]); MULADD(at[27], at[61]); MULADD(at[28], at[60]); MULADD(at[29], at[59]); MULADD(at[30], at[58]); MULADD(at[31], at[57]); MULADD(at[32], at[56]); MULADD(at[33], at[55]); MULADD(at[34], at[54]); MULADD(at[35], at[53]); MULADD(at[36], at[52]); MULADD(at[37], at[51]); MULADD(at[38], at[50]); MULADD(at[39], at[49]); MULADD(at[40], at[48]); COMBA_STORE(C->dp[40]); /* 41 */ COMBA_FORWARD; MULADD(at[0], at[89]); MULADD(at[1], at[88]); MULADD(at[2], at[87]); MULADD(at[3], at[86]); MULADD(at[4], at[85]); MULADD(at[5], at[84]); MULADD(at[6], at[83]); MULADD(at[7], at[82]); MULADD(at[8], at[81]); MULADD(at[9], at[80]); MULADD(at[10], at[79]); MULADD(at[11], at[78]); MULADD(at[12], at[77]); MULADD(at[13], at[76]); MULADD(at[14], at[75]); MULADD(at[15], at[74]); MULADD(at[16], at[73]); MULADD(at[17], at[72]); MULADD(at[18], at[71]); MULADD(at[19], at[70]); MULADD(at[20], at[69]); MULADD(at[21], at[68]); MULADD(at[22], at[67]); MULADD(at[23], at[66]); MULADD(at[24], at[65]); MULADD(at[25], at[64]); MULADD(at[26], at[63]); MULADD(at[27], at[62]); MULADD(at[28], at[61]); MULADD(at[29], at[60]); MULADD(at[30], at[59]); MULADD(at[31], at[58]); MULADD(at[32], at[57]); MULADD(at[33], at[56]); MULADD(at[34], at[55]); MULADD(at[35], at[54]); MULADD(at[36], at[53]); MULADD(at[37], at[52]); MULADD(at[38], at[51]); MULADD(at[39], at[50]); MULADD(at[40], at[49]); MULADD(at[41], at[48]); COMBA_STORE(C->dp[41]); /* 42 */ COMBA_FORWARD; MULADD(at[0], at[90]); MULADD(at[1], at[89]); MULADD(at[2], at[88]); MULADD(at[3], at[87]); MULADD(at[4], at[86]); MULADD(at[5], at[85]); MULADD(at[6], at[84]); MULADD(at[7], at[83]); MULADD(at[8], at[82]); MULADD(at[9], at[81]); MULADD(at[10], at[80]); MULADD(at[11], at[79]); MULADD(at[12], at[78]); MULADD(at[13], at[77]); MULADD(at[14], at[76]); MULADD(at[15], at[75]); MULADD(at[16], at[74]); MULADD(at[17], at[73]); MULADD(at[18], at[72]); MULADD(at[19], at[71]); MULADD(at[20], at[70]); MULADD(at[21], at[69]); MULADD(at[22], at[68]); MULADD(at[23], at[67]); MULADD(at[24], at[66]); MULADD(at[25], at[65]); MULADD(at[26], at[64]); MULADD(at[27], at[63]); MULADD(at[28], at[62]); MULADD(at[29], at[61]); MULADD(at[30], at[60]); MULADD(at[31], at[59]); MULADD(at[32], at[58]); MULADD(at[33], at[57]); MULADD(at[34], at[56]); MULADD(at[35], at[55]); MULADD(at[36], at[54]); MULADD(at[37], at[53]); MULADD(at[38], at[52]); MULADD(at[39], at[51]); MULADD(at[40], at[50]); MULADD(at[41], at[49]); MULADD(at[42], at[48]); COMBA_STORE(C->dp[42]); /* 43 */ COMBA_FORWARD; MULADD(at[0], at[91]); MULADD(at[1], at[90]); MULADD(at[2], at[89]); MULADD(at[3], at[88]); MULADD(at[4], at[87]); MULADD(at[5], at[86]); MULADD(at[6], at[85]); MULADD(at[7], at[84]); MULADD(at[8], at[83]); MULADD(at[9], at[82]); MULADD(at[10], at[81]); MULADD(at[11], at[80]); MULADD(at[12], at[79]); MULADD(at[13], at[78]); MULADD(at[14], at[77]); MULADD(at[15], at[76]); MULADD(at[16], at[75]); MULADD(at[17], at[74]); MULADD(at[18], at[73]); MULADD(at[19], at[72]); MULADD(at[20], at[71]); MULADD(at[21], at[70]); MULADD(at[22], at[69]); MULADD(at[23], at[68]); MULADD(at[24], at[67]); MULADD(at[25], at[66]); MULADD(at[26], at[65]); MULADD(at[27], at[64]); MULADD(at[28], at[63]); MULADD(at[29], at[62]); MULADD(at[30], at[61]); MULADD(at[31], at[60]); MULADD(at[32], at[59]); MULADD(at[33], at[58]); MULADD(at[34], at[57]); MULADD(at[35], at[56]); MULADD(at[36], at[55]); MULADD(at[37], at[54]); MULADD(at[38], at[53]); MULADD(at[39], at[52]); MULADD(at[40], at[51]); MULADD(at[41], at[50]); MULADD(at[42], at[49]); MULADD(at[43], at[48]); COMBA_STORE(C->dp[43]); /* 44 */ COMBA_FORWARD; MULADD(at[0], at[92]); MULADD(at[1], at[91]); MULADD(at[2], at[90]); MULADD(at[3], at[89]); MULADD(at[4], at[88]); MULADD(at[5], at[87]); MULADD(at[6], at[86]); MULADD(at[7], at[85]); MULADD(at[8], at[84]); MULADD(at[9], at[83]); MULADD(at[10], at[82]); MULADD(at[11], at[81]); MULADD(at[12], at[80]); MULADD(at[13], at[79]); MULADD(at[14], at[78]); MULADD(at[15], at[77]); MULADD(at[16], at[76]); MULADD(at[17], at[75]); MULADD(at[18], at[74]); MULADD(at[19], at[73]); MULADD(at[20], at[72]); MULADD(at[21], at[71]); MULADD(at[22], at[70]); MULADD(at[23], at[69]); MULADD(at[24], at[68]); MULADD(at[25], at[67]); MULADD(at[26], at[66]); MULADD(at[27], at[65]); MULADD(at[28], at[64]); MULADD(at[29], at[63]); MULADD(at[30], at[62]); MULADD(at[31], at[61]); MULADD(at[32], at[60]); MULADD(at[33], at[59]); MULADD(at[34], at[58]); MULADD(at[35], at[57]); MULADD(at[36], at[56]); MULADD(at[37], at[55]); MULADD(at[38], at[54]); MULADD(at[39], at[53]); MULADD(at[40], at[52]); MULADD(at[41], at[51]); MULADD(at[42], at[50]); MULADD(at[43], at[49]); MULADD(at[44], at[48]); COMBA_STORE(C->dp[44]); /* 45 */ COMBA_FORWARD; MULADD(at[0], at[93]); MULADD(at[1], at[92]); MULADD(at[2], at[91]); MULADD(at[3], at[90]); MULADD(at[4], at[89]); MULADD(at[5], at[88]); MULADD(at[6], at[87]); MULADD(at[7], at[86]); MULADD(at[8], at[85]); MULADD(at[9], at[84]); MULADD(at[10], at[83]); MULADD(at[11], at[82]); MULADD(at[12], at[81]); MULADD(at[13], at[80]); MULADD(at[14], at[79]); MULADD(at[15], at[78]); MULADD(at[16], at[77]); MULADD(at[17], at[76]); MULADD(at[18], at[75]); MULADD(at[19], at[74]); MULADD(at[20], at[73]); MULADD(at[21], at[72]); MULADD(at[22], at[71]); MULADD(at[23], at[70]); MULADD(at[24], at[69]); MULADD(at[25], at[68]); MULADD(at[26], at[67]); MULADD(at[27], at[66]); MULADD(at[28], at[65]); MULADD(at[29], at[64]); MULADD(at[30], at[63]); MULADD(at[31], at[62]); MULADD(at[32], at[61]); MULADD(at[33], at[60]); MULADD(at[34], at[59]); MULADD(at[35], at[58]); MULADD(at[36], at[57]); MULADD(at[37], at[56]); MULADD(at[38], at[55]); MULADD(at[39], at[54]); MULADD(at[40], at[53]); MULADD(at[41], at[52]); MULADD(at[42], at[51]); MULADD(at[43], at[50]); MULADD(at[44], at[49]); MULADD(at[45], at[48]); COMBA_STORE(C->dp[45]); /* 46 */ COMBA_FORWARD; MULADD(at[0], at[94]); MULADD(at[1], at[93]); MULADD(at[2], at[92]); MULADD(at[3], at[91]); MULADD(at[4], at[90]); MULADD(at[5], at[89]); MULADD(at[6], at[88]); MULADD(at[7], at[87]); MULADD(at[8], at[86]); MULADD(at[9], at[85]); MULADD(at[10], at[84]); MULADD(at[11], at[83]); MULADD(at[12], at[82]); MULADD(at[13], at[81]); MULADD(at[14], at[80]); MULADD(at[15], at[79]); MULADD(at[16], at[78]); MULADD(at[17], at[77]); MULADD(at[18], at[76]); MULADD(at[19], at[75]); MULADD(at[20], at[74]); MULADD(at[21], at[73]); MULADD(at[22], at[72]); MULADD(at[23], at[71]); MULADD(at[24], at[70]); MULADD(at[25], at[69]); MULADD(at[26], at[68]); MULADD(at[27], at[67]); MULADD(at[28], at[66]); MULADD(at[29], at[65]); MULADD(at[30], at[64]); MULADD(at[31], at[63]); MULADD(at[32], at[62]); MULADD(at[33], at[61]); MULADD(at[34], at[60]); MULADD(at[35], at[59]); MULADD(at[36], at[58]); MULADD(at[37], at[57]); MULADD(at[38], at[56]); MULADD(at[39], at[55]); MULADD(at[40], at[54]); MULADD(at[41], at[53]); MULADD(at[42], at[52]); MULADD(at[43], at[51]); MULADD(at[44], at[50]); MULADD(at[45], at[49]); MULADD(at[46], at[48]); COMBA_STORE(C->dp[46]); /* 47 */ COMBA_FORWARD; MULADD(at[0], at[95]); MULADD(at[1], at[94]); MULADD(at[2], at[93]); MULADD(at[3], at[92]); MULADD(at[4], at[91]); MULADD(at[5], at[90]); MULADD(at[6], at[89]); MULADD(at[7], at[88]); MULADD(at[8], at[87]); MULADD(at[9], at[86]); MULADD(at[10], at[85]); MULADD(at[11], at[84]); MULADD(at[12], at[83]); MULADD(at[13], at[82]); MULADD(at[14], at[81]); MULADD(at[15], at[80]); MULADD(at[16], at[79]); MULADD(at[17], at[78]); MULADD(at[18], at[77]); MULADD(at[19], at[76]); MULADD(at[20], at[75]); MULADD(at[21], at[74]); MULADD(at[22], at[73]); MULADD(at[23], at[72]); MULADD(at[24], at[71]); MULADD(at[25], at[70]); MULADD(at[26], at[69]); MULADD(at[27], at[68]); MULADD(at[28], at[67]); MULADD(at[29], at[66]); MULADD(at[30], at[65]); MULADD(at[31], at[64]); MULADD(at[32], at[63]); MULADD(at[33], at[62]); MULADD(at[34], at[61]); MULADD(at[35], at[60]); MULADD(at[36], at[59]); MULADD(at[37], at[58]); MULADD(at[38], at[57]); MULADD(at[39], at[56]); MULADD(at[40], at[55]); MULADD(at[41], at[54]); MULADD(at[42], at[53]); MULADD(at[43], at[52]); MULADD(at[44], at[51]); MULADD(at[45], at[50]); MULADD(at[46], at[49]); MULADD(at[47], at[48]); COMBA_STORE(C->dp[47]); /* 48 */ COMBA_FORWARD; MULADD(at[1], at[95]); MULADD(at[2], at[94]); MULADD(at[3], at[93]); MULADD(at[4], at[92]); MULADD(at[5], at[91]); MULADD(at[6], at[90]); MULADD(at[7], at[89]); MULADD(at[8], at[88]); MULADD(at[9], at[87]); MULADD(at[10], at[86]); MULADD(at[11], at[85]); MULADD(at[12], at[84]); MULADD(at[13], at[83]); MULADD(at[14], at[82]); MULADD(at[15], at[81]); MULADD(at[16], at[80]); MULADD(at[17], at[79]); MULADD(at[18], at[78]); MULADD(at[19], at[77]); MULADD(at[20], at[76]); MULADD(at[21], at[75]); MULADD(at[22], at[74]); MULADD(at[23], at[73]); MULADD(at[24], at[72]); MULADD(at[25], at[71]); MULADD(at[26], at[70]); MULADD(at[27], at[69]); MULADD(at[28], at[68]); MULADD(at[29], at[67]); MULADD(at[30], at[66]); MULADD(at[31], at[65]); MULADD(at[32], at[64]); MULADD(at[33], at[63]); MULADD(at[34], at[62]); MULADD(at[35], at[61]); MULADD(at[36], at[60]); MULADD(at[37], at[59]); MULADD(at[38], at[58]); MULADD(at[39], at[57]); MULADD(at[40], at[56]); MULADD(at[41], at[55]); MULADD(at[42], at[54]); MULADD(at[43], at[53]); MULADD(at[44], at[52]); MULADD(at[45], at[51]); MULADD(at[46], at[50]); MULADD(at[47], at[49]); COMBA_STORE(C->dp[48]); /* 49 */ COMBA_FORWARD; MULADD(at[2], at[95]); MULADD(at[3], at[94]); MULADD(at[4], at[93]); MULADD(at[5], at[92]); MULADD(at[6], at[91]); MULADD(at[7], at[90]); MULADD(at[8], at[89]); MULADD(at[9], at[88]); MULADD(at[10], at[87]); MULADD(at[11], at[86]); MULADD(at[12], at[85]); MULADD(at[13], at[84]); MULADD(at[14], at[83]); MULADD(at[15], at[82]); MULADD(at[16], at[81]); MULADD(at[17], at[80]); MULADD(at[18], at[79]); MULADD(at[19], at[78]); MULADD(at[20], at[77]); MULADD(at[21], at[76]); MULADD(at[22], at[75]); MULADD(at[23], at[74]); MULADD(at[24], at[73]); MULADD(at[25], at[72]); MULADD(at[26], at[71]); MULADD(at[27], at[70]); MULADD(at[28], at[69]); MULADD(at[29], at[68]); MULADD(at[30], at[67]); MULADD(at[31], at[66]); MULADD(at[32], at[65]); MULADD(at[33], at[64]); MULADD(at[34], at[63]); MULADD(at[35], at[62]); MULADD(at[36], at[61]); MULADD(at[37], at[60]); MULADD(at[38], at[59]); MULADD(at[39], at[58]); MULADD(at[40], at[57]); MULADD(at[41], at[56]); MULADD(at[42], at[55]); MULADD(at[43], at[54]); MULADD(at[44], at[53]); MULADD(at[45], at[52]); MULADD(at[46], at[51]); MULADD(at[47], at[50]); COMBA_STORE(C->dp[49]); /* 50 */ COMBA_FORWARD; MULADD(at[3], at[95]); MULADD(at[4], at[94]); MULADD(at[5], at[93]); MULADD(at[6], at[92]); MULADD(at[7], at[91]); MULADD(at[8], at[90]); MULADD(at[9], at[89]); MULADD(at[10], at[88]); MULADD(at[11], at[87]); MULADD(at[12], at[86]); MULADD(at[13], at[85]); MULADD(at[14], at[84]); MULADD(at[15], at[83]); MULADD(at[16], at[82]); MULADD(at[17], at[81]); MULADD(at[18], at[80]); MULADD(at[19], at[79]); MULADD(at[20], at[78]); MULADD(at[21], at[77]); MULADD(at[22], at[76]); MULADD(at[23], at[75]); MULADD(at[24], at[74]); MULADD(at[25], at[73]); MULADD(at[26], at[72]); MULADD(at[27], at[71]); MULADD(at[28], at[70]); MULADD(at[29], at[69]); MULADD(at[30], at[68]); MULADD(at[31], at[67]); MULADD(at[32], at[66]); MULADD(at[33], at[65]); MULADD(at[34], at[64]); MULADD(at[35], at[63]); MULADD(at[36], at[62]); MULADD(at[37], at[61]); MULADD(at[38], at[60]); MULADD(at[39], at[59]); MULADD(at[40], at[58]); MULADD(at[41], at[57]); MULADD(at[42], at[56]); MULADD(at[43], at[55]); MULADD(at[44], at[54]); MULADD(at[45], at[53]); MULADD(at[46], at[52]); MULADD(at[47], at[51]); COMBA_STORE(C->dp[50]); /* 51 */ COMBA_FORWARD; MULADD(at[4], at[95]); MULADD(at[5], at[94]); MULADD(at[6], at[93]); MULADD(at[7], at[92]); MULADD(at[8], at[91]); MULADD(at[9], at[90]); MULADD(at[10], at[89]); MULADD(at[11], at[88]); MULADD(at[12], at[87]); MULADD(at[13], at[86]); MULADD(at[14], at[85]); MULADD(at[15], at[84]); MULADD(at[16], at[83]); MULADD(at[17], at[82]); MULADD(at[18], at[81]); MULADD(at[19], at[80]); MULADD(at[20], at[79]); MULADD(at[21], at[78]); MULADD(at[22], at[77]); MULADD(at[23], at[76]); MULADD(at[24], at[75]); MULADD(at[25], at[74]); MULADD(at[26], at[73]); MULADD(at[27], at[72]); MULADD(at[28], at[71]); MULADD(at[29], at[70]); MULADD(at[30], at[69]); MULADD(at[31], at[68]); MULADD(at[32], at[67]); MULADD(at[33], at[66]); MULADD(at[34], at[65]); MULADD(at[35], at[64]); MULADD(at[36], at[63]); MULADD(at[37], at[62]); MULADD(at[38], at[61]); MULADD(at[39], at[60]); MULADD(at[40], at[59]); MULADD(at[41], at[58]); MULADD(at[42], at[57]); MULADD(at[43], at[56]); MULADD(at[44], at[55]); MULADD(at[45], at[54]); MULADD(at[46], at[53]); MULADD(at[47], at[52]); COMBA_STORE(C->dp[51]); /* 52 */ COMBA_FORWARD; MULADD(at[5], at[95]); MULADD(at[6], at[94]); MULADD(at[7], at[93]); MULADD(at[8], at[92]); MULADD(at[9], at[91]); MULADD(at[10], at[90]); MULADD(at[11], at[89]); MULADD(at[12], at[88]); MULADD(at[13], at[87]); MULADD(at[14], at[86]); MULADD(at[15], at[85]); MULADD(at[16], at[84]); MULADD(at[17], at[83]); MULADD(at[18], at[82]); MULADD(at[19], at[81]); MULADD(at[20], at[80]); MULADD(at[21], at[79]); MULADD(at[22], at[78]); MULADD(at[23], at[77]); MULADD(at[24], at[76]); MULADD(at[25], at[75]); MULADD(at[26], at[74]); MULADD(at[27], at[73]); MULADD(at[28], at[72]); MULADD(at[29], at[71]); MULADD(at[30], at[70]); MULADD(at[31], at[69]); MULADD(at[32], at[68]); MULADD(at[33], at[67]); MULADD(at[34], at[66]); MULADD(at[35], at[65]); MULADD(at[36], at[64]); MULADD(at[37], at[63]); MULADD(at[38], at[62]); MULADD(at[39], at[61]); MULADD(at[40], at[60]); MULADD(at[41], at[59]); MULADD(at[42], at[58]); MULADD(at[43], at[57]); MULADD(at[44], at[56]); MULADD(at[45], at[55]); MULADD(at[46], at[54]); MULADD(at[47], at[53]); COMBA_STORE(C->dp[52]); /* 53 */ COMBA_FORWARD; MULADD(at[6], at[95]); MULADD(at[7], at[94]); MULADD(at[8], at[93]); MULADD(at[9], at[92]); MULADD(at[10], at[91]); MULADD(at[11], at[90]); MULADD(at[12], at[89]); MULADD(at[13], at[88]); MULADD(at[14], at[87]); MULADD(at[15], at[86]); MULADD(at[16], at[85]); MULADD(at[17], at[84]); MULADD(at[18], at[83]); MULADD(at[19], at[82]); MULADD(at[20], at[81]); MULADD(at[21], at[80]); MULADD(at[22], at[79]); MULADD(at[23], at[78]); MULADD(at[24], at[77]); MULADD(at[25], at[76]); MULADD(at[26], at[75]); MULADD(at[27], at[74]); MULADD(at[28], at[73]); MULADD(at[29], at[72]); MULADD(at[30], at[71]); MULADD(at[31], at[70]); MULADD(at[32], at[69]); MULADD(at[33], at[68]); MULADD(at[34], at[67]); MULADD(at[35], at[66]); MULADD(at[36], at[65]); MULADD(at[37], at[64]); MULADD(at[38], at[63]); MULADD(at[39], at[62]); MULADD(at[40], at[61]); MULADD(at[41], at[60]); MULADD(at[42], at[59]); MULADD(at[43], at[58]); MULADD(at[44], at[57]); MULADD(at[45], at[56]); MULADD(at[46], at[55]); MULADD(at[47], at[54]); COMBA_STORE(C->dp[53]); /* 54 */ COMBA_FORWARD; MULADD(at[7], at[95]); MULADD(at[8], at[94]); MULADD(at[9], at[93]); MULADD(at[10], at[92]); MULADD(at[11], at[91]); MULADD(at[12], at[90]); MULADD(at[13], at[89]); MULADD(at[14], at[88]); MULADD(at[15], at[87]); MULADD(at[16], at[86]); MULADD(at[17], at[85]); MULADD(at[18], at[84]); MULADD(at[19], at[83]); MULADD(at[20], at[82]); MULADD(at[21], at[81]); MULADD(at[22], at[80]); MULADD(at[23], at[79]); MULADD(at[24], at[78]); MULADD(at[25], at[77]); MULADD(at[26], at[76]); MULADD(at[27], at[75]); MULADD(at[28], at[74]); MULADD(at[29], at[73]); MULADD(at[30], at[72]); MULADD(at[31], at[71]); MULADD(at[32], at[70]); MULADD(at[33], at[69]); MULADD(at[34], at[68]); MULADD(at[35], at[67]); MULADD(at[36], at[66]); MULADD(at[37], at[65]); MULADD(at[38], at[64]); MULADD(at[39], at[63]); MULADD(at[40], at[62]); MULADD(at[41], at[61]); MULADD(at[42], at[60]); MULADD(at[43], at[59]); MULADD(at[44], at[58]); MULADD(at[45], at[57]); MULADD(at[46], at[56]); MULADD(at[47], at[55]); COMBA_STORE(C->dp[54]); /* 55 */ COMBA_FORWARD; MULADD(at[8], at[95]); MULADD(at[9], at[94]); MULADD(at[10], at[93]); MULADD(at[11], at[92]); MULADD(at[12], at[91]); MULADD(at[13], at[90]); MULADD(at[14], at[89]); MULADD(at[15], at[88]); MULADD(at[16], at[87]); MULADD(at[17], at[86]); MULADD(at[18], at[85]); MULADD(at[19], at[84]); MULADD(at[20], at[83]); MULADD(at[21], at[82]); MULADD(at[22], at[81]); MULADD(at[23], at[80]); MULADD(at[24], at[79]); MULADD(at[25], at[78]); MULADD(at[26], at[77]); MULADD(at[27], at[76]); MULADD(at[28], at[75]); MULADD(at[29], at[74]); MULADD(at[30], at[73]); MULADD(at[31], at[72]); MULADD(at[32], at[71]); MULADD(at[33], at[70]); MULADD(at[34], at[69]); MULADD(at[35], at[68]); MULADD(at[36], at[67]); MULADD(at[37], at[66]); MULADD(at[38], at[65]); MULADD(at[39], at[64]); MULADD(at[40], at[63]); MULADD(at[41], at[62]); MULADD(at[42], at[61]); MULADD(at[43], at[60]); MULADD(at[44], at[59]); MULADD(at[45], at[58]); MULADD(at[46], at[57]); MULADD(at[47], at[56]); COMBA_STORE(C->dp[55]); /* 56 */ COMBA_FORWARD; MULADD(at[9], at[95]); MULADD(at[10], at[94]); MULADD(at[11], at[93]); MULADD(at[12], at[92]); MULADD(at[13], at[91]); MULADD(at[14], at[90]); MULADD(at[15], at[89]); MULADD(at[16], at[88]); MULADD(at[17], at[87]); MULADD(at[18], at[86]); MULADD(at[19], at[85]); MULADD(at[20], at[84]); MULADD(at[21], at[83]); MULADD(at[22], at[82]); MULADD(at[23], at[81]); MULADD(at[24], at[80]); MULADD(at[25], at[79]); MULADD(at[26], at[78]); MULADD(at[27], at[77]); MULADD(at[28], at[76]); MULADD(at[29], at[75]); MULADD(at[30], at[74]); MULADD(at[31], at[73]); MULADD(at[32], at[72]); MULADD(at[33], at[71]); MULADD(at[34], at[70]); MULADD(at[35], at[69]); MULADD(at[36], at[68]); MULADD(at[37], at[67]); MULADD(at[38], at[66]); MULADD(at[39], at[65]); MULADD(at[40], at[64]); MULADD(at[41], at[63]); MULADD(at[42], at[62]); MULADD(at[43], at[61]); MULADD(at[44], at[60]); MULADD(at[45], at[59]); MULADD(at[46], at[58]); MULADD(at[47], at[57]); COMBA_STORE(C->dp[56]); /* 57 */ COMBA_FORWARD; MULADD(at[10], at[95]); MULADD(at[11], at[94]); MULADD(at[12], at[93]); MULADD(at[13], at[92]); MULADD(at[14], at[91]); MULADD(at[15], at[90]); MULADD(at[16], at[89]); MULADD(at[17], at[88]); MULADD(at[18], at[87]); MULADD(at[19], at[86]); MULADD(at[20], at[85]); MULADD(at[21], at[84]); MULADD(at[22], at[83]); MULADD(at[23], at[82]); MULADD(at[24], at[81]); MULADD(at[25], at[80]); MULADD(at[26], at[79]); MULADD(at[27], at[78]); MULADD(at[28], at[77]); MULADD(at[29], at[76]); MULADD(at[30], at[75]); MULADD(at[31], at[74]); MULADD(at[32], at[73]); MULADD(at[33], at[72]); MULADD(at[34], at[71]); MULADD(at[35], at[70]); MULADD(at[36], at[69]); MULADD(at[37], at[68]); MULADD(at[38], at[67]); MULADD(at[39], at[66]); MULADD(at[40], at[65]); MULADD(at[41], at[64]); MULADD(at[42], at[63]); MULADD(at[43], at[62]); MULADD(at[44], at[61]); MULADD(at[45], at[60]); MULADD(at[46], at[59]); MULADD(at[47], at[58]); COMBA_STORE(C->dp[57]); /* 58 */ COMBA_FORWARD; MULADD(at[11], at[95]); MULADD(at[12], at[94]); MULADD(at[13], at[93]); MULADD(at[14], at[92]); MULADD(at[15], at[91]); MULADD(at[16], at[90]); MULADD(at[17], at[89]); MULADD(at[18], at[88]); MULADD(at[19], at[87]); MULADD(at[20], at[86]); MULADD(at[21], at[85]); MULADD(at[22], at[84]); MULADD(at[23], at[83]); MULADD(at[24], at[82]); MULADD(at[25], at[81]); MULADD(at[26], at[80]); MULADD(at[27], at[79]); MULADD(at[28], at[78]); MULADD(at[29], at[77]); MULADD(at[30], at[76]); MULADD(at[31], at[75]); MULADD(at[32], at[74]); MULADD(at[33], at[73]); MULADD(at[34], at[72]); MULADD(at[35], at[71]); MULADD(at[36], at[70]); MULADD(at[37], at[69]); MULADD(at[38], at[68]); MULADD(at[39], at[67]); MULADD(at[40], at[66]); MULADD(at[41], at[65]); MULADD(at[42], at[64]); MULADD(at[43], at[63]); MULADD(at[44], at[62]); MULADD(at[45], at[61]); MULADD(at[46], at[60]); MULADD(at[47], at[59]); COMBA_STORE(C->dp[58]); /* 59 */ COMBA_FORWARD; MULADD(at[12], at[95]); MULADD(at[13], at[94]); MULADD(at[14], at[93]); MULADD(at[15], at[92]); MULADD(at[16], at[91]); MULADD(at[17], at[90]); MULADD(at[18], at[89]); MULADD(at[19], at[88]); MULADD(at[20], at[87]); MULADD(at[21], at[86]); MULADD(at[22], at[85]); MULADD(at[23], at[84]); MULADD(at[24], at[83]); MULADD(at[25], at[82]); MULADD(at[26], at[81]); MULADD(at[27], at[80]); MULADD(at[28], at[79]); MULADD(at[29], at[78]); MULADD(at[30], at[77]); MULADD(at[31], at[76]); MULADD(at[32], at[75]); MULADD(at[33], at[74]); MULADD(at[34], at[73]); MULADD(at[35], at[72]); MULADD(at[36], at[71]); MULADD(at[37], at[70]); MULADD(at[38], at[69]); MULADD(at[39], at[68]); MULADD(at[40], at[67]); MULADD(at[41], at[66]); MULADD(at[42], at[65]); MULADD(at[43], at[64]); MULADD(at[44], at[63]); MULADD(at[45], at[62]); MULADD(at[46], at[61]); MULADD(at[47], at[60]); COMBA_STORE(C->dp[59]); /* 60 */ COMBA_FORWARD; MULADD(at[13], at[95]); MULADD(at[14], at[94]); MULADD(at[15], at[93]); MULADD(at[16], at[92]); MULADD(at[17], at[91]); MULADD(at[18], at[90]); MULADD(at[19], at[89]); MULADD(at[20], at[88]); MULADD(at[21], at[87]); MULADD(at[22], at[86]); MULADD(at[23], at[85]); MULADD(at[24], at[84]); MULADD(at[25], at[83]); MULADD(at[26], at[82]); MULADD(at[27], at[81]); MULADD(at[28], at[80]); MULADD(at[29], at[79]); MULADD(at[30], at[78]); MULADD(at[31], at[77]); MULADD(at[32], at[76]); MULADD(at[33], at[75]); MULADD(at[34], at[74]); MULADD(at[35], at[73]); MULADD(at[36], at[72]); MULADD(at[37], at[71]); MULADD(at[38], at[70]); MULADD(at[39], at[69]); MULADD(at[40], at[68]); MULADD(at[41], at[67]); MULADD(at[42], at[66]); MULADD(at[43], at[65]); MULADD(at[44], at[64]); MULADD(at[45], at[63]); MULADD(at[46], at[62]); MULADD(at[47], at[61]); COMBA_STORE(C->dp[60]); /* 61 */ COMBA_FORWARD; MULADD(at[14], at[95]); MULADD(at[15], at[94]); MULADD(at[16], at[93]); MULADD(at[17], at[92]); MULADD(at[18], at[91]); MULADD(at[19], at[90]); MULADD(at[20], at[89]); MULADD(at[21], at[88]); MULADD(at[22], at[87]); MULADD(at[23], at[86]); MULADD(at[24], at[85]); MULADD(at[25], at[84]); MULADD(at[26], at[83]); MULADD(at[27], at[82]); MULADD(at[28], at[81]); MULADD(at[29], at[80]); MULADD(at[30], at[79]); MULADD(at[31], at[78]); MULADD(at[32], at[77]); MULADD(at[33], at[76]); MULADD(at[34], at[75]); MULADD(at[35], at[74]); MULADD(at[36], at[73]); MULADD(at[37], at[72]); MULADD(at[38], at[71]); MULADD(at[39], at[70]); MULADD(at[40], at[69]); MULADD(at[41], at[68]); MULADD(at[42], at[67]); MULADD(at[43], at[66]); MULADD(at[44], at[65]); MULADD(at[45], at[64]); MULADD(at[46], at[63]); MULADD(at[47], at[62]); COMBA_STORE(C->dp[61]); /* 62 */ COMBA_FORWARD; MULADD(at[15], at[95]); MULADD(at[16], at[94]); MULADD(at[17], at[93]); MULADD(at[18], at[92]); MULADD(at[19], at[91]); MULADD(at[20], at[90]); MULADD(at[21], at[89]); MULADD(at[22], at[88]); MULADD(at[23], at[87]); MULADD(at[24], at[86]); MULADD(at[25], at[85]); MULADD(at[26], at[84]); MULADD(at[27], at[83]); MULADD(at[28], at[82]); MULADD(at[29], at[81]); MULADD(at[30], at[80]); MULADD(at[31], at[79]); MULADD(at[32], at[78]); MULADD(at[33], at[77]); MULADD(at[34], at[76]); MULADD(at[35], at[75]); MULADD(at[36], at[74]); MULADD(at[37], at[73]); MULADD(at[38], at[72]); MULADD(at[39], at[71]); MULADD(at[40], at[70]); MULADD(at[41], at[69]); MULADD(at[42], at[68]); MULADD(at[43], at[67]); MULADD(at[44], at[66]); MULADD(at[45], at[65]); MULADD(at[46], at[64]); MULADD(at[47], at[63]); COMBA_STORE(C->dp[62]); /* 63 */ COMBA_FORWARD; MULADD(at[16], at[95]); MULADD(at[17], at[94]); MULADD(at[18], at[93]); MULADD(at[19], at[92]); MULADD(at[20], at[91]); MULADD(at[21], at[90]); MULADD(at[22], at[89]); MULADD(at[23], at[88]); MULADD(at[24], at[87]); MULADD(at[25], at[86]); MULADD(at[26], at[85]); MULADD(at[27], at[84]); MULADD(at[28], at[83]); MULADD(at[29], at[82]); MULADD(at[30], at[81]); MULADD(at[31], at[80]); MULADD(at[32], at[79]); MULADD(at[33], at[78]); MULADD(at[34], at[77]); MULADD(at[35], at[76]); MULADD(at[36], at[75]); MULADD(at[37], at[74]); MULADD(at[38], at[73]); MULADD(at[39], at[72]); MULADD(at[40], at[71]); MULADD(at[41], at[70]); MULADD(at[42], at[69]); MULADD(at[43], at[68]); MULADD(at[44], at[67]); MULADD(at[45], at[66]); MULADD(at[46], at[65]); MULADD(at[47], at[64]); COMBA_STORE(C->dp[63]); /* 64 */ COMBA_FORWARD; MULADD(at[17], at[95]); MULADD(at[18], at[94]); MULADD(at[19], at[93]); MULADD(at[20], at[92]); MULADD(at[21], at[91]); MULADD(at[22], at[90]); MULADD(at[23], at[89]); MULADD(at[24], at[88]); MULADD(at[25], at[87]); MULADD(at[26], at[86]); MULADD(at[27], at[85]); MULADD(at[28], at[84]); MULADD(at[29], at[83]); MULADD(at[30], at[82]); MULADD(at[31], at[81]); MULADD(at[32], at[80]); MULADD(at[33], at[79]); MULADD(at[34], at[78]); MULADD(at[35], at[77]); MULADD(at[36], at[76]); MULADD(at[37], at[75]); MULADD(at[38], at[74]); MULADD(at[39], at[73]); MULADD(at[40], at[72]); MULADD(at[41], at[71]); MULADD(at[42], at[70]); MULADD(at[43], at[69]); MULADD(at[44], at[68]); MULADD(at[45], at[67]); MULADD(at[46], at[66]); MULADD(at[47], at[65]); COMBA_STORE(C->dp[64]); /* 65 */ COMBA_FORWARD; MULADD(at[18], at[95]); MULADD(at[19], at[94]); MULADD(at[20], at[93]); MULADD(at[21], at[92]); MULADD(at[22], at[91]); MULADD(at[23], at[90]); MULADD(at[24], at[89]); MULADD(at[25], at[88]); MULADD(at[26], at[87]); MULADD(at[27], at[86]); MULADD(at[28], at[85]); MULADD(at[29], at[84]); MULADD(at[30], at[83]); MULADD(at[31], at[82]); MULADD(at[32], at[81]); MULADD(at[33], at[80]); MULADD(at[34], at[79]); MULADD(at[35], at[78]); MULADD(at[36], at[77]); MULADD(at[37], at[76]); MULADD(at[38], at[75]); MULADD(at[39], at[74]); MULADD(at[40], at[73]); MULADD(at[41], at[72]); MULADD(at[42], at[71]); MULADD(at[43], at[70]); MULADD(at[44], at[69]); MULADD(at[45], at[68]); MULADD(at[46], at[67]); MULADD(at[47], at[66]); COMBA_STORE(C->dp[65]); /* 66 */ COMBA_FORWARD; MULADD(at[19], at[95]); MULADD(at[20], at[94]); MULADD(at[21], at[93]); MULADD(at[22], at[92]); MULADD(at[23], at[91]); MULADD(at[24], at[90]); MULADD(at[25], at[89]); MULADD(at[26], at[88]); MULADD(at[27], at[87]); MULADD(at[28], at[86]); MULADD(at[29], at[85]); MULADD(at[30], at[84]); MULADD(at[31], at[83]); MULADD(at[32], at[82]); MULADD(at[33], at[81]); MULADD(at[34], at[80]); MULADD(at[35], at[79]); MULADD(at[36], at[78]); MULADD(at[37], at[77]); MULADD(at[38], at[76]); MULADD(at[39], at[75]); MULADD(at[40], at[74]); MULADD(at[41], at[73]); MULADD(at[42], at[72]); MULADD(at[43], at[71]); MULADD(at[44], at[70]); MULADD(at[45], at[69]); MULADD(at[46], at[68]); MULADD(at[47], at[67]); COMBA_STORE(C->dp[66]); /* 67 */ COMBA_FORWARD; MULADD(at[20], at[95]); MULADD(at[21], at[94]); MULADD(at[22], at[93]); MULADD(at[23], at[92]); MULADD(at[24], at[91]); MULADD(at[25], at[90]); MULADD(at[26], at[89]); MULADD(at[27], at[88]); MULADD(at[28], at[87]); MULADD(at[29], at[86]); MULADD(at[30], at[85]); MULADD(at[31], at[84]); MULADD(at[32], at[83]); MULADD(at[33], at[82]); MULADD(at[34], at[81]); MULADD(at[35], at[80]); MULADD(at[36], at[79]); MULADD(at[37], at[78]); MULADD(at[38], at[77]); MULADD(at[39], at[76]); MULADD(at[40], at[75]); MULADD(at[41], at[74]); MULADD(at[42], at[73]); MULADD(at[43], at[72]); MULADD(at[44], at[71]); MULADD(at[45], at[70]); MULADD(at[46], at[69]); MULADD(at[47], at[68]); COMBA_STORE(C->dp[67]); /* 68 */ COMBA_FORWARD; MULADD(at[21], at[95]); MULADD(at[22], at[94]); MULADD(at[23], at[93]); MULADD(at[24], at[92]); MULADD(at[25], at[91]); MULADD(at[26], at[90]); MULADD(at[27], at[89]); MULADD(at[28], at[88]); MULADD(at[29], at[87]); MULADD(at[30], at[86]); MULADD(at[31], at[85]); MULADD(at[32], at[84]); MULADD(at[33], at[83]); MULADD(at[34], at[82]); MULADD(at[35], at[81]); MULADD(at[36], at[80]); MULADD(at[37], at[79]); MULADD(at[38], at[78]); MULADD(at[39], at[77]); MULADD(at[40], at[76]); MULADD(at[41], at[75]); MULADD(at[42], at[74]); MULADD(at[43], at[73]); MULADD(at[44], at[72]); MULADD(at[45], at[71]); MULADD(at[46], at[70]); MULADD(at[47], at[69]); COMBA_STORE(C->dp[68]); /* 69 */ COMBA_FORWARD; MULADD(at[22], at[95]); MULADD(at[23], at[94]); MULADD(at[24], at[93]); MULADD(at[25], at[92]); MULADD(at[26], at[91]); MULADD(at[27], at[90]); MULADD(at[28], at[89]); MULADD(at[29], at[88]); MULADD(at[30], at[87]); MULADD(at[31], at[86]); MULADD(at[32], at[85]); MULADD(at[33], at[84]); MULADD(at[34], at[83]); MULADD(at[35], at[82]); MULADD(at[36], at[81]); MULADD(at[37], at[80]); MULADD(at[38], at[79]); MULADD(at[39], at[78]); MULADD(at[40], at[77]); MULADD(at[41], at[76]); MULADD(at[42], at[75]); MULADD(at[43], at[74]); MULADD(at[44], at[73]); MULADD(at[45], at[72]); MULADD(at[46], at[71]); MULADD(at[47], at[70]); COMBA_STORE(C->dp[69]); /* 70 */ COMBA_FORWARD; MULADD(at[23], at[95]); MULADD(at[24], at[94]); MULADD(at[25], at[93]); MULADD(at[26], at[92]); MULADD(at[27], at[91]); MULADD(at[28], at[90]); MULADD(at[29], at[89]); MULADD(at[30], at[88]); MULADD(at[31], at[87]); MULADD(at[32], at[86]); MULADD(at[33], at[85]); MULADD(at[34], at[84]); MULADD(at[35], at[83]); MULADD(at[36], at[82]); MULADD(at[37], at[81]); MULADD(at[38], at[80]); MULADD(at[39], at[79]); MULADD(at[40], at[78]); MULADD(at[41], at[77]); MULADD(at[42], at[76]); MULADD(at[43], at[75]); MULADD(at[44], at[74]); MULADD(at[45], at[73]); MULADD(at[46], at[72]); MULADD(at[47], at[71]); COMBA_STORE(C->dp[70]); /* 71 */ COMBA_FORWARD; MULADD(at[24], at[95]); MULADD(at[25], at[94]); MULADD(at[26], at[93]); MULADD(at[27], at[92]); MULADD(at[28], at[91]); MULADD(at[29], at[90]); MULADD(at[30], at[89]); MULADD(at[31], at[88]); MULADD(at[32], at[87]); MULADD(at[33], at[86]); MULADD(at[34], at[85]); MULADD(at[35], at[84]); MULADD(at[36], at[83]); MULADD(at[37], at[82]); MULADD(at[38], at[81]); MULADD(at[39], at[80]); MULADD(at[40], at[79]); MULADD(at[41], at[78]); MULADD(at[42], at[77]); MULADD(at[43], at[76]); MULADD(at[44], at[75]); MULADD(at[45], at[74]); MULADD(at[46], at[73]); MULADD(at[47], at[72]); COMBA_STORE(C->dp[71]); /* 72 */ COMBA_FORWARD; MULADD(at[25], at[95]); MULADD(at[26], at[94]); MULADD(at[27], at[93]); MULADD(at[28], at[92]); MULADD(at[29], at[91]); MULADD(at[30], at[90]); MULADD(at[31], at[89]); MULADD(at[32], at[88]); MULADD(at[33], at[87]); MULADD(at[34], at[86]); MULADD(at[35], at[85]); MULADD(at[36], at[84]); MULADD(at[37], at[83]); MULADD(at[38], at[82]); MULADD(at[39], at[81]); MULADD(at[40], at[80]); MULADD(at[41], at[79]); MULADD(at[42], at[78]); MULADD(at[43], at[77]); MULADD(at[44], at[76]); MULADD(at[45], at[75]); MULADD(at[46], at[74]); MULADD(at[47], at[73]); COMBA_STORE(C->dp[72]); /* 73 */ COMBA_FORWARD; MULADD(at[26], at[95]); MULADD(at[27], at[94]); MULADD(at[28], at[93]); MULADD(at[29], at[92]); MULADD(at[30], at[91]); MULADD(at[31], at[90]); MULADD(at[32], at[89]); MULADD(at[33], at[88]); MULADD(at[34], at[87]); MULADD(at[35], at[86]); MULADD(at[36], at[85]); MULADD(at[37], at[84]); MULADD(at[38], at[83]); MULADD(at[39], at[82]); MULADD(at[40], at[81]); MULADD(at[41], at[80]); MULADD(at[42], at[79]); MULADD(at[43], at[78]); MULADD(at[44], at[77]); MULADD(at[45], at[76]); MULADD(at[46], at[75]); MULADD(at[47], at[74]); COMBA_STORE(C->dp[73]); /* 74 */ COMBA_FORWARD; MULADD(at[27], at[95]); MULADD(at[28], at[94]); MULADD(at[29], at[93]); MULADD(at[30], at[92]); MULADD(at[31], at[91]); MULADD(at[32], at[90]); MULADD(at[33], at[89]); MULADD(at[34], at[88]); MULADD(at[35], at[87]); MULADD(at[36], at[86]); MULADD(at[37], at[85]); MULADD(at[38], at[84]); MULADD(at[39], at[83]); MULADD(at[40], at[82]); MULADD(at[41], at[81]); MULADD(at[42], at[80]); MULADD(at[43], at[79]); MULADD(at[44], at[78]); MULADD(at[45], at[77]); MULADD(at[46], at[76]); MULADD(at[47], at[75]); COMBA_STORE(C->dp[74]); /* 75 */ COMBA_FORWARD; MULADD(at[28], at[95]); MULADD(at[29], at[94]); MULADD(at[30], at[93]); MULADD(at[31], at[92]); MULADD(at[32], at[91]); MULADD(at[33], at[90]); MULADD(at[34], at[89]); MULADD(at[35], at[88]); MULADD(at[36], at[87]); MULADD(at[37], at[86]); MULADD(at[38], at[85]); MULADD(at[39], at[84]); MULADD(at[40], at[83]); MULADD(at[41], at[82]); MULADD(at[42], at[81]); MULADD(at[43], at[80]); MULADD(at[44], at[79]); MULADD(at[45], at[78]); MULADD(at[46], at[77]); MULADD(at[47], at[76]); COMBA_STORE(C->dp[75]); /* 76 */ COMBA_FORWARD; MULADD(at[29], at[95]); MULADD(at[30], at[94]); MULADD(at[31], at[93]); MULADD(at[32], at[92]); MULADD(at[33], at[91]); MULADD(at[34], at[90]); MULADD(at[35], at[89]); MULADD(at[36], at[88]); MULADD(at[37], at[87]); MULADD(at[38], at[86]); MULADD(at[39], at[85]); MULADD(at[40], at[84]); MULADD(at[41], at[83]); MULADD(at[42], at[82]); MULADD(at[43], at[81]); MULADD(at[44], at[80]); MULADD(at[45], at[79]); MULADD(at[46], at[78]); MULADD(at[47], at[77]); COMBA_STORE(C->dp[76]); /* 77 */ COMBA_FORWARD; MULADD(at[30], at[95]); MULADD(at[31], at[94]); MULADD(at[32], at[93]); MULADD(at[33], at[92]); MULADD(at[34], at[91]); MULADD(at[35], at[90]); MULADD(at[36], at[89]); MULADD(at[37], at[88]); MULADD(at[38], at[87]); MULADD(at[39], at[86]); MULADD(at[40], at[85]); MULADD(at[41], at[84]); MULADD(at[42], at[83]); MULADD(at[43], at[82]); MULADD(at[44], at[81]); MULADD(at[45], at[80]); MULADD(at[46], at[79]); MULADD(at[47], at[78]); COMBA_STORE(C->dp[77]); /* 78 */ COMBA_FORWARD; MULADD(at[31], at[95]); MULADD(at[32], at[94]); MULADD(at[33], at[93]); MULADD(at[34], at[92]); MULADD(at[35], at[91]); MULADD(at[36], at[90]); MULADD(at[37], at[89]); MULADD(at[38], at[88]); MULADD(at[39], at[87]); MULADD(at[40], at[86]); MULADD(at[41], at[85]); MULADD(at[42], at[84]); MULADD(at[43], at[83]); MULADD(at[44], at[82]); MULADD(at[45], at[81]); MULADD(at[46], at[80]); MULADD(at[47], at[79]); COMBA_STORE(C->dp[78]); /* 79 */ COMBA_FORWARD; MULADD(at[32], at[95]); MULADD(at[33], at[94]); MULADD(at[34], at[93]); MULADD(at[35], at[92]); MULADD(at[36], at[91]); MULADD(at[37], at[90]); MULADD(at[38], at[89]); MULADD(at[39], at[88]); MULADD(at[40], at[87]); MULADD(at[41], at[86]); MULADD(at[42], at[85]); MULADD(at[43], at[84]); MULADD(at[44], at[83]); MULADD(at[45], at[82]); MULADD(at[46], at[81]); MULADD(at[47], at[80]); COMBA_STORE(C->dp[79]); /* 80 */ COMBA_FORWARD; MULADD(at[33], at[95]); MULADD(at[34], at[94]); MULADD(at[35], at[93]); MULADD(at[36], at[92]); MULADD(at[37], at[91]); MULADD(at[38], at[90]); MULADD(at[39], at[89]); MULADD(at[40], at[88]); MULADD(at[41], at[87]); MULADD(at[42], at[86]); MULADD(at[43], at[85]); MULADD(at[44], at[84]); MULADD(at[45], at[83]); MULADD(at[46], at[82]); MULADD(at[47], at[81]); COMBA_STORE(C->dp[80]); /* 81 */ COMBA_FORWARD; MULADD(at[34], at[95]); MULADD(at[35], at[94]); MULADD(at[36], at[93]); MULADD(at[37], at[92]); MULADD(at[38], at[91]); MULADD(at[39], at[90]); MULADD(at[40], at[89]); MULADD(at[41], at[88]); MULADD(at[42], at[87]); MULADD(at[43], at[86]); MULADD(at[44], at[85]); MULADD(at[45], at[84]); MULADD(at[46], at[83]); MULADD(at[47], at[82]); COMBA_STORE(C->dp[81]); /* 82 */ COMBA_FORWARD; MULADD(at[35], at[95]); MULADD(at[36], at[94]); MULADD(at[37], at[93]); MULADD(at[38], at[92]); MULADD(at[39], at[91]); MULADD(at[40], at[90]); MULADD(at[41], at[89]); MULADD(at[42], at[88]); MULADD(at[43], at[87]); MULADD(at[44], at[86]); MULADD(at[45], at[85]); MULADD(at[46], at[84]); MULADD(at[47], at[83]); COMBA_STORE(C->dp[82]); /* 83 */ COMBA_FORWARD; MULADD(at[36], at[95]); MULADD(at[37], at[94]); MULADD(at[38], at[93]); MULADD(at[39], at[92]); MULADD(at[40], at[91]); MULADD(at[41], at[90]); MULADD(at[42], at[89]); MULADD(at[43], at[88]); MULADD(at[44], at[87]); MULADD(at[45], at[86]); MULADD(at[46], at[85]); MULADD(at[47], at[84]); COMBA_STORE(C->dp[83]); /* 84 */ COMBA_FORWARD; MULADD(at[37], at[95]); MULADD(at[38], at[94]); MULADD(at[39], at[93]); MULADD(at[40], at[92]); MULADD(at[41], at[91]); MULADD(at[42], at[90]); MULADD(at[43], at[89]); MULADD(at[44], at[88]); MULADD(at[45], at[87]); MULADD(at[46], at[86]); MULADD(at[47], at[85]); COMBA_STORE(C->dp[84]); /* 85 */ COMBA_FORWARD; MULADD(at[38], at[95]); MULADD(at[39], at[94]); MULADD(at[40], at[93]); MULADD(at[41], at[92]); MULADD(at[42], at[91]); MULADD(at[43], at[90]); MULADD(at[44], at[89]); MULADD(at[45], at[88]); MULADD(at[46], at[87]); MULADD(at[47], at[86]); COMBA_STORE(C->dp[85]); /* 86 */ COMBA_FORWARD; MULADD(at[39], at[95]); MULADD(at[40], at[94]); MULADD(at[41], at[93]); MULADD(at[42], at[92]); MULADD(at[43], at[91]); MULADD(at[44], at[90]); MULADD(at[45], at[89]); MULADD(at[46], at[88]); MULADD(at[47], at[87]); COMBA_STORE(C->dp[86]); /* 87 */ COMBA_FORWARD; MULADD(at[40], at[95]); MULADD(at[41], at[94]); MULADD(at[42], at[93]); MULADD(at[43], at[92]); MULADD(at[44], at[91]); MULADD(at[45], at[90]); MULADD(at[46], at[89]); MULADD(at[47], at[88]); COMBA_STORE(C->dp[87]); /* 88 */ COMBA_FORWARD; MULADD(at[41], at[95]); MULADD(at[42], at[94]); MULADD(at[43], at[93]); MULADD(at[44], at[92]); MULADD(at[45], at[91]); MULADD(at[46], at[90]); MULADD(at[47], at[89]); COMBA_STORE(C->dp[88]); /* 89 */ COMBA_FORWARD; MULADD(at[42], at[95]); MULADD(at[43], at[94]); MULADD(at[44], at[93]); MULADD(at[45], at[92]); MULADD(at[46], at[91]); MULADD(at[47], at[90]); COMBA_STORE(C->dp[89]); /* 90 */ COMBA_FORWARD; MULADD(at[43], at[95]); MULADD(at[44], at[94]); MULADD(at[45], at[93]); MULADD(at[46], at[92]); MULADD(at[47], at[91]); COMBA_STORE(C->dp[90]); /* 91 */ COMBA_FORWARD; MULADD(at[44], at[95]); MULADD(at[45], at[94]); MULADD(at[46], at[93]); MULADD(at[47], at[92]); COMBA_STORE(C->dp[91]); /* 92 */ COMBA_FORWARD; MULADD(at[45], at[95]); MULADD(at[46], at[94]); MULADD(at[47], at[93]); COMBA_STORE(C->dp[92]); /* 93 */ COMBA_FORWARD; MULADD(at[46], at[95]); MULADD(at[47], at[94]); COMBA_STORE(C->dp[93]); /* 94 */ COMBA_FORWARD; MULADD(at[47], at[95]); COMBA_STORE(C->dp[94]); COMBA_STORE2(C->dp[95]); C->used = 96; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; } #endif /* End: src/mul/fp_mul_comba_48.c */ /* Start: src/mul/fp_mul_comba_6.c */ #define TFM_DEFINES //#include "fp_mul_comba.c" #ifdef TFM_MUL6 void fp_mul_comba6(fp_int *A, fp_int *B, fp_int *C) { fp_digit c0, c1, c2, at[12]; memcpy(at, A->dp, 6 * sizeof(fp_digit)); memcpy(at+6, B->dp, 6 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[6]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[7]); MULADD(at[1], at[6]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[8]); MULADD(at[1], at[7]); MULADD(at[2], at[6]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[9]); MULADD(at[1], at[8]); MULADD(at[2], at[7]); MULADD(at[3], at[6]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[10]); MULADD(at[1], at[9]); MULADD(at[2], at[8]); MULADD(at[3], at[7]); MULADD(at[4], at[6]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[11]); MULADD(at[1], at[10]); MULADD(at[2], at[9]); MULADD(at[3], at[8]); MULADD(at[4], at[7]); MULADD(at[5], at[6]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[1], at[11]); MULADD(at[2], at[10]); MULADD(at[3], at[9]); MULADD(at[4], at[8]); MULADD(at[5], at[7]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[2], at[11]); MULADD(at[3], at[10]); MULADD(at[4], at[9]); MULADD(at[5], at[8]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[3], at[11]); MULADD(at[4], at[10]); MULADD(at[5], at[9]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[4], at[11]); MULADD(at[5], at[10]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[5], at[11]); COMBA_STORE(C->dp[10]); COMBA_STORE2(C->dp[11]); C->used = 12; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; } #endif /* End: src/mul/fp_mul_comba_6.c */ /* Start: src/mul/fp_mul_comba_64.c */ #define TFM_DEFINES //#include "fp_mul_comba.c" #ifdef TFM_MUL64 void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C) { fp_digit c0, c1, c2, at[128]; memcpy(at, A->dp, 64 * sizeof(fp_digit)); memcpy(at+64, B->dp, 64 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[64]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[65]); MULADD(at[1], at[64]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[66]); MULADD(at[1], at[65]); MULADD(at[2], at[64]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[67]); MULADD(at[1], at[66]); MULADD(at[2], at[65]); MULADD(at[3], at[64]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[68]); MULADD(at[1], at[67]); MULADD(at[2], at[66]); MULADD(at[3], at[65]); MULADD(at[4], at[64]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[69]); MULADD(at[1], at[68]); MULADD(at[2], at[67]); MULADD(at[3], at[66]); MULADD(at[4], at[65]); MULADD(at[5], at[64]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[70]); MULADD(at[1], at[69]); MULADD(at[2], at[68]); MULADD(at[3], at[67]); MULADD(at[4], at[66]); MULADD(at[5], at[65]); MULADD(at[6], at[64]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[71]); MULADD(at[1], at[70]); MULADD(at[2], at[69]); MULADD(at[3], at[68]); MULADD(at[4], at[67]); MULADD(at[5], at[66]); MULADD(at[6], at[65]); MULADD(at[7], at[64]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[0], at[72]); MULADD(at[1], at[71]); MULADD(at[2], at[70]); MULADD(at[3], at[69]); MULADD(at[4], at[68]); MULADD(at[5], at[67]); MULADD(at[6], at[66]); MULADD(at[7], at[65]); MULADD(at[8], at[64]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[0], at[73]); MULADD(at[1], at[72]); MULADD(at[2], at[71]); MULADD(at[3], at[70]); MULADD(at[4], at[69]); MULADD(at[5], at[68]); MULADD(at[6], at[67]); MULADD(at[7], at[66]); MULADD(at[8], at[65]); MULADD(at[9], at[64]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[0], at[74]); MULADD(at[1], at[73]); MULADD(at[2], at[72]); MULADD(at[3], at[71]); MULADD(at[4], at[70]); MULADD(at[5], at[69]); MULADD(at[6], at[68]); MULADD(at[7], at[67]); MULADD(at[8], at[66]); MULADD(at[9], at[65]); MULADD(at[10], at[64]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[0], at[75]); MULADD(at[1], at[74]); MULADD(at[2], at[73]); MULADD(at[3], at[72]); MULADD(at[4], at[71]); MULADD(at[5], at[70]); MULADD(at[6], at[69]); MULADD(at[7], at[68]); MULADD(at[8], at[67]); MULADD(at[9], at[66]); MULADD(at[10], at[65]); MULADD(at[11], at[64]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[0], at[76]); MULADD(at[1], at[75]); MULADD(at[2], at[74]); MULADD(at[3], at[73]); MULADD(at[4], at[72]); MULADD(at[5], at[71]); MULADD(at[6], at[70]); MULADD(at[7], at[69]); MULADD(at[8], at[68]); MULADD(at[9], at[67]); MULADD(at[10], at[66]); MULADD(at[11], at[65]); MULADD(at[12], at[64]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[0], at[77]); MULADD(at[1], at[76]); MULADD(at[2], at[75]); MULADD(at[3], at[74]); MULADD(at[4], at[73]); MULADD(at[5], at[72]); MULADD(at[6], at[71]); MULADD(at[7], at[70]); MULADD(at[8], at[69]); MULADD(at[9], at[68]); MULADD(at[10], at[67]); MULADD(at[11], at[66]); MULADD(at[12], at[65]); MULADD(at[13], at[64]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[0], at[78]); MULADD(at[1], at[77]); MULADD(at[2], at[76]); MULADD(at[3], at[75]); MULADD(at[4], at[74]); MULADD(at[5], at[73]); MULADD(at[6], at[72]); MULADD(at[7], at[71]); MULADD(at[8], at[70]); MULADD(at[9], at[69]); MULADD(at[10], at[68]); MULADD(at[11], at[67]); MULADD(at[12], at[66]); MULADD(at[13], at[65]); MULADD(at[14], at[64]); COMBA_STORE(C->dp[14]); /* 15 */ COMBA_FORWARD; MULADD(at[0], at[79]); MULADD(at[1], at[78]); MULADD(at[2], at[77]); MULADD(at[3], at[76]); MULADD(at[4], at[75]); MULADD(at[5], at[74]); MULADD(at[6], at[73]); MULADD(at[7], at[72]); MULADD(at[8], at[71]); MULADD(at[9], at[70]); MULADD(at[10], at[69]); MULADD(at[11], at[68]); MULADD(at[12], at[67]); MULADD(at[13], at[66]); MULADD(at[14], at[65]); MULADD(at[15], at[64]); COMBA_STORE(C->dp[15]); /* 16 */ COMBA_FORWARD; MULADD(at[0], at[80]); MULADD(at[1], at[79]); MULADD(at[2], at[78]); MULADD(at[3], at[77]); MULADD(at[4], at[76]); MULADD(at[5], at[75]); MULADD(at[6], at[74]); MULADD(at[7], at[73]); MULADD(at[8], at[72]); MULADD(at[9], at[71]); MULADD(at[10], at[70]); MULADD(at[11], at[69]); MULADD(at[12], at[68]); MULADD(at[13], at[67]); MULADD(at[14], at[66]); MULADD(at[15], at[65]); MULADD(at[16], at[64]); COMBA_STORE(C->dp[16]); /* 17 */ COMBA_FORWARD; MULADD(at[0], at[81]); MULADD(at[1], at[80]); MULADD(at[2], at[79]); MULADD(at[3], at[78]); MULADD(at[4], at[77]); MULADD(at[5], at[76]); MULADD(at[6], at[75]); MULADD(at[7], at[74]); MULADD(at[8], at[73]); MULADD(at[9], at[72]); MULADD(at[10], at[71]); MULADD(at[11], at[70]); MULADD(at[12], at[69]); MULADD(at[13], at[68]); MULADD(at[14], at[67]); MULADD(at[15], at[66]); MULADD(at[16], at[65]); MULADD(at[17], at[64]); COMBA_STORE(C->dp[17]); /* 18 */ COMBA_FORWARD; MULADD(at[0], at[82]); MULADD(at[1], at[81]); MULADD(at[2], at[80]); MULADD(at[3], at[79]); MULADD(at[4], at[78]); MULADD(at[5], at[77]); MULADD(at[6], at[76]); MULADD(at[7], at[75]); MULADD(at[8], at[74]); MULADD(at[9], at[73]); MULADD(at[10], at[72]); MULADD(at[11], at[71]); MULADD(at[12], at[70]); MULADD(at[13], at[69]); MULADD(at[14], at[68]); MULADD(at[15], at[67]); MULADD(at[16], at[66]); MULADD(at[17], at[65]); MULADD(at[18], at[64]); COMBA_STORE(C->dp[18]); /* 19 */ COMBA_FORWARD; MULADD(at[0], at[83]); MULADD(at[1], at[82]); MULADD(at[2], at[81]); MULADD(at[3], at[80]); MULADD(at[4], at[79]); MULADD(at[5], at[78]); MULADD(at[6], at[77]); MULADD(at[7], at[76]); MULADD(at[8], at[75]); MULADD(at[9], at[74]); MULADD(at[10], at[73]); MULADD(at[11], at[72]); MULADD(at[12], at[71]); MULADD(at[13], at[70]); MULADD(at[14], at[69]); MULADD(at[15], at[68]); MULADD(at[16], at[67]); MULADD(at[17], at[66]); MULADD(at[18], at[65]); MULADD(at[19], at[64]); COMBA_STORE(C->dp[19]); /* 20 */ COMBA_FORWARD; MULADD(at[0], at[84]); MULADD(at[1], at[83]); MULADD(at[2], at[82]); MULADD(at[3], at[81]); MULADD(at[4], at[80]); MULADD(at[5], at[79]); MULADD(at[6], at[78]); MULADD(at[7], at[77]); MULADD(at[8], at[76]); MULADD(at[9], at[75]); MULADD(at[10], at[74]); MULADD(at[11], at[73]); MULADD(at[12], at[72]); MULADD(at[13], at[71]); MULADD(at[14], at[70]); MULADD(at[15], at[69]); MULADD(at[16], at[68]); MULADD(at[17], at[67]); MULADD(at[18], at[66]); MULADD(at[19], at[65]); MULADD(at[20], at[64]); COMBA_STORE(C->dp[20]); /* 21 */ COMBA_FORWARD; MULADD(at[0], at[85]); MULADD(at[1], at[84]); MULADD(at[2], at[83]); MULADD(at[3], at[82]); MULADD(at[4], at[81]); MULADD(at[5], at[80]); MULADD(at[6], at[79]); MULADD(at[7], at[78]); MULADD(at[8], at[77]); MULADD(at[9], at[76]); MULADD(at[10], at[75]); MULADD(at[11], at[74]); MULADD(at[12], at[73]); MULADD(at[13], at[72]); MULADD(at[14], at[71]); MULADD(at[15], at[70]); MULADD(at[16], at[69]); MULADD(at[17], at[68]); MULADD(at[18], at[67]); MULADD(at[19], at[66]); MULADD(at[20], at[65]); MULADD(at[21], at[64]); COMBA_STORE(C->dp[21]); /* 22 */ COMBA_FORWARD; MULADD(at[0], at[86]); MULADD(at[1], at[85]); MULADD(at[2], at[84]); MULADD(at[3], at[83]); MULADD(at[4], at[82]); MULADD(at[5], at[81]); MULADD(at[6], at[80]); MULADD(at[7], at[79]); MULADD(at[8], at[78]); MULADD(at[9], at[77]); MULADD(at[10], at[76]); MULADD(at[11], at[75]); MULADD(at[12], at[74]); MULADD(at[13], at[73]); MULADD(at[14], at[72]); MULADD(at[15], at[71]); MULADD(at[16], at[70]); MULADD(at[17], at[69]); MULADD(at[18], at[68]); MULADD(at[19], at[67]); MULADD(at[20], at[66]); MULADD(at[21], at[65]); MULADD(at[22], at[64]); COMBA_STORE(C->dp[22]); /* 23 */ COMBA_FORWARD; MULADD(at[0], at[87]); MULADD(at[1], at[86]); MULADD(at[2], at[85]); MULADD(at[3], at[84]); MULADD(at[4], at[83]); MULADD(at[5], at[82]); MULADD(at[6], at[81]); MULADD(at[7], at[80]); MULADD(at[8], at[79]); MULADD(at[9], at[78]); MULADD(at[10], at[77]); MULADD(at[11], at[76]); MULADD(at[12], at[75]); MULADD(at[13], at[74]); MULADD(at[14], at[73]); MULADD(at[15], at[72]); MULADD(at[16], at[71]); MULADD(at[17], at[70]); MULADD(at[18], at[69]); MULADD(at[19], at[68]); MULADD(at[20], at[67]); MULADD(at[21], at[66]); MULADD(at[22], at[65]); MULADD(at[23], at[64]); COMBA_STORE(C->dp[23]); /* 24 */ COMBA_FORWARD; MULADD(at[0], at[88]); MULADD(at[1], at[87]); MULADD(at[2], at[86]); MULADD(at[3], at[85]); MULADD(at[4], at[84]); MULADD(at[5], at[83]); MULADD(at[6], at[82]); MULADD(at[7], at[81]); MULADD(at[8], at[80]); MULADD(at[9], at[79]); MULADD(at[10], at[78]); MULADD(at[11], at[77]); MULADD(at[12], at[76]); MULADD(at[13], at[75]); MULADD(at[14], at[74]); MULADD(at[15], at[73]); MULADD(at[16], at[72]); MULADD(at[17], at[71]); MULADD(at[18], at[70]); MULADD(at[19], at[69]); MULADD(at[20], at[68]); MULADD(at[21], at[67]); MULADD(at[22], at[66]); MULADD(at[23], at[65]); MULADD(at[24], at[64]); COMBA_STORE(C->dp[24]); /* 25 */ COMBA_FORWARD; MULADD(at[0], at[89]); MULADD(at[1], at[88]); MULADD(at[2], at[87]); MULADD(at[3], at[86]); MULADD(at[4], at[85]); MULADD(at[5], at[84]); MULADD(at[6], at[83]); MULADD(at[7], at[82]); MULADD(at[8], at[81]); MULADD(at[9], at[80]); MULADD(at[10], at[79]); MULADD(at[11], at[78]); MULADD(at[12], at[77]); MULADD(at[13], at[76]); MULADD(at[14], at[75]); MULADD(at[15], at[74]); MULADD(at[16], at[73]); MULADD(at[17], at[72]); MULADD(at[18], at[71]); MULADD(at[19], at[70]); MULADD(at[20], at[69]); MULADD(at[21], at[68]); MULADD(at[22], at[67]); MULADD(at[23], at[66]); MULADD(at[24], at[65]); MULADD(at[25], at[64]); COMBA_STORE(C->dp[25]); /* 26 */ COMBA_FORWARD; MULADD(at[0], at[90]); MULADD(at[1], at[89]); MULADD(at[2], at[88]); MULADD(at[3], at[87]); MULADD(at[4], at[86]); MULADD(at[5], at[85]); MULADD(at[6], at[84]); MULADD(at[7], at[83]); MULADD(at[8], at[82]); MULADD(at[9], at[81]); MULADD(at[10], at[80]); MULADD(at[11], at[79]); MULADD(at[12], at[78]); MULADD(at[13], at[77]); MULADD(at[14], at[76]); MULADD(at[15], at[75]); MULADD(at[16], at[74]); MULADD(at[17], at[73]); MULADD(at[18], at[72]); MULADD(at[19], at[71]); MULADD(at[20], at[70]); MULADD(at[21], at[69]); MULADD(at[22], at[68]); MULADD(at[23], at[67]); MULADD(at[24], at[66]); MULADD(at[25], at[65]); MULADD(at[26], at[64]); COMBA_STORE(C->dp[26]); /* 27 */ COMBA_FORWARD; MULADD(at[0], at[91]); MULADD(at[1], at[90]); MULADD(at[2], at[89]); MULADD(at[3], at[88]); MULADD(at[4], at[87]); MULADD(at[5], at[86]); MULADD(at[6], at[85]); MULADD(at[7], at[84]); MULADD(at[8], at[83]); MULADD(at[9], at[82]); MULADD(at[10], at[81]); MULADD(at[11], at[80]); MULADD(at[12], at[79]); MULADD(at[13], at[78]); MULADD(at[14], at[77]); MULADD(at[15], at[76]); MULADD(at[16], at[75]); MULADD(at[17], at[74]); MULADD(at[18], at[73]); MULADD(at[19], at[72]); MULADD(at[20], at[71]); MULADD(at[21], at[70]); MULADD(at[22], at[69]); MULADD(at[23], at[68]); MULADD(at[24], at[67]); MULADD(at[25], at[66]); MULADD(at[26], at[65]); MULADD(at[27], at[64]); COMBA_STORE(C->dp[27]); /* 28 */ COMBA_FORWARD; MULADD(at[0], at[92]); MULADD(at[1], at[91]); MULADD(at[2], at[90]); MULADD(at[3], at[89]); MULADD(at[4], at[88]); MULADD(at[5], at[87]); MULADD(at[6], at[86]); MULADD(at[7], at[85]); MULADD(at[8], at[84]); MULADD(at[9], at[83]); MULADD(at[10], at[82]); MULADD(at[11], at[81]); MULADD(at[12], at[80]); MULADD(at[13], at[79]); MULADD(at[14], at[78]); MULADD(at[15], at[77]); MULADD(at[16], at[76]); MULADD(at[17], at[75]); MULADD(at[18], at[74]); MULADD(at[19], at[73]); MULADD(at[20], at[72]); MULADD(at[21], at[71]); MULADD(at[22], at[70]); MULADD(at[23], at[69]); MULADD(at[24], at[68]); MULADD(at[25], at[67]); MULADD(at[26], at[66]); MULADD(at[27], at[65]); MULADD(at[28], at[64]); COMBA_STORE(C->dp[28]); /* 29 */ COMBA_FORWARD; MULADD(at[0], at[93]); MULADD(at[1], at[92]); MULADD(at[2], at[91]); MULADD(at[3], at[90]); MULADD(at[4], at[89]); MULADD(at[5], at[88]); MULADD(at[6], at[87]); MULADD(at[7], at[86]); MULADD(at[8], at[85]); MULADD(at[9], at[84]); MULADD(at[10], at[83]); MULADD(at[11], at[82]); MULADD(at[12], at[81]); MULADD(at[13], at[80]); MULADD(at[14], at[79]); MULADD(at[15], at[78]); MULADD(at[16], at[77]); MULADD(at[17], at[76]); MULADD(at[18], at[75]); MULADD(at[19], at[74]); MULADD(at[20], at[73]); MULADD(at[21], at[72]); MULADD(at[22], at[71]); MULADD(at[23], at[70]); MULADD(at[24], at[69]); MULADD(at[25], at[68]); MULADD(at[26], at[67]); MULADD(at[27], at[66]); MULADD(at[28], at[65]); MULADD(at[29], at[64]); COMBA_STORE(C->dp[29]); /* 30 */ COMBA_FORWARD; MULADD(at[0], at[94]); MULADD(at[1], at[93]); MULADD(at[2], at[92]); MULADD(at[3], at[91]); MULADD(at[4], at[90]); MULADD(at[5], at[89]); MULADD(at[6], at[88]); MULADD(at[7], at[87]); MULADD(at[8], at[86]); MULADD(at[9], at[85]); MULADD(at[10], at[84]); MULADD(at[11], at[83]); MULADD(at[12], at[82]); MULADD(at[13], at[81]); MULADD(at[14], at[80]); MULADD(at[15], at[79]); MULADD(at[16], at[78]); MULADD(at[17], at[77]); MULADD(at[18], at[76]); MULADD(at[19], at[75]); MULADD(at[20], at[74]); MULADD(at[21], at[73]); MULADD(at[22], at[72]); MULADD(at[23], at[71]); MULADD(at[24], at[70]); MULADD(at[25], at[69]); MULADD(at[26], at[68]); MULADD(at[27], at[67]); MULADD(at[28], at[66]); MULADD(at[29], at[65]); MULADD(at[30], at[64]); COMBA_STORE(C->dp[30]); /* 31 */ COMBA_FORWARD; MULADD(at[0], at[95]); MULADD(at[1], at[94]); MULADD(at[2], at[93]); MULADD(at[3], at[92]); MULADD(at[4], at[91]); MULADD(at[5], at[90]); MULADD(at[6], at[89]); MULADD(at[7], at[88]); MULADD(at[8], at[87]); MULADD(at[9], at[86]); MULADD(at[10], at[85]); MULADD(at[11], at[84]); MULADD(at[12], at[83]); MULADD(at[13], at[82]); MULADD(at[14], at[81]); MULADD(at[15], at[80]); MULADD(at[16], at[79]); MULADD(at[17], at[78]); MULADD(at[18], at[77]); MULADD(at[19], at[76]); MULADD(at[20], at[75]); MULADD(at[21], at[74]); MULADD(at[22], at[73]); MULADD(at[23], at[72]); MULADD(at[24], at[71]); MULADD(at[25], at[70]); MULADD(at[26], at[69]); MULADD(at[27], at[68]); MULADD(at[28], at[67]); MULADD(at[29], at[66]); MULADD(at[30], at[65]); MULADD(at[31], at[64]); COMBA_STORE(C->dp[31]); /* 32 */ COMBA_FORWARD; MULADD(at[0], at[96]); MULADD(at[1], at[95]); MULADD(at[2], at[94]); MULADD(at[3], at[93]); MULADD(at[4], at[92]); MULADD(at[5], at[91]); MULADD(at[6], at[90]); MULADD(at[7], at[89]); MULADD(at[8], at[88]); MULADD(at[9], at[87]); MULADD(at[10], at[86]); MULADD(at[11], at[85]); MULADD(at[12], at[84]); MULADD(at[13], at[83]); MULADD(at[14], at[82]); MULADD(at[15], at[81]); MULADD(at[16], at[80]); MULADD(at[17], at[79]); MULADD(at[18], at[78]); MULADD(at[19], at[77]); MULADD(at[20], at[76]); MULADD(at[21], at[75]); MULADD(at[22], at[74]); MULADD(at[23], at[73]); MULADD(at[24], at[72]); MULADD(at[25], at[71]); MULADD(at[26], at[70]); MULADD(at[27], at[69]); MULADD(at[28], at[68]); MULADD(at[29], at[67]); MULADD(at[30], at[66]); MULADD(at[31], at[65]); MULADD(at[32], at[64]); COMBA_STORE(C->dp[32]); /* 33 */ COMBA_FORWARD; MULADD(at[0], at[97]); MULADD(at[1], at[96]); MULADD(at[2], at[95]); MULADD(at[3], at[94]); MULADD(at[4], at[93]); MULADD(at[5], at[92]); MULADD(at[6], at[91]); MULADD(at[7], at[90]); MULADD(at[8], at[89]); MULADD(at[9], at[88]); MULADD(at[10], at[87]); MULADD(at[11], at[86]); MULADD(at[12], at[85]); MULADD(at[13], at[84]); MULADD(at[14], at[83]); MULADD(at[15], at[82]); MULADD(at[16], at[81]); MULADD(at[17], at[80]); MULADD(at[18], at[79]); MULADD(at[19], at[78]); MULADD(at[20], at[77]); MULADD(at[21], at[76]); MULADD(at[22], at[75]); MULADD(at[23], at[74]); MULADD(at[24], at[73]); MULADD(at[25], at[72]); MULADD(at[26], at[71]); MULADD(at[27], at[70]); MULADD(at[28], at[69]); MULADD(at[29], at[68]); MULADD(at[30], at[67]); MULADD(at[31], at[66]); MULADD(at[32], at[65]); MULADD(at[33], at[64]); COMBA_STORE(C->dp[33]); /* 34 */ COMBA_FORWARD; MULADD(at[0], at[98]); MULADD(at[1], at[97]); MULADD(at[2], at[96]); MULADD(at[3], at[95]); MULADD(at[4], at[94]); MULADD(at[5], at[93]); MULADD(at[6], at[92]); MULADD(at[7], at[91]); MULADD(at[8], at[90]); MULADD(at[9], at[89]); MULADD(at[10], at[88]); MULADD(at[11], at[87]); MULADD(at[12], at[86]); MULADD(at[13], at[85]); MULADD(at[14], at[84]); MULADD(at[15], at[83]); MULADD(at[16], at[82]); MULADD(at[17], at[81]); MULADD(at[18], at[80]); MULADD(at[19], at[79]); MULADD(at[20], at[78]); MULADD(at[21], at[77]); MULADD(at[22], at[76]); MULADD(at[23], at[75]); MULADD(at[24], at[74]); MULADD(at[25], at[73]); MULADD(at[26], at[72]); MULADD(at[27], at[71]); MULADD(at[28], at[70]); MULADD(at[29], at[69]); MULADD(at[30], at[68]); MULADD(at[31], at[67]); MULADD(at[32], at[66]); MULADD(at[33], at[65]); MULADD(at[34], at[64]); COMBA_STORE(C->dp[34]); /* 35 */ COMBA_FORWARD; MULADD(at[0], at[99]); MULADD(at[1], at[98]); MULADD(at[2], at[97]); MULADD(at[3], at[96]); MULADD(at[4], at[95]); MULADD(at[5], at[94]); MULADD(at[6], at[93]); MULADD(at[7], at[92]); MULADD(at[8], at[91]); MULADD(at[9], at[90]); MULADD(at[10], at[89]); MULADD(at[11], at[88]); MULADD(at[12], at[87]); MULADD(at[13], at[86]); MULADD(at[14], at[85]); MULADD(at[15], at[84]); MULADD(at[16], at[83]); MULADD(at[17], at[82]); MULADD(at[18], at[81]); MULADD(at[19], at[80]); MULADD(at[20], at[79]); MULADD(at[21], at[78]); MULADD(at[22], at[77]); MULADD(at[23], at[76]); MULADD(at[24], at[75]); MULADD(at[25], at[74]); MULADD(at[26], at[73]); MULADD(at[27], at[72]); MULADD(at[28], at[71]); MULADD(at[29], at[70]); MULADD(at[30], at[69]); MULADD(at[31], at[68]); MULADD(at[32], at[67]); MULADD(at[33], at[66]); MULADD(at[34], at[65]); MULADD(at[35], at[64]); COMBA_STORE(C->dp[35]); /* 36 */ COMBA_FORWARD; MULADD(at[0], at[100]); MULADD(at[1], at[99]); MULADD(at[2], at[98]); MULADD(at[3], at[97]); MULADD(at[4], at[96]); MULADD(at[5], at[95]); MULADD(at[6], at[94]); MULADD(at[7], at[93]); MULADD(at[8], at[92]); MULADD(at[9], at[91]); MULADD(at[10], at[90]); MULADD(at[11], at[89]); MULADD(at[12], at[88]); MULADD(at[13], at[87]); MULADD(at[14], at[86]); MULADD(at[15], at[85]); MULADD(at[16], at[84]); MULADD(at[17], at[83]); MULADD(at[18], at[82]); MULADD(at[19], at[81]); MULADD(at[20], at[80]); MULADD(at[21], at[79]); MULADD(at[22], at[78]); MULADD(at[23], at[77]); MULADD(at[24], at[76]); MULADD(at[25], at[75]); MULADD(at[26], at[74]); MULADD(at[27], at[73]); MULADD(at[28], at[72]); MULADD(at[29], at[71]); MULADD(at[30], at[70]); MULADD(at[31], at[69]); MULADD(at[32], at[68]); MULADD(at[33], at[67]); MULADD(at[34], at[66]); MULADD(at[35], at[65]); MULADD(at[36], at[64]); COMBA_STORE(C->dp[36]); /* 37 */ COMBA_FORWARD; MULADD(at[0], at[101]); MULADD(at[1], at[100]); MULADD(at[2], at[99]); MULADD(at[3], at[98]); MULADD(at[4], at[97]); MULADD(at[5], at[96]); MULADD(at[6], at[95]); MULADD(at[7], at[94]); MULADD(at[8], at[93]); MULADD(at[9], at[92]); MULADD(at[10], at[91]); MULADD(at[11], at[90]); MULADD(at[12], at[89]); MULADD(at[13], at[88]); MULADD(at[14], at[87]); MULADD(at[15], at[86]); MULADD(at[16], at[85]); MULADD(at[17], at[84]); MULADD(at[18], at[83]); MULADD(at[19], at[82]); MULADD(at[20], at[81]); MULADD(at[21], at[80]); MULADD(at[22], at[79]); MULADD(at[23], at[78]); MULADD(at[24], at[77]); MULADD(at[25], at[76]); MULADD(at[26], at[75]); MULADD(at[27], at[74]); MULADD(at[28], at[73]); MULADD(at[29], at[72]); MULADD(at[30], at[71]); MULADD(at[31], at[70]); MULADD(at[32], at[69]); MULADD(at[33], at[68]); MULADD(at[34], at[67]); MULADD(at[35], at[66]); MULADD(at[36], at[65]); MULADD(at[37], at[64]); COMBA_STORE(C->dp[37]); /* 38 */ COMBA_FORWARD; MULADD(at[0], at[102]); MULADD(at[1], at[101]); MULADD(at[2], at[100]); MULADD(at[3], at[99]); MULADD(at[4], at[98]); MULADD(at[5], at[97]); MULADD(at[6], at[96]); MULADD(at[7], at[95]); MULADD(at[8], at[94]); MULADD(at[9], at[93]); MULADD(at[10], at[92]); MULADD(at[11], at[91]); MULADD(at[12], at[90]); MULADD(at[13], at[89]); MULADD(at[14], at[88]); MULADD(at[15], at[87]); MULADD(at[16], at[86]); MULADD(at[17], at[85]); MULADD(at[18], at[84]); MULADD(at[19], at[83]); MULADD(at[20], at[82]); MULADD(at[21], at[81]); MULADD(at[22], at[80]); MULADD(at[23], at[79]); MULADD(at[24], at[78]); MULADD(at[25], at[77]); MULADD(at[26], at[76]); MULADD(at[27], at[75]); MULADD(at[28], at[74]); MULADD(at[29], at[73]); MULADD(at[30], at[72]); MULADD(at[31], at[71]); MULADD(at[32], at[70]); MULADD(at[33], at[69]); MULADD(at[34], at[68]); MULADD(at[35], at[67]); MULADD(at[36], at[66]); MULADD(at[37], at[65]); MULADD(at[38], at[64]); COMBA_STORE(C->dp[38]); /* 39 */ COMBA_FORWARD; MULADD(at[0], at[103]); MULADD(at[1], at[102]); MULADD(at[2], at[101]); MULADD(at[3], at[100]); MULADD(at[4], at[99]); MULADD(at[5], at[98]); MULADD(at[6], at[97]); MULADD(at[7], at[96]); MULADD(at[8], at[95]); MULADD(at[9], at[94]); MULADD(at[10], at[93]); MULADD(at[11], at[92]); MULADD(at[12], at[91]); MULADD(at[13], at[90]); MULADD(at[14], at[89]); MULADD(at[15], at[88]); MULADD(at[16], at[87]); MULADD(at[17], at[86]); MULADD(at[18], at[85]); MULADD(at[19], at[84]); MULADD(at[20], at[83]); MULADD(at[21], at[82]); MULADD(at[22], at[81]); MULADD(at[23], at[80]); MULADD(at[24], at[79]); MULADD(at[25], at[78]); MULADD(at[26], at[77]); MULADD(at[27], at[76]); MULADD(at[28], at[75]); MULADD(at[29], at[74]); MULADD(at[30], at[73]); MULADD(at[31], at[72]); MULADD(at[32], at[71]); MULADD(at[33], at[70]); MULADD(at[34], at[69]); MULADD(at[35], at[68]); MULADD(at[36], at[67]); MULADD(at[37], at[66]); MULADD(at[38], at[65]); MULADD(at[39], at[64]); COMBA_STORE(C->dp[39]); /* 40 */ COMBA_FORWARD; MULADD(at[0], at[104]); MULADD(at[1], at[103]); MULADD(at[2], at[102]); MULADD(at[3], at[101]); MULADD(at[4], at[100]); MULADD(at[5], at[99]); MULADD(at[6], at[98]); MULADD(at[7], at[97]); MULADD(at[8], at[96]); MULADD(at[9], at[95]); MULADD(at[10], at[94]); MULADD(at[11], at[93]); MULADD(at[12], at[92]); MULADD(at[13], at[91]); MULADD(at[14], at[90]); MULADD(at[15], at[89]); MULADD(at[16], at[88]); MULADD(at[17], at[87]); MULADD(at[18], at[86]); MULADD(at[19], at[85]); MULADD(at[20], at[84]); MULADD(at[21], at[83]); MULADD(at[22], at[82]); MULADD(at[23], at[81]); MULADD(at[24], at[80]); MULADD(at[25], at[79]); MULADD(at[26], at[78]); MULADD(at[27], at[77]); MULADD(at[28], at[76]); MULADD(at[29], at[75]); MULADD(at[30], at[74]); MULADD(at[31], at[73]); MULADD(at[32], at[72]); MULADD(at[33], at[71]); MULADD(at[34], at[70]); MULADD(at[35], at[69]); MULADD(at[36], at[68]); MULADD(at[37], at[67]); MULADD(at[38], at[66]); MULADD(at[39], at[65]); MULADD(at[40], at[64]); COMBA_STORE(C->dp[40]); /* 41 */ COMBA_FORWARD; MULADD(at[0], at[105]); MULADD(at[1], at[104]); MULADD(at[2], at[103]); MULADD(at[3], at[102]); MULADD(at[4], at[101]); MULADD(at[5], at[100]); MULADD(at[6], at[99]); MULADD(at[7], at[98]); MULADD(at[8], at[97]); MULADD(at[9], at[96]); MULADD(at[10], at[95]); MULADD(at[11], at[94]); MULADD(at[12], at[93]); MULADD(at[13], at[92]); MULADD(at[14], at[91]); MULADD(at[15], at[90]); MULADD(at[16], at[89]); MULADD(at[17], at[88]); MULADD(at[18], at[87]); MULADD(at[19], at[86]); MULADD(at[20], at[85]); MULADD(at[21], at[84]); MULADD(at[22], at[83]); MULADD(at[23], at[82]); MULADD(at[24], at[81]); MULADD(at[25], at[80]); MULADD(at[26], at[79]); MULADD(at[27], at[78]); MULADD(at[28], at[77]); MULADD(at[29], at[76]); MULADD(at[30], at[75]); MULADD(at[31], at[74]); MULADD(at[32], at[73]); MULADD(at[33], at[72]); MULADD(at[34], at[71]); MULADD(at[35], at[70]); MULADD(at[36], at[69]); MULADD(at[37], at[68]); MULADD(at[38], at[67]); MULADD(at[39], at[66]); MULADD(at[40], at[65]); MULADD(at[41], at[64]); COMBA_STORE(C->dp[41]); /* 42 */ COMBA_FORWARD; MULADD(at[0], at[106]); MULADD(at[1], at[105]); MULADD(at[2], at[104]); MULADD(at[3], at[103]); MULADD(at[4], at[102]); MULADD(at[5], at[101]); MULADD(at[6], at[100]); MULADD(at[7], at[99]); MULADD(at[8], at[98]); MULADD(at[9], at[97]); MULADD(at[10], at[96]); MULADD(at[11], at[95]); MULADD(at[12], at[94]); MULADD(at[13], at[93]); MULADD(at[14], at[92]); MULADD(at[15], at[91]); MULADD(at[16], at[90]); MULADD(at[17], at[89]); MULADD(at[18], at[88]); MULADD(at[19], at[87]); MULADD(at[20], at[86]); MULADD(at[21], at[85]); MULADD(at[22], at[84]); MULADD(at[23], at[83]); MULADD(at[24], at[82]); MULADD(at[25], at[81]); MULADD(at[26], at[80]); MULADD(at[27], at[79]); MULADD(at[28], at[78]); MULADD(at[29], at[77]); MULADD(at[30], at[76]); MULADD(at[31], at[75]); MULADD(at[32], at[74]); MULADD(at[33], at[73]); MULADD(at[34], at[72]); MULADD(at[35], at[71]); MULADD(at[36], at[70]); MULADD(at[37], at[69]); MULADD(at[38], at[68]); MULADD(at[39], at[67]); MULADD(at[40], at[66]); MULADD(at[41], at[65]); MULADD(at[42], at[64]); COMBA_STORE(C->dp[42]); /* 43 */ COMBA_FORWARD; MULADD(at[0], at[107]); MULADD(at[1], at[106]); MULADD(at[2], at[105]); MULADD(at[3], at[104]); MULADD(at[4], at[103]); MULADD(at[5], at[102]); MULADD(at[6], at[101]); MULADD(at[7], at[100]); MULADD(at[8], at[99]); MULADD(at[9], at[98]); MULADD(at[10], at[97]); MULADD(at[11], at[96]); MULADD(at[12], at[95]); MULADD(at[13], at[94]); MULADD(at[14], at[93]); MULADD(at[15], at[92]); MULADD(at[16], at[91]); MULADD(at[17], at[90]); MULADD(at[18], at[89]); MULADD(at[19], at[88]); MULADD(at[20], at[87]); MULADD(at[21], at[86]); MULADD(at[22], at[85]); MULADD(at[23], at[84]); MULADD(at[24], at[83]); MULADD(at[25], at[82]); MULADD(at[26], at[81]); MULADD(at[27], at[80]); MULADD(at[28], at[79]); MULADD(at[29], at[78]); MULADD(at[30], at[77]); MULADD(at[31], at[76]); MULADD(at[32], at[75]); MULADD(at[33], at[74]); MULADD(at[34], at[73]); MULADD(at[35], at[72]); MULADD(at[36], at[71]); MULADD(at[37], at[70]); MULADD(at[38], at[69]); MULADD(at[39], at[68]); MULADD(at[40], at[67]); MULADD(at[41], at[66]); MULADD(at[42], at[65]); MULADD(at[43], at[64]); COMBA_STORE(C->dp[43]); /* 44 */ COMBA_FORWARD; MULADD(at[0], at[108]); MULADD(at[1], at[107]); MULADD(at[2], at[106]); MULADD(at[3], at[105]); MULADD(at[4], at[104]); MULADD(at[5], at[103]); MULADD(at[6], at[102]); MULADD(at[7], at[101]); MULADD(at[8], at[100]); MULADD(at[9], at[99]); MULADD(at[10], at[98]); MULADD(at[11], at[97]); MULADD(at[12], at[96]); MULADD(at[13], at[95]); MULADD(at[14], at[94]); MULADD(at[15], at[93]); MULADD(at[16], at[92]); MULADD(at[17], at[91]); MULADD(at[18], at[90]); MULADD(at[19], at[89]); MULADD(at[20], at[88]); MULADD(at[21], at[87]); MULADD(at[22], at[86]); MULADD(at[23], at[85]); MULADD(at[24], at[84]); MULADD(at[25], at[83]); MULADD(at[26], at[82]); MULADD(at[27], at[81]); MULADD(at[28], at[80]); MULADD(at[29], at[79]); MULADD(at[30], at[78]); MULADD(at[31], at[77]); MULADD(at[32], at[76]); MULADD(at[33], at[75]); MULADD(at[34], at[74]); MULADD(at[35], at[73]); MULADD(at[36], at[72]); MULADD(at[37], at[71]); MULADD(at[38], at[70]); MULADD(at[39], at[69]); MULADD(at[40], at[68]); MULADD(at[41], at[67]); MULADD(at[42], at[66]); MULADD(at[43], at[65]); MULADD(at[44], at[64]); COMBA_STORE(C->dp[44]); /* 45 */ COMBA_FORWARD; MULADD(at[0], at[109]); MULADD(at[1], at[108]); MULADD(at[2], at[107]); MULADD(at[3], at[106]); MULADD(at[4], at[105]); MULADD(at[5], at[104]); MULADD(at[6], at[103]); MULADD(at[7], at[102]); MULADD(at[8], at[101]); MULADD(at[9], at[100]); MULADD(at[10], at[99]); MULADD(at[11], at[98]); MULADD(at[12], at[97]); MULADD(at[13], at[96]); MULADD(at[14], at[95]); MULADD(at[15], at[94]); MULADD(at[16], at[93]); MULADD(at[17], at[92]); MULADD(at[18], at[91]); MULADD(at[19], at[90]); MULADD(at[20], at[89]); MULADD(at[21], at[88]); MULADD(at[22], at[87]); MULADD(at[23], at[86]); MULADD(at[24], at[85]); MULADD(at[25], at[84]); MULADD(at[26], at[83]); MULADD(at[27], at[82]); MULADD(at[28], at[81]); MULADD(at[29], at[80]); MULADD(at[30], at[79]); MULADD(at[31], at[78]); MULADD(at[32], at[77]); MULADD(at[33], at[76]); MULADD(at[34], at[75]); MULADD(at[35], at[74]); MULADD(at[36], at[73]); MULADD(at[37], at[72]); MULADD(at[38], at[71]); MULADD(at[39], at[70]); MULADD(at[40], at[69]); MULADD(at[41], at[68]); MULADD(at[42], at[67]); MULADD(at[43], at[66]); MULADD(at[44], at[65]); MULADD(at[45], at[64]); COMBA_STORE(C->dp[45]); /* 46 */ COMBA_FORWARD; MULADD(at[0], at[110]); MULADD(at[1], at[109]); MULADD(at[2], at[108]); MULADD(at[3], at[107]); MULADD(at[4], at[106]); MULADD(at[5], at[105]); MULADD(at[6], at[104]); MULADD(at[7], at[103]); MULADD(at[8], at[102]); MULADD(at[9], at[101]); MULADD(at[10], at[100]); MULADD(at[11], at[99]); MULADD(at[12], at[98]); MULADD(at[13], at[97]); MULADD(at[14], at[96]); MULADD(at[15], at[95]); MULADD(at[16], at[94]); MULADD(at[17], at[93]); MULADD(at[18], at[92]); MULADD(at[19], at[91]); MULADD(at[20], at[90]); MULADD(at[21], at[89]); MULADD(at[22], at[88]); MULADD(at[23], at[87]); MULADD(at[24], at[86]); MULADD(at[25], at[85]); MULADD(at[26], at[84]); MULADD(at[27], at[83]); MULADD(at[28], at[82]); MULADD(at[29], at[81]); MULADD(at[30], at[80]); MULADD(at[31], at[79]); MULADD(at[32], at[78]); MULADD(at[33], at[77]); MULADD(at[34], at[76]); MULADD(at[35], at[75]); MULADD(at[36], at[74]); MULADD(at[37], at[73]); MULADD(at[38], at[72]); MULADD(at[39], at[71]); MULADD(at[40], at[70]); MULADD(at[41], at[69]); MULADD(at[42], at[68]); MULADD(at[43], at[67]); MULADD(at[44], at[66]); MULADD(at[45], at[65]); MULADD(at[46], at[64]); COMBA_STORE(C->dp[46]); /* 47 */ COMBA_FORWARD; MULADD(at[0], at[111]); MULADD(at[1], at[110]); MULADD(at[2], at[109]); MULADD(at[3], at[108]); MULADD(at[4], at[107]); MULADD(at[5], at[106]); MULADD(at[6], at[105]); MULADD(at[7], at[104]); MULADD(at[8], at[103]); MULADD(at[9], at[102]); MULADD(at[10], at[101]); MULADD(at[11], at[100]); MULADD(at[12], at[99]); MULADD(at[13], at[98]); MULADD(at[14], at[97]); MULADD(at[15], at[96]); MULADD(at[16], at[95]); MULADD(at[17], at[94]); MULADD(at[18], at[93]); MULADD(at[19], at[92]); MULADD(at[20], at[91]); MULADD(at[21], at[90]); MULADD(at[22], at[89]); MULADD(at[23], at[88]); MULADD(at[24], at[87]); MULADD(at[25], at[86]); MULADD(at[26], at[85]); MULADD(at[27], at[84]); MULADD(at[28], at[83]); MULADD(at[29], at[82]); MULADD(at[30], at[81]); MULADD(at[31], at[80]); MULADD(at[32], at[79]); MULADD(at[33], at[78]); MULADD(at[34], at[77]); MULADD(at[35], at[76]); MULADD(at[36], at[75]); MULADD(at[37], at[74]); MULADD(at[38], at[73]); MULADD(at[39], at[72]); MULADD(at[40], at[71]); MULADD(at[41], at[70]); MULADD(at[42], at[69]); MULADD(at[43], at[68]); MULADD(at[44], at[67]); MULADD(at[45], at[66]); MULADD(at[46], at[65]); MULADD(at[47], at[64]); COMBA_STORE(C->dp[47]); /* 48 */ COMBA_FORWARD; MULADD(at[0], at[112]); MULADD(at[1], at[111]); MULADD(at[2], at[110]); MULADD(at[3], at[109]); MULADD(at[4], at[108]); MULADD(at[5], at[107]); MULADD(at[6], at[106]); MULADD(at[7], at[105]); MULADD(at[8], at[104]); MULADD(at[9], at[103]); MULADD(at[10], at[102]); MULADD(at[11], at[101]); MULADD(at[12], at[100]); MULADD(at[13], at[99]); MULADD(at[14], at[98]); MULADD(at[15], at[97]); MULADD(at[16], at[96]); MULADD(at[17], at[95]); MULADD(at[18], at[94]); MULADD(at[19], at[93]); MULADD(at[20], at[92]); MULADD(at[21], at[91]); MULADD(at[22], at[90]); MULADD(at[23], at[89]); MULADD(at[24], at[88]); MULADD(at[25], at[87]); MULADD(at[26], at[86]); MULADD(at[27], at[85]); MULADD(at[28], at[84]); MULADD(at[29], at[83]); MULADD(at[30], at[82]); MULADD(at[31], at[81]); MULADD(at[32], at[80]); MULADD(at[33], at[79]); MULADD(at[34], at[78]); MULADD(at[35], at[77]); MULADD(at[36], at[76]); MULADD(at[37], at[75]); MULADD(at[38], at[74]); MULADD(at[39], at[73]); MULADD(at[40], at[72]); MULADD(at[41], at[71]); MULADD(at[42], at[70]); MULADD(at[43], at[69]); MULADD(at[44], at[68]); MULADD(at[45], at[67]); MULADD(at[46], at[66]); MULADD(at[47], at[65]); MULADD(at[48], at[64]); COMBA_STORE(C->dp[48]); /* 49 */ COMBA_FORWARD; MULADD(at[0], at[113]); MULADD(at[1], at[112]); MULADD(at[2], at[111]); MULADD(at[3], at[110]); MULADD(at[4], at[109]); MULADD(at[5], at[108]); MULADD(at[6], at[107]); MULADD(at[7], at[106]); MULADD(at[8], at[105]); MULADD(at[9], at[104]); MULADD(at[10], at[103]); MULADD(at[11], at[102]); MULADD(at[12], at[101]); MULADD(at[13], at[100]); MULADD(at[14], at[99]); MULADD(at[15], at[98]); MULADD(at[16], at[97]); MULADD(at[17], at[96]); MULADD(at[18], at[95]); MULADD(at[19], at[94]); MULADD(at[20], at[93]); MULADD(at[21], at[92]); MULADD(at[22], at[91]); MULADD(at[23], at[90]); MULADD(at[24], at[89]); MULADD(at[25], at[88]); MULADD(at[26], at[87]); MULADD(at[27], at[86]); MULADD(at[28], at[85]); MULADD(at[29], at[84]); MULADD(at[30], at[83]); MULADD(at[31], at[82]); MULADD(at[32], at[81]); MULADD(at[33], at[80]); MULADD(at[34], at[79]); MULADD(at[35], at[78]); MULADD(at[36], at[77]); MULADD(at[37], at[76]); MULADD(at[38], at[75]); MULADD(at[39], at[74]); MULADD(at[40], at[73]); MULADD(at[41], at[72]); MULADD(at[42], at[71]); MULADD(at[43], at[70]); MULADD(at[44], at[69]); MULADD(at[45], at[68]); MULADD(at[46], at[67]); MULADD(at[47], at[66]); MULADD(at[48], at[65]); MULADD(at[49], at[64]); COMBA_STORE(C->dp[49]); /* 50 */ COMBA_FORWARD; MULADD(at[0], at[114]); MULADD(at[1], at[113]); MULADD(at[2], at[112]); MULADD(at[3], at[111]); MULADD(at[4], at[110]); MULADD(at[5], at[109]); MULADD(at[6], at[108]); MULADD(at[7], at[107]); MULADD(at[8], at[106]); MULADD(at[9], at[105]); MULADD(at[10], at[104]); MULADD(at[11], at[103]); MULADD(at[12], at[102]); MULADD(at[13], at[101]); MULADD(at[14], at[100]); MULADD(at[15], at[99]); MULADD(at[16], at[98]); MULADD(at[17], at[97]); MULADD(at[18], at[96]); MULADD(at[19], at[95]); MULADD(at[20], at[94]); MULADD(at[21], at[93]); MULADD(at[22], at[92]); MULADD(at[23], at[91]); MULADD(at[24], at[90]); MULADD(at[25], at[89]); MULADD(at[26], at[88]); MULADD(at[27], at[87]); MULADD(at[28], at[86]); MULADD(at[29], at[85]); MULADD(at[30], at[84]); MULADD(at[31], at[83]); MULADD(at[32], at[82]); MULADD(at[33], at[81]); MULADD(at[34], at[80]); MULADD(at[35], at[79]); MULADD(at[36], at[78]); MULADD(at[37], at[77]); MULADD(at[38], at[76]); MULADD(at[39], at[75]); MULADD(at[40], at[74]); MULADD(at[41], at[73]); MULADD(at[42], at[72]); MULADD(at[43], at[71]); MULADD(at[44], at[70]); MULADD(at[45], at[69]); MULADD(at[46], at[68]); MULADD(at[47], at[67]); MULADD(at[48], at[66]); MULADD(at[49], at[65]); MULADD(at[50], at[64]); COMBA_STORE(C->dp[50]); /* 51 */ COMBA_FORWARD; MULADD(at[0], at[115]); MULADD(at[1], at[114]); MULADD(at[2], at[113]); MULADD(at[3], at[112]); MULADD(at[4], at[111]); MULADD(at[5], at[110]); MULADD(at[6], at[109]); MULADD(at[7], at[108]); MULADD(at[8], at[107]); MULADD(at[9], at[106]); MULADD(at[10], at[105]); MULADD(at[11], at[104]); MULADD(at[12], at[103]); MULADD(at[13], at[102]); MULADD(at[14], at[101]); MULADD(at[15], at[100]); MULADD(at[16], at[99]); MULADD(at[17], at[98]); MULADD(at[18], at[97]); MULADD(at[19], at[96]); MULADD(at[20], at[95]); MULADD(at[21], at[94]); MULADD(at[22], at[93]); MULADD(at[23], at[92]); MULADD(at[24], at[91]); MULADD(at[25], at[90]); MULADD(at[26], at[89]); MULADD(at[27], at[88]); MULADD(at[28], at[87]); MULADD(at[29], at[86]); MULADD(at[30], at[85]); MULADD(at[31], at[84]); MULADD(at[32], at[83]); MULADD(at[33], at[82]); MULADD(at[34], at[81]); MULADD(at[35], at[80]); MULADD(at[36], at[79]); MULADD(at[37], at[78]); MULADD(at[38], at[77]); MULADD(at[39], at[76]); MULADD(at[40], at[75]); MULADD(at[41], at[74]); MULADD(at[42], at[73]); MULADD(at[43], at[72]); MULADD(at[44], at[71]); MULADD(at[45], at[70]); MULADD(at[46], at[69]); MULADD(at[47], at[68]); MULADD(at[48], at[67]); MULADD(at[49], at[66]); MULADD(at[50], at[65]); MULADD(at[51], at[64]); COMBA_STORE(C->dp[51]); /* 52 */ COMBA_FORWARD; MULADD(at[0], at[116]); MULADD(at[1], at[115]); MULADD(at[2], at[114]); MULADD(at[3], at[113]); MULADD(at[4], at[112]); MULADD(at[5], at[111]); MULADD(at[6], at[110]); MULADD(at[7], at[109]); MULADD(at[8], at[108]); MULADD(at[9], at[107]); MULADD(at[10], at[106]); MULADD(at[11], at[105]); MULADD(at[12], at[104]); MULADD(at[13], at[103]); MULADD(at[14], at[102]); MULADD(at[15], at[101]); MULADD(at[16], at[100]); MULADD(at[17], at[99]); MULADD(at[18], at[98]); MULADD(at[19], at[97]); MULADD(at[20], at[96]); MULADD(at[21], at[95]); MULADD(at[22], at[94]); MULADD(at[23], at[93]); MULADD(at[24], at[92]); MULADD(at[25], at[91]); MULADD(at[26], at[90]); MULADD(at[27], at[89]); MULADD(at[28], at[88]); MULADD(at[29], at[87]); MULADD(at[30], at[86]); MULADD(at[31], at[85]); MULADD(at[32], at[84]); MULADD(at[33], at[83]); MULADD(at[34], at[82]); MULADD(at[35], at[81]); MULADD(at[36], at[80]); MULADD(at[37], at[79]); MULADD(at[38], at[78]); MULADD(at[39], at[77]); MULADD(at[40], at[76]); MULADD(at[41], at[75]); MULADD(at[42], at[74]); MULADD(at[43], at[73]); MULADD(at[44], at[72]); MULADD(at[45], at[71]); MULADD(at[46], at[70]); MULADD(at[47], at[69]); MULADD(at[48], at[68]); MULADD(at[49], at[67]); MULADD(at[50], at[66]); MULADD(at[51], at[65]); MULADD(at[52], at[64]); COMBA_STORE(C->dp[52]); /* 53 */ COMBA_FORWARD; MULADD(at[0], at[117]); MULADD(at[1], at[116]); MULADD(at[2], at[115]); MULADD(at[3], at[114]); MULADD(at[4], at[113]); MULADD(at[5], at[112]); MULADD(at[6], at[111]); MULADD(at[7], at[110]); MULADD(at[8], at[109]); MULADD(at[9], at[108]); MULADD(at[10], at[107]); MULADD(at[11], at[106]); MULADD(at[12], at[105]); MULADD(at[13], at[104]); MULADD(at[14], at[103]); MULADD(at[15], at[102]); MULADD(at[16], at[101]); MULADD(at[17], at[100]); MULADD(at[18], at[99]); MULADD(at[19], at[98]); MULADD(at[20], at[97]); MULADD(at[21], at[96]); MULADD(at[22], at[95]); MULADD(at[23], at[94]); MULADD(at[24], at[93]); MULADD(at[25], at[92]); MULADD(at[26], at[91]); MULADD(at[27], at[90]); MULADD(at[28], at[89]); MULADD(at[29], at[88]); MULADD(at[30], at[87]); MULADD(at[31], at[86]); MULADD(at[32], at[85]); MULADD(at[33], at[84]); MULADD(at[34], at[83]); MULADD(at[35], at[82]); MULADD(at[36], at[81]); MULADD(at[37], at[80]); MULADD(at[38], at[79]); MULADD(at[39], at[78]); MULADD(at[40], at[77]); MULADD(at[41], at[76]); MULADD(at[42], at[75]); MULADD(at[43], at[74]); MULADD(at[44], at[73]); MULADD(at[45], at[72]); MULADD(at[46], at[71]); MULADD(at[47], at[70]); MULADD(at[48], at[69]); MULADD(at[49], at[68]); MULADD(at[50], at[67]); MULADD(at[51], at[66]); MULADD(at[52], at[65]); MULADD(at[53], at[64]); COMBA_STORE(C->dp[53]); /* 54 */ COMBA_FORWARD; MULADD(at[0], at[118]); MULADD(at[1], at[117]); MULADD(at[2], at[116]); MULADD(at[3], at[115]); MULADD(at[4], at[114]); MULADD(at[5], at[113]); MULADD(at[6], at[112]); MULADD(at[7], at[111]); MULADD(at[8], at[110]); MULADD(at[9], at[109]); MULADD(at[10], at[108]); MULADD(at[11], at[107]); MULADD(at[12], at[106]); MULADD(at[13], at[105]); MULADD(at[14], at[104]); MULADD(at[15], at[103]); MULADD(at[16], at[102]); MULADD(at[17], at[101]); MULADD(at[18], at[100]); MULADD(at[19], at[99]); MULADD(at[20], at[98]); MULADD(at[21], at[97]); MULADD(at[22], at[96]); MULADD(at[23], at[95]); MULADD(at[24], at[94]); MULADD(at[25], at[93]); MULADD(at[26], at[92]); MULADD(at[27], at[91]); MULADD(at[28], at[90]); MULADD(at[29], at[89]); MULADD(at[30], at[88]); MULADD(at[31], at[87]); MULADD(at[32], at[86]); MULADD(at[33], at[85]); MULADD(at[34], at[84]); MULADD(at[35], at[83]); MULADD(at[36], at[82]); MULADD(at[37], at[81]); MULADD(at[38], at[80]); MULADD(at[39], at[79]); MULADD(at[40], at[78]); MULADD(at[41], at[77]); MULADD(at[42], at[76]); MULADD(at[43], at[75]); MULADD(at[44], at[74]); MULADD(at[45], at[73]); MULADD(at[46], at[72]); MULADD(at[47], at[71]); MULADD(at[48], at[70]); MULADD(at[49], at[69]); MULADD(at[50], at[68]); MULADD(at[51], at[67]); MULADD(at[52], at[66]); MULADD(at[53], at[65]); MULADD(at[54], at[64]); COMBA_STORE(C->dp[54]); /* 55 */ COMBA_FORWARD; MULADD(at[0], at[119]); MULADD(at[1], at[118]); MULADD(at[2], at[117]); MULADD(at[3], at[116]); MULADD(at[4], at[115]); MULADD(at[5], at[114]); MULADD(at[6], at[113]); MULADD(at[7], at[112]); MULADD(at[8], at[111]); MULADD(at[9], at[110]); MULADD(at[10], at[109]); MULADD(at[11], at[108]); MULADD(at[12], at[107]); MULADD(at[13], at[106]); MULADD(at[14], at[105]); MULADD(at[15], at[104]); MULADD(at[16], at[103]); MULADD(at[17], at[102]); MULADD(at[18], at[101]); MULADD(at[19], at[100]); MULADD(at[20], at[99]); MULADD(at[21], at[98]); MULADD(at[22], at[97]); MULADD(at[23], at[96]); MULADD(at[24], at[95]); MULADD(at[25], at[94]); MULADD(at[26], at[93]); MULADD(at[27], at[92]); MULADD(at[28], at[91]); MULADD(at[29], at[90]); MULADD(at[30], at[89]); MULADD(at[31], at[88]); MULADD(at[32], at[87]); MULADD(at[33], at[86]); MULADD(at[34], at[85]); MULADD(at[35], at[84]); MULADD(at[36], at[83]); MULADD(at[37], at[82]); MULADD(at[38], at[81]); MULADD(at[39], at[80]); MULADD(at[40], at[79]); MULADD(at[41], at[78]); MULADD(at[42], at[77]); MULADD(at[43], at[76]); MULADD(at[44], at[75]); MULADD(at[45], at[74]); MULADD(at[46], at[73]); MULADD(at[47], at[72]); MULADD(at[48], at[71]); MULADD(at[49], at[70]); MULADD(at[50], at[69]); MULADD(at[51], at[68]); MULADD(at[52], at[67]); MULADD(at[53], at[66]); MULADD(at[54], at[65]); MULADD(at[55], at[64]); COMBA_STORE(C->dp[55]); /* 56 */ COMBA_FORWARD; MULADD(at[0], at[120]); MULADD(at[1], at[119]); MULADD(at[2], at[118]); MULADD(at[3], at[117]); MULADD(at[4], at[116]); MULADD(at[5], at[115]); MULADD(at[6], at[114]); MULADD(at[7], at[113]); MULADD(at[8], at[112]); MULADD(at[9], at[111]); MULADD(at[10], at[110]); MULADD(at[11], at[109]); MULADD(at[12], at[108]); MULADD(at[13], at[107]); MULADD(at[14], at[106]); MULADD(at[15], at[105]); MULADD(at[16], at[104]); MULADD(at[17], at[103]); MULADD(at[18], at[102]); MULADD(at[19], at[101]); MULADD(at[20], at[100]); MULADD(at[21], at[99]); MULADD(at[22], at[98]); MULADD(at[23], at[97]); MULADD(at[24], at[96]); MULADD(at[25], at[95]); MULADD(at[26], at[94]); MULADD(at[27], at[93]); MULADD(at[28], at[92]); MULADD(at[29], at[91]); MULADD(at[30], at[90]); MULADD(at[31], at[89]); MULADD(at[32], at[88]); MULADD(at[33], at[87]); MULADD(at[34], at[86]); MULADD(at[35], at[85]); MULADD(at[36], at[84]); MULADD(at[37], at[83]); MULADD(at[38], at[82]); MULADD(at[39], at[81]); MULADD(at[40], at[80]); MULADD(at[41], at[79]); MULADD(at[42], at[78]); MULADD(at[43], at[77]); MULADD(at[44], at[76]); MULADD(at[45], at[75]); MULADD(at[46], at[74]); MULADD(at[47], at[73]); MULADD(at[48], at[72]); MULADD(at[49], at[71]); MULADD(at[50], at[70]); MULADD(at[51], at[69]); MULADD(at[52], at[68]); MULADD(at[53], at[67]); MULADD(at[54], at[66]); MULADD(at[55], at[65]); MULADD(at[56], at[64]); COMBA_STORE(C->dp[56]); /* 57 */ COMBA_FORWARD; MULADD(at[0], at[121]); MULADD(at[1], at[120]); MULADD(at[2], at[119]); MULADD(at[3], at[118]); MULADD(at[4], at[117]); MULADD(at[5], at[116]); MULADD(at[6], at[115]); MULADD(at[7], at[114]); MULADD(at[8], at[113]); MULADD(at[9], at[112]); MULADD(at[10], at[111]); MULADD(at[11], at[110]); MULADD(at[12], at[109]); MULADD(at[13], at[108]); MULADD(at[14], at[107]); MULADD(at[15], at[106]); MULADD(at[16], at[105]); MULADD(at[17], at[104]); MULADD(at[18], at[103]); MULADD(at[19], at[102]); MULADD(at[20], at[101]); MULADD(at[21], at[100]); MULADD(at[22], at[99]); MULADD(at[23], at[98]); MULADD(at[24], at[97]); MULADD(at[25], at[96]); MULADD(at[26], at[95]); MULADD(at[27], at[94]); MULADD(at[28], at[93]); MULADD(at[29], at[92]); MULADD(at[30], at[91]); MULADD(at[31], at[90]); MULADD(at[32], at[89]); MULADD(at[33], at[88]); MULADD(at[34], at[87]); MULADD(at[35], at[86]); MULADD(at[36], at[85]); MULADD(at[37], at[84]); MULADD(at[38], at[83]); MULADD(at[39], at[82]); MULADD(at[40], at[81]); MULADD(at[41], at[80]); MULADD(at[42], at[79]); MULADD(at[43], at[78]); MULADD(at[44], at[77]); MULADD(at[45], at[76]); MULADD(at[46], at[75]); MULADD(at[47], at[74]); MULADD(at[48], at[73]); MULADD(at[49], at[72]); MULADD(at[50], at[71]); MULADD(at[51], at[70]); MULADD(at[52], at[69]); MULADD(at[53], at[68]); MULADD(at[54], at[67]); MULADD(at[55], at[66]); MULADD(at[56], at[65]); MULADD(at[57], at[64]); COMBA_STORE(C->dp[57]); /* 58 */ COMBA_FORWARD; MULADD(at[0], at[122]); MULADD(at[1], at[121]); MULADD(at[2], at[120]); MULADD(at[3], at[119]); MULADD(at[4], at[118]); MULADD(at[5], at[117]); MULADD(at[6], at[116]); MULADD(at[7], at[115]); MULADD(at[8], at[114]); MULADD(at[9], at[113]); MULADD(at[10], at[112]); MULADD(at[11], at[111]); MULADD(at[12], at[110]); MULADD(at[13], at[109]); MULADD(at[14], at[108]); MULADD(at[15], at[107]); MULADD(at[16], at[106]); MULADD(at[17], at[105]); MULADD(at[18], at[104]); MULADD(at[19], at[103]); MULADD(at[20], at[102]); MULADD(at[21], at[101]); MULADD(at[22], at[100]); MULADD(at[23], at[99]); MULADD(at[24], at[98]); MULADD(at[25], at[97]); MULADD(at[26], at[96]); MULADD(at[27], at[95]); MULADD(at[28], at[94]); MULADD(at[29], at[93]); MULADD(at[30], at[92]); MULADD(at[31], at[91]); MULADD(at[32], at[90]); MULADD(at[33], at[89]); MULADD(at[34], at[88]); MULADD(at[35], at[87]); MULADD(at[36], at[86]); MULADD(at[37], at[85]); MULADD(at[38], at[84]); MULADD(at[39], at[83]); MULADD(at[40], at[82]); MULADD(at[41], at[81]); MULADD(at[42], at[80]); MULADD(at[43], at[79]); MULADD(at[44], at[78]); MULADD(at[45], at[77]); MULADD(at[46], at[76]); MULADD(at[47], at[75]); MULADD(at[48], at[74]); MULADD(at[49], at[73]); MULADD(at[50], at[72]); MULADD(at[51], at[71]); MULADD(at[52], at[70]); MULADD(at[53], at[69]); MULADD(at[54], at[68]); MULADD(at[55], at[67]); MULADD(at[56], at[66]); MULADD(at[57], at[65]); MULADD(at[58], at[64]); COMBA_STORE(C->dp[58]); /* 59 */ COMBA_FORWARD; MULADD(at[0], at[123]); MULADD(at[1], at[122]); MULADD(at[2], at[121]); MULADD(at[3], at[120]); MULADD(at[4], at[119]); MULADD(at[5], at[118]); MULADD(at[6], at[117]); MULADD(at[7], at[116]); MULADD(at[8], at[115]); MULADD(at[9], at[114]); MULADD(at[10], at[113]); MULADD(at[11], at[112]); MULADD(at[12], at[111]); MULADD(at[13], at[110]); MULADD(at[14], at[109]); MULADD(at[15], at[108]); MULADD(at[16], at[107]); MULADD(at[17], at[106]); MULADD(at[18], at[105]); MULADD(at[19], at[104]); MULADD(at[20], at[103]); MULADD(at[21], at[102]); MULADD(at[22], at[101]); MULADD(at[23], at[100]); MULADD(at[24], at[99]); MULADD(at[25], at[98]); MULADD(at[26], at[97]); MULADD(at[27], at[96]); MULADD(at[28], at[95]); MULADD(at[29], at[94]); MULADD(at[30], at[93]); MULADD(at[31], at[92]); MULADD(at[32], at[91]); MULADD(at[33], at[90]); MULADD(at[34], at[89]); MULADD(at[35], at[88]); MULADD(at[36], at[87]); MULADD(at[37], at[86]); MULADD(at[38], at[85]); MULADD(at[39], at[84]); MULADD(at[40], at[83]); MULADD(at[41], at[82]); MULADD(at[42], at[81]); MULADD(at[43], at[80]); MULADD(at[44], at[79]); MULADD(at[45], at[78]); MULADD(at[46], at[77]); MULADD(at[47], at[76]); MULADD(at[48], at[75]); MULADD(at[49], at[74]); MULADD(at[50], at[73]); MULADD(at[51], at[72]); MULADD(at[52], at[71]); MULADD(at[53], at[70]); MULADD(at[54], at[69]); MULADD(at[55], at[68]); MULADD(at[56], at[67]); MULADD(at[57], at[66]); MULADD(at[58], at[65]); MULADD(at[59], at[64]); COMBA_STORE(C->dp[59]); /* 60 */ COMBA_FORWARD; MULADD(at[0], at[124]); MULADD(at[1], at[123]); MULADD(at[2], at[122]); MULADD(at[3], at[121]); MULADD(at[4], at[120]); MULADD(at[5], at[119]); MULADD(at[6], at[118]); MULADD(at[7], at[117]); MULADD(at[8], at[116]); MULADD(at[9], at[115]); MULADD(at[10], at[114]); MULADD(at[11], at[113]); MULADD(at[12], at[112]); MULADD(at[13], at[111]); MULADD(at[14], at[110]); MULADD(at[15], at[109]); MULADD(at[16], at[108]); MULADD(at[17], at[107]); MULADD(at[18], at[106]); MULADD(at[19], at[105]); MULADD(at[20], at[104]); MULADD(at[21], at[103]); MULADD(at[22], at[102]); MULADD(at[23], at[101]); MULADD(at[24], at[100]); MULADD(at[25], at[99]); MULADD(at[26], at[98]); MULADD(at[27], at[97]); MULADD(at[28], at[96]); MULADD(at[29], at[95]); MULADD(at[30], at[94]); MULADD(at[31], at[93]); MULADD(at[32], at[92]); MULADD(at[33], at[91]); MULADD(at[34], at[90]); MULADD(at[35], at[89]); MULADD(at[36], at[88]); MULADD(at[37], at[87]); MULADD(at[38], at[86]); MULADD(at[39], at[85]); MULADD(at[40], at[84]); MULADD(at[41], at[83]); MULADD(at[42], at[82]); MULADD(at[43], at[81]); MULADD(at[44], at[80]); MULADD(at[45], at[79]); MULADD(at[46], at[78]); MULADD(at[47], at[77]); MULADD(at[48], at[76]); MULADD(at[49], at[75]); MULADD(at[50], at[74]); MULADD(at[51], at[73]); MULADD(at[52], at[72]); MULADD(at[53], at[71]); MULADD(at[54], at[70]); MULADD(at[55], at[69]); MULADD(at[56], at[68]); MULADD(at[57], at[67]); MULADD(at[58], at[66]); MULADD(at[59], at[65]); MULADD(at[60], at[64]); COMBA_STORE(C->dp[60]); /* 61 */ COMBA_FORWARD; MULADD(at[0], at[125]); MULADD(at[1], at[124]); MULADD(at[2], at[123]); MULADD(at[3], at[122]); MULADD(at[4], at[121]); MULADD(at[5], at[120]); MULADD(at[6], at[119]); MULADD(at[7], at[118]); MULADD(at[8], at[117]); MULADD(at[9], at[116]); MULADD(at[10], at[115]); MULADD(at[11], at[114]); MULADD(at[12], at[113]); MULADD(at[13], at[112]); MULADD(at[14], at[111]); MULADD(at[15], at[110]); MULADD(at[16], at[109]); MULADD(at[17], at[108]); MULADD(at[18], at[107]); MULADD(at[19], at[106]); MULADD(at[20], at[105]); MULADD(at[21], at[104]); MULADD(at[22], at[103]); MULADD(at[23], at[102]); MULADD(at[24], at[101]); MULADD(at[25], at[100]); MULADD(at[26], at[99]); MULADD(at[27], at[98]); MULADD(at[28], at[97]); MULADD(at[29], at[96]); MULADD(at[30], at[95]); MULADD(at[31], at[94]); MULADD(at[32], at[93]); MULADD(at[33], at[92]); MULADD(at[34], at[91]); MULADD(at[35], at[90]); MULADD(at[36], at[89]); MULADD(at[37], at[88]); MULADD(at[38], at[87]); MULADD(at[39], at[86]); MULADD(at[40], at[85]); MULADD(at[41], at[84]); MULADD(at[42], at[83]); MULADD(at[43], at[82]); MULADD(at[44], at[81]); MULADD(at[45], at[80]); MULADD(at[46], at[79]); MULADD(at[47], at[78]); MULADD(at[48], at[77]); MULADD(at[49], at[76]); MULADD(at[50], at[75]); MULADD(at[51], at[74]); MULADD(at[52], at[73]); MULADD(at[53], at[72]); MULADD(at[54], at[71]); MULADD(at[55], at[70]); MULADD(at[56], at[69]); MULADD(at[57], at[68]); MULADD(at[58], at[67]); MULADD(at[59], at[66]); MULADD(at[60], at[65]); MULADD(at[61], at[64]); COMBA_STORE(C->dp[61]); /* 62 */ COMBA_FORWARD; MULADD(at[0], at[126]); MULADD(at[1], at[125]); MULADD(at[2], at[124]); MULADD(at[3], at[123]); MULADD(at[4], at[122]); MULADD(at[5], at[121]); MULADD(at[6], at[120]); MULADD(at[7], at[119]); MULADD(at[8], at[118]); MULADD(at[9], at[117]); MULADD(at[10], at[116]); MULADD(at[11], at[115]); MULADD(at[12], at[114]); MULADD(at[13], at[113]); MULADD(at[14], at[112]); MULADD(at[15], at[111]); MULADD(at[16], at[110]); MULADD(at[17], at[109]); MULADD(at[18], at[108]); MULADD(at[19], at[107]); MULADD(at[20], at[106]); MULADD(at[21], at[105]); MULADD(at[22], at[104]); MULADD(at[23], at[103]); MULADD(at[24], at[102]); MULADD(at[25], at[101]); MULADD(at[26], at[100]); MULADD(at[27], at[99]); MULADD(at[28], at[98]); MULADD(at[29], at[97]); MULADD(at[30], at[96]); MULADD(at[31], at[95]); MULADD(at[32], at[94]); MULADD(at[33], at[93]); MULADD(at[34], at[92]); MULADD(at[35], at[91]); MULADD(at[36], at[90]); MULADD(at[37], at[89]); MULADD(at[38], at[88]); MULADD(at[39], at[87]); MULADD(at[40], at[86]); MULADD(at[41], at[85]); MULADD(at[42], at[84]); MULADD(at[43], at[83]); MULADD(at[44], at[82]); MULADD(at[45], at[81]); MULADD(at[46], at[80]); MULADD(at[47], at[79]); MULADD(at[48], at[78]); MULADD(at[49], at[77]); MULADD(at[50], at[76]); MULADD(at[51], at[75]); MULADD(at[52], at[74]); MULADD(at[53], at[73]); MULADD(at[54], at[72]); MULADD(at[55], at[71]); MULADD(at[56], at[70]); MULADD(at[57], at[69]); MULADD(at[58], at[68]); MULADD(at[59], at[67]); MULADD(at[60], at[66]); MULADD(at[61], at[65]); MULADD(at[62], at[64]); COMBA_STORE(C->dp[62]); /* 63 */ COMBA_FORWARD; MULADD(at[0], at[127]); MULADD(at[1], at[126]); MULADD(at[2], at[125]); MULADD(at[3], at[124]); MULADD(at[4], at[123]); MULADD(at[5], at[122]); MULADD(at[6], at[121]); MULADD(at[7], at[120]); MULADD(at[8], at[119]); MULADD(at[9], at[118]); MULADD(at[10], at[117]); MULADD(at[11], at[116]); MULADD(at[12], at[115]); MULADD(at[13], at[114]); MULADD(at[14], at[113]); MULADD(at[15], at[112]); MULADD(at[16], at[111]); MULADD(at[17], at[110]); MULADD(at[18], at[109]); MULADD(at[19], at[108]); MULADD(at[20], at[107]); MULADD(at[21], at[106]); MULADD(at[22], at[105]); MULADD(at[23], at[104]); MULADD(at[24], at[103]); MULADD(at[25], at[102]); MULADD(at[26], at[101]); MULADD(at[27], at[100]); MULADD(at[28], at[99]); MULADD(at[29], at[98]); MULADD(at[30], at[97]); MULADD(at[31], at[96]); MULADD(at[32], at[95]); MULADD(at[33], at[94]); MULADD(at[34], at[93]); MULADD(at[35], at[92]); MULADD(at[36], at[91]); MULADD(at[37], at[90]); MULADD(at[38], at[89]); MULADD(at[39], at[88]); MULADD(at[40], at[87]); MULADD(at[41], at[86]); MULADD(at[42], at[85]); MULADD(at[43], at[84]); MULADD(at[44], at[83]); MULADD(at[45], at[82]); MULADD(at[46], at[81]); MULADD(at[47], at[80]); MULADD(at[48], at[79]); MULADD(at[49], at[78]); MULADD(at[50], at[77]); MULADD(at[51], at[76]); MULADD(at[52], at[75]); MULADD(at[53], at[74]); MULADD(at[54], at[73]); MULADD(at[55], at[72]); MULADD(at[56], at[71]); MULADD(at[57], at[70]); MULADD(at[58], at[69]); MULADD(at[59], at[68]); MULADD(at[60], at[67]); MULADD(at[61], at[66]); MULADD(at[62], at[65]); MULADD(at[63], at[64]); COMBA_STORE(C->dp[63]); /* 64 */ COMBA_FORWARD; MULADD(at[1], at[127]); MULADD(at[2], at[126]); MULADD(at[3], at[125]); MULADD(at[4], at[124]); MULADD(at[5], at[123]); MULADD(at[6], at[122]); MULADD(at[7], at[121]); MULADD(at[8], at[120]); MULADD(at[9], at[119]); MULADD(at[10], at[118]); MULADD(at[11], at[117]); MULADD(at[12], at[116]); MULADD(at[13], at[115]); MULADD(at[14], at[114]); MULADD(at[15], at[113]); MULADD(at[16], at[112]); MULADD(at[17], at[111]); MULADD(at[18], at[110]); MULADD(at[19], at[109]); MULADD(at[20], at[108]); MULADD(at[21], at[107]); MULADD(at[22], at[106]); MULADD(at[23], at[105]); MULADD(at[24], at[104]); MULADD(at[25], at[103]); MULADD(at[26], at[102]); MULADD(at[27], at[101]); MULADD(at[28], at[100]); MULADD(at[29], at[99]); MULADD(at[30], at[98]); MULADD(at[31], at[97]); MULADD(at[32], at[96]); MULADD(at[33], at[95]); MULADD(at[34], at[94]); MULADD(at[35], at[93]); MULADD(at[36], at[92]); MULADD(at[37], at[91]); MULADD(at[38], at[90]); MULADD(at[39], at[89]); MULADD(at[40], at[88]); MULADD(at[41], at[87]); MULADD(at[42], at[86]); MULADD(at[43], at[85]); MULADD(at[44], at[84]); MULADD(at[45], at[83]); MULADD(at[46], at[82]); MULADD(at[47], at[81]); MULADD(at[48], at[80]); MULADD(at[49], at[79]); MULADD(at[50], at[78]); MULADD(at[51], at[77]); MULADD(at[52], at[76]); MULADD(at[53], at[75]); MULADD(at[54], at[74]); MULADD(at[55], at[73]); MULADD(at[56], at[72]); MULADD(at[57], at[71]); MULADD(at[58], at[70]); MULADD(at[59], at[69]); MULADD(at[60], at[68]); MULADD(at[61], at[67]); MULADD(at[62], at[66]); MULADD(at[63], at[65]); COMBA_STORE(C->dp[64]); /* 65 */ COMBA_FORWARD; MULADD(at[2], at[127]); MULADD(at[3], at[126]); MULADD(at[4], at[125]); MULADD(at[5], at[124]); MULADD(at[6], at[123]); MULADD(at[7], at[122]); MULADD(at[8], at[121]); MULADD(at[9], at[120]); MULADD(at[10], at[119]); MULADD(at[11], at[118]); MULADD(at[12], at[117]); MULADD(at[13], at[116]); MULADD(at[14], at[115]); MULADD(at[15], at[114]); MULADD(at[16], at[113]); MULADD(at[17], at[112]); MULADD(at[18], at[111]); MULADD(at[19], at[110]); MULADD(at[20], at[109]); MULADD(at[21], at[108]); MULADD(at[22], at[107]); MULADD(at[23], at[106]); MULADD(at[24], at[105]); MULADD(at[25], at[104]); MULADD(at[26], at[103]); MULADD(at[27], at[102]); MULADD(at[28], at[101]); MULADD(at[29], at[100]); MULADD(at[30], at[99]); MULADD(at[31], at[98]); MULADD(at[32], at[97]); MULADD(at[33], at[96]); MULADD(at[34], at[95]); MULADD(at[35], at[94]); MULADD(at[36], at[93]); MULADD(at[37], at[92]); MULADD(at[38], at[91]); MULADD(at[39], at[90]); MULADD(at[40], at[89]); MULADD(at[41], at[88]); MULADD(at[42], at[87]); MULADD(at[43], at[86]); MULADD(at[44], at[85]); MULADD(at[45], at[84]); MULADD(at[46], at[83]); MULADD(at[47], at[82]); MULADD(at[48], at[81]); MULADD(at[49], at[80]); MULADD(at[50], at[79]); MULADD(at[51], at[78]); MULADD(at[52], at[77]); MULADD(at[53], at[76]); MULADD(at[54], at[75]); MULADD(at[55], at[74]); MULADD(at[56], at[73]); MULADD(at[57], at[72]); MULADD(at[58], at[71]); MULADD(at[59], at[70]); MULADD(at[60], at[69]); MULADD(at[61], at[68]); MULADD(at[62], at[67]); MULADD(at[63], at[66]); COMBA_STORE(C->dp[65]); /* 66 */ COMBA_FORWARD; MULADD(at[3], at[127]); MULADD(at[4], at[126]); MULADD(at[5], at[125]); MULADD(at[6], at[124]); MULADD(at[7], at[123]); MULADD(at[8], at[122]); MULADD(at[9], at[121]); MULADD(at[10], at[120]); MULADD(at[11], at[119]); MULADD(at[12], at[118]); MULADD(at[13], at[117]); MULADD(at[14], at[116]); MULADD(at[15], at[115]); MULADD(at[16], at[114]); MULADD(at[17], at[113]); MULADD(at[18], at[112]); MULADD(at[19], at[111]); MULADD(at[20], at[110]); MULADD(at[21], at[109]); MULADD(at[22], at[108]); MULADD(at[23], at[107]); MULADD(at[24], at[106]); MULADD(at[25], at[105]); MULADD(at[26], at[104]); MULADD(at[27], at[103]); MULADD(at[28], at[102]); MULADD(at[29], at[101]); MULADD(at[30], at[100]); MULADD(at[31], at[99]); MULADD(at[32], at[98]); MULADD(at[33], at[97]); MULADD(at[34], at[96]); MULADD(at[35], at[95]); MULADD(at[36], at[94]); MULADD(at[37], at[93]); MULADD(at[38], at[92]); MULADD(at[39], at[91]); MULADD(at[40], at[90]); MULADD(at[41], at[89]); MULADD(at[42], at[88]); MULADD(at[43], at[87]); MULADD(at[44], at[86]); MULADD(at[45], at[85]); MULADD(at[46], at[84]); MULADD(at[47], at[83]); MULADD(at[48], at[82]); MULADD(at[49], at[81]); MULADD(at[50], at[80]); MULADD(at[51], at[79]); MULADD(at[52], at[78]); MULADD(at[53], at[77]); MULADD(at[54], at[76]); MULADD(at[55], at[75]); MULADD(at[56], at[74]); MULADD(at[57], at[73]); MULADD(at[58], at[72]); MULADD(at[59], at[71]); MULADD(at[60], at[70]); MULADD(at[61], at[69]); MULADD(at[62], at[68]); MULADD(at[63], at[67]); COMBA_STORE(C->dp[66]); /* 67 */ COMBA_FORWARD; MULADD(at[4], at[127]); MULADD(at[5], at[126]); MULADD(at[6], at[125]); MULADD(at[7], at[124]); MULADD(at[8], at[123]); MULADD(at[9], at[122]); MULADD(at[10], at[121]); MULADD(at[11], at[120]); MULADD(at[12], at[119]); MULADD(at[13], at[118]); MULADD(at[14], at[117]); MULADD(at[15], at[116]); MULADD(at[16], at[115]); MULADD(at[17], at[114]); MULADD(at[18], at[113]); MULADD(at[19], at[112]); MULADD(at[20], at[111]); MULADD(at[21], at[110]); MULADD(at[22], at[109]); MULADD(at[23], at[108]); MULADD(at[24], at[107]); MULADD(at[25], at[106]); MULADD(at[26], at[105]); MULADD(at[27], at[104]); MULADD(at[28], at[103]); MULADD(at[29], at[102]); MULADD(at[30], at[101]); MULADD(at[31], at[100]); MULADD(at[32], at[99]); MULADD(at[33], at[98]); MULADD(at[34], at[97]); MULADD(at[35], at[96]); MULADD(at[36], at[95]); MULADD(at[37], at[94]); MULADD(at[38], at[93]); MULADD(at[39], at[92]); MULADD(at[40], at[91]); MULADD(at[41], at[90]); MULADD(at[42], at[89]); MULADD(at[43], at[88]); MULADD(at[44], at[87]); MULADD(at[45], at[86]); MULADD(at[46], at[85]); MULADD(at[47], at[84]); MULADD(at[48], at[83]); MULADD(at[49], at[82]); MULADD(at[50], at[81]); MULADD(at[51], at[80]); MULADD(at[52], at[79]); MULADD(at[53], at[78]); MULADD(at[54], at[77]); MULADD(at[55], at[76]); MULADD(at[56], at[75]); MULADD(at[57], at[74]); MULADD(at[58], at[73]); MULADD(at[59], at[72]); MULADD(at[60], at[71]); MULADD(at[61], at[70]); MULADD(at[62], at[69]); MULADD(at[63], at[68]); COMBA_STORE(C->dp[67]); /* 68 */ COMBA_FORWARD; MULADD(at[5], at[127]); MULADD(at[6], at[126]); MULADD(at[7], at[125]); MULADD(at[8], at[124]); MULADD(at[9], at[123]); MULADD(at[10], at[122]); MULADD(at[11], at[121]); MULADD(at[12], at[120]); MULADD(at[13], at[119]); MULADD(at[14], at[118]); MULADD(at[15], at[117]); MULADD(at[16], at[116]); MULADD(at[17], at[115]); MULADD(at[18], at[114]); MULADD(at[19], at[113]); MULADD(at[20], at[112]); MULADD(at[21], at[111]); MULADD(at[22], at[110]); MULADD(at[23], at[109]); MULADD(at[24], at[108]); MULADD(at[25], at[107]); MULADD(at[26], at[106]); MULADD(at[27], at[105]); MULADD(at[28], at[104]); MULADD(at[29], at[103]); MULADD(at[30], at[102]); MULADD(at[31], at[101]); MULADD(at[32], at[100]); MULADD(at[33], at[99]); MULADD(at[34], at[98]); MULADD(at[35], at[97]); MULADD(at[36], at[96]); MULADD(at[37], at[95]); MULADD(at[38], at[94]); MULADD(at[39], at[93]); MULADD(at[40], at[92]); MULADD(at[41], at[91]); MULADD(at[42], at[90]); MULADD(at[43], at[89]); MULADD(at[44], at[88]); MULADD(at[45], at[87]); MULADD(at[46], at[86]); MULADD(at[47], at[85]); MULADD(at[48], at[84]); MULADD(at[49], at[83]); MULADD(at[50], at[82]); MULADD(at[51], at[81]); MULADD(at[52], at[80]); MULADD(at[53], at[79]); MULADD(at[54], at[78]); MULADD(at[55], at[77]); MULADD(at[56], at[76]); MULADD(at[57], at[75]); MULADD(at[58], at[74]); MULADD(at[59], at[73]); MULADD(at[60], at[72]); MULADD(at[61], at[71]); MULADD(at[62], at[70]); MULADD(at[63], at[69]); COMBA_STORE(C->dp[68]); /* 69 */ COMBA_FORWARD; MULADD(at[6], at[127]); MULADD(at[7], at[126]); MULADD(at[8], at[125]); MULADD(at[9], at[124]); MULADD(at[10], at[123]); MULADD(at[11], at[122]); MULADD(at[12], at[121]); MULADD(at[13], at[120]); MULADD(at[14], at[119]); MULADD(at[15], at[118]); MULADD(at[16], at[117]); MULADD(at[17], at[116]); MULADD(at[18], at[115]); MULADD(at[19], at[114]); MULADD(at[20], at[113]); MULADD(at[21], at[112]); MULADD(at[22], at[111]); MULADD(at[23], at[110]); MULADD(at[24], at[109]); MULADD(at[25], at[108]); MULADD(at[26], at[107]); MULADD(at[27], at[106]); MULADD(at[28], at[105]); MULADD(at[29], at[104]); MULADD(at[30], at[103]); MULADD(at[31], at[102]); MULADD(at[32], at[101]); MULADD(at[33], at[100]); MULADD(at[34], at[99]); MULADD(at[35], at[98]); MULADD(at[36], at[97]); MULADD(at[37], at[96]); MULADD(at[38], at[95]); MULADD(at[39], at[94]); MULADD(at[40], at[93]); MULADD(at[41], at[92]); MULADD(at[42], at[91]); MULADD(at[43], at[90]); MULADD(at[44], at[89]); MULADD(at[45], at[88]); MULADD(at[46], at[87]); MULADD(at[47], at[86]); MULADD(at[48], at[85]); MULADD(at[49], at[84]); MULADD(at[50], at[83]); MULADD(at[51], at[82]); MULADD(at[52], at[81]); MULADD(at[53], at[80]); MULADD(at[54], at[79]); MULADD(at[55], at[78]); MULADD(at[56], at[77]); MULADD(at[57], at[76]); MULADD(at[58], at[75]); MULADD(at[59], at[74]); MULADD(at[60], at[73]); MULADD(at[61], at[72]); MULADD(at[62], at[71]); MULADD(at[63], at[70]); COMBA_STORE(C->dp[69]); /* 70 */ COMBA_FORWARD; MULADD(at[7], at[127]); MULADD(at[8], at[126]); MULADD(at[9], at[125]); MULADD(at[10], at[124]); MULADD(at[11], at[123]); MULADD(at[12], at[122]); MULADD(at[13], at[121]); MULADD(at[14], at[120]); MULADD(at[15], at[119]); MULADD(at[16], at[118]); MULADD(at[17], at[117]); MULADD(at[18], at[116]); MULADD(at[19], at[115]); MULADD(at[20], at[114]); MULADD(at[21], at[113]); MULADD(at[22], at[112]); MULADD(at[23], at[111]); MULADD(at[24], at[110]); MULADD(at[25], at[109]); MULADD(at[26], at[108]); MULADD(at[27], at[107]); MULADD(at[28], at[106]); MULADD(at[29], at[105]); MULADD(at[30], at[104]); MULADD(at[31], at[103]); MULADD(at[32], at[102]); MULADD(at[33], at[101]); MULADD(at[34], at[100]); MULADD(at[35], at[99]); MULADD(at[36], at[98]); MULADD(at[37], at[97]); MULADD(at[38], at[96]); MULADD(at[39], at[95]); MULADD(at[40], at[94]); MULADD(at[41], at[93]); MULADD(at[42], at[92]); MULADD(at[43], at[91]); MULADD(at[44], at[90]); MULADD(at[45], at[89]); MULADD(at[46], at[88]); MULADD(at[47], at[87]); MULADD(at[48], at[86]); MULADD(at[49], at[85]); MULADD(at[50], at[84]); MULADD(at[51], at[83]); MULADD(at[52], at[82]); MULADD(at[53], at[81]); MULADD(at[54], at[80]); MULADD(at[55], at[79]); MULADD(at[56], at[78]); MULADD(at[57], at[77]); MULADD(at[58], at[76]); MULADD(at[59], at[75]); MULADD(at[60], at[74]); MULADD(at[61], at[73]); MULADD(at[62], at[72]); MULADD(at[63], at[71]); COMBA_STORE(C->dp[70]); /* 71 */ COMBA_FORWARD; MULADD(at[8], at[127]); MULADD(at[9], at[126]); MULADD(at[10], at[125]); MULADD(at[11], at[124]); MULADD(at[12], at[123]); MULADD(at[13], at[122]); MULADD(at[14], at[121]); MULADD(at[15], at[120]); MULADD(at[16], at[119]); MULADD(at[17], at[118]); MULADD(at[18], at[117]); MULADD(at[19], at[116]); MULADD(at[20], at[115]); MULADD(at[21], at[114]); MULADD(at[22], at[113]); MULADD(at[23], at[112]); MULADD(at[24], at[111]); MULADD(at[25], at[110]); MULADD(at[26], at[109]); MULADD(at[27], at[108]); MULADD(at[28], at[107]); MULADD(at[29], at[106]); MULADD(at[30], at[105]); MULADD(at[31], at[104]); MULADD(at[32], at[103]); MULADD(at[33], at[102]); MULADD(at[34], at[101]); MULADD(at[35], at[100]); MULADD(at[36], at[99]); MULADD(at[37], at[98]); MULADD(at[38], at[97]); MULADD(at[39], at[96]); MULADD(at[40], at[95]); MULADD(at[41], at[94]); MULADD(at[42], at[93]); MULADD(at[43], at[92]); MULADD(at[44], at[91]); MULADD(at[45], at[90]); MULADD(at[46], at[89]); MULADD(at[47], at[88]); MULADD(at[48], at[87]); MULADD(at[49], at[86]); MULADD(at[50], at[85]); MULADD(at[51], at[84]); MULADD(at[52], at[83]); MULADD(at[53], at[82]); MULADD(at[54], at[81]); MULADD(at[55], at[80]); MULADD(at[56], at[79]); MULADD(at[57], at[78]); MULADD(at[58], at[77]); MULADD(at[59], at[76]); MULADD(at[60], at[75]); MULADD(at[61], at[74]); MULADD(at[62], at[73]); MULADD(at[63], at[72]); COMBA_STORE(C->dp[71]); /* 72 */ COMBA_FORWARD; MULADD(at[9], at[127]); MULADD(at[10], at[126]); MULADD(at[11], at[125]); MULADD(at[12], at[124]); MULADD(at[13], at[123]); MULADD(at[14], at[122]); MULADD(at[15], at[121]); MULADD(at[16], at[120]); MULADD(at[17], at[119]); MULADD(at[18], at[118]); MULADD(at[19], at[117]); MULADD(at[20], at[116]); MULADD(at[21], at[115]); MULADD(at[22], at[114]); MULADD(at[23], at[113]); MULADD(at[24], at[112]); MULADD(at[25], at[111]); MULADD(at[26], at[110]); MULADD(at[27], at[109]); MULADD(at[28], at[108]); MULADD(at[29], at[107]); MULADD(at[30], at[106]); MULADD(at[31], at[105]); MULADD(at[32], at[104]); MULADD(at[33], at[103]); MULADD(at[34], at[102]); MULADD(at[35], at[101]); MULADD(at[36], at[100]); MULADD(at[37], at[99]); MULADD(at[38], at[98]); MULADD(at[39], at[97]); MULADD(at[40], at[96]); MULADD(at[41], at[95]); MULADD(at[42], at[94]); MULADD(at[43], at[93]); MULADD(at[44], at[92]); MULADD(at[45], at[91]); MULADD(at[46], at[90]); MULADD(at[47], at[89]); MULADD(at[48], at[88]); MULADD(at[49], at[87]); MULADD(at[50], at[86]); MULADD(at[51], at[85]); MULADD(at[52], at[84]); MULADD(at[53], at[83]); MULADD(at[54], at[82]); MULADD(at[55], at[81]); MULADD(at[56], at[80]); MULADD(at[57], at[79]); MULADD(at[58], at[78]); MULADD(at[59], at[77]); MULADD(at[60], at[76]); MULADD(at[61], at[75]); MULADD(at[62], at[74]); MULADD(at[63], at[73]); COMBA_STORE(C->dp[72]); /* 73 */ COMBA_FORWARD; MULADD(at[10], at[127]); MULADD(at[11], at[126]); MULADD(at[12], at[125]); MULADD(at[13], at[124]); MULADD(at[14], at[123]); MULADD(at[15], at[122]); MULADD(at[16], at[121]); MULADD(at[17], at[120]); MULADD(at[18], at[119]); MULADD(at[19], at[118]); MULADD(at[20], at[117]); MULADD(at[21], at[116]); MULADD(at[22], at[115]); MULADD(at[23], at[114]); MULADD(at[24], at[113]); MULADD(at[25], at[112]); MULADD(at[26], at[111]); MULADD(at[27], at[110]); MULADD(at[28], at[109]); MULADD(at[29], at[108]); MULADD(at[30], at[107]); MULADD(at[31], at[106]); MULADD(at[32], at[105]); MULADD(at[33], at[104]); MULADD(at[34], at[103]); MULADD(at[35], at[102]); MULADD(at[36], at[101]); MULADD(at[37], at[100]); MULADD(at[38], at[99]); MULADD(at[39], at[98]); MULADD(at[40], at[97]); MULADD(at[41], at[96]); MULADD(at[42], at[95]); MULADD(at[43], at[94]); MULADD(at[44], at[93]); MULADD(at[45], at[92]); MULADD(at[46], at[91]); MULADD(at[47], at[90]); MULADD(at[48], at[89]); MULADD(at[49], at[88]); MULADD(at[50], at[87]); MULADD(at[51], at[86]); MULADD(at[52], at[85]); MULADD(at[53], at[84]); MULADD(at[54], at[83]); MULADD(at[55], at[82]); MULADD(at[56], at[81]); MULADD(at[57], at[80]); MULADD(at[58], at[79]); MULADD(at[59], at[78]); MULADD(at[60], at[77]); MULADD(at[61], at[76]); MULADD(at[62], at[75]); MULADD(at[63], at[74]); COMBA_STORE(C->dp[73]); /* 74 */ COMBA_FORWARD; MULADD(at[11], at[127]); MULADD(at[12], at[126]); MULADD(at[13], at[125]); MULADD(at[14], at[124]); MULADD(at[15], at[123]); MULADD(at[16], at[122]); MULADD(at[17], at[121]); MULADD(at[18], at[120]); MULADD(at[19], at[119]); MULADD(at[20], at[118]); MULADD(at[21], at[117]); MULADD(at[22], at[116]); MULADD(at[23], at[115]); MULADD(at[24], at[114]); MULADD(at[25], at[113]); MULADD(at[26], at[112]); MULADD(at[27], at[111]); MULADD(at[28], at[110]); MULADD(at[29], at[109]); MULADD(at[30], at[108]); MULADD(at[31], at[107]); MULADD(at[32], at[106]); MULADD(at[33], at[105]); MULADD(at[34], at[104]); MULADD(at[35], at[103]); MULADD(at[36], at[102]); MULADD(at[37], at[101]); MULADD(at[38], at[100]); MULADD(at[39], at[99]); MULADD(at[40], at[98]); MULADD(at[41], at[97]); MULADD(at[42], at[96]); MULADD(at[43], at[95]); MULADD(at[44], at[94]); MULADD(at[45], at[93]); MULADD(at[46], at[92]); MULADD(at[47], at[91]); MULADD(at[48], at[90]); MULADD(at[49], at[89]); MULADD(at[50], at[88]); MULADD(at[51], at[87]); MULADD(at[52], at[86]); MULADD(at[53], at[85]); MULADD(at[54], at[84]); MULADD(at[55], at[83]); MULADD(at[56], at[82]); MULADD(at[57], at[81]); MULADD(at[58], at[80]); MULADD(at[59], at[79]); MULADD(at[60], at[78]); MULADD(at[61], at[77]); MULADD(at[62], at[76]); MULADD(at[63], at[75]); COMBA_STORE(C->dp[74]); /* 75 */ COMBA_FORWARD; MULADD(at[12], at[127]); MULADD(at[13], at[126]); MULADD(at[14], at[125]); MULADD(at[15], at[124]); MULADD(at[16], at[123]); MULADD(at[17], at[122]); MULADD(at[18], at[121]); MULADD(at[19], at[120]); MULADD(at[20], at[119]); MULADD(at[21], at[118]); MULADD(at[22], at[117]); MULADD(at[23], at[116]); MULADD(at[24], at[115]); MULADD(at[25], at[114]); MULADD(at[26], at[113]); MULADD(at[27], at[112]); MULADD(at[28], at[111]); MULADD(at[29], at[110]); MULADD(at[30], at[109]); MULADD(at[31], at[108]); MULADD(at[32], at[107]); MULADD(at[33], at[106]); MULADD(at[34], at[105]); MULADD(at[35], at[104]); MULADD(at[36], at[103]); MULADD(at[37], at[102]); MULADD(at[38], at[101]); MULADD(at[39], at[100]); MULADD(at[40], at[99]); MULADD(at[41], at[98]); MULADD(at[42], at[97]); MULADD(at[43], at[96]); MULADD(at[44], at[95]); MULADD(at[45], at[94]); MULADD(at[46], at[93]); MULADD(at[47], at[92]); MULADD(at[48], at[91]); MULADD(at[49], at[90]); MULADD(at[50], at[89]); MULADD(at[51], at[88]); MULADD(at[52], at[87]); MULADD(at[53], at[86]); MULADD(at[54], at[85]); MULADD(at[55], at[84]); MULADD(at[56], at[83]); MULADD(at[57], at[82]); MULADD(at[58], at[81]); MULADD(at[59], at[80]); MULADD(at[60], at[79]); MULADD(at[61], at[78]); MULADD(at[62], at[77]); MULADD(at[63], at[76]); COMBA_STORE(C->dp[75]); /* 76 */ COMBA_FORWARD; MULADD(at[13], at[127]); MULADD(at[14], at[126]); MULADD(at[15], at[125]); MULADD(at[16], at[124]); MULADD(at[17], at[123]); MULADD(at[18], at[122]); MULADD(at[19], at[121]); MULADD(at[20], at[120]); MULADD(at[21], at[119]); MULADD(at[22], at[118]); MULADD(at[23], at[117]); MULADD(at[24], at[116]); MULADD(at[25], at[115]); MULADD(at[26], at[114]); MULADD(at[27], at[113]); MULADD(at[28], at[112]); MULADD(at[29], at[111]); MULADD(at[30], at[110]); MULADD(at[31], at[109]); MULADD(at[32], at[108]); MULADD(at[33], at[107]); MULADD(at[34], at[106]); MULADD(at[35], at[105]); MULADD(at[36], at[104]); MULADD(at[37], at[103]); MULADD(at[38], at[102]); MULADD(at[39], at[101]); MULADD(at[40], at[100]); MULADD(at[41], at[99]); MULADD(at[42], at[98]); MULADD(at[43], at[97]); MULADD(at[44], at[96]); MULADD(at[45], at[95]); MULADD(at[46], at[94]); MULADD(at[47], at[93]); MULADD(at[48], at[92]); MULADD(at[49], at[91]); MULADD(at[50], at[90]); MULADD(at[51], at[89]); MULADD(at[52], at[88]); MULADD(at[53], at[87]); MULADD(at[54], at[86]); MULADD(at[55], at[85]); MULADD(at[56], at[84]); MULADD(at[57], at[83]); MULADD(at[58], at[82]); MULADD(at[59], at[81]); MULADD(at[60], at[80]); MULADD(at[61], at[79]); MULADD(at[62], at[78]); MULADD(at[63], at[77]); COMBA_STORE(C->dp[76]); /* 77 */ COMBA_FORWARD; MULADD(at[14], at[127]); MULADD(at[15], at[126]); MULADD(at[16], at[125]); MULADD(at[17], at[124]); MULADD(at[18], at[123]); MULADD(at[19], at[122]); MULADD(at[20], at[121]); MULADD(at[21], at[120]); MULADD(at[22], at[119]); MULADD(at[23], at[118]); MULADD(at[24], at[117]); MULADD(at[25], at[116]); MULADD(at[26], at[115]); MULADD(at[27], at[114]); MULADD(at[28], at[113]); MULADD(at[29], at[112]); MULADD(at[30], at[111]); MULADD(at[31], at[110]); MULADD(at[32], at[109]); MULADD(at[33], at[108]); MULADD(at[34], at[107]); MULADD(at[35], at[106]); MULADD(at[36], at[105]); MULADD(at[37], at[104]); MULADD(at[38], at[103]); MULADD(at[39], at[102]); MULADD(at[40], at[101]); MULADD(at[41], at[100]); MULADD(at[42], at[99]); MULADD(at[43], at[98]); MULADD(at[44], at[97]); MULADD(at[45], at[96]); MULADD(at[46], at[95]); MULADD(at[47], at[94]); MULADD(at[48], at[93]); MULADD(at[49], at[92]); MULADD(at[50], at[91]); MULADD(at[51], at[90]); MULADD(at[52], at[89]); MULADD(at[53], at[88]); MULADD(at[54], at[87]); MULADD(at[55], at[86]); MULADD(at[56], at[85]); MULADD(at[57], at[84]); MULADD(at[58], at[83]); MULADD(at[59], at[82]); MULADD(at[60], at[81]); MULADD(at[61], at[80]); MULADD(at[62], at[79]); MULADD(at[63], at[78]); COMBA_STORE(C->dp[77]); /* 78 */ COMBA_FORWARD; MULADD(at[15], at[127]); MULADD(at[16], at[126]); MULADD(at[17], at[125]); MULADD(at[18], at[124]); MULADD(at[19], at[123]); MULADD(at[20], at[122]); MULADD(at[21], at[121]); MULADD(at[22], at[120]); MULADD(at[23], at[119]); MULADD(at[24], at[118]); MULADD(at[25], at[117]); MULADD(at[26], at[116]); MULADD(at[27], at[115]); MULADD(at[28], at[114]); MULADD(at[29], at[113]); MULADD(at[30], at[112]); MULADD(at[31], at[111]); MULADD(at[32], at[110]); MULADD(at[33], at[109]); MULADD(at[34], at[108]); MULADD(at[35], at[107]); MULADD(at[36], at[106]); MULADD(at[37], at[105]); MULADD(at[38], at[104]); MULADD(at[39], at[103]); MULADD(at[40], at[102]); MULADD(at[41], at[101]); MULADD(at[42], at[100]); MULADD(at[43], at[99]); MULADD(at[44], at[98]); MULADD(at[45], at[97]); MULADD(at[46], at[96]); MULADD(at[47], at[95]); MULADD(at[48], at[94]); MULADD(at[49], at[93]); MULADD(at[50], at[92]); MULADD(at[51], at[91]); MULADD(at[52], at[90]); MULADD(at[53], at[89]); MULADD(at[54], at[88]); MULADD(at[55], at[87]); MULADD(at[56], at[86]); MULADD(at[57], at[85]); MULADD(at[58], at[84]); MULADD(at[59], at[83]); MULADD(at[60], at[82]); MULADD(at[61], at[81]); MULADD(at[62], at[80]); MULADD(at[63], at[79]); COMBA_STORE(C->dp[78]); /* 79 */ COMBA_FORWARD; MULADD(at[16], at[127]); MULADD(at[17], at[126]); MULADD(at[18], at[125]); MULADD(at[19], at[124]); MULADD(at[20], at[123]); MULADD(at[21], at[122]); MULADD(at[22], at[121]); MULADD(at[23], at[120]); MULADD(at[24], at[119]); MULADD(at[25], at[118]); MULADD(at[26], at[117]); MULADD(at[27], at[116]); MULADD(at[28], at[115]); MULADD(at[29], at[114]); MULADD(at[30], at[113]); MULADD(at[31], at[112]); MULADD(at[32], at[111]); MULADD(at[33], at[110]); MULADD(at[34], at[109]); MULADD(at[35], at[108]); MULADD(at[36], at[107]); MULADD(at[37], at[106]); MULADD(at[38], at[105]); MULADD(at[39], at[104]); MULADD(at[40], at[103]); MULADD(at[41], at[102]); MULADD(at[42], at[101]); MULADD(at[43], at[100]); MULADD(at[44], at[99]); MULADD(at[45], at[98]); MULADD(at[46], at[97]); MULADD(at[47], at[96]); MULADD(at[48], at[95]); MULADD(at[49], at[94]); MULADD(at[50], at[93]); MULADD(at[51], at[92]); MULADD(at[52], at[91]); MULADD(at[53], at[90]); MULADD(at[54], at[89]); MULADD(at[55], at[88]); MULADD(at[56], at[87]); MULADD(at[57], at[86]); MULADD(at[58], at[85]); MULADD(at[59], at[84]); MULADD(at[60], at[83]); MULADD(at[61], at[82]); MULADD(at[62], at[81]); MULADD(at[63], at[80]); COMBA_STORE(C->dp[79]); /* 80 */ COMBA_FORWARD; MULADD(at[17], at[127]); MULADD(at[18], at[126]); MULADD(at[19], at[125]); MULADD(at[20], at[124]); MULADD(at[21], at[123]); MULADD(at[22], at[122]); MULADD(at[23], at[121]); MULADD(at[24], at[120]); MULADD(at[25], at[119]); MULADD(at[26], at[118]); MULADD(at[27], at[117]); MULADD(at[28], at[116]); MULADD(at[29], at[115]); MULADD(at[30], at[114]); MULADD(at[31], at[113]); MULADD(at[32], at[112]); MULADD(at[33], at[111]); MULADD(at[34], at[110]); MULADD(at[35], at[109]); MULADD(at[36], at[108]); MULADD(at[37], at[107]); MULADD(at[38], at[106]); MULADD(at[39], at[105]); MULADD(at[40], at[104]); MULADD(at[41], at[103]); MULADD(at[42], at[102]); MULADD(at[43], at[101]); MULADD(at[44], at[100]); MULADD(at[45], at[99]); MULADD(at[46], at[98]); MULADD(at[47], at[97]); MULADD(at[48], at[96]); MULADD(at[49], at[95]); MULADD(at[50], at[94]); MULADD(at[51], at[93]); MULADD(at[52], at[92]); MULADD(at[53], at[91]); MULADD(at[54], at[90]); MULADD(at[55], at[89]); MULADD(at[56], at[88]); MULADD(at[57], at[87]); MULADD(at[58], at[86]); MULADD(at[59], at[85]); MULADD(at[60], at[84]); MULADD(at[61], at[83]); MULADD(at[62], at[82]); MULADD(at[63], at[81]); COMBA_STORE(C->dp[80]); /* 81 */ COMBA_FORWARD; MULADD(at[18], at[127]); MULADD(at[19], at[126]); MULADD(at[20], at[125]); MULADD(at[21], at[124]); MULADD(at[22], at[123]); MULADD(at[23], at[122]); MULADD(at[24], at[121]); MULADD(at[25], at[120]); MULADD(at[26], at[119]); MULADD(at[27], at[118]); MULADD(at[28], at[117]); MULADD(at[29], at[116]); MULADD(at[30], at[115]); MULADD(at[31], at[114]); MULADD(at[32], at[113]); MULADD(at[33], at[112]); MULADD(at[34], at[111]); MULADD(at[35], at[110]); MULADD(at[36], at[109]); MULADD(at[37], at[108]); MULADD(at[38], at[107]); MULADD(at[39], at[106]); MULADD(at[40], at[105]); MULADD(at[41], at[104]); MULADD(at[42], at[103]); MULADD(at[43], at[102]); MULADD(at[44], at[101]); MULADD(at[45], at[100]); MULADD(at[46], at[99]); MULADD(at[47], at[98]); MULADD(at[48], at[97]); MULADD(at[49], at[96]); MULADD(at[50], at[95]); MULADD(at[51], at[94]); MULADD(at[52], at[93]); MULADD(at[53], at[92]); MULADD(at[54], at[91]); MULADD(at[55], at[90]); MULADD(at[56], at[89]); MULADD(at[57], at[88]); MULADD(at[58], at[87]); MULADD(at[59], at[86]); MULADD(at[60], at[85]); MULADD(at[61], at[84]); MULADD(at[62], at[83]); MULADD(at[63], at[82]); COMBA_STORE(C->dp[81]); /* 82 */ COMBA_FORWARD; MULADD(at[19], at[127]); MULADD(at[20], at[126]); MULADD(at[21], at[125]); MULADD(at[22], at[124]); MULADD(at[23], at[123]); MULADD(at[24], at[122]); MULADD(at[25], at[121]); MULADD(at[26], at[120]); MULADD(at[27], at[119]); MULADD(at[28], at[118]); MULADD(at[29], at[117]); MULADD(at[30], at[116]); MULADD(at[31], at[115]); MULADD(at[32], at[114]); MULADD(at[33], at[113]); MULADD(at[34], at[112]); MULADD(at[35], at[111]); MULADD(at[36], at[110]); MULADD(at[37], at[109]); MULADD(at[38], at[108]); MULADD(at[39], at[107]); MULADD(at[40], at[106]); MULADD(at[41], at[105]); MULADD(at[42], at[104]); MULADD(at[43], at[103]); MULADD(at[44], at[102]); MULADD(at[45], at[101]); MULADD(at[46], at[100]); MULADD(at[47], at[99]); MULADD(at[48], at[98]); MULADD(at[49], at[97]); MULADD(at[50], at[96]); MULADD(at[51], at[95]); MULADD(at[52], at[94]); MULADD(at[53], at[93]); MULADD(at[54], at[92]); MULADD(at[55], at[91]); MULADD(at[56], at[90]); MULADD(at[57], at[89]); MULADD(at[58], at[88]); MULADD(at[59], at[87]); MULADD(at[60], at[86]); MULADD(at[61], at[85]); MULADD(at[62], at[84]); MULADD(at[63], at[83]); COMBA_STORE(C->dp[82]); /* 83 */ COMBA_FORWARD; MULADD(at[20], at[127]); MULADD(at[21], at[126]); MULADD(at[22], at[125]); MULADD(at[23], at[124]); MULADD(at[24], at[123]); MULADD(at[25], at[122]); MULADD(at[26], at[121]); MULADD(at[27], at[120]); MULADD(at[28], at[119]); MULADD(at[29], at[118]); MULADD(at[30], at[117]); MULADD(at[31], at[116]); MULADD(at[32], at[115]); MULADD(at[33], at[114]); MULADD(at[34], at[113]); MULADD(at[35], at[112]); MULADD(at[36], at[111]); MULADD(at[37], at[110]); MULADD(at[38], at[109]); MULADD(at[39], at[108]); MULADD(at[40], at[107]); MULADD(at[41], at[106]); MULADD(at[42], at[105]); MULADD(at[43], at[104]); MULADD(at[44], at[103]); MULADD(at[45], at[102]); MULADD(at[46], at[101]); MULADD(at[47], at[100]); MULADD(at[48], at[99]); MULADD(at[49], at[98]); MULADD(at[50], at[97]); MULADD(at[51], at[96]); MULADD(at[52], at[95]); MULADD(at[53], at[94]); MULADD(at[54], at[93]); MULADD(at[55], at[92]); MULADD(at[56], at[91]); MULADD(at[57], at[90]); MULADD(at[58], at[89]); MULADD(at[59], at[88]); MULADD(at[60], at[87]); MULADD(at[61], at[86]); MULADD(at[62], at[85]); MULADD(at[63], at[84]); COMBA_STORE(C->dp[83]); /* 84 */ COMBA_FORWARD; MULADD(at[21], at[127]); MULADD(at[22], at[126]); MULADD(at[23], at[125]); MULADD(at[24], at[124]); MULADD(at[25], at[123]); MULADD(at[26], at[122]); MULADD(at[27], at[121]); MULADD(at[28], at[120]); MULADD(at[29], at[119]); MULADD(at[30], at[118]); MULADD(at[31], at[117]); MULADD(at[32], at[116]); MULADD(at[33], at[115]); MULADD(at[34], at[114]); MULADD(at[35], at[113]); MULADD(at[36], at[112]); MULADD(at[37], at[111]); MULADD(at[38], at[110]); MULADD(at[39], at[109]); MULADD(at[40], at[108]); MULADD(at[41], at[107]); MULADD(at[42], at[106]); MULADD(at[43], at[105]); MULADD(at[44], at[104]); MULADD(at[45], at[103]); MULADD(at[46], at[102]); MULADD(at[47], at[101]); MULADD(at[48], at[100]); MULADD(at[49], at[99]); MULADD(at[50], at[98]); MULADD(at[51], at[97]); MULADD(at[52], at[96]); MULADD(at[53], at[95]); MULADD(at[54], at[94]); MULADD(at[55], at[93]); MULADD(at[56], at[92]); MULADD(at[57], at[91]); MULADD(at[58], at[90]); MULADD(at[59], at[89]); MULADD(at[60], at[88]); MULADD(at[61], at[87]); MULADD(at[62], at[86]); MULADD(at[63], at[85]); COMBA_STORE(C->dp[84]); /* 85 */ COMBA_FORWARD; MULADD(at[22], at[127]); MULADD(at[23], at[126]); MULADD(at[24], at[125]); MULADD(at[25], at[124]); MULADD(at[26], at[123]); MULADD(at[27], at[122]); MULADD(at[28], at[121]); MULADD(at[29], at[120]); MULADD(at[30], at[119]); MULADD(at[31], at[118]); MULADD(at[32], at[117]); MULADD(at[33], at[116]); MULADD(at[34], at[115]); MULADD(at[35], at[114]); MULADD(at[36], at[113]); MULADD(at[37], at[112]); MULADD(at[38], at[111]); MULADD(at[39], at[110]); MULADD(at[40], at[109]); MULADD(at[41], at[108]); MULADD(at[42], at[107]); MULADD(at[43], at[106]); MULADD(at[44], at[105]); MULADD(at[45], at[104]); MULADD(at[46], at[103]); MULADD(at[47], at[102]); MULADD(at[48], at[101]); MULADD(at[49], at[100]); MULADD(at[50], at[99]); MULADD(at[51], at[98]); MULADD(at[52], at[97]); MULADD(at[53], at[96]); MULADD(at[54], at[95]); MULADD(at[55], at[94]); MULADD(at[56], at[93]); MULADD(at[57], at[92]); MULADD(at[58], at[91]); MULADD(at[59], at[90]); MULADD(at[60], at[89]); MULADD(at[61], at[88]); MULADD(at[62], at[87]); MULADD(at[63], at[86]); COMBA_STORE(C->dp[85]); /* 86 */ COMBA_FORWARD; MULADD(at[23], at[127]); MULADD(at[24], at[126]); MULADD(at[25], at[125]); MULADD(at[26], at[124]); MULADD(at[27], at[123]); MULADD(at[28], at[122]); MULADD(at[29], at[121]); MULADD(at[30], at[120]); MULADD(at[31], at[119]); MULADD(at[32], at[118]); MULADD(at[33], at[117]); MULADD(at[34], at[116]); MULADD(at[35], at[115]); MULADD(at[36], at[114]); MULADD(at[37], at[113]); MULADD(at[38], at[112]); MULADD(at[39], at[111]); MULADD(at[40], at[110]); MULADD(at[41], at[109]); MULADD(at[42], at[108]); MULADD(at[43], at[107]); MULADD(at[44], at[106]); MULADD(at[45], at[105]); MULADD(at[46], at[104]); MULADD(at[47], at[103]); MULADD(at[48], at[102]); MULADD(at[49], at[101]); MULADD(at[50], at[100]); MULADD(at[51], at[99]); MULADD(at[52], at[98]); MULADD(at[53], at[97]); MULADD(at[54], at[96]); MULADD(at[55], at[95]); MULADD(at[56], at[94]); MULADD(at[57], at[93]); MULADD(at[58], at[92]); MULADD(at[59], at[91]); MULADD(at[60], at[90]); MULADD(at[61], at[89]); MULADD(at[62], at[88]); MULADD(at[63], at[87]); COMBA_STORE(C->dp[86]); /* 87 */ COMBA_FORWARD; MULADD(at[24], at[127]); MULADD(at[25], at[126]); MULADD(at[26], at[125]); MULADD(at[27], at[124]); MULADD(at[28], at[123]); MULADD(at[29], at[122]); MULADD(at[30], at[121]); MULADD(at[31], at[120]); MULADD(at[32], at[119]); MULADD(at[33], at[118]); MULADD(at[34], at[117]); MULADD(at[35], at[116]); MULADD(at[36], at[115]); MULADD(at[37], at[114]); MULADD(at[38], at[113]); MULADD(at[39], at[112]); MULADD(at[40], at[111]); MULADD(at[41], at[110]); MULADD(at[42], at[109]); MULADD(at[43], at[108]); MULADD(at[44], at[107]); MULADD(at[45], at[106]); MULADD(at[46], at[105]); MULADD(at[47], at[104]); MULADD(at[48], at[103]); MULADD(at[49], at[102]); MULADD(at[50], at[101]); MULADD(at[51], at[100]); MULADD(at[52], at[99]); MULADD(at[53], at[98]); MULADD(at[54], at[97]); MULADD(at[55], at[96]); MULADD(at[56], at[95]); MULADD(at[57], at[94]); MULADD(at[58], at[93]); MULADD(at[59], at[92]); MULADD(at[60], at[91]); MULADD(at[61], at[90]); MULADD(at[62], at[89]); MULADD(at[63], at[88]); COMBA_STORE(C->dp[87]); /* 88 */ COMBA_FORWARD; MULADD(at[25], at[127]); MULADD(at[26], at[126]); MULADD(at[27], at[125]); MULADD(at[28], at[124]); MULADD(at[29], at[123]); MULADD(at[30], at[122]); MULADD(at[31], at[121]); MULADD(at[32], at[120]); MULADD(at[33], at[119]); MULADD(at[34], at[118]); MULADD(at[35], at[117]); MULADD(at[36], at[116]); MULADD(at[37], at[115]); MULADD(at[38], at[114]); MULADD(at[39], at[113]); MULADD(at[40], at[112]); MULADD(at[41], at[111]); MULADD(at[42], at[110]); MULADD(at[43], at[109]); MULADD(at[44], at[108]); MULADD(at[45], at[107]); MULADD(at[46], at[106]); MULADD(at[47], at[105]); MULADD(at[48], at[104]); MULADD(at[49], at[103]); MULADD(at[50], at[102]); MULADD(at[51], at[101]); MULADD(at[52], at[100]); MULADD(at[53], at[99]); MULADD(at[54], at[98]); MULADD(at[55], at[97]); MULADD(at[56], at[96]); MULADD(at[57], at[95]); MULADD(at[58], at[94]); MULADD(at[59], at[93]); MULADD(at[60], at[92]); MULADD(at[61], at[91]); MULADD(at[62], at[90]); MULADD(at[63], at[89]); COMBA_STORE(C->dp[88]); /* 89 */ COMBA_FORWARD; MULADD(at[26], at[127]); MULADD(at[27], at[126]); MULADD(at[28], at[125]); MULADD(at[29], at[124]); MULADD(at[30], at[123]); MULADD(at[31], at[122]); MULADD(at[32], at[121]); MULADD(at[33], at[120]); MULADD(at[34], at[119]); MULADD(at[35], at[118]); MULADD(at[36], at[117]); MULADD(at[37], at[116]); MULADD(at[38], at[115]); MULADD(at[39], at[114]); MULADD(at[40], at[113]); MULADD(at[41], at[112]); MULADD(at[42], at[111]); MULADD(at[43], at[110]); MULADD(at[44], at[109]); MULADD(at[45], at[108]); MULADD(at[46], at[107]); MULADD(at[47], at[106]); MULADD(at[48], at[105]); MULADD(at[49], at[104]); MULADD(at[50], at[103]); MULADD(at[51], at[102]); MULADD(at[52], at[101]); MULADD(at[53], at[100]); MULADD(at[54], at[99]); MULADD(at[55], at[98]); MULADD(at[56], at[97]); MULADD(at[57], at[96]); MULADD(at[58], at[95]); MULADD(at[59], at[94]); MULADD(at[60], at[93]); MULADD(at[61], at[92]); MULADD(at[62], at[91]); MULADD(at[63], at[90]); COMBA_STORE(C->dp[89]); /* 90 */ COMBA_FORWARD; MULADD(at[27], at[127]); MULADD(at[28], at[126]); MULADD(at[29], at[125]); MULADD(at[30], at[124]); MULADD(at[31], at[123]); MULADD(at[32], at[122]); MULADD(at[33], at[121]); MULADD(at[34], at[120]); MULADD(at[35], at[119]); MULADD(at[36], at[118]); MULADD(at[37], at[117]); MULADD(at[38], at[116]); MULADD(at[39], at[115]); MULADD(at[40], at[114]); MULADD(at[41], at[113]); MULADD(at[42], at[112]); MULADD(at[43], at[111]); MULADD(at[44], at[110]); MULADD(at[45], at[109]); MULADD(at[46], at[108]); MULADD(at[47], at[107]); MULADD(at[48], at[106]); MULADD(at[49], at[105]); MULADD(at[50], at[104]); MULADD(at[51], at[103]); MULADD(at[52], at[102]); MULADD(at[53], at[101]); MULADD(at[54], at[100]); MULADD(at[55], at[99]); MULADD(at[56], at[98]); MULADD(at[57], at[97]); MULADD(at[58], at[96]); MULADD(at[59], at[95]); MULADD(at[60], at[94]); MULADD(at[61], at[93]); MULADD(at[62], at[92]); MULADD(at[63], at[91]); COMBA_STORE(C->dp[90]); /* 91 */ COMBA_FORWARD; MULADD(at[28], at[127]); MULADD(at[29], at[126]); MULADD(at[30], at[125]); MULADD(at[31], at[124]); MULADD(at[32], at[123]); MULADD(at[33], at[122]); MULADD(at[34], at[121]); MULADD(at[35], at[120]); MULADD(at[36], at[119]); MULADD(at[37], at[118]); MULADD(at[38], at[117]); MULADD(at[39], at[116]); MULADD(at[40], at[115]); MULADD(at[41], at[114]); MULADD(at[42], at[113]); MULADD(at[43], at[112]); MULADD(at[44], at[111]); MULADD(at[45], at[110]); MULADD(at[46], at[109]); MULADD(at[47], at[108]); MULADD(at[48], at[107]); MULADD(at[49], at[106]); MULADD(at[50], at[105]); MULADD(at[51], at[104]); MULADD(at[52], at[103]); MULADD(at[53], at[102]); MULADD(at[54], at[101]); MULADD(at[55], at[100]); MULADD(at[56], at[99]); MULADD(at[57], at[98]); MULADD(at[58], at[97]); MULADD(at[59], at[96]); MULADD(at[60], at[95]); MULADD(at[61], at[94]); MULADD(at[62], at[93]); MULADD(at[63], at[92]); COMBA_STORE(C->dp[91]); /* 92 */ COMBA_FORWARD; MULADD(at[29], at[127]); MULADD(at[30], at[126]); MULADD(at[31], at[125]); MULADD(at[32], at[124]); MULADD(at[33], at[123]); MULADD(at[34], at[122]); MULADD(at[35], at[121]); MULADD(at[36], at[120]); MULADD(at[37], at[119]); MULADD(at[38], at[118]); MULADD(at[39], at[117]); MULADD(at[40], at[116]); MULADD(at[41], at[115]); MULADD(at[42], at[114]); MULADD(at[43], at[113]); MULADD(at[44], at[112]); MULADD(at[45], at[111]); MULADD(at[46], at[110]); MULADD(at[47], at[109]); MULADD(at[48], at[108]); MULADD(at[49], at[107]); MULADD(at[50], at[106]); MULADD(at[51], at[105]); MULADD(at[52], at[104]); MULADD(at[53], at[103]); MULADD(at[54], at[102]); MULADD(at[55], at[101]); MULADD(at[56], at[100]); MULADD(at[57], at[99]); MULADD(at[58], at[98]); MULADD(at[59], at[97]); MULADD(at[60], at[96]); MULADD(at[61], at[95]); MULADD(at[62], at[94]); MULADD(at[63], at[93]); COMBA_STORE(C->dp[92]); /* 93 */ COMBA_FORWARD; MULADD(at[30], at[127]); MULADD(at[31], at[126]); MULADD(at[32], at[125]); MULADD(at[33], at[124]); MULADD(at[34], at[123]); MULADD(at[35], at[122]); MULADD(at[36], at[121]); MULADD(at[37], at[120]); MULADD(at[38], at[119]); MULADD(at[39], at[118]); MULADD(at[40], at[117]); MULADD(at[41], at[116]); MULADD(at[42], at[115]); MULADD(at[43], at[114]); MULADD(at[44], at[113]); MULADD(at[45], at[112]); MULADD(at[46], at[111]); MULADD(at[47], at[110]); MULADD(at[48], at[109]); MULADD(at[49], at[108]); MULADD(at[50], at[107]); MULADD(at[51], at[106]); MULADD(at[52], at[105]); MULADD(at[53], at[104]); MULADD(at[54], at[103]); MULADD(at[55], at[102]); MULADD(at[56], at[101]); MULADD(at[57], at[100]); MULADD(at[58], at[99]); MULADD(at[59], at[98]); MULADD(at[60], at[97]); MULADD(at[61], at[96]); MULADD(at[62], at[95]); MULADD(at[63], at[94]); COMBA_STORE(C->dp[93]); /* 94 */ COMBA_FORWARD; MULADD(at[31], at[127]); MULADD(at[32], at[126]); MULADD(at[33], at[125]); MULADD(at[34], at[124]); MULADD(at[35], at[123]); MULADD(at[36], at[122]); MULADD(at[37], at[121]); MULADD(at[38], at[120]); MULADD(at[39], at[119]); MULADD(at[40], at[118]); MULADD(at[41], at[117]); MULADD(at[42], at[116]); MULADD(at[43], at[115]); MULADD(at[44], at[114]); MULADD(at[45], at[113]); MULADD(at[46], at[112]); MULADD(at[47], at[111]); MULADD(at[48], at[110]); MULADD(at[49], at[109]); MULADD(at[50], at[108]); MULADD(at[51], at[107]); MULADD(at[52], at[106]); MULADD(at[53], at[105]); MULADD(at[54], at[104]); MULADD(at[55], at[103]); MULADD(at[56], at[102]); MULADD(at[57], at[101]); MULADD(at[58], at[100]); MULADD(at[59], at[99]); MULADD(at[60], at[98]); MULADD(at[61], at[97]); MULADD(at[62], at[96]); MULADD(at[63], at[95]); COMBA_STORE(C->dp[94]); /* 95 */ COMBA_FORWARD; MULADD(at[32], at[127]); MULADD(at[33], at[126]); MULADD(at[34], at[125]); MULADD(at[35], at[124]); MULADD(at[36], at[123]); MULADD(at[37], at[122]); MULADD(at[38], at[121]); MULADD(at[39], at[120]); MULADD(at[40], at[119]); MULADD(at[41], at[118]); MULADD(at[42], at[117]); MULADD(at[43], at[116]); MULADD(at[44], at[115]); MULADD(at[45], at[114]); MULADD(at[46], at[113]); MULADD(at[47], at[112]); MULADD(at[48], at[111]); MULADD(at[49], at[110]); MULADD(at[50], at[109]); MULADD(at[51], at[108]); MULADD(at[52], at[107]); MULADD(at[53], at[106]); MULADD(at[54], at[105]); MULADD(at[55], at[104]); MULADD(at[56], at[103]); MULADD(at[57], at[102]); MULADD(at[58], at[101]); MULADD(at[59], at[100]); MULADD(at[60], at[99]); MULADD(at[61], at[98]); MULADD(at[62], at[97]); MULADD(at[63], at[96]); COMBA_STORE(C->dp[95]); /* 96 */ COMBA_FORWARD; MULADD(at[33], at[127]); MULADD(at[34], at[126]); MULADD(at[35], at[125]); MULADD(at[36], at[124]); MULADD(at[37], at[123]); MULADD(at[38], at[122]); MULADD(at[39], at[121]); MULADD(at[40], at[120]); MULADD(at[41], at[119]); MULADD(at[42], at[118]); MULADD(at[43], at[117]); MULADD(at[44], at[116]); MULADD(at[45], at[115]); MULADD(at[46], at[114]); MULADD(at[47], at[113]); MULADD(at[48], at[112]); MULADD(at[49], at[111]); MULADD(at[50], at[110]); MULADD(at[51], at[109]); MULADD(at[52], at[108]); MULADD(at[53], at[107]); MULADD(at[54], at[106]); MULADD(at[55], at[105]); MULADD(at[56], at[104]); MULADD(at[57], at[103]); MULADD(at[58], at[102]); MULADD(at[59], at[101]); MULADD(at[60], at[100]); MULADD(at[61], at[99]); MULADD(at[62], at[98]); MULADD(at[63], at[97]); COMBA_STORE(C->dp[96]); /* 97 */ COMBA_FORWARD; MULADD(at[34], at[127]); MULADD(at[35], at[126]); MULADD(at[36], at[125]); MULADD(at[37], at[124]); MULADD(at[38], at[123]); MULADD(at[39], at[122]); MULADD(at[40], at[121]); MULADD(at[41], at[120]); MULADD(at[42], at[119]); MULADD(at[43], at[118]); MULADD(at[44], at[117]); MULADD(at[45], at[116]); MULADD(at[46], at[115]); MULADD(at[47], at[114]); MULADD(at[48], at[113]); MULADD(at[49], at[112]); MULADD(at[50], at[111]); MULADD(at[51], at[110]); MULADD(at[52], at[109]); MULADD(at[53], at[108]); MULADD(at[54], at[107]); MULADD(at[55], at[106]); MULADD(at[56], at[105]); MULADD(at[57], at[104]); MULADD(at[58], at[103]); MULADD(at[59], at[102]); MULADD(at[60], at[101]); MULADD(at[61], at[100]); MULADD(at[62], at[99]); MULADD(at[63], at[98]); COMBA_STORE(C->dp[97]); /* 98 */ COMBA_FORWARD; MULADD(at[35], at[127]); MULADD(at[36], at[126]); MULADD(at[37], at[125]); MULADD(at[38], at[124]); MULADD(at[39], at[123]); MULADD(at[40], at[122]); MULADD(at[41], at[121]); MULADD(at[42], at[120]); MULADD(at[43], at[119]); MULADD(at[44], at[118]); MULADD(at[45], at[117]); MULADD(at[46], at[116]); MULADD(at[47], at[115]); MULADD(at[48], at[114]); MULADD(at[49], at[113]); MULADD(at[50], at[112]); MULADD(at[51], at[111]); MULADD(at[52], at[110]); MULADD(at[53], at[109]); MULADD(at[54], at[108]); MULADD(at[55], at[107]); MULADD(at[56], at[106]); MULADD(at[57], at[105]); MULADD(at[58], at[104]); MULADD(at[59], at[103]); MULADD(at[60], at[102]); MULADD(at[61], at[101]); MULADD(at[62], at[100]); MULADD(at[63], at[99]); COMBA_STORE(C->dp[98]); /* 99 */ COMBA_FORWARD; MULADD(at[36], at[127]); MULADD(at[37], at[126]); MULADD(at[38], at[125]); MULADD(at[39], at[124]); MULADD(at[40], at[123]); MULADD(at[41], at[122]); MULADD(at[42], at[121]); MULADD(at[43], at[120]); MULADD(at[44], at[119]); MULADD(at[45], at[118]); MULADD(at[46], at[117]); MULADD(at[47], at[116]); MULADD(at[48], at[115]); MULADD(at[49], at[114]); MULADD(at[50], at[113]); MULADD(at[51], at[112]); MULADD(at[52], at[111]); MULADD(at[53], at[110]); MULADD(at[54], at[109]); MULADD(at[55], at[108]); MULADD(at[56], at[107]); MULADD(at[57], at[106]); MULADD(at[58], at[105]); MULADD(at[59], at[104]); MULADD(at[60], at[103]); MULADD(at[61], at[102]); MULADD(at[62], at[101]); MULADD(at[63], at[100]); COMBA_STORE(C->dp[99]); /* 100 */ COMBA_FORWARD; MULADD(at[37], at[127]); MULADD(at[38], at[126]); MULADD(at[39], at[125]); MULADD(at[40], at[124]); MULADD(at[41], at[123]); MULADD(at[42], at[122]); MULADD(at[43], at[121]); MULADD(at[44], at[120]); MULADD(at[45], at[119]); MULADD(at[46], at[118]); MULADD(at[47], at[117]); MULADD(at[48], at[116]); MULADD(at[49], at[115]); MULADD(at[50], at[114]); MULADD(at[51], at[113]); MULADD(at[52], at[112]); MULADD(at[53], at[111]); MULADD(at[54], at[110]); MULADD(at[55], at[109]); MULADD(at[56], at[108]); MULADD(at[57], at[107]); MULADD(at[58], at[106]); MULADD(at[59], at[105]); MULADD(at[60], at[104]); MULADD(at[61], at[103]); MULADD(at[62], at[102]); MULADD(at[63], at[101]); COMBA_STORE(C->dp[100]); /* 101 */ COMBA_FORWARD; MULADD(at[38], at[127]); MULADD(at[39], at[126]); MULADD(at[40], at[125]); MULADD(at[41], at[124]); MULADD(at[42], at[123]); MULADD(at[43], at[122]); MULADD(at[44], at[121]); MULADD(at[45], at[120]); MULADD(at[46], at[119]); MULADD(at[47], at[118]); MULADD(at[48], at[117]); MULADD(at[49], at[116]); MULADD(at[50], at[115]); MULADD(at[51], at[114]); MULADD(at[52], at[113]); MULADD(at[53], at[112]); MULADD(at[54], at[111]); MULADD(at[55], at[110]); MULADD(at[56], at[109]); MULADD(at[57], at[108]); MULADD(at[58], at[107]); MULADD(at[59], at[106]); MULADD(at[60], at[105]); MULADD(at[61], at[104]); MULADD(at[62], at[103]); MULADD(at[63], at[102]); COMBA_STORE(C->dp[101]); /* 102 */ COMBA_FORWARD; MULADD(at[39], at[127]); MULADD(at[40], at[126]); MULADD(at[41], at[125]); MULADD(at[42], at[124]); MULADD(at[43], at[123]); MULADD(at[44], at[122]); MULADD(at[45], at[121]); MULADD(at[46], at[120]); MULADD(at[47], at[119]); MULADD(at[48], at[118]); MULADD(at[49], at[117]); MULADD(at[50], at[116]); MULADD(at[51], at[115]); MULADD(at[52], at[114]); MULADD(at[53], at[113]); MULADD(at[54], at[112]); MULADD(at[55], at[111]); MULADD(at[56], at[110]); MULADD(at[57], at[109]); MULADD(at[58], at[108]); MULADD(at[59], at[107]); MULADD(at[60], at[106]); MULADD(at[61], at[105]); MULADD(at[62], at[104]); MULADD(at[63], at[103]); COMBA_STORE(C->dp[102]); /* 103 */ COMBA_FORWARD; MULADD(at[40], at[127]); MULADD(at[41], at[126]); MULADD(at[42], at[125]); MULADD(at[43], at[124]); MULADD(at[44], at[123]); MULADD(at[45], at[122]); MULADD(at[46], at[121]); MULADD(at[47], at[120]); MULADD(at[48], at[119]); MULADD(at[49], at[118]); MULADD(at[50], at[117]); MULADD(at[51], at[116]); MULADD(at[52], at[115]); MULADD(at[53], at[114]); MULADD(at[54], at[113]); MULADD(at[55], at[112]); MULADD(at[56], at[111]); MULADD(at[57], at[110]); MULADD(at[58], at[109]); MULADD(at[59], at[108]); MULADD(at[60], at[107]); MULADD(at[61], at[106]); MULADD(at[62], at[105]); MULADD(at[63], at[104]); COMBA_STORE(C->dp[103]); /* 104 */ COMBA_FORWARD; MULADD(at[41], at[127]); MULADD(at[42], at[126]); MULADD(at[43], at[125]); MULADD(at[44], at[124]); MULADD(at[45], at[123]); MULADD(at[46], at[122]); MULADD(at[47], at[121]); MULADD(at[48], at[120]); MULADD(at[49], at[119]); MULADD(at[50], at[118]); MULADD(at[51], at[117]); MULADD(at[52], at[116]); MULADD(at[53], at[115]); MULADD(at[54], at[114]); MULADD(at[55], at[113]); MULADD(at[56], at[112]); MULADD(at[57], at[111]); MULADD(at[58], at[110]); MULADD(at[59], at[109]); MULADD(at[60], at[108]); MULADD(at[61], at[107]); MULADD(at[62], at[106]); MULADD(at[63], at[105]); COMBA_STORE(C->dp[104]); /* 105 */ COMBA_FORWARD; MULADD(at[42], at[127]); MULADD(at[43], at[126]); MULADD(at[44], at[125]); MULADD(at[45], at[124]); MULADD(at[46], at[123]); MULADD(at[47], at[122]); MULADD(at[48], at[121]); MULADD(at[49], at[120]); MULADD(at[50], at[119]); MULADD(at[51], at[118]); MULADD(at[52], at[117]); MULADD(at[53], at[116]); MULADD(at[54], at[115]); MULADD(at[55], at[114]); MULADD(at[56], at[113]); MULADD(at[57], at[112]); MULADD(at[58], at[111]); MULADD(at[59], at[110]); MULADD(at[60], at[109]); MULADD(at[61], at[108]); MULADD(at[62], at[107]); MULADD(at[63], at[106]); COMBA_STORE(C->dp[105]); /* 106 */ COMBA_FORWARD; MULADD(at[43], at[127]); MULADD(at[44], at[126]); MULADD(at[45], at[125]); MULADD(at[46], at[124]); MULADD(at[47], at[123]); MULADD(at[48], at[122]); MULADD(at[49], at[121]); MULADD(at[50], at[120]); MULADD(at[51], at[119]); MULADD(at[52], at[118]); MULADD(at[53], at[117]); MULADD(at[54], at[116]); MULADD(at[55], at[115]); MULADD(at[56], at[114]); MULADD(at[57], at[113]); MULADD(at[58], at[112]); MULADD(at[59], at[111]); MULADD(at[60], at[110]); MULADD(at[61], at[109]); MULADD(at[62], at[108]); MULADD(at[63], at[107]); COMBA_STORE(C->dp[106]); /* 107 */ COMBA_FORWARD; MULADD(at[44], at[127]); MULADD(at[45], at[126]); MULADD(at[46], at[125]); MULADD(at[47], at[124]); MULADD(at[48], at[123]); MULADD(at[49], at[122]); MULADD(at[50], at[121]); MULADD(at[51], at[120]); MULADD(at[52], at[119]); MULADD(at[53], at[118]); MULADD(at[54], at[117]); MULADD(at[55], at[116]); MULADD(at[56], at[115]); MULADD(at[57], at[114]); MULADD(at[58], at[113]); MULADD(at[59], at[112]); MULADD(at[60], at[111]); MULADD(at[61], at[110]); MULADD(at[62], at[109]); MULADD(at[63], at[108]); COMBA_STORE(C->dp[107]); /* 108 */ COMBA_FORWARD; MULADD(at[45], at[127]); MULADD(at[46], at[126]); MULADD(at[47], at[125]); MULADD(at[48], at[124]); MULADD(at[49], at[123]); MULADD(at[50], at[122]); MULADD(at[51], at[121]); MULADD(at[52], at[120]); MULADD(at[53], at[119]); MULADD(at[54], at[118]); MULADD(at[55], at[117]); MULADD(at[56], at[116]); MULADD(at[57], at[115]); MULADD(at[58], at[114]); MULADD(at[59], at[113]); MULADD(at[60], at[112]); MULADD(at[61], at[111]); MULADD(at[62], at[110]); MULADD(at[63], at[109]); COMBA_STORE(C->dp[108]); /* 109 */ COMBA_FORWARD; MULADD(at[46], at[127]); MULADD(at[47], at[126]); MULADD(at[48], at[125]); MULADD(at[49], at[124]); MULADD(at[50], at[123]); MULADD(at[51], at[122]); MULADD(at[52], at[121]); MULADD(at[53], at[120]); MULADD(at[54], at[119]); MULADD(at[55], at[118]); MULADD(at[56], at[117]); MULADD(at[57], at[116]); MULADD(at[58], at[115]); MULADD(at[59], at[114]); MULADD(at[60], at[113]); MULADD(at[61], at[112]); MULADD(at[62], at[111]); MULADD(at[63], at[110]); COMBA_STORE(C->dp[109]); /* 110 */ COMBA_FORWARD; MULADD(at[47], at[127]); MULADD(at[48], at[126]); MULADD(at[49], at[125]); MULADD(at[50], at[124]); MULADD(at[51], at[123]); MULADD(at[52], at[122]); MULADD(at[53], at[121]); MULADD(at[54], at[120]); MULADD(at[55], at[119]); MULADD(at[56], at[118]); MULADD(at[57], at[117]); MULADD(at[58], at[116]); MULADD(at[59], at[115]); MULADD(at[60], at[114]); MULADD(at[61], at[113]); MULADD(at[62], at[112]); MULADD(at[63], at[111]); COMBA_STORE(C->dp[110]); /* 111 */ COMBA_FORWARD; MULADD(at[48], at[127]); MULADD(at[49], at[126]); MULADD(at[50], at[125]); MULADD(at[51], at[124]); MULADD(at[52], at[123]); MULADD(at[53], at[122]); MULADD(at[54], at[121]); MULADD(at[55], at[120]); MULADD(at[56], at[119]); MULADD(at[57], at[118]); MULADD(at[58], at[117]); MULADD(at[59], at[116]); MULADD(at[60], at[115]); MULADD(at[61], at[114]); MULADD(at[62], at[113]); MULADD(at[63], at[112]); COMBA_STORE(C->dp[111]); /* 112 */ COMBA_FORWARD; MULADD(at[49], at[127]); MULADD(at[50], at[126]); MULADD(at[51], at[125]); MULADD(at[52], at[124]); MULADD(at[53], at[123]); MULADD(at[54], at[122]); MULADD(at[55], at[121]); MULADD(at[56], at[120]); MULADD(at[57], at[119]); MULADD(at[58], at[118]); MULADD(at[59], at[117]); MULADD(at[60], at[116]); MULADD(at[61], at[115]); MULADD(at[62], at[114]); MULADD(at[63], at[113]); COMBA_STORE(C->dp[112]); /* 113 */ COMBA_FORWARD; MULADD(at[50], at[127]); MULADD(at[51], at[126]); MULADD(at[52], at[125]); MULADD(at[53], at[124]); MULADD(at[54], at[123]); MULADD(at[55], at[122]); MULADD(at[56], at[121]); MULADD(at[57], at[120]); MULADD(at[58], at[119]); MULADD(at[59], at[118]); MULADD(at[60], at[117]); MULADD(at[61], at[116]); MULADD(at[62], at[115]); MULADD(at[63], at[114]); COMBA_STORE(C->dp[113]); /* 114 */ COMBA_FORWARD; MULADD(at[51], at[127]); MULADD(at[52], at[126]); MULADD(at[53], at[125]); MULADD(at[54], at[124]); MULADD(at[55], at[123]); MULADD(at[56], at[122]); MULADD(at[57], at[121]); MULADD(at[58], at[120]); MULADD(at[59], at[119]); MULADD(at[60], at[118]); MULADD(at[61], at[117]); MULADD(at[62], at[116]); MULADD(at[63], at[115]); COMBA_STORE(C->dp[114]); /* 115 */ COMBA_FORWARD; MULADD(at[52], at[127]); MULADD(at[53], at[126]); MULADD(at[54], at[125]); MULADD(at[55], at[124]); MULADD(at[56], at[123]); MULADD(at[57], at[122]); MULADD(at[58], at[121]); MULADD(at[59], at[120]); MULADD(at[60], at[119]); MULADD(at[61], at[118]); MULADD(at[62], at[117]); MULADD(at[63], at[116]); COMBA_STORE(C->dp[115]); /* 116 */ COMBA_FORWARD; MULADD(at[53], at[127]); MULADD(at[54], at[126]); MULADD(at[55], at[125]); MULADD(at[56], at[124]); MULADD(at[57], at[123]); MULADD(at[58], at[122]); MULADD(at[59], at[121]); MULADD(at[60], at[120]); MULADD(at[61], at[119]); MULADD(at[62], at[118]); MULADD(at[63], at[117]); COMBA_STORE(C->dp[116]); /* 117 */ COMBA_FORWARD; MULADD(at[54], at[127]); MULADD(at[55], at[126]); MULADD(at[56], at[125]); MULADD(at[57], at[124]); MULADD(at[58], at[123]); MULADD(at[59], at[122]); MULADD(at[60], at[121]); MULADD(at[61], at[120]); MULADD(at[62], at[119]); MULADD(at[63], at[118]); COMBA_STORE(C->dp[117]); /* 118 */ COMBA_FORWARD; MULADD(at[55], at[127]); MULADD(at[56], at[126]); MULADD(at[57], at[125]); MULADD(at[58], at[124]); MULADD(at[59], at[123]); MULADD(at[60], at[122]); MULADD(at[61], at[121]); MULADD(at[62], at[120]); MULADD(at[63], at[119]); COMBA_STORE(C->dp[118]); /* 119 */ COMBA_FORWARD; MULADD(at[56], at[127]); MULADD(at[57], at[126]); MULADD(at[58], at[125]); MULADD(at[59], at[124]); MULADD(at[60], at[123]); MULADD(at[61], at[122]); MULADD(at[62], at[121]); MULADD(at[63], at[120]); COMBA_STORE(C->dp[119]); /* 120 */ COMBA_FORWARD; MULADD(at[57], at[127]); MULADD(at[58], at[126]); MULADD(at[59], at[125]); MULADD(at[60], at[124]); MULADD(at[61], at[123]); MULADD(at[62], at[122]); MULADD(at[63], at[121]); COMBA_STORE(C->dp[120]); /* 121 */ COMBA_FORWARD; MULADD(at[58], at[127]); MULADD(at[59], at[126]); MULADD(at[60], at[125]); MULADD(at[61], at[124]); MULADD(at[62], at[123]); MULADD(at[63], at[122]); COMBA_STORE(C->dp[121]); /* 122 */ COMBA_FORWARD; MULADD(at[59], at[127]); MULADD(at[60], at[126]); MULADD(at[61], at[125]); MULADD(at[62], at[124]); MULADD(at[63], at[123]); COMBA_STORE(C->dp[122]); /* 123 */ COMBA_FORWARD; MULADD(at[60], at[127]); MULADD(at[61], at[126]); MULADD(at[62], at[125]); MULADD(at[63], at[124]); COMBA_STORE(C->dp[123]); /* 124 */ COMBA_FORWARD; MULADD(at[61], at[127]); MULADD(at[62], at[126]); MULADD(at[63], at[125]); COMBA_STORE(C->dp[124]); /* 125 */ COMBA_FORWARD; MULADD(at[62], at[127]); MULADD(at[63], at[126]); COMBA_STORE(C->dp[125]); /* 126 */ COMBA_FORWARD; MULADD(at[63], at[127]); COMBA_STORE(C->dp[126]); COMBA_STORE2(C->dp[127]); C->used = 128; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; } #endif /* End: src/mul/fp_mul_comba_64.c */ /* Start: src/mul/fp_mul_comba_7.c */ #define TFM_DEFINES //#include "fp_mul_comba.c" #ifdef TFM_MUL7 void fp_mul_comba7(fp_int *A, fp_int *B, fp_int *C) { fp_digit c0, c1, c2, at[14]; memcpy(at, A->dp, 7 * sizeof(fp_digit)); memcpy(at+7, B->dp, 7 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[7]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[8]); MULADD(at[1], at[7]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[9]); MULADD(at[1], at[8]); MULADD(at[2], at[7]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[10]); MULADD(at[1], at[9]); MULADD(at[2], at[8]); MULADD(at[3], at[7]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[11]); MULADD(at[1], at[10]); MULADD(at[2], at[9]); MULADD(at[3], at[8]); MULADD(at[4], at[7]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[12]); MULADD(at[1], at[11]); MULADD(at[2], at[10]); MULADD(at[3], at[9]); MULADD(at[4], at[8]); MULADD(at[5], at[7]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[13]); MULADD(at[1], at[12]); MULADD(at[2], at[11]); MULADD(at[3], at[10]); MULADD(at[4], at[9]); MULADD(at[5], at[8]); MULADD(at[6], at[7]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[1], at[13]); MULADD(at[2], at[12]); MULADD(at[3], at[11]); MULADD(at[4], at[10]); MULADD(at[5], at[9]); MULADD(at[6], at[8]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[2], at[13]); MULADD(at[3], at[12]); MULADD(at[4], at[11]); MULADD(at[5], at[10]); MULADD(at[6], at[9]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[3], at[13]); MULADD(at[4], at[12]); MULADD(at[5], at[11]); MULADD(at[6], at[10]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[4], at[13]); MULADD(at[5], at[12]); MULADD(at[6], at[11]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[5], at[13]); MULADD(at[6], at[12]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[6], at[13]); COMBA_STORE(C->dp[12]); COMBA_STORE2(C->dp[13]); C->used = 14; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; } #endif /* End: src/mul/fp_mul_comba_7.c */ /* Start: src/mul/fp_mul_comba_8.c */ #define TFM_DEFINES //#include "fp_mul_comba.c" #ifdef TFM_MUL8 void fp_mul_comba8(fp_int *A, fp_int *B, fp_int *C) { fp_digit c0, c1, c2, at[16]; memcpy(at, A->dp, 8 * sizeof(fp_digit)); memcpy(at+8, B->dp, 8 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[8]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[9]); MULADD(at[1], at[8]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[10]); MULADD(at[1], at[9]); MULADD(at[2], at[8]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[11]); MULADD(at[1], at[10]); MULADD(at[2], at[9]); MULADD(at[3], at[8]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[12]); MULADD(at[1], at[11]); MULADD(at[2], at[10]); MULADD(at[3], at[9]); MULADD(at[4], at[8]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[13]); MULADD(at[1], at[12]); MULADD(at[2], at[11]); MULADD(at[3], at[10]); MULADD(at[4], at[9]); MULADD(at[5], at[8]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[14]); MULADD(at[1], at[13]); MULADD(at[2], at[12]); MULADD(at[3], at[11]); MULADD(at[4], at[10]); MULADD(at[5], at[9]); MULADD(at[6], at[8]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[15]); MULADD(at[1], at[14]); MULADD(at[2], at[13]); MULADD(at[3], at[12]); MULADD(at[4], at[11]); MULADD(at[5], at[10]); MULADD(at[6], at[9]); MULADD(at[7], at[8]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[1], at[15]); MULADD(at[2], at[14]); MULADD(at[3], at[13]); MULADD(at[4], at[12]); MULADD(at[5], at[11]); MULADD(at[6], at[10]); MULADD(at[7], at[9]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[2], at[15]); MULADD(at[3], at[14]); MULADD(at[4], at[13]); MULADD(at[5], at[12]); MULADD(at[6], at[11]); MULADD(at[7], at[10]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[3], at[15]); MULADD(at[4], at[14]); MULADD(at[5], at[13]); MULADD(at[6], at[12]); MULADD(at[7], at[11]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[4], at[15]); MULADD(at[5], at[14]); MULADD(at[6], at[13]); MULADD(at[7], at[12]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[5], at[15]); MULADD(at[6], at[14]); MULADD(at[7], at[13]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[6], at[15]); MULADD(at[7], at[14]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[7], at[15]); COMBA_STORE(C->dp[14]); COMBA_STORE2(C->dp[15]); C->used = 16; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; } #endif /* End: src/mul/fp_mul_comba_8.c */ /* Start: src/mul/fp_mul_comba_9.c */ #define TFM_DEFINES //#include "fp_mul_comba.c" #ifdef TFM_MUL9 void fp_mul_comba9(fp_int *A, fp_int *B, fp_int *C) { fp_digit c0, c1, c2, at[18]; memcpy(at, A->dp, 9 * sizeof(fp_digit)); memcpy(at+9, B->dp, 9 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[9]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[10]); MULADD(at[1], at[9]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[11]); MULADD(at[1], at[10]); MULADD(at[2], at[9]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[12]); MULADD(at[1], at[11]); MULADD(at[2], at[10]); MULADD(at[3], at[9]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[13]); MULADD(at[1], at[12]); MULADD(at[2], at[11]); MULADD(at[3], at[10]); MULADD(at[4], at[9]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[14]); MULADD(at[1], at[13]); MULADD(at[2], at[12]); MULADD(at[3], at[11]); MULADD(at[4], at[10]); MULADD(at[5], at[9]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[15]); MULADD(at[1], at[14]); MULADD(at[2], at[13]); MULADD(at[3], at[12]); MULADD(at[4], at[11]); MULADD(at[5], at[10]); MULADD(at[6], at[9]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[16]); MULADD(at[1], at[15]); MULADD(at[2], at[14]); MULADD(at[3], at[13]); MULADD(at[4], at[12]); MULADD(at[5], at[11]); MULADD(at[6], at[10]); MULADD(at[7], at[9]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[0], at[17]); MULADD(at[1], at[16]); MULADD(at[2], at[15]); MULADD(at[3], at[14]); MULADD(at[4], at[13]); MULADD(at[5], at[12]); MULADD(at[6], at[11]); MULADD(at[7], at[10]); MULADD(at[8], at[9]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[1], at[17]); MULADD(at[2], at[16]); MULADD(at[3], at[15]); MULADD(at[4], at[14]); MULADD(at[5], at[13]); MULADD(at[6], at[12]); MULADD(at[7], at[11]); MULADD(at[8], at[10]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[2], at[17]); MULADD(at[3], at[16]); MULADD(at[4], at[15]); MULADD(at[5], at[14]); MULADD(at[6], at[13]); MULADD(at[7], at[12]); MULADD(at[8], at[11]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[3], at[17]); MULADD(at[4], at[16]); MULADD(at[5], at[15]); MULADD(at[6], at[14]); MULADD(at[7], at[13]); MULADD(at[8], at[12]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[4], at[17]); MULADD(at[5], at[16]); MULADD(at[6], at[15]); MULADD(at[7], at[14]); MULADD(at[8], at[13]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[5], at[17]); MULADD(at[6], at[16]); MULADD(at[7], at[15]); MULADD(at[8], at[14]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[6], at[17]); MULADD(at[7], at[16]); MULADD(at[8], at[15]); COMBA_STORE(C->dp[14]); /* 15 */ COMBA_FORWARD; MULADD(at[7], at[17]); MULADD(at[8], at[16]); COMBA_STORE(C->dp[15]); /* 16 */ COMBA_FORWARD; MULADD(at[8], at[17]); COMBA_STORE(C->dp[16]); COMBA_STORE2(C->dp[17]); C->used = 18; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; } #endif /* End: src/mul/fp_mul_comba_9.c */ /* Start: src/mul/fp_mul_comba_small_set.c */ #define TFM_DEFINES //#include "fp_mul_comba.c" #if defined(TFM_SMALL_SET) void fp_mul_comba_small(fp_int *A, fp_int *B, fp_int *C) { fp_digit c0, c1, c2, at[32]; switch (MAX(A->used, B->used)) { case 1: memcpy(at, A->dp, 1 * sizeof(fp_digit)); memcpy(at+1, B->dp, 1 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[1]); COMBA_STORE(C->dp[0]); COMBA_STORE2(C->dp[1]); C->used = 2; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; break; case 2: memcpy(at, A->dp, 2 * sizeof(fp_digit)); memcpy(at+2, B->dp, 2 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[2]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[3]); MULADD(at[1], at[2]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[1], at[3]); COMBA_STORE(C->dp[2]); COMBA_STORE2(C->dp[3]); C->used = 4; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; break; case 3: memcpy(at, A->dp, 3 * sizeof(fp_digit)); memcpy(at+3, B->dp, 3 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[3]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[4]); MULADD(at[1], at[3]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[5]); MULADD(at[1], at[4]); MULADD(at[2], at[3]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[1], at[5]); MULADD(at[2], at[4]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[2], at[5]); COMBA_STORE(C->dp[4]); COMBA_STORE2(C->dp[5]); C->used = 6; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; break; case 4: memcpy(at, A->dp, 4 * sizeof(fp_digit)); memcpy(at+4, B->dp, 4 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[4]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[5]); MULADD(at[1], at[4]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[6]); MULADD(at[1], at[5]); MULADD(at[2], at[4]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[7]); MULADD(at[1], at[6]); MULADD(at[2], at[5]); MULADD(at[3], at[4]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[1], at[7]); MULADD(at[2], at[6]); MULADD(at[3], at[5]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[2], at[7]); MULADD(at[3], at[6]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[3], at[7]); COMBA_STORE(C->dp[6]); COMBA_STORE2(C->dp[7]); C->used = 8; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; break; case 5: memcpy(at, A->dp, 5 * sizeof(fp_digit)); memcpy(at+5, B->dp, 5 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[5]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[6]); MULADD(at[1], at[5]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[7]); MULADD(at[1], at[6]); MULADD(at[2], at[5]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[8]); MULADD(at[1], at[7]); MULADD(at[2], at[6]); MULADD(at[3], at[5]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[9]); MULADD(at[1], at[8]); MULADD(at[2], at[7]); MULADD(at[3], at[6]); MULADD(at[4], at[5]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[1], at[9]); MULADD(at[2], at[8]); MULADD(at[3], at[7]); MULADD(at[4], at[6]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[2], at[9]); MULADD(at[3], at[8]); MULADD(at[4], at[7]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[3], at[9]); MULADD(at[4], at[8]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[4], at[9]); COMBA_STORE(C->dp[8]); COMBA_STORE2(C->dp[9]); C->used = 10; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; break; case 6: memcpy(at, A->dp, 6 * sizeof(fp_digit)); memcpy(at+6, B->dp, 6 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[6]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[7]); MULADD(at[1], at[6]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[8]); MULADD(at[1], at[7]); MULADD(at[2], at[6]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[9]); MULADD(at[1], at[8]); MULADD(at[2], at[7]); MULADD(at[3], at[6]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[10]); MULADD(at[1], at[9]); MULADD(at[2], at[8]); MULADD(at[3], at[7]); MULADD(at[4], at[6]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[11]); MULADD(at[1], at[10]); MULADD(at[2], at[9]); MULADD(at[3], at[8]); MULADD(at[4], at[7]); MULADD(at[5], at[6]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[1], at[11]); MULADD(at[2], at[10]); MULADD(at[3], at[9]); MULADD(at[4], at[8]); MULADD(at[5], at[7]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[2], at[11]); MULADD(at[3], at[10]); MULADD(at[4], at[9]); MULADD(at[5], at[8]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[3], at[11]); MULADD(at[4], at[10]); MULADD(at[5], at[9]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[4], at[11]); MULADD(at[5], at[10]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[5], at[11]); COMBA_STORE(C->dp[10]); COMBA_STORE2(C->dp[11]); C->used = 12; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; break; case 7: memcpy(at, A->dp, 7 * sizeof(fp_digit)); memcpy(at+7, B->dp, 7 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[7]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[8]); MULADD(at[1], at[7]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[9]); MULADD(at[1], at[8]); MULADD(at[2], at[7]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[10]); MULADD(at[1], at[9]); MULADD(at[2], at[8]); MULADD(at[3], at[7]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[11]); MULADD(at[1], at[10]); MULADD(at[2], at[9]); MULADD(at[3], at[8]); MULADD(at[4], at[7]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[12]); MULADD(at[1], at[11]); MULADD(at[2], at[10]); MULADD(at[3], at[9]); MULADD(at[4], at[8]); MULADD(at[5], at[7]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[13]); MULADD(at[1], at[12]); MULADD(at[2], at[11]); MULADD(at[3], at[10]); MULADD(at[4], at[9]); MULADD(at[5], at[8]); MULADD(at[6], at[7]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[1], at[13]); MULADD(at[2], at[12]); MULADD(at[3], at[11]); MULADD(at[4], at[10]); MULADD(at[5], at[9]); MULADD(at[6], at[8]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[2], at[13]); MULADD(at[3], at[12]); MULADD(at[4], at[11]); MULADD(at[5], at[10]); MULADD(at[6], at[9]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[3], at[13]); MULADD(at[4], at[12]); MULADD(at[5], at[11]); MULADD(at[6], at[10]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[4], at[13]); MULADD(at[5], at[12]); MULADD(at[6], at[11]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[5], at[13]); MULADD(at[6], at[12]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[6], at[13]); COMBA_STORE(C->dp[12]); COMBA_STORE2(C->dp[13]); C->used = 14; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; break; case 8: memcpy(at, A->dp, 8 * sizeof(fp_digit)); memcpy(at+8, B->dp, 8 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[8]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[9]); MULADD(at[1], at[8]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[10]); MULADD(at[1], at[9]); MULADD(at[2], at[8]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[11]); MULADD(at[1], at[10]); MULADD(at[2], at[9]); MULADD(at[3], at[8]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[12]); MULADD(at[1], at[11]); MULADD(at[2], at[10]); MULADD(at[3], at[9]); MULADD(at[4], at[8]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[13]); MULADD(at[1], at[12]); MULADD(at[2], at[11]); MULADD(at[3], at[10]); MULADD(at[4], at[9]); MULADD(at[5], at[8]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[14]); MULADD(at[1], at[13]); MULADD(at[2], at[12]); MULADD(at[3], at[11]); MULADD(at[4], at[10]); MULADD(at[5], at[9]); MULADD(at[6], at[8]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[15]); MULADD(at[1], at[14]); MULADD(at[2], at[13]); MULADD(at[3], at[12]); MULADD(at[4], at[11]); MULADD(at[5], at[10]); MULADD(at[6], at[9]); MULADD(at[7], at[8]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[1], at[15]); MULADD(at[2], at[14]); MULADD(at[3], at[13]); MULADD(at[4], at[12]); MULADD(at[5], at[11]); MULADD(at[6], at[10]); MULADD(at[7], at[9]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[2], at[15]); MULADD(at[3], at[14]); MULADD(at[4], at[13]); MULADD(at[5], at[12]); MULADD(at[6], at[11]); MULADD(at[7], at[10]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[3], at[15]); MULADD(at[4], at[14]); MULADD(at[5], at[13]); MULADD(at[6], at[12]); MULADD(at[7], at[11]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[4], at[15]); MULADD(at[5], at[14]); MULADD(at[6], at[13]); MULADD(at[7], at[12]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[5], at[15]); MULADD(at[6], at[14]); MULADD(at[7], at[13]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[6], at[15]); MULADD(at[7], at[14]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[7], at[15]); COMBA_STORE(C->dp[14]); COMBA_STORE2(C->dp[15]); C->used = 16; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; break; case 9: memcpy(at, A->dp, 9 * sizeof(fp_digit)); memcpy(at+9, B->dp, 9 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[9]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[10]); MULADD(at[1], at[9]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[11]); MULADD(at[1], at[10]); MULADD(at[2], at[9]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[12]); MULADD(at[1], at[11]); MULADD(at[2], at[10]); MULADD(at[3], at[9]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[13]); MULADD(at[1], at[12]); MULADD(at[2], at[11]); MULADD(at[3], at[10]); MULADD(at[4], at[9]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[14]); MULADD(at[1], at[13]); MULADD(at[2], at[12]); MULADD(at[3], at[11]); MULADD(at[4], at[10]); MULADD(at[5], at[9]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[15]); MULADD(at[1], at[14]); MULADD(at[2], at[13]); MULADD(at[3], at[12]); MULADD(at[4], at[11]); MULADD(at[5], at[10]); MULADD(at[6], at[9]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[16]); MULADD(at[1], at[15]); MULADD(at[2], at[14]); MULADD(at[3], at[13]); MULADD(at[4], at[12]); MULADD(at[5], at[11]); MULADD(at[6], at[10]); MULADD(at[7], at[9]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[0], at[17]); MULADD(at[1], at[16]); MULADD(at[2], at[15]); MULADD(at[3], at[14]); MULADD(at[4], at[13]); MULADD(at[5], at[12]); MULADD(at[6], at[11]); MULADD(at[7], at[10]); MULADD(at[8], at[9]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[1], at[17]); MULADD(at[2], at[16]); MULADD(at[3], at[15]); MULADD(at[4], at[14]); MULADD(at[5], at[13]); MULADD(at[6], at[12]); MULADD(at[7], at[11]); MULADD(at[8], at[10]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[2], at[17]); MULADD(at[3], at[16]); MULADD(at[4], at[15]); MULADD(at[5], at[14]); MULADD(at[6], at[13]); MULADD(at[7], at[12]); MULADD(at[8], at[11]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[3], at[17]); MULADD(at[4], at[16]); MULADD(at[5], at[15]); MULADD(at[6], at[14]); MULADD(at[7], at[13]); MULADD(at[8], at[12]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[4], at[17]); MULADD(at[5], at[16]); MULADD(at[6], at[15]); MULADD(at[7], at[14]); MULADD(at[8], at[13]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[5], at[17]); MULADD(at[6], at[16]); MULADD(at[7], at[15]); MULADD(at[8], at[14]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[6], at[17]); MULADD(at[7], at[16]); MULADD(at[8], at[15]); COMBA_STORE(C->dp[14]); /* 15 */ COMBA_FORWARD; MULADD(at[7], at[17]); MULADD(at[8], at[16]); COMBA_STORE(C->dp[15]); /* 16 */ COMBA_FORWARD; MULADD(at[8], at[17]); COMBA_STORE(C->dp[16]); COMBA_STORE2(C->dp[17]); C->used = 18; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; break; case 10: memcpy(at, A->dp, 10 * sizeof(fp_digit)); memcpy(at+10, B->dp, 10 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[10]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[11]); MULADD(at[1], at[10]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[12]); MULADD(at[1], at[11]); MULADD(at[2], at[10]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[13]); MULADD(at[1], at[12]); MULADD(at[2], at[11]); MULADD(at[3], at[10]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[14]); MULADD(at[1], at[13]); MULADD(at[2], at[12]); MULADD(at[3], at[11]); MULADD(at[4], at[10]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[15]); MULADD(at[1], at[14]); MULADD(at[2], at[13]); MULADD(at[3], at[12]); MULADD(at[4], at[11]); MULADD(at[5], at[10]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[16]); MULADD(at[1], at[15]); MULADD(at[2], at[14]); MULADD(at[3], at[13]); MULADD(at[4], at[12]); MULADD(at[5], at[11]); MULADD(at[6], at[10]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[17]); MULADD(at[1], at[16]); MULADD(at[2], at[15]); MULADD(at[3], at[14]); MULADD(at[4], at[13]); MULADD(at[5], at[12]); MULADD(at[6], at[11]); MULADD(at[7], at[10]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[0], at[18]); MULADD(at[1], at[17]); MULADD(at[2], at[16]); MULADD(at[3], at[15]); MULADD(at[4], at[14]); MULADD(at[5], at[13]); MULADD(at[6], at[12]); MULADD(at[7], at[11]); MULADD(at[8], at[10]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[0], at[19]); MULADD(at[1], at[18]); MULADD(at[2], at[17]); MULADD(at[3], at[16]); MULADD(at[4], at[15]); MULADD(at[5], at[14]); MULADD(at[6], at[13]); MULADD(at[7], at[12]); MULADD(at[8], at[11]); MULADD(at[9], at[10]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[1], at[19]); MULADD(at[2], at[18]); MULADD(at[3], at[17]); MULADD(at[4], at[16]); MULADD(at[5], at[15]); MULADD(at[6], at[14]); MULADD(at[7], at[13]); MULADD(at[8], at[12]); MULADD(at[9], at[11]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[2], at[19]); MULADD(at[3], at[18]); MULADD(at[4], at[17]); MULADD(at[5], at[16]); MULADD(at[6], at[15]); MULADD(at[7], at[14]); MULADD(at[8], at[13]); MULADD(at[9], at[12]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[3], at[19]); MULADD(at[4], at[18]); MULADD(at[5], at[17]); MULADD(at[6], at[16]); MULADD(at[7], at[15]); MULADD(at[8], at[14]); MULADD(at[9], at[13]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[4], at[19]); MULADD(at[5], at[18]); MULADD(at[6], at[17]); MULADD(at[7], at[16]); MULADD(at[8], at[15]); MULADD(at[9], at[14]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[5], at[19]); MULADD(at[6], at[18]); MULADD(at[7], at[17]); MULADD(at[8], at[16]); MULADD(at[9], at[15]); COMBA_STORE(C->dp[14]); /* 15 */ COMBA_FORWARD; MULADD(at[6], at[19]); MULADD(at[7], at[18]); MULADD(at[8], at[17]); MULADD(at[9], at[16]); COMBA_STORE(C->dp[15]); /* 16 */ COMBA_FORWARD; MULADD(at[7], at[19]); MULADD(at[8], at[18]); MULADD(at[9], at[17]); COMBA_STORE(C->dp[16]); /* 17 */ COMBA_FORWARD; MULADD(at[8], at[19]); MULADD(at[9], at[18]); COMBA_STORE(C->dp[17]); /* 18 */ COMBA_FORWARD; MULADD(at[9], at[19]); COMBA_STORE(C->dp[18]); COMBA_STORE2(C->dp[19]); C->used = 20; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; break; case 11: memcpy(at, A->dp, 11 * sizeof(fp_digit)); memcpy(at+11, B->dp, 11 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[11]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[12]); MULADD(at[1], at[11]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[13]); MULADD(at[1], at[12]); MULADD(at[2], at[11]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[14]); MULADD(at[1], at[13]); MULADD(at[2], at[12]); MULADD(at[3], at[11]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[15]); MULADD(at[1], at[14]); MULADD(at[2], at[13]); MULADD(at[3], at[12]); MULADD(at[4], at[11]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[16]); MULADD(at[1], at[15]); MULADD(at[2], at[14]); MULADD(at[3], at[13]); MULADD(at[4], at[12]); MULADD(at[5], at[11]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[17]); MULADD(at[1], at[16]); MULADD(at[2], at[15]); MULADD(at[3], at[14]); MULADD(at[4], at[13]); MULADD(at[5], at[12]); MULADD(at[6], at[11]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[18]); MULADD(at[1], at[17]); MULADD(at[2], at[16]); MULADD(at[3], at[15]); MULADD(at[4], at[14]); MULADD(at[5], at[13]); MULADD(at[6], at[12]); MULADD(at[7], at[11]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[0], at[19]); MULADD(at[1], at[18]); MULADD(at[2], at[17]); MULADD(at[3], at[16]); MULADD(at[4], at[15]); MULADD(at[5], at[14]); MULADD(at[6], at[13]); MULADD(at[7], at[12]); MULADD(at[8], at[11]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[0], at[20]); MULADD(at[1], at[19]); MULADD(at[2], at[18]); MULADD(at[3], at[17]); MULADD(at[4], at[16]); MULADD(at[5], at[15]); MULADD(at[6], at[14]); MULADD(at[7], at[13]); MULADD(at[8], at[12]); MULADD(at[9], at[11]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[0], at[21]); MULADD(at[1], at[20]); MULADD(at[2], at[19]); MULADD(at[3], at[18]); MULADD(at[4], at[17]); MULADD(at[5], at[16]); MULADD(at[6], at[15]); MULADD(at[7], at[14]); MULADD(at[8], at[13]); MULADD(at[9], at[12]); MULADD(at[10], at[11]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[1], at[21]); MULADD(at[2], at[20]); MULADD(at[3], at[19]); MULADD(at[4], at[18]); MULADD(at[5], at[17]); MULADD(at[6], at[16]); MULADD(at[7], at[15]); MULADD(at[8], at[14]); MULADD(at[9], at[13]); MULADD(at[10], at[12]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[2], at[21]); MULADD(at[3], at[20]); MULADD(at[4], at[19]); MULADD(at[5], at[18]); MULADD(at[6], at[17]); MULADD(at[7], at[16]); MULADD(at[8], at[15]); MULADD(at[9], at[14]); MULADD(at[10], at[13]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[3], at[21]); MULADD(at[4], at[20]); MULADD(at[5], at[19]); MULADD(at[6], at[18]); MULADD(at[7], at[17]); MULADD(at[8], at[16]); MULADD(at[9], at[15]); MULADD(at[10], at[14]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[4], at[21]); MULADD(at[5], at[20]); MULADD(at[6], at[19]); MULADD(at[7], at[18]); MULADD(at[8], at[17]); MULADD(at[9], at[16]); MULADD(at[10], at[15]); COMBA_STORE(C->dp[14]); /* 15 */ COMBA_FORWARD; MULADD(at[5], at[21]); MULADD(at[6], at[20]); MULADD(at[7], at[19]); MULADD(at[8], at[18]); MULADD(at[9], at[17]); MULADD(at[10], at[16]); COMBA_STORE(C->dp[15]); /* 16 */ COMBA_FORWARD; MULADD(at[6], at[21]); MULADD(at[7], at[20]); MULADD(at[8], at[19]); MULADD(at[9], at[18]); MULADD(at[10], at[17]); COMBA_STORE(C->dp[16]); /* 17 */ COMBA_FORWARD; MULADD(at[7], at[21]); MULADD(at[8], at[20]); MULADD(at[9], at[19]); MULADD(at[10], at[18]); COMBA_STORE(C->dp[17]); /* 18 */ COMBA_FORWARD; MULADD(at[8], at[21]); MULADD(at[9], at[20]); MULADD(at[10], at[19]); COMBA_STORE(C->dp[18]); /* 19 */ COMBA_FORWARD; MULADD(at[9], at[21]); MULADD(at[10], at[20]); COMBA_STORE(C->dp[19]); /* 20 */ COMBA_FORWARD; MULADD(at[10], at[21]); COMBA_STORE(C->dp[20]); COMBA_STORE2(C->dp[21]); C->used = 22; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; break; case 12: memcpy(at, A->dp, 12 * sizeof(fp_digit)); memcpy(at+12, B->dp, 12 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[12]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[13]); MULADD(at[1], at[12]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[14]); MULADD(at[1], at[13]); MULADD(at[2], at[12]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[15]); MULADD(at[1], at[14]); MULADD(at[2], at[13]); MULADD(at[3], at[12]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[16]); MULADD(at[1], at[15]); MULADD(at[2], at[14]); MULADD(at[3], at[13]); MULADD(at[4], at[12]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[17]); MULADD(at[1], at[16]); MULADD(at[2], at[15]); MULADD(at[3], at[14]); MULADD(at[4], at[13]); MULADD(at[5], at[12]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[18]); MULADD(at[1], at[17]); MULADD(at[2], at[16]); MULADD(at[3], at[15]); MULADD(at[4], at[14]); MULADD(at[5], at[13]); MULADD(at[6], at[12]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[19]); MULADD(at[1], at[18]); MULADD(at[2], at[17]); MULADD(at[3], at[16]); MULADD(at[4], at[15]); MULADD(at[5], at[14]); MULADD(at[6], at[13]); MULADD(at[7], at[12]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[0], at[20]); MULADD(at[1], at[19]); MULADD(at[2], at[18]); MULADD(at[3], at[17]); MULADD(at[4], at[16]); MULADD(at[5], at[15]); MULADD(at[6], at[14]); MULADD(at[7], at[13]); MULADD(at[8], at[12]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[0], at[21]); MULADD(at[1], at[20]); MULADD(at[2], at[19]); MULADD(at[3], at[18]); MULADD(at[4], at[17]); MULADD(at[5], at[16]); MULADD(at[6], at[15]); MULADD(at[7], at[14]); MULADD(at[8], at[13]); MULADD(at[9], at[12]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[0], at[22]); MULADD(at[1], at[21]); MULADD(at[2], at[20]); MULADD(at[3], at[19]); MULADD(at[4], at[18]); MULADD(at[5], at[17]); MULADD(at[6], at[16]); MULADD(at[7], at[15]); MULADD(at[8], at[14]); MULADD(at[9], at[13]); MULADD(at[10], at[12]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[0], at[23]); MULADD(at[1], at[22]); MULADD(at[2], at[21]); MULADD(at[3], at[20]); MULADD(at[4], at[19]); MULADD(at[5], at[18]); MULADD(at[6], at[17]); MULADD(at[7], at[16]); MULADD(at[8], at[15]); MULADD(at[9], at[14]); MULADD(at[10], at[13]); MULADD(at[11], at[12]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[1], at[23]); MULADD(at[2], at[22]); MULADD(at[3], at[21]); MULADD(at[4], at[20]); MULADD(at[5], at[19]); MULADD(at[6], at[18]); MULADD(at[7], at[17]); MULADD(at[8], at[16]); MULADD(at[9], at[15]); MULADD(at[10], at[14]); MULADD(at[11], at[13]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[2], at[23]); MULADD(at[3], at[22]); MULADD(at[4], at[21]); MULADD(at[5], at[20]); MULADD(at[6], at[19]); MULADD(at[7], at[18]); MULADD(at[8], at[17]); MULADD(at[9], at[16]); MULADD(at[10], at[15]); MULADD(at[11], at[14]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[3], at[23]); MULADD(at[4], at[22]); MULADD(at[5], at[21]); MULADD(at[6], at[20]); MULADD(at[7], at[19]); MULADD(at[8], at[18]); MULADD(at[9], at[17]); MULADD(at[10], at[16]); MULADD(at[11], at[15]); COMBA_STORE(C->dp[14]); /* 15 */ COMBA_FORWARD; MULADD(at[4], at[23]); MULADD(at[5], at[22]); MULADD(at[6], at[21]); MULADD(at[7], at[20]); MULADD(at[8], at[19]); MULADD(at[9], at[18]); MULADD(at[10], at[17]); MULADD(at[11], at[16]); COMBA_STORE(C->dp[15]); /* 16 */ COMBA_FORWARD; MULADD(at[5], at[23]); MULADD(at[6], at[22]); MULADD(at[7], at[21]); MULADD(at[8], at[20]); MULADD(at[9], at[19]); MULADD(at[10], at[18]); MULADD(at[11], at[17]); COMBA_STORE(C->dp[16]); /* 17 */ COMBA_FORWARD; MULADD(at[6], at[23]); MULADD(at[7], at[22]); MULADD(at[8], at[21]); MULADD(at[9], at[20]); MULADD(at[10], at[19]); MULADD(at[11], at[18]); COMBA_STORE(C->dp[17]); /* 18 */ COMBA_FORWARD; MULADD(at[7], at[23]); MULADD(at[8], at[22]); MULADD(at[9], at[21]); MULADD(at[10], at[20]); MULADD(at[11], at[19]); COMBA_STORE(C->dp[18]); /* 19 */ COMBA_FORWARD; MULADD(at[8], at[23]); MULADD(at[9], at[22]); MULADD(at[10], at[21]); MULADD(at[11], at[20]); COMBA_STORE(C->dp[19]); /* 20 */ COMBA_FORWARD; MULADD(at[9], at[23]); MULADD(at[10], at[22]); MULADD(at[11], at[21]); COMBA_STORE(C->dp[20]); /* 21 */ COMBA_FORWARD; MULADD(at[10], at[23]); MULADD(at[11], at[22]); COMBA_STORE(C->dp[21]); /* 22 */ COMBA_FORWARD; MULADD(at[11], at[23]); COMBA_STORE(C->dp[22]); COMBA_STORE2(C->dp[23]); C->used = 24; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; break; case 13: memcpy(at, A->dp, 13 * sizeof(fp_digit)); memcpy(at+13, B->dp, 13 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[13]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[14]); MULADD(at[1], at[13]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[15]); MULADD(at[1], at[14]); MULADD(at[2], at[13]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[16]); MULADD(at[1], at[15]); MULADD(at[2], at[14]); MULADD(at[3], at[13]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[17]); MULADD(at[1], at[16]); MULADD(at[2], at[15]); MULADD(at[3], at[14]); MULADD(at[4], at[13]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[18]); MULADD(at[1], at[17]); MULADD(at[2], at[16]); MULADD(at[3], at[15]); MULADD(at[4], at[14]); MULADD(at[5], at[13]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[19]); MULADD(at[1], at[18]); MULADD(at[2], at[17]); MULADD(at[3], at[16]); MULADD(at[4], at[15]); MULADD(at[5], at[14]); MULADD(at[6], at[13]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[20]); MULADD(at[1], at[19]); MULADD(at[2], at[18]); MULADD(at[3], at[17]); MULADD(at[4], at[16]); MULADD(at[5], at[15]); MULADD(at[6], at[14]); MULADD(at[7], at[13]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[0], at[21]); MULADD(at[1], at[20]); MULADD(at[2], at[19]); MULADD(at[3], at[18]); MULADD(at[4], at[17]); MULADD(at[5], at[16]); MULADD(at[6], at[15]); MULADD(at[7], at[14]); MULADD(at[8], at[13]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[0], at[22]); MULADD(at[1], at[21]); MULADD(at[2], at[20]); MULADD(at[3], at[19]); MULADD(at[4], at[18]); MULADD(at[5], at[17]); MULADD(at[6], at[16]); MULADD(at[7], at[15]); MULADD(at[8], at[14]); MULADD(at[9], at[13]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[0], at[23]); MULADD(at[1], at[22]); MULADD(at[2], at[21]); MULADD(at[3], at[20]); MULADD(at[4], at[19]); MULADD(at[5], at[18]); MULADD(at[6], at[17]); MULADD(at[7], at[16]); MULADD(at[8], at[15]); MULADD(at[9], at[14]); MULADD(at[10], at[13]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[0], at[24]); MULADD(at[1], at[23]); MULADD(at[2], at[22]); MULADD(at[3], at[21]); MULADD(at[4], at[20]); MULADD(at[5], at[19]); MULADD(at[6], at[18]); MULADD(at[7], at[17]); MULADD(at[8], at[16]); MULADD(at[9], at[15]); MULADD(at[10], at[14]); MULADD(at[11], at[13]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[0], at[25]); MULADD(at[1], at[24]); MULADD(at[2], at[23]); MULADD(at[3], at[22]); MULADD(at[4], at[21]); MULADD(at[5], at[20]); MULADD(at[6], at[19]); MULADD(at[7], at[18]); MULADD(at[8], at[17]); MULADD(at[9], at[16]); MULADD(at[10], at[15]); MULADD(at[11], at[14]); MULADD(at[12], at[13]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[1], at[25]); MULADD(at[2], at[24]); MULADD(at[3], at[23]); MULADD(at[4], at[22]); MULADD(at[5], at[21]); MULADD(at[6], at[20]); MULADD(at[7], at[19]); MULADD(at[8], at[18]); MULADD(at[9], at[17]); MULADD(at[10], at[16]); MULADD(at[11], at[15]); MULADD(at[12], at[14]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[2], at[25]); MULADD(at[3], at[24]); MULADD(at[4], at[23]); MULADD(at[5], at[22]); MULADD(at[6], at[21]); MULADD(at[7], at[20]); MULADD(at[8], at[19]); MULADD(at[9], at[18]); MULADD(at[10], at[17]); MULADD(at[11], at[16]); MULADD(at[12], at[15]); COMBA_STORE(C->dp[14]); /* 15 */ COMBA_FORWARD; MULADD(at[3], at[25]); MULADD(at[4], at[24]); MULADD(at[5], at[23]); MULADD(at[6], at[22]); MULADD(at[7], at[21]); MULADD(at[8], at[20]); MULADD(at[9], at[19]); MULADD(at[10], at[18]); MULADD(at[11], at[17]); MULADD(at[12], at[16]); COMBA_STORE(C->dp[15]); /* 16 */ COMBA_FORWARD; MULADD(at[4], at[25]); MULADD(at[5], at[24]); MULADD(at[6], at[23]); MULADD(at[7], at[22]); MULADD(at[8], at[21]); MULADD(at[9], at[20]); MULADD(at[10], at[19]); MULADD(at[11], at[18]); MULADD(at[12], at[17]); COMBA_STORE(C->dp[16]); /* 17 */ COMBA_FORWARD; MULADD(at[5], at[25]); MULADD(at[6], at[24]); MULADD(at[7], at[23]); MULADD(at[8], at[22]); MULADD(at[9], at[21]); MULADD(at[10], at[20]); MULADD(at[11], at[19]); MULADD(at[12], at[18]); COMBA_STORE(C->dp[17]); /* 18 */ COMBA_FORWARD; MULADD(at[6], at[25]); MULADD(at[7], at[24]); MULADD(at[8], at[23]); MULADD(at[9], at[22]); MULADD(at[10], at[21]); MULADD(at[11], at[20]); MULADD(at[12], at[19]); COMBA_STORE(C->dp[18]); /* 19 */ COMBA_FORWARD; MULADD(at[7], at[25]); MULADD(at[8], at[24]); MULADD(at[9], at[23]); MULADD(at[10], at[22]); MULADD(at[11], at[21]); MULADD(at[12], at[20]); COMBA_STORE(C->dp[19]); /* 20 */ COMBA_FORWARD; MULADD(at[8], at[25]); MULADD(at[9], at[24]); MULADD(at[10], at[23]); MULADD(at[11], at[22]); MULADD(at[12], at[21]); COMBA_STORE(C->dp[20]); /* 21 */ COMBA_FORWARD; MULADD(at[9], at[25]); MULADD(at[10], at[24]); MULADD(at[11], at[23]); MULADD(at[12], at[22]); COMBA_STORE(C->dp[21]); /* 22 */ COMBA_FORWARD; MULADD(at[10], at[25]); MULADD(at[11], at[24]); MULADD(at[12], at[23]); COMBA_STORE(C->dp[22]); /* 23 */ COMBA_FORWARD; MULADD(at[11], at[25]); MULADD(at[12], at[24]); COMBA_STORE(C->dp[23]); /* 24 */ COMBA_FORWARD; MULADD(at[12], at[25]); COMBA_STORE(C->dp[24]); COMBA_STORE2(C->dp[25]); C->used = 26; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; break; case 14: memcpy(at, A->dp, 14 * sizeof(fp_digit)); memcpy(at+14, B->dp, 14 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[14]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[15]); MULADD(at[1], at[14]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[16]); MULADD(at[1], at[15]); MULADD(at[2], at[14]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[17]); MULADD(at[1], at[16]); MULADD(at[2], at[15]); MULADD(at[3], at[14]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[18]); MULADD(at[1], at[17]); MULADD(at[2], at[16]); MULADD(at[3], at[15]); MULADD(at[4], at[14]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[19]); MULADD(at[1], at[18]); MULADD(at[2], at[17]); MULADD(at[3], at[16]); MULADD(at[4], at[15]); MULADD(at[5], at[14]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[20]); MULADD(at[1], at[19]); MULADD(at[2], at[18]); MULADD(at[3], at[17]); MULADD(at[4], at[16]); MULADD(at[5], at[15]); MULADD(at[6], at[14]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[21]); MULADD(at[1], at[20]); MULADD(at[2], at[19]); MULADD(at[3], at[18]); MULADD(at[4], at[17]); MULADD(at[5], at[16]); MULADD(at[6], at[15]); MULADD(at[7], at[14]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[0], at[22]); MULADD(at[1], at[21]); MULADD(at[2], at[20]); MULADD(at[3], at[19]); MULADD(at[4], at[18]); MULADD(at[5], at[17]); MULADD(at[6], at[16]); MULADD(at[7], at[15]); MULADD(at[8], at[14]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[0], at[23]); MULADD(at[1], at[22]); MULADD(at[2], at[21]); MULADD(at[3], at[20]); MULADD(at[4], at[19]); MULADD(at[5], at[18]); MULADD(at[6], at[17]); MULADD(at[7], at[16]); MULADD(at[8], at[15]); MULADD(at[9], at[14]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[0], at[24]); MULADD(at[1], at[23]); MULADD(at[2], at[22]); MULADD(at[3], at[21]); MULADD(at[4], at[20]); MULADD(at[5], at[19]); MULADD(at[6], at[18]); MULADD(at[7], at[17]); MULADD(at[8], at[16]); MULADD(at[9], at[15]); MULADD(at[10], at[14]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[0], at[25]); MULADD(at[1], at[24]); MULADD(at[2], at[23]); MULADD(at[3], at[22]); MULADD(at[4], at[21]); MULADD(at[5], at[20]); MULADD(at[6], at[19]); MULADD(at[7], at[18]); MULADD(at[8], at[17]); MULADD(at[9], at[16]); MULADD(at[10], at[15]); MULADD(at[11], at[14]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[0], at[26]); MULADD(at[1], at[25]); MULADD(at[2], at[24]); MULADD(at[3], at[23]); MULADD(at[4], at[22]); MULADD(at[5], at[21]); MULADD(at[6], at[20]); MULADD(at[7], at[19]); MULADD(at[8], at[18]); MULADD(at[9], at[17]); MULADD(at[10], at[16]); MULADD(at[11], at[15]); MULADD(at[12], at[14]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[0], at[27]); MULADD(at[1], at[26]); MULADD(at[2], at[25]); MULADD(at[3], at[24]); MULADD(at[4], at[23]); MULADD(at[5], at[22]); MULADD(at[6], at[21]); MULADD(at[7], at[20]); MULADD(at[8], at[19]); MULADD(at[9], at[18]); MULADD(at[10], at[17]); MULADD(at[11], at[16]); MULADD(at[12], at[15]); MULADD(at[13], at[14]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[1], at[27]); MULADD(at[2], at[26]); MULADD(at[3], at[25]); MULADD(at[4], at[24]); MULADD(at[5], at[23]); MULADD(at[6], at[22]); MULADD(at[7], at[21]); MULADD(at[8], at[20]); MULADD(at[9], at[19]); MULADD(at[10], at[18]); MULADD(at[11], at[17]); MULADD(at[12], at[16]); MULADD(at[13], at[15]); COMBA_STORE(C->dp[14]); /* 15 */ COMBA_FORWARD; MULADD(at[2], at[27]); MULADD(at[3], at[26]); MULADD(at[4], at[25]); MULADD(at[5], at[24]); MULADD(at[6], at[23]); MULADD(at[7], at[22]); MULADD(at[8], at[21]); MULADD(at[9], at[20]); MULADD(at[10], at[19]); MULADD(at[11], at[18]); MULADD(at[12], at[17]); MULADD(at[13], at[16]); COMBA_STORE(C->dp[15]); /* 16 */ COMBA_FORWARD; MULADD(at[3], at[27]); MULADD(at[4], at[26]); MULADD(at[5], at[25]); MULADD(at[6], at[24]); MULADD(at[7], at[23]); MULADD(at[8], at[22]); MULADD(at[9], at[21]); MULADD(at[10], at[20]); MULADD(at[11], at[19]); MULADD(at[12], at[18]); MULADD(at[13], at[17]); COMBA_STORE(C->dp[16]); /* 17 */ COMBA_FORWARD; MULADD(at[4], at[27]); MULADD(at[5], at[26]); MULADD(at[6], at[25]); MULADD(at[7], at[24]); MULADD(at[8], at[23]); MULADD(at[9], at[22]); MULADD(at[10], at[21]); MULADD(at[11], at[20]); MULADD(at[12], at[19]); MULADD(at[13], at[18]); COMBA_STORE(C->dp[17]); /* 18 */ COMBA_FORWARD; MULADD(at[5], at[27]); MULADD(at[6], at[26]); MULADD(at[7], at[25]); MULADD(at[8], at[24]); MULADD(at[9], at[23]); MULADD(at[10], at[22]); MULADD(at[11], at[21]); MULADD(at[12], at[20]); MULADD(at[13], at[19]); COMBA_STORE(C->dp[18]); /* 19 */ COMBA_FORWARD; MULADD(at[6], at[27]); MULADD(at[7], at[26]); MULADD(at[8], at[25]); MULADD(at[9], at[24]); MULADD(at[10], at[23]); MULADD(at[11], at[22]); MULADD(at[12], at[21]); MULADD(at[13], at[20]); COMBA_STORE(C->dp[19]); /* 20 */ COMBA_FORWARD; MULADD(at[7], at[27]); MULADD(at[8], at[26]); MULADD(at[9], at[25]); MULADD(at[10], at[24]); MULADD(at[11], at[23]); MULADD(at[12], at[22]); MULADD(at[13], at[21]); COMBA_STORE(C->dp[20]); /* 21 */ COMBA_FORWARD; MULADD(at[8], at[27]); MULADD(at[9], at[26]); MULADD(at[10], at[25]); MULADD(at[11], at[24]); MULADD(at[12], at[23]); MULADD(at[13], at[22]); COMBA_STORE(C->dp[21]); /* 22 */ COMBA_FORWARD; MULADD(at[9], at[27]); MULADD(at[10], at[26]); MULADD(at[11], at[25]); MULADD(at[12], at[24]); MULADD(at[13], at[23]); COMBA_STORE(C->dp[22]); /* 23 */ COMBA_FORWARD; MULADD(at[10], at[27]); MULADD(at[11], at[26]); MULADD(at[12], at[25]); MULADD(at[13], at[24]); COMBA_STORE(C->dp[23]); /* 24 */ COMBA_FORWARD; MULADD(at[11], at[27]); MULADD(at[12], at[26]); MULADD(at[13], at[25]); COMBA_STORE(C->dp[24]); /* 25 */ COMBA_FORWARD; MULADD(at[12], at[27]); MULADD(at[13], at[26]); COMBA_STORE(C->dp[25]); /* 26 */ COMBA_FORWARD; MULADD(at[13], at[27]); COMBA_STORE(C->dp[26]); COMBA_STORE2(C->dp[27]); C->used = 28; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; break; case 15: memcpy(at, A->dp, 15 * sizeof(fp_digit)); memcpy(at+15, B->dp, 15 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[15]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[16]); MULADD(at[1], at[15]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[17]); MULADD(at[1], at[16]); MULADD(at[2], at[15]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[18]); MULADD(at[1], at[17]); MULADD(at[2], at[16]); MULADD(at[3], at[15]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[19]); MULADD(at[1], at[18]); MULADD(at[2], at[17]); MULADD(at[3], at[16]); MULADD(at[4], at[15]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[20]); MULADD(at[1], at[19]); MULADD(at[2], at[18]); MULADD(at[3], at[17]); MULADD(at[4], at[16]); MULADD(at[5], at[15]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[21]); MULADD(at[1], at[20]); MULADD(at[2], at[19]); MULADD(at[3], at[18]); MULADD(at[4], at[17]); MULADD(at[5], at[16]); MULADD(at[6], at[15]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[22]); MULADD(at[1], at[21]); MULADD(at[2], at[20]); MULADD(at[3], at[19]); MULADD(at[4], at[18]); MULADD(at[5], at[17]); MULADD(at[6], at[16]); MULADD(at[7], at[15]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[0], at[23]); MULADD(at[1], at[22]); MULADD(at[2], at[21]); MULADD(at[3], at[20]); MULADD(at[4], at[19]); MULADD(at[5], at[18]); MULADD(at[6], at[17]); MULADD(at[7], at[16]); MULADD(at[8], at[15]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[0], at[24]); MULADD(at[1], at[23]); MULADD(at[2], at[22]); MULADD(at[3], at[21]); MULADD(at[4], at[20]); MULADD(at[5], at[19]); MULADD(at[6], at[18]); MULADD(at[7], at[17]); MULADD(at[8], at[16]); MULADD(at[9], at[15]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[0], at[25]); MULADD(at[1], at[24]); MULADD(at[2], at[23]); MULADD(at[3], at[22]); MULADD(at[4], at[21]); MULADD(at[5], at[20]); MULADD(at[6], at[19]); MULADD(at[7], at[18]); MULADD(at[8], at[17]); MULADD(at[9], at[16]); MULADD(at[10], at[15]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[0], at[26]); MULADD(at[1], at[25]); MULADD(at[2], at[24]); MULADD(at[3], at[23]); MULADD(at[4], at[22]); MULADD(at[5], at[21]); MULADD(at[6], at[20]); MULADD(at[7], at[19]); MULADD(at[8], at[18]); MULADD(at[9], at[17]); MULADD(at[10], at[16]); MULADD(at[11], at[15]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[0], at[27]); MULADD(at[1], at[26]); MULADD(at[2], at[25]); MULADD(at[3], at[24]); MULADD(at[4], at[23]); MULADD(at[5], at[22]); MULADD(at[6], at[21]); MULADD(at[7], at[20]); MULADD(at[8], at[19]); MULADD(at[9], at[18]); MULADD(at[10], at[17]); MULADD(at[11], at[16]); MULADD(at[12], at[15]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[0], at[28]); MULADD(at[1], at[27]); MULADD(at[2], at[26]); MULADD(at[3], at[25]); MULADD(at[4], at[24]); MULADD(at[5], at[23]); MULADD(at[6], at[22]); MULADD(at[7], at[21]); MULADD(at[8], at[20]); MULADD(at[9], at[19]); MULADD(at[10], at[18]); MULADD(at[11], at[17]); MULADD(at[12], at[16]); MULADD(at[13], at[15]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[0], at[29]); MULADD(at[1], at[28]); MULADD(at[2], at[27]); MULADD(at[3], at[26]); MULADD(at[4], at[25]); MULADD(at[5], at[24]); MULADD(at[6], at[23]); MULADD(at[7], at[22]); MULADD(at[8], at[21]); MULADD(at[9], at[20]); MULADD(at[10], at[19]); MULADD(at[11], at[18]); MULADD(at[12], at[17]); MULADD(at[13], at[16]); MULADD(at[14], at[15]); COMBA_STORE(C->dp[14]); /* 15 */ COMBA_FORWARD; MULADD(at[1], at[29]); MULADD(at[2], at[28]); MULADD(at[3], at[27]); MULADD(at[4], at[26]); MULADD(at[5], at[25]); MULADD(at[6], at[24]); MULADD(at[7], at[23]); MULADD(at[8], at[22]); MULADD(at[9], at[21]); MULADD(at[10], at[20]); MULADD(at[11], at[19]); MULADD(at[12], at[18]); MULADD(at[13], at[17]); MULADD(at[14], at[16]); COMBA_STORE(C->dp[15]); /* 16 */ COMBA_FORWARD; MULADD(at[2], at[29]); MULADD(at[3], at[28]); MULADD(at[4], at[27]); MULADD(at[5], at[26]); MULADD(at[6], at[25]); MULADD(at[7], at[24]); MULADD(at[8], at[23]); MULADD(at[9], at[22]); MULADD(at[10], at[21]); MULADD(at[11], at[20]); MULADD(at[12], at[19]); MULADD(at[13], at[18]); MULADD(at[14], at[17]); COMBA_STORE(C->dp[16]); /* 17 */ COMBA_FORWARD; MULADD(at[3], at[29]); MULADD(at[4], at[28]); MULADD(at[5], at[27]); MULADD(at[6], at[26]); MULADD(at[7], at[25]); MULADD(at[8], at[24]); MULADD(at[9], at[23]); MULADD(at[10], at[22]); MULADD(at[11], at[21]); MULADD(at[12], at[20]); MULADD(at[13], at[19]); MULADD(at[14], at[18]); COMBA_STORE(C->dp[17]); /* 18 */ COMBA_FORWARD; MULADD(at[4], at[29]); MULADD(at[5], at[28]); MULADD(at[6], at[27]); MULADD(at[7], at[26]); MULADD(at[8], at[25]); MULADD(at[9], at[24]); MULADD(at[10], at[23]); MULADD(at[11], at[22]); MULADD(at[12], at[21]); MULADD(at[13], at[20]); MULADD(at[14], at[19]); COMBA_STORE(C->dp[18]); /* 19 */ COMBA_FORWARD; MULADD(at[5], at[29]); MULADD(at[6], at[28]); MULADD(at[7], at[27]); MULADD(at[8], at[26]); MULADD(at[9], at[25]); MULADD(at[10], at[24]); MULADD(at[11], at[23]); MULADD(at[12], at[22]); MULADD(at[13], at[21]); MULADD(at[14], at[20]); COMBA_STORE(C->dp[19]); /* 20 */ COMBA_FORWARD; MULADD(at[6], at[29]); MULADD(at[7], at[28]); MULADD(at[8], at[27]); MULADD(at[9], at[26]); MULADD(at[10], at[25]); MULADD(at[11], at[24]); MULADD(at[12], at[23]); MULADD(at[13], at[22]); MULADD(at[14], at[21]); COMBA_STORE(C->dp[20]); /* 21 */ COMBA_FORWARD; MULADD(at[7], at[29]); MULADD(at[8], at[28]); MULADD(at[9], at[27]); MULADD(at[10], at[26]); MULADD(at[11], at[25]); MULADD(at[12], at[24]); MULADD(at[13], at[23]); MULADD(at[14], at[22]); COMBA_STORE(C->dp[21]); /* 22 */ COMBA_FORWARD; MULADD(at[8], at[29]); MULADD(at[9], at[28]); MULADD(at[10], at[27]); MULADD(at[11], at[26]); MULADD(at[12], at[25]); MULADD(at[13], at[24]); MULADD(at[14], at[23]); COMBA_STORE(C->dp[22]); /* 23 */ COMBA_FORWARD; MULADD(at[9], at[29]); MULADD(at[10], at[28]); MULADD(at[11], at[27]); MULADD(at[12], at[26]); MULADD(at[13], at[25]); MULADD(at[14], at[24]); COMBA_STORE(C->dp[23]); /* 24 */ COMBA_FORWARD; MULADD(at[10], at[29]); MULADD(at[11], at[28]); MULADD(at[12], at[27]); MULADD(at[13], at[26]); MULADD(at[14], at[25]); COMBA_STORE(C->dp[24]); /* 25 */ COMBA_FORWARD; MULADD(at[11], at[29]); MULADD(at[12], at[28]); MULADD(at[13], at[27]); MULADD(at[14], at[26]); COMBA_STORE(C->dp[25]); /* 26 */ COMBA_FORWARD; MULADD(at[12], at[29]); MULADD(at[13], at[28]); MULADD(at[14], at[27]); COMBA_STORE(C->dp[26]); /* 27 */ COMBA_FORWARD; MULADD(at[13], at[29]); MULADD(at[14], at[28]); COMBA_STORE(C->dp[27]); /* 28 */ COMBA_FORWARD; MULADD(at[14], at[29]); COMBA_STORE(C->dp[28]); COMBA_STORE2(C->dp[29]); C->used = 30; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; break; case 16: memcpy(at, A->dp, 16 * sizeof(fp_digit)); memcpy(at+16, B->dp, 16 * sizeof(fp_digit)); COMBA_START; COMBA_CLEAR; /* 0 */ MULADD(at[0], at[16]); COMBA_STORE(C->dp[0]); /* 1 */ COMBA_FORWARD; MULADD(at[0], at[17]); MULADD(at[1], at[16]); COMBA_STORE(C->dp[1]); /* 2 */ COMBA_FORWARD; MULADD(at[0], at[18]); MULADD(at[1], at[17]); MULADD(at[2], at[16]); COMBA_STORE(C->dp[2]); /* 3 */ COMBA_FORWARD; MULADD(at[0], at[19]); MULADD(at[1], at[18]); MULADD(at[2], at[17]); MULADD(at[3], at[16]); COMBA_STORE(C->dp[3]); /* 4 */ COMBA_FORWARD; MULADD(at[0], at[20]); MULADD(at[1], at[19]); MULADD(at[2], at[18]); MULADD(at[3], at[17]); MULADD(at[4], at[16]); COMBA_STORE(C->dp[4]); /* 5 */ COMBA_FORWARD; MULADD(at[0], at[21]); MULADD(at[1], at[20]); MULADD(at[2], at[19]); MULADD(at[3], at[18]); MULADD(at[4], at[17]); MULADD(at[5], at[16]); COMBA_STORE(C->dp[5]); /* 6 */ COMBA_FORWARD; MULADD(at[0], at[22]); MULADD(at[1], at[21]); MULADD(at[2], at[20]); MULADD(at[3], at[19]); MULADD(at[4], at[18]); MULADD(at[5], at[17]); MULADD(at[6], at[16]); COMBA_STORE(C->dp[6]); /* 7 */ COMBA_FORWARD; MULADD(at[0], at[23]); MULADD(at[1], at[22]); MULADD(at[2], at[21]); MULADD(at[3], at[20]); MULADD(at[4], at[19]); MULADD(at[5], at[18]); MULADD(at[6], at[17]); MULADD(at[7], at[16]); COMBA_STORE(C->dp[7]); /* 8 */ COMBA_FORWARD; MULADD(at[0], at[24]); MULADD(at[1], at[23]); MULADD(at[2], at[22]); MULADD(at[3], at[21]); MULADD(at[4], at[20]); MULADD(at[5], at[19]); MULADD(at[6], at[18]); MULADD(at[7], at[17]); MULADD(at[8], at[16]); COMBA_STORE(C->dp[8]); /* 9 */ COMBA_FORWARD; MULADD(at[0], at[25]); MULADD(at[1], at[24]); MULADD(at[2], at[23]); MULADD(at[3], at[22]); MULADD(at[4], at[21]); MULADD(at[5], at[20]); MULADD(at[6], at[19]); MULADD(at[7], at[18]); MULADD(at[8], at[17]); MULADD(at[9], at[16]); COMBA_STORE(C->dp[9]); /* 10 */ COMBA_FORWARD; MULADD(at[0], at[26]); MULADD(at[1], at[25]); MULADD(at[2], at[24]); MULADD(at[3], at[23]); MULADD(at[4], at[22]); MULADD(at[5], at[21]); MULADD(at[6], at[20]); MULADD(at[7], at[19]); MULADD(at[8], at[18]); MULADD(at[9], at[17]); MULADD(at[10], at[16]); COMBA_STORE(C->dp[10]); /* 11 */ COMBA_FORWARD; MULADD(at[0], at[27]); MULADD(at[1], at[26]); MULADD(at[2], at[25]); MULADD(at[3], at[24]); MULADD(at[4], at[23]); MULADD(at[5], at[22]); MULADD(at[6], at[21]); MULADD(at[7], at[20]); MULADD(at[8], at[19]); MULADD(at[9], at[18]); MULADD(at[10], at[17]); MULADD(at[11], at[16]); COMBA_STORE(C->dp[11]); /* 12 */ COMBA_FORWARD; MULADD(at[0], at[28]); MULADD(at[1], at[27]); MULADD(at[2], at[26]); MULADD(at[3], at[25]); MULADD(at[4], at[24]); MULADD(at[5], at[23]); MULADD(at[6], at[22]); MULADD(at[7], at[21]); MULADD(at[8], at[20]); MULADD(at[9], at[19]); MULADD(at[10], at[18]); MULADD(at[11], at[17]); MULADD(at[12], at[16]); COMBA_STORE(C->dp[12]); /* 13 */ COMBA_FORWARD; MULADD(at[0], at[29]); MULADD(at[1], at[28]); MULADD(at[2], at[27]); MULADD(at[3], at[26]); MULADD(at[4], at[25]); MULADD(at[5], at[24]); MULADD(at[6], at[23]); MULADD(at[7], at[22]); MULADD(at[8], at[21]); MULADD(at[9], at[20]); MULADD(at[10], at[19]); MULADD(at[11], at[18]); MULADD(at[12], at[17]); MULADD(at[13], at[16]); COMBA_STORE(C->dp[13]); /* 14 */ COMBA_FORWARD; MULADD(at[0], at[30]); MULADD(at[1], at[29]); MULADD(at[2], at[28]); MULADD(at[3], at[27]); MULADD(at[4], at[26]); MULADD(at[5], at[25]); MULADD(at[6], at[24]); MULADD(at[7], at[23]); MULADD(at[8], at[22]); MULADD(at[9], at[21]); MULADD(at[10], at[20]); MULADD(at[11], at[19]); MULADD(at[12], at[18]); MULADD(at[13], at[17]); MULADD(at[14], at[16]); COMBA_STORE(C->dp[14]); /* 15 */ COMBA_FORWARD; MULADD(at[0], at[31]); MULADD(at[1], at[30]); MULADD(at[2], at[29]); MULADD(at[3], at[28]); MULADD(at[4], at[27]); MULADD(at[5], at[26]); MULADD(at[6], at[25]); MULADD(at[7], at[24]); MULADD(at[8], at[23]); MULADD(at[9], at[22]); MULADD(at[10], at[21]); MULADD(at[11], at[20]); MULADD(at[12], at[19]); MULADD(at[13], at[18]); MULADD(at[14], at[17]); MULADD(at[15], at[16]); COMBA_STORE(C->dp[15]); /* 16 */ COMBA_FORWARD; MULADD(at[1], at[31]); MULADD(at[2], at[30]); MULADD(at[3], at[29]); MULADD(at[4], at[28]); MULADD(at[5], at[27]); MULADD(at[6], at[26]); MULADD(at[7], at[25]); MULADD(at[8], at[24]); MULADD(at[9], at[23]); MULADD(at[10], at[22]); MULADD(at[11], at[21]); MULADD(at[12], at[20]); MULADD(at[13], at[19]); MULADD(at[14], at[18]); MULADD(at[15], at[17]); COMBA_STORE(C->dp[16]); /* 17 */ COMBA_FORWARD; MULADD(at[2], at[31]); MULADD(at[3], at[30]); MULADD(at[4], at[29]); MULADD(at[5], at[28]); MULADD(at[6], at[27]); MULADD(at[7], at[26]); MULADD(at[8], at[25]); MULADD(at[9], at[24]); MULADD(at[10], at[23]); MULADD(at[11], at[22]); MULADD(at[12], at[21]); MULADD(at[13], at[20]); MULADD(at[14], at[19]); MULADD(at[15], at[18]); COMBA_STORE(C->dp[17]); /* 18 */ COMBA_FORWARD; MULADD(at[3], at[31]); MULADD(at[4], at[30]); MULADD(at[5], at[29]); MULADD(at[6], at[28]); MULADD(at[7], at[27]); MULADD(at[8], at[26]); MULADD(at[9], at[25]); MULADD(at[10], at[24]); MULADD(at[11], at[23]); MULADD(at[12], at[22]); MULADD(at[13], at[21]); MULADD(at[14], at[20]); MULADD(at[15], at[19]); COMBA_STORE(C->dp[18]); /* 19 */ COMBA_FORWARD; MULADD(at[4], at[31]); MULADD(at[5], at[30]); MULADD(at[6], at[29]); MULADD(at[7], at[28]); MULADD(at[8], at[27]); MULADD(at[9], at[26]); MULADD(at[10], at[25]); MULADD(at[11], at[24]); MULADD(at[12], at[23]); MULADD(at[13], at[22]); MULADD(at[14], at[21]); MULADD(at[15], at[20]); COMBA_STORE(C->dp[19]); /* 20 */ COMBA_FORWARD; MULADD(at[5], at[31]); MULADD(at[6], at[30]); MULADD(at[7], at[29]); MULADD(at[8], at[28]); MULADD(at[9], at[27]); MULADD(at[10], at[26]); MULADD(at[11], at[25]); MULADD(at[12], at[24]); MULADD(at[13], at[23]); MULADD(at[14], at[22]); MULADD(at[15], at[21]); COMBA_STORE(C->dp[20]); /* 21 */ COMBA_FORWARD; MULADD(at[6], at[31]); MULADD(at[7], at[30]); MULADD(at[8], at[29]); MULADD(at[9], at[28]); MULADD(at[10], at[27]); MULADD(at[11], at[26]); MULADD(at[12], at[25]); MULADD(at[13], at[24]); MULADD(at[14], at[23]); MULADD(at[15], at[22]); COMBA_STORE(C->dp[21]); /* 22 */ COMBA_FORWARD; MULADD(at[7], at[31]); MULADD(at[8], at[30]); MULADD(at[9], at[29]); MULADD(at[10], at[28]); MULADD(at[11], at[27]); MULADD(at[12], at[26]); MULADD(at[13], at[25]); MULADD(at[14], at[24]); MULADD(at[15], at[23]); COMBA_STORE(C->dp[22]); /* 23 */ COMBA_FORWARD; MULADD(at[8], at[31]); MULADD(at[9], at[30]); MULADD(at[10], at[29]); MULADD(at[11], at[28]); MULADD(at[12], at[27]); MULADD(at[13], at[26]); MULADD(at[14], at[25]); MULADD(at[15], at[24]); COMBA_STORE(C->dp[23]); /* 24 */ COMBA_FORWARD; MULADD(at[9], at[31]); MULADD(at[10], at[30]); MULADD(at[11], at[29]); MULADD(at[12], at[28]); MULADD(at[13], at[27]); MULADD(at[14], at[26]); MULADD(at[15], at[25]); COMBA_STORE(C->dp[24]); /* 25 */ COMBA_FORWARD; MULADD(at[10], at[31]); MULADD(at[11], at[30]); MULADD(at[12], at[29]); MULADD(at[13], at[28]); MULADD(at[14], at[27]); MULADD(at[15], at[26]); COMBA_STORE(C->dp[25]); /* 26 */ COMBA_FORWARD; MULADD(at[11], at[31]); MULADD(at[12], at[30]); MULADD(at[13], at[29]); MULADD(at[14], at[28]); MULADD(at[15], at[27]); COMBA_STORE(C->dp[26]); /* 27 */ COMBA_FORWARD; MULADD(at[12], at[31]); MULADD(at[13], at[30]); MULADD(at[14], at[29]); MULADD(at[15], at[28]); COMBA_STORE(C->dp[27]); /* 28 */ COMBA_FORWARD; MULADD(at[13], at[31]); MULADD(at[14], at[30]); MULADD(at[15], at[29]); COMBA_STORE(C->dp[28]); /* 29 */ COMBA_FORWARD; MULADD(at[14], at[31]); MULADD(at[15], at[30]); COMBA_STORE(C->dp[29]); /* 30 */ COMBA_FORWARD; MULADD(at[15], at[31]); COMBA_STORE(C->dp[30]); COMBA_STORE2(C->dp[31]); C->used = 32; C->sign = A->sign ^ B->sign; fp_clamp(C); COMBA_FINI; break; } } #endif /* End: src/mul/fp_mul_comba_small_set.c */ /* Start: src/mul/fp_mul_d.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* c = a * b */ void fp_mul_d(fp_int *a, fp_digit b, fp_int *c) { fp_word w; int x, oldused; oldused = c->used; c->used = a->used; c->sign = a->sign; w = 0; for (x = 0; x < a->used; x++) { w = ((fp_word)a->dp[x]) * ((fp_word)b) + w; c->dp[x] = (fp_digit)w; w = w >> DIGIT_BIT; } if (w != 0 && (a->used != FP_SIZE)) { c->dp[c->used++] = w; ++x; } for (; x < oldused; x++) { c->dp[x] = 0; } fp_clamp(c); } /* $Source: /cvs/libtom/tomsfastmath/src/mul/fp_mul_d.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/mul/fp_mul_d.c */ /* Start: src/mul/fp_mulmod.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* d = a * b (mod c) */ int fp_mulmod(fp_int *a, fp_int *b, fp_int *c, fp_int *d) { fp_int tmp; fp_zero(&tmp); fp_mul(a, b, &tmp); return fp_mod(&tmp, c, d); } /* $Source: /cvs/libtom/tomsfastmath/src/mul/fp_mulmod.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/mul/fp_mulmod.c */ /* Start: src/numtheory/fp_gcd.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* c = (a, b) */ void fp_gcd(fp_int *a, fp_int *b, fp_int *c) { fp_int u, v, r; /* either zero than gcd is the largest */ if (fp_iszero (a) == 1 && fp_iszero (b) == 0) { fp_abs (b, c); return; } if (fp_iszero (a) == 0 && fp_iszero (b) == 1) { fp_abs (a, c); return; } /* optimized. At this point if a == 0 then * b must equal zero too */ if (fp_iszero (a) == 1) { fp_zero(c); return; } /* sort inputs */ if (fp_cmp_mag(a, b) != FP_LT) { fp_init_copy(&u, a); fp_init_copy(&v, b); } else { fp_init_copy(&u, b); fp_init_copy(&v, a); } fp_zero(&r); while (fp_iszero(&v) == FP_NO) { fp_mod(&u, &v, &r); fp_copy(&v, &u); fp_copy(&r, &v); } fp_copy(&u, c); } /* $Source: /cvs/libtom/tomsfastmath/src/numtheory/fp_gcd.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2007/01/24 21:25:19 $ */ /* End: src/numtheory/fp_gcd.c */ /* Start: src/numtheory/fp_invmod.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include static int fp_invmod_slow (fp_int * a, fp_int * b, fp_int * c) { fp_int x, y, u, v, A, B, C, D; int res; /* b cannot be negative */ if (b->sign == FP_NEG || fp_iszero(b) == 1) { return FP_VAL; } /* init temps */ fp_init(&x); fp_init(&y); fp_init(&u); fp_init(&v); fp_init(&A); fp_init(&B); fp_init(&C); fp_init(&D); /* x = a, y = b */ if ((res = fp_mod(a, b, &x)) != FP_OKAY) { return res; } fp_copy(b, &y); /* 2. [modified] if x,y are both even then return an error! */ if (fp_iseven (&x) == 1 && fp_iseven (&y) == 1) { return FP_VAL; } /* 3. u=x, v=y, A=1, B=0, C=0,D=1 */ fp_copy (&x, &u); fp_copy (&y, &v); fp_set (&A, 1); fp_set (&D, 1); top: /* 4. while u is even do */ while (fp_iseven (&u) == 1) { /* 4.1 u = u/2 */ fp_div_2 (&u, &u); /* 4.2 if A or B is odd then */ if (fp_isodd (&A) == 1 || fp_isodd (&B) == 1) { /* A = (A+y)/2, B = (B-x)/2 */ fp_add (&A, &y, &A); fp_sub (&B, &x, &B); } /* A = A/2, B = B/2 */ fp_div_2 (&A, &A); fp_div_2 (&B, &B); } /* 5. while v is even do */ while (fp_iseven (&v) == 1) { /* 5.1 v = v/2 */ fp_div_2 (&v, &v); /* 5.2 if C or D is odd then */ if (fp_isodd (&C) == 1 || fp_isodd (&D) == 1) { /* C = (C+y)/2, D = (D-x)/2 */ fp_add (&C, &y, &C); fp_sub (&D, &x, &D); } /* C = C/2, D = D/2 */ fp_div_2 (&C, &C); fp_div_2 (&D, &D); } /* 6. if u >= v then */ if (fp_cmp (&u, &v) != FP_LT) { /* u = u - v, A = A - C, B = B - D */ fp_sub (&u, &v, &u); fp_sub (&A, &C, &A); fp_sub (&B, &D, &B); } else { /* v - v - u, C = C - A, D = D - B */ fp_sub (&v, &u, &v); fp_sub (&C, &A, &C); fp_sub (&D, &B, &D); } /* if not zero goto step 4 */ if (fp_iszero (&u) == 0) goto top; /* now a = C, b = D, gcd == g*v */ /* if v != 1 then there is no inverse */ if (fp_cmp_d (&v, 1) != FP_EQ) { return FP_VAL; } /* if its too low */ while (fp_cmp_d(&C, 0) == FP_LT) { fp_add(&C, b, &C); } /* too big */ while (fp_cmp_mag(&C, b) != FP_LT) { fp_sub(&C, b, &C); } /* C is now the inverse */ fp_copy(&C, c); return FP_OKAY; } /* c = 1/a (mod b) for odd b only */ int fp_invmod(fp_int *a, fp_int *b, fp_int *c) { fp_int x, y, u, v, B, D; int neg; /* 2. [modified] b must be odd */ if (fp_iseven (b) == FP_YES) { return fp_invmod_slow(a,b,c); } /* init all our temps */ fp_init(&x); fp_init(&y); fp_init(&u); fp_init(&v); fp_init(&B); fp_init(&D); /* x == modulus, y == value to invert */ fp_copy(b, &x); /* we need y = |a| */ fp_abs(a, &y); /* 3. u=x, v=y, A=1, B=0, C=0,D=1 */ fp_copy(&x, &u); fp_copy(&y, &v); fp_set (&D, 1); top: /* 4. while u is even do */ while (fp_iseven (&u) == FP_YES) { /* 4.1 u = u/2 */ fp_div_2 (&u, &u); /* 4.2 if B is odd then */ if (fp_isodd (&B) == FP_YES) { fp_sub (&B, &x, &B); } /* B = B/2 */ fp_div_2 (&B, &B); } /* 5. while v is even do */ while (fp_iseven (&v) == FP_YES) { /* 5.1 v = v/2 */ fp_div_2 (&v, &v); /* 5.2 if D is odd then */ if (fp_isodd (&D) == FP_YES) { /* D = (D-x)/2 */ fp_sub (&D, &x, &D); } /* D = D/2 */ fp_div_2 (&D, &D); } /* 6. if u >= v then */ if (fp_cmp (&u, &v) != FP_LT) { /* u = u - v, B = B - D */ fp_sub (&u, &v, &u); fp_sub (&B, &D, &B); } else { /* v - v - u, D = D - B */ fp_sub (&v, &u, &v); fp_sub (&D, &B, &D); } /* if not zero goto step 4 */ if (fp_iszero (&u) == FP_NO) { goto top; } /* now a = C, b = D, gcd == g*v */ /* if v != 1 then there is no inverse */ if (fp_cmp_d (&v, 1) != FP_EQ) { return FP_VAL; } /* b is now the inverse */ neg = a->sign; while (D.sign == FP_NEG) { fp_add (&D, b, &D); } fp_copy (&D, c); c->sign = neg; return FP_OKAY; } /* $Source: /cvs/libtom/tomsfastmath/src/numtheory/fp_invmod.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2007/01/24 21:25:19 $ */ /* End: src/numtheory/fp_invmod.c */ /* Start: src/numtheory/fp_isprime.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* a few primes */ static const fp_digit primes[256] = { 0x0002, 0x0003, 0x0005, 0x0007, 0x000B, 0x000D, 0x0011, 0x0013, 0x0017, 0x001D, 0x001F, 0x0025, 0x0029, 0x002B, 0x002F, 0x0035, 0x003B, 0x003D, 0x0043, 0x0047, 0x0049, 0x004F, 0x0053, 0x0059, 0x0061, 0x0065, 0x0067, 0x006B, 0x006D, 0x0071, 0x007F, 0x0083, 0x0089, 0x008B, 0x0095, 0x0097, 0x009D, 0x00A3, 0x00A7, 0x00AD, 0x00B3, 0x00B5, 0x00BF, 0x00C1, 0x00C5, 0x00C7, 0x00D3, 0x00DF, 0x00E3, 0x00E5, 0x00E9, 0x00EF, 0x00F1, 0x00FB, 0x0101, 0x0107, 0x010D, 0x010F, 0x0115, 0x0119, 0x011B, 0x0125, 0x0133, 0x0137, 0x0139, 0x013D, 0x014B, 0x0151, 0x015B, 0x015D, 0x0161, 0x0167, 0x016F, 0x0175, 0x017B, 0x017F, 0x0185, 0x018D, 0x0191, 0x0199, 0x01A3, 0x01A5, 0x01AF, 0x01B1, 0x01B7, 0x01BB, 0x01C1, 0x01C9, 0x01CD, 0x01CF, 0x01D3, 0x01DF, 0x01E7, 0x01EB, 0x01F3, 0x01F7, 0x01FD, 0x0209, 0x020B, 0x021D, 0x0223, 0x022D, 0x0233, 0x0239, 0x023B, 0x0241, 0x024B, 0x0251, 0x0257, 0x0259, 0x025F, 0x0265, 0x0269, 0x026B, 0x0277, 0x0281, 0x0283, 0x0287, 0x028D, 0x0293, 0x0295, 0x02A1, 0x02A5, 0x02AB, 0x02B3, 0x02BD, 0x02C5, 0x02CF, 0x02D7, 0x02DD, 0x02E3, 0x02E7, 0x02EF, 0x02F5, 0x02F9, 0x0301, 0x0305, 0x0313, 0x031D, 0x0329, 0x032B, 0x0335, 0x0337, 0x033B, 0x033D, 0x0347, 0x0355, 0x0359, 0x035B, 0x035F, 0x036D, 0x0371, 0x0373, 0x0377, 0x038B, 0x038F, 0x0397, 0x03A1, 0x03A9, 0x03AD, 0x03B3, 0x03B9, 0x03C7, 0x03CB, 0x03D1, 0x03D7, 0x03DF, 0x03E5, 0x03F1, 0x03F5, 0x03FB, 0x03FD, 0x0407, 0x0409, 0x040F, 0x0419, 0x041B, 0x0425, 0x0427, 0x042D, 0x043F, 0x0443, 0x0445, 0x0449, 0x044F, 0x0455, 0x045D, 0x0463, 0x0469, 0x047F, 0x0481, 0x048B, 0x0493, 0x049D, 0x04A3, 0x04A9, 0x04B1, 0x04BD, 0x04C1, 0x04C7, 0x04CD, 0x04CF, 0x04D5, 0x04E1, 0x04EB, 0x04FD, 0x04FF, 0x0503, 0x0509, 0x050B, 0x0511, 0x0515, 0x0517, 0x051B, 0x0527, 0x0529, 0x052F, 0x0551, 0x0557, 0x055D, 0x0565, 0x0577, 0x0581, 0x058F, 0x0593, 0x0595, 0x0599, 0x059F, 0x05A7, 0x05AB, 0x05AD, 0x05B3, 0x05BF, 0x05C9, 0x05CB, 0x05CF, 0x05D1, 0x05D5, 0x05DB, 0x05E7, 0x05F3, 0x05FB, 0x0607, 0x060D, 0x0611, 0x0617, 0x061F, 0x0623, 0x062B, 0x062F, 0x063D, 0x0641, 0x0647, 0x0649, 0x064D, 0x0653 }; int fp_isprime(fp_int *a) { fp_int b; fp_digit d; int r, res; /* do trial division */ for (r = 0; r < 256; r++) { fp_mod_d(a, primes[r], &d); if (d == 0) { return FP_NO; } } /* now do 8 miller rabins */ fp_init(&b); for (r = 0; r < 8; r++) { fp_set(&b, primes[r]); fp_prime_miller_rabin(a, &b, &res); if (res == FP_NO) { return FP_NO; } } return FP_YES; } /* $Source: /cvs/libtom/tomsfastmath/src/numtheory/fp_isprime.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2007/01/24 21:25:19 $ */ /* End: src/numtheory/fp_isprime.c */ /* Start: src/numtheory/fp_lcm.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* c = [a, b] */ void fp_lcm(fp_int *a, fp_int *b, fp_int *c) { fp_int t1, t2; fp_init(&t1); fp_init(&t2); fp_gcd(a, b, &t1); if (fp_cmp_mag(a, b) == FP_GT) { fp_div(a, &t1, &t2, NULL); fp_mul(b, &t2, c); } else { fp_div(b, &t1, &t2, NULL); fp_mul(a, &t2, c); } } /* $Source: /cvs/libtom/tomsfastmath/src/numtheory/fp_lcm.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2007/01/24 21:25:19 $ */ /* End: src/numtheory/fp_lcm.c */ /* Start: src/numtheory/fp_prime_miller_rabin.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* Miller-Rabin test of "a" to the base of "b" as described in * HAC pp. 139 Algorithm 4.24 * * Sets result to 0 if definitely composite or 1 if probably prime. * Randomly the chance of error is no more than 1/4 and often * very much lower. */ void fp_prime_miller_rabin (fp_int * a, fp_int * b, int *result) { fp_int n1, y, r; int s, j; /* default */ *result = FP_NO; /* ensure b > 1 */ if (fp_cmp_d(b, 1) != FP_GT) { return; } /* get n1 = a - 1 */ fp_init_copy(&n1, a); fp_sub_d(&n1, 1, &n1); /* set 2**s * r = n1 */ fp_init_copy(&r, &n1); /* count the number of least significant bits * which are zero */ s = fp_cnt_lsb(&r); /* now divide n - 1 by 2**s */ fp_div_2d (&r, s, &r, NULL); /* compute y = b**r mod a */ fp_init(&y); fp_exptmod(b, &r, a, &y); /* if y != 1 and y != n1 do */ if (fp_cmp_d (&y, 1) != FP_EQ && fp_cmp (&y, &n1) != FP_EQ) { j = 1; /* while j <= s-1 and y != n1 */ while ((j <= (s - 1)) && fp_cmp (&y, &n1) != FP_EQ) { fp_sqrmod (&y, a, &y); /* if y == 1 then composite */ if (fp_cmp_d (&y, 1) == FP_EQ) { return; } ++j; } /* if y != n1 then composite */ if (fp_cmp (&y, &n1) != FP_EQ) { return; } } /* probably prime now */ *result = FP_YES; } /* $Source: /cvs/libtom/tomsfastmath/src/numtheory/fp_prime_miller_rabin.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2007/01/24 21:25:19 $ */ /* End: src/numtheory/fp_prime_miller_rabin.c */ /* Start: src/numtheory/fp_prime_random_ex.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* This is possibly the mother of all prime generation functions, muahahahahaha! */ int fp_prime_random_ex(fp_int *a, int t, int size, int flags, tfm_prime_callback cb, void *dat) { unsigned char *tmp, maskAND, maskOR_msb, maskOR_lsb; int res, err, bsize, maskOR_msb_offset; /* sanity check the input */ if (size <= 1 || t <= 0) { return FP_VAL; } /* TFM_PRIME_SAFE implies TFM_PRIME_BBS */ if (flags & TFM_PRIME_SAFE) { flags |= TFM_PRIME_BBS; } /* calc the byte size */ bsize = (size>>3)+(size&7?1:0); /* we need a buffer of bsize bytes */ tmp = malloc(bsize); if (tmp == NULL) { return FP_MEM; } /* calc the maskAND value for the MSbyte*/ maskAND = 0xFF >> (8 - (size & 7)); /* calc the maskOR_msb */ maskOR_msb = 0; maskOR_msb_offset = (size - 2) >> 3; if (flags & TFM_PRIME_2MSB_ON) { maskOR_msb |= 1 << ((size - 2) & 7); } else if (flags & TFM_PRIME_2MSB_OFF) { maskAND &= ~(1 << ((size - 2) & 7)); } /* get the maskOR_lsb */ maskOR_lsb = 1; if (flags & TFM_PRIME_BBS) { maskOR_lsb |= 3; } do { /* read the bytes */ if (cb(tmp, bsize, dat) != bsize) { err = FP_VAL; goto error; } /* work over the MSbyte */ tmp[0] &= maskAND; tmp[0] |= 1 << ((size - 1) & 7); /* mix in the maskORs */ tmp[maskOR_msb_offset] |= maskOR_msb; tmp[bsize-1] |= maskOR_lsb; /* read it in */ fp_read_unsigned_bin(a, tmp, bsize); /* is it prime? */ res = fp_isprime(a); if (res == FP_NO) continue; if (flags & TFM_PRIME_SAFE) { /* see if (a-1)/2 is prime */ fp_sub_d(a, 1, a); fp_div_2(a, a); /* is it prime? */ res = fp_isprime(a); } } while (res == FP_NO); if (flags & TFM_PRIME_SAFE) { /* restore a to the original value */ fp_mul_2(a, a); fp_add_d(a, 1, a); } err = FP_OKAY; error: free(tmp); return err; } /* $Source: /cvs/libtom/tomsfastmath/src/numtheory/fp_prime_random_ex.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2007/01/24 21:25:19 $ */ /* End: src/numtheory/fp_prime_random_ex.c */ /* Start: src/sqr/fp_sqr.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* b = a*a */ void fp_sqr(fp_int *A, fp_int *B) { int y; /* call generic if we're out of range */ if (A->used + A->used > FP_SIZE) { fp_sqr_comba(A, B); return ; } y = A->used; #if defined(TFM_SQR3) if (y <= 3) { fp_sqr_comba3(A,B); return; } #endif #if defined(TFM_SQR4) if (y == 4) { fp_sqr_comba4(A,B); return; } #endif #if defined(TFM_SQR6) if (y <= 6) { fp_sqr_comba6(A,B); return; } #endif #if defined(TFM_SQR7) if (y == 7) { fp_sqr_comba7(A,B); return; } #endif #if defined(TFM_SQR8) if (y == 8) { fp_sqr_comba8(A,B); return; } #endif #if defined(TFM_SQR9) if (y == 9) { fp_sqr_comba9(A,B); return; } #endif #if defined(TFM_SQR12) if (y <= 12) { fp_sqr_comba12(A,B); return; } #endif #if defined(TFM_SQR17) if (y <= 17) { fp_sqr_comba17(A,B); return; } #endif #if defined(TFM_SMALL_SET) if (y <= 16) { fp_sqr_comba_small(A,B); return; } #endif #if defined(TFM_SQR20) if (y <= 20) { fp_sqr_comba20(A,B); return; } #endif #if defined(TFM_SQR24) if (y <= 24) { fp_sqr_comba24(A,B); return; } #endif #if defined(TFM_SQR28) if (y <= 28) { fp_sqr_comba28(A,B); return; } #endif #if defined(TFM_SQR32) if (y <= 32) { fp_sqr_comba32(A,B); return; } #endif #if defined(TFM_SQR48) if (y <= 48) { fp_sqr_comba48(A,B); return; } #endif #if defined(TFM_SQR64) if (y <= 64) { fp_sqr_comba64(A,B); return; } #endif fp_sqr_comba(A, B); } /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/sqr/fp_sqr.c */ /* Start: src/sqr/fp_sqr_comba.c */ /* * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include #if defined(TFM_PRESCOTT) && defined(TFM_SSE2) #undef TFM_SSE2 #define TFM_X86 #endif #if defined(TFM_X86) /* x86-32 optimized */ #define COMBA_START #define CLEAR_CARRY \ c0 = c1 = c2 = 0; #define COMBA_STORE(x) \ x = c0; #define COMBA_STORE2(x) \ x = c1; #define CARRY_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); #define COMBA_FINI #define SQRADD(i, j) \ asm( \ "movl %6,%%eax \n\t" \ "mull %%eax \n\t" \ "addl %%eax,%0 \n\t" \ "adcl %%edx,%1 \n\t" \ "adcl $0,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "m"(i) :"%eax","%edx","%cc"); #define SQRADD2(i, j) \ asm( \ "movl %6,%%eax \n\t" \ "mull %7 \n\t" \ "addl %%eax,%0 \n\t" \ "adcl %%edx,%1 \n\t" \ "adcl $0,%2 \n\t" \ "addl %%eax,%0 \n\t" \ "adcl %%edx,%1 \n\t" \ "adcl $0,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "m"(i), "m"(j) :"%eax","%edx","%cc"); #define SQRADDSC(i, j) \ asm( \ "movl %6,%%eax \n\t" \ "mull %7 \n\t" \ "movl %%eax,%0 \n\t" \ "movl %%edx,%1 \n\t" \ "xorl %2,%2 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2): "0"(sc0), "1"(sc1), "2"(sc2), "g"(i), "g"(j) :"%eax","%edx","%cc"); #define SQRADDAC(i, j) \ asm( \ "movl %6,%%eax \n\t" \ "mull %7 \n\t" \ "addl %%eax,%0 \n\t" \ "adcl %%edx,%1 \n\t" \ "adcl $0,%2 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2): "0"(sc0), "1"(sc1), "2"(sc2), "g"(i), "g"(j) :"%eax","%edx","%cc"); #define SQRADDDB \ asm( \ "addl %6,%0 \n\t" \ "adcl %7,%1 \n\t" \ "adcl %8,%2 \n\t" \ "addl %6,%0 \n\t" \ "adcl %7,%1 \n\t" \ "adcl %8,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2) : "0"(c0), "1"(c1), "2"(c2), "r"(sc0), "r"(sc1), "r"(sc2) : "%cc"); #elif defined(TFM_X86_64) /* x86-64 optimized */ #define COMBA_START #define CLEAR_CARRY \ c0 = c1 = c2 = 0; #define COMBA_STORE(x) \ x = c0; #define COMBA_STORE2(x) \ x = c1; #define CARRY_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); #define COMBA_FINI #define SQRADD(i, j) \ asm( \ "movq %6,%%rax \n\t" \ "mulq %%rax \n\t" \ "addq %%rax,%0 \n\t" \ "adcq %%rdx,%1 \n\t" \ "adcq $0,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "g"(i) :"%rax","%rdx","%cc"); #define SQRADD2(i, j) \ asm( \ "movq %6,%%rax \n\t" \ "mulq %7 \n\t" \ "addq %%rax,%0 \n\t" \ "adcq %%rdx,%1 \n\t" \ "adcq $0,%2 \n\t" \ "addq %%rax,%0 \n\t" \ "adcq %%rdx,%1 \n\t" \ "adcq $0,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "g"(i), "g"(j) :"%rax","%rdx","%cc"); #define SQRADDSC(i, j) \ asm( \ "movq %6,%%rax \n\t" \ "mulq %7 \n\t" \ "movq %%rax,%0 \n\t" \ "movq %%rdx,%1 \n\t" \ "xorq %2,%2 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2): "0"(sc0), "1"(sc1), "2"(sc2), "g"(i), "g"(j) :"%rax","%rdx","%cc"); #define SQRADDAC(i, j) \ asm( \ "movq %6,%%rax \n\t" \ "mulq %7 \n\t" \ "addq %%rax,%0 \n\t" \ "adcq %%rdx,%1 \n\t" \ "adcq $0,%2 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2): "0"(sc0), "1"(sc1), "2"(sc2), "g"(i), "g"(j) :"%rax","%rdx","%cc"); #define SQRADDDB \ asm( \ "addq %6,%0 \n\t" \ "adcq %7,%1 \n\t" \ "adcq %8,%2 \n\t" \ "addq %6,%0 \n\t" \ "adcq %7,%1 \n\t" \ "adcq %8,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2) : "0"(c0), "1"(c1), "2"(c2), "r"(sc0), "r"(sc1), "r"(sc2) : "%cc"); #elif defined(TFM_SSE2) /* SSE2 Optimized */ #define COMBA_START #define CLEAR_CARRY \ c0 = c1 = c2 = 0; #define COMBA_STORE(x) \ x = c0; #define COMBA_STORE2(x) \ x = c1; #define CARRY_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); #define COMBA_FINI \ asm("emms"); #define SQRADD(i, j) \ asm( \ "movd %6,%%mm0 \n\t" \ "pmuludq %%mm0,%%mm0\n\t" \ "movd %%mm0,%%eax \n\t" \ "psrlq $32,%%mm0 \n\t" \ "addl %%eax,%0 \n\t" \ "movd %%mm0,%%eax \n\t" \ "adcl %%eax,%1 \n\t" \ "adcl $0,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "m"(i) :"%eax","%cc"); #define SQRADD2(i, j) \ asm( \ "movd %6,%%mm0 \n\t" \ "movd %7,%%mm1 \n\t" \ "pmuludq %%mm1,%%mm0\n\t" \ "movd %%mm0,%%eax \n\t" \ "psrlq $32,%%mm0 \n\t" \ "movd %%mm0,%%edx \n\t" \ "addl %%eax,%0 \n\t" \ "adcl %%edx,%1 \n\t" \ "adcl $0,%2 \n\t" \ "addl %%eax,%0 \n\t" \ "adcl %%edx,%1 \n\t" \ "adcl $0,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2): "0"(c0), "1"(c1), "2"(c2), "m"(i), "m"(j) :"%eax","%edx","%cc"); #define SQRADDSC(i, j) \ asm( \ "movd %6,%%mm0 \n\t" \ "movd %7,%%mm1 \n\t" \ "pmuludq %%mm1,%%mm0\n\t" \ "movd %%mm0,%0 \n\t" \ "psrlq $32,%%mm0 \n\t" \ "movd %%mm0,%1 \n\t" \ "xorl %2,%2 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2): "0"(sc0), "1"(sc1), "2"(sc2), "m"(i), "m"(j)); #define SQRADDAC(i, j) \ asm( \ "movd %6,%%mm0 \n\t" \ "movd %7,%%mm1 \n\t" \ "pmuludq %%mm1,%%mm0\n\t" \ "movd %%mm0,%%eax \n\t" \ "psrlq $32,%%mm0 \n\t" \ "movd %%mm0,%%edx \n\t" \ "addl %%eax,%0 \n\t" \ "adcl %%edx,%1 \n\t" \ "adcl $0,%2 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2): "0"(sc0), "1"(sc1), "2"(sc2), "m"(i), "m"(j) :"%eax","%edx","%cc"); #define SQRADDDB \ asm( \ "addl %6,%0 \n\t" \ "adcl %7,%1 \n\t" \ "adcl %8,%2 \n\t" \ "addl %6,%0 \n\t" \ "adcl %7,%1 \n\t" \ "adcl %8,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2) : "0"(c0), "1"(c1), "2"(c2), "r"(sc0), "r"(sc1), "r"(sc2) : "%cc"); #elif defined(TFM_ARM) /* ARM code */ #define COMBA_START #define CLEAR_CARRY \ c0 = c1 = c2 = 0; #define COMBA_STORE(x) \ x = c0; #define COMBA_STORE2(x) \ x = c1; #define CARRY_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); #define COMBA_FINI /* multiplies point i and j, updates carry "c1" and digit c2 */ #define SQRADD(i, j) \ asm( \ " UMULL r0,r1,%6,%6 \n\t" \ " ADDS %0,%0,r0 \n\t" \ " ADCS %1,%1,r1 \n\t" \ " ADC %2,%2,#0 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2) : "0"(c0), "1"(c1), "2"(c2), "r"(i) : "r0", "r1", "%cc"); /* for squaring some of the terms are doubled... */ #define SQRADD2(i, j) \ asm( \ " UMULL r0,r1,%6,%7 \n\t" \ " ADDS %0,%0,r0 \n\t" \ " ADCS %1,%1,r1 \n\t" \ " ADC %2,%2,#0 \n\t" \ " ADDS %0,%0,r0 \n\t" \ " ADCS %1,%1,r1 \n\t" \ " ADC %2,%2,#0 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2) : "0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j) : "r0", "r1", "%cc"); #define SQRADDSC(i, j) \ asm( \ " UMULL %0,%1,%6,%7 \n\t" \ " SUB %2,%2,%2 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2) : "0"(sc0), "1"(sc1), "2"(sc2), "r"(i), "r"(j) : "%cc"); #define SQRADDAC(i, j) \ asm( \ " UMULL r0,r1,%6,%7 \n\t" \ " ADDS %0,%0,r0 \n\t" \ " ADCS %1,%1,r1 \n\t" \ " ADC %2,%2,#0 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2) : "0"(sc0), "1"(sc1), "2"(sc2), "r"(i), "r"(j) : "r0", "r1", "%cc"); #define SQRADDDB \ asm( \ " ADDS %0,%0,%3 \n\t" \ " ADCS %1,%1,%4 \n\t" \ " ADC %2,%2,%5 \n\t" \ " ADDS %0,%0,%3 \n\t" \ " ADCS %1,%1,%4 \n\t" \ " ADC %2,%2,%5 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2) : "r"(sc0), "r"(sc1), "r"(sc2), "0"(c0), "1"(c1), "2"(c2) : "%cc"); #elif defined(TFM_PPC32) /* PPC32 */ #define COMBA_START #define CLEAR_CARRY \ c0 = c1 = c2 = 0; #define COMBA_STORE(x) \ x = c0; #define COMBA_STORE2(x) \ x = c1; #define CARRY_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); #define COMBA_FINI /* multiplies point i and j, updates carry "c1" and digit c2 */ #define SQRADD(i, j) \ asm( \ " mullw 16,%6,%6 \n\t" \ " addc %0,%0,16 \n\t" \ " mulhwu 16,%6,%6 \n\t" \ " adde %1,%1,16 \n\t" \ " addze %2,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i):"16","%cc"); /* for squaring some of the terms are doubled... */ #define SQRADD2(i, j) \ asm( \ " mullw 16,%6,%7 \n\t" \ " mulhwu 17,%6,%7 \n\t" \ " addc %0,%0,16 \n\t" \ " adde %1,%1,17 \n\t" \ " addze %2,%2 \n\t" \ " addc %0,%0,16 \n\t" \ " adde %1,%1,17 \n\t" \ " addze %2,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j):"16", "17","%cc"); #define SQRADDSC(i, j) \ asm( \ " mullw %0,%6,%7 \n\t" \ " mulhwu %1,%6,%7 \n\t" \ " xor %2,%2,%2 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i),"r"(j) : "%cc"); #define SQRADDAC(i, j) \ asm( \ " mullw 16,%6,%7 \n\t" \ " addc %0,%0,16 \n\t" \ " mulhwu 16,%6,%7 \n\t" \ " adde %1,%1,16 \n\t" \ " addze %2,%2 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i), "r"(j):"16", "%cc"); #define SQRADDDB \ asm( \ " addc %0,%0,%3 \n\t" \ " adde %1,%1,%4 \n\t" \ " adde %2,%2,%5 \n\t" \ " addc %0,%0,%3 \n\t" \ " adde %1,%1,%4 \n\t" \ " adde %2,%2,%5 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2) : "r"(sc0), "r"(sc1), "r"(sc2), "0"(c0), "1"(c1), "2"(c2) : "%cc"); #elif defined(TFM_PPC64) /* PPC64 */ #define COMBA_START #define CLEAR_CARRY \ c0 = c1 = c2 = 0; #define COMBA_STORE(x) \ x = c0; #define COMBA_STORE2(x) \ x = c1; #define CARRY_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); #define COMBA_FINI /* multiplies point i and j, updates carry "c1" and digit c2 */ #define SQRADD(i, j) \ asm( \ " mulld r16,%6,%6 \n\t" \ " addc %0,%0,r16 \n\t" \ " mulhdu r16,%6,%6 \n\t" \ " adde %1,%1,r16 \n\t" \ " addze %2,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i):"r16","%cc"); /* for squaring some of the terms are doubled... */ #define SQRADD2(i, j) \ asm( \ " mulld r16,%6,%7 \n\t" \ " mulhdu r17,%6,%7 \n\t" \ " addc %0,%0,r16 \n\t" \ " adde %1,%1,r17 \n\t" \ " addze %2,%2 \n\t" \ " addc %0,%0,r16 \n\t" \ " adde %1,%1,r17 \n\t" \ " addze %2,%2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j):"r16", "r17","%cc"); #define SQRADDSC(i, j) \ asm( \ " mulld %0,%6,%7 \n\t" \ " mulhdu %1,%6,%7 \n\t" \ " xor %2,%2,%2 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i),"r"(j) : "%cc"); #define SQRADDAC(i, j) \ asm( \ " mulld r16,%6,%7 \n\t" \ " addc %0,%0,r16 \n\t" \ " mulhdu r16,%6,%7 \n\t" \ " adde %1,%1,r16 \n\t" \ " addze %2,%2 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i), "r"(j):"r16", "%cc"); #define SQRADDDB \ asm( \ " addc %0,%0,%3 \n\t" \ " adde %1,%1,%4 \n\t" \ " adde %2,%2,%5 \n\t" \ " addc %0,%0,%3 \n\t" \ " adde %1,%1,%4 \n\t" \ " adde %2,%2,%5 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2) : "r"(sc0), "r"(sc1), "r"(sc2), "0"(c0), "1"(c1), "2"(c2) : "%cc"); #elif defined(TFM_AVR32) /* AVR32 */ #define COMBA_START #define CLEAR_CARRY \ c0 = c1 = c2 = 0; #define COMBA_STORE(x) \ x = c0; #define COMBA_STORE2(x) \ x = c1; #define CARRY_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); #define COMBA_FINI /* multiplies point i and j, updates carry "c1" and digit c2 */ #define SQRADD(i, j) \ asm( \ " mulu.d r2,%6,%6 \n\t" \ " add %0,%0,r2 \n\t" \ " adc %1,%1,r3 \n\t" \ " acr %2 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i):"r2","r3"); /* for squaring some of the terms are doubled... */ #define SQRADD2(i, j) \ asm( \ " mulu.d r2,%6,%7 \n\t" \ " add %0,%0,r2 \n\t" \ " adc %1,%1,r3 \n\t" \ " acr %2, \n\t" \ " add %0,%0,r2 \n\t" \ " adc %1,%1,r3 \n\t" \ " acr %2, \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j):"r2", "r3"); #define SQRADDSC(i, j) \ asm( \ " mulu.d r2,%6,%7 \n\t" \ " mov %0,r2 \n\t" \ " mov %1,r3 \n\t" \ " eor %2,%2 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i),"r"(j) : "r2", "r3"); #define SQRADDAC(i, j) \ asm( \ " mulu.d r2,%6,%7 \n\t" \ " add %0,%0,r2 \n\t" \ " adc %1,%1,r3 \n\t" \ " acr %2 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i), "r"(j):"r2", "r3"); #define SQRADDDB \ asm( \ " add %0,%0,%3 \n\t" \ " adc %1,%1,%4 \n\t" \ " adc %2,%2,%5 \n\t" \ " add %0,%0,%3 \n\t" \ " adc %1,%1,%4 \n\t" \ " adc %2,%2,%5 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2) : "r"(sc0), "r"(sc1), "r"(sc2), "0"(c0), "1"(c1), "2"(c2) : "%cc"); #elif defined(TFM_MIPS) /* MIPS */ #define COMBA_START #define CLEAR_CARRY \ c0 = c1 = c2 = 0; #define COMBA_STORE(x) \ x = c0; #define COMBA_STORE2(x) \ x = c1; #define CARRY_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); #define COMBA_FINI /* multiplies point i and j, updates carry "c1" and digit c2 */ #define SQRADD(i, j) \ asm( \ " multu %6,%6 \n\t" \ " mflo $12 \n\t" \ " mfhi $13 \n\t" \ " addu %0,%0,$12 \n\t" \ " sltu $12,%0,$12 \n\t" \ " addu %1,%1,$13 \n\t" \ " sltu $13,%1,$13 \n\t" \ " addu %1,%1,$12 \n\t" \ " sltu $12,%1,$12 \n\t" \ " addu %2,%2,$13 \n\t" \ " addu %2,%2,$12 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i):"$12","$13"); /* for squaring some of the terms are doubled... */ #define SQRADD2(i, j) \ asm( \ " multu %6,%7 \n\t" \ " mflo $12 \n\t" \ " mfhi $13 \n\t" \ \ " addu %0,%0,$12 \n\t" \ " sltu $14,%0,$12 \n\t" \ " addu %1,%1,$13 \n\t" \ " sltu $15,%1,$13 \n\t" \ " addu %1,%1,$14 \n\t" \ " sltu $14,%1,$14 \n\t" \ " addu %2,%2,$15 \n\t" \ " addu %2,%2,$14 \n\t" \ \ " addu %0,%0,$12 \n\t" \ " sltu $14,%0,$12 \n\t" \ " addu %1,%1,$13 \n\t" \ " sltu $15,%1,$13 \n\t" \ " addu %1,%1,$14 \n\t" \ " sltu $14,%1,$14 \n\t" \ " addu %2,%2,$15 \n\t" \ " addu %2,%2,$14 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2):"0"(c0), "1"(c1), "2"(c2), "r"(i), "r"(j):"$12", "$13", "$14", "$15"); #define SQRADDSC(i, j) \ asm( \ " multu %6,%7 \n\t" \ " mflo %0 \n\t" \ " mfhi %1 \n\t" \ " xor %2,%2,%2 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i),"r"(j) : "%cc"); #define SQRADDAC(i, j) \ asm( \ " multu %6,%7 \n\t" \ " mflo $12 \n\t" \ " mfhi $13 \n\t" \ " addu %0,%0,$12 \n\t" \ " sltu $12,%0,$12 \n\t" \ " addu %1,%1,$13 \n\t" \ " sltu $13,%1,$13 \n\t" \ " addu %1,%1,$12 \n\t" \ " sltu $12,%1,$12 \n\t" \ " addu %2,%2,$13 \n\t" \ " addu %2,%2,$12 \n\t" \ :"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2), "r"(i), "r"(j):"$12", "$13", "$14"); #define SQRADDDB \ asm( \ " addu %0,%0,%3 \n\t" \ " sltu $10,%0,%3 \n\t" \ " addu %1,%1,$10 \n\t" \ " sltu $10,%1,$10 \n\t" \ " addu %1,%1,%4 \n\t" \ " sltu $11,%1,%4 \n\t" \ " addu %2,%2,$10 \n\t" \ " addu %2,%2,$11 \n\t" \ " addu %2,%2,%5 \n\t" \ \ " addu %0,%0,%3 \n\t" \ " sltu $10,%0,%3 \n\t" \ " addu %1,%1,$10 \n\t" \ " sltu $10,%1,$10 \n\t" \ " addu %1,%1,%4 \n\t" \ " sltu $11,%1,%4 \n\t" \ " addu %2,%2,$10 \n\t" \ " addu %2,%2,$11 \n\t" \ " addu %2,%2,%5 \n\t" \ :"=r"(c0), "=r"(c1), "=r"(c2) : "r"(sc0), "r"(sc1), "r"(sc2), "0"(c0), "1"(c1), "2"(c2) : "$10", "$11"); #else #define TFM_ISO /* ISO C portable code */ #define COMBA_START #define CLEAR_CARRY \ c0 = c1 = c2 = 0; #define COMBA_STORE(x) \ x = c0; #define COMBA_STORE2(x) \ x = c1; #define CARRY_FORWARD \ do { c0 = c1; c1 = c2; c2 = 0; } while (0); #define COMBA_FINI /* multiplies point i and j, updates carry "c1" and digit c2 */ #define SQRADD(i, j) \ do { fp_word t; \ t = c0 + ((fp_word)i) * ((fp_word)j); c0 = t; \ t = c1 + (t >> DIGIT_BIT); c1 = t; c2 += t >> DIGIT_BIT; \ } while (0); /* for squaring some of the terms are doubled... */ #define SQRADD2(i, j) \ do { fp_word t; \ t = ((fp_word)i) * ((fp_word)j); \ tt = (fp_word)c0 + t; c0 = tt; \ tt = (fp_word)c1 + (tt >> DIGIT_BIT); c1 = tt; c2 += tt >> DIGIT_BIT; \ tt = (fp_word)c0 + t; c0 = tt; \ tt = (fp_word)c1 + (tt >> DIGIT_BIT); c1 = tt; c2 += tt >> DIGIT_BIT; \ } while (0); #define SQRADDSC(i, j) \ do { fp_word t; \ t = ((fp_word)i) * ((fp_word)j); \ sc0 = (fp_digit)t; sc1 = (t >> DIGIT_BIT); sc2 = 0; \ } while (0); #define SQRADDAC(i, j) \ do { fp_word t; \ t = sc0 + ((fp_word)i) * ((fp_word)j); sc0 = t; \ t = sc1 + (t >> DIGIT_BIT); sc1 = t; sc2 += t >> DIGIT_BIT; \ } while (0); #define SQRADDDB \ do { fp_word t; \ t = ((fp_word)sc0) + ((fp_word)sc0) + c0; c0 = t; \ t = ((fp_word)sc1) + ((fp_word)sc1) + c1 + (t >> DIGIT_BIT); c1 = t; \ c2 = c2 + ((fp_word)sc2) + ((fp_word)sc2) + (t >> DIGIT_BIT); \ } while (0); #endif /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr_comba.c,v $ */ /* $Revision: 1.4 $ */ /* $Date: 2007/03/14 23:47:42 $ */ /* End: src/sqr/fp_sqr_comba.c */ /* Start: src/sqr/fp_sqr_comba_12.c */ #define TFM_DEFINES ////#include "fp_sqr_comba.c" #ifdef TFM_SQR12 void fp_sqr_comba12(fp_int *A, fp_int *B) { fp_digit *a, b[24], c0, c1, c2, sc0, sc1, sc2; #ifdef TFM_ISO fp_word tt; #endif a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADDSC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADDSC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADDSC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADDSC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADDSC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); COMBA_STORE(b[16]); /* output 17 */ CARRY_FORWARD; SQRADDSC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; COMBA_STORE(b[17]); /* output 18 */ CARRY_FORWARD; SQRADD2(a[7], a[11]); SQRADD2(a[8], a[10]); SQRADD(a[9], a[9]); COMBA_STORE(b[18]); /* output 19 */ CARRY_FORWARD; SQRADD2(a[8], a[11]); SQRADD2(a[9], a[10]); COMBA_STORE(b[19]); /* output 20 */ CARRY_FORWARD; SQRADD2(a[9], a[11]); SQRADD(a[10], a[10]); COMBA_STORE(b[20]); /* output 21 */ CARRY_FORWARD; SQRADD2(a[10], a[11]); COMBA_STORE(b[21]); /* output 22 */ CARRY_FORWARD; SQRADD(a[11], a[11]); COMBA_STORE(b[22]); COMBA_STORE2(b[23]); COMBA_FINI; B->used = 24; B->sign = FP_ZPOS; memcpy(B->dp, b, 24 * sizeof(fp_digit)); fp_clamp(B); } #endif /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr_comba_12.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/17 03:39:01 $ */ /* End: src/sqr/fp_sqr_comba_12.c */ /* Start: src/sqr/fp_sqr_comba_17.c */ #define TFM_DEFINES //#include "fp_sqr_comba.c" #ifdef TFM_SQR17 void fp_sqr_comba17(fp_int *A, fp_int *B) { fp_digit *a, b[34], c0, c1, c2, sc0, sc1, sc2; #ifdef TFM_ISO fp_word tt; #endif a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADDSC(a[0], a[15]); SQRADDAC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADDSC(a[0], a[16]); SQRADDAC(a[1], a[15]); SQRADDAC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); COMBA_STORE(b[16]); /* output 17 */ CARRY_FORWARD; SQRADDSC(a[1], a[16]); SQRADDAC(a[2], a[15]); SQRADDAC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; COMBA_STORE(b[17]); /* output 18 */ CARRY_FORWARD; SQRADDSC(a[2], a[16]); SQRADDAC(a[3], a[15]); SQRADDAC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); COMBA_STORE(b[18]); /* output 19 */ CARRY_FORWARD; SQRADDSC(a[3], a[16]); SQRADDAC(a[4], a[15]); SQRADDAC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; COMBA_STORE(b[19]); /* output 20 */ CARRY_FORWARD; SQRADDSC(a[4], a[16]); SQRADDAC(a[5], a[15]); SQRADDAC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); COMBA_STORE(b[20]); /* output 21 */ CARRY_FORWARD; SQRADDSC(a[5], a[16]); SQRADDAC(a[6], a[15]); SQRADDAC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; COMBA_STORE(b[21]); /* output 22 */ CARRY_FORWARD; SQRADDSC(a[6], a[16]); SQRADDAC(a[7], a[15]); SQRADDAC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); COMBA_STORE(b[22]); /* output 23 */ CARRY_FORWARD; SQRADDSC(a[7], a[16]); SQRADDAC(a[8], a[15]); SQRADDAC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; COMBA_STORE(b[23]); /* output 24 */ CARRY_FORWARD; SQRADDSC(a[8], a[16]); SQRADDAC(a[9], a[15]); SQRADDAC(a[10], a[14]); SQRADDAC(a[11], a[13]); SQRADDDB; SQRADD(a[12], a[12]); COMBA_STORE(b[24]); /* output 25 */ CARRY_FORWARD; SQRADDSC(a[9], a[16]); SQRADDAC(a[10], a[15]); SQRADDAC(a[11], a[14]); SQRADDAC(a[12], a[13]); SQRADDDB; COMBA_STORE(b[25]); /* output 26 */ CARRY_FORWARD; SQRADDSC(a[10], a[16]); SQRADDAC(a[11], a[15]); SQRADDAC(a[12], a[14]); SQRADDDB; SQRADD(a[13], a[13]); COMBA_STORE(b[26]); /* output 27 */ CARRY_FORWARD; SQRADDSC(a[11], a[16]); SQRADDAC(a[12], a[15]); SQRADDAC(a[13], a[14]); SQRADDDB; COMBA_STORE(b[27]); /* output 28 */ CARRY_FORWARD; SQRADD2(a[12], a[16]); SQRADD2(a[13], a[15]); SQRADD(a[14], a[14]); COMBA_STORE(b[28]); /* output 29 */ CARRY_FORWARD; SQRADD2(a[13], a[16]); SQRADD2(a[14], a[15]); COMBA_STORE(b[29]); /* output 30 */ CARRY_FORWARD; SQRADD2(a[14], a[16]); SQRADD(a[15], a[15]); COMBA_STORE(b[30]); /* output 31 */ CARRY_FORWARD; SQRADD2(a[15], a[16]); COMBA_STORE(b[31]); /* output 32 */ CARRY_FORWARD; SQRADD(a[16], a[16]); COMBA_STORE(b[32]); COMBA_STORE2(b[33]); COMBA_FINI; B->used = 34; B->sign = FP_ZPOS; memcpy(B->dp, b, 34 * sizeof(fp_digit)); fp_clamp(B); } #endif /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr_comba_17.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/17 03:39:01 $ */ /* End: src/sqr/fp_sqr_comba_17.c */ /* Start: src/sqr/fp_sqr_comba_20.c */ #define TFM_DEFINES //#include "fp_sqr_comba.c" #ifdef TFM_SQR20 void fp_sqr_comba20(fp_int *A, fp_int *B) { fp_digit *a, b[40], c0, c1, c2, sc0, sc1, sc2; #ifdef TFM_ISO fp_word tt; #endif a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADDSC(a[0], a[15]); SQRADDAC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADDSC(a[0], a[16]); SQRADDAC(a[1], a[15]); SQRADDAC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); COMBA_STORE(b[16]); /* output 17 */ CARRY_FORWARD; SQRADDSC(a[0], a[17]); SQRADDAC(a[1], a[16]); SQRADDAC(a[2], a[15]); SQRADDAC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; COMBA_STORE(b[17]); /* output 18 */ CARRY_FORWARD; SQRADDSC(a[0], a[18]); SQRADDAC(a[1], a[17]); SQRADDAC(a[2], a[16]); SQRADDAC(a[3], a[15]); SQRADDAC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); COMBA_STORE(b[18]); /* output 19 */ CARRY_FORWARD; SQRADDSC(a[0], a[19]); SQRADDAC(a[1], a[18]); SQRADDAC(a[2], a[17]); SQRADDAC(a[3], a[16]); SQRADDAC(a[4], a[15]); SQRADDAC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; COMBA_STORE(b[19]); /* output 20 */ CARRY_FORWARD; SQRADDSC(a[1], a[19]); SQRADDAC(a[2], a[18]); SQRADDAC(a[3], a[17]); SQRADDAC(a[4], a[16]); SQRADDAC(a[5], a[15]); SQRADDAC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); COMBA_STORE(b[20]); /* output 21 */ CARRY_FORWARD; SQRADDSC(a[2], a[19]); SQRADDAC(a[3], a[18]); SQRADDAC(a[4], a[17]); SQRADDAC(a[5], a[16]); SQRADDAC(a[6], a[15]); SQRADDAC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; COMBA_STORE(b[21]); /* output 22 */ CARRY_FORWARD; SQRADDSC(a[3], a[19]); SQRADDAC(a[4], a[18]); SQRADDAC(a[5], a[17]); SQRADDAC(a[6], a[16]); SQRADDAC(a[7], a[15]); SQRADDAC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); COMBA_STORE(b[22]); /* output 23 */ CARRY_FORWARD; SQRADDSC(a[4], a[19]); SQRADDAC(a[5], a[18]); SQRADDAC(a[6], a[17]); SQRADDAC(a[7], a[16]); SQRADDAC(a[8], a[15]); SQRADDAC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; COMBA_STORE(b[23]); /* output 24 */ CARRY_FORWARD; SQRADDSC(a[5], a[19]); SQRADDAC(a[6], a[18]); SQRADDAC(a[7], a[17]); SQRADDAC(a[8], a[16]); SQRADDAC(a[9], a[15]); SQRADDAC(a[10], a[14]); SQRADDAC(a[11], a[13]); SQRADDDB; SQRADD(a[12], a[12]); COMBA_STORE(b[24]); /* output 25 */ CARRY_FORWARD; SQRADDSC(a[6], a[19]); SQRADDAC(a[7], a[18]); SQRADDAC(a[8], a[17]); SQRADDAC(a[9], a[16]); SQRADDAC(a[10], a[15]); SQRADDAC(a[11], a[14]); SQRADDAC(a[12], a[13]); SQRADDDB; COMBA_STORE(b[25]); /* output 26 */ CARRY_FORWARD; SQRADDSC(a[7], a[19]); SQRADDAC(a[8], a[18]); SQRADDAC(a[9], a[17]); SQRADDAC(a[10], a[16]); SQRADDAC(a[11], a[15]); SQRADDAC(a[12], a[14]); SQRADDDB; SQRADD(a[13], a[13]); COMBA_STORE(b[26]); /* output 27 */ CARRY_FORWARD; SQRADDSC(a[8], a[19]); SQRADDAC(a[9], a[18]); SQRADDAC(a[10], a[17]); SQRADDAC(a[11], a[16]); SQRADDAC(a[12], a[15]); SQRADDAC(a[13], a[14]); SQRADDDB; COMBA_STORE(b[27]); /* output 28 */ CARRY_FORWARD; SQRADDSC(a[9], a[19]); SQRADDAC(a[10], a[18]); SQRADDAC(a[11], a[17]); SQRADDAC(a[12], a[16]); SQRADDAC(a[13], a[15]); SQRADDDB; SQRADD(a[14], a[14]); COMBA_STORE(b[28]); /* output 29 */ CARRY_FORWARD; SQRADDSC(a[10], a[19]); SQRADDAC(a[11], a[18]); SQRADDAC(a[12], a[17]); SQRADDAC(a[13], a[16]); SQRADDAC(a[14], a[15]); SQRADDDB; COMBA_STORE(b[29]); /* output 30 */ CARRY_FORWARD; SQRADDSC(a[11], a[19]); SQRADDAC(a[12], a[18]); SQRADDAC(a[13], a[17]); SQRADDAC(a[14], a[16]); SQRADDDB; SQRADD(a[15], a[15]); COMBA_STORE(b[30]); /* output 31 */ CARRY_FORWARD; SQRADDSC(a[12], a[19]); SQRADDAC(a[13], a[18]); SQRADDAC(a[14], a[17]); SQRADDAC(a[15], a[16]); SQRADDDB; COMBA_STORE(b[31]); /* output 32 */ CARRY_FORWARD; SQRADDSC(a[13], a[19]); SQRADDAC(a[14], a[18]); SQRADDAC(a[15], a[17]); SQRADDDB; SQRADD(a[16], a[16]); COMBA_STORE(b[32]); /* output 33 */ CARRY_FORWARD; SQRADDSC(a[14], a[19]); SQRADDAC(a[15], a[18]); SQRADDAC(a[16], a[17]); SQRADDDB; COMBA_STORE(b[33]); /* output 34 */ CARRY_FORWARD; SQRADD2(a[15], a[19]); SQRADD2(a[16], a[18]); SQRADD(a[17], a[17]); COMBA_STORE(b[34]); /* output 35 */ CARRY_FORWARD; SQRADD2(a[16], a[19]); SQRADD2(a[17], a[18]); COMBA_STORE(b[35]); /* output 36 */ CARRY_FORWARD; SQRADD2(a[17], a[19]); SQRADD(a[18], a[18]); COMBA_STORE(b[36]); /* output 37 */ CARRY_FORWARD; SQRADD2(a[18], a[19]); COMBA_STORE(b[37]); /* output 38 */ CARRY_FORWARD; SQRADD(a[19], a[19]); COMBA_STORE(b[38]); COMBA_STORE2(b[39]); COMBA_FINI; B->used = 40; B->sign = FP_ZPOS; memcpy(B->dp, b, 40 * sizeof(fp_digit)); fp_clamp(B); } #endif /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr_comba_20.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/17 03:39:01 $ */ /* End: src/sqr/fp_sqr_comba_20.c */ /* Start: src/sqr/fp_sqr_comba_24.c */ #define TFM_DEFINES //#include "fp_sqr_comba.c" #ifdef TFM_SQR24 void fp_sqr_comba24(fp_int *A, fp_int *B) { fp_digit *a, b[48], c0, c1, c2, sc0, sc1, sc2; #ifdef TFM_ISO fp_word tt; #endif a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADDSC(a[0], a[15]); SQRADDAC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADDSC(a[0], a[16]); SQRADDAC(a[1], a[15]); SQRADDAC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); COMBA_STORE(b[16]); /* output 17 */ CARRY_FORWARD; SQRADDSC(a[0], a[17]); SQRADDAC(a[1], a[16]); SQRADDAC(a[2], a[15]); SQRADDAC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; COMBA_STORE(b[17]); /* output 18 */ CARRY_FORWARD; SQRADDSC(a[0], a[18]); SQRADDAC(a[1], a[17]); SQRADDAC(a[2], a[16]); SQRADDAC(a[3], a[15]); SQRADDAC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); COMBA_STORE(b[18]); /* output 19 */ CARRY_FORWARD; SQRADDSC(a[0], a[19]); SQRADDAC(a[1], a[18]); SQRADDAC(a[2], a[17]); SQRADDAC(a[3], a[16]); SQRADDAC(a[4], a[15]); SQRADDAC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; COMBA_STORE(b[19]); /* output 20 */ CARRY_FORWARD; SQRADDSC(a[0], a[20]); SQRADDAC(a[1], a[19]); SQRADDAC(a[2], a[18]); SQRADDAC(a[3], a[17]); SQRADDAC(a[4], a[16]); SQRADDAC(a[5], a[15]); SQRADDAC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); COMBA_STORE(b[20]); /* output 21 */ CARRY_FORWARD; SQRADDSC(a[0], a[21]); SQRADDAC(a[1], a[20]); SQRADDAC(a[2], a[19]); SQRADDAC(a[3], a[18]); SQRADDAC(a[4], a[17]); SQRADDAC(a[5], a[16]); SQRADDAC(a[6], a[15]); SQRADDAC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; COMBA_STORE(b[21]); /* output 22 */ CARRY_FORWARD; SQRADDSC(a[0], a[22]); SQRADDAC(a[1], a[21]); SQRADDAC(a[2], a[20]); SQRADDAC(a[3], a[19]); SQRADDAC(a[4], a[18]); SQRADDAC(a[5], a[17]); SQRADDAC(a[6], a[16]); SQRADDAC(a[7], a[15]); SQRADDAC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); COMBA_STORE(b[22]); /* output 23 */ CARRY_FORWARD; SQRADDSC(a[0], a[23]); SQRADDAC(a[1], a[22]); SQRADDAC(a[2], a[21]); SQRADDAC(a[3], a[20]); SQRADDAC(a[4], a[19]); SQRADDAC(a[5], a[18]); SQRADDAC(a[6], a[17]); SQRADDAC(a[7], a[16]); SQRADDAC(a[8], a[15]); SQRADDAC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; COMBA_STORE(b[23]); /* output 24 */ CARRY_FORWARD; SQRADDSC(a[1], a[23]); SQRADDAC(a[2], a[22]); SQRADDAC(a[3], a[21]); SQRADDAC(a[4], a[20]); SQRADDAC(a[5], a[19]); SQRADDAC(a[6], a[18]); SQRADDAC(a[7], a[17]); SQRADDAC(a[8], a[16]); SQRADDAC(a[9], a[15]); SQRADDAC(a[10], a[14]); SQRADDAC(a[11], a[13]); SQRADDDB; SQRADD(a[12], a[12]); COMBA_STORE(b[24]); /* output 25 */ CARRY_FORWARD; SQRADDSC(a[2], a[23]); SQRADDAC(a[3], a[22]); SQRADDAC(a[4], a[21]); SQRADDAC(a[5], a[20]); SQRADDAC(a[6], a[19]); SQRADDAC(a[7], a[18]); SQRADDAC(a[8], a[17]); SQRADDAC(a[9], a[16]); SQRADDAC(a[10], a[15]); SQRADDAC(a[11], a[14]); SQRADDAC(a[12], a[13]); SQRADDDB; COMBA_STORE(b[25]); /* output 26 */ CARRY_FORWARD; SQRADDSC(a[3], a[23]); SQRADDAC(a[4], a[22]); SQRADDAC(a[5], a[21]); SQRADDAC(a[6], a[20]); SQRADDAC(a[7], a[19]); SQRADDAC(a[8], a[18]); SQRADDAC(a[9], a[17]); SQRADDAC(a[10], a[16]); SQRADDAC(a[11], a[15]); SQRADDAC(a[12], a[14]); SQRADDDB; SQRADD(a[13], a[13]); COMBA_STORE(b[26]); /* output 27 */ CARRY_FORWARD; SQRADDSC(a[4], a[23]); SQRADDAC(a[5], a[22]); SQRADDAC(a[6], a[21]); SQRADDAC(a[7], a[20]); SQRADDAC(a[8], a[19]); SQRADDAC(a[9], a[18]); SQRADDAC(a[10], a[17]); SQRADDAC(a[11], a[16]); SQRADDAC(a[12], a[15]); SQRADDAC(a[13], a[14]); SQRADDDB; COMBA_STORE(b[27]); /* output 28 */ CARRY_FORWARD; SQRADDSC(a[5], a[23]); SQRADDAC(a[6], a[22]); SQRADDAC(a[7], a[21]); SQRADDAC(a[8], a[20]); SQRADDAC(a[9], a[19]); SQRADDAC(a[10], a[18]); SQRADDAC(a[11], a[17]); SQRADDAC(a[12], a[16]); SQRADDAC(a[13], a[15]); SQRADDDB; SQRADD(a[14], a[14]); COMBA_STORE(b[28]); /* output 29 */ CARRY_FORWARD; SQRADDSC(a[6], a[23]); SQRADDAC(a[7], a[22]); SQRADDAC(a[8], a[21]); SQRADDAC(a[9], a[20]); SQRADDAC(a[10], a[19]); SQRADDAC(a[11], a[18]); SQRADDAC(a[12], a[17]); SQRADDAC(a[13], a[16]); SQRADDAC(a[14], a[15]); SQRADDDB; COMBA_STORE(b[29]); /* output 30 */ CARRY_FORWARD; SQRADDSC(a[7], a[23]); SQRADDAC(a[8], a[22]); SQRADDAC(a[9], a[21]); SQRADDAC(a[10], a[20]); SQRADDAC(a[11], a[19]); SQRADDAC(a[12], a[18]); SQRADDAC(a[13], a[17]); SQRADDAC(a[14], a[16]); SQRADDDB; SQRADD(a[15], a[15]); COMBA_STORE(b[30]); /* output 31 */ CARRY_FORWARD; SQRADDSC(a[8], a[23]); SQRADDAC(a[9], a[22]); SQRADDAC(a[10], a[21]); SQRADDAC(a[11], a[20]); SQRADDAC(a[12], a[19]); SQRADDAC(a[13], a[18]); SQRADDAC(a[14], a[17]); SQRADDAC(a[15], a[16]); SQRADDDB; COMBA_STORE(b[31]); /* output 32 */ CARRY_FORWARD; SQRADDSC(a[9], a[23]); SQRADDAC(a[10], a[22]); SQRADDAC(a[11], a[21]); SQRADDAC(a[12], a[20]); SQRADDAC(a[13], a[19]); SQRADDAC(a[14], a[18]); SQRADDAC(a[15], a[17]); SQRADDDB; SQRADD(a[16], a[16]); COMBA_STORE(b[32]); /* output 33 */ CARRY_FORWARD; SQRADDSC(a[10], a[23]); SQRADDAC(a[11], a[22]); SQRADDAC(a[12], a[21]); SQRADDAC(a[13], a[20]); SQRADDAC(a[14], a[19]); SQRADDAC(a[15], a[18]); SQRADDAC(a[16], a[17]); SQRADDDB; COMBA_STORE(b[33]); /* output 34 */ CARRY_FORWARD; SQRADDSC(a[11], a[23]); SQRADDAC(a[12], a[22]); SQRADDAC(a[13], a[21]); SQRADDAC(a[14], a[20]); SQRADDAC(a[15], a[19]); SQRADDAC(a[16], a[18]); SQRADDDB; SQRADD(a[17], a[17]); COMBA_STORE(b[34]); /* output 35 */ CARRY_FORWARD; SQRADDSC(a[12], a[23]); SQRADDAC(a[13], a[22]); SQRADDAC(a[14], a[21]); SQRADDAC(a[15], a[20]); SQRADDAC(a[16], a[19]); SQRADDAC(a[17], a[18]); SQRADDDB; COMBA_STORE(b[35]); /* output 36 */ CARRY_FORWARD; SQRADDSC(a[13], a[23]); SQRADDAC(a[14], a[22]); SQRADDAC(a[15], a[21]); SQRADDAC(a[16], a[20]); SQRADDAC(a[17], a[19]); SQRADDDB; SQRADD(a[18], a[18]); COMBA_STORE(b[36]); /* output 37 */ CARRY_FORWARD; SQRADDSC(a[14], a[23]); SQRADDAC(a[15], a[22]); SQRADDAC(a[16], a[21]); SQRADDAC(a[17], a[20]); SQRADDAC(a[18], a[19]); SQRADDDB; COMBA_STORE(b[37]); /* output 38 */ CARRY_FORWARD; SQRADDSC(a[15], a[23]); SQRADDAC(a[16], a[22]); SQRADDAC(a[17], a[21]); SQRADDAC(a[18], a[20]); SQRADDDB; SQRADD(a[19], a[19]); COMBA_STORE(b[38]); /* output 39 */ CARRY_FORWARD; SQRADDSC(a[16], a[23]); SQRADDAC(a[17], a[22]); SQRADDAC(a[18], a[21]); SQRADDAC(a[19], a[20]); SQRADDDB; COMBA_STORE(b[39]); /* output 40 */ CARRY_FORWARD; SQRADDSC(a[17], a[23]); SQRADDAC(a[18], a[22]); SQRADDAC(a[19], a[21]); SQRADDDB; SQRADD(a[20], a[20]); COMBA_STORE(b[40]); /* output 41 */ CARRY_FORWARD; SQRADDSC(a[18], a[23]); SQRADDAC(a[19], a[22]); SQRADDAC(a[20], a[21]); SQRADDDB; COMBA_STORE(b[41]); /* output 42 */ CARRY_FORWARD; SQRADD2(a[19], a[23]); SQRADD2(a[20], a[22]); SQRADD(a[21], a[21]); COMBA_STORE(b[42]); /* output 43 */ CARRY_FORWARD; SQRADD2(a[20], a[23]); SQRADD2(a[21], a[22]); COMBA_STORE(b[43]); /* output 44 */ CARRY_FORWARD; SQRADD2(a[21], a[23]); SQRADD(a[22], a[22]); COMBA_STORE(b[44]); /* output 45 */ CARRY_FORWARD; SQRADD2(a[22], a[23]); COMBA_STORE(b[45]); /* output 46 */ CARRY_FORWARD; SQRADD(a[23], a[23]); COMBA_STORE(b[46]); COMBA_STORE2(b[47]); COMBA_FINI; B->used = 48; B->sign = FP_ZPOS; memcpy(B->dp, b, 48 * sizeof(fp_digit)); fp_clamp(B); } #endif /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr_comba_24.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/17 03:39:01 $ */ /* End: src/sqr/fp_sqr_comba_24.c */ /* Start: src/sqr/fp_sqr_comba_28.c */ #define TFM_DEFINES //#include "fp_sqr_comba.c" #ifdef TFM_SQR28 void fp_sqr_comba28(fp_int *A, fp_int *B) { fp_digit *a, b[56], c0, c1, c2, sc0, sc1, sc2; #ifdef TFM_ISO fp_word tt; #endif a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADDSC(a[0], a[15]); SQRADDAC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADDSC(a[0], a[16]); SQRADDAC(a[1], a[15]); SQRADDAC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); COMBA_STORE(b[16]); /* output 17 */ CARRY_FORWARD; SQRADDSC(a[0], a[17]); SQRADDAC(a[1], a[16]); SQRADDAC(a[2], a[15]); SQRADDAC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; COMBA_STORE(b[17]); /* output 18 */ CARRY_FORWARD; SQRADDSC(a[0], a[18]); SQRADDAC(a[1], a[17]); SQRADDAC(a[2], a[16]); SQRADDAC(a[3], a[15]); SQRADDAC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); COMBA_STORE(b[18]); /* output 19 */ CARRY_FORWARD; SQRADDSC(a[0], a[19]); SQRADDAC(a[1], a[18]); SQRADDAC(a[2], a[17]); SQRADDAC(a[3], a[16]); SQRADDAC(a[4], a[15]); SQRADDAC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; COMBA_STORE(b[19]); /* output 20 */ CARRY_FORWARD; SQRADDSC(a[0], a[20]); SQRADDAC(a[1], a[19]); SQRADDAC(a[2], a[18]); SQRADDAC(a[3], a[17]); SQRADDAC(a[4], a[16]); SQRADDAC(a[5], a[15]); SQRADDAC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); COMBA_STORE(b[20]); /* output 21 */ CARRY_FORWARD; SQRADDSC(a[0], a[21]); SQRADDAC(a[1], a[20]); SQRADDAC(a[2], a[19]); SQRADDAC(a[3], a[18]); SQRADDAC(a[4], a[17]); SQRADDAC(a[5], a[16]); SQRADDAC(a[6], a[15]); SQRADDAC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; COMBA_STORE(b[21]); /* output 22 */ CARRY_FORWARD; SQRADDSC(a[0], a[22]); SQRADDAC(a[1], a[21]); SQRADDAC(a[2], a[20]); SQRADDAC(a[3], a[19]); SQRADDAC(a[4], a[18]); SQRADDAC(a[5], a[17]); SQRADDAC(a[6], a[16]); SQRADDAC(a[7], a[15]); SQRADDAC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); COMBA_STORE(b[22]); /* output 23 */ CARRY_FORWARD; SQRADDSC(a[0], a[23]); SQRADDAC(a[1], a[22]); SQRADDAC(a[2], a[21]); SQRADDAC(a[3], a[20]); SQRADDAC(a[4], a[19]); SQRADDAC(a[5], a[18]); SQRADDAC(a[6], a[17]); SQRADDAC(a[7], a[16]); SQRADDAC(a[8], a[15]); SQRADDAC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; COMBA_STORE(b[23]); /* output 24 */ CARRY_FORWARD; SQRADDSC(a[0], a[24]); SQRADDAC(a[1], a[23]); SQRADDAC(a[2], a[22]); SQRADDAC(a[3], a[21]); SQRADDAC(a[4], a[20]); SQRADDAC(a[5], a[19]); SQRADDAC(a[6], a[18]); SQRADDAC(a[7], a[17]); SQRADDAC(a[8], a[16]); SQRADDAC(a[9], a[15]); SQRADDAC(a[10], a[14]); SQRADDAC(a[11], a[13]); SQRADDDB; SQRADD(a[12], a[12]); COMBA_STORE(b[24]); /* output 25 */ CARRY_FORWARD; SQRADDSC(a[0], a[25]); SQRADDAC(a[1], a[24]); SQRADDAC(a[2], a[23]); SQRADDAC(a[3], a[22]); SQRADDAC(a[4], a[21]); SQRADDAC(a[5], a[20]); SQRADDAC(a[6], a[19]); SQRADDAC(a[7], a[18]); SQRADDAC(a[8], a[17]); SQRADDAC(a[9], a[16]); SQRADDAC(a[10], a[15]); SQRADDAC(a[11], a[14]); SQRADDAC(a[12], a[13]); SQRADDDB; COMBA_STORE(b[25]); /* output 26 */ CARRY_FORWARD; SQRADDSC(a[0], a[26]); SQRADDAC(a[1], a[25]); SQRADDAC(a[2], a[24]); SQRADDAC(a[3], a[23]); SQRADDAC(a[4], a[22]); SQRADDAC(a[5], a[21]); SQRADDAC(a[6], a[20]); SQRADDAC(a[7], a[19]); SQRADDAC(a[8], a[18]); SQRADDAC(a[9], a[17]); SQRADDAC(a[10], a[16]); SQRADDAC(a[11], a[15]); SQRADDAC(a[12], a[14]); SQRADDDB; SQRADD(a[13], a[13]); COMBA_STORE(b[26]); /* output 27 */ CARRY_FORWARD; SQRADDSC(a[0], a[27]); SQRADDAC(a[1], a[26]); SQRADDAC(a[2], a[25]); SQRADDAC(a[3], a[24]); SQRADDAC(a[4], a[23]); SQRADDAC(a[5], a[22]); SQRADDAC(a[6], a[21]); SQRADDAC(a[7], a[20]); SQRADDAC(a[8], a[19]); SQRADDAC(a[9], a[18]); SQRADDAC(a[10], a[17]); SQRADDAC(a[11], a[16]); SQRADDAC(a[12], a[15]); SQRADDAC(a[13], a[14]); SQRADDDB; COMBA_STORE(b[27]); /* output 28 */ CARRY_FORWARD; SQRADDSC(a[1], a[27]); SQRADDAC(a[2], a[26]); SQRADDAC(a[3], a[25]); SQRADDAC(a[4], a[24]); SQRADDAC(a[5], a[23]); SQRADDAC(a[6], a[22]); SQRADDAC(a[7], a[21]); SQRADDAC(a[8], a[20]); SQRADDAC(a[9], a[19]); SQRADDAC(a[10], a[18]); SQRADDAC(a[11], a[17]); SQRADDAC(a[12], a[16]); SQRADDAC(a[13], a[15]); SQRADDDB; SQRADD(a[14], a[14]); COMBA_STORE(b[28]); /* output 29 */ CARRY_FORWARD; SQRADDSC(a[2], a[27]); SQRADDAC(a[3], a[26]); SQRADDAC(a[4], a[25]); SQRADDAC(a[5], a[24]); SQRADDAC(a[6], a[23]); SQRADDAC(a[7], a[22]); SQRADDAC(a[8], a[21]); SQRADDAC(a[9], a[20]); SQRADDAC(a[10], a[19]); SQRADDAC(a[11], a[18]); SQRADDAC(a[12], a[17]); SQRADDAC(a[13], a[16]); SQRADDAC(a[14], a[15]); SQRADDDB; COMBA_STORE(b[29]); /* output 30 */ CARRY_FORWARD; SQRADDSC(a[3], a[27]); SQRADDAC(a[4], a[26]); SQRADDAC(a[5], a[25]); SQRADDAC(a[6], a[24]); SQRADDAC(a[7], a[23]); SQRADDAC(a[8], a[22]); SQRADDAC(a[9], a[21]); SQRADDAC(a[10], a[20]); SQRADDAC(a[11], a[19]); SQRADDAC(a[12], a[18]); SQRADDAC(a[13], a[17]); SQRADDAC(a[14], a[16]); SQRADDDB; SQRADD(a[15], a[15]); COMBA_STORE(b[30]); /* output 31 */ CARRY_FORWARD; SQRADDSC(a[4], a[27]); SQRADDAC(a[5], a[26]); SQRADDAC(a[6], a[25]); SQRADDAC(a[7], a[24]); SQRADDAC(a[8], a[23]); SQRADDAC(a[9], a[22]); SQRADDAC(a[10], a[21]); SQRADDAC(a[11], a[20]); SQRADDAC(a[12], a[19]); SQRADDAC(a[13], a[18]); SQRADDAC(a[14], a[17]); SQRADDAC(a[15], a[16]); SQRADDDB; COMBA_STORE(b[31]); /* output 32 */ CARRY_FORWARD; SQRADDSC(a[5], a[27]); SQRADDAC(a[6], a[26]); SQRADDAC(a[7], a[25]); SQRADDAC(a[8], a[24]); SQRADDAC(a[9], a[23]); SQRADDAC(a[10], a[22]); SQRADDAC(a[11], a[21]); SQRADDAC(a[12], a[20]); SQRADDAC(a[13], a[19]); SQRADDAC(a[14], a[18]); SQRADDAC(a[15], a[17]); SQRADDDB; SQRADD(a[16], a[16]); COMBA_STORE(b[32]); /* output 33 */ CARRY_FORWARD; SQRADDSC(a[6], a[27]); SQRADDAC(a[7], a[26]); SQRADDAC(a[8], a[25]); SQRADDAC(a[9], a[24]); SQRADDAC(a[10], a[23]); SQRADDAC(a[11], a[22]); SQRADDAC(a[12], a[21]); SQRADDAC(a[13], a[20]); SQRADDAC(a[14], a[19]); SQRADDAC(a[15], a[18]); SQRADDAC(a[16], a[17]); SQRADDDB; COMBA_STORE(b[33]); /* output 34 */ CARRY_FORWARD; SQRADDSC(a[7], a[27]); SQRADDAC(a[8], a[26]); SQRADDAC(a[9], a[25]); SQRADDAC(a[10], a[24]); SQRADDAC(a[11], a[23]); SQRADDAC(a[12], a[22]); SQRADDAC(a[13], a[21]); SQRADDAC(a[14], a[20]); SQRADDAC(a[15], a[19]); SQRADDAC(a[16], a[18]); SQRADDDB; SQRADD(a[17], a[17]); COMBA_STORE(b[34]); /* output 35 */ CARRY_FORWARD; SQRADDSC(a[8], a[27]); SQRADDAC(a[9], a[26]); SQRADDAC(a[10], a[25]); SQRADDAC(a[11], a[24]); SQRADDAC(a[12], a[23]); SQRADDAC(a[13], a[22]); SQRADDAC(a[14], a[21]); SQRADDAC(a[15], a[20]); SQRADDAC(a[16], a[19]); SQRADDAC(a[17], a[18]); SQRADDDB; COMBA_STORE(b[35]); /* output 36 */ CARRY_FORWARD; SQRADDSC(a[9], a[27]); SQRADDAC(a[10], a[26]); SQRADDAC(a[11], a[25]); SQRADDAC(a[12], a[24]); SQRADDAC(a[13], a[23]); SQRADDAC(a[14], a[22]); SQRADDAC(a[15], a[21]); SQRADDAC(a[16], a[20]); SQRADDAC(a[17], a[19]); SQRADDDB; SQRADD(a[18], a[18]); COMBA_STORE(b[36]); /* output 37 */ CARRY_FORWARD; SQRADDSC(a[10], a[27]); SQRADDAC(a[11], a[26]); SQRADDAC(a[12], a[25]); SQRADDAC(a[13], a[24]); SQRADDAC(a[14], a[23]); SQRADDAC(a[15], a[22]); SQRADDAC(a[16], a[21]); SQRADDAC(a[17], a[20]); SQRADDAC(a[18], a[19]); SQRADDDB; COMBA_STORE(b[37]); /* output 38 */ CARRY_FORWARD; SQRADDSC(a[11], a[27]); SQRADDAC(a[12], a[26]); SQRADDAC(a[13], a[25]); SQRADDAC(a[14], a[24]); SQRADDAC(a[15], a[23]); SQRADDAC(a[16], a[22]); SQRADDAC(a[17], a[21]); SQRADDAC(a[18], a[20]); SQRADDDB; SQRADD(a[19], a[19]); COMBA_STORE(b[38]); /* output 39 */ CARRY_FORWARD; SQRADDSC(a[12], a[27]); SQRADDAC(a[13], a[26]); SQRADDAC(a[14], a[25]); SQRADDAC(a[15], a[24]); SQRADDAC(a[16], a[23]); SQRADDAC(a[17], a[22]); SQRADDAC(a[18], a[21]); SQRADDAC(a[19], a[20]); SQRADDDB; COMBA_STORE(b[39]); /* output 40 */ CARRY_FORWARD; SQRADDSC(a[13], a[27]); SQRADDAC(a[14], a[26]); SQRADDAC(a[15], a[25]); SQRADDAC(a[16], a[24]); SQRADDAC(a[17], a[23]); SQRADDAC(a[18], a[22]); SQRADDAC(a[19], a[21]); SQRADDDB; SQRADD(a[20], a[20]); COMBA_STORE(b[40]); /* output 41 */ CARRY_FORWARD; SQRADDSC(a[14], a[27]); SQRADDAC(a[15], a[26]); SQRADDAC(a[16], a[25]); SQRADDAC(a[17], a[24]); SQRADDAC(a[18], a[23]); SQRADDAC(a[19], a[22]); SQRADDAC(a[20], a[21]); SQRADDDB; COMBA_STORE(b[41]); /* output 42 */ CARRY_FORWARD; SQRADDSC(a[15], a[27]); SQRADDAC(a[16], a[26]); SQRADDAC(a[17], a[25]); SQRADDAC(a[18], a[24]); SQRADDAC(a[19], a[23]); SQRADDAC(a[20], a[22]); SQRADDDB; SQRADD(a[21], a[21]); COMBA_STORE(b[42]); /* output 43 */ CARRY_FORWARD; SQRADDSC(a[16], a[27]); SQRADDAC(a[17], a[26]); SQRADDAC(a[18], a[25]); SQRADDAC(a[19], a[24]); SQRADDAC(a[20], a[23]); SQRADDAC(a[21], a[22]); SQRADDDB; COMBA_STORE(b[43]); /* output 44 */ CARRY_FORWARD; SQRADDSC(a[17], a[27]); SQRADDAC(a[18], a[26]); SQRADDAC(a[19], a[25]); SQRADDAC(a[20], a[24]); SQRADDAC(a[21], a[23]); SQRADDDB; SQRADD(a[22], a[22]); COMBA_STORE(b[44]); /* output 45 */ CARRY_FORWARD; SQRADDSC(a[18], a[27]); SQRADDAC(a[19], a[26]); SQRADDAC(a[20], a[25]); SQRADDAC(a[21], a[24]); SQRADDAC(a[22], a[23]); SQRADDDB; COMBA_STORE(b[45]); /* output 46 */ CARRY_FORWARD; SQRADDSC(a[19], a[27]); SQRADDAC(a[20], a[26]); SQRADDAC(a[21], a[25]); SQRADDAC(a[22], a[24]); SQRADDDB; SQRADD(a[23], a[23]); COMBA_STORE(b[46]); /* output 47 */ CARRY_FORWARD; SQRADDSC(a[20], a[27]); SQRADDAC(a[21], a[26]); SQRADDAC(a[22], a[25]); SQRADDAC(a[23], a[24]); SQRADDDB; COMBA_STORE(b[47]); /* output 48 */ CARRY_FORWARD; SQRADDSC(a[21], a[27]); SQRADDAC(a[22], a[26]); SQRADDAC(a[23], a[25]); SQRADDDB; SQRADD(a[24], a[24]); COMBA_STORE(b[48]); /* output 49 */ CARRY_FORWARD; SQRADDSC(a[22], a[27]); SQRADDAC(a[23], a[26]); SQRADDAC(a[24], a[25]); SQRADDDB; COMBA_STORE(b[49]); /* output 50 */ CARRY_FORWARD; SQRADD2(a[23], a[27]); SQRADD2(a[24], a[26]); SQRADD(a[25], a[25]); COMBA_STORE(b[50]); /* output 51 */ CARRY_FORWARD; SQRADD2(a[24], a[27]); SQRADD2(a[25], a[26]); COMBA_STORE(b[51]); /* output 52 */ CARRY_FORWARD; SQRADD2(a[25], a[27]); SQRADD(a[26], a[26]); COMBA_STORE(b[52]); /* output 53 */ CARRY_FORWARD; SQRADD2(a[26], a[27]); COMBA_STORE(b[53]); /* output 54 */ CARRY_FORWARD; SQRADD(a[27], a[27]); COMBA_STORE(b[54]); COMBA_STORE2(b[55]); COMBA_FINI; B->used = 56; B->sign = FP_ZPOS; memcpy(B->dp, b, 56 * sizeof(fp_digit)); fp_clamp(B); } #endif /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr_comba_28.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/17 03:39:01 $ */ /* End: src/sqr/fp_sqr_comba_28.c */ /* Start: src/sqr/fp_sqr_comba_3.c */ #define TFM_DEFINES //#include "fp_sqr_comba.c" #ifdef TFM_SQR3 void fp_sqr_comba3(fp_int *A, fp_int *B) { fp_digit *a, b[6], c0, c1, c2, sc0, sc1, sc2; #ifdef TFM_ISO fp_word tt; #endif a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD(a[2], a[2]); COMBA_STORE(b[4]); COMBA_STORE2(b[5]); COMBA_FINI; B->used = 6; B->sign = FP_ZPOS; memcpy(B->dp, b, 6 * sizeof(fp_digit)); fp_clamp(B); } #endif /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr_comba_3.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/17 03:39:01 $ */ /* End: src/sqr/fp_sqr_comba_3.c */ /* Start: src/sqr/fp_sqr_comba_32.c */ #define TFM_DEFINES //#include "fp_sqr_comba.c" #ifdef TFM_SQR32 void fp_sqr_comba32(fp_int *A, fp_int *B) { fp_digit *a, b[64], c0, c1, c2, sc0, sc1, sc2; #ifdef TFM_ISO fp_word tt; #endif a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADDSC(a[0], a[15]); SQRADDAC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADDSC(a[0], a[16]); SQRADDAC(a[1], a[15]); SQRADDAC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); COMBA_STORE(b[16]); /* output 17 */ CARRY_FORWARD; SQRADDSC(a[0], a[17]); SQRADDAC(a[1], a[16]); SQRADDAC(a[2], a[15]); SQRADDAC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; COMBA_STORE(b[17]); /* output 18 */ CARRY_FORWARD; SQRADDSC(a[0], a[18]); SQRADDAC(a[1], a[17]); SQRADDAC(a[2], a[16]); SQRADDAC(a[3], a[15]); SQRADDAC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); COMBA_STORE(b[18]); /* output 19 */ CARRY_FORWARD; SQRADDSC(a[0], a[19]); SQRADDAC(a[1], a[18]); SQRADDAC(a[2], a[17]); SQRADDAC(a[3], a[16]); SQRADDAC(a[4], a[15]); SQRADDAC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; COMBA_STORE(b[19]); /* output 20 */ CARRY_FORWARD; SQRADDSC(a[0], a[20]); SQRADDAC(a[1], a[19]); SQRADDAC(a[2], a[18]); SQRADDAC(a[3], a[17]); SQRADDAC(a[4], a[16]); SQRADDAC(a[5], a[15]); SQRADDAC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); COMBA_STORE(b[20]); /* output 21 */ CARRY_FORWARD; SQRADDSC(a[0], a[21]); SQRADDAC(a[1], a[20]); SQRADDAC(a[2], a[19]); SQRADDAC(a[3], a[18]); SQRADDAC(a[4], a[17]); SQRADDAC(a[5], a[16]); SQRADDAC(a[6], a[15]); SQRADDAC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; COMBA_STORE(b[21]); /* output 22 */ CARRY_FORWARD; SQRADDSC(a[0], a[22]); SQRADDAC(a[1], a[21]); SQRADDAC(a[2], a[20]); SQRADDAC(a[3], a[19]); SQRADDAC(a[4], a[18]); SQRADDAC(a[5], a[17]); SQRADDAC(a[6], a[16]); SQRADDAC(a[7], a[15]); SQRADDAC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); COMBA_STORE(b[22]); /* output 23 */ CARRY_FORWARD; SQRADDSC(a[0], a[23]); SQRADDAC(a[1], a[22]); SQRADDAC(a[2], a[21]); SQRADDAC(a[3], a[20]); SQRADDAC(a[4], a[19]); SQRADDAC(a[5], a[18]); SQRADDAC(a[6], a[17]); SQRADDAC(a[7], a[16]); SQRADDAC(a[8], a[15]); SQRADDAC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; COMBA_STORE(b[23]); /* output 24 */ CARRY_FORWARD; SQRADDSC(a[0], a[24]); SQRADDAC(a[1], a[23]); SQRADDAC(a[2], a[22]); SQRADDAC(a[3], a[21]); SQRADDAC(a[4], a[20]); SQRADDAC(a[5], a[19]); SQRADDAC(a[6], a[18]); SQRADDAC(a[7], a[17]); SQRADDAC(a[8], a[16]); SQRADDAC(a[9], a[15]); SQRADDAC(a[10], a[14]); SQRADDAC(a[11], a[13]); SQRADDDB; SQRADD(a[12], a[12]); COMBA_STORE(b[24]); /* output 25 */ CARRY_FORWARD; SQRADDSC(a[0], a[25]); SQRADDAC(a[1], a[24]); SQRADDAC(a[2], a[23]); SQRADDAC(a[3], a[22]); SQRADDAC(a[4], a[21]); SQRADDAC(a[5], a[20]); SQRADDAC(a[6], a[19]); SQRADDAC(a[7], a[18]); SQRADDAC(a[8], a[17]); SQRADDAC(a[9], a[16]); SQRADDAC(a[10], a[15]); SQRADDAC(a[11], a[14]); SQRADDAC(a[12], a[13]); SQRADDDB; COMBA_STORE(b[25]); /* output 26 */ CARRY_FORWARD; SQRADDSC(a[0], a[26]); SQRADDAC(a[1], a[25]); SQRADDAC(a[2], a[24]); SQRADDAC(a[3], a[23]); SQRADDAC(a[4], a[22]); SQRADDAC(a[5], a[21]); SQRADDAC(a[6], a[20]); SQRADDAC(a[7], a[19]); SQRADDAC(a[8], a[18]); SQRADDAC(a[9], a[17]); SQRADDAC(a[10], a[16]); SQRADDAC(a[11], a[15]); SQRADDAC(a[12], a[14]); SQRADDDB; SQRADD(a[13], a[13]); COMBA_STORE(b[26]); /* output 27 */ CARRY_FORWARD; SQRADDSC(a[0], a[27]); SQRADDAC(a[1], a[26]); SQRADDAC(a[2], a[25]); SQRADDAC(a[3], a[24]); SQRADDAC(a[4], a[23]); SQRADDAC(a[5], a[22]); SQRADDAC(a[6], a[21]); SQRADDAC(a[7], a[20]); SQRADDAC(a[8], a[19]); SQRADDAC(a[9], a[18]); SQRADDAC(a[10], a[17]); SQRADDAC(a[11], a[16]); SQRADDAC(a[12], a[15]); SQRADDAC(a[13], a[14]); SQRADDDB; COMBA_STORE(b[27]); /* output 28 */ CARRY_FORWARD; SQRADDSC(a[0], a[28]); SQRADDAC(a[1], a[27]); SQRADDAC(a[2], a[26]); SQRADDAC(a[3], a[25]); SQRADDAC(a[4], a[24]); SQRADDAC(a[5], a[23]); SQRADDAC(a[6], a[22]); SQRADDAC(a[7], a[21]); SQRADDAC(a[8], a[20]); SQRADDAC(a[9], a[19]); SQRADDAC(a[10], a[18]); SQRADDAC(a[11], a[17]); SQRADDAC(a[12], a[16]); SQRADDAC(a[13], a[15]); SQRADDDB; SQRADD(a[14], a[14]); COMBA_STORE(b[28]); /* output 29 */ CARRY_FORWARD; SQRADDSC(a[0], a[29]); SQRADDAC(a[1], a[28]); SQRADDAC(a[2], a[27]); SQRADDAC(a[3], a[26]); SQRADDAC(a[4], a[25]); SQRADDAC(a[5], a[24]); SQRADDAC(a[6], a[23]); SQRADDAC(a[7], a[22]); SQRADDAC(a[8], a[21]); SQRADDAC(a[9], a[20]); SQRADDAC(a[10], a[19]); SQRADDAC(a[11], a[18]); SQRADDAC(a[12], a[17]); SQRADDAC(a[13], a[16]); SQRADDAC(a[14], a[15]); SQRADDDB; COMBA_STORE(b[29]); /* output 30 */ CARRY_FORWARD; SQRADDSC(a[0], a[30]); SQRADDAC(a[1], a[29]); SQRADDAC(a[2], a[28]); SQRADDAC(a[3], a[27]); SQRADDAC(a[4], a[26]); SQRADDAC(a[5], a[25]); SQRADDAC(a[6], a[24]); SQRADDAC(a[7], a[23]); SQRADDAC(a[8], a[22]); SQRADDAC(a[9], a[21]); SQRADDAC(a[10], a[20]); SQRADDAC(a[11], a[19]); SQRADDAC(a[12], a[18]); SQRADDAC(a[13], a[17]); SQRADDAC(a[14], a[16]); SQRADDDB; SQRADD(a[15], a[15]); COMBA_STORE(b[30]); /* output 31 */ CARRY_FORWARD; SQRADDSC(a[0], a[31]); SQRADDAC(a[1], a[30]); SQRADDAC(a[2], a[29]); SQRADDAC(a[3], a[28]); SQRADDAC(a[4], a[27]); SQRADDAC(a[5], a[26]); SQRADDAC(a[6], a[25]); SQRADDAC(a[7], a[24]); SQRADDAC(a[8], a[23]); SQRADDAC(a[9], a[22]); SQRADDAC(a[10], a[21]); SQRADDAC(a[11], a[20]); SQRADDAC(a[12], a[19]); SQRADDAC(a[13], a[18]); SQRADDAC(a[14], a[17]); SQRADDAC(a[15], a[16]); SQRADDDB; COMBA_STORE(b[31]); /* output 32 */ CARRY_FORWARD; SQRADDSC(a[1], a[31]); SQRADDAC(a[2], a[30]); SQRADDAC(a[3], a[29]); SQRADDAC(a[4], a[28]); SQRADDAC(a[5], a[27]); SQRADDAC(a[6], a[26]); SQRADDAC(a[7], a[25]); SQRADDAC(a[8], a[24]); SQRADDAC(a[9], a[23]); SQRADDAC(a[10], a[22]); SQRADDAC(a[11], a[21]); SQRADDAC(a[12], a[20]); SQRADDAC(a[13], a[19]); SQRADDAC(a[14], a[18]); SQRADDAC(a[15], a[17]); SQRADDDB; SQRADD(a[16], a[16]); COMBA_STORE(b[32]); /* output 33 */ CARRY_FORWARD; SQRADDSC(a[2], a[31]); SQRADDAC(a[3], a[30]); SQRADDAC(a[4], a[29]); SQRADDAC(a[5], a[28]); SQRADDAC(a[6], a[27]); SQRADDAC(a[7], a[26]); SQRADDAC(a[8], a[25]); SQRADDAC(a[9], a[24]); SQRADDAC(a[10], a[23]); SQRADDAC(a[11], a[22]); SQRADDAC(a[12], a[21]); SQRADDAC(a[13], a[20]); SQRADDAC(a[14], a[19]); SQRADDAC(a[15], a[18]); SQRADDAC(a[16], a[17]); SQRADDDB; COMBA_STORE(b[33]); /* output 34 */ CARRY_FORWARD; SQRADDSC(a[3], a[31]); SQRADDAC(a[4], a[30]); SQRADDAC(a[5], a[29]); SQRADDAC(a[6], a[28]); SQRADDAC(a[7], a[27]); SQRADDAC(a[8], a[26]); SQRADDAC(a[9], a[25]); SQRADDAC(a[10], a[24]); SQRADDAC(a[11], a[23]); SQRADDAC(a[12], a[22]); SQRADDAC(a[13], a[21]); SQRADDAC(a[14], a[20]); SQRADDAC(a[15], a[19]); SQRADDAC(a[16], a[18]); SQRADDDB; SQRADD(a[17], a[17]); COMBA_STORE(b[34]); /* output 35 */ CARRY_FORWARD; SQRADDSC(a[4], a[31]); SQRADDAC(a[5], a[30]); SQRADDAC(a[6], a[29]); SQRADDAC(a[7], a[28]); SQRADDAC(a[8], a[27]); SQRADDAC(a[9], a[26]); SQRADDAC(a[10], a[25]); SQRADDAC(a[11], a[24]); SQRADDAC(a[12], a[23]); SQRADDAC(a[13], a[22]); SQRADDAC(a[14], a[21]); SQRADDAC(a[15], a[20]); SQRADDAC(a[16], a[19]); SQRADDAC(a[17], a[18]); SQRADDDB; COMBA_STORE(b[35]); /* output 36 */ CARRY_FORWARD; SQRADDSC(a[5], a[31]); SQRADDAC(a[6], a[30]); SQRADDAC(a[7], a[29]); SQRADDAC(a[8], a[28]); SQRADDAC(a[9], a[27]); SQRADDAC(a[10], a[26]); SQRADDAC(a[11], a[25]); SQRADDAC(a[12], a[24]); SQRADDAC(a[13], a[23]); SQRADDAC(a[14], a[22]); SQRADDAC(a[15], a[21]); SQRADDAC(a[16], a[20]); SQRADDAC(a[17], a[19]); SQRADDDB; SQRADD(a[18], a[18]); COMBA_STORE(b[36]); /* output 37 */ CARRY_FORWARD; SQRADDSC(a[6], a[31]); SQRADDAC(a[7], a[30]); SQRADDAC(a[8], a[29]); SQRADDAC(a[9], a[28]); SQRADDAC(a[10], a[27]); SQRADDAC(a[11], a[26]); SQRADDAC(a[12], a[25]); SQRADDAC(a[13], a[24]); SQRADDAC(a[14], a[23]); SQRADDAC(a[15], a[22]); SQRADDAC(a[16], a[21]); SQRADDAC(a[17], a[20]); SQRADDAC(a[18], a[19]); SQRADDDB; COMBA_STORE(b[37]); /* output 38 */ CARRY_FORWARD; SQRADDSC(a[7], a[31]); SQRADDAC(a[8], a[30]); SQRADDAC(a[9], a[29]); SQRADDAC(a[10], a[28]); SQRADDAC(a[11], a[27]); SQRADDAC(a[12], a[26]); SQRADDAC(a[13], a[25]); SQRADDAC(a[14], a[24]); SQRADDAC(a[15], a[23]); SQRADDAC(a[16], a[22]); SQRADDAC(a[17], a[21]); SQRADDAC(a[18], a[20]); SQRADDDB; SQRADD(a[19], a[19]); COMBA_STORE(b[38]); /* output 39 */ CARRY_FORWARD; SQRADDSC(a[8], a[31]); SQRADDAC(a[9], a[30]); SQRADDAC(a[10], a[29]); SQRADDAC(a[11], a[28]); SQRADDAC(a[12], a[27]); SQRADDAC(a[13], a[26]); SQRADDAC(a[14], a[25]); SQRADDAC(a[15], a[24]); SQRADDAC(a[16], a[23]); SQRADDAC(a[17], a[22]); SQRADDAC(a[18], a[21]); SQRADDAC(a[19], a[20]); SQRADDDB; COMBA_STORE(b[39]); /* output 40 */ CARRY_FORWARD; SQRADDSC(a[9], a[31]); SQRADDAC(a[10], a[30]); SQRADDAC(a[11], a[29]); SQRADDAC(a[12], a[28]); SQRADDAC(a[13], a[27]); SQRADDAC(a[14], a[26]); SQRADDAC(a[15], a[25]); SQRADDAC(a[16], a[24]); SQRADDAC(a[17], a[23]); SQRADDAC(a[18], a[22]); SQRADDAC(a[19], a[21]); SQRADDDB; SQRADD(a[20], a[20]); COMBA_STORE(b[40]); /* output 41 */ CARRY_FORWARD; SQRADDSC(a[10], a[31]); SQRADDAC(a[11], a[30]); SQRADDAC(a[12], a[29]); SQRADDAC(a[13], a[28]); SQRADDAC(a[14], a[27]); SQRADDAC(a[15], a[26]); SQRADDAC(a[16], a[25]); SQRADDAC(a[17], a[24]); SQRADDAC(a[18], a[23]); SQRADDAC(a[19], a[22]); SQRADDAC(a[20], a[21]); SQRADDDB; COMBA_STORE(b[41]); /* output 42 */ CARRY_FORWARD; SQRADDSC(a[11], a[31]); SQRADDAC(a[12], a[30]); SQRADDAC(a[13], a[29]); SQRADDAC(a[14], a[28]); SQRADDAC(a[15], a[27]); SQRADDAC(a[16], a[26]); SQRADDAC(a[17], a[25]); SQRADDAC(a[18], a[24]); SQRADDAC(a[19], a[23]); SQRADDAC(a[20], a[22]); SQRADDDB; SQRADD(a[21], a[21]); COMBA_STORE(b[42]); /* output 43 */ CARRY_FORWARD; SQRADDSC(a[12], a[31]); SQRADDAC(a[13], a[30]); SQRADDAC(a[14], a[29]); SQRADDAC(a[15], a[28]); SQRADDAC(a[16], a[27]); SQRADDAC(a[17], a[26]); SQRADDAC(a[18], a[25]); SQRADDAC(a[19], a[24]); SQRADDAC(a[20], a[23]); SQRADDAC(a[21], a[22]); SQRADDDB; COMBA_STORE(b[43]); /* output 44 */ CARRY_FORWARD; SQRADDSC(a[13], a[31]); SQRADDAC(a[14], a[30]); SQRADDAC(a[15], a[29]); SQRADDAC(a[16], a[28]); SQRADDAC(a[17], a[27]); SQRADDAC(a[18], a[26]); SQRADDAC(a[19], a[25]); SQRADDAC(a[20], a[24]); SQRADDAC(a[21], a[23]); SQRADDDB; SQRADD(a[22], a[22]); COMBA_STORE(b[44]); /* output 45 */ CARRY_FORWARD; SQRADDSC(a[14], a[31]); SQRADDAC(a[15], a[30]); SQRADDAC(a[16], a[29]); SQRADDAC(a[17], a[28]); SQRADDAC(a[18], a[27]); SQRADDAC(a[19], a[26]); SQRADDAC(a[20], a[25]); SQRADDAC(a[21], a[24]); SQRADDAC(a[22], a[23]); SQRADDDB; COMBA_STORE(b[45]); /* output 46 */ CARRY_FORWARD; SQRADDSC(a[15], a[31]); SQRADDAC(a[16], a[30]); SQRADDAC(a[17], a[29]); SQRADDAC(a[18], a[28]); SQRADDAC(a[19], a[27]); SQRADDAC(a[20], a[26]); SQRADDAC(a[21], a[25]); SQRADDAC(a[22], a[24]); SQRADDDB; SQRADD(a[23], a[23]); COMBA_STORE(b[46]); /* output 47 */ CARRY_FORWARD; SQRADDSC(a[16], a[31]); SQRADDAC(a[17], a[30]); SQRADDAC(a[18], a[29]); SQRADDAC(a[19], a[28]); SQRADDAC(a[20], a[27]); SQRADDAC(a[21], a[26]); SQRADDAC(a[22], a[25]); SQRADDAC(a[23], a[24]); SQRADDDB; COMBA_STORE(b[47]); /* output 48 */ CARRY_FORWARD; SQRADDSC(a[17], a[31]); SQRADDAC(a[18], a[30]); SQRADDAC(a[19], a[29]); SQRADDAC(a[20], a[28]); SQRADDAC(a[21], a[27]); SQRADDAC(a[22], a[26]); SQRADDAC(a[23], a[25]); SQRADDDB; SQRADD(a[24], a[24]); COMBA_STORE(b[48]); /* output 49 */ CARRY_FORWARD; SQRADDSC(a[18], a[31]); SQRADDAC(a[19], a[30]); SQRADDAC(a[20], a[29]); SQRADDAC(a[21], a[28]); SQRADDAC(a[22], a[27]); SQRADDAC(a[23], a[26]); SQRADDAC(a[24], a[25]); SQRADDDB; COMBA_STORE(b[49]); /* output 50 */ CARRY_FORWARD; SQRADDSC(a[19], a[31]); SQRADDAC(a[20], a[30]); SQRADDAC(a[21], a[29]); SQRADDAC(a[22], a[28]); SQRADDAC(a[23], a[27]); SQRADDAC(a[24], a[26]); SQRADDDB; SQRADD(a[25], a[25]); COMBA_STORE(b[50]); /* output 51 */ CARRY_FORWARD; SQRADDSC(a[20], a[31]); SQRADDAC(a[21], a[30]); SQRADDAC(a[22], a[29]); SQRADDAC(a[23], a[28]); SQRADDAC(a[24], a[27]); SQRADDAC(a[25], a[26]); SQRADDDB; COMBA_STORE(b[51]); /* output 52 */ CARRY_FORWARD; SQRADDSC(a[21], a[31]); SQRADDAC(a[22], a[30]); SQRADDAC(a[23], a[29]); SQRADDAC(a[24], a[28]); SQRADDAC(a[25], a[27]); SQRADDDB; SQRADD(a[26], a[26]); COMBA_STORE(b[52]); /* output 53 */ CARRY_FORWARD; SQRADDSC(a[22], a[31]); SQRADDAC(a[23], a[30]); SQRADDAC(a[24], a[29]); SQRADDAC(a[25], a[28]); SQRADDAC(a[26], a[27]); SQRADDDB; COMBA_STORE(b[53]); /* output 54 */ CARRY_FORWARD; SQRADDSC(a[23], a[31]); SQRADDAC(a[24], a[30]); SQRADDAC(a[25], a[29]); SQRADDAC(a[26], a[28]); SQRADDDB; SQRADD(a[27], a[27]); COMBA_STORE(b[54]); /* output 55 */ CARRY_FORWARD; SQRADDSC(a[24], a[31]); SQRADDAC(a[25], a[30]); SQRADDAC(a[26], a[29]); SQRADDAC(a[27], a[28]); SQRADDDB; COMBA_STORE(b[55]); /* output 56 */ CARRY_FORWARD; SQRADDSC(a[25], a[31]); SQRADDAC(a[26], a[30]); SQRADDAC(a[27], a[29]); SQRADDDB; SQRADD(a[28], a[28]); COMBA_STORE(b[56]); /* output 57 */ CARRY_FORWARD; SQRADDSC(a[26], a[31]); SQRADDAC(a[27], a[30]); SQRADDAC(a[28], a[29]); SQRADDDB; COMBA_STORE(b[57]); /* output 58 */ CARRY_FORWARD; SQRADD2(a[27], a[31]); SQRADD2(a[28], a[30]); SQRADD(a[29], a[29]); COMBA_STORE(b[58]); /* output 59 */ CARRY_FORWARD; SQRADD2(a[28], a[31]); SQRADD2(a[29], a[30]); COMBA_STORE(b[59]); /* output 60 */ CARRY_FORWARD; SQRADD2(a[29], a[31]); SQRADD(a[30], a[30]); COMBA_STORE(b[60]); /* output 61 */ CARRY_FORWARD; SQRADD2(a[30], a[31]); COMBA_STORE(b[61]); /* output 62 */ CARRY_FORWARD; SQRADD(a[31], a[31]); COMBA_STORE(b[62]); COMBA_STORE2(b[63]); COMBA_FINI; B->used = 64; B->sign = FP_ZPOS; memcpy(B->dp, b, 64 * sizeof(fp_digit)); fp_clamp(B); } #endif /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr_comba_32.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/17 03:39:01 $ */ /* End: src/sqr/fp_sqr_comba_32.c */ /* Start: src/sqr/fp_sqr_comba_4.c */ #define TFM_DEFINES //#include "fp_sqr_comba.c" #ifdef TFM_SQR4 void fp_sqr_comba4(fp_int *A, fp_int *B) { fp_digit *a, b[8], c0, c1, c2, sc0, sc1, sc2; #ifdef TFM_ISO fp_word tt; #endif a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADD2(a[2], a[3]); COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); COMBA_STORE2(b[7]); COMBA_FINI; B->used = 8; B->sign = FP_ZPOS; memcpy(B->dp, b, 8 * sizeof(fp_digit)); fp_clamp(B); } #endif /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr_comba_4.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/17 03:39:01 $ */ /* End: src/sqr/fp_sqr_comba_4.c */ /* Start: src/sqr/fp_sqr_comba_48.c */ #define TFM_DEFINES //#include "fp_sqr_comba.c" #ifdef TFM_SQR48 void fp_sqr_comba48(fp_int *A, fp_int *B) { fp_digit *a, b[96], c0, c1, c2, sc0, sc1, sc2; #ifdef TFM_ISO fp_word tt; #endif a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADDSC(a[0], a[15]); SQRADDAC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADDSC(a[0], a[16]); SQRADDAC(a[1], a[15]); SQRADDAC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); COMBA_STORE(b[16]); /* output 17 */ CARRY_FORWARD; SQRADDSC(a[0], a[17]); SQRADDAC(a[1], a[16]); SQRADDAC(a[2], a[15]); SQRADDAC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; COMBA_STORE(b[17]); /* output 18 */ CARRY_FORWARD; SQRADDSC(a[0], a[18]); SQRADDAC(a[1], a[17]); SQRADDAC(a[2], a[16]); SQRADDAC(a[3], a[15]); SQRADDAC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); COMBA_STORE(b[18]); /* output 19 */ CARRY_FORWARD; SQRADDSC(a[0], a[19]); SQRADDAC(a[1], a[18]); SQRADDAC(a[2], a[17]); SQRADDAC(a[3], a[16]); SQRADDAC(a[4], a[15]); SQRADDAC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; COMBA_STORE(b[19]); /* output 20 */ CARRY_FORWARD; SQRADDSC(a[0], a[20]); SQRADDAC(a[1], a[19]); SQRADDAC(a[2], a[18]); SQRADDAC(a[3], a[17]); SQRADDAC(a[4], a[16]); SQRADDAC(a[5], a[15]); SQRADDAC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); COMBA_STORE(b[20]); /* output 21 */ CARRY_FORWARD; SQRADDSC(a[0], a[21]); SQRADDAC(a[1], a[20]); SQRADDAC(a[2], a[19]); SQRADDAC(a[3], a[18]); SQRADDAC(a[4], a[17]); SQRADDAC(a[5], a[16]); SQRADDAC(a[6], a[15]); SQRADDAC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; COMBA_STORE(b[21]); /* output 22 */ CARRY_FORWARD; SQRADDSC(a[0], a[22]); SQRADDAC(a[1], a[21]); SQRADDAC(a[2], a[20]); SQRADDAC(a[3], a[19]); SQRADDAC(a[4], a[18]); SQRADDAC(a[5], a[17]); SQRADDAC(a[6], a[16]); SQRADDAC(a[7], a[15]); SQRADDAC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); COMBA_STORE(b[22]); /* output 23 */ CARRY_FORWARD; SQRADDSC(a[0], a[23]); SQRADDAC(a[1], a[22]); SQRADDAC(a[2], a[21]); SQRADDAC(a[3], a[20]); SQRADDAC(a[4], a[19]); SQRADDAC(a[5], a[18]); SQRADDAC(a[6], a[17]); SQRADDAC(a[7], a[16]); SQRADDAC(a[8], a[15]); SQRADDAC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; COMBA_STORE(b[23]); /* output 24 */ CARRY_FORWARD; SQRADDSC(a[0], a[24]); SQRADDAC(a[1], a[23]); SQRADDAC(a[2], a[22]); SQRADDAC(a[3], a[21]); SQRADDAC(a[4], a[20]); SQRADDAC(a[5], a[19]); SQRADDAC(a[6], a[18]); SQRADDAC(a[7], a[17]); SQRADDAC(a[8], a[16]); SQRADDAC(a[9], a[15]); SQRADDAC(a[10], a[14]); SQRADDAC(a[11], a[13]); SQRADDDB; SQRADD(a[12], a[12]); COMBA_STORE(b[24]); /* output 25 */ CARRY_FORWARD; SQRADDSC(a[0], a[25]); SQRADDAC(a[1], a[24]); SQRADDAC(a[2], a[23]); SQRADDAC(a[3], a[22]); SQRADDAC(a[4], a[21]); SQRADDAC(a[5], a[20]); SQRADDAC(a[6], a[19]); SQRADDAC(a[7], a[18]); SQRADDAC(a[8], a[17]); SQRADDAC(a[9], a[16]); SQRADDAC(a[10], a[15]); SQRADDAC(a[11], a[14]); SQRADDAC(a[12], a[13]); SQRADDDB; COMBA_STORE(b[25]); /* output 26 */ CARRY_FORWARD; SQRADDSC(a[0], a[26]); SQRADDAC(a[1], a[25]); SQRADDAC(a[2], a[24]); SQRADDAC(a[3], a[23]); SQRADDAC(a[4], a[22]); SQRADDAC(a[5], a[21]); SQRADDAC(a[6], a[20]); SQRADDAC(a[7], a[19]); SQRADDAC(a[8], a[18]); SQRADDAC(a[9], a[17]); SQRADDAC(a[10], a[16]); SQRADDAC(a[11], a[15]); SQRADDAC(a[12], a[14]); SQRADDDB; SQRADD(a[13], a[13]); COMBA_STORE(b[26]); /* output 27 */ CARRY_FORWARD; SQRADDSC(a[0], a[27]); SQRADDAC(a[1], a[26]); SQRADDAC(a[2], a[25]); SQRADDAC(a[3], a[24]); SQRADDAC(a[4], a[23]); SQRADDAC(a[5], a[22]); SQRADDAC(a[6], a[21]); SQRADDAC(a[7], a[20]); SQRADDAC(a[8], a[19]); SQRADDAC(a[9], a[18]); SQRADDAC(a[10], a[17]); SQRADDAC(a[11], a[16]); SQRADDAC(a[12], a[15]); SQRADDAC(a[13], a[14]); SQRADDDB; COMBA_STORE(b[27]); /* output 28 */ CARRY_FORWARD; SQRADDSC(a[0], a[28]); SQRADDAC(a[1], a[27]); SQRADDAC(a[2], a[26]); SQRADDAC(a[3], a[25]); SQRADDAC(a[4], a[24]); SQRADDAC(a[5], a[23]); SQRADDAC(a[6], a[22]); SQRADDAC(a[7], a[21]); SQRADDAC(a[8], a[20]); SQRADDAC(a[9], a[19]); SQRADDAC(a[10], a[18]); SQRADDAC(a[11], a[17]); SQRADDAC(a[12], a[16]); SQRADDAC(a[13], a[15]); SQRADDDB; SQRADD(a[14], a[14]); COMBA_STORE(b[28]); /* output 29 */ CARRY_FORWARD; SQRADDSC(a[0], a[29]); SQRADDAC(a[1], a[28]); SQRADDAC(a[2], a[27]); SQRADDAC(a[3], a[26]); SQRADDAC(a[4], a[25]); SQRADDAC(a[5], a[24]); SQRADDAC(a[6], a[23]); SQRADDAC(a[7], a[22]); SQRADDAC(a[8], a[21]); SQRADDAC(a[9], a[20]); SQRADDAC(a[10], a[19]); SQRADDAC(a[11], a[18]); SQRADDAC(a[12], a[17]); SQRADDAC(a[13], a[16]); SQRADDAC(a[14], a[15]); SQRADDDB; COMBA_STORE(b[29]); /* output 30 */ CARRY_FORWARD; SQRADDSC(a[0], a[30]); SQRADDAC(a[1], a[29]); SQRADDAC(a[2], a[28]); SQRADDAC(a[3], a[27]); SQRADDAC(a[4], a[26]); SQRADDAC(a[5], a[25]); SQRADDAC(a[6], a[24]); SQRADDAC(a[7], a[23]); SQRADDAC(a[8], a[22]); SQRADDAC(a[9], a[21]); SQRADDAC(a[10], a[20]); SQRADDAC(a[11], a[19]); SQRADDAC(a[12], a[18]); SQRADDAC(a[13], a[17]); SQRADDAC(a[14], a[16]); SQRADDDB; SQRADD(a[15], a[15]); COMBA_STORE(b[30]); /* output 31 */ CARRY_FORWARD; SQRADDSC(a[0], a[31]); SQRADDAC(a[1], a[30]); SQRADDAC(a[2], a[29]); SQRADDAC(a[3], a[28]); SQRADDAC(a[4], a[27]); SQRADDAC(a[5], a[26]); SQRADDAC(a[6], a[25]); SQRADDAC(a[7], a[24]); SQRADDAC(a[8], a[23]); SQRADDAC(a[9], a[22]); SQRADDAC(a[10], a[21]); SQRADDAC(a[11], a[20]); SQRADDAC(a[12], a[19]); SQRADDAC(a[13], a[18]); SQRADDAC(a[14], a[17]); SQRADDAC(a[15], a[16]); SQRADDDB; COMBA_STORE(b[31]); /* output 32 */ CARRY_FORWARD; SQRADDSC(a[0], a[32]); SQRADDAC(a[1], a[31]); SQRADDAC(a[2], a[30]); SQRADDAC(a[3], a[29]); SQRADDAC(a[4], a[28]); SQRADDAC(a[5], a[27]); SQRADDAC(a[6], a[26]); SQRADDAC(a[7], a[25]); SQRADDAC(a[8], a[24]); SQRADDAC(a[9], a[23]); SQRADDAC(a[10], a[22]); SQRADDAC(a[11], a[21]); SQRADDAC(a[12], a[20]); SQRADDAC(a[13], a[19]); SQRADDAC(a[14], a[18]); SQRADDAC(a[15], a[17]); SQRADDDB; SQRADD(a[16], a[16]); COMBA_STORE(b[32]); /* output 33 */ CARRY_FORWARD; SQRADDSC(a[0], a[33]); SQRADDAC(a[1], a[32]); SQRADDAC(a[2], a[31]); SQRADDAC(a[3], a[30]); SQRADDAC(a[4], a[29]); SQRADDAC(a[5], a[28]); SQRADDAC(a[6], a[27]); SQRADDAC(a[7], a[26]); SQRADDAC(a[8], a[25]); SQRADDAC(a[9], a[24]); SQRADDAC(a[10], a[23]); SQRADDAC(a[11], a[22]); SQRADDAC(a[12], a[21]); SQRADDAC(a[13], a[20]); SQRADDAC(a[14], a[19]); SQRADDAC(a[15], a[18]); SQRADDAC(a[16], a[17]); SQRADDDB; COMBA_STORE(b[33]); /* output 34 */ CARRY_FORWARD; SQRADDSC(a[0], a[34]); SQRADDAC(a[1], a[33]); SQRADDAC(a[2], a[32]); SQRADDAC(a[3], a[31]); SQRADDAC(a[4], a[30]); SQRADDAC(a[5], a[29]); SQRADDAC(a[6], a[28]); SQRADDAC(a[7], a[27]); SQRADDAC(a[8], a[26]); SQRADDAC(a[9], a[25]); SQRADDAC(a[10], a[24]); SQRADDAC(a[11], a[23]); SQRADDAC(a[12], a[22]); SQRADDAC(a[13], a[21]); SQRADDAC(a[14], a[20]); SQRADDAC(a[15], a[19]); SQRADDAC(a[16], a[18]); SQRADDDB; SQRADD(a[17], a[17]); COMBA_STORE(b[34]); /* output 35 */ CARRY_FORWARD; SQRADDSC(a[0], a[35]); SQRADDAC(a[1], a[34]); SQRADDAC(a[2], a[33]); SQRADDAC(a[3], a[32]); SQRADDAC(a[4], a[31]); SQRADDAC(a[5], a[30]); SQRADDAC(a[6], a[29]); SQRADDAC(a[7], a[28]); SQRADDAC(a[8], a[27]); SQRADDAC(a[9], a[26]); SQRADDAC(a[10], a[25]); SQRADDAC(a[11], a[24]); SQRADDAC(a[12], a[23]); SQRADDAC(a[13], a[22]); SQRADDAC(a[14], a[21]); SQRADDAC(a[15], a[20]); SQRADDAC(a[16], a[19]); SQRADDAC(a[17], a[18]); SQRADDDB; COMBA_STORE(b[35]); /* output 36 */ CARRY_FORWARD; SQRADDSC(a[0], a[36]); SQRADDAC(a[1], a[35]); SQRADDAC(a[2], a[34]); SQRADDAC(a[3], a[33]); SQRADDAC(a[4], a[32]); SQRADDAC(a[5], a[31]); SQRADDAC(a[6], a[30]); SQRADDAC(a[7], a[29]); SQRADDAC(a[8], a[28]); SQRADDAC(a[9], a[27]); SQRADDAC(a[10], a[26]); SQRADDAC(a[11], a[25]); SQRADDAC(a[12], a[24]); SQRADDAC(a[13], a[23]); SQRADDAC(a[14], a[22]); SQRADDAC(a[15], a[21]); SQRADDAC(a[16], a[20]); SQRADDAC(a[17], a[19]); SQRADDDB; SQRADD(a[18], a[18]); COMBA_STORE(b[36]); /* output 37 */ CARRY_FORWARD; SQRADDSC(a[0], a[37]); SQRADDAC(a[1], a[36]); SQRADDAC(a[2], a[35]); SQRADDAC(a[3], a[34]); SQRADDAC(a[4], a[33]); SQRADDAC(a[5], a[32]); SQRADDAC(a[6], a[31]); SQRADDAC(a[7], a[30]); SQRADDAC(a[8], a[29]); SQRADDAC(a[9], a[28]); SQRADDAC(a[10], a[27]); SQRADDAC(a[11], a[26]); SQRADDAC(a[12], a[25]); SQRADDAC(a[13], a[24]); SQRADDAC(a[14], a[23]); SQRADDAC(a[15], a[22]); SQRADDAC(a[16], a[21]); SQRADDAC(a[17], a[20]); SQRADDAC(a[18], a[19]); SQRADDDB; COMBA_STORE(b[37]); /* output 38 */ CARRY_FORWARD; SQRADDSC(a[0], a[38]); SQRADDAC(a[1], a[37]); SQRADDAC(a[2], a[36]); SQRADDAC(a[3], a[35]); SQRADDAC(a[4], a[34]); SQRADDAC(a[5], a[33]); SQRADDAC(a[6], a[32]); SQRADDAC(a[7], a[31]); SQRADDAC(a[8], a[30]); SQRADDAC(a[9], a[29]); SQRADDAC(a[10], a[28]); SQRADDAC(a[11], a[27]); SQRADDAC(a[12], a[26]); SQRADDAC(a[13], a[25]); SQRADDAC(a[14], a[24]); SQRADDAC(a[15], a[23]); SQRADDAC(a[16], a[22]); SQRADDAC(a[17], a[21]); SQRADDAC(a[18], a[20]); SQRADDDB; SQRADD(a[19], a[19]); COMBA_STORE(b[38]); /* output 39 */ CARRY_FORWARD; SQRADDSC(a[0], a[39]); SQRADDAC(a[1], a[38]); SQRADDAC(a[2], a[37]); SQRADDAC(a[3], a[36]); SQRADDAC(a[4], a[35]); SQRADDAC(a[5], a[34]); SQRADDAC(a[6], a[33]); SQRADDAC(a[7], a[32]); SQRADDAC(a[8], a[31]); SQRADDAC(a[9], a[30]); SQRADDAC(a[10], a[29]); SQRADDAC(a[11], a[28]); SQRADDAC(a[12], a[27]); SQRADDAC(a[13], a[26]); SQRADDAC(a[14], a[25]); SQRADDAC(a[15], a[24]); SQRADDAC(a[16], a[23]); SQRADDAC(a[17], a[22]); SQRADDAC(a[18], a[21]); SQRADDAC(a[19], a[20]); SQRADDDB; COMBA_STORE(b[39]); /* output 40 */ CARRY_FORWARD; SQRADDSC(a[0], a[40]); SQRADDAC(a[1], a[39]); SQRADDAC(a[2], a[38]); SQRADDAC(a[3], a[37]); SQRADDAC(a[4], a[36]); SQRADDAC(a[5], a[35]); SQRADDAC(a[6], a[34]); SQRADDAC(a[7], a[33]); SQRADDAC(a[8], a[32]); SQRADDAC(a[9], a[31]); SQRADDAC(a[10], a[30]); SQRADDAC(a[11], a[29]); SQRADDAC(a[12], a[28]); SQRADDAC(a[13], a[27]); SQRADDAC(a[14], a[26]); SQRADDAC(a[15], a[25]); SQRADDAC(a[16], a[24]); SQRADDAC(a[17], a[23]); SQRADDAC(a[18], a[22]); SQRADDAC(a[19], a[21]); SQRADDDB; SQRADD(a[20], a[20]); COMBA_STORE(b[40]); /* output 41 */ CARRY_FORWARD; SQRADDSC(a[0], a[41]); SQRADDAC(a[1], a[40]); SQRADDAC(a[2], a[39]); SQRADDAC(a[3], a[38]); SQRADDAC(a[4], a[37]); SQRADDAC(a[5], a[36]); SQRADDAC(a[6], a[35]); SQRADDAC(a[7], a[34]); SQRADDAC(a[8], a[33]); SQRADDAC(a[9], a[32]); SQRADDAC(a[10], a[31]); SQRADDAC(a[11], a[30]); SQRADDAC(a[12], a[29]); SQRADDAC(a[13], a[28]); SQRADDAC(a[14], a[27]); SQRADDAC(a[15], a[26]); SQRADDAC(a[16], a[25]); SQRADDAC(a[17], a[24]); SQRADDAC(a[18], a[23]); SQRADDAC(a[19], a[22]); SQRADDAC(a[20], a[21]); SQRADDDB; COMBA_STORE(b[41]); /* output 42 */ CARRY_FORWARD; SQRADDSC(a[0], a[42]); SQRADDAC(a[1], a[41]); SQRADDAC(a[2], a[40]); SQRADDAC(a[3], a[39]); SQRADDAC(a[4], a[38]); SQRADDAC(a[5], a[37]); SQRADDAC(a[6], a[36]); SQRADDAC(a[7], a[35]); SQRADDAC(a[8], a[34]); SQRADDAC(a[9], a[33]); SQRADDAC(a[10], a[32]); SQRADDAC(a[11], a[31]); SQRADDAC(a[12], a[30]); SQRADDAC(a[13], a[29]); SQRADDAC(a[14], a[28]); SQRADDAC(a[15], a[27]); SQRADDAC(a[16], a[26]); SQRADDAC(a[17], a[25]); SQRADDAC(a[18], a[24]); SQRADDAC(a[19], a[23]); SQRADDAC(a[20], a[22]); SQRADDDB; SQRADD(a[21], a[21]); COMBA_STORE(b[42]); /* output 43 */ CARRY_FORWARD; SQRADDSC(a[0], a[43]); SQRADDAC(a[1], a[42]); SQRADDAC(a[2], a[41]); SQRADDAC(a[3], a[40]); SQRADDAC(a[4], a[39]); SQRADDAC(a[5], a[38]); SQRADDAC(a[6], a[37]); SQRADDAC(a[7], a[36]); SQRADDAC(a[8], a[35]); SQRADDAC(a[9], a[34]); SQRADDAC(a[10], a[33]); SQRADDAC(a[11], a[32]); SQRADDAC(a[12], a[31]); SQRADDAC(a[13], a[30]); SQRADDAC(a[14], a[29]); SQRADDAC(a[15], a[28]); SQRADDAC(a[16], a[27]); SQRADDAC(a[17], a[26]); SQRADDAC(a[18], a[25]); SQRADDAC(a[19], a[24]); SQRADDAC(a[20], a[23]); SQRADDAC(a[21], a[22]); SQRADDDB; COMBA_STORE(b[43]); /* output 44 */ CARRY_FORWARD; SQRADDSC(a[0], a[44]); SQRADDAC(a[1], a[43]); SQRADDAC(a[2], a[42]); SQRADDAC(a[3], a[41]); SQRADDAC(a[4], a[40]); SQRADDAC(a[5], a[39]); SQRADDAC(a[6], a[38]); SQRADDAC(a[7], a[37]); SQRADDAC(a[8], a[36]); SQRADDAC(a[9], a[35]); SQRADDAC(a[10], a[34]); SQRADDAC(a[11], a[33]); SQRADDAC(a[12], a[32]); SQRADDAC(a[13], a[31]); SQRADDAC(a[14], a[30]); SQRADDAC(a[15], a[29]); SQRADDAC(a[16], a[28]); SQRADDAC(a[17], a[27]); SQRADDAC(a[18], a[26]); SQRADDAC(a[19], a[25]); SQRADDAC(a[20], a[24]); SQRADDAC(a[21], a[23]); SQRADDDB; SQRADD(a[22], a[22]); COMBA_STORE(b[44]); /* output 45 */ CARRY_FORWARD; SQRADDSC(a[0], a[45]); SQRADDAC(a[1], a[44]); SQRADDAC(a[2], a[43]); SQRADDAC(a[3], a[42]); SQRADDAC(a[4], a[41]); SQRADDAC(a[5], a[40]); SQRADDAC(a[6], a[39]); SQRADDAC(a[7], a[38]); SQRADDAC(a[8], a[37]); SQRADDAC(a[9], a[36]); SQRADDAC(a[10], a[35]); SQRADDAC(a[11], a[34]); SQRADDAC(a[12], a[33]); SQRADDAC(a[13], a[32]); SQRADDAC(a[14], a[31]); SQRADDAC(a[15], a[30]); SQRADDAC(a[16], a[29]); SQRADDAC(a[17], a[28]); SQRADDAC(a[18], a[27]); SQRADDAC(a[19], a[26]); SQRADDAC(a[20], a[25]); SQRADDAC(a[21], a[24]); SQRADDAC(a[22], a[23]); SQRADDDB; COMBA_STORE(b[45]); /* output 46 */ CARRY_FORWARD; SQRADDSC(a[0], a[46]); SQRADDAC(a[1], a[45]); SQRADDAC(a[2], a[44]); SQRADDAC(a[3], a[43]); SQRADDAC(a[4], a[42]); SQRADDAC(a[5], a[41]); SQRADDAC(a[6], a[40]); SQRADDAC(a[7], a[39]); SQRADDAC(a[8], a[38]); SQRADDAC(a[9], a[37]); SQRADDAC(a[10], a[36]); SQRADDAC(a[11], a[35]); SQRADDAC(a[12], a[34]); SQRADDAC(a[13], a[33]); SQRADDAC(a[14], a[32]); SQRADDAC(a[15], a[31]); SQRADDAC(a[16], a[30]); SQRADDAC(a[17], a[29]); SQRADDAC(a[18], a[28]); SQRADDAC(a[19], a[27]); SQRADDAC(a[20], a[26]); SQRADDAC(a[21], a[25]); SQRADDAC(a[22], a[24]); SQRADDDB; SQRADD(a[23], a[23]); COMBA_STORE(b[46]); /* output 47 */ CARRY_FORWARD; SQRADDSC(a[0], a[47]); SQRADDAC(a[1], a[46]); SQRADDAC(a[2], a[45]); SQRADDAC(a[3], a[44]); SQRADDAC(a[4], a[43]); SQRADDAC(a[5], a[42]); SQRADDAC(a[6], a[41]); SQRADDAC(a[7], a[40]); SQRADDAC(a[8], a[39]); SQRADDAC(a[9], a[38]); SQRADDAC(a[10], a[37]); SQRADDAC(a[11], a[36]); SQRADDAC(a[12], a[35]); SQRADDAC(a[13], a[34]); SQRADDAC(a[14], a[33]); SQRADDAC(a[15], a[32]); SQRADDAC(a[16], a[31]); SQRADDAC(a[17], a[30]); SQRADDAC(a[18], a[29]); SQRADDAC(a[19], a[28]); SQRADDAC(a[20], a[27]); SQRADDAC(a[21], a[26]); SQRADDAC(a[22], a[25]); SQRADDAC(a[23], a[24]); SQRADDDB; COMBA_STORE(b[47]); /* output 48 */ CARRY_FORWARD; SQRADDSC(a[1], a[47]); SQRADDAC(a[2], a[46]); SQRADDAC(a[3], a[45]); SQRADDAC(a[4], a[44]); SQRADDAC(a[5], a[43]); SQRADDAC(a[6], a[42]); SQRADDAC(a[7], a[41]); SQRADDAC(a[8], a[40]); SQRADDAC(a[9], a[39]); SQRADDAC(a[10], a[38]); SQRADDAC(a[11], a[37]); SQRADDAC(a[12], a[36]); SQRADDAC(a[13], a[35]); SQRADDAC(a[14], a[34]); SQRADDAC(a[15], a[33]); SQRADDAC(a[16], a[32]); SQRADDAC(a[17], a[31]); SQRADDAC(a[18], a[30]); SQRADDAC(a[19], a[29]); SQRADDAC(a[20], a[28]); SQRADDAC(a[21], a[27]); SQRADDAC(a[22], a[26]); SQRADDAC(a[23], a[25]); SQRADDDB; SQRADD(a[24], a[24]); COMBA_STORE(b[48]); /* output 49 */ CARRY_FORWARD; SQRADDSC(a[2], a[47]); SQRADDAC(a[3], a[46]); SQRADDAC(a[4], a[45]); SQRADDAC(a[5], a[44]); SQRADDAC(a[6], a[43]); SQRADDAC(a[7], a[42]); SQRADDAC(a[8], a[41]); SQRADDAC(a[9], a[40]); SQRADDAC(a[10], a[39]); SQRADDAC(a[11], a[38]); SQRADDAC(a[12], a[37]); SQRADDAC(a[13], a[36]); SQRADDAC(a[14], a[35]); SQRADDAC(a[15], a[34]); SQRADDAC(a[16], a[33]); SQRADDAC(a[17], a[32]); SQRADDAC(a[18], a[31]); SQRADDAC(a[19], a[30]); SQRADDAC(a[20], a[29]); SQRADDAC(a[21], a[28]); SQRADDAC(a[22], a[27]); SQRADDAC(a[23], a[26]); SQRADDAC(a[24], a[25]); SQRADDDB; COMBA_STORE(b[49]); /* output 50 */ CARRY_FORWARD; SQRADDSC(a[3], a[47]); SQRADDAC(a[4], a[46]); SQRADDAC(a[5], a[45]); SQRADDAC(a[6], a[44]); SQRADDAC(a[7], a[43]); SQRADDAC(a[8], a[42]); SQRADDAC(a[9], a[41]); SQRADDAC(a[10], a[40]); SQRADDAC(a[11], a[39]); SQRADDAC(a[12], a[38]); SQRADDAC(a[13], a[37]); SQRADDAC(a[14], a[36]); SQRADDAC(a[15], a[35]); SQRADDAC(a[16], a[34]); SQRADDAC(a[17], a[33]); SQRADDAC(a[18], a[32]); SQRADDAC(a[19], a[31]); SQRADDAC(a[20], a[30]); SQRADDAC(a[21], a[29]); SQRADDAC(a[22], a[28]); SQRADDAC(a[23], a[27]); SQRADDAC(a[24], a[26]); SQRADDDB; SQRADD(a[25], a[25]); COMBA_STORE(b[50]); /* output 51 */ CARRY_FORWARD; SQRADDSC(a[4], a[47]); SQRADDAC(a[5], a[46]); SQRADDAC(a[6], a[45]); SQRADDAC(a[7], a[44]); SQRADDAC(a[8], a[43]); SQRADDAC(a[9], a[42]); SQRADDAC(a[10], a[41]); SQRADDAC(a[11], a[40]); SQRADDAC(a[12], a[39]); SQRADDAC(a[13], a[38]); SQRADDAC(a[14], a[37]); SQRADDAC(a[15], a[36]); SQRADDAC(a[16], a[35]); SQRADDAC(a[17], a[34]); SQRADDAC(a[18], a[33]); SQRADDAC(a[19], a[32]); SQRADDAC(a[20], a[31]); SQRADDAC(a[21], a[30]); SQRADDAC(a[22], a[29]); SQRADDAC(a[23], a[28]); SQRADDAC(a[24], a[27]); SQRADDAC(a[25], a[26]); SQRADDDB; COMBA_STORE(b[51]); /* output 52 */ CARRY_FORWARD; SQRADDSC(a[5], a[47]); SQRADDAC(a[6], a[46]); SQRADDAC(a[7], a[45]); SQRADDAC(a[8], a[44]); SQRADDAC(a[9], a[43]); SQRADDAC(a[10], a[42]); SQRADDAC(a[11], a[41]); SQRADDAC(a[12], a[40]); SQRADDAC(a[13], a[39]); SQRADDAC(a[14], a[38]); SQRADDAC(a[15], a[37]); SQRADDAC(a[16], a[36]); SQRADDAC(a[17], a[35]); SQRADDAC(a[18], a[34]); SQRADDAC(a[19], a[33]); SQRADDAC(a[20], a[32]); SQRADDAC(a[21], a[31]); SQRADDAC(a[22], a[30]); SQRADDAC(a[23], a[29]); SQRADDAC(a[24], a[28]); SQRADDAC(a[25], a[27]); SQRADDDB; SQRADD(a[26], a[26]); COMBA_STORE(b[52]); /* output 53 */ CARRY_FORWARD; SQRADDSC(a[6], a[47]); SQRADDAC(a[7], a[46]); SQRADDAC(a[8], a[45]); SQRADDAC(a[9], a[44]); SQRADDAC(a[10], a[43]); SQRADDAC(a[11], a[42]); SQRADDAC(a[12], a[41]); SQRADDAC(a[13], a[40]); SQRADDAC(a[14], a[39]); SQRADDAC(a[15], a[38]); SQRADDAC(a[16], a[37]); SQRADDAC(a[17], a[36]); SQRADDAC(a[18], a[35]); SQRADDAC(a[19], a[34]); SQRADDAC(a[20], a[33]); SQRADDAC(a[21], a[32]); SQRADDAC(a[22], a[31]); SQRADDAC(a[23], a[30]); SQRADDAC(a[24], a[29]); SQRADDAC(a[25], a[28]); SQRADDAC(a[26], a[27]); SQRADDDB; COMBA_STORE(b[53]); /* output 54 */ CARRY_FORWARD; SQRADDSC(a[7], a[47]); SQRADDAC(a[8], a[46]); SQRADDAC(a[9], a[45]); SQRADDAC(a[10], a[44]); SQRADDAC(a[11], a[43]); SQRADDAC(a[12], a[42]); SQRADDAC(a[13], a[41]); SQRADDAC(a[14], a[40]); SQRADDAC(a[15], a[39]); SQRADDAC(a[16], a[38]); SQRADDAC(a[17], a[37]); SQRADDAC(a[18], a[36]); SQRADDAC(a[19], a[35]); SQRADDAC(a[20], a[34]); SQRADDAC(a[21], a[33]); SQRADDAC(a[22], a[32]); SQRADDAC(a[23], a[31]); SQRADDAC(a[24], a[30]); SQRADDAC(a[25], a[29]); SQRADDAC(a[26], a[28]); SQRADDDB; SQRADD(a[27], a[27]); COMBA_STORE(b[54]); /* output 55 */ CARRY_FORWARD; SQRADDSC(a[8], a[47]); SQRADDAC(a[9], a[46]); SQRADDAC(a[10], a[45]); SQRADDAC(a[11], a[44]); SQRADDAC(a[12], a[43]); SQRADDAC(a[13], a[42]); SQRADDAC(a[14], a[41]); SQRADDAC(a[15], a[40]); SQRADDAC(a[16], a[39]); SQRADDAC(a[17], a[38]); SQRADDAC(a[18], a[37]); SQRADDAC(a[19], a[36]); SQRADDAC(a[20], a[35]); SQRADDAC(a[21], a[34]); SQRADDAC(a[22], a[33]); SQRADDAC(a[23], a[32]); SQRADDAC(a[24], a[31]); SQRADDAC(a[25], a[30]); SQRADDAC(a[26], a[29]); SQRADDAC(a[27], a[28]); SQRADDDB; COMBA_STORE(b[55]); /* output 56 */ CARRY_FORWARD; SQRADDSC(a[9], a[47]); SQRADDAC(a[10], a[46]); SQRADDAC(a[11], a[45]); SQRADDAC(a[12], a[44]); SQRADDAC(a[13], a[43]); SQRADDAC(a[14], a[42]); SQRADDAC(a[15], a[41]); SQRADDAC(a[16], a[40]); SQRADDAC(a[17], a[39]); SQRADDAC(a[18], a[38]); SQRADDAC(a[19], a[37]); SQRADDAC(a[20], a[36]); SQRADDAC(a[21], a[35]); SQRADDAC(a[22], a[34]); SQRADDAC(a[23], a[33]); SQRADDAC(a[24], a[32]); SQRADDAC(a[25], a[31]); SQRADDAC(a[26], a[30]); SQRADDAC(a[27], a[29]); SQRADDDB; SQRADD(a[28], a[28]); COMBA_STORE(b[56]); /* output 57 */ CARRY_FORWARD; SQRADDSC(a[10], a[47]); SQRADDAC(a[11], a[46]); SQRADDAC(a[12], a[45]); SQRADDAC(a[13], a[44]); SQRADDAC(a[14], a[43]); SQRADDAC(a[15], a[42]); SQRADDAC(a[16], a[41]); SQRADDAC(a[17], a[40]); SQRADDAC(a[18], a[39]); SQRADDAC(a[19], a[38]); SQRADDAC(a[20], a[37]); SQRADDAC(a[21], a[36]); SQRADDAC(a[22], a[35]); SQRADDAC(a[23], a[34]); SQRADDAC(a[24], a[33]); SQRADDAC(a[25], a[32]); SQRADDAC(a[26], a[31]); SQRADDAC(a[27], a[30]); SQRADDAC(a[28], a[29]); SQRADDDB; COMBA_STORE(b[57]); /* output 58 */ CARRY_FORWARD; SQRADDSC(a[11], a[47]); SQRADDAC(a[12], a[46]); SQRADDAC(a[13], a[45]); SQRADDAC(a[14], a[44]); SQRADDAC(a[15], a[43]); SQRADDAC(a[16], a[42]); SQRADDAC(a[17], a[41]); SQRADDAC(a[18], a[40]); SQRADDAC(a[19], a[39]); SQRADDAC(a[20], a[38]); SQRADDAC(a[21], a[37]); SQRADDAC(a[22], a[36]); SQRADDAC(a[23], a[35]); SQRADDAC(a[24], a[34]); SQRADDAC(a[25], a[33]); SQRADDAC(a[26], a[32]); SQRADDAC(a[27], a[31]); SQRADDAC(a[28], a[30]); SQRADDDB; SQRADD(a[29], a[29]); COMBA_STORE(b[58]); /* output 59 */ CARRY_FORWARD; SQRADDSC(a[12], a[47]); SQRADDAC(a[13], a[46]); SQRADDAC(a[14], a[45]); SQRADDAC(a[15], a[44]); SQRADDAC(a[16], a[43]); SQRADDAC(a[17], a[42]); SQRADDAC(a[18], a[41]); SQRADDAC(a[19], a[40]); SQRADDAC(a[20], a[39]); SQRADDAC(a[21], a[38]); SQRADDAC(a[22], a[37]); SQRADDAC(a[23], a[36]); SQRADDAC(a[24], a[35]); SQRADDAC(a[25], a[34]); SQRADDAC(a[26], a[33]); SQRADDAC(a[27], a[32]); SQRADDAC(a[28], a[31]); SQRADDAC(a[29], a[30]); SQRADDDB; COMBA_STORE(b[59]); /* output 60 */ CARRY_FORWARD; SQRADDSC(a[13], a[47]); SQRADDAC(a[14], a[46]); SQRADDAC(a[15], a[45]); SQRADDAC(a[16], a[44]); SQRADDAC(a[17], a[43]); SQRADDAC(a[18], a[42]); SQRADDAC(a[19], a[41]); SQRADDAC(a[20], a[40]); SQRADDAC(a[21], a[39]); SQRADDAC(a[22], a[38]); SQRADDAC(a[23], a[37]); SQRADDAC(a[24], a[36]); SQRADDAC(a[25], a[35]); SQRADDAC(a[26], a[34]); SQRADDAC(a[27], a[33]); SQRADDAC(a[28], a[32]); SQRADDAC(a[29], a[31]); SQRADDDB; SQRADD(a[30], a[30]); COMBA_STORE(b[60]); /* output 61 */ CARRY_FORWARD; SQRADDSC(a[14], a[47]); SQRADDAC(a[15], a[46]); SQRADDAC(a[16], a[45]); SQRADDAC(a[17], a[44]); SQRADDAC(a[18], a[43]); SQRADDAC(a[19], a[42]); SQRADDAC(a[20], a[41]); SQRADDAC(a[21], a[40]); SQRADDAC(a[22], a[39]); SQRADDAC(a[23], a[38]); SQRADDAC(a[24], a[37]); SQRADDAC(a[25], a[36]); SQRADDAC(a[26], a[35]); SQRADDAC(a[27], a[34]); SQRADDAC(a[28], a[33]); SQRADDAC(a[29], a[32]); SQRADDAC(a[30], a[31]); SQRADDDB; COMBA_STORE(b[61]); /* output 62 */ CARRY_FORWARD; SQRADDSC(a[15], a[47]); SQRADDAC(a[16], a[46]); SQRADDAC(a[17], a[45]); SQRADDAC(a[18], a[44]); SQRADDAC(a[19], a[43]); SQRADDAC(a[20], a[42]); SQRADDAC(a[21], a[41]); SQRADDAC(a[22], a[40]); SQRADDAC(a[23], a[39]); SQRADDAC(a[24], a[38]); SQRADDAC(a[25], a[37]); SQRADDAC(a[26], a[36]); SQRADDAC(a[27], a[35]); SQRADDAC(a[28], a[34]); SQRADDAC(a[29], a[33]); SQRADDAC(a[30], a[32]); SQRADDDB; SQRADD(a[31], a[31]); COMBA_STORE(b[62]); /* output 63 */ CARRY_FORWARD; SQRADDSC(a[16], a[47]); SQRADDAC(a[17], a[46]); SQRADDAC(a[18], a[45]); SQRADDAC(a[19], a[44]); SQRADDAC(a[20], a[43]); SQRADDAC(a[21], a[42]); SQRADDAC(a[22], a[41]); SQRADDAC(a[23], a[40]); SQRADDAC(a[24], a[39]); SQRADDAC(a[25], a[38]); SQRADDAC(a[26], a[37]); SQRADDAC(a[27], a[36]); SQRADDAC(a[28], a[35]); SQRADDAC(a[29], a[34]); SQRADDAC(a[30], a[33]); SQRADDAC(a[31], a[32]); SQRADDDB; COMBA_STORE(b[63]); /* output 64 */ CARRY_FORWARD; SQRADDSC(a[17], a[47]); SQRADDAC(a[18], a[46]); SQRADDAC(a[19], a[45]); SQRADDAC(a[20], a[44]); SQRADDAC(a[21], a[43]); SQRADDAC(a[22], a[42]); SQRADDAC(a[23], a[41]); SQRADDAC(a[24], a[40]); SQRADDAC(a[25], a[39]); SQRADDAC(a[26], a[38]); SQRADDAC(a[27], a[37]); SQRADDAC(a[28], a[36]); SQRADDAC(a[29], a[35]); SQRADDAC(a[30], a[34]); SQRADDAC(a[31], a[33]); SQRADDDB; SQRADD(a[32], a[32]); COMBA_STORE(b[64]); /* output 65 */ CARRY_FORWARD; SQRADDSC(a[18], a[47]); SQRADDAC(a[19], a[46]); SQRADDAC(a[20], a[45]); SQRADDAC(a[21], a[44]); SQRADDAC(a[22], a[43]); SQRADDAC(a[23], a[42]); SQRADDAC(a[24], a[41]); SQRADDAC(a[25], a[40]); SQRADDAC(a[26], a[39]); SQRADDAC(a[27], a[38]); SQRADDAC(a[28], a[37]); SQRADDAC(a[29], a[36]); SQRADDAC(a[30], a[35]); SQRADDAC(a[31], a[34]); SQRADDAC(a[32], a[33]); SQRADDDB; COMBA_STORE(b[65]); /* output 66 */ CARRY_FORWARD; SQRADDSC(a[19], a[47]); SQRADDAC(a[20], a[46]); SQRADDAC(a[21], a[45]); SQRADDAC(a[22], a[44]); SQRADDAC(a[23], a[43]); SQRADDAC(a[24], a[42]); SQRADDAC(a[25], a[41]); SQRADDAC(a[26], a[40]); SQRADDAC(a[27], a[39]); SQRADDAC(a[28], a[38]); SQRADDAC(a[29], a[37]); SQRADDAC(a[30], a[36]); SQRADDAC(a[31], a[35]); SQRADDAC(a[32], a[34]); SQRADDDB; SQRADD(a[33], a[33]); COMBA_STORE(b[66]); /* output 67 */ CARRY_FORWARD; SQRADDSC(a[20], a[47]); SQRADDAC(a[21], a[46]); SQRADDAC(a[22], a[45]); SQRADDAC(a[23], a[44]); SQRADDAC(a[24], a[43]); SQRADDAC(a[25], a[42]); SQRADDAC(a[26], a[41]); SQRADDAC(a[27], a[40]); SQRADDAC(a[28], a[39]); SQRADDAC(a[29], a[38]); SQRADDAC(a[30], a[37]); SQRADDAC(a[31], a[36]); SQRADDAC(a[32], a[35]); SQRADDAC(a[33], a[34]); SQRADDDB; COMBA_STORE(b[67]); /* output 68 */ CARRY_FORWARD; SQRADDSC(a[21], a[47]); SQRADDAC(a[22], a[46]); SQRADDAC(a[23], a[45]); SQRADDAC(a[24], a[44]); SQRADDAC(a[25], a[43]); SQRADDAC(a[26], a[42]); SQRADDAC(a[27], a[41]); SQRADDAC(a[28], a[40]); SQRADDAC(a[29], a[39]); SQRADDAC(a[30], a[38]); SQRADDAC(a[31], a[37]); SQRADDAC(a[32], a[36]); SQRADDAC(a[33], a[35]); SQRADDDB; SQRADD(a[34], a[34]); COMBA_STORE(b[68]); /* output 69 */ CARRY_FORWARD; SQRADDSC(a[22], a[47]); SQRADDAC(a[23], a[46]); SQRADDAC(a[24], a[45]); SQRADDAC(a[25], a[44]); SQRADDAC(a[26], a[43]); SQRADDAC(a[27], a[42]); SQRADDAC(a[28], a[41]); SQRADDAC(a[29], a[40]); SQRADDAC(a[30], a[39]); SQRADDAC(a[31], a[38]); SQRADDAC(a[32], a[37]); SQRADDAC(a[33], a[36]); SQRADDAC(a[34], a[35]); SQRADDDB; COMBA_STORE(b[69]); /* output 70 */ CARRY_FORWARD; SQRADDSC(a[23], a[47]); SQRADDAC(a[24], a[46]); SQRADDAC(a[25], a[45]); SQRADDAC(a[26], a[44]); SQRADDAC(a[27], a[43]); SQRADDAC(a[28], a[42]); SQRADDAC(a[29], a[41]); SQRADDAC(a[30], a[40]); SQRADDAC(a[31], a[39]); SQRADDAC(a[32], a[38]); SQRADDAC(a[33], a[37]); SQRADDAC(a[34], a[36]); SQRADDDB; SQRADD(a[35], a[35]); COMBA_STORE(b[70]); /* output 71 */ CARRY_FORWARD; SQRADDSC(a[24], a[47]); SQRADDAC(a[25], a[46]); SQRADDAC(a[26], a[45]); SQRADDAC(a[27], a[44]); SQRADDAC(a[28], a[43]); SQRADDAC(a[29], a[42]); SQRADDAC(a[30], a[41]); SQRADDAC(a[31], a[40]); SQRADDAC(a[32], a[39]); SQRADDAC(a[33], a[38]); SQRADDAC(a[34], a[37]); SQRADDAC(a[35], a[36]); SQRADDDB; COMBA_STORE(b[71]); /* output 72 */ CARRY_FORWARD; SQRADDSC(a[25], a[47]); SQRADDAC(a[26], a[46]); SQRADDAC(a[27], a[45]); SQRADDAC(a[28], a[44]); SQRADDAC(a[29], a[43]); SQRADDAC(a[30], a[42]); SQRADDAC(a[31], a[41]); SQRADDAC(a[32], a[40]); SQRADDAC(a[33], a[39]); SQRADDAC(a[34], a[38]); SQRADDAC(a[35], a[37]); SQRADDDB; SQRADD(a[36], a[36]); COMBA_STORE(b[72]); /* output 73 */ CARRY_FORWARD; SQRADDSC(a[26], a[47]); SQRADDAC(a[27], a[46]); SQRADDAC(a[28], a[45]); SQRADDAC(a[29], a[44]); SQRADDAC(a[30], a[43]); SQRADDAC(a[31], a[42]); SQRADDAC(a[32], a[41]); SQRADDAC(a[33], a[40]); SQRADDAC(a[34], a[39]); SQRADDAC(a[35], a[38]); SQRADDAC(a[36], a[37]); SQRADDDB; COMBA_STORE(b[73]); /* output 74 */ CARRY_FORWARD; SQRADDSC(a[27], a[47]); SQRADDAC(a[28], a[46]); SQRADDAC(a[29], a[45]); SQRADDAC(a[30], a[44]); SQRADDAC(a[31], a[43]); SQRADDAC(a[32], a[42]); SQRADDAC(a[33], a[41]); SQRADDAC(a[34], a[40]); SQRADDAC(a[35], a[39]); SQRADDAC(a[36], a[38]); SQRADDDB; SQRADD(a[37], a[37]); COMBA_STORE(b[74]); /* output 75 */ CARRY_FORWARD; SQRADDSC(a[28], a[47]); SQRADDAC(a[29], a[46]); SQRADDAC(a[30], a[45]); SQRADDAC(a[31], a[44]); SQRADDAC(a[32], a[43]); SQRADDAC(a[33], a[42]); SQRADDAC(a[34], a[41]); SQRADDAC(a[35], a[40]); SQRADDAC(a[36], a[39]); SQRADDAC(a[37], a[38]); SQRADDDB; COMBA_STORE(b[75]); /* output 76 */ CARRY_FORWARD; SQRADDSC(a[29], a[47]); SQRADDAC(a[30], a[46]); SQRADDAC(a[31], a[45]); SQRADDAC(a[32], a[44]); SQRADDAC(a[33], a[43]); SQRADDAC(a[34], a[42]); SQRADDAC(a[35], a[41]); SQRADDAC(a[36], a[40]); SQRADDAC(a[37], a[39]); SQRADDDB; SQRADD(a[38], a[38]); COMBA_STORE(b[76]); /* output 77 */ CARRY_FORWARD; SQRADDSC(a[30], a[47]); SQRADDAC(a[31], a[46]); SQRADDAC(a[32], a[45]); SQRADDAC(a[33], a[44]); SQRADDAC(a[34], a[43]); SQRADDAC(a[35], a[42]); SQRADDAC(a[36], a[41]); SQRADDAC(a[37], a[40]); SQRADDAC(a[38], a[39]); SQRADDDB; COMBA_STORE(b[77]); /* output 78 */ CARRY_FORWARD; SQRADDSC(a[31], a[47]); SQRADDAC(a[32], a[46]); SQRADDAC(a[33], a[45]); SQRADDAC(a[34], a[44]); SQRADDAC(a[35], a[43]); SQRADDAC(a[36], a[42]); SQRADDAC(a[37], a[41]); SQRADDAC(a[38], a[40]); SQRADDDB; SQRADD(a[39], a[39]); COMBA_STORE(b[78]); /* output 79 */ CARRY_FORWARD; SQRADDSC(a[32], a[47]); SQRADDAC(a[33], a[46]); SQRADDAC(a[34], a[45]); SQRADDAC(a[35], a[44]); SQRADDAC(a[36], a[43]); SQRADDAC(a[37], a[42]); SQRADDAC(a[38], a[41]); SQRADDAC(a[39], a[40]); SQRADDDB; COMBA_STORE(b[79]); /* output 80 */ CARRY_FORWARD; SQRADDSC(a[33], a[47]); SQRADDAC(a[34], a[46]); SQRADDAC(a[35], a[45]); SQRADDAC(a[36], a[44]); SQRADDAC(a[37], a[43]); SQRADDAC(a[38], a[42]); SQRADDAC(a[39], a[41]); SQRADDDB; SQRADD(a[40], a[40]); COMBA_STORE(b[80]); /* output 81 */ CARRY_FORWARD; SQRADDSC(a[34], a[47]); SQRADDAC(a[35], a[46]); SQRADDAC(a[36], a[45]); SQRADDAC(a[37], a[44]); SQRADDAC(a[38], a[43]); SQRADDAC(a[39], a[42]); SQRADDAC(a[40], a[41]); SQRADDDB; COMBA_STORE(b[81]); /* output 82 */ CARRY_FORWARD; SQRADDSC(a[35], a[47]); SQRADDAC(a[36], a[46]); SQRADDAC(a[37], a[45]); SQRADDAC(a[38], a[44]); SQRADDAC(a[39], a[43]); SQRADDAC(a[40], a[42]); SQRADDDB; SQRADD(a[41], a[41]); COMBA_STORE(b[82]); /* output 83 */ CARRY_FORWARD; SQRADDSC(a[36], a[47]); SQRADDAC(a[37], a[46]); SQRADDAC(a[38], a[45]); SQRADDAC(a[39], a[44]); SQRADDAC(a[40], a[43]); SQRADDAC(a[41], a[42]); SQRADDDB; COMBA_STORE(b[83]); /* output 84 */ CARRY_FORWARD; SQRADDSC(a[37], a[47]); SQRADDAC(a[38], a[46]); SQRADDAC(a[39], a[45]); SQRADDAC(a[40], a[44]); SQRADDAC(a[41], a[43]); SQRADDDB; SQRADD(a[42], a[42]); COMBA_STORE(b[84]); /* output 85 */ CARRY_FORWARD; SQRADDSC(a[38], a[47]); SQRADDAC(a[39], a[46]); SQRADDAC(a[40], a[45]); SQRADDAC(a[41], a[44]); SQRADDAC(a[42], a[43]); SQRADDDB; COMBA_STORE(b[85]); /* output 86 */ CARRY_FORWARD; SQRADDSC(a[39], a[47]); SQRADDAC(a[40], a[46]); SQRADDAC(a[41], a[45]); SQRADDAC(a[42], a[44]); SQRADDDB; SQRADD(a[43], a[43]); COMBA_STORE(b[86]); /* output 87 */ CARRY_FORWARD; SQRADDSC(a[40], a[47]); SQRADDAC(a[41], a[46]); SQRADDAC(a[42], a[45]); SQRADDAC(a[43], a[44]); SQRADDDB; COMBA_STORE(b[87]); /* output 88 */ CARRY_FORWARD; SQRADDSC(a[41], a[47]); SQRADDAC(a[42], a[46]); SQRADDAC(a[43], a[45]); SQRADDDB; SQRADD(a[44], a[44]); COMBA_STORE(b[88]); /* output 89 */ CARRY_FORWARD; SQRADDSC(a[42], a[47]); SQRADDAC(a[43], a[46]); SQRADDAC(a[44], a[45]); SQRADDDB; COMBA_STORE(b[89]); /* output 90 */ CARRY_FORWARD; SQRADD2(a[43], a[47]); SQRADD2(a[44], a[46]); SQRADD(a[45], a[45]); COMBA_STORE(b[90]); /* output 91 */ CARRY_FORWARD; SQRADD2(a[44], a[47]); SQRADD2(a[45], a[46]); COMBA_STORE(b[91]); /* output 92 */ CARRY_FORWARD; SQRADD2(a[45], a[47]); SQRADD(a[46], a[46]); COMBA_STORE(b[92]); /* output 93 */ CARRY_FORWARD; SQRADD2(a[46], a[47]); COMBA_STORE(b[93]); /* output 94 */ CARRY_FORWARD; SQRADD(a[47], a[47]); COMBA_STORE(b[94]); COMBA_STORE2(b[95]); COMBA_FINI; B->used = 96; B->sign = FP_ZPOS; memcpy(B->dp, b, 96 * sizeof(fp_digit)); fp_clamp(B); } #endif /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr_comba_48.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/17 03:39:01 $ */ /* End: src/sqr/fp_sqr_comba_48.c */ /* Start: src/sqr/fp_sqr_comba_6.c */ #define TFM_DEFINES //#include "fp_sqr_comba.c" #ifdef TFM_SQR6 void fp_sqr_comba6(fp_int *A, fp_int *B) { fp_digit *a, b[12], c0, c1, c2, sc0, sc1, sc2; #ifdef TFM_ISO fp_word tt; #endif a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADD2(a[1], a[5]); SQRADD2(a[2], a[4]); SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADD2(a[2], a[5]); SQRADD2(a[3], a[4]); COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADD2(a[3], a[5]); SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADD2(a[4], a[5]); COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); COMBA_STORE2(b[11]); COMBA_FINI; B->used = 12; B->sign = FP_ZPOS; memcpy(B->dp, b, 12 * sizeof(fp_digit)); fp_clamp(B); } #endif /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr_comba_6.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/17 03:39:01 $ */ /* End: src/sqr/fp_sqr_comba_6.c */ /* Start: src/sqr/fp_sqr_comba_64.c */ #define TFM_DEFINES //#include "fp_sqr_comba.c" #ifdef TFM_SQR64 void fp_sqr_comba64(fp_int *A, fp_int *B) { fp_digit *a, b[128], c0, c1, c2, sc0, sc1, sc2; #ifdef TFM_ISO fp_word tt; #endif a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADDSC(a[0], a[15]); SQRADDAC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADDSC(a[0], a[16]); SQRADDAC(a[1], a[15]); SQRADDAC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); COMBA_STORE(b[16]); /* output 17 */ CARRY_FORWARD; SQRADDSC(a[0], a[17]); SQRADDAC(a[1], a[16]); SQRADDAC(a[2], a[15]); SQRADDAC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; COMBA_STORE(b[17]); /* output 18 */ CARRY_FORWARD; SQRADDSC(a[0], a[18]); SQRADDAC(a[1], a[17]); SQRADDAC(a[2], a[16]); SQRADDAC(a[3], a[15]); SQRADDAC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); COMBA_STORE(b[18]); /* output 19 */ CARRY_FORWARD; SQRADDSC(a[0], a[19]); SQRADDAC(a[1], a[18]); SQRADDAC(a[2], a[17]); SQRADDAC(a[3], a[16]); SQRADDAC(a[4], a[15]); SQRADDAC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; COMBA_STORE(b[19]); /* output 20 */ CARRY_FORWARD; SQRADDSC(a[0], a[20]); SQRADDAC(a[1], a[19]); SQRADDAC(a[2], a[18]); SQRADDAC(a[3], a[17]); SQRADDAC(a[4], a[16]); SQRADDAC(a[5], a[15]); SQRADDAC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); COMBA_STORE(b[20]); /* output 21 */ CARRY_FORWARD; SQRADDSC(a[0], a[21]); SQRADDAC(a[1], a[20]); SQRADDAC(a[2], a[19]); SQRADDAC(a[3], a[18]); SQRADDAC(a[4], a[17]); SQRADDAC(a[5], a[16]); SQRADDAC(a[6], a[15]); SQRADDAC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; COMBA_STORE(b[21]); /* output 22 */ CARRY_FORWARD; SQRADDSC(a[0], a[22]); SQRADDAC(a[1], a[21]); SQRADDAC(a[2], a[20]); SQRADDAC(a[3], a[19]); SQRADDAC(a[4], a[18]); SQRADDAC(a[5], a[17]); SQRADDAC(a[6], a[16]); SQRADDAC(a[7], a[15]); SQRADDAC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); COMBA_STORE(b[22]); /* output 23 */ CARRY_FORWARD; SQRADDSC(a[0], a[23]); SQRADDAC(a[1], a[22]); SQRADDAC(a[2], a[21]); SQRADDAC(a[3], a[20]); SQRADDAC(a[4], a[19]); SQRADDAC(a[5], a[18]); SQRADDAC(a[6], a[17]); SQRADDAC(a[7], a[16]); SQRADDAC(a[8], a[15]); SQRADDAC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; COMBA_STORE(b[23]); /* output 24 */ CARRY_FORWARD; SQRADDSC(a[0], a[24]); SQRADDAC(a[1], a[23]); SQRADDAC(a[2], a[22]); SQRADDAC(a[3], a[21]); SQRADDAC(a[4], a[20]); SQRADDAC(a[5], a[19]); SQRADDAC(a[6], a[18]); SQRADDAC(a[7], a[17]); SQRADDAC(a[8], a[16]); SQRADDAC(a[9], a[15]); SQRADDAC(a[10], a[14]); SQRADDAC(a[11], a[13]); SQRADDDB; SQRADD(a[12], a[12]); COMBA_STORE(b[24]); /* output 25 */ CARRY_FORWARD; SQRADDSC(a[0], a[25]); SQRADDAC(a[1], a[24]); SQRADDAC(a[2], a[23]); SQRADDAC(a[3], a[22]); SQRADDAC(a[4], a[21]); SQRADDAC(a[5], a[20]); SQRADDAC(a[6], a[19]); SQRADDAC(a[7], a[18]); SQRADDAC(a[8], a[17]); SQRADDAC(a[9], a[16]); SQRADDAC(a[10], a[15]); SQRADDAC(a[11], a[14]); SQRADDAC(a[12], a[13]); SQRADDDB; COMBA_STORE(b[25]); /* output 26 */ CARRY_FORWARD; SQRADDSC(a[0], a[26]); SQRADDAC(a[1], a[25]); SQRADDAC(a[2], a[24]); SQRADDAC(a[3], a[23]); SQRADDAC(a[4], a[22]); SQRADDAC(a[5], a[21]); SQRADDAC(a[6], a[20]); SQRADDAC(a[7], a[19]); SQRADDAC(a[8], a[18]); SQRADDAC(a[9], a[17]); SQRADDAC(a[10], a[16]); SQRADDAC(a[11], a[15]); SQRADDAC(a[12], a[14]); SQRADDDB; SQRADD(a[13], a[13]); COMBA_STORE(b[26]); /* output 27 */ CARRY_FORWARD; SQRADDSC(a[0], a[27]); SQRADDAC(a[1], a[26]); SQRADDAC(a[2], a[25]); SQRADDAC(a[3], a[24]); SQRADDAC(a[4], a[23]); SQRADDAC(a[5], a[22]); SQRADDAC(a[6], a[21]); SQRADDAC(a[7], a[20]); SQRADDAC(a[8], a[19]); SQRADDAC(a[9], a[18]); SQRADDAC(a[10], a[17]); SQRADDAC(a[11], a[16]); SQRADDAC(a[12], a[15]); SQRADDAC(a[13], a[14]); SQRADDDB; COMBA_STORE(b[27]); /* output 28 */ CARRY_FORWARD; SQRADDSC(a[0], a[28]); SQRADDAC(a[1], a[27]); SQRADDAC(a[2], a[26]); SQRADDAC(a[3], a[25]); SQRADDAC(a[4], a[24]); SQRADDAC(a[5], a[23]); SQRADDAC(a[6], a[22]); SQRADDAC(a[7], a[21]); SQRADDAC(a[8], a[20]); SQRADDAC(a[9], a[19]); SQRADDAC(a[10], a[18]); SQRADDAC(a[11], a[17]); SQRADDAC(a[12], a[16]); SQRADDAC(a[13], a[15]); SQRADDDB; SQRADD(a[14], a[14]); COMBA_STORE(b[28]); /* output 29 */ CARRY_FORWARD; SQRADDSC(a[0], a[29]); SQRADDAC(a[1], a[28]); SQRADDAC(a[2], a[27]); SQRADDAC(a[3], a[26]); SQRADDAC(a[4], a[25]); SQRADDAC(a[5], a[24]); SQRADDAC(a[6], a[23]); SQRADDAC(a[7], a[22]); SQRADDAC(a[8], a[21]); SQRADDAC(a[9], a[20]); SQRADDAC(a[10], a[19]); SQRADDAC(a[11], a[18]); SQRADDAC(a[12], a[17]); SQRADDAC(a[13], a[16]); SQRADDAC(a[14], a[15]); SQRADDDB; COMBA_STORE(b[29]); /* output 30 */ CARRY_FORWARD; SQRADDSC(a[0], a[30]); SQRADDAC(a[1], a[29]); SQRADDAC(a[2], a[28]); SQRADDAC(a[3], a[27]); SQRADDAC(a[4], a[26]); SQRADDAC(a[5], a[25]); SQRADDAC(a[6], a[24]); SQRADDAC(a[7], a[23]); SQRADDAC(a[8], a[22]); SQRADDAC(a[9], a[21]); SQRADDAC(a[10], a[20]); SQRADDAC(a[11], a[19]); SQRADDAC(a[12], a[18]); SQRADDAC(a[13], a[17]); SQRADDAC(a[14], a[16]); SQRADDDB; SQRADD(a[15], a[15]); COMBA_STORE(b[30]); /* output 31 */ CARRY_FORWARD; SQRADDSC(a[0], a[31]); SQRADDAC(a[1], a[30]); SQRADDAC(a[2], a[29]); SQRADDAC(a[3], a[28]); SQRADDAC(a[4], a[27]); SQRADDAC(a[5], a[26]); SQRADDAC(a[6], a[25]); SQRADDAC(a[7], a[24]); SQRADDAC(a[8], a[23]); SQRADDAC(a[9], a[22]); SQRADDAC(a[10], a[21]); SQRADDAC(a[11], a[20]); SQRADDAC(a[12], a[19]); SQRADDAC(a[13], a[18]); SQRADDAC(a[14], a[17]); SQRADDAC(a[15], a[16]); SQRADDDB; COMBA_STORE(b[31]); /* output 32 */ CARRY_FORWARD; SQRADDSC(a[0], a[32]); SQRADDAC(a[1], a[31]); SQRADDAC(a[2], a[30]); SQRADDAC(a[3], a[29]); SQRADDAC(a[4], a[28]); SQRADDAC(a[5], a[27]); SQRADDAC(a[6], a[26]); SQRADDAC(a[7], a[25]); SQRADDAC(a[8], a[24]); SQRADDAC(a[9], a[23]); SQRADDAC(a[10], a[22]); SQRADDAC(a[11], a[21]); SQRADDAC(a[12], a[20]); SQRADDAC(a[13], a[19]); SQRADDAC(a[14], a[18]); SQRADDAC(a[15], a[17]); SQRADDDB; SQRADD(a[16], a[16]); COMBA_STORE(b[32]); /* output 33 */ CARRY_FORWARD; SQRADDSC(a[0], a[33]); SQRADDAC(a[1], a[32]); SQRADDAC(a[2], a[31]); SQRADDAC(a[3], a[30]); SQRADDAC(a[4], a[29]); SQRADDAC(a[5], a[28]); SQRADDAC(a[6], a[27]); SQRADDAC(a[7], a[26]); SQRADDAC(a[8], a[25]); SQRADDAC(a[9], a[24]); SQRADDAC(a[10], a[23]); SQRADDAC(a[11], a[22]); SQRADDAC(a[12], a[21]); SQRADDAC(a[13], a[20]); SQRADDAC(a[14], a[19]); SQRADDAC(a[15], a[18]); SQRADDAC(a[16], a[17]); SQRADDDB; COMBA_STORE(b[33]); /* output 34 */ CARRY_FORWARD; SQRADDSC(a[0], a[34]); SQRADDAC(a[1], a[33]); SQRADDAC(a[2], a[32]); SQRADDAC(a[3], a[31]); SQRADDAC(a[4], a[30]); SQRADDAC(a[5], a[29]); SQRADDAC(a[6], a[28]); SQRADDAC(a[7], a[27]); SQRADDAC(a[8], a[26]); SQRADDAC(a[9], a[25]); SQRADDAC(a[10], a[24]); SQRADDAC(a[11], a[23]); SQRADDAC(a[12], a[22]); SQRADDAC(a[13], a[21]); SQRADDAC(a[14], a[20]); SQRADDAC(a[15], a[19]); SQRADDAC(a[16], a[18]); SQRADDDB; SQRADD(a[17], a[17]); COMBA_STORE(b[34]); /* output 35 */ CARRY_FORWARD; SQRADDSC(a[0], a[35]); SQRADDAC(a[1], a[34]); SQRADDAC(a[2], a[33]); SQRADDAC(a[3], a[32]); SQRADDAC(a[4], a[31]); SQRADDAC(a[5], a[30]); SQRADDAC(a[6], a[29]); SQRADDAC(a[7], a[28]); SQRADDAC(a[8], a[27]); SQRADDAC(a[9], a[26]); SQRADDAC(a[10], a[25]); SQRADDAC(a[11], a[24]); SQRADDAC(a[12], a[23]); SQRADDAC(a[13], a[22]); SQRADDAC(a[14], a[21]); SQRADDAC(a[15], a[20]); SQRADDAC(a[16], a[19]); SQRADDAC(a[17], a[18]); SQRADDDB; COMBA_STORE(b[35]); /* output 36 */ CARRY_FORWARD; SQRADDSC(a[0], a[36]); SQRADDAC(a[1], a[35]); SQRADDAC(a[2], a[34]); SQRADDAC(a[3], a[33]); SQRADDAC(a[4], a[32]); SQRADDAC(a[5], a[31]); SQRADDAC(a[6], a[30]); SQRADDAC(a[7], a[29]); SQRADDAC(a[8], a[28]); SQRADDAC(a[9], a[27]); SQRADDAC(a[10], a[26]); SQRADDAC(a[11], a[25]); SQRADDAC(a[12], a[24]); SQRADDAC(a[13], a[23]); SQRADDAC(a[14], a[22]); SQRADDAC(a[15], a[21]); SQRADDAC(a[16], a[20]); SQRADDAC(a[17], a[19]); SQRADDDB; SQRADD(a[18], a[18]); COMBA_STORE(b[36]); /* output 37 */ CARRY_FORWARD; SQRADDSC(a[0], a[37]); SQRADDAC(a[1], a[36]); SQRADDAC(a[2], a[35]); SQRADDAC(a[3], a[34]); SQRADDAC(a[4], a[33]); SQRADDAC(a[5], a[32]); SQRADDAC(a[6], a[31]); SQRADDAC(a[7], a[30]); SQRADDAC(a[8], a[29]); SQRADDAC(a[9], a[28]); SQRADDAC(a[10], a[27]); SQRADDAC(a[11], a[26]); SQRADDAC(a[12], a[25]); SQRADDAC(a[13], a[24]); SQRADDAC(a[14], a[23]); SQRADDAC(a[15], a[22]); SQRADDAC(a[16], a[21]); SQRADDAC(a[17], a[20]); SQRADDAC(a[18], a[19]); SQRADDDB; COMBA_STORE(b[37]); /* output 38 */ CARRY_FORWARD; SQRADDSC(a[0], a[38]); SQRADDAC(a[1], a[37]); SQRADDAC(a[2], a[36]); SQRADDAC(a[3], a[35]); SQRADDAC(a[4], a[34]); SQRADDAC(a[5], a[33]); SQRADDAC(a[6], a[32]); SQRADDAC(a[7], a[31]); SQRADDAC(a[8], a[30]); SQRADDAC(a[9], a[29]); SQRADDAC(a[10], a[28]); SQRADDAC(a[11], a[27]); SQRADDAC(a[12], a[26]); SQRADDAC(a[13], a[25]); SQRADDAC(a[14], a[24]); SQRADDAC(a[15], a[23]); SQRADDAC(a[16], a[22]); SQRADDAC(a[17], a[21]); SQRADDAC(a[18], a[20]); SQRADDDB; SQRADD(a[19], a[19]); COMBA_STORE(b[38]); /* output 39 */ CARRY_FORWARD; SQRADDSC(a[0], a[39]); SQRADDAC(a[1], a[38]); SQRADDAC(a[2], a[37]); SQRADDAC(a[3], a[36]); SQRADDAC(a[4], a[35]); SQRADDAC(a[5], a[34]); SQRADDAC(a[6], a[33]); SQRADDAC(a[7], a[32]); SQRADDAC(a[8], a[31]); SQRADDAC(a[9], a[30]); SQRADDAC(a[10], a[29]); SQRADDAC(a[11], a[28]); SQRADDAC(a[12], a[27]); SQRADDAC(a[13], a[26]); SQRADDAC(a[14], a[25]); SQRADDAC(a[15], a[24]); SQRADDAC(a[16], a[23]); SQRADDAC(a[17], a[22]); SQRADDAC(a[18], a[21]); SQRADDAC(a[19], a[20]); SQRADDDB; COMBA_STORE(b[39]); /* output 40 */ CARRY_FORWARD; SQRADDSC(a[0], a[40]); SQRADDAC(a[1], a[39]); SQRADDAC(a[2], a[38]); SQRADDAC(a[3], a[37]); SQRADDAC(a[4], a[36]); SQRADDAC(a[5], a[35]); SQRADDAC(a[6], a[34]); SQRADDAC(a[7], a[33]); SQRADDAC(a[8], a[32]); SQRADDAC(a[9], a[31]); SQRADDAC(a[10], a[30]); SQRADDAC(a[11], a[29]); SQRADDAC(a[12], a[28]); SQRADDAC(a[13], a[27]); SQRADDAC(a[14], a[26]); SQRADDAC(a[15], a[25]); SQRADDAC(a[16], a[24]); SQRADDAC(a[17], a[23]); SQRADDAC(a[18], a[22]); SQRADDAC(a[19], a[21]); SQRADDDB; SQRADD(a[20], a[20]); COMBA_STORE(b[40]); /* output 41 */ CARRY_FORWARD; SQRADDSC(a[0], a[41]); SQRADDAC(a[1], a[40]); SQRADDAC(a[2], a[39]); SQRADDAC(a[3], a[38]); SQRADDAC(a[4], a[37]); SQRADDAC(a[5], a[36]); SQRADDAC(a[6], a[35]); SQRADDAC(a[7], a[34]); SQRADDAC(a[8], a[33]); SQRADDAC(a[9], a[32]); SQRADDAC(a[10], a[31]); SQRADDAC(a[11], a[30]); SQRADDAC(a[12], a[29]); SQRADDAC(a[13], a[28]); SQRADDAC(a[14], a[27]); SQRADDAC(a[15], a[26]); SQRADDAC(a[16], a[25]); SQRADDAC(a[17], a[24]); SQRADDAC(a[18], a[23]); SQRADDAC(a[19], a[22]); SQRADDAC(a[20], a[21]); SQRADDDB; COMBA_STORE(b[41]); /* output 42 */ CARRY_FORWARD; SQRADDSC(a[0], a[42]); SQRADDAC(a[1], a[41]); SQRADDAC(a[2], a[40]); SQRADDAC(a[3], a[39]); SQRADDAC(a[4], a[38]); SQRADDAC(a[5], a[37]); SQRADDAC(a[6], a[36]); SQRADDAC(a[7], a[35]); SQRADDAC(a[8], a[34]); SQRADDAC(a[9], a[33]); SQRADDAC(a[10], a[32]); SQRADDAC(a[11], a[31]); SQRADDAC(a[12], a[30]); SQRADDAC(a[13], a[29]); SQRADDAC(a[14], a[28]); SQRADDAC(a[15], a[27]); SQRADDAC(a[16], a[26]); SQRADDAC(a[17], a[25]); SQRADDAC(a[18], a[24]); SQRADDAC(a[19], a[23]); SQRADDAC(a[20], a[22]); SQRADDDB; SQRADD(a[21], a[21]); COMBA_STORE(b[42]); /* output 43 */ CARRY_FORWARD; SQRADDSC(a[0], a[43]); SQRADDAC(a[1], a[42]); SQRADDAC(a[2], a[41]); SQRADDAC(a[3], a[40]); SQRADDAC(a[4], a[39]); SQRADDAC(a[5], a[38]); SQRADDAC(a[6], a[37]); SQRADDAC(a[7], a[36]); SQRADDAC(a[8], a[35]); SQRADDAC(a[9], a[34]); SQRADDAC(a[10], a[33]); SQRADDAC(a[11], a[32]); SQRADDAC(a[12], a[31]); SQRADDAC(a[13], a[30]); SQRADDAC(a[14], a[29]); SQRADDAC(a[15], a[28]); SQRADDAC(a[16], a[27]); SQRADDAC(a[17], a[26]); SQRADDAC(a[18], a[25]); SQRADDAC(a[19], a[24]); SQRADDAC(a[20], a[23]); SQRADDAC(a[21], a[22]); SQRADDDB; COMBA_STORE(b[43]); /* output 44 */ CARRY_FORWARD; SQRADDSC(a[0], a[44]); SQRADDAC(a[1], a[43]); SQRADDAC(a[2], a[42]); SQRADDAC(a[3], a[41]); SQRADDAC(a[4], a[40]); SQRADDAC(a[5], a[39]); SQRADDAC(a[6], a[38]); SQRADDAC(a[7], a[37]); SQRADDAC(a[8], a[36]); SQRADDAC(a[9], a[35]); SQRADDAC(a[10], a[34]); SQRADDAC(a[11], a[33]); SQRADDAC(a[12], a[32]); SQRADDAC(a[13], a[31]); SQRADDAC(a[14], a[30]); SQRADDAC(a[15], a[29]); SQRADDAC(a[16], a[28]); SQRADDAC(a[17], a[27]); SQRADDAC(a[18], a[26]); SQRADDAC(a[19], a[25]); SQRADDAC(a[20], a[24]); SQRADDAC(a[21], a[23]); SQRADDDB; SQRADD(a[22], a[22]); COMBA_STORE(b[44]); /* output 45 */ CARRY_FORWARD; SQRADDSC(a[0], a[45]); SQRADDAC(a[1], a[44]); SQRADDAC(a[2], a[43]); SQRADDAC(a[3], a[42]); SQRADDAC(a[4], a[41]); SQRADDAC(a[5], a[40]); SQRADDAC(a[6], a[39]); SQRADDAC(a[7], a[38]); SQRADDAC(a[8], a[37]); SQRADDAC(a[9], a[36]); SQRADDAC(a[10], a[35]); SQRADDAC(a[11], a[34]); SQRADDAC(a[12], a[33]); SQRADDAC(a[13], a[32]); SQRADDAC(a[14], a[31]); SQRADDAC(a[15], a[30]); SQRADDAC(a[16], a[29]); SQRADDAC(a[17], a[28]); SQRADDAC(a[18], a[27]); SQRADDAC(a[19], a[26]); SQRADDAC(a[20], a[25]); SQRADDAC(a[21], a[24]); SQRADDAC(a[22], a[23]); SQRADDDB; COMBA_STORE(b[45]); /* output 46 */ CARRY_FORWARD; SQRADDSC(a[0], a[46]); SQRADDAC(a[1], a[45]); SQRADDAC(a[2], a[44]); SQRADDAC(a[3], a[43]); SQRADDAC(a[4], a[42]); SQRADDAC(a[5], a[41]); SQRADDAC(a[6], a[40]); SQRADDAC(a[7], a[39]); SQRADDAC(a[8], a[38]); SQRADDAC(a[9], a[37]); SQRADDAC(a[10], a[36]); SQRADDAC(a[11], a[35]); SQRADDAC(a[12], a[34]); SQRADDAC(a[13], a[33]); SQRADDAC(a[14], a[32]); SQRADDAC(a[15], a[31]); SQRADDAC(a[16], a[30]); SQRADDAC(a[17], a[29]); SQRADDAC(a[18], a[28]); SQRADDAC(a[19], a[27]); SQRADDAC(a[20], a[26]); SQRADDAC(a[21], a[25]); SQRADDAC(a[22], a[24]); SQRADDDB; SQRADD(a[23], a[23]); COMBA_STORE(b[46]); /* output 47 */ CARRY_FORWARD; SQRADDSC(a[0], a[47]); SQRADDAC(a[1], a[46]); SQRADDAC(a[2], a[45]); SQRADDAC(a[3], a[44]); SQRADDAC(a[4], a[43]); SQRADDAC(a[5], a[42]); SQRADDAC(a[6], a[41]); SQRADDAC(a[7], a[40]); SQRADDAC(a[8], a[39]); SQRADDAC(a[9], a[38]); SQRADDAC(a[10], a[37]); SQRADDAC(a[11], a[36]); SQRADDAC(a[12], a[35]); SQRADDAC(a[13], a[34]); SQRADDAC(a[14], a[33]); SQRADDAC(a[15], a[32]); SQRADDAC(a[16], a[31]); SQRADDAC(a[17], a[30]); SQRADDAC(a[18], a[29]); SQRADDAC(a[19], a[28]); SQRADDAC(a[20], a[27]); SQRADDAC(a[21], a[26]); SQRADDAC(a[22], a[25]); SQRADDAC(a[23], a[24]); SQRADDDB; COMBA_STORE(b[47]); /* output 48 */ CARRY_FORWARD; SQRADDSC(a[0], a[48]); SQRADDAC(a[1], a[47]); SQRADDAC(a[2], a[46]); SQRADDAC(a[3], a[45]); SQRADDAC(a[4], a[44]); SQRADDAC(a[5], a[43]); SQRADDAC(a[6], a[42]); SQRADDAC(a[7], a[41]); SQRADDAC(a[8], a[40]); SQRADDAC(a[9], a[39]); SQRADDAC(a[10], a[38]); SQRADDAC(a[11], a[37]); SQRADDAC(a[12], a[36]); SQRADDAC(a[13], a[35]); SQRADDAC(a[14], a[34]); SQRADDAC(a[15], a[33]); SQRADDAC(a[16], a[32]); SQRADDAC(a[17], a[31]); SQRADDAC(a[18], a[30]); SQRADDAC(a[19], a[29]); SQRADDAC(a[20], a[28]); SQRADDAC(a[21], a[27]); SQRADDAC(a[22], a[26]); SQRADDAC(a[23], a[25]); SQRADDDB; SQRADD(a[24], a[24]); COMBA_STORE(b[48]); /* output 49 */ CARRY_FORWARD; SQRADDSC(a[0], a[49]); SQRADDAC(a[1], a[48]); SQRADDAC(a[2], a[47]); SQRADDAC(a[3], a[46]); SQRADDAC(a[4], a[45]); SQRADDAC(a[5], a[44]); SQRADDAC(a[6], a[43]); SQRADDAC(a[7], a[42]); SQRADDAC(a[8], a[41]); SQRADDAC(a[9], a[40]); SQRADDAC(a[10], a[39]); SQRADDAC(a[11], a[38]); SQRADDAC(a[12], a[37]); SQRADDAC(a[13], a[36]); SQRADDAC(a[14], a[35]); SQRADDAC(a[15], a[34]); SQRADDAC(a[16], a[33]); SQRADDAC(a[17], a[32]); SQRADDAC(a[18], a[31]); SQRADDAC(a[19], a[30]); SQRADDAC(a[20], a[29]); SQRADDAC(a[21], a[28]); SQRADDAC(a[22], a[27]); SQRADDAC(a[23], a[26]); SQRADDAC(a[24], a[25]); SQRADDDB; COMBA_STORE(b[49]); /* output 50 */ CARRY_FORWARD; SQRADDSC(a[0], a[50]); SQRADDAC(a[1], a[49]); SQRADDAC(a[2], a[48]); SQRADDAC(a[3], a[47]); SQRADDAC(a[4], a[46]); SQRADDAC(a[5], a[45]); SQRADDAC(a[6], a[44]); SQRADDAC(a[7], a[43]); SQRADDAC(a[8], a[42]); SQRADDAC(a[9], a[41]); SQRADDAC(a[10], a[40]); SQRADDAC(a[11], a[39]); SQRADDAC(a[12], a[38]); SQRADDAC(a[13], a[37]); SQRADDAC(a[14], a[36]); SQRADDAC(a[15], a[35]); SQRADDAC(a[16], a[34]); SQRADDAC(a[17], a[33]); SQRADDAC(a[18], a[32]); SQRADDAC(a[19], a[31]); SQRADDAC(a[20], a[30]); SQRADDAC(a[21], a[29]); SQRADDAC(a[22], a[28]); SQRADDAC(a[23], a[27]); SQRADDAC(a[24], a[26]); SQRADDDB; SQRADD(a[25], a[25]); COMBA_STORE(b[50]); /* output 51 */ CARRY_FORWARD; SQRADDSC(a[0], a[51]); SQRADDAC(a[1], a[50]); SQRADDAC(a[2], a[49]); SQRADDAC(a[3], a[48]); SQRADDAC(a[4], a[47]); SQRADDAC(a[5], a[46]); SQRADDAC(a[6], a[45]); SQRADDAC(a[7], a[44]); SQRADDAC(a[8], a[43]); SQRADDAC(a[9], a[42]); SQRADDAC(a[10], a[41]); SQRADDAC(a[11], a[40]); SQRADDAC(a[12], a[39]); SQRADDAC(a[13], a[38]); SQRADDAC(a[14], a[37]); SQRADDAC(a[15], a[36]); SQRADDAC(a[16], a[35]); SQRADDAC(a[17], a[34]); SQRADDAC(a[18], a[33]); SQRADDAC(a[19], a[32]); SQRADDAC(a[20], a[31]); SQRADDAC(a[21], a[30]); SQRADDAC(a[22], a[29]); SQRADDAC(a[23], a[28]); SQRADDAC(a[24], a[27]); SQRADDAC(a[25], a[26]); SQRADDDB; COMBA_STORE(b[51]); /* output 52 */ CARRY_FORWARD; SQRADDSC(a[0], a[52]); SQRADDAC(a[1], a[51]); SQRADDAC(a[2], a[50]); SQRADDAC(a[3], a[49]); SQRADDAC(a[4], a[48]); SQRADDAC(a[5], a[47]); SQRADDAC(a[6], a[46]); SQRADDAC(a[7], a[45]); SQRADDAC(a[8], a[44]); SQRADDAC(a[9], a[43]); SQRADDAC(a[10], a[42]); SQRADDAC(a[11], a[41]); SQRADDAC(a[12], a[40]); SQRADDAC(a[13], a[39]); SQRADDAC(a[14], a[38]); SQRADDAC(a[15], a[37]); SQRADDAC(a[16], a[36]); SQRADDAC(a[17], a[35]); SQRADDAC(a[18], a[34]); SQRADDAC(a[19], a[33]); SQRADDAC(a[20], a[32]); SQRADDAC(a[21], a[31]); SQRADDAC(a[22], a[30]); SQRADDAC(a[23], a[29]); SQRADDAC(a[24], a[28]); SQRADDAC(a[25], a[27]); SQRADDDB; SQRADD(a[26], a[26]); COMBA_STORE(b[52]); /* output 53 */ CARRY_FORWARD; SQRADDSC(a[0], a[53]); SQRADDAC(a[1], a[52]); SQRADDAC(a[2], a[51]); SQRADDAC(a[3], a[50]); SQRADDAC(a[4], a[49]); SQRADDAC(a[5], a[48]); SQRADDAC(a[6], a[47]); SQRADDAC(a[7], a[46]); SQRADDAC(a[8], a[45]); SQRADDAC(a[9], a[44]); SQRADDAC(a[10], a[43]); SQRADDAC(a[11], a[42]); SQRADDAC(a[12], a[41]); SQRADDAC(a[13], a[40]); SQRADDAC(a[14], a[39]); SQRADDAC(a[15], a[38]); SQRADDAC(a[16], a[37]); SQRADDAC(a[17], a[36]); SQRADDAC(a[18], a[35]); SQRADDAC(a[19], a[34]); SQRADDAC(a[20], a[33]); SQRADDAC(a[21], a[32]); SQRADDAC(a[22], a[31]); SQRADDAC(a[23], a[30]); SQRADDAC(a[24], a[29]); SQRADDAC(a[25], a[28]); SQRADDAC(a[26], a[27]); SQRADDDB; COMBA_STORE(b[53]); /* output 54 */ CARRY_FORWARD; SQRADDSC(a[0], a[54]); SQRADDAC(a[1], a[53]); SQRADDAC(a[2], a[52]); SQRADDAC(a[3], a[51]); SQRADDAC(a[4], a[50]); SQRADDAC(a[5], a[49]); SQRADDAC(a[6], a[48]); SQRADDAC(a[7], a[47]); SQRADDAC(a[8], a[46]); SQRADDAC(a[9], a[45]); SQRADDAC(a[10], a[44]); SQRADDAC(a[11], a[43]); SQRADDAC(a[12], a[42]); SQRADDAC(a[13], a[41]); SQRADDAC(a[14], a[40]); SQRADDAC(a[15], a[39]); SQRADDAC(a[16], a[38]); SQRADDAC(a[17], a[37]); SQRADDAC(a[18], a[36]); SQRADDAC(a[19], a[35]); SQRADDAC(a[20], a[34]); SQRADDAC(a[21], a[33]); SQRADDAC(a[22], a[32]); SQRADDAC(a[23], a[31]); SQRADDAC(a[24], a[30]); SQRADDAC(a[25], a[29]); SQRADDAC(a[26], a[28]); SQRADDDB; SQRADD(a[27], a[27]); COMBA_STORE(b[54]); /* output 55 */ CARRY_FORWARD; SQRADDSC(a[0], a[55]); SQRADDAC(a[1], a[54]); SQRADDAC(a[2], a[53]); SQRADDAC(a[3], a[52]); SQRADDAC(a[4], a[51]); SQRADDAC(a[5], a[50]); SQRADDAC(a[6], a[49]); SQRADDAC(a[7], a[48]); SQRADDAC(a[8], a[47]); SQRADDAC(a[9], a[46]); SQRADDAC(a[10], a[45]); SQRADDAC(a[11], a[44]); SQRADDAC(a[12], a[43]); SQRADDAC(a[13], a[42]); SQRADDAC(a[14], a[41]); SQRADDAC(a[15], a[40]); SQRADDAC(a[16], a[39]); SQRADDAC(a[17], a[38]); SQRADDAC(a[18], a[37]); SQRADDAC(a[19], a[36]); SQRADDAC(a[20], a[35]); SQRADDAC(a[21], a[34]); SQRADDAC(a[22], a[33]); SQRADDAC(a[23], a[32]); SQRADDAC(a[24], a[31]); SQRADDAC(a[25], a[30]); SQRADDAC(a[26], a[29]); SQRADDAC(a[27], a[28]); SQRADDDB; COMBA_STORE(b[55]); /* output 56 */ CARRY_FORWARD; SQRADDSC(a[0], a[56]); SQRADDAC(a[1], a[55]); SQRADDAC(a[2], a[54]); SQRADDAC(a[3], a[53]); SQRADDAC(a[4], a[52]); SQRADDAC(a[5], a[51]); SQRADDAC(a[6], a[50]); SQRADDAC(a[7], a[49]); SQRADDAC(a[8], a[48]); SQRADDAC(a[9], a[47]); SQRADDAC(a[10], a[46]); SQRADDAC(a[11], a[45]); SQRADDAC(a[12], a[44]); SQRADDAC(a[13], a[43]); SQRADDAC(a[14], a[42]); SQRADDAC(a[15], a[41]); SQRADDAC(a[16], a[40]); SQRADDAC(a[17], a[39]); SQRADDAC(a[18], a[38]); SQRADDAC(a[19], a[37]); SQRADDAC(a[20], a[36]); SQRADDAC(a[21], a[35]); SQRADDAC(a[22], a[34]); SQRADDAC(a[23], a[33]); SQRADDAC(a[24], a[32]); SQRADDAC(a[25], a[31]); SQRADDAC(a[26], a[30]); SQRADDAC(a[27], a[29]); SQRADDDB; SQRADD(a[28], a[28]); COMBA_STORE(b[56]); /* output 57 */ CARRY_FORWARD; SQRADDSC(a[0], a[57]); SQRADDAC(a[1], a[56]); SQRADDAC(a[2], a[55]); SQRADDAC(a[3], a[54]); SQRADDAC(a[4], a[53]); SQRADDAC(a[5], a[52]); SQRADDAC(a[6], a[51]); SQRADDAC(a[7], a[50]); SQRADDAC(a[8], a[49]); SQRADDAC(a[9], a[48]); SQRADDAC(a[10], a[47]); SQRADDAC(a[11], a[46]); SQRADDAC(a[12], a[45]); SQRADDAC(a[13], a[44]); SQRADDAC(a[14], a[43]); SQRADDAC(a[15], a[42]); SQRADDAC(a[16], a[41]); SQRADDAC(a[17], a[40]); SQRADDAC(a[18], a[39]); SQRADDAC(a[19], a[38]); SQRADDAC(a[20], a[37]); SQRADDAC(a[21], a[36]); SQRADDAC(a[22], a[35]); SQRADDAC(a[23], a[34]); SQRADDAC(a[24], a[33]); SQRADDAC(a[25], a[32]); SQRADDAC(a[26], a[31]); SQRADDAC(a[27], a[30]); SQRADDAC(a[28], a[29]); SQRADDDB; COMBA_STORE(b[57]); /* output 58 */ CARRY_FORWARD; SQRADDSC(a[0], a[58]); SQRADDAC(a[1], a[57]); SQRADDAC(a[2], a[56]); SQRADDAC(a[3], a[55]); SQRADDAC(a[4], a[54]); SQRADDAC(a[5], a[53]); SQRADDAC(a[6], a[52]); SQRADDAC(a[7], a[51]); SQRADDAC(a[8], a[50]); SQRADDAC(a[9], a[49]); SQRADDAC(a[10], a[48]); SQRADDAC(a[11], a[47]); SQRADDAC(a[12], a[46]); SQRADDAC(a[13], a[45]); SQRADDAC(a[14], a[44]); SQRADDAC(a[15], a[43]); SQRADDAC(a[16], a[42]); SQRADDAC(a[17], a[41]); SQRADDAC(a[18], a[40]); SQRADDAC(a[19], a[39]); SQRADDAC(a[20], a[38]); SQRADDAC(a[21], a[37]); SQRADDAC(a[22], a[36]); SQRADDAC(a[23], a[35]); SQRADDAC(a[24], a[34]); SQRADDAC(a[25], a[33]); SQRADDAC(a[26], a[32]); SQRADDAC(a[27], a[31]); SQRADDAC(a[28], a[30]); SQRADDDB; SQRADD(a[29], a[29]); COMBA_STORE(b[58]); /* output 59 */ CARRY_FORWARD; SQRADDSC(a[0], a[59]); SQRADDAC(a[1], a[58]); SQRADDAC(a[2], a[57]); SQRADDAC(a[3], a[56]); SQRADDAC(a[4], a[55]); SQRADDAC(a[5], a[54]); SQRADDAC(a[6], a[53]); SQRADDAC(a[7], a[52]); SQRADDAC(a[8], a[51]); SQRADDAC(a[9], a[50]); SQRADDAC(a[10], a[49]); SQRADDAC(a[11], a[48]); SQRADDAC(a[12], a[47]); SQRADDAC(a[13], a[46]); SQRADDAC(a[14], a[45]); SQRADDAC(a[15], a[44]); SQRADDAC(a[16], a[43]); SQRADDAC(a[17], a[42]); SQRADDAC(a[18], a[41]); SQRADDAC(a[19], a[40]); SQRADDAC(a[20], a[39]); SQRADDAC(a[21], a[38]); SQRADDAC(a[22], a[37]); SQRADDAC(a[23], a[36]); SQRADDAC(a[24], a[35]); SQRADDAC(a[25], a[34]); SQRADDAC(a[26], a[33]); SQRADDAC(a[27], a[32]); SQRADDAC(a[28], a[31]); SQRADDAC(a[29], a[30]); SQRADDDB; COMBA_STORE(b[59]); /* output 60 */ CARRY_FORWARD; SQRADDSC(a[0], a[60]); SQRADDAC(a[1], a[59]); SQRADDAC(a[2], a[58]); SQRADDAC(a[3], a[57]); SQRADDAC(a[4], a[56]); SQRADDAC(a[5], a[55]); SQRADDAC(a[6], a[54]); SQRADDAC(a[7], a[53]); SQRADDAC(a[8], a[52]); SQRADDAC(a[9], a[51]); SQRADDAC(a[10], a[50]); SQRADDAC(a[11], a[49]); SQRADDAC(a[12], a[48]); SQRADDAC(a[13], a[47]); SQRADDAC(a[14], a[46]); SQRADDAC(a[15], a[45]); SQRADDAC(a[16], a[44]); SQRADDAC(a[17], a[43]); SQRADDAC(a[18], a[42]); SQRADDAC(a[19], a[41]); SQRADDAC(a[20], a[40]); SQRADDAC(a[21], a[39]); SQRADDAC(a[22], a[38]); SQRADDAC(a[23], a[37]); SQRADDAC(a[24], a[36]); SQRADDAC(a[25], a[35]); SQRADDAC(a[26], a[34]); SQRADDAC(a[27], a[33]); SQRADDAC(a[28], a[32]); SQRADDAC(a[29], a[31]); SQRADDDB; SQRADD(a[30], a[30]); COMBA_STORE(b[60]); /* output 61 */ CARRY_FORWARD; SQRADDSC(a[0], a[61]); SQRADDAC(a[1], a[60]); SQRADDAC(a[2], a[59]); SQRADDAC(a[3], a[58]); SQRADDAC(a[4], a[57]); SQRADDAC(a[5], a[56]); SQRADDAC(a[6], a[55]); SQRADDAC(a[7], a[54]); SQRADDAC(a[8], a[53]); SQRADDAC(a[9], a[52]); SQRADDAC(a[10], a[51]); SQRADDAC(a[11], a[50]); SQRADDAC(a[12], a[49]); SQRADDAC(a[13], a[48]); SQRADDAC(a[14], a[47]); SQRADDAC(a[15], a[46]); SQRADDAC(a[16], a[45]); SQRADDAC(a[17], a[44]); SQRADDAC(a[18], a[43]); SQRADDAC(a[19], a[42]); SQRADDAC(a[20], a[41]); SQRADDAC(a[21], a[40]); SQRADDAC(a[22], a[39]); SQRADDAC(a[23], a[38]); SQRADDAC(a[24], a[37]); SQRADDAC(a[25], a[36]); SQRADDAC(a[26], a[35]); SQRADDAC(a[27], a[34]); SQRADDAC(a[28], a[33]); SQRADDAC(a[29], a[32]); SQRADDAC(a[30], a[31]); SQRADDDB; COMBA_STORE(b[61]); /* output 62 */ CARRY_FORWARD; SQRADDSC(a[0], a[62]); SQRADDAC(a[1], a[61]); SQRADDAC(a[2], a[60]); SQRADDAC(a[3], a[59]); SQRADDAC(a[4], a[58]); SQRADDAC(a[5], a[57]); SQRADDAC(a[6], a[56]); SQRADDAC(a[7], a[55]); SQRADDAC(a[8], a[54]); SQRADDAC(a[9], a[53]); SQRADDAC(a[10], a[52]); SQRADDAC(a[11], a[51]); SQRADDAC(a[12], a[50]); SQRADDAC(a[13], a[49]); SQRADDAC(a[14], a[48]); SQRADDAC(a[15], a[47]); SQRADDAC(a[16], a[46]); SQRADDAC(a[17], a[45]); SQRADDAC(a[18], a[44]); SQRADDAC(a[19], a[43]); SQRADDAC(a[20], a[42]); SQRADDAC(a[21], a[41]); SQRADDAC(a[22], a[40]); SQRADDAC(a[23], a[39]); SQRADDAC(a[24], a[38]); SQRADDAC(a[25], a[37]); SQRADDAC(a[26], a[36]); SQRADDAC(a[27], a[35]); SQRADDAC(a[28], a[34]); SQRADDAC(a[29], a[33]); SQRADDAC(a[30], a[32]); SQRADDDB; SQRADD(a[31], a[31]); COMBA_STORE(b[62]); /* output 63 */ CARRY_FORWARD; SQRADDSC(a[0], a[63]); SQRADDAC(a[1], a[62]); SQRADDAC(a[2], a[61]); SQRADDAC(a[3], a[60]); SQRADDAC(a[4], a[59]); SQRADDAC(a[5], a[58]); SQRADDAC(a[6], a[57]); SQRADDAC(a[7], a[56]); SQRADDAC(a[8], a[55]); SQRADDAC(a[9], a[54]); SQRADDAC(a[10], a[53]); SQRADDAC(a[11], a[52]); SQRADDAC(a[12], a[51]); SQRADDAC(a[13], a[50]); SQRADDAC(a[14], a[49]); SQRADDAC(a[15], a[48]); SQRADDAC(a[16], a[47]); SQRADDAC(a[17], a[46]); SQRADDAC(a[18], a[45]); SQRADDAC(a[19], a[44]); SQRADDAC(a[20], a[43]); SQRADDAC(a[21], a[42]); SQRADDAC(a[22], a[41]); SQRADDAC(a[23], a[40]); SQRADDAC(a[24], a[39]); SQRADDAC(a[25], a[38]); SQRADDAC(a[26], a[37]); SQRADDAC(a[27], a[36]); SQRADDAC(a[28], a[35]); SQRADDAC(a[29], a[34]); SQRADDAC(a[30], a[33]); SQRADDAC(a[31], a[32]); SQRADDDB; COMBA_STORE(b[63]); /* output 64 */ CARRY_FORWARD; SQRADDSC(a[1], a[63]); SQRADDAC(a[2], a[62]); SQRADDAC(a[3], a[61]); SQRADDAC(a[4], a[60]); SQRADDAC(a[5], a[59]); SQRADDAC(a[6], a[58]); SQRADDAC(a[7], a[57]); SQRADDAC(a[8], a[56]); SQRADDAC(a[9], a[55]); SQRADDAC(a[10], a[54]); SQRADDAC(a[11], a[53]); SQRADDAC(a[12], a[52]); SQRADDAC(a[13], a[51]); SQRADDAC(a[14], a[50]); SQRADDAC(a[15], a[49]); SQRADDAC(a[16], a[48]); SQRADDAC(a[17], a[47]); SQRADDAC(a[18], a[46]); SQRADDAC(a[19], a[45]); SQRADDAC(a[20], a[44]); SQRADDAC(a[21], a[43]); SQRADDAC(a[22], a[42]); SQRADDAC(a[23], a[41]); SQRADDAC(a[24], a[40]); SQRADDAC(a[25], a[39]); SQRADDAC(a[26], a[38]); SQRADDAC(a[27], a[37]); SQRADDAC(a[28], a[36]); SQRADDAC(a[29], a[35]); SQRADDAC(a[30], a[34]); SQRADDAC(a[31], a[33]); SQRADDDB; SQRADD(a[32], a[32]); COMBA_STORE(b[64]); /* output 65 */ CARRY_FORWARD; SQRADDSC(a[2], a[63]); SQRADDAC(a[3], a[62]); SQRADDAC(a[4], a[61]); SQRADDAC(a[5], a[60]); SQRADDAC(a[6], a[59]); SQRADDAC(a[7], a[58]); SQRADDAC(a[8], a[57]); SQRADDAC(a[9], a[56]); SQRADDAC(a[10], a[55]); SQRADDAC(a[11], a[54]); SQRADDAC(a[12], a[53]); SQRADDAC(a[13], a[52]); SQRADDAC(a[14], a[51]); SQRADDAC(a[15], a[50]); SQRADDAC(a[16], a[49]); SQRADDAC(a[17], a[48]); SQRADDAC(a[18], a[47]); SQRADDAC(a[19], a[46]); SQRADDAC(a[20], a[45]); SQRADDAC(a[21], a[44]); SQRADDAC(a[22], a[43]); SQRADDAC(a[23], a[42]); SQRADDAC(a[24], a[41]); SQRADDAC(a[25], a[40]); SQRADDAC(a[26], a[39]); SQRADDAC(a[27], a[38]); SQRADDAC(a[28], a[37]); SQRADDAC(a[29], a[36]); SQRADDAC(a[30], a[35]); SQRADDAC(a[31], a[34]); SQRADDAC(a[32], a[33]); SQRADDDB; COMBA_STORE(b[65]); /* output 66 */ CARRY_FORWARD; SQRADDSC(a[3], a[63]); SQRADDAC(a[4], a[62]); SQRADDAC(a[5], a[61]); SQRADDAC(a[6], a[60]); SQRADDAC(a[7], a[59]); SQRADDAC(a[8], a[58]); SQRADDAC(a[9], a[57]); SQRADDAC(a[10], a[56]); SQRADDAC(a[11], a[55]); SQRADDAC(a[12], a[54]); SQRADDAC(a[13], a[53]); SQRADDAC(a[14], a[52]); SQRADDAC(a[15], a[51]); SQRADDAC(a[16], a[50]); SQRADDAC(a[17], a[49]); SQRADDAC(a[18], a[48]); SQRADDAC(a[19], a[47]); SQRADDAC(a[20], a[46]); SQRADDAC(a[21], a[45]); SQRADDAC(a[22], a[44]); SQRADDAC(a[23], a[43]); SQRADDAC(a[24], a[42]); SQRADDAC(a[25], a[41]); SQRADDAC(a[26], a[40]); SQRADDAC(a[27], a[39]); SQRADDAC(a[28], a[38]); SQRADDAC(a[29], a[37]); SQRADDAC(a[30], a[36]); SQRADDAC(a[31], a[35]); SQRADDAC(a[32], a[34]); SQRADDDB; SQRADD(a[33], a[33]); COMBA_STORE(b[66]); /* output 67 */ CARRY_FORWARD; SQRADDSC(a[4], a[63]); SQRADDAC(a[5], a[62]); SQRADDAC(a[6], a[61]); SQRADDAC(a[7], a[60]); SQRADDAC(a[8], a[59]); SQRADDAC(a[9], a[58]); SQRADDAC(a[10], a[57]); SQRADDAC(a[11], a[56]); SQRADDAC(a[12], a[55]); SQRADDAC(a[13], a[54]); SQRADDAC(a[14], a[53]); SQRADDAC(a[15], a[52]); SQRADDAC(a[16], a[51]); SQRADDAC(a[17], a[50]); SQRADDAC(a[18], a[49]); SQRADDAC(a[19], a[48]); SQRADDAC(a[20], a[47]); SQRADDAC(a[21], a[46]); SQRADDAC(a[22], a[45]); SQRADDAC(a[23], a[44]); SQRADDAC(a[24], a[43]); SQRADDAC(a[25], a[42]); SQRADDAC(a[26], a[41]); SQRADDAC(a[27], a[40]); SQRADDAC(a[28], a[39]); SQRADDAC(a[29], a[38]); SQRADDAC(a[30], a[37]); SQRADDAC(a[31], a[36]); SQRADDAC(a[32], a[35]); SQRADDAC(a[33], a[34]); SQRADDDB; COMBA_STORE(b[67]); /* output 68 */ CARRY_FORWARD; SQRADDSC(a[5], a[63]); SQRADDAC(a[6], a[62]); SQRADDAC(a[7], a[61]); SQRADDAC(a[8], a[60]); SQRADDAC(a[9], a[59]); SQRADDAC(a[10], a[58]); SQRADDAC(a[11], a[57]); SQRADDAC(a[12], a[56]); SQRADDAC(a[13], a[55]); SQRADDAC(a[14], a[54]); SQRADDAC(a[15], a[53]); SQRADDAC(a[16], a[52]); SQRADDAC(a[17], a[51]); SQRADDAC(a[18], a[50]); SQRADDAC(a[19], a[49]); SQRADDAC(a[20], a[48]); SQRADDAC(a[21], a[47]); SQRADDAC(a[22], a[46]); SQRADDAC(a[23], a[45]); SQRADDAC(a[24], a[44]); SQRADDAC(a[25], a[43]); SQRADDAC(a[26], a[42]); SQRADDAC(a[27], a[41]); SQRADDAC(a[28], a[40]); SQRADDAC(a[29], a[39]); SQRADDAC(a[30], a[38]); SQRADDAC(a[31], a[37]); SQRADDAC(a[32], a[36]); SQRADDAC(a[33], a[35]); SQRADDDB; SQRADD(a[34], a[34]); COMBA_STORE(b[68]); /* output 69 */ CARRY_FORWARD; SQRADDSC(a[6], a[63]); SQRADDAC(a[7], a[62]); SQRADDAC(a[8], a[61]); SQRADDAC(a[9], a[60]); SQRADDAC(a[10], a[59]); SQRADDAC(a[11], a[58]); SQRADDAC(a[12], a[57]); SQRADDAC(a[13], a[56]); SQRADDAC(a[14], a[55]); SQRADDAC(a[15], a[54]); SQRADDAC(a[16], a[53]); SQRADDAC(a[17], a[52]); SQRADDAC(a[18], a[51]); SQRADDAC(a[19], a[50]); SQRADDAC(a[20], a[49]); SQRADDAC(a[21], a[48]); SQRADDAC(a[22], a[47]); SQRADDAC(a[23], a[46]); SQRADDAC(a[24], a[45]); SQRADDAC(a[25], a[44]); SQRADDAC(a[26], a[43]); SQRADDAC(a[27], a[42]); SQRADDAC(a[28], a[41]); SQRADDAC(a[29], a[40]); SQRADDAC(a[30], a[39]); SQRADDAC(a[31], a[38]); SQRADDAC(a[32], a[37]); SQRADDAC(a[33], a[36]); SQRADDAC(a[34], a[35]); SQRADDDB; COMBA_STORE(b[69]); /* output 70 */ CARRY_FORWARD; SQRADDSC(a[7], a[63]); SQRADDAC(a[8], a[62]); SQRADDAC(a[9], a[61]); SQRADDAC(a[10], a[60]); SQRADDAC(a[11], a[59]); SQRADDAC(a[12], a[58]); SQRADDAC(a[13], a[57]); SQRADDAC(a[14], a[56]); SQRADDAC(a[15], a[55]); SQRADDAC(a[16], a[54]); SQRADDAC(a[17], a[53]); SQRADDAC(a[18], a[52]); SQRADDAC(a[19], a[51]); SQRADDAC(a[20], a[50]); SQRADDAC(a[21], a[49]); SQRADDAC(a[22], a[48]); SQRADDAC(a[23], a[47]); SQRADDAC(a[24], a[46]); SQRADDAC(a[25], a[45]); SQRADDAC(a[26], a[44]); SQRADDAC(a[27], a[43]); SQRADDAC(a[28], a[42]); SQRADDAC(a[29], a[41]); SQRADDAC(a[30], a[40]); SQRADDAC(a[31], a[39]); SQRADDAC(a[32], a[38]); SQRADDAC(a[33], a[37]); SQRADDAC(a[34], a[36]); SQRADDDB; SQRADD(a[35], a[35]); COMBA_STORE(b[70]); /* output 71 */ CARRY_FORWARD; SQRADDSC(a[8], a[63]); SQRADDAC(a[9], a[62]); SQRADDAC(a[10], a[61]); SQRADDAC(a[11], a[60]); SQRADDAC(a[12], a[59]); SQRADDAC(a[13], a[58]); SQRADDAC(a[14], a[57]); SQRADDAC(a[15], a[56]); SQRADDAC(a[16], a[55]); SQRADDAC(a[17], a[54]); SQRADDAC(a[18], a[53]); SQRADDAC(a[19], a[52]); SQRADDAC(a[20], a[51]); SQRADDAC(a[21], a[50]); SQRADDAC(a[22], a[49]); SQRADDAC(a[23], a[48]); SQRADDAC(a[24], a[47]); SQRADDAC(a[25], a[46]); SQRADDAC(a[26], a[45]); SQRADDAC(a[27], a[44]); SQRADDAC(a[28], a[43]); SQRADDAC(a[29], a[42]); SQRADDAC(a[30], a[41]); SQRADDAC(a[31], a[40]); SQRADDAC(a[32], a[39]); SQRADDAC(a[33], a[38]); SQRADDAC(a[34], a[37]); SQRADDAC(a[35], a[36]); SQRADDDB; COMBA_STORE(b[71]); /* output 72 */ CARRY_FORWARD; SQRADDSC(a[9], a[63]); SQRADDAC(a[10], a[62]); SQRADDAC(a[11], a[61]); SQRADDAC(a[12], a[60]); SQRADDAC(a[13], a[59]); SQRADDAC(a[14], a[58]); SQRADDAC(a[15], a[57]); SQRADDAC(a[16], a[56]); SQRADDAC(a[17], a[55]); SQRADDAC(a[18], a[54]); SQRADDAC(a[19], a[53]); SQRADDAC(a[20], a[52]); SQRADDAC(a[21], a[51]); SQRADDAC(a[22], a[50]); SQRADDAC(a[23], a[49]); SQRADDAC(a[24], a[48]); SQRADDAC(a[25], a[47]); SQRADDAC(a[26], a[46]); SQRADDAC(a[27], a[45]); SQRADDAC(a[28], a[44]); SQRADDAC(a[29], a[43]); SQRADDAC(a[30], a[42]); SQRADDAC(a[31], a[41]); SQRADDAC(a[32], a[40]); SQRADDAC(a[33], a[39]); SQRADDAC(a[34], a[38]); SQRADDAC(a[35], a[37]); SQRADDDB; SQRADD(a[36], a[36]); COMBA_STORE(b[72]); /* output 73 */ CARRY_FORWARD; SQRADDSC(a[10], a[63]); SQRADDAC(a[11], a[62]); SQRADDAC(a[12], a[61]); SQRADDAC(a[13], a[60]); SQRADDAC(a[14], a[59]); SQRADDAC(a[15], a[58]); SQRADDAC(a[16], a[57]); SQRADDAC(a[17], a[56]); SQRADDAC(a[18], a[55]); SQRADDAC(a[19], a[54]); SQRADDAC(a[20], a[53]); SQRADDAC(a[21], a[52]); SQRADDAC(a[22], a[51]); SQRADDAC(a[23], a[50]); SQRADDAC(a[24], a[49]); SQRADDAC(a[25], a[48]); SQRADDAC(a[26], a[47]); SQRADDAC(a[27], a[46]); SQRADDAC(a[28], a[45]); SQRADDAC(a[29], a[44]); SQRADDAC(a[30], a[43]); SQRADDAC(a[31], a[42]); SQRADDAC(a[32], a[41]); SQRADDAC(a[33], a[40]); SQRADDAC(a[34], a[39]); SQRADDAC(a[35], a[38]); SQRADDAC(a[36], a[37]); SQRADDDB; COMBA_STORE(b[73]); /* output 74 */ CARRY_FORWARD; SQRADDSC(a[11], a[63]); SQRADDAC(a[12], a[62]); SQRADDAC(a[13], a[61]); SQRADDAC(a[14], a[60]); SQRADDAC(a[15], a[59]); SQRADDAC(a[16], a[58]); SQRADDAC(a[17], a[57]); SQRADDAC(a[18], a[56]); SQRADDAC(a[19], a[55]); SQRADDAC(a[20], a[54]); SQRADDAC(a[21], a[53]); SQRADDAC(a[22], a[52]); SQRADDAC(a[23], a[51]); SQRADDAC(a[24], a[50]); SQRADDAC(a[25], a[49]); SQRADDAC(a[26], a[48]); SQRADDAC(a[27], a[47]); SQRADDAC(a[28], a[46]); SQRADDAC(a[29], a[45]); SQRADDAC(a[30], a[44]); SQRADDAC(a[31], a[43]); SQRADDAC(a[32], a[42]); SQRADDAC(a[33], a[41]); SQRADDAC(a[34], a[40]); SQRADDAC(a[35], a[39]); SQRADDAC(a[36], a[38]); SQRADDDB; SQRADD(a[37], a[37]); COMBA_STORE(b[74]); /* output 75 */ CARRY_FORWARD; SQRADDSC(a[12], a[63]); SQRADDAC(a[13], a[62]); SQRADDAC(a[14], a[61]); SQRADDAC(a[15], a[60]); SQRADDAC(a[16], a[59]); SQRADDAC(a[17], a[58]); SQRADDAC(a[18], a[57]); SQRADDAC(a[19], a[56]); SQRADDAC(a[20], a[55]); SQRADDAC(a[21], a[54]); SQRADDAC(a[22], a[53]); SQRADDAC(a[23], a[52]); SQRADDAC(a[24], a[51]); SQRADDAC(a[25], a[50]); SQRADDAC(a[26], a[49]); SQRADDAC(a[27], a[48]); SQRADDAC(a[28], a[47]); SQRADDAC(a[29], a[46]); SQRADDAC(a[30], a[45]); SQRADDAC(a[31], a[44]); SQRADDAC(a[32], a[43]); SQRADDAC(a[33], a[42]); SQRADDAC(a[34], a[41]); SQRADDAC(a[35], a[40]); SQRADDAC(a[36], a[39]); SQRADDAC(a[37], a[38]); SQRADDDB; COMBA_STORE(b[75]); /* output 76 */ CARRY_FORWARD; SQRADDSC(a[13], a[63]); SQRADDAC(a[14], a[62]); SQRADDAC(a[15], a[61]); SQRADDAC(a[16], a[60]); SQRADDAC(a[17], a[59]); SQRADDAC(a[18], a[58]); SQRADDAC(a[19], a[57]); SQRADDAC(a[20], a[56]); SQRADDAC(a[21], a[55]); SQRADDAC(a[22], a[54]); SQRADDAC(a[23], a[53]); SQRADDAC(a[24], a[52]); SQRADDAC(a[25], a[51]); SQRADDAC(a[26], a[50]); SQRADDAC(a[27], a[49]); SQRADDAC(a[28], a[48]); SQRADDAC(a[29], a[47]); SQRADDAC(a[30], a[46]); SQRADDAC(a[31], a[45]); SQRADDAC(a[32], a[44]); SQRADDAC(a[33], a[43]); SQRADDAC(a[34], a[42]); SQRADDAC(a[35], a[41]); SQRADDAC(a[36], a[40]); SQRADDAC(a[37], a[39]); SQRADDDB; SQRADD(a[38], a[38]); COMBA_STORE(b[76]); /* output 77 */ CARRY_FORWARD; SQRADDSC(a[14], a[63]); SQRADDAC(a[15], a[62]); SQRADDAC(a[16], a[61]); SQRADDAC(a[17], a[60]); SQRADDAC(a[18], a[59]); SQRADDAC(a[19], a[58]); SQRADDAC(a[20], a[57]); SQRADDAC(a[21], a[56]); SQRADDAC(a[22], a[55]); SQRADDAC(a[23], a[54]); SQRADDAC(a[24], a[53]); SQRADDAC(a[25], a[52]); SQRADDAC(a[26], a[51]); SQRADDAC(a[27], a[50]); SQRADDAC(a[28], a[49]); SQRADDAC(a[29], a[48]); SQRADDAC(a[30], a[47]); SQRADDAC(a[31], a[46]); SQRADDAC(a[32], a[45]); SQRADDAC(a[33], a[44]); SQRADDAC(a[34], a[43]); SQRADDAC(a[35], a[42]); SQRADDAC(a[36], a[41]); SQRADDAC(a[37], a[40]); SQRADDAC(a[38], a[39]); SQRADDDB; COMBA_STORE(b[77]); /* output 78 */ CARRY_FORWARD; SQRADDSC(a[15], a[63]); SQRADDAC(a[16], a[62]); SQRADDAC(a[17], a[61]); SQRADDAC(a[18], a[60]); SQRADDAC(a[19], a[59]); SQRADDAC(a[20], a[58]); SQRADDAC(a[21], a[57]); SQRADDAC(a[22], a[56]); SQRADDAC(a[23], a[55]); SQRADDAC(a[24], a[54]); SQRADDAC(a[25], a[53]); SQRADDAC(a[26], a[52]); SQRADDAC(a[27], a[51]); SQRADDAC(a[28], a[50]); SQRADDAC(a[29], a[49]); SQRADDAC(a[30], a[48]); SQRADDAC(a[31], a[47]); SQRADDAC(a[32], a[46]); SQRADDAC(a[33], a[45]); SQRADDAC(a[34], a[44]); SQRADDAC(a[35], a[43]); SQRADDAC(a[36], a[42]); SQRADDAC(a[37], a[41]); SQRADDAC(a[38], a[40]); SQRADDDB; SQRADD(a[39], a[39]); COMBA_STORE(b[78]); /* output 79 */ CARRY_FORWARD; SQRADDSC(a[16], a[63]); SQRADDAC(a[17], a[62]); SQRADDAC(a[18], a[61]); SQRADDAC(a[19], a[60]); SQRADDAC(a[20], a[59]); SQRADDAC(a[21], a[58]); SQRADDAC(a[22], a[57]); SQRADDAC(a[23], a[56]); SQRADDAC(a[24], a[55]); SQRADDAC(a[25], a[54]); SQRADDAC(a[26], a[53]); SQRADDAC(a[27], a[52]); SQRADDAC(a[28], a[51]); SQRADDAC(a[29], a[50]); SQRADDAC(a[30], a[49]); SQRADDAC(a[31], a[48]); SQRADDAC(a[32], a[47]); SQRADDAC(a[33], a[46]); SQRADDAC(a[34], a[45]); SQRADDAC(a[35], a[44]); SQRADDAC(a[36], a[43]); SQRADDAC(a[37], a[42]); SQRADDAC(a[38], a[41]); SQRADDAC(a[39], a[40]); SQRADDDB; COMBA_STORE(b[79]); /* output 80 */ CARRY_FORWARD; SQRADDSC(a[17], a[63]); SQRADDAC(a[18], a[62]); SQRADDAC(a[19], a[61]); SQRADDAC(a[20], a[60]); SQRADDAC(a[21], a[59]); SQRADDAC(a[22], a[58]); SQRADDAC(a[23], a[57]); SQRADDAC(a[24], a[56]); SQRADDAC(a[25], a[55]); SQRADDAC(a[26], a[54]); SQRADDAC(a[27], a[53]); SQRADDAC(a[28], a[52]); SQRADDAC(a[29], a[51]); SQRADDAC(a[30], a[50]); SQRADDAC(a[31], a[49]); SQRADDAC(a[32], a[48]); SQRADDAC(a[33], a[47]); SQRADDAC(a[34], a[46]); SQRADDAC(a[35], a[45]); SQRADDAC(a[36], a[44]); SQRADDAC(a[37], a[43]); SQRADDAC(a[38], a[42]); SQRADDAC(a[39], a[41]); SQRADDDB; SQRADD(a[40], a[40]); COMBA_STORE(b[80]); /* output 81 */ CARRY_FORWARD; SQRADDSC(a[18], a[63]); SQRADDAC(a[19], a[62]); SQRADDAC(a[20], a[61]); SQRADDAC(a[21], a[60]); SQRADDAC(a[22], a[59]); SQRADDAC(a[23], a[58]); SQRADDAC(a[24], a[57]); SQRADDAC(a[25], a[56]); SQRADDAC(a[26], a[55]); SQRADDAC(a[27], a[54]); SQRADDAC(a[28], a[53]); SQRADDAC(a[29], a[52]); SQRADDAC(a[30], a[51]); SQRADDAC(a[31], a[50]); SQRADDAC(a[32], a[49]); SQRADDAC(a[33], a[48]); SQRADDAC(a[34], a[47]); SQRADDAC(a[35], a[46]); SQRADDAC(a[36], a[45]); SQRADDAC(a[37], a[44]); SQRADDAC(a[38], a[43]); SQRADDAC(a[39], a[42]); SQRADDAC(a[40], a[41]); SQRADDDB; COMBA_STORE(b[81]); /* output 82 */ CARRY_FORWARD; SQRADDSC(a[19], a[63]); SQRADDAC(a[20], a[62]); SQRADDAC(a[21], a[61]); SQRADDAC(a[22], a[60]); SQRADDAC(a[23], a[59]); SQRADDAC(a[24], a[58]); SQRADDAC(a[25], a[57]); SQRADDAC(a[26], a[56]); SQRADDAC(a[27], a[55]); SQRADDAC(a[28], a[54]); SQRADDAC(a[29], a[53]); SQRADDAC(a[30], a[52]); SQRADDAC(a[31], a[51]); SQRADDAC(a[32], a[50]); SQRADDAC(a[33], a[49]); SQRADDAC(a[34], a[48]); SQRADDAC(a[35], a[47]); SQRADDAC(a[36], a[46]); SQRADDAC(a[37], a[45]); SQRADDAC(a[38], a[44]); SQRADDAC(a[39], a[43]); SQRADDAC(a[40], a[42]); SQRADDDB; SQRADD(a[41], a[41]); COMBA_STORE(b[82]); /* output 83 */ CARRY_FORWARD; SQRADDSC(a[20], a[63]); SQRADDAC(a[21], a[62]); SQRADDAC(a[22], a[61]); SQRADDAC(a[23], a[60]); SQRADDAC(a[24], a[59]); SQRADDAC(a[25], a[58]); SQRADDAC(a[26], a[57]); SQRADDAC(a[27], a[56]); SQRADDAC(a[28], a[55]); SQRADDAC(a[29], a[54]); SQRADDAC(a[30], a[53]); SQRADDAC(a[31], a[52]); SQRADDAC(a[32], a[51]); SQRADDAC(a[33], a[50]); SQRADDAC(a[34], a[49]); SQRADDAC(a[35], a[48]); SQRADDAC(a[36], a[47]); SQRADDAC(a[37], a[46]); SQRADDAC(a[38], a[45]); SQRADDAC(a[39], a[44]); SQRADDAC(a[40], a[43]); SQRADDAC(a[41], a[42]); SQRADDDB; COMBA_STORE(b[83]); /* output 84 */ CARRY_FORWARD; SQRADDSC(a[21], a[63]); SQRADDAC(a[22], a[62]); SQRADDAC(a[23], a[61]); SQRADDAC(a[24], a[60]); SQRADDAC(a[25], a[59]); SQRADDAC(a[26], a[58]); SQRADDAC(a[27], a[57]); SQRADDAC(a[28], a[56]); SQRADDAC(a[29], a[55]); SQRADDAC(a[30], a[54]); SQRADDAC(a[31], a[53]); SQRADDAC(a[32], a[52]); SQRADDAC(a[33], a[51]); SQRADDAC(a[34], a[50]); SQRADDAC(a[35], a[49]); SQRADDAC(a[36], a[48]); SQRADDAC(a[37], a[47]); SQRADDAC(a[38], a[46]); SQRADDAC(a[39], a[45]); SQRADDAC(a[40], a[44]); SQRADDAC(a[41], a[43]); SQRADDDB; SQRADD(a[42], a[42]); COMBA_STORE(b[84]); /* output 85 */ CARRY_FORWARD; SQRADDSC(a[22], a[63]); SQRADDAC(a[23], a[62]); SQRADDAC(a[24], a[61]); SQRADDAC(a[25], a[60]); SQRADDAC(a[26], a[59]); SQRADDAC(a[27], a[58]); SQRADDAC(a[28], a[57]); SQRADDAC(a[29], a[56]); SQRADDAC(a[30], a[55]); SQRADDAC(a[31], a[54]); SQRADDAC(a[32], a[53]); SQRADDAC(a[33], a[52]); SQRADDAC(a[34], a[51]); SQRADDAC(a[35], a[50]); SQRADDAC(a[36], a[49]); SQRADDAC(a[37], a[48]); SQRADDAC(a[38], a[47]); SQRADDAC(a[39], a[46]); SQRADDAC(a[40], a[45]); SQRADDAC(a[41], a[44]); SQRADDAC(a[42], a[43]); SQRADDDB; COMBA_STORE(b[85]); /* output 86 */ CARRY_FORWARD; SQRADDSC(a[23], a[63]); SQRADDAC(a[24], a[62]); SQRADDAC(a[25], a[61]); SQRADDAC(a[26], a[60]); SQRADDAC(a[27], a[59]); SQRADDAC(a[28], a[58]); SQRADDAC(a[29], a[57]); SQRADDAC(a[30], a[56]); SQRADDAC(a[31], a[55]); SQRADDAC(a[32], a[54]); SQRADDAC(a[33], a[53]); SQRADDAC(a[34], a[52]); SQRADDAC(a[35], a[51]); SQRADDAC(a[36], a[50]); SQRADDAC(a[37], a[49]); SQRADDAC(a[38], a[48]); SQRADDAC(a[39], a[47]); SQRADDAC(a[40], a[46]); SQRADDAC(a[41], a[45]); SQRADDAC(a[42], a[44]); SQRADDDB; SQRADD(a[43], a[43]); COMBA_STORE(b[86]); /* output 87 */ CARRY_FORWARD; SQRADDSC(a[24], a[63]); SQRADDAC(a[25], a[62]); SQRADDAC(a[26], a[61]); SQRADDAC(a[27], a[60]); SQRADDAC(a[28], a[59]); SQRADDAC(a[29], a[58]); SQRADDAC(a[30], a[57]); SQRADDAC(a[31], a[56]); SQRADDAC(a[32], a[55]); SQRADDAC(a[33], a[54]); SQRADDAC(a[34], a[53]); SQRADDAC(a[35], a[52]); SQRADDAC(a[36], a[51]); SQRADDAC(a[37], a[50]); SQRADDAC(a[38], a[49]); SQRADDAC(a[39], a[48]); SQRADDAC(a[40], a[47]); SQRADDAC(a[41], a[46]); SQRADDAC(a[42], a[45]); SQRADDAC(a[43], a[44]); SQRADDDB; COMBA_STORE(b[87]); /* output 88 */ CARRY_FORWARD; SQRADDSC(a[25], a[63]); SQRADDAC(a[26], a[62]); SQRADDAC(a[27], a[61]); SQRADDAC(a[28], a[60]); SQRADDAC(a[29], a[59]); SQRADDAC(a[30], a[58]); SQRADDAC(a[31], a[57]); SQRADDAC(a[32], a[56]); SQRADDAC(a[33], a[55]); SQRADDAC(a[34], a[54]); SQRADDAC(a[35], a[53]); SQRADDAC(a[36], a[52]); SQRADDAC(a[37], a[51]); SQRADDAC(a[38], a[50]); SQRADDAC(a[39], a[49]); SQRADDAC(a[40], a[48]); SQRADDAC(a[41], a[47]); SQRADDAC(a[42], a[46]); SQRADDAC(a[43], a[45]); SQRADDDB; SQRADD(a[44], a[44]); COMBA_STORE(b[88]); /* output 89 */ CARRY_FORWARD; SQRADDSC(a[26], a[63]); SQRADDAC(a[27], a[62]); SQRADDAC(a[28], a[61]); SQRADDAC(a[29], a[60]); SQRADDAC(a[30], a[59]); SQRADDAC(a[31], a[58]); SQRADDAC(a[32], a[57]); SQRADDAC(a[33], a[56]); SQRADDAC(a[34], a[55]); SQRADDAC(a[35], a[54]); SQRADDAC(a[36], a[53]); SQRADDAC(a[37], a[52]); SQRADDAC(a[38], a[51]); SQRADDAC(a[39], a[50]); SQRADDAC(a[40], a[49]); SQRADDAC(a[41], a[48]); SQRADDAC(a[42], a[47]); SQRADDAC(a[43], a[46]); SQRADDAC(a[44], a[45]); SQRADDDB; COMBA_STORE(b[89]); /* output 90 */ CARRY_FORWARD; SQRADDSC(a[27], a[63]); SQRADDAC(a[28], a[62]); SQRADDAC(a[29], a[61]); SQRADDAC(a[30], a[60]); SQRADDAC(a[31], a[59]); SQRADDAC(a[32], a[58]); SQRADDAC(a[33], a[57]); SQRADDAC(a[34], a[56]); SQRADDAC(a[35], a[55]); SQRADDAC(a[36], a[54]); SQRADDAC(a[37], a[53]); SQRADDAC(a[38], a[52]); SQRADDAC(a[39], a[51]); SQRADDAC(a[40], a[50]); SQRADDAC(a[41], a[49]); SQRADDAC(a[42], a[48]); SQRADDAC(a[43], a[47]); SQRADDAC(a[44], a[46]); SQRADDDB; SQRADD(a[45], a[45]); COMBA_STORE(b[90]); /* output 91 */ CARRY_FORWARD; SQRADDSC(a[28], a[63]); SQRADDAC(a[29], a[62]); SQRADDAC(a[30], a[61]); SQRADDAC(a[31], a[60]); SQRADDAC(a[32], a[59]); SQRADDAC(a[33], a[58]); SQRADDAC(a[34], a[57]); SQRADDAC(a[35], a[56]); SQRADDAC(a[36], a[55]); SQRADDAC(a[37], a[54]); SQRADDAC(a[38], a[53]); SQRADDAC(a[39], a[52]); SQRADDAC(a[40], a[51]); SQRADDAC(a[41], a[50]); SQRADDAC(a[42], a[49]); SQRADDAC(a[43], a[48]); SQRADDAC(a[44], a[47]); SQRADDAC(a[45], a[46]); SQRADDDB; COMBA_STORE(b[91]); /* output 92 */ CARRY_FORWARD; SQRADDSC(a[29], a[63]); SQRADDAC(a[30], a[62]); SQRADDAC(a[31], a[61]); SQRADDAC(a[32], a[60]); SQRADDAC(a[33], a[59]); SQRADDAC(a[34], a[58]); SQRADDAC(a[35], a[57]); SQRADDAC(a[36], a[56]); SQRADDAC(a[37], a[55]); SQRADDAC(a[38], a[54]); SQRADDAC(a[39], a[53]); SQRADDAC(a[40], a[52]); SQRADDAC(a[41], a[51]); SQRADDAC(a[42], a[50]); SQRADDAC(a[43], a[49]); SQRADDAC(a[44], a[48]); SQRADDAC(a[45], a[47]); SQRADDDB; SQRADD(a[46], a[46]); COMBA_STORE(b[92]); /* output 93 */ CARRY_FORWARD; SQRADDSC(a[30], a[63]); SQRADDAC(a[31], a[62]); SQRADDAC(a[32], a[61]); SQRADDAC(a[33], a[60]); SQRADDAC(a[34], a[59]); SQRADDAC(a[35], a[58]); SQRADDAC(a[36], a[57]); SQRADDAC(a[37], a[56]); SQRADDAC(a[38], a[55]); SQRADDAC(a[39], a[54]); SQRADDAC(a[40], a[53]); SQRADDAC(a[41], a[52]); SQRADDAC(a[42], a[51]); SQRADDAC(a[43], a[50]); SQRADDAC(a[44], a[49]); SQRADDAC(a[45], a[48]); SQRADDAC(a[46], a[47]); SQRADDDB; COMBA_STORE(b[93]); /* output 94 */ CARRY_FORWARD; SQRADDSC(a[31], a[63]); SQRADDAC(a[32], a[62]); SQRADDAC(a[33], a[61]); SQRADDAC(a[34], a[60]); SQRADDAC(a[35], a[59]); SQRADDAC(a[36], a[58]); SQRADDAC(a[37], a[57]); SQRADDAC(a[38], a[56]); SQRADDAC(a[39], a[55]); SQRADDAC(a[40], a[54]); SQRADDAC(a[41], a[53]); SQRADDAC(a[42], a[52]); SQRADDAC(a[43], a[51]); SQRADDAC(a[44], a[50]); SQRADDAC(a[45], a[49]); SQRADDAC(a[46], a[48]); SQRADDDB; SQRADD(a[47], a[47]); COMBA_STORE(b[94]); /* output 95 */ CARRY_FORWARD; SQRADDSC(a[32], a[63]); SQRADDAC(a[33], a[62]); SQRADDAC(a[34], a[61]); SQRADDAC(a[35], a[60]); SQRADDAC(a[36], a[59]); SQRADDAC(a[37], a[58]); SQRADDAC(a[38], a[57]); SQRADDAC(a[39], a[56]); SQRADDAC(a[40], a[55]); SQRADDAC(a[41], a[54]); SQRADDAC(a[42], a[53]); SQRADDAC(a[43], a[52]); SQRADDAC(a[44], a[51]); SQRADDAC(a[45], a[50]); SQRADDAC(a[46], a[49]); SQRADDAC(a[47], a[48]); SQRADDDB; COMBA_STORE(b[95]); /* output 96 */ CARRY_FORWARD; SQRADDSC(a[33], a[63]); SQRADDAC(a[34], a[62]); SQRADDAC(a[35], a[61]); SQRADDAC(a[36], a[60]); SQRADDAC(a[37], a[59]); SQRADDAC(a[38], a[58]); SQRADDAC(a[39], a[57]); SQRADDAC(a[40], a[56]); SQRADDAC(a[41], a[55]); SQRADDAC(a[42], a[54]); SQRADDAC(a[43], a[53]); SQRADDAC(a[44], a[52]); SQRADDAC(a[45], a[51]); SQRADDAC(a[46], a[50]); SQRADDAC(a[47], a[49]); SQRADDDB; SQRADD(a[48], a[48]); COMBA_STORE(b[96]); /* output 97 */ CARRY_FORWARD; SQRADDSC(a[34], a[63]); SQRADDAC(a[35], a[62]); SQRADDAC(a[36], a[61]); SQRADDAC(a[37], a[60]); SQRADDAC(a[38], a[59]); SQRADDAC(a[39], a[58]); SQRADDAC(a[40], a[57]); SQRADDAC(a[41], a[56]); SQRADDAC(a[42], a[55]); SQRADDAC(a[43], a[54]); SQRADDAC(a[44], a[53]); SQRADDAC(a[45], a[52]); SQRADDAC(a[46], a[51]); SQRADDAC(a[47], a[50]); SQRADDAC(a[48], a[49]); SQRADDDB; COMBA_STORE(b[97]); /* output 98 */ CARRY_FORWARD; SQRADDSC(a[35], a[63]); SQRADDAC(a[36], a[62]); SQRADDAC(a[37], a[61]); SQRADDAC(a[38], a[60]); SQRADDAC(a[39], a[59]); SQRADDAC(a[40], a[58]); SQRADDAC(a[41], a[57]); SQRADDAC(a[42], a[56]); SQRADDAC(a[43], a[55]); SQRADDAC(a[44], a[54]); SQRADDAC(a[45], a[53]); SQRADDAC(a[46], a[52]); SQRADDAC(a[47], a[51]); SQRADDAC(a[48], a[50]); SQRADDDB; SQRADD(a[49], a[49]); COMBA_STORE(b[98]); /* output 99 */ CARRY_FORWARD; SQRADDSC(a[36], a[63]); SQRADDAC(a[37], a[62]); SQRADDAC(a[38], a[61]); SQRADDAC(a[39], a[60]); SQRADDAC(a[40], a[59]); SQRADDAC(a[41], a[58]); SQRADDAC(a[42], a[57]); SQRADDAC(a[43], a[56]); SQRADDAC(a[44], a[55]); SQRADDAC(a[45], a[54]); SQRADDAC(a[46], a[53]); SQRADDAC(a[47], a[52]); SQRADDAC(a[48], a[51]); SQRADDAC(a[49], a[50]); SQRADDDB; COMBA_STORE(b[99]); /* output 100 */ CARRY_FORWARD; SQRADDSC(a[37], a[63]); SQRADDAC(a[38], a[62]); SQRADDAC(a[39], a[61]); SQRADDAC(a[40], a[60]); SQRADDAC(a[41], a[59]); SQRADDAC(a[42], a[58]); SQRADDAC(a[43], a[57]); SQRADDAC(a[44], a[56]); SQRADDAC(a[45], a[55]); SQRADDAC(a[46], a[54]); SQRADDAC(a[47], a[53]); SQRADDAC(a[48], a[52]); SQRADDAC(a[49], a[51]); SQRADDDB; SQRADD(a[50], a[50]); COMBA_STORE(b[100]); /* output 101 */ CARRY_FORWARD; SQRADDSC(a[38], a[63]); SQRADDAC(a[39], a[62]); SQRADDAC(a[40], a[61]); SQRADDAC(a[41], a[60]); SQRADDAC(a[42], a[59]); SQRADDAC(a[43], a[58]); SQRADDAC(a[44], a[57]); SQRADDAC(a[45], a[56]); SQRADDAC(a[46], a[55]); SQRADDAC(a[47], a[54]); SQRADDAC(a[48], a[53]); SQRADDAC(a[49], a[52]); SQRADDAC(a[50], a[51]); SQRADDDB; COMBA_STORE(b[101]); /* output 102 */ CARRY_FORWARD; SQRADDSC(a[39], a[63]); SQRADDAC(a[40], a[62]); SQRADDAC(a[41], a[61]); SQRADDAC(a[42], a[60]); SQRADDAC(a[43], a[59]); SQRADDAC(a[44], a[58]); SQRADDAC(a[45], a[57]); SQRADDAC(a[46], a[56]); SQRADDAC(a[47], a[55]); SQRADDAC(a[48], a[54]); SQRADDAC(a[49], a[53]); SQRADDAC(a[50], a[52]); SQRADDDB; SQRADD(a[51], a[51]); COMBA_STORE(b[102]); /* output 103 */ CARRY_FORWARD; SQRADDSC(a[40], a[63]); SQRADDAC(a[41], a[62]); SQRADDAC(a[42], a[61]); SQRADDAC(a[43], a[60]); SQRADDAC(a[44], a[59]); SQRADDAC(a[45], a[58]); SQRADDAC(a[46], a[57]); SQRADDAC(a[47], a[56]); SQRADDAC(a[48], a[55]); SQRADDAC(a[49], a[54]); SQRADDAC(a[50], a[53]); SQRADDAC(a[51], a[52]); SQRADDDB; COMBA_STORE(b[103]); /* output 104 */ CARRY_FORWARD; SQRADDSC(a[41], a[63]); SQRADDAC(a[42], a[62]); SQRADDAC(a[43], a[61]); SQRADDAC(a[44], a[60]); SQRADDAC(a[45], a[59]); SQRADDAC(a[46], a[58]); SQRADDAC(a[47], a[57]); SQRADDAC(a[48], a[56]); SQRADDAC(a[49], a[55]); SQRADDAC(a[50], a[54]); SQRADDAC(a[51], a[53]); SQRADDDB; SQRADD(a[52], a[52]); COMBA_STORE(b[104]); /* output 105 */ CARRY_FORWARD; SQRADDSC(a[42], a[63]); SQRADDAC(a[43], a[62]); SQRADDAC(a[44], a[61]); SQRADDAC(a[45], a[60]); SQRADDAC(a[46], a[59]); SQRADDAC(a[47], a[58]); SQRADDAC(a[48], a[57]); SQRADDAC(a[49], a[56]); SQRADDAC(a[50], a[55]); SQRADDAC(a[51], a[54]); SQRADDAC(a[52], a[53]); SQRADDDB; COMBA_STORE(b[105]); /* output 106 */ CARRY_FORWARD; SQRADDSC(a[43], a[63]); SQRADDAC(a[44], a[62]); SQRADDAC(a[45], a[61]); SQRADDAC(a[46], a[60]); SQRADDAC(a[47], a[59]); SQRADDAC(a[48], a[58]); SQRADDAC(a[49], a[57]); SQRADDAC(a[50], a[56]); SQRADDAC(a[51], a[55]); SQRADDAC(a[52], a[54]); SQRADDDB; SQRADD(a[53], a[53]); COMBA_STORE(b[106]); /* output 107 */ CARRY_FORWARD; SQRADDSC(a[44], a[63]); SQRADDAC(a[45], a[62]); SQRADDAC(a[46], a[61]); SQRADDAC(a[47], a[60]); SQRADDAC(a[48], a[59]); SQRADDAC(a[49], a[58]); SQRADDAC(a[50], a[57]); SQRADDAC(a[51], a[56]); SQRADDAC(a[52], a[55]); SQRADDAC(a[53], a[54]); SQRADDDB; COMBA_STORE(b[107]); /* output 108 */ CARRY_FORWARD; SQRADDSC(a[45], a[63]); SQRADDAC(a[46], a[62]); SQRADDAC(a[47], a[61]); SQRADDAC(a[48], a[60]); SQRADDAC(a[49], a[59]); SQRADDAC(a[50], a[58]); SQRADDAC(a[51], a[57]); SQRADDAC(a[52], a[56]); SQRADDAC(a[53], a[55]); SQRADDDB; SQRADD(a[54], a[54]); COMBA_STORE(b[108]); /* output 109 */ CARRY_FORWARD; SQRADDSC(a[46], a[63]); SQRADDAC(a[47], a[62]); SQRADDAC(a[48], a[61]); SQRADDAC(a[49], a[60]); SQRADDAC(a[50], a[59]); SQRADDAC(a[51], a[58]); SQRADDAC(a[52], a[57]); SQRADDAC(a[53], a[56]); SQRADDAC(a[54], a[55]); SQRADDDB; COMBA_STORE(b[109]); /* output 110 */ CARRY_FORWARD; SQRADDSC(a[47], a[63]); SQRADDAC(a[48], a[62]); SQRADDAC(a[49], a[61]); SQRADDAC(a[50], a[60]); SQRADDAC(a[51], a[59]); SQRADDAC(a[52], a[58]); SQRADDAC(a[53], a[57]); SQRADDAC(a[54], a[56]); SQRADDDB; SQRADD(a[55], a[55]); COMBA_STORE(b[110]); /* output 111 */ CARRY_FORWARD; SQRADDSC(a[48], a[63]); SQRADDAC(a[49], a[62]); SQRADDAC(a[50], a[61]); SQRADDAC(a[51], a[60]); SQRADDAC(a[52], a[59]); SQRADDAC(a[53], a[58]); SQRADDAC(a[54], a[57]); SQRADDAC(a[55], a[56]); SQRADDDB; COMBA_STORE(b[111]); /* output 112 */ CARRY_FORWARD; SQRADDSC(a[49], a[63]); SQRADDAC(a[50], a[62]); SQRADDAC(a[51], a[61]); SQRADDAC(a[52], a[60]); SQRADDAC(a[53], a[59]); SQRADDAC(a[54], a[58]); SQRADDAC(a[55], a[57]); SQRADDDB; SQRADD(a[56], a[56]); COMBA_STORE(b[112]); /* output 113 */ CARRY_FORWARD; SQRADDSC(a[50], a[63]); SQRADDAC(a[51], a[62]); SQRADDAC(a[52], a[61]); SQRADDAC(a[53], a[60]); SQRADDAC(a[54], a[59]); SQRADDAC(a[55], a[58]); SQRADDAC(a[56], a[57]); SQRADDDB; COMBA_STORE(b[113]); /* output 114 */ CARRY_FORWARD; SQRADDSC(a[51], a[63]); SQRADDAC(a[52], a[62]); SQRADDAC(a[53], a[61]); SQRADDAC(a[54], a[60]); SQRADDAC(a[55], a[59]); SQRADDAC(a[56], a[58]); SQRADDDB; SQRADD(a[57], a[57]); COMBA_STORE(b[114]); /* output 115 */ CARRY_FORWARD; SQRADDSC(a[52], a[63]); SQRADDAC(a[53], a[62]); SQRADDAC(a[54], a[61]); SQRADDAC(a[55], a[60]); SQRADDAC(a[56], a[59]); SQRADDAC(a[57], a[58]); SQRADDDB; COMBA_STORE(b[115]); /* output 116 */ CARRY_FORWARD; SQRADDSC(a[53], a[63]); SQRADDAC(a[54], a[62]); SQRADDAC(a[55], a[61]); SQRADDAC(a[56], a[60]); SQRADDAC(a[57], a[59]); SQRADDDB; SQRADD(a[58], a[58]); COMBA_STORE(b[116]); /* output 117 */ CARRY_FORWARD; SQRADDSC(a[54], a[63]); SQRADDAC(a[55], a[62]); SQRADDAC(a[56], a[61]); SQRADDAC(a[57], a[60]); SQRADDAC(a[58], a[59]); SQRADDDB; COMBA_STORE(b[117]); /* output 118 */ CARRY_FORWARD; SQRADDSC(a[55], a[63]); SQRADDAC(a[56], a[62]); SQRADDAC(a[57], a[61]); SQRADDAC(a[58], a[60]); SQRADDDB; SQRADD(a[59], a[59]); COMBA_STORE(b[118]); /* output 119 */ CARRY_FORWARD; SQRADDSC(a[56], a[63]); SQRADDAC(a[57], a[62]); SQRADDAC(a[58], a[61]); SQRADDAC(a[59], a[60]); SQRADDDB; COMBA_STORE(b[119]); /* output 120 */ CARRY_FORWARD; SQRADDSC(a[57], a[63]); SQRADDAC(a[58], a[62]); SQRADDAC(a[59], a[61]); SQRADDDB; SQRADD(a[60], a[60]); COMBA_STORE(b[120]); /* output 121 */ CARRY_FORWARD; SQRADDSC(a[58], a[63]); SQRADDAC(a[59], a[62]); SQRADDAC(a[60], a[61]); SQRADDDB; COMBA_STORE(b[121]); /* output 122 */ CARRY_FORWARD; SQRADD2(a[59], a[63]); SQRADD2(a[60], a[62]); SQRADD(a[61], a[61]); COMBA_STORE(b[122]); /* output 123 */ CARRY_FORWARD; SQRADD2(a[60], a[63]); SQRADD2(a[61], a[62]); COMBA_STORE(b[123]); /* output 124 */ CARRY_FORWARD; SQRADD2(a[61], a[63]); SQRADD(a[62], a[62]); COMBA_STORE(b[124]); /* output 125 */ CARRY_FORWARD; SQRADD2(a[62], a[63]); COMBA_STORE(b[125]); /* output 126 */ CARRY_FORWARD; SQRADD(a[63], a[63]); COMBA_STORE(b[126]); COMBA_STORE2(b[127]); COMBA_FINI; B->used = 128; B->sign = FP_ZPOS; memcpy(B->dp, b, 128 * sizeof(fp_digit)); fp_clamp(B); } #endif /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr_comba_64.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/17 03:39:01 $ */ /* End: src/sqr/fp_sqr_comba_64.c */ /* Start: src/sqr/fp_sqr_comba_7.c */ #define TFM_DEFINES //#include "fp_sqr_comba.c" #ifdef TFM_SQR7 void fp_sqr_comba7(fp_int *A, fp_int *B) { fp_digit *a, b[14], c0, c1, c2, sc0, sc1, sc2; #ifdef TFM_ISO fp_word tt; #endif a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADD2(a[2], a[6]); SQRADD2(a[3], a[5]); SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADD2(a[3], a[6]); SQRADD2(a[4], a[5]); COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADD2(a[4], a[6]); SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADD2(a[5], a[6]); COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); COMBA_STORE2(b[13]); COMBA_FINI; B->used = 14; B->sign = FP_ZPOS; memcpy(B->dp, b, 14 * sizeof(fp_digit)); fp_clamp(B); } #endif /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr_comba_7.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/17 03:39:01 $ */ /* End: src/sqr/fp_sqr_comba_7.c */ /* Start: src/sqr/fp_sqr_comba_8.c */ #define TFM_DEFINES //#include "fp_sqr_comba.c" #ifdef TFM_SQR8 void fp_sqr_comba8(fp_int *A, fp_int *B) { fp_digit *a, b[16], c0, c1, c2, sc0, sc1, sc2; #ifdef TFM_ISO fp_word tt; #endif a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADD2(a[3], a[7]); SQRADD2(a[4], a[6]); SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADD2(a[4], a[7]); SQRADD2(a[5], a[6]); COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADD2(a[5], a[7]); SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADD2(a[6], a[7]); COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADD(a[7], a[7]); COMBA_STORE(b[14]); COMBA_STORE2(b[15]); COMBA_FINI; B->used = 16; B->sign = FP_ZPOS; memcpy(B->dp, b, 16 * sizeof(fp_digit)); fp_clamp(B); } #endif /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr_comba_8.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/17 03:39:01 $ */ /* End: src/sqr/fp_sqr_comba_8.c */ /* Start: src/sqr/fp_sqr_comba_9.c */ #define TFM_DEFINES //#include "fp_sqr_comba.c" #ifdef TFM_SQR9 void fp_sqr_comba9(fp_int *A, fp_int *B) { fp_digit *a, b[18], c0, c1, c2, sc0, sc1, sc2; #ifdef TFM_ISO fp_word tt; #endif a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADD2(a[4], a[8]); SQRADD2(a[5], a[7]); SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADD2(a[5], a[8]); SQRADD2(a[6], a[7]); COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADD2(a[6], a[8]); SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADD2(a[7], a[8]); COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADD(a[8], a[8]); COMBA_STORE(b[16]); COMBA_STORE2(b[17]); COMBA_FINI; B->used = 18; B->sign = FP_ZPOS; memcpy(B->dp, b, 18 * sizeof(fp_digit)); fp_clamp(B); } #endif /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr_comba_9.c,v $ */ /* $Revision: 1.2 $ */ /* $Date: 2007/02/17 03:39:01 $ */ /* End: src/sqr/fp_sqr_comba_9.c */ /* Start: src/sqr/fp_sqr_comba_generic.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #define TFM_DEFINES //#include "fp_sqr_comba.c" /* generic comba squarer */ void fp_sqr_comba(fp_int *A, fp_int *B) { int pa, ix, iz; fp_digit c0, c1, c2; fp_int tmp, *dst; #ifdef TFM_ISO fp_word tt; #endif /* get size of output and trim */ pa = A->used + A->used; if (pa >= FP_SIZE) { pa = FP_SIZE-1; } /* number of output digits to produce */ COMBA_START; CLEAR_CARRY; if (A == B) { fp_zero(&tmp); dst = &tmp; } else { fp_zero(B); dst = B; } for (ix = 0; ix < pa; ix++) { int tx, ty, iy; fp_digit *tmpy, *tmpx; /* get offsets into the two bignums */ ty = MIN(A->used-1, ix); tx = ix - ty; /* setup temp aliases */ tmpx = A->dp + tx; tmpy = A->dp + ty; /* this is the number of times the loop will iterrate, while (tx++ < a->used && ty-- >= 0) { ... } */ iy = MIN(A->used-tx, ty+1); /* now for squaring tx can never equal ty * we halve the distance since they approach * at a rate of 2x and we have to round because * odd cases need to be executed */ iy = MIN(iy, (ty-tx+1)>>1); /* forward carries */ CARRY_FORWARD; /* execute loop */ for (iz = 0; iz < iy; iz++) { SQRADD2(*tmpx++, *tmpy--); } /* even columns have the square term in them */ if ((ix&1) == 0) { SQRADD(A->dp[ix>>1], A->dp[ix>>1]); } /* store it */ COMBA_STORE(dst->dp[ix]); } COMBA_FINI; /* setup dest */ dst->used = pa; fp_clamp (dst); if (dst != B) { fp_copy(dst, B); } } /* $Source: /cvs/libtom/tomsfastmath/src/sqr/Attic/fp_sqr_comba_generic.c,v $ */ /* $Revision: 1.3 $ */ /* $Date: 2007/02/15 00:31:32 $ */ /* End: src/sqr/fp_sqr_comba_generic.c */ /* Start: src/sqr/fp_sqr_comba_small_set.c */ #define TFM_DEFINES //#include "fp_sqr_comba.c" #if defined(TFM_SMALL_SET) void fp_sqr_comba_small(fp_int *A, fp_int *B) { fp_digit *a, b[32], c0, c1, c2, sc0, sc1, sc2; #ifdef TFM_ISO fp_word tt; #endif switch (A->used) { case 1: a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); COMBA_STORE2(b[1]); COMBA_FINI; B->used = 2; B->sign = FP_ZPOS; memcpy(B->dp, b, 2 * sizeof(fp_digit)); fp_clamp(B); break; case 2: a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD(a[1], a[1]); COMBA_STORE(b[2]); COMBA_STORE2(b[3]); COMBA_FINI; B->used = 4; B->sign = FP_ZPOS; memcpy(B->dp, b, 4 * sizeof(fp_digit)); fp_clamp(B); break; case 3: a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD(a[2], a[2]); COMBA_STORE(b[4]); COMBA_STORE2(b[5]); COMBA_FINI; B->used = 6; B->sign = FP_ZPOS; memcpy(B->dp, b, 6 * sizeof(fp_digit)); fp_clamp(B); break; case 4: a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADD2(a[2], a[3]); COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); COMBA_STORE2(b[7]); COMBA_FINI; B->used = 8; B->sign = FP_ZPOS; memcpy(B->dp, b, 8 * sizeof(fp_digit)); fp_clamp(B); break; case 5: a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADD2(a[1], a[4]); SQRADD2(a[2], a[3]); COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADD2(a[2], a[4]); SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADD2(a[3], a[4]); COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); COMBA_STORE2(b[9]); COMBA_FINI; B->used = 10; B->sign = FP_ZPOS; memcpy(B->dp, b, 10 * sizeof(fp_digit)); fp_clamp(B); break; case 6: a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADD2(a[1], a[5]); SQRADD2(a[2], a[4]); SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADD2(a[2], a[5]); SQRADD2(a[3], a[4]); COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADD2(a[3], a[5]); SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADD2(a[4], a[5]); COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); COMBA_STORE2(b[11]); COMBA_FINI; B->used = 12; B->sign = FP_ZPOS; memcpy(B->dp, b, 12 * sizeof(fp_digit)); fp_clamp(B); break; case 7: a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADD2(a[2], a[6]); SQRADD2(a[3], a[5]); SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADD2(a[3], a[6]); SQRADD2(a[4], a[5]); COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADD2(a[4], a[6]); SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADD2(a[5], a[6]); COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); COMBA_STORE2(b[13]); COMBA_FINI; B->used = 14; B->sign = FP_ZPOS; memcpy(B->dp, b, 14 * sizeof(fp_digit)); fp_clamp(B); break; case 8: a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADD2(a[3], a[7]); SQRADD2(a[4], a[6]); SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADD2(a[4], a[7]); SQRADD2(a[5], a[6]); COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADD2(a[5], a[7]); SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADD2(a[6], a[7]); COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADD(a[7], a[7]); COMBA_STORE(b[14]); COMBA_STORE2(b[15]); COMBA_FINI; B->used = 16; B->sign = FP_ZPOS; memcpy(B->dp, b, 16 * sizeof(fp_digit)); fp_clamp(B); break; case 9: a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADD2(a[4], a[8]); SQRADD2(a[5], a[7]); SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADD2(a[5], a[8]); SQRADD2(a[6], a[7]); COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADD2(a[6], a[8]); SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADD2(a[7], a[8]); COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADD(a[8], a[8]); COMBA_STORE(b[16]); COMBA_STORE2(b[17]); COMBA_FINI; B->used = 18; B->sign = FP_ZPOS; memcpy(B->dp, b, 18 * sizeof(fp_digit)); fp_clamp(B); break; case 10: a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADDSC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADDSC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADD2(a[5], a[9]); SQRADD2(a[6], a[8]); SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADD2(a[6], a[9]); SQRADD2(a[7], a[8]); COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADD2(a[7], a[9]); SQRADD(a[8], a[8]); COMBA_STORE(b[16]); /* output 17 */ CARRY_FORWARD; SQRADD2(a[8], a[9]); COMBA_STORE(b[17]); /* output 18 */ CARRY_FORWARD; SQRADD(a[9], a[9]); COMBA_STORE(b[18]); COMBA_STORE2(b[19]); COMBA_FINI; B->used = 20; B->sign = FP_ZPOS; memcpy(B->dp, b, 20 * sizeof(fp_digit)); fp_clamp(B); break; case 11: a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADDSC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADDSC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADDSC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADDSC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADD2(a[6], a[10]); SQRADD2(a[7], a[9]); SQRADD(a[8], a[8]); COMBA_STORE(b[16]); /* output 17 */ CARRY_FORWARD; SQRADD2(a[7], a[10]); SQRADD2(a[8], a[9]); COMBA_STORE(b[17]); /* output 18 */ CARRY_FORWARD; SQRADD2(a[8], a[10]); SQRADD(a[9], a[9]); COMBA_STORE(b[18]); /* output 19 */ CARRY_FORWARD; SQRADD2(a[9], a[10]); COMBA_STORE(b[19]); /* output 20 */ CARRY_FORWARD; SQRADD(a[10], a[10]); COMBA_STORE(b[20]); COMBA_STORE2(b[21]); COMBA_FINI; B->used = 22; B->sign = FP_ZPOS; memcpy(B->dp, b, 22 * sizeof(fp_digit)); fp_clamp(B); break; case 12: a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADDSC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADDSC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADDSC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADDSC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADDSC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); COMBA_STORE(b[16]); /* output 17 */ CARRY_FORWARD; SQRADDSC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; COMBA_STORE(b[17]); /* output 18 */ CARRY_FORWARD; SQRADD2(a[7], a[11]); SQRADD2(a[8], a[10]); SQRADD(a[9], a[9]); COMBA_STORE(b[18]); /* output 19 */ CARRY_FORWARD; SQRADD2(a[8], a[11]); SQRADD2(a[9], a[10]); COMBA_STORE(b[19]); /* output 20 */ CARRY_FORWARD; SQRADD2(a[9], a[11]); SQRADD(a[10], a[10]); COMBA_STORE(b[20]); /* output 21 */ CARRY_FORWARD; SQRADD2(a[10], a[11]); COMBA_STORE(b[21]); /* output 22 */ CARRY_FORWARD; SQRADD(a[11], a[11]); COMBA_STORE(b[22]); COMBA_STORE2(b[23]); COMBA_FINI; B->used = 24; B->sign = FP_ZPOS; memcpy(B->dp, b, 24 * sizeof(fp_digit)); fp_clamp(B); break; case 13: a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADDSC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADDSC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADDSC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADDSC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); COMBA_STORE(b[16]); /* output 17 */ CARRY_FORWARD; SQRADDSC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; COMBA_STORE(b[17]); /* output 18 */ CARRY_FORWARD; SQRADDSC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); COMBA_STORE(b[18]); /* output 19 */ CARRY_FORWARD; SQRADDSC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; COMBA_STORE(b[19]); /* output 20 */ CARRY_FORWARD; SQRADD2(a[8], a[12]); SQRADD2(a[9], a[11]); SQRADD(a[10], a[10]); COMBA_STORE(b[20]); /* output 21 */ CARRY_FORWARD; SQRADD2(a[9], a[12]); SQRADD2(a[10], a[11]); COMBA_STORE(b[21]); /* output 22 */ CARRY_FORWARD; SQRADD2(a[10], a[12]); SQRADD(a[11], a[11]); COMBA_STORE(b[22]); /* output 23 */ CARRY_FORWARD; SQRADD2(a[11], a[12]); COMBA_STORE(b[23]); /* output 24 */ CARRY_FORWARD; SQRADD(a[12], a[12]); COMBA_STORE(b[24]); COMBA_STORE2(b[25]); COMBA_FINI; B->used = 26; B->sign = FP_ZPOS; memcpy(B->dp, b, 26 * sizeof(fp_digit)); fp_clamp(B); break; case 14: a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADDSC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADDSC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADDSC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); COMBA_STORE(b[16]); /* output 17 */ CARRY_FORWARD; SQRADDSC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; COMBA_STORE(b[17]); /* output 18 */ CARRY_FORWARD; SQRADDSC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); COMBA_STORE(b[18]); /* output 19 */ CARRY_FORWARD; SQRADDSC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; COMBA_STORE(b[19]); /* output 20 */ CARRY_FORWARD; SQRADDSC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); COMBA_STORE(b[20]); /* output 21 */ CARRY_FORWARD; SQRADDSC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; COMBA_STORE(b[21]); /* output 22 */ CARRY_FORWARD; SQRADD2(a[9], a[13]); SQRADD2(a[10], a[12]); SQRADD(a[11], a[11]); COMBA_STORE(b[22]); /* output 23 */ CARRY_FORWARD; SQRADD2(a[10], a[13]); SQRADD2(a[11], a[12]); COMBA_STORE(b[23]); /* output 24 */ CARRY_FORWARD; SQRADD2(a[11], a[13]); SQRADD(a[12], a[12]); COMBA_STORE(b[24]); /* output 25 */ CARRY_FORWARD; SQRADD2(a[12], a[13]); COMBA_STORE(b[25]); /* output 26 */ CARRY_FORWARD; SQRADD(a[13], a[13]); COMBA_STORE(b[26]); COMBA_STORE2(b[27]); COMBA_FINI; B->used = 28; B->sign = FP_ZPOS; memcpy(B->dp, b, 28 * sizeof(fp_digit)); fp_clamp(B); break; case 15: a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADDSC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADDSC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); COMBA_STORE(b[16]); /* output 17 */ CARRY_FORWARD; SQRADDSC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; COMBA_STORE(b[17]); /* output 18 */ CARRY_FORWARD; SQRADDSC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); COMBA_STORE(b[18]); /* output 19 */ CARRY_FORWARD; SQRADDSC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; COMBA_STORE(b[19]); /* output 20 */ CARRY_FORWARD; SQRADDSC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); COMBA_STORE(b[20]); /* output 21 */ CARRY_FORWARD; SQRADDSC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; COMBA_STORE(b[21]); /* output 22 */ CARRY_FORWARD; SQRADDSC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); COMBA_STORE(b[22]); /* output 23 */ CARRY_FORWARD; SQRADDSC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; COMBA_STORE(b[23]); /* output 24 */ CARRY_FORWARD; SQRADD2(a[10], a[14]); SQRADD2(a[11], a[13]); SQRADD(a[12], a[12]); COMBA_STORE(b[24]); /* output 25 */ CARRY_FORWARD; SQRADD2(a[11], a[14]); SQRADD2(a[12], a[13]); COMBA_STORE(b[25]); /* output 26 */ CARRY_FORWARD; SQRADD2(a[12], a[14]); SQRADD(a[13], a[13]); COMBA_STORE(b[26]); /* output 27 */ CARRY_FORWARD; SQRADD2(a[13], a[14]); COMBA_STORE(b[27]); /* output 28 */ CARRY_FORWARD; SQRADD(a[14], a[14]); COMBA_STORE(b[28]); COMBA_STORE2(b[29]); COMBA_FINI; B->used = 30; B->sign = FP_ZPOS; memcpy(B->dp, b, 30 * sizeof(fp_digit)); fp_clamp(B); break; case 16: a = A->dp; COMBA_START; /* clear carries */ CLEAR_CARRY; /* output 0 */ SQRADD(a[0],a[0]); COMBA_STORE(b[0]); /* output 1 */ CARRY_FORWARD; SQRADD2(a[0], a[1]); COMBA_STORE(b[1]); /* output 2 */ CARRY_FORWARD; SQRADD2(a[0], a[2]); SQRADD(a[1], a[1]); COMBA_STORE(b[2]); /* output 3 */ CARRY_FORWARD; SQRADD2(a[0], a[3]); SQRADD2(a[1], a[2]); COMBA_STORE(b[3]); /* output 4 */ CARRY_FORWARD; SQRADD2(a[0], a[4]); SQRADD2(a[1], a[3]); SQRADD(a[2], a[2]); COMBA_STORE(b[4]); /* output 5 */ CARRY_FORWARD; SQRADDSC(a[0], a[5]); SQRADDAC(a[1], a[4]); SQRADDAC(a[2], a[3]); SQRADDDB; COMBA_STORE(b[5]); /* output 6 */ CARRY_FORWARD; SQRADDSC(a[0], a[6]); SQRADDAC(a[1], a[5]); SQRADDAC(a[2], a[4]); SQRADDDB; SQRADD(a[3], a[3]); COMBA_STORE(b[6]); /* output 7 */ CARRY_FORWARD; SQRADDSC(a[0], a[7]); SQRADDAC(a[1], a[6]); SQRADDAC(a[2], a[5]); SQRADDAC(a[3], a[4]); SQRADDDB; COMBA_STORE(b[7]); /* output 8 */ CARRY_FORWARD; SQRADDSC(a[0], a[8]); SQRADDAC(a[1], a[7]); SQRADDAC(a[2], a[6]); SQRADDAC(a[3], a[5]); SQRADDDB; SQRADD(a[4], a[4]); COMBA_STORE(b[8]); /* output 9 */ CARRY_FORWARD; SQRADDSC(a[0], a[9]); SQRADDAC(a[1], a[8]); SQRADDAC(a[2], a[7]); SQRADDAC(a[3], a[6]); SQRADDAC(a[4], a[5]); SQRADDDB; COMBA_STORE(b[9]); /* output 10 */ CARRY_FORWARD; SQRADDSC(a[0], a[10]); SQRADDAC(a[1], a[9]); SQRADDAC(a[2], a[8]); SQRADDAC(a[3], a[7]); SQRADDAC(a[4], a[6]); SQRADDDB; SQRADD(a[5], a[5]); COMBA_STORE(b[10]); /* output 11 */ CARRY_FORWARD; SQRADDSC(a[0], a[11]); SQRADDAC(a[1], a[10]); SQRADDAC(a[2], a[9]); SQRADDAC(a[3], a[8]); SQRADDAC(a[4], a[7]); SQRADDAC(a[5], a[6]); SQRADDDB; COMBA_STORE(b[11]); /* output 12 */ CARRY_FORWARD; SQRADDSC(a[0], a[12]); SQRADDAC(a[1], a[11]); SQRADDAC(a[2], a[10]); SQRADDAC(a[3], a[9]); SQRADDAC(a[4], a[8]); SQRADDAC(a[5], a[7]); SQRADDDB; SQRADD(a[6], a[6]); COMBA_STORE(b[12]); /* output 13 */ CARRY_FORWARD; SQRADDSC(a[0], a[13]); SQRADDAC(a[1], a[12]); SQRADDAC(a[2], a[11]); SQRADDAC(a[3], a[10]); SQRADDAC(a[4], a[9]); SQRADDAC(a[5], a[8]); SQRADDAC(a[6], a[7]); SQRADDDB; COMBA_STORE(b[13]); /* output 14 */ CARRY_FORWARD; SQRADDSC(a[0], a[14]); SQRADDAC(a[1], a[13]); SQRADDAC(a[2], a[12]); SQRADDAC(a[3], a[11]); SQRADDAC(a[4], a[10]); SQRADDAC(a[5], a[9]); SQRADDAC(a[6], a[8]); SQRADDDB; SQRADD(a[7], a[7]); COMBA_STORE(b[14]); /* output 15 */ CARRY_FORWARD; SQRADDSC(a[0], a[15]); SQRADDAC(a[1], a[14]); SQRADDAC(a[2], a[13]); SQRADDAC(a[3], a[12]); SQRADDAC(a[4], a[11]); SQRADDAC(a[5], a[10]); SQRADDAC(a[6], a[9]); SQRADDAC(a[7], a[8]); SQRADDDB; COMBA_STORE(b[15]); /* output 16 */ CARRY_FORWARD; SQRADDSC(a[1], a[15]); SQRADDAC(a[2], a[14]); SQRADDAC(a[3], a[13]); SQRADDAC(a[4], a[12]); SQRADDAC(a[5], a[11]); SQRADDAC(a[6], a[10]); SQRADDAC(a[7], a[9]); SQRADDDB; SQRADD(a[8], a[8]); COMBA_STORE(b[16]); /* output 17 */ CARRY_FORWARD; SQRADDSC(a[2], a[15]); SQRADDAC(a[3], a[14]); SQRADDAC(a[4], a[13]); SQRADDAC(a[5], a[12]); SQRADDAC(a[6], a[11]); SQRADDAC(a[7], a[10]); SQRADDAC(a[8], a[9]); SQRADDDB; COMBA_STORE(b[17]); /* output 18 */ CARRY_FORWARD; SQRADDSC(a[3], a[15]); SQRADDAC(a[4], a[14]); SQRADDAC(a[5], a[13]); SQRADDAC(a[6], a[12]); SQRADDAC(a[7], a[11]); SQRADDAC(a[8], a[10]); SQRADDDB; SQRADD(a[9], a[9]); COMBA_STORE(b[18]); /* output 19 */ CARRY_FORWARD; SQRADDSC(a[4], a[15]); SQRADDAC(a[5], a[14]); SQRADDAC(a[6], a[13]); SQRADDAC(a[7], a[12]); SQRADDAC(a[8], a[11]); SQRADDAC(a[9], a[10]); SQRADDDB; COMBA_STORE(b[19]); /* output 20 */ CARRY_FORWARD; SQRADDSC(a[5], a[15]); SQRADDAC(a[6], a[14]); SQRADDAC(a[7], a[13]); SQRADDAC(a[8], a[12]); SQRADDAC(a[9], a[11]); SQRADDDB; SQRADD(a[10], a[10]); COMBA_STORE(b[20]); /* output 21 */ CARRY_FORWARD; SQRADDSC(a[6], a[15]); SQRADDAC(a[7], a[14]); SQRADDAC(a[8], a[13]); SQRADDAC(a[9], a[12]); SQRADDAC(a[10], a[11]); SQRADDDB; COMBA_STORE(b[21]); /* output 22 */ CARRY_FORWARD; SQRADDSC(a[7], a[15]); SQRADDAC(a[8], a[14]); SQRADDAC(a[9], a[13]); SQRADDAC(a[10], a[12]); SQRADDDB; SQRADD(a[11], a[11]); COMBA_STORE(b[22]); /* output 23 */ CARRY_FORWARD; SQRADDSC(a[8], a[15]); SQRADDAC(a[9], a[14]); SQRADDAC(a[10], a[13]); SQRADDAC(a[11], a[12]); SQRADDDB; COMBA_STORE(b[23]); /* output 24 */ CARRY_FORWARD; SQRADDSC(a[9], a[15]); SQRADDAC(a[10], a[14]); SQRADDAC(a[11], a[13]); SQRADDDB; SQRADD(a[12], a[12]); COMBA_STORE(b[24]); /* output 25 */ CARRY_FORWARD; SQRADDSC(a[10], a[15]); SQRADDAC(a[11], a[14]); SQRADDAC(a[12], a[13]); SQRADDDB; COMBA_STORE(b[25]); /* output 26 */ CARRY_FORWARD; SQRADD2(a[11], a[15]); SQRADD2(a[12], a[14]); SQRADD(a[13], a[13]); COMBA_STORE(b[26]); /* output 27 */ CARRY_FORWARD; SQRADD2(a[12], a[15]); SQRADD2(a[13], a[14]); COMBA_STORE(b[27]); /* output 28 */ CARRY_FORWARD; SQRADD2(a[13], a[15]); SQRADD(a[14], a[14]); COMBA_STORE(b[28]); /* output 29 */ CARRY_FORWARD; SQRADD2(a[14], a[15]); COMBA_STORE(b[29]); /* output 30 */ CARRY_FORWARD; SQRADD(a[15], a[15]); COMBA_STORE(b[30]); COMBA_STORE2(b[31]); COMBA_FINI; B->used = 32; B->sign = FP_ZPOS; memcpy(B->dp, b, 32 * sizeof(fp_digit)); fp_clamp(B); break; } } #endif /* TFM_SMALL_SET */ /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqr_comba_small_set.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2007/02/15 00:31:32 $ */ /* End: src/sqr/fp_sqr_comba_small_set.c */ /* Start: src/sqr/fp_sqrmod.c */ /* TomsFastMath, a fast ISO C bignum library. * * This project is meant to fill in where LibTomMath * falls short. That is speed ;-) * * This project is public domain and free for all purposes. * * Tom St Denis, tomstdenis@gmail.com */ #include /* c = a * a (mod b) */ int fp_sqrmod(fp_int *a, fp_int *b, fp_int *c) { fp_int tmp; fp_zero(&tmp); fp_sqr(a, &tmp); return fp_mod(&tmp, b, c); } /* $Source: /cvs/libtom/tomsfastmath/src/sqr/fp_sqrmod.c,v $ */ /* $Revision: 1.1 $ */ /* $Date: 2006/12/31 21:25:53 $ */ /* End: src/sqr/fp_sqrmod.c */ /* EOF */ sks-ecc-0.93/util.c0000644000175000017500000001464310715702751013075 0ustar nachonacho/* util.c Auxiliar functions of 'sks' project Copyright (C) 2004-2007 Manuel Pancorbo Castro This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Manuel Pancorbo Castro */ #include #include "mycrypt.h" #include "binasc.h" #include "sks.h" #ifdef LINUX #define ECHO_OFF "stty -echo" #define ECHO_ON "stty echo" #elif defined WIN32 #include "conio.h" /*#define ECHO_OFF "echo off" #define ECHO_ON "echo on"*/ #else #error "WIN32 or LINUX must be defined" #endif void burn_stack(unsigned long len) { unsigned char buf[32]; zeromem(buf, sizeof(buf)); if (len > (unsigned long)sizeof(buf)) burn_stack(len - sizeof(buf)); } ERROR get_text(FILE *inp, char *frase, const char *msg) { char last; assert((inp != NULL) && (frase != NULL)); if(inp == stdin){ fputs(msg, stderr); fgets(frase, PASSWD_SIZE, inp); #if 0 fputs("\n", stderr); #endif } else{ fgets(frase, PASSWD_SIZE, inp); } last = frase[strlen(frase)-1]; if((last == '\n') || last == '\r') frase[strlen(frase)-1] = 0; last = frase[strlen(frase)-1]; if((last == '\n') || last == '\r') frase[strlen(frase)-1] = 0; return 0; } #ifdef WIN32 ERROR get_secret_text(char *pass, int n, const char *msg) { int i, x; _cputs(msg); for(i = 0; i < n; ++i){ x = (_getch() & 0xff); if ( (x == '\n') || (x == '\r')){ pass[i] = 0; break; } if(x == '\b'){ _putch(x); _putch(' '); _putch(x); i--; i = (i < 0)? 0: i; pass[i--] = 0; /*_getch();*/ } else{ pass[i] = (x & 0xff); _putch( '*' ); } } _putch( '\n' ); return 0; } #endif ERROR get_privkey(FILE *inp, PrivKey p, const char *msg) { char frase[PASSWD_SIZE]; ERROR err; memset(frase, 0, PASSWD_SIZE); #ifdef LINUX system(ECHO_OFF); if((err = get_text(inp, frase, msg))) return err; system(ECHO_ON); fputs("\n", stderr); #elif defined WIN32 get_secret_text(frase, PASSWD_SIZE, msg); #endif if((err = hash_password( frase, p))) return err; memset(frase, 0, PASSWD_SIZE); return 0; } void write_longint(FILE *ptr, unsigned long int x, int binmode) /** In UTF-like stile: data are input in 7-bit chunks; 8th bit shows if more data should be read **/ { int out, base = 1 << 7; while(1){ out = x % base; x /= base; if(x) {fputcPlus(out | 0x80, ptr, binmode);} else{ fputcPlus(out, ptr, binmode); return; } } } int read_longint(FILE *ptr, unsigned long int *x, int binmode) { int i = 0 ; unsigned char c; *x = 0; while(1){ freadPlus(&c, 1, 1, ptr, binmode); *x += ((unsigned long int) (c & 0x7f)) << 7*i; ++i; if(!(c & 0x80)) break; } return i; } ERROR write_signature(FILE *ptr, sgPair *sig) { int binmode = 0; fwritePlus(sig->r, 1, KEY_SIZE, ptr, binmode); fwritePlus(sig->s, 1, KEY_SIZE, ptr, binmode); if(!binmode) flushArmour(ptr); return 0; } ERROR read_signature(FILE *ptr, sgPair *sig, int binmode) { if(freadPlus(sig->r, 1, KEY_SIZE, ptr, binmode) != KEY_SIZE) return -1; if(freadPlus(sig->s, 1, KEY_SIZE, ptr, binmode) != KEY_SIZE) return -1; if(!binmode) burnBinasc(); return 0; } int position(FILE * f_inp, /*FILE *f_out,*/ const char *pattern) /* scan ascii file for pattern */ { while(!feof(f_inp)) { char buffer[SMALL_BUF]; fgets(buffer, SMALL_BUF, f_inp); if(!strncasecmp(buffer, pattern, strlen(pattern))) break; /*if(f_out != NULL){ fputs(buffer, f_out); fputc('\n', f_out); }*/ } if(feof(f_inp)) { return -1; } return 0; } int str_match(char *s1, char *s2) /** Looks for matching substring in main string **/ /** Returns 1 if match and 0 if not **/ { int i, s1_len, s2_len, main_len, sub_len; char *main_str, *sub_str; s1_len = strlen(s1); s2_len = strlen(s2); if(s1_len == s2_len) return !strcasecmp(s1, s2); else if(s1_len > s2_len){ main_str = s1; sub_str = s2; main_len = s1_len; sub_len = s2_len; } else /*if(s2__len > s1_len)*/{ main_str = s2; sub_str = s1; main_len = s2_len; sub_len = s1_len; } for(i = 0; i <= main_len - sub_len; ++i){ if(!strncasecmp(main_str + i, sub_str, sub_len)) return 1; } return 0; } ERROR fputs_base36(PubKey a, FILE *out) { vl_number b; PubKey hsh; int i = 0; char buf[40], x, *p; hash_binary(hsh, a, GF_SIZE); // vlOpen(b); gfZero(b); vlUnpack(b, hsh); gf_toradix(b, buf, 36); p = buf + strlen(buf) - 30; for(i = 0; i < 30; ++i){ if( (x = p[i]) == 'O') {fputc('o', out);} else {fputc(x, out);} if( !((i+1) % 5) ) fputc(' ', out); } vlClear(b); return 0; } int char_set_conversion = 0; void test_charset() { #ifdef LINUX #include char_set_conversion = !str_match(getenv("LANG"), "UTF-8"); // char_set_conversion = 0; #else char_set_conversion = 1; #endif /*fprintf(stderr, "Consersión: %d\n", char_set_conversion);*/ } static char dest[1024]; char * utf8_to_latin1( char *source) { assert(source != NULL); if(!char_set_conversion) return source; int i, j, in, out, len; #ifdef WIN32 unsigned char lat1[] = {225, 233, 237, 243, 250, 252, 241, 231, 193, 201, 205, 211, 218, 220, 209, 199, 161, 191}; unsigned char oem[] = {160, 130, 161, 162, 163, 129, 164, 135, 181, 144, 214, 224, 233, 154, 165, 128, 173, 168, 32}; #endif len = strlen(source); memset(dest, 0, len + 1); for(i = j =0; i < len; ++i){ if((in = source[i]) >= 0x80){ out = (in & 0x1F); if(((in & 0xE0) != 0xC0) || (out > 3)){ fprintf(stderr, "No válido: c1 = 0x%02x\n", in); continue; } in = source[++i]; if(((in & 0xC0) != 0x80)){ fprintf(stderr, "No válido: c2 = 0x%02x\n", in); continue; } out <<= 6; out += in & 0x3f; #ifdef WIN32 /*** CP851 transform ***/ int k; for(k = 0; k< sizeof(lat1); ++k) if(out == lat1[k]) break; out = oem[k]; #endif } else out = in; dest[j++] = out; if(!out) break; } return dest; } sks-ecc-0.93/zlib/0000755000175000017500000000000010707654112012702 5ustar nachonachosks-ecc-0.93/zlib/ChangeLog0000644000175000017500000012366010604550750014463 0ustar nachonacho ChangeLog file for zlib Changes in 1.2.3 (18 July 2005) - Apply security vulnerability fixes to contrib/infback9 as well - Clean up some text files (carriage returns, trailing space) - Update testzlib, vstudio, masmx64, and masmx86 in contrib [Vollant] Changes in 1.2.2.4 (11 July 2005) - Add inflatePrime() function for starting inflation at bit boundary - Avoid some Visual C warnings in deflate.c - Avoid more silly Visual C warnings in inflate.c and inftrees.c for 64-bit compile - Fix some spelling errors in comments [Betts] - Correct inflateInit2() error return documentation in zlib.h - Added zran.c example of compressed data random access to examples directory, shows use of inflatePrime() - Fix cast for assignments to strm->state in inflate.c and infback.c - Fix zlibCompileFlags() in zutil.c to use 1L for long shifts [Oberhumer] - Move declarations of gf2 functions to right place in crc32.c [Oberhumer] - Add cast in trees.c t avoid a warning [Oberhumer] - Avoid some warnings in fitblk.c, gun.c, gzjoin.c in examples [Oberhumer] - Update make_vms.com [Zinser] - Initialize state->write in inflateReset() since copied in inflate_fast() - Be more strict on incomplete code sets in inflate_table() and increase ENOUGH and MAXD -- this repairs a possible security vulnerability for invalid inflate input. Thanks to Tavis Ormandy and Markus Oberhumer for discovering the vulnerability and providing test cases. - Add ia64 support to configure for HP-UX [Smith] - Add error return to gzread() for format or i/o error [Levin] - Use malloc.h for OS/2 [Necasek] Changes in 1.2.2.3 (27 May 2005) - Replace 1U constants in inflate.c and inftrees.c for 64-bit compile - Typecast fread() return values in gzio.c [Vollant] - Remove trailing space in minigzip.c outmode (VC++ can't deal with it) - Fix crc check bug in gzread() after gzungetc() [Heiner] - Add the deflateTune() function to adjust internal compression parameters - Add a fast gzip decompressor, gun.c, to examples (use of inflateBack) - Remove an incorrect assertion in examples/zpipe.c - Add C++ wrapper in infback9.h [Donais] - Fix bug in inflateCopy() when decoding fixed codes - Note in zlib.h how much deflateSetDictionary() actually uses - Remove USE_DICT_HEAD in deflate.c (would mess up inflate if used) - Add _WIN32_WCE to define WIN32 in zconf.in.h [Spencer] - Don't include stderr.h or errno.h for _WIN32_WCE in zutil.h [Spencer] - Add gzdirect() function to indicate transparent reads - Update contrib/minizip [Vollant] - Fix compilation of deflate.c when both ASMV and FASTEST [Oberhumer] - Add casts in crc32.c to avoid warnings [Oberhumer] - Add contrib/masmx64 [Vollant] - Update contrib/asm586, asm686, masmx86, testzlib, vstudio [Vollant] Changes in 1.2.2.2 (30 December 2004) - Replace structure assignments in deflate.c and inflate.c with zmemcpy to avoid implicit memcpy calls (portability for no-library compilation) - Increase sprintf() buffer size in gzdopen() to allow for large numbers - Add INFLATE_STRICT to check distances against zlib header - Improve WinCE errno handling and comments [Chang] - Remove comment about no gzip header processing in FAQ - Add Z_FIXED strategy option to deflateInit2() to force fixed trees - Add updated make_vms.com [Coghlan], update README - Create a new "examples" directory, move gzappend.c there, add zpipe.c, fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html. - Add FAQ entry and comments in deflate.c on uninitialized memory access - Add Solaris 9 make options in configure [Gilbert] - Allow strerror() usage in gzio.c for STDC - Fix DecompressBuf in contrib/delphi/ZLib.pas [ManChesTer] - Update contrib/masmx86/inffas32.asm and gvmat32.asm [Vollant] - Use z_off_t for adler32_combine() and crc32_combine() lengths - Make adler32() much faster for small len - Use OS_CODE in deflate() default gzip header Changes in 1.2.2.1 (31 October 2004) - Allow inflateSetDictionary() call for raw inflate - Fix inflate header crc check bug for file names and comments - Add deflateSetHeader() and gz_header structure for custom gzip headers - Add inflateGetheader() to retrieve gzip headers - Add crc32_combine() and adler32_combine() functions - Add alloc_func, free_func, in_func, out_func to Z_PREFIX list - Use zstreamp consistently in zlib.h (inflate_back functions) - Remove GUNZIP condition from definition of inflate_mode in inflate.h and in contrib/inflate86/inffast.S [Truta, Anderson] - Add support for AMD64 in contrib/inflate86/inffas86.c [Anderson] - Update projects/README.projects and projects/visualc6 [Truta] - Update win32/DLL_FAQ.txt [Truta] - Avoid warning under NO_GZCOMPRESS in gzio.c; fix typo [Truta] - Deprecate Z_ASCII; use Z_TEXT instead [Truta] - Use a new algorithm for setting strm->data_type in trees.c [Truta] - Do not define an exit() prototype in zutil.c unless DEBUG defined - Remove prototype of exit() from zutil.c, example.c, minigzip.c [Truta] - Add comment in zlib.h for Z_NO_FLUSH parameter to deflate() - Fix Darwin build version identification [Peterson] Changes in 1.2.2 (3 October 2004) - Update zlib.h comments on gzip in-memory processing - Set adler to 1 in inflateReset() to support Java test suite [Walles] - Add contrib/dotzlib [Ravn] - Update win32/DLL_FAQ.txt [Truta] - Update contrib/minizip [Vollant] - Move contrib/visual-basic.txt to old/ [Truta] - Fix assembler builds in projects/visualc6/ [Truta] Changes in 1.2.1.2 (9 September 2004) - Update INDEX file - Fix trees.c to update strm->data_type (no one ever noticed!) - Fix bug in error case in inflate.c, infback.c, and infback9.c [Brown] - Add "volatile" to crc table flag declaration (for DYNAMIC_CRC_TABLE) - Add limited multitasking protection to DYNAMIC_CRC_TABLE - Add NO_vsnprintf for VMS in zutil.h [Mozilla] - Don't declare strerror() under VMS [Mozilla] - Add comment to DYNAMIC_CRC_TABLE to use get_crc_table() to initialize - Update contrib/ada [Anisimkov] - Update contrib/minizip [Vollant] - Fix configure to not hardcode directories for Darwin [Peterson] - Fix gzio.c to not return error on empty files [Brown] - Fix indentation; update version in contrib/delphi/ZLib.pas and contrib/pascal/zlibpas.pas [Truta] - Update mkasm.bat in contrib/masmx86 [Truta] - Update contrib/untgz [Truta] - Add projects/README.projects [Truta] - Add project for MS Visual C++ 6.0 in projects/visualc6 [Cadieux, Truta] - Update win32/DLL_FAQ.txt [Truta] - Update list of Z_PREFIX symbols in zconf.h [Randers-Pehrson, Truta] - Remove an unnecessary assignment to curr in inftrees.c [Truta] - Add OS/2 to exe builds in configure [Poltorak] - Remove err dummy parameter in zlib.h [Kientzle] Changes in 1.2.1.1 (9 January 2004) - Update email address in README - Several FAQ updates - Fix a big fat bug in inftrees.c that prevented decoding valid dynamic blocks with only literals and no distance codes -- Thanks to "Hot Emu" for the bug report and sample file - Add a note to puff.c on no distance codes case. Changes in 1.2.1 (17 November 2003) - Remove a tab in contrib/gzappend/gzappend.c - Update some interfaces in contrib for new zlib functions - Update zlib version number in some contrib entries - Add Windows CE definition for ptrdiff_t in zutil.h [Mai, Truta] - Support shared libraries on Hurd and KFreeBSD [Brown] - Fix error in NO_DIVIDE option of adler32.c Changes in 1.2.0.8 (4 November 2003) - Update version in contrib/delphi/ZLib.pas and contrib/pascal/zlibpas.pas - Add experimental NO_DIVIDE #define in adler32.c - Possibly faster on some processors (let me know if it is) - Correct Z_BLOCK to not return on first inflate call if no wrap - Fix strm->data_type on inflate() return to correctly indicate EOB - Add deflatePrime() function for appending in the middle of a byte - Add contrib/gzappend for an example of appending to a stream - Update win32/DLL_FAQ.txt [Truta] - Delete Turbo C comment in README [Truta] - Improve some indentation in zconf.h [Truta] - Fix infinite loop on bad input in configure script [Church] - Fix gzeof() for concatenated gzip files [Johnson] - Add example to contrib/visual-basic.txt [Michael B.] - Add -p to mkdir's in Makefile.in [vda] - Fix configure to properly detect presence or lack of printf functions - Add AS400 support [Monnerat] - Add a little Cygwin support [Wilson] Changes in 1.2.0.7 (21 September 2003) - Correct some debug formats in contrib/infback9 - Cast a type in a debug statement in trees.c - Change search and replace delimiter in configure from % to # [Beebe] - Update contrib/untgz to 0.2 with various fixes [Truta] - Add build support for Amiga [Nikl] - Remove some directories in old that have been updated to 1.2 - Add dylib building for Mac OS X in configure and Makefile.in - Remove old distribution stuff from Makefile - Update README to point to DLL_FAQ.txt, and add comment on Mac OS X - Update links in README Changes in 1.2.0.6 (13 September 2003) - Minor FAQ updates - Update contrib/minizip to 1.00 [Vollant] - Remove test of gz functions in example.c when GZ_COMPRESS defined [Truta] - Update POSTINC comment for 68060 [Nikl] - Add contrib/infback9 with deflate64 decoding (unsupported) - For MVS define NO_vsnprintf and undefine FAR [van Burik] - Add pragma for fdopen on MVS [van Burik] Changes in 1.2.0.5 (8 September 2003) - Add OF to inflateBackEnd() declaration in zlib.h - Remember start when using gzdopen in the middle of a file - Use internal off_t counters in gz* functions to properly handle seeks - Perform more rigorous check for distance-too-far in inffast.c - Add Z_BLOCK flush option to return from inflate at block boundary - Set strm->data_type on return from inflate - Indicate bits unused, if at block boundary, and if in last block - Replace size_t with ptrdiff_t in crc32.c, and check for correct size - Add condition so old NO_DEFLATE define still works for compatibility - FAQ update regarding the Windows DLL [Truta] - INDEX update: add qnx entry, remove aix entry [Truta] - Install zlib.3 into mandir [Wilson] - Move contrib/zlib_dll_FAQ.txt to win32/DLL_FAQ.txt; update [Truta] - Adapt the zlib interface to the new DLL convention guidelines [Truta] - Introduce ZLIB_WINAPI macro to allow the export of functions using the WINAPI calling convention, for Visual Basic [Vollant, Truta] - Update msdos and win32 scripts and makefiles [Truta] - Export symbols by name, not by ordinal, in win32/zlib.def [Truta] - Add contrib/ada [Anisimkov] - Move asm files from contrib/vstudio/vc70_32 to contrib/asm386 [Truta] - Rename contrib/asm386 to contrib/masmx86 [Truta, Vollant] - Add contrib/masm686 [Truta] - Fix offsets in contrib/inflate86 and contrib/masmx86/inffas32.asm [Truta, Vollant] - Update contrib/delphi; rename to contrib/pascal; add example [Truta] - Remove contrib/delphi2; add a new contrib/delphi [Truta] - Avoid inclusion of the nonstandard in contrib/iostream, and fix some method prototypes [Truta] - Fix the ZCR_SEED2 constant to avoid warnings in contrib/minizip [Truta] - Avoid the use of backslash (\) in contrib/minizip [Vollant] - Fix file time handling in contrib/untgz; update makefiles [Truta] - Update contrib/vstudio/vc70_32 to comply with the new DLL guidelines [Vollant] - Remove contrib/vstudio/vc15_16 [Vollant] - Rename contrib/vstudio/vc70_32 to contrib/vstudio/vc7 [Truta] - Update README.contrib [Truta] - Invert the assignment order of match_head and s->prev[...] in INSERT_STRING [Truta] - Compare TOO_FAR with 32767 instead of 32768, to avoid 16-bit warnings [Truta] - Compare function pointers with 0, not with NULL or Z_NULL [Truta] - Fix prototype of syncsearch in inflate.c [Truta] - Introduce ASMINF macro to be enabled when using an ASM implementation of inflate_fast [Truta] - Change NO_DEFLATE to NO_GZCOMPRESS [Truta] - Modify test_gzio in example.c to take a single file name as a parameter [Truta] - Exit the example.c program if gzopen fails [Truta] - Add type casts around strlen in example.c [Truta] - Remove casting to sizeof in minigzip.c; give a proper type to the variable compared with SUFFIX_LEN [Truta] - Update definitions of STDC and STDC99 in zconf.h [Truta] - Synchronize zconf.h with the new Windows DLL interface [Truta] - Use SYS16BIT instead of __32BIT__ to distinguish between 16- and 32-bit platforms [Truta] - Use far memory allocators in small 16-bit memory models for Turbo C [Truta] - Add info about the use of ASMV, ASMINF and ZLIB_WINAPI in zlibCompileFlags [Truta] - Cygwin has vsnprintf [Wilson] - In Windows16, OS_CODE is 0, as in MSDOS [Truta] - In Cygwin, OS_CODE is 3 (Unix), not 11 (Windows32) [Wilson] Changes in 1.2.0.4 (10 August 2003) - Minor FAQ updates - Be more strict when checking inflateInit2's windowBits parameter - Change NO_GUNZIP compile option to NO_GZIP to cover deflate as well - Add gzip wrapper option to deflateInit2 using windowBits - Add updated QNX rule in configure and qnx directory [Bonnefoy] - Make inflate distance-too-far checks more rigorous - Clean up FAR usage in inflate - Add casting to sizeof() in gzio.c and minigzip.c Changes in 1.2.0.3 (19 July 2003) - Fix silly error in gzungetc() implementation [Vollant] - Update contrib/minizip and contrib/vstudio [Vollant] - Fix printf format in example.c - Correct cdecl support in zconf.in.h [Anisimkov] - Minor FAQ updates Changes in 1.2.0.2 (13 July 2003) - Add ZLIB_VERNUM in zlib.h for numerical preprocessor comparisons - Attempt to avoid warnings in crc32.c for pointer-int conversion - Add AIX to configure, remove aix directory [Bakker] - Add some casts to minigzip.c - Improve checking after insecure sprintf() or vsprintf() calls - Remove #elif's from crc32.c - Change leave label to inf_leave in inflate.c and infback.c to avoid library conflicts - Remove inflate gzip decoding by default--only enable gzip decoding by special request for stricter backward compatibility - Add zlibCompileFlags() function to return compilation information - More typecasting in deflate.c to avoid warnings - Remove leading underscore from _Capital #defines [Truta] - Fix configure to link shared library when testing - Add some Windows CE target adjustments [Mai] - Remove #define ZLIB_DLL in zconf.h [Vollant] - Add zlib.3 [Rodgers] - Update RFC URL in deflate.c and algorithm.txt [Mai] - Add zlib_dll_FAQ.txt to contrib [Truta] - Add UL to some constants [Truta] - Update minizip and vstudio [Vollant] - Remove vestigial NEED_DUMMY_RETURN from zconf.in.h - Expand use of NO_DUMMY_DECL to avoid all dummy structures - Added iostream3 to contrib [Schwardt] - Replace rewind() with fseek() for WinCE [Truta] - Improve setting of zlib format compression level flags - Report 0 for huffman and rle strategies and for level == 0 or 1 - Report 2 only for level == 6 - Only deal with 64K limit when necessary at compile time [Truta] - Allow TOO_FAR check to be turned off at compile time [Truta] - Add gzclearerr() function [Souza] - Add gzungetc() function Changes in 1.2.0.1 (17 March 2003) - Add Z_RLE strategy for run-length encoding [Truta] - When Z_RLE requested, restrict matches to distance one - Update zlib.h, minigzip.c, gzopen(), gzdopen() for Z_RLE - Correct FASTEST compilation to allow level == 0 - Clean up what gets compiled for FASTEST - Incorporate changes to zconf.in.h [Vollant] - Refine detection of Turbo C need for dummy returns - Refine ZLIB_DLL compilation - Include additional header file on VMS for off_t typedef - Try to use _vsnprintf where it supplants vsprintf [Vollant] - Add some casts in inffast.c - Enchance comments in zlib.h on what happens if gzprintf() tries to write more than 4095 bytes before compression - Remove unused state from inflateBackEnd() - Remove exit(0) from minigzip.c, example.c - Get rid of all those darn tabs - Add "check" target to Makefile.in that does the same thing as "test" - Add "mostlyclean" and "maintainer-clean" targets to Makefile.in - Update contrib/inflate86 [Anderson] - Update contrib/testzlib, contrib/vstudio, contrib/minizip [Vollant] - Add msdos and win32 directories with makefiles [Truta] - More additions and improvements to the FAQ Changes in 1.2.0 (9 March 2003) - New and improved inflate code - About 20% faster - Does not allocate 32K window unless and until needed - Automatically detects and decompresses gzip streams - Raw inflate no longer needs an extra dummy byte at end - Added inflateBack functions using a callback interface--even faster than inflate, useful for file utilities (gzip, zip) - Added inflateCopy() function to record state for random access on externally generated deflate streams (e.g. in gzip files) - More readable code (I hope) - New and improved crc32() - About 50% faster, thanks to suggestions from Rodney Brown - Add deflateBound() and compressBound() functions - Fix memory leak in deflateInit2() - Permit setting dictionary for raw deflate (for parallel deflate) - Fix const declaration for gzwrite() - Check for some malloc() failures in gzio.c - Fix bug in gzopen() on single-byte file 0x1f - Fix bug in gzread() on concatenated file with 0x1f at end of buffer and next buffer doesn't start with 0x8b - Fix uncompress() to return Z_DATA_ERROR on truncated input - Free memory at end of example.c - Remove MAX #define in trees.c (conflicted with some libraries) - Fix static const's in deflate.c, gzio.c, and zutil.[ch] - Declare malloc() and free() in gzio.c if STDC not defined - Use malloc() instead of calloc() in zutil.c if int big enough - Define STDC for AIX - Add aix/ with approach for compiling shared library on AIX - Add HP-UX support for shared libraries in configure - Add OpenUNIX support for shared libraries in configure - Use $cc instead of gcc to build shared library - Make prefix directory if needed when installing - Correct Macintosh avoidance of typedef Byte in zconf.h - Correct Turbo C memory allocation when under Linux - Use libz.a instead of -lz in Makefile (assure use of compiled library) - Update configure to check for snprintf or vsnprintf functions and their return value, warn during make if using an insecure function - Fix configure problem with compile-time knowledge of HAVE_UNISTD_H that is lost when library is used--resolution is to build new zconf.h - Documentation improvements (in zlib.h): - Document raw deflate and inflate - Update RFCs URL - Point out that zlib and gzip formats are different - Note that Z_BUF_ERROR is not fatal - Document string limit for gzprintf() and possible buffer overflow - Note requirement on avail_out when flushing - Note permitted values of flush parameter of inflate() - Add some FAQs (and even answers) to the FAQ - Add contrib/inflate86/ for x86 faster inflate - Add contrib/blast/ for PKWare Data Compression Library decompression - Add contrib/puff/ simple inflate for deflate format description Changes in 1.1.4 (11 March 2002) - ZFREE was repeated on same allocation on some error conditions. This creates a security problem described in http://www.zlib.org/advisory-2002-03-11.txt - Returned incorrect error (Z_MEM_ERROR) on some invalid data - Avoid accesses before window for invalid distances with inflate window less than 32K. - force windowBits > 8 to avoid a bug in the encoder for a window size of 256 bytes. (A complete fix will be available in 1.1.5). Changes in 1.1.3 (9 July 1998) - fix "an inflate input buffer bug that shows up on rare but persistent occasions" (Mark) - fix gzread and gztell for concatenated .gz files (Didier Le Botlan) - fix gzseek(..., SEEK_SET) in write mode - fix crc check after a gzeek (Frank Faubert) - fix miniunzip when the last entry in a zip file is itself a zip file (J Lillge) - add contrib/asm586 and contrib/asm686 (Brian Raiter) See http://www.muppetlabs.com/~breadbox/software/assembly.html - add support for Delphi 3 in contrib/delphi (Bob Dellaca) - add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti) - do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren) - use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks) - added a FAQ file - Support gzdopen on Mac with Metrowerks (Jason Linhart) - Do not redefine Byte on Mac (Brad Pettit & Jason Linhart) - define SEEK_END too if SEEK_SET is not defined (Albert Chin-A-Young) - avoid some warnings with Borland C (Tom Tanner) - fix a problem in contrib/minizip/zip.c for 16-bit MSDOS (Gilles Vollant) - emulate utime() for WIN32 in contrib/untgz (Gilles Vollant) - allow several arguments to configure (Tim Mooney, Frodo Looijaard) - use libdir and includedir in Makefile.in (Tim Mooney) - support shared libraries on OSF1 V4 (Tim Mooney) - remove so_locations in "make clean" (Tim Mooney) - fix maketree.c compilation error (Glenn, Mark) - Python interface to zlib now in Python 1.5 (Jeremy Hylton) - new Makefile.riscos (Rich Walker) - initialize static descriptors in trees.c for embedded targets (Nick Smith) - use "foo-gz" in example.c for RISCOS and VMS (Nick Smith) - add the OS/2 files in Makefile.in too (Andrew Zabolotny) - fix fdopen and halloc macros for Microsoft C 6.0 (Tom Lane) - fix maketree.c to allow clean compilation of inffixed.h (Mark) - fix parameter check in deflateCopy (Gunther Nikl) - cleanup trees.c, use compressed_len only in debug mode (Christian Spieler) - Many portability patches by Christian Spieler: . zutil.c, zutil.h: added "const" for zmem* . Make_vms.com: fixed some typos . Make_vms.com: msdos/Makefile.*: removed zutil.h from some dependency lists . msdos/Makefile.msc: remove "default rtl link library" info from obj files . msdos/Makefile.*: use model-dependent name for the built zlib library . msdos/Makefile.emx, nt/Makefile.emx, nt/Makefile.gcc: new makefiles, for emx (DOS/OS2), emx&rsxnt and mingw32 (Windows 9x / NT) - use define instead of typedef for Bytef also for MSC small/medium (Tom Lane) - replace __far with _far for better portability (Christian Spieler, Tom Lane) - fix test for errno.h in configure (Tim Newsham) Changes in 1.1.2 (19 March 98) - added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant) See http://www.winimage.com/zLibDll/unzip.html - preinitialize the inflate tables for fixed codes, to make the code completely thread safe (Mark) - some simplifications and slight speed-up to the inflate code (Mark) - fix gzeof on non-compressed files (Allan Schrum) - add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs) - use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn) - added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny) - add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori) - do not wrap extern "C" around system includes (Tom Lane) - mention zlib binding for TCL in README (Andreas Kupries) - added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert) - allow "make install prefix=..." even after configure (Glenn Randers-Pehrson) - allow "configure --prefix $HOME" (Tim Mooney) - remove warnings in example.c and gzio.c (Glenn Randers-Pehrson) - move Makefile.sas to amiga/Makefile.sas Changes in 1.1.1 (27 Feb 98) - fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson) - remove block truncation heuristic which had very marginal effect for zlib (smaller lit_bufsize than in gzip 1.2.4) and degraded a little the compression ratio on some files. This also allows inlining _tr_tally for matches in deflate_slow. - added msdos/Makefile.w32 for WIN32 Microsoft Visual C++ (Bob Frazier) Changes in 1.1.0 (24 Feb 98) - do not return STREAM_END prematurely in inflate (John Bowler) - revert to the zlib 1.0.8 inflate to avoid the gcc 2.8.0 bug (Jeremy Buhler) - compile with -DFASTEST to get compression code optimized for speed only - in minigzip, try mmap'ing the input file first (Miguel Albrecht) - increase size of I/O buffers in minigzip.c and gzio.c (not a big gain on Sun but significant on HP) - add a pointer to experimental unzip library in README (Gilles Vollant) - initialize variable gcc in configure (Chris Herborth) Changes in 1.0.9 (17 Feb 1998) - added gzputs and gzgets functions - do not clear eof flag in gzseek (Mark Diekhans) - fix gzseek for files in transparent mode (Mark Diekhans) - do not assume that vsprintf returns the number of bytes written (Jens Krinke) - replace EXPORT with ZEXPORT to avoid conflict with other programs - added compress2 in zconf.h, zlib.def, zlib.dnt - new asm code from Gilles Vollant in contrib/asm386 - simplify the inflate code (Mark): . Replace ZALLOC's in huft_build() with single ZALLOC in inflate_blocks_new() . ZALLOC the length list in inflate_trees_fixed() instead of using stack . ZALLOC the value area for huft_build() instead of using stack . Simplify Z_FINISH check in inflate() - Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8 - in inftrees.c, avoid cc -O bug on HP (Farshid Elahi) - in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with the declaration of FAR (Gilles VOllant) - install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann) - read_buf buf parameter of type Bytef* instead of charf* - zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout) - do not redeclare unlink in minigzip.c for WIN32 (John Bowler) - fix check for presence of directories in "make install" (Ian Willis) Changes in 1.0.8 (27 Jan 1998) - fixed offsets in contrib/asm386/gvmat32.asm (Gilles Vollant) - fix gzgetc and gzputc for big endian systems (Markus Oberhumer) - added compress2() to allow setting the compression level - include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong) - use constant arrays for the static trees in trees.c instead of computing them at run time (thanks to Ken Raeburn for this suggestion). To create trees.h, compile with GEN_TREES_H and run "make test". - check return code of example in "make test" and display result - pass minigzip command line options to file_compress - simplifying code of inflateSync to avoid gcc 2.8 bug - support CC="gcc -Wall" in configure -s (QingLong) - avoid a flush caused by ftell in gzopen for write mode (Ken Raeburn) - fix test for shared library support to avoid compiler warnings - zlib.lib -> zlib.dll in msdos/zlib.rc (Gilles Vollant) - check for TARGET_OS_MAC in addition to MACOS (Brad Pettit) - do not use fdopen for Metrowerks on Mac (Brad Pettit)) - add checks for gzputc and gzputc in example.c - avoid warnings in gzio.c and deflate.c (Andreas Kleinert) - use const for the CRC table (Ken Raeburn) - fixed "make uninstall" for shared libraries - use Tracev instead of Trace in infblock.c - in example.c use correct compressed length for test_sync - suppress +vnocompatwarnings in configure for HPUX (not always supported) Changes in 1.0.7 (20 Jan 1998) - fix gzseek which was broken in write mode - return error for gzseek to negative absolute position - fix configure for Linux (Chun-Chung Chen) - increase stack space for MSC (Tim Wegner) - get_crc_table and inflateSyncPoint are EXPORTed (Gilles Vollant) - define EXPORTVA for gzprintf (Gilles Vollant) - added man page zlib.3 (Rick Rodgers) - for contrib/untgz, fix makedir() and improve Makefile - check gzseek in write mode in example.c - allocate extra buffer for seeks only if gzseek is actually called - avoid signed/unsigned comparisons (Tim Wegner, Gilles Vollant) - add inflateSyncPoint in zconf.h - fix list of exported functions in nt/zlib.dnt and mdsos/zlib.def Changes in 1.0.6 (19 Jan 1998) - add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code) - Fix a deflate bug occurring only with compression level 0 (thanks to Andy Buckler for finding this one). - In minigzip, pass transparently also the first byte for .Z files. - return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress() - check Z_FINISH in inflate (thanks to Marc Schluper) - Implement deflateCopy (thanks to Adam Costello) - make static libraries by default in configure, add --shared option. - move MSDOS or Windows specific files to directory msdos - suppress the notion of partial flush to simplify the interface (but the symbol Z_PARTIAL_FLUSH is kept for compatibility with 1.0.4) - suppress history buffer provided by application to simplify the interface (this feature was not implemented anyway in 1.0.4) - next_in and avail_in must be initialized before calling inflateInit or inflateInit2 - add EXPORT in all exported functions (for Windows DLL) - added Makefile.nt (thanks to Stephen Williams) - added the unsupported "contrib" directory: contrib/asm386/ by Gilles Vollant 386 asm code replacing longest_match(). contrib/iostream/ by Kevin Ruland A C++ I/O streams interface to the zlib gz* functions contrib/iostream2/ by Tyge Løvset Another C++ I/O streams interface contrib/untgz/ by "Pedro A. Aranda Guti\irrez" A very simple tar.gz file extractor using zlib contrib/visual-basic.txt by Carlos Rios How to use compress(), uncompress() and the gz* functions from VB. - pass params -f (filtered data), -h (huffman only), -1 to -9 (compression level) in minigzip (thanks to Tom Lane) - use const for rommable constants in deflate - added test for gzseek and gztell in example.c - add undocumented function inflateSyncPoint() (hack for Paul Mackerras) - add undocumented function zError to convert error code to string (for Tim Smithers) - Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code. - Use default memcpy for Symantec MSDOS compiler. - Add EXPORT keyword for check_func (needed for Windows DLL) - add current directory to LD_LIBRARY_PATH for "make test" - create also a link for libz.so.1 - added support for FUJITSU UXP/DS (thanks to Toshiaki Nomura) - use $(SHAREDLIB) instead of libz.so in Makefile.in (for HPUX) - added -soname for Linux in configure (Chun-Chung Chen, - assign numbers to the exported functions in zlib.def (for Windows DLL) - add advice in zlib.h for best usage of deflateSetDictionary - work around compiler bug on Atari (cast Z_NULL in call of s->checkfn) - allow compilation with ANSI keywords only enabled for TurboC in large model - avoid "versionString"[0] (Borland bug) - add NEED_DUMMY_RETURN for Borland - use variable z_verbose for tracing in debug mode (L. Peter Deutsch). - allow compilation with CC - defined STDC for OS/2 (David Charlap) - limit external names to 8 chars for MVS (Thomas Lund) - in minigzip.c, use static buffers only for 16-bit systems - fix suffix check for "minigzip -d foo.gz" - do not return an error for the 2nd of two consecutive gzflush() (Felix Lee) - use _fdopen instead of fdopen for MSC >= 6.0 (Thomas Fanslau) - added makelcc.bat for lcc-win32 (Tom St Denis) - in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe) - Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion. - check for unistd.h in configure (for off_t) - remove useless check parameter in inflate_blocks_free - avoid useless assignment of s->check to itself in inflate_blocks_new - do not flush twice in gzclose (thanks to Ken Raeburn) - rename FOPEN as F_OPEN to avoid clash with /usr/include/sys/file.h - use NO_ERRNO_H instead of enumeration of operating systems with errno.h - work around buggy fclose on pipes for HP/UX - support zlib DLL with BORLAND C++ 5.0 (thanks to Glenn Randers-Pehrson) - fix configure if CC is already equal to gcc Changes in 1.0.5 (3 Jan 98) - Fix inflate to terminate gracefully when fed corrupted or invalid data - Use const for rommable constants in inflate - Eliminate memory leaks on error conditions in inflate - Removed some vestigial code in inflate - Update web address in README Changes in 1.0.4 (24 Jul 96) - In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF bit, so the decompressor could decompress all the correct data but went on to attempt decompressing extra garbage data. This affected minigzip too. - zlibVersion and gzerror return const char* (needed for DLL) - port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno) - use z_error only for DEBUG (avoid problem with DLLs) Changes in 1.0.3 (2 Jul 96) - use z_streamp instead of z_stream *, which is now a far pointer in MSDOS small and medium models; this makes the library incompatible with previous versions for these models. (No effect in large model or on other systems.) - return OK instead of BUF_ERROR if previous deflate call returned with avail_out as zero but there is nothing to do - added memcmp for non STDC compilers - define NO_DUMMY_DECL for more Mac compilers (.h files merged incorrectly) - define __32BIT__ if __386__ or i386 is defined (pb. with Watcom and SCO) - better check for 16-bit mode MSC (avoids problem with Symantec) Changes in 1.0.2 (23 May 96) - added Windows DLL support - added a function zlibVersion (for the DLL support) - fixed declarations using Bytef in infutil.c (pb with MSDOS medium model) - Bytef is define's instead of typedef'd only for Borland C - avoid reading uninitialized memory in example.c - mention in README that the zlib format is now RFC1950 - updated Makefile.dj2 - added algorithm.doc Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion] - fix array overlay in deflate.c which sometimes caused bad compressed data - fix inflate bug with empty stored block - fix MSDOS medium model which was broken in 0.99 - fix deflateParams() which could generated bad compressed data. - Bytef is define'd instead of typedef'ed (work around Borland bug) - added an INDEX file - new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32), Watcom (Makefile.wat), Amiga SAS/C (Makefile.sas) - speed up adler32 for modern machines without auto-increment - added -ansi for IRIX in configure - static_init_done in trees.c is an int - define unlink as delete for VMS - fix configure for QNX - add configure branch for SCO and HPUX - avoid many warnings (unused variables, dead assignments, etc...) - no fdopen for BeOS - fix the Watcom fix for 32 bit mode (define FAR as empty) - removed redefinition of Byte for MKWERKS - work around an MWKERKS bug (incorrect merge of all .h files) Changes in 0.99 (27 Jan 96) - allow preset dictionary shared between compressor and decompressor - allow compression level 0 (no compression) - add deflateParams in zlib.h: allow dynamic change of compression level and compression strategy. - test large buffers and deflateParams in example.c - add optional "configure" to build zlib as a shared library - suppress Makefile.qnx, use configure instead - fixed deflate for 64-bit systems (detected on Cray) - fixed inflate_blocks for 64-bit systems (detected on Alpha) - declare Z_DEFLATED in zlib.h (possible parameter for deflateInit2) - always return Z_BUF_ERROR when deflate() has nothing to do - deflateInit and inflateInit are now macros to allow version checking - prefix all global functions and types with z_ with -DZ_PREFIX - make falloc completely reentrant (inftrees.c) - fixed very unlikely race condition in ct_static_init - free in reverse order of allocation to help memory manager - use zlib-1.0/* instead of zlib/* inside the tar.gz - make zlib warning-free with "gcc -O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion -Wstrict-prototypes -Wmissing-prototypes" - allow gzread on concatenated .gz files - deflateEnd now returns Z_DATA_ERROR if it was premature - deflate is finally (?) fully deterministic (no matches beyond end of input) - Document Z_SYNC_FLUSH - add uninstall in Makefile - Check for __cpluplus in zlib.h - Better test in ct_align for partial flush - avoid harmless warnings for Borland C++ - initialize hash_head in deflate.c - avoid warning on fdopen (gzio.c) for HP cc -Aa - include stdlib.h for STDC compilers - include errno.h for Cray - ignore error if ranlib doesn't exist - call ranlib twice for NeXTSTEP - use exec_prefix instead of prefix for libz.a - renamed ct_* as _tr_* to avoid conflict with applications - clear z->msg in inflateInit2 before any error return - initialize opaque in example.c, gzio.c, deflate.c and inflate.c - fixed typo in zconf.h (_GNUC__ => __GNUC__) - check for WIN32 in zconf.h and zutil.c (avoid farmalloc in 32-bit mode) - fix typo in Make_vms.com (f$trnlnm -> f$getsyi) - in fcalloc, normalize pointer if size > 65520 bytes - don't use special fcalloc for 32 bit Borland C++ - use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc... - use Z_BINARY instead of BINARY - document that gzclose after gzdopen will close the file - allow "a" as mode in gzopen. - fix error checking in gzread - allow skipping .gz extra-field on pipes - added reference to Perl interface in README - put the crc table in FAR data (I dislike more and more the medium model :) - added get_crc_table - added a dimension to all arrays (Borland C can't count). - workaround Borland C bug in declaration of inflate_codes_new & inflate_fast - guard against multiple inclusion of *.h (for precompiled header on Mac) - Watcom C pretends to be Microsoft C small model even in 32 bit mode. - don't use unsized arrays to avoid silly warnings by Visual C++: warning C4746: 'inflate_mask' : unsized array treated as '__far' (what's wrong with far data in far model?). - define enum out of inflate_blocks_state to allow compilation with C++ Changes in 0.95 (16 Aug 95) - fix MSDOS small and medium model (now easier to adapt to any compiler) - inlined send_bits - fix the final (:-) bug for deflate with flush (output was correct but not completely flushed in rare occasions). - default window size is same for compression and decompression (it's now sufficient to set MAX_WBITS in zconf.h). - voidp -> voidpf and voidnp -> voidp (for consistency with other typedefs and because voidnp was not near in large model). Changes in 0.94 (13 Aug 95) - support MSDOS medium model - fix deflate with flush (could sometimes generate bad output) - fix deflateReset (zlib header was incorrectly suppressed) - added support for VMS - allow a compression level in gzopen() - gzflush now calls fflush - For deflate with flush, flush even if no more input is provided. - rename libgz.a as libz.a - avoid complex expression in infcodes.c triggering Turbo C bug - work around a problem with gcc on Alpha (in INSERT_STRING) - don't use inline functions (problem with some gcc versions) - allow renaming of Byte, uInt, etc... with #define. - avoid warning about (unused) pointer before start of array in deflate.c - avoid various warnings in gzio.c, example.c, infblock.c, adler32.c, zutil.c - avoid reserved word 'new' in trees.c Changes in 0.93 (25 June 95) - temporarily disable inline functions - make deflate deterministic - give enough lookahead for PARTIAL_FLUSH - Set binary mode for stdin/stdout in minigzip.c for OS/2 - don't even use signed char in inflate (not portable enough) - fix inflate memory leak for segmented architectures Changes in 0.92 (3 May 95) - don't assume that char is signed (problem on SGI) - Clear bit buffer when starting a stored block - no memcpy on Pyramid - suppressed inftest.c - optimized fill_window, put longest_match inline for gcc - optimized inflate on stored blocks. - untabify all sources to simplify patches Changes in 0.91 (2 May 95) - Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h - Document the memory requirements in zconf.h - added "make install" - fix sync search logic in inflateSync - deflate(Z_FULL_FLUSH) now works even if output buffer too short - after inflateSync, don't scare people with just "lo world" - added support for DJGPP Changes in 0.9 (1 May 95) - don't assume that zalloc clears the allocated memory (the TurboC bug was Mark's bug after all :) - let again gzread copy uncompressed data unchanged (was working in 0.71) - deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented - added a test of inflateSync in example.c - moved MAX_WBITS to zconf.h because users might want to change that. - document explicitly that zalloc(64K) on MSDOS must return a normalized pointer (zero offset) - added Makefiles for Microsoft C, Turbo C, Borland C++ - faster crc32() Changes in 0.8 (29 April 95) - added fast inflate (inffast.c) - deflate(Z_FINISH) now returns Z_STREAM_END when done. Warning: this is incompatible with previous versions of zlib which returned Z_OK. - work around a TurboC compiler bug (bad code for b << 0, see infutil.h) (actually that was not a compiler bug, see 0.81 above) - gzread no longer reads one extra byte in certain cases - In gzio destroy(), don't reference a freed structure - avoid many warnings for MSDOS - avoid the ERROR symbol which is used by MS Windows Changes in 0.71 (14 April 95) - Fixed more MSDOS compilation problems :( There is still a bug with TurboC large model. Changes in 0.7 (14 April 95) - Added full inflate support. - Simplified the crc32() interface. The pre- and post-conditioning (one's complement) is now done inside crc32(). WARNING: this is incompatible with previous versions; see zlib.h for the new usage. Changes in 0.61 (12 April 95) - workaround for a bug in TurboC. example and minigzip now work on MSDOS. Changes in 0.6 (11 April 95) - added minigzip.c - added gzdopen to reopen a file descriptor as gzFile - added transparent reading of non-gziped files in gzread. - fixed bug in gzread (don't read crc as data) - fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose). - don't allocate big arrays in the stack (for MSDOS) - fix some MSDOS compilation problems Changes in 0.5: - do real compression in deflate.c. Z_PARTIAL_FLUSH is supported but not yet Z_FULL_FLUSH. - support decompression but only in a single step (forced Z_FINISH) - added opaque object for zalloc and zfree. - added deflateReset and inflateReset - added a variable zlib_version for consistency checking. - renamed the 'filter' parameter of deflateInit2 as 'strategy'. Added Z_FILTERED and Z_HUFFMAN_ONLY constants. Changes in 0.4: - avoid "zip" everywhere, use zlib instead of ziplib. - suppress Z_BLOCK_FLUSH, interpret Z_PARTIAL_FLUSH as block flush if compression method == 8. - added adler32 and crc32 - renamed deflateOptions as deflateInit2, call one or the other but not both - added the method parameter for deflateInit2. - added inflateInit2 - simplied considerably deflateInit and inflateInit by not supporting user-provided history buffer. This is supported only in deflateInit2 and inflateInit2. Changes in 0.3: - prefix all macro names with Z_ - use Z_FINISH instead of deflateEnd to finish compression. - added Z_HUFFMAN_ONLY - added gzerror() sks-ecc-0.93/zlib/configure0000755000175000017500000003155710604550750014623 0ustar nachonacho#!/bin/sh # configure script for zlib. This script is needed only if # you wish to build a shared library and your system supports them, # of if you need special compiler, flags or install directory. # Otherwise, you can just use directly "make test; make install" # # To create a shared library, use "configure --shared"; by default a static # library is created. If the primitive shared library support provided here # does not work, use ftp://prep.ai.mit.edu/pub/gnu/libtool-*.tar.gz # # To impose specific compiler or flags or install directory, use for example: # prefix=$HOME CC=cc CFLAGS="-O4" ./configure # or for csh/tcsh users: # (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure) # LDSHARED is the command to be used to create a shared library # Incorrect settings of CC or CFLAGS may prevent creating a shared library. # If you have problems, try without defining CC and CFLAGS before reporting # an error. LIBS=libz.a LDFLAGS="-L. ${LIBS}" VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h` VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h` VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h` AR=${AR-"ar rc"} RANLIB=${RANLIB-"ranlib"} prefix=${prefix-/usr/local} exec_prefix=${exec_prefix-'${prefix}'} libdir=${libdir-'${exec_prefix}/lib'} includedir=${includedir-'${prefix}/include'} mandir=${mandir-'${prefix}/share/man'} shared_ext='.so' shared=0 gcc=0 old_cc="$CC" old_cflags="$CFLAGS" while test $# -ge 1 do case "$1" in -h* | --h*) echo 'usage:' echo ' configure [--shared] [--prefix=PREFIX] [--exec_prefix=EXPREFIX]' echo ' [--libdir=LIBDIR] [--includedir=INCLUDEDIR]' exit 0;; -p*=* | --p*=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;; -e*=* | --e*=*) exec_prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;; -l*=* | --libdir=*) libdir=`echo $1 | sed 's/[-a-z_]*=//'`; shift;; -i*=* | --includedir=*) includedir=`echo $1 | sed 's/[-a-z_]*=//'`;shift;; -p* | --p*) prefix="$2"; shift; shift;; -e* | --e*) exec_prefix="$2"; shift; shift;; -l* | --l*) libdir="$2"; shift; shift;; -i* | --i*) includedir="$2"; shift; shift;; -s* | --s*) shared=1; shift;; *) echo "unknown option: $1"; echo "$0 --help for help"; exit 1;; esac done test=ztest$$ cat > $test.c </dev/null; then CC="$cc" SFLAGS=${CFLAGS-"-fPIC -O3"} CFLAGS="$cflags" case `(uname -s || echo unknown) 2>/dev/null` in Linux | linux | GNU | GNU/*) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};; CYGWIN* | Cygwin* | cygwin* | OS/2* ) EXE='.exe';; QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4 # (alain.bonnefoy@icbt.com) LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"};; HP-UX*) LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"} case `(uname -m || echo unknown) 2>/dev/null` in ia64) shared_ext='.so' SHAREDLIB='libz.so';; *) shared_ext='.sl' SHAREDLIB='libz.sl';; esac;; Darwin*) shared_ext='.dylib' SHAREDLIB=libz$shared_ext SHAREDLIBV=libz.$VER$shared_ext SHAREDLIBM=libz.$VER1$shared_ext LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER"};; *) LDSHARED=${LDSHARED-"$cc -shared"};; esac else # find system name and corresponding cc options CC=${CC-cc} case `(uname -sr || echo unknown) 2>/dev/null` in HP-UX*) SFLAGS=${CFLAGS-"-O +z"} CFLAGS=${CFLAGS-"-O"} # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"} LDSHARED=${LDSHARED-"ld -b"} case `(uname -m || echo unknown) 2>/dev/null` in ia64) shared_ext='.so' SHAREDLIB='libz.so';; *) shared_ext='.sl' SHAREDLIB='libz.sl';; esac;; IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."} CFLAGS=${CFLAGS-"-ansi -O2"} LDSHARED=${LDSHARED-"cc -shared"};; OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"} CFLAGS=${CFLAGS-"-O -std1"} LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"};; OSF1*) SFLAGS=${CFLAGS-"-O -std1"} CFLAGS=${CFLAGS-"-O -std1"} LDSHARED=${LDSHARED-"cc -shared"};; QNX*) SFLAGS=${CFLAGS-"-4 -O"} CFLAGS=${CFLAGS-"-4 -O"} LDSHARED=${LDSHARED-"cc"} RANLIB=${RANLIB-"true"} AR="cc -A";; SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "} CFLAGS=${CFLAGS-"-O3"} LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};; SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."} CFLAGS=${CFLAGS-"-fast -xcg89"} LDSHARED=${LDSHARED-"cc -G"};; SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"} CFLAGS=${CFLAGS-"-O2"} LDSHARED=${LDSHARED-"ld"};; SunStudio\ 9*) SFLAGS=${CFLAGS-"-DUSE_MMAP -fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"} CFLAGS=${CFLAGS-"-DUSE_MMAP -fast -xtarget=ultra3 -xarch=v9b"} LDSHARED=${LDSHARED-"cc -xarch=v9b"};; UNIX_System_V\ 4.2.0) SFLAGS=${CFLAGS-"-KPIC -O"} CFLAGS=${CFLAGS-"-O"} LDSHARED=${LDSHARED-"cc -G"};; UNIX_SV\ 4.2MP) SFLAGS=${CFLAGS-"-Kconform_pic -O"} CFLAGS=${CFLAGS-"-O"} LDSHARED=${LDSHARED-"cc -G"};; OpenUNIX\ 5) SFLAGS=${CFLAGS-"-KPIC -O"} CFLAGS=${CFLAGS-"-O"} LDSHARED=${LDSHARED-"cc -G"};; AIX*) # Courtesy of dbakker@arrayasolutions.com SFLAGS=${CFLAGS-"-O -qmaxmem=8192"} CFLAGS=${CFLAGS-"-O -qmaxmem=8192"} LDSHARED=${LDSHARED-"xlc -G"};; # send working options for other systems to support@gzip.org *) SFLAGS=${CFLAGS-"-O"} CFLAGS=${CFLAGS-"-O"} LDSHARED=${LDSHARED-"cc -shared"};; esac fi SHAREDLIB=${SHAREDLIB-"libz$shared_ext"} SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"} SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"} if test $shared -eq 1; then echo Checking for shared library support... # we must test in two steps (cc then ld), required at least on SunOS 4.x if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" && test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then CFLAGS="$SFLAGS" LIBS="$SHAREDLIBV" echo Building shared library $SHAREDLIBV with $CC. elif test -z "$old_cc" -a -z "$old_cflags"; then echo No shared library support. shared=0; else echo 'No shared library support; try without defining CC and CFLAGS' shared=0; fi fi if test $shared -eq 0; then LDSHARED="$CC" echo Building static library $LIBS version $VER with $CC. else LDFLAGS="-L. ${SHAREDLIBV}" fi cat > $test.c < int main() { return 0; } EOF if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then sed < zconf.in.h "/HAVE_UNISTD_H/s%0%1%" > zconf.h echo "Checking for unistd.h... Yes." else cp -p zconf.in.h zconf.h echo "Checking for unistd.h... No." fi cat > $test.c < #include #include "zconf.h" int main() { #ifndef STDC choke me #endif return 0; } EOF if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()" cat > $test.c < #include int mytest(char *fmt, ...) { char buf[20]; va_list ap; va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); return 0; } int main() { return (mytest("Hello%d\n", 1)); } EOF if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then echo "Checking for vsnprintf() in stdio.h... Yes." cat >$test.c < #include int mytest(char *fmt, ...) { int n; char buf[20]; va_list ap; va_start(ap, fmt); n = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); return n; } int main() { return (mytest("Hello%d\n", 1)); } EOF if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then echo "Checking for return value of vsnprintf()... Yes." else CFLAGS="$CFLAGS -DHAS_vsnprintf_void" echo "Checking for return value of vsnprintf()... No." echo " WARNING: apparently vsnprintf() does not return a value. zlib" echo " can build but will be open to possible string-format security" echo " vulnerabilities." fi else CFLAGS="$CFLAGS -DNO_vsnprintf" echo "Checking for vsnprintf() in stdio.h... No." echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" echo " can build but will be open to possible buffer-overflow security" echo " vulnerabilities." cat >$test.c < #include int mytest(char *fmt, ...) { int n; char buf[20]; va_list ap; va_start(ap, fmt); n = vsprintf(buf, fmt, ap); va_end(ap); return n; } int main() { return (mytest("Hello%d\n", 1)); } EOF if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then echo "Checking for return value of vsprintf()... Yes." else CFLAGS="$CFLAGS -DHAS_vsprintf_void" echo "Checking for return value of vsprintf()... No." echo " WARNING: apparently vsprintf() does not return a value. zlib" echo " can build but will be open to possible string-format security" echo " vulnerabilities." fi fi else echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()" cat >$test.c < int mytest() { char buf[20]; snprintf(buf, sizeof(buf), "%s", "foo"); return 0; } int main() { return (mytest()); } EOF if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then echo "Checking for snprintf() in stdio.h... Yes." cat >$test.c < int mytest() { char buf[20]; return snprintf(buf, sizeof(buf), "%s", "foo"); } int main() { return (mytest()); } EOF if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then echo "Checking for return value of snprintf()... Yes." else CFLAGS="$CFLAGS -DHAS_snprintf_void" echo "Checking for return value of snprintf()... No." echo " WARNING: apparently snprintf() does not return a value. zlib" echo " can build but will be open to possible string-format security" echo " vulnerabilities." fi else CFLAGS="$CFLAGS -DNO_snprintf" echo "Checking for snprintf() in stdio.h... No." echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" echo " can build but will be open to possible buffer-overflow security" echo " vulnerabilities." cat >$test.c < int mytest() { char buf[20]; return sprintf(buf, "%s", "foo"); } int main() { return (mytest()); } EOF if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then echo "Checking for return value of sprintf()... Yes." else CFLAGS="$CFLAGS -DHAS_sprintf_void" echo "Checking for return value of sprintf()... No." echo " WARNING: apparently sprintf() does not return a value. zlib" echo " can build but will be open to possible string-format security" echo " vulnerabilities." fi fi fi cat >$test.c < int main() { return 0; } EOF if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then echo "Checking for errno.h... Yes." else echo "Checking for errno.h... No." CFLAGS="$CFLAGS -DNO_ERRNO_H" fi cat > $test.c < #include #include caddr_t hello() { return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0); } EOF if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then CFLAGS="$CFLAGS -DUSE_MMAP" echo Checking for mmap support... Yes. else echo Checking for mmap support... No. fi CPP=${CPP-"$CC -E"} case $CFLAGS in *ASMV*) if test "`nm $test.o | grep _hello`" = ""; then CPP="$CPP -DNO_UNDERLINE" echo Checking for underline in external names... No. else echo Checking for underline in external names... Yes. fi;; esac rm -f $test.[co] $test $test$shared_ext # udpate Makefile sed < Makefile.in " /^CC *=/s#=.*#=$CC# /^CFLAGS *=/s#=.*#=$CFLAGS# /^CPP *=/s#=.*#=$CPP# /^LDSHARED *=/s#=.*#=$LDSHARED# /^LIBS *=/s#=.*#=$LIBS# /^SHAREDLIB *=/s#=.*#=$SHAREDLIB# /^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV# /^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM# /^AR *=/s#=.*#=$AR# /^RANLIB *=/s#=.*#=$RANLIB# /^EXE *=/s#=.*#=$EXE# /^prefix *=/s#=.*#=$prefix# /^exec_prefix *=/s#=.*#=$exec_prefix# /^libdir *=/s#=.*#=$libdir# /^includedir *=/s#=.*#=$includedir# /^mandir *=/s#=.*#=$mandir# /^LDFLAGS *=/s#=.*#=$LDFLAGS# " > Makefile sks-ecc-0.93/zlib/old/0000755000175000017500000000000010604550750013457 5ustar nachonachosks-ecc-0.93/zlib/old/README0000644000175000017500000000020510604550750014334 0ustar nachonachoThis directory contains files that have not been updated for zlib 1.2.x (Volunteers are encouraged to help clean this up. Thanks.) sks-ecc-0.93/zlib/old/zlib.html0000644000175000017500000016111510604550750015312 0ustar nachonacho zlib general purpose compression library version 1.1.4

zlib 1.1.4 Manual


Contents

  1. Prologue
  2. Introduction
  3. Utility functions
  4. Basic functions
  5. Advanced functions
  6. Constants
  7. struct z_stream_s
  8. Checksum functions
  9. Misc

Prologue

'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
jloup@gzip.org
Mark Adler
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).

This manual is converted from zlib.h by piaip

Visit http://ftp.cdrom.com/pub/infozip/zlib/ for the official zlib web page.


Introduction

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.


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.

Function list

  • int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
  • int compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level);
  • int uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
  • typedef voidp gzFile;
  • gzFile gzopen (const char *path, const char *mode);
  • gzFile gzdopen (int fd, const char *mode);
  • int gzsetparams (gzFile file, int level, int strategy);
  • int gzread (gzFile file, voidp buf, unsigned len);
  • int gzwrite (gzFile file, const voidp buf, unsigned len);
  • int VA gzprintf (gzFile file, const char *format, ...);
  • int gzputs (gzFile file, const char *s);
  • char * gzgets (gzFile file, char *buf, int len);
  • int gzputc (gzFile file, int c);
  • int gzgetc (gzFile file);
  • int gzflush (gzFile file, int flush);
  • z_off_t gzseek (gzFile file, z_off_t offset, int whence);
  • z_off_t gztell (gzFile file);
  • int gzrewind (gzFile file);
  • int gzeof (gzFile file);
  • int gzclose (gzFile file);
  • const char * gzerror (gzFile file, int *errnum);

Function description

int compress (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.

int compress2 (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.

int uncompress (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;

gzFile gzopen (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).

gzFile gzdopen (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.

int gzsetparams (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.

int gzread (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).

int gzwrite (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).

int VA gzprintf (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).

int gzputs (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.

char * gzgets (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.

int gzputc (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.

int gzgetc (gzFile file);
Reads one byte from the compressed file. gzgetc returns this byte or -1 in case of end of file or error.

int gzflush (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.

z_off_t gzseek (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.

int gzrewind (gzFile file);
Rewinds the given file. This function is supported only for reading.

gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)

z_off_t gztell (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)

int gzeof (gzFile file);
Returns 1 when EOF has previously been detected reading the given input stream, otherwise zero.

int gzclose (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).

const char * gzerror (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.


Basic functions

Function list

Function description

const char * zlibVersion (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.

int deflateInit (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().

int deflate (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).

int deflateEnd (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).

int inflateInit (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.)

int inflate (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.

int inflateEnd (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.

Function list

Function description

int deflateInit2 (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().

int deflateSetDictionary (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().

int deflateCopy (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.

int deflateReset (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).

int deflateParams (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.

int inflateInit2 (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.)

int inflateSetDictionary (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().

int inflateSync (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.

int inflateReset (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).


Checksum functions

These functions are not related to compression but are exported anyway because they might be useful in applications using the compression library.

Function list

Function description

uLong adler32 (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();
   
uLong crc32 (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();
   

struct z_stream_s

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 less than 1.0.2 */

Misc

deflateInit and inflateInit are macros to allow checking the zlib version and the compiler's view of z_stream.

Other functions:

const char * zError (int err);
int inflateSyncPoint (z_streamp z);
const uLongf * get_crc_table (void);

Last update: Wed Oct 13 20:42:34 1999
piapi@csie.ntu.edu.tw
sks-ecc-0.93/zlib/old/Makefile.riscos0000600000175000017500000000726710604550750016424 0ustar nachonacho# Project: zlib_1_03 # Patched for zlib 1.1.2 rw@shadow.org.uk 19980430 # test works out-of-the-box, installs `somewhere' on demand # Toolflags: CCflags = -c -depend !Depend -IC: -g -throwback -DRISCOS -fah C++flags = -c -depend !Depend -IC: -throwback Linkflags = -aif -c++ -o $@ ObjAsmflags = -throwback -NoCache -depend !Depend CMHGflags = LibFileflags = -c -l -o $@ Squeezeflags = -o $@ # change the line below to where _you_ want the library installed. libdest = lib:zlib # Final targets: @.lib: @.o.adler32 @.o.compress @.o.crc32 @.o.deflate @.o.gzio \ @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil @.o.trees \ @.o.uncompr @.o.zutil LibFile $(LibFileflags) @.o.adler32 @.o.compress @.o.crc32 @.o.deflate \ @.o.gzio @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil \ @.o.trees @.o.uncompr @.o.zutil test: @.minigzip @.example @.lib @copy @.lib @.libc A~C~DF~L~N~P~Q~RS~TV @echo running tests: hang on. @/@.minigzip -f -9 libc @/@.minigzip -d libc-gz @/@.minigzip -f -1 libc @/@.minigzip -d libc-gz @/@.minigzip -h -9 libc @/@.minigzip -d libc-gz @/@.minigzip -h -1 libc @/@.minigzip -d libc-gz @/@.minigzip -9 libc @/@.minigzip -d libc-gz @/@.minigzip -1 libc @/@.minigzip -d libc-gz @diff @.lib @.libc @echo that should have reported '@.lib and @.libc identical' if you have diff. @/@.example @.fred @.fred @echo that will have given lots of hello!'s. @.minigzip: @.o.minigzip @.lib C:o.Stubs Link $(Linkflags) @.o.minigzip @.lib C:o.Stubs @.example: @.o.example @.lib C:o.Stubs Link $(Linkflags) @.o.example @.lib C:o.Stubs install: @.lib cdir $(libdest) cdir $(libdest).h @copy @.h.zlib $(libdest).h.zlib A~C~DF~L~N~P~Q~RS~TV @copy @.h.zconf $(libdest).h.zconf A~C~DF~L~N~P~Q~RS~TV @copy @.lib $(libdest).lib A~C~DF~L~N~P~Q~RS~TV @echo okay, installed zlib in $(libdest) clean:; remove @.minigzip remove @.example remove @.libc -wipe @.o.* F~r~cV remove @.fred # User-editable dependencies: .c.o: cc $(ccflags) -o $@ $< # Static dependencies: # Dynamic dependencies: o.example: c.example o.example: h.zlib o.example: h.zconf o.minigzip: c.minigzip o.minigzip: h.zlib o.minigzip: h.zconf o.adler32: c.adler32 o.adler32: h.zlib o.adler32: h.zconf o.compress: c.compress o.compress: h.zlib o.compress: h.zconf o.crc32: c.crc32 o.crc32: h.zlib o.crc32: h.zconf o.deflate: c.deflate o.deflate: h.deflate o.deflate: h.zutil o.deflate: h.zlib o.deflate: h.zconf o.gzio: c.gzio o.gzio: h.zutil o.gzio: h.zlib o.gzio: h.zconf o.infblock: c.infblock o.infblock: h.zutil o.infblock: h.zlib o.infblock: h.zconf o.infblock: h.infblock o.infblock: h.inftrees o.infblock: h.infcodes o.infblock: h.infutil o.infcodes: c.infcodes o.infcodes: h.zutil o.infcodes: h.zlib o.infcodes: h.zconf o.infcodes: h.inftrees o.infcodes: h.infblock o.infcodes: h.infcodes o.infcodes: h.infutil o.infcodes: h.inffast o.inffast: c.inffast o.inffast: h.zutil o.inffast: h.zlib o.inffast: h.zconf o.inffast: h.inftrees o.inffast: h.infblock o.inffast: h.infcodes o.inffast: h.infutil o.inffast: h.inffast o.inflate: c.inflate o.inflate: h.zutil o.inflate: h.zlib o.inflate: h.zconf o.inflate: h.infblock o.inftrees: c.inftrees o.inftrees: h.zutil o.inftrees: h.zlib o.inftrees: h.zconf o.inftrees: h.inftrees o.inftrees: h.inffixed o.infutil: c.infutil o.infutil: h.zutil o.infutil: h.zlib o.infutil: h.zconf o.infutil: h.infblock o.infutil: h.inftrees o.infutil: h.infcodes o.infutil: h.infutil o.trees: c.trees o.trees: h.deflate o.trees: h.zutil o.trees: h.zlib o.trees: h.zconf o.trees: h.trees o.uncompr: c.uncompr o.uncompr: h.zlib o.uncompr: h.zconf o.zutil: c.zutil o.zutil: h.zutil o.zutil: h.zlib o.zutil: h.zconf sks-ecc-0.93/zlib/old/os2/0000755000175000017500000000000010604550750014162 5ustar nachonachosks-ecc-0.93/zlib/old/os2/Makefile.os20000644000175000017500000001001010604550750016314 0ustar nachonacho# Makefile for zlib under OS/2 using GCC (PGCC) # For conditions of distribution and use, see copyright notice in zlib.h # To compile and test, type: # cp Makefile.os2 .. # cd .. # make -f Makefile.os2 test # This makefile will build a static library z.lib, a shared library # z.dll and a import library zdll.lib. You can use either z.lib or # zdll.lib by specifying either -lz or -lzdll on gcc's command line CC=gcc -Zomf -s CFLAGS=-O6 -Wall #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 #CFLAGS=-g -DDEBUG #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ # -Wstrict-prototypes -Wmissing-prototypes #################### BUG WARNING: ##################### ## infcodes.c hits a bug in pgcc-1.0, so you have to use either ## -O# where # <= 4 or one of (-fno-ommit-frame-pointer or -fno-force-mem) ## This bug is reportedly fixed in pgcc >1.0, but this was not tested CFLAGS+=-fno-force-mem LDFLAGS=-s -L. -lzdll -Zcrtdll LDSHARED=$(CC) -s -Zomf -Zdll -Zcrtdll VER=1.1.0 ZLIB=z.lib SHAREDLIB=z.dll SHAREDLIBIMP=zdll.lib LIBS=$(ZLIB) $(SHAREDLIB) $(SHAREDLIBIMP) AR=emxomfar cr IMPLIB=emximp RANLIB=echo TAR=tar SHELL=bash prefix=/usr/local exec_prefix = $(prefix) OBJS = 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 TEST_OBJS = example.o minigzip.o DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] *.[ch] descrip.mms \ algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ nt/Makefile.nt nt/zlib.dnt contrib/README.contrib contrib/*.txt \ contrib/asm386/*.asm contrib/asm386/*.c \ contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/iostream/*.cpp \ contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \ contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 all: example.exe minigzip.exe test: all @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ echo hello world | ./minigzip | ./minigzip -d || \ echo ' *** minigzip test FAILED ***' ; \ if ./example; then \ echo ' *** zlib test OK ***'; \ else \ echo ' *** zlib test FAILED ***'; \ fi $(ZLIB): $(OBJS) $(AR) $@ $(OBJS) -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 $(SHAREDLIB): $(OBJS) os2/z.def $(LDSHARED) -o $@ $^ $(SHAREDLIBIMP): os2/z.def $(IMPLIB) -o $@ $^ example.exe: example.o $(LIBS) $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) minigzip.exe: minigzip.o $(LIBS) $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) clean: rm -f *.o *~ example minigzip libz.a libz.so* foo.gz distclean: clean zip: mv Makefile Makefile~; cp -p Makefile.in Makefile rm -f test.c ztest*.c v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ zip -ul9 zlib$$v $(DISTFILES) mv Makefile~ Makefile dist: mv Makefile Makefile~; cp -p Makefile.in Makefile rm -f test.c ztest*.c d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ rm -f $$d.tar.gz; \ if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \ files=""; \ for f in $(DISTFILES); do files="$$files $$d/$$f"; done; \ cd ..; \ GZIP=-9 $(TAR) chofz $$d/$$d.tar.gz $$files; \ if test ! -d $$d; then rm -f $$d; fi mv Makefile~ Makefile tags: etags *.[ch] depend: makedepend -- $(CFLAGS) -- *.[ch] # DO NOT DELETE THIS LINE -- make depend depends on it. adler32.o: zlib.h zconf.h compress.o: zlib.h zconf.h crc32.o: zlib.h zconf.h deflate.o: deflate.h zutil.h zlib.h zconf.h example.o: zlib.h zconf.h gzio.o: zutil.h zlib.h zconf.h infblock.o: infblock.h inftrees.h infcodes.h infutil.h zutil.h zlib.h zconf.h infcodes.o: zutil.h zlib.h zconf.h infcodes.o: inftrees.h infblock.h infcodes.h infutil.h inffast.h inffast.o: zutil.h zlib.h zconf.h inftrees.h inffast.o: infblock.h infcodes.h infutil.h inffast.h inflate.o: zutil.h zlib.h zconf.h infblock.h inftrees.o: zutil.h zlib.h zconf.h inftrees.h infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h minigzip.o: zlib.h zconf.h trees.o: deflate.h zutil.h zlib.h zconf.h trees.h uncompr.o: zlib.h zconf.h zutil.o: zutil.h zlib.h zconf.h sks-ecc-0.93/zlib/old/os2/zlib.def0000644000175000017500000000141210604550750015600 0ustar nachonacho; ; Slightly modified version of ../nt/zlib.dnt :-) ; LIBRARY Z DESCRIPTION "Zlib compression library for OS/2" CODE PRELOAD MOVEABLE DISCARDABLE DATA PRELOAD MOVEABLE MULTIPLE EXPORTS adler32 compress crc32 deflate deflateCopy deflateEnd deflateInit2_ deflateInit_ deflateParams deflateReset deflateSetDictionary gzclose gzdopen gzerror gzflush gzopen gzread gzwrite inflate inflateEnd inflateInit2_ inflateInit_ inflateReset inflateSetDictionary inflateSync uncompress zlibVersion gzprintf gzputc gzgetc gzseek gzrewind gztell gzeof gzsetparams zError inflateSyncPoint get_crc_table compress2 gzputs gzgets sks-ecc-0.93/zlib/old/descrip.mms0000644000175000017500000000301110604550750015621 0ustar nachonacho# descrip.mms: MMS description file for building zlib on VMS # written by Martin P.J. Zinser cc_defs = c_deb = .ifdef __DECC__ pref = /prefix=all .endif OBJS = adler32.obj, compress.obj, crc32.obj, gzio.obj, uncompr.obj,\ deflate.obj, trees.obj, zutil.obj, inflate.obj, infblock.obj,\ inftrees.obj, infcodes.obj, infutil.obj, inffast.obj CFLAGS= $(C_DEB) $(CC_DEFS) $(PREF) all : example.exe minigzip.exe @ write sys$output " Example applications available" libz.olb : libz.olb($(OBJS)) @ write sys$output " libz available" example.exe : example.obj libz.olb link example,libz.olb/lib minigzip.exe : minigzip.obj libz.olb link minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib clean : delete *.obj;*,libz.olb;* # Other dependencies. adler32.obj : zutil.h zlib.h zconf.h compress.obj : zlib.h zconf.h crc32.obj : zutil.h zlib.h zconf.h deflate.obj : deflate.h zutil.h zlib.h zconf.h example.obj : zlib.h zconf.h gzio.obj : zutil.h zlib.h zconf.h infblock.obj : zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h infcodes.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h infcodes.h inffast.h inffast.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h inflate.obj : zutil.h zlib.h zconf.h infblock.h inftrees.obj : zutil.h zlib.h zconf.h inftrees.h infutil.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h minigzip.obj : zlib.h zconf.h trees.obj : deflate.h zutil.h zlib.h zconf.h uncompr.obj : zlib.h zconf.h zutil.obj : zutil.h zlib.h zconf.h sks-ecc-0.93/zlib/old/visual-basic.txt0000644000175000017500000001365410604550750016613 0ustar nachonachoSee below some functions declarations for Visual Basic. Frequently Asked Question: Q: Each time I use the compress function I get the -5 error (not enough room in the output buffer). A: Make sure that the length of the compressed buffer is passed by reference ("as any"), not by value ("as long"). Also check that before the call of compress this length is equal to the total size of the compressed buffer and not zero. From: "Jon Caruana" Subject: Re: How to port zlib declares to vb? Date: Mon, 28 Oct 1996 18:33:03 -0600 Got the answer! (I haven't had time to check this but it's what I got, and looks correct): He has the following routines working: compress uncompress gzopen gzwrite gzread gzclose Declares follow: (Quoted from Carlos Rios , in Vb4 form) #If Win16 Then 'Use Win16 calls. Declare Function compress Lib "ZLIB.DLL" (ByVal compr As String, comprLen As Any, ByVal buf As String, ByVal buflen As Long) As Integer Declare Function uncompress Lib "ZLIB.DLL" (ByVal uncompr As String, uncomprLen As Any, ByVal compr As String, ByVal lcompr As Long) As Integer Declare Function gzopen Lib "ZLIB.DLL" (ByVal filePath As String, ByVal mode As String) As Long Declare Function gzread Lib "ZLIB.DLL" (ByVal file As Long, ByVal uncompr As String, ByVal uncomprLen As Integer) As Integer Declare Function gzwrite Lib "ZLIB.DLL" (ByVal file As Long, ByVal uncompr As String, ByVal uncomprLen As Integer) As Integer Declare Function gzclose Lib "ZLIB.DLL" (ByVal file As Long) As Integer #Else Declare Function compress Lib "ZLIB32.DLL" (ByVal compr As String, comprLen As Any, ByVal buf As String, ByVal buflen As Long) As Integer Declare Function uncompress Lib "ZLIB32.DLL" (ByVal uncompr As String, uncomprLen As Any, ByVal compr As String, ByVal lcompr As Long) As Long Declare Function gzopen Lib "ZLIB32.DLL" (ByVal file As String, ByVal mode As String) As Long Declare Function gzread Lib "ZLIB32.DLL" (ByVal file As Long, ByVal uncompr As String, ByVal uncomprLen As Long) As Long Declare Function gzwrite Lib "ZLIB32.DLL" (ByVal file As Long, ByVal uncompr As String, ByVal uncomprLen As Long) As Long Declare Function gzclose Lib "ZLIB32.DLL" (ByVal file As Long) As Long #End If -Jon Caruana jon-net@usa.net Microsoft Sitebuilder Network Level 1 Member - HTML Writer's Guild Member Here is another example from Michael that he says conforms to the VB guidelines, and that solves the problem of not knowing the uncompressed size by storing it at the end of the file: 'Calling the functions: 'bracket meaning: [optional] {Range of possible values} 'Call subCompressFile( [, , [level of compression {1..9}]]) 'Call subUncompressFile() Option Explicit Private lngpvtPcnSml As Long 'Stores value for 'lngPercentSmaller' Private Const SUCCESS As Long = 0 Private Const strFilExt As String = ".cpr" Private Declare Function lngfncCpr Lib "zlib.dll" Alias "compress2" (ByRef dest As Any, ByRef destLen As Any, ByRef src As Any, ByVal srcLen As Long, ByVal level As Integer) As Long Private Declare Function lngfncUcp Lib "zlib.dll" Alias "uncompress" (ByRef dest As Any, ByRef destLen As Any, ByRef src As Any, ByVal srcLen As Long) As Long Public Sub subCompressFile(ByVal strargOriFilPth As String, Optional ByVal strargCprFilPth As String, Optional ByVal intLvl As Integer = 9) Dim strCprPth As String Dim lngOriSiz As Long Dim lngCprSiz As Long Dim bytaryOri() As Byte Dim bytaryCpr() As Byte lngOriSiz = FileLen(strargOriFilPth) ReDim bytaryOri(lngOriSiz - 1) Open strargOriFilPth For Binary Access Read As #1 Get #1, , bytaryOri() Close #1 strCprPth = IIf(strargCprFilPth = "", strargOriFilPth, strargCprFilPth) 'Select file path and name strCprPth = strCprPth & IIf(Right(strCprPth, Len(strFilExt)) = strFilExt, "", strFilExt) 'Add file extension if not exists lngCprSiz = (lngOriSiz * 1.01) + 12 'Compression needs temporary a bit more space then original file size ReDim bytaryCpr(lngCprSiz - 1) If lngfncCpr(bytaryCpr(0), lngCprSiz, bytaryOri(0), lngOriSiz, intLvl) = SUCCESS Then lngpvtPcnSml = (1# - (lngCprSiz / lngOriSiz)) * 100 ReDim Preserve bytaryCpr(lngCprSiz - 1) Open strCprPth For Binary Access Write As #1 Put #1, , bytaryCpr() Put #1, , lngOriSiz 'Add the the original size value to the end (last 4 bytes) Close #1 Else MsgBox "Compression error" End If Erase bytaryCpr Erase bytaryOri End Sub Public Sub subUncompressFile(ByVal strargFilPth As String) Dim bytaryCpr() As Byte Dim bytaryOri() As Byte Dim lngOriSiz As Long Dim lngCprSiz As Long Dim strOriPth As String lngCprSiz = FileLen(strargFilPth) ReDim bytaryCpr(lngCprSiz - 1) Open strargFilPth For Binary Access Read As #1 Get #1, , bytaryCpr() Close #1 'Read the original file size value: lngOriSiz = bytaryCpr(lngCprSiz - 1) * (2 ^ 24) _ + bytaryCpr(lngCprSiz - 2) * (2 ^ 16) _ + bytaryCpr(lngCprSiz - 3) * (2 ^ 8) _ + bytaryCpr(lngCprSiz - 4) ReDim Preserve bytaryCpr(lngCprSiz - 5) 'Cut of the original size value ReDim bytaryOri(lngOriSiz - 1) If lngfncUcp(bytaryOri(0), lngOriSiz, bytaryCpr(0), lngCprSiz) = SUCCESS Then strOriPth = Left(strargFilPth, Len(strargFilPth) - Len(strFilExt)) Open strOriPth For Binary Access Write As #1 Put #1, , bytaryOri() Close #1 Else MsgBox "Uncompression error" End If Erase bytaryCpr Erase bytaryOri End Sub Public Property Get lngPercentSmaller() As Long lngPercentSmaller = lngpvtPcnSml End Property sks-ecc-0.93/zlib/as400/0000755000175000017500000000000010604550750013530 5ustar nachonachosks-ecc-0.93/zlib/as400/readme.txt0000644000175000017500000001110310604550750015522 0ustar nachonacho ZLIB version 1.2.3 for AS400 installation instructions I) From an AS400 *SAVF file: 1) Unpacking archive to an AS400 save file On the AS400: _ Create the ZLIB AS400 library: CRTLIB LIB(ZLIB) TYPE(PROD) TEXT('ZLIB compression API library') _ Create a work save file, for example: CRTSAVF FILE(ZLIB/ZLIBSAVF) On a PC connected to the target AS400: _ Unpack the save file image to a PC file "ZLIBSAVF" _ Upload this file into the save file on the AS400, for example using ftp in BINARY mode. 2) Populating the ZLIB AS400 source library On the AS400: _ Extract the saved objects into the ZLIB AS400 library using: RSTOBJ OBJ(*ALL) SAVLIB(ZLIB) DEV(*SAVF) SAVF(ZLIB/ZLIBSAVF) RSTLIB(ZLIB) 3) Customize installation: _ Edit CL member ZLIB/TOOLS(COMPILE) and change parameters if needed, according to the comments. _ Compile this member with: CRTCLPGM PGM(ZLIB/COMPILE) SRCFILE(ZLIB/TOOLS) SRCMBR(COMPILE) 4) Compile and generate the service program: _ This can now be done by executing: CALL PGM(ZLIB/COMPILE) II) From the original source distribution: 1) On the AS400, create the source library: CRTLIB LIB(ZLIB) TYPE(PROD) TEXT('ZLIB compression API library') 2) Create the source files: CRTSRCPF FILE(ZLIB/SOURCES) RCDLEN(112) TEXT('ZLIB library modules') CRTSRCPF FILE(ZLIB/H) RCDLEN(112) TEXT('ZLIB library includes') CRTSRCPF FILE(ZLIB/TOOLS) RCDLEN(112) TEXT('ZLIB library control utilities') 3) From the machine hosting the distribution files, upload them (with FTP in text mode, for example) according to the following table: Original AS400 AS400 AS400 AS400 file file member type description SOURCES Original ZLIB C subprogram sources adler32.c ADLER32 C ZLIB - Compute the Adler-32 checksum of a dta strm compress.c COMPRESS C ZLIB - Compress a memory buffer crc32.c CRC32 C ZLIB - Compute the CRC-32 of a data stream deflate.c DEFLATE C ZLIB - Compress data using the deflation algorithm gzio.c GZIO C ZLIB - IO on .gz files infback.c INFBACK C ZLIB - Inflate using a callback interface inffast.c INFFAST C ZLIB - Fast proc. literals & length/distance pairs inflate.c INFLATE C ZLIB - Interface to inflate modules inftrees.c INFTREES C ZLIB - Generate Huffman trees for efficient decode trees.c TREES C ZLIB - Output deflated data using Huffman coding uncompr.c UNCOMPR C ZLIB - Decompress a memory buffer zutil.c ZUTIL C ZLIB - Target dependent utility functions H Original ZLIB C and ILE/RPG include files crc32.h CRC32 C ZLIB - CRC32 tables deflate.h DEFLATE C ZLIB - Internal compression state inffast.h INFFAST C ZLIB - Header to use inffast.c inffixed.h INFFIXED C ZLIB - Table for decoding fixed codes inflate.h INFLATE C ZLIB - Internal inflate state definitions inftrees.h INFTREES C ZLIB - Header to use inftrees.c trees.h TREES C ZLIB - Created automatically with -DGEN_TREES_H zconf.h ZCONF C ZLIB - Compression library configuration zlib.h ZLIB C ZLIB - Compression library C user interface as400/zlib.inc ZLIB.INC RPGLE ZLIB - Compression library ILE RPG user interface zutil.h ZUTIL C ZLIB - Internal interface and configuration TOOLS Building source software & AS/400 README as400/bndsrc BNDSRC Entry point exportation list as400/compile.clp COMPILE CLP Compile sources & generate service program as400/readme.txt README TXT Installation instructions 4) Continue as in I)3). Notes: For AS400 ILE RPG programmers, a /copy member defining the ZLIB API prototypes for ILE RPG can be found in ZLIB/H(ZLIB.INC). Please read comments in this member for more information. Remember that most foreign textual data are ASCII coded: this implementation does not handle conversion from/to ASCII, so text data code conversions must be done explicitely. Always open zipped files in binary mode. sks-ecc-0.93/zlib/as400/bndsrc0000644000175000017500000001163410604550750014733 0ustar nachonachoSTRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB') /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /* Version 1.1.3 entry points. */ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /********************************************************************/ /* *MODULE ADLER32 ZLIB 01/02/01 00:15:09 */ /********************************************************************/ EXPORT SYMBOL("adler32") /********************************************************************/ /* *MODULE COMPRESS ZLIB 01/02/01 00:15:09 */ /********************************************************************/ EXPORT SYMBOL("compress") EXPORT SYMBOL("compress2") /********************************************************************/ /* *MODULE CRC32 ZLIB 01/02/01 00:15:09 */ /********************************************************************/ EXPORT SYMBOL("crc32") EXPORT SYMBOL("get_crc_table") /********************************************************************/ /* *MODULE DEFLATE ZLIB 01/02/01 00:15:09 */ /********************************************************************/ EXPORT SYMBOL("deflate") EXPORT SYMBOL("deflateEnd") EXPORT SYMBOL("deflateSetDictionary") EXPORT SYMBOL("deflateCopy") EXPORT SYMBOL("deflateReset") EXPORT SYMBOL("deflateParams") EXPORT SYMBOL("deflatePrime") EXPORT SYMBOL("deflateInit_") EXPORT SYMBOL("deflateInit2_") /********************************************************************/ /* *MODULE GZIO ZLIB 01/02/01 00:15:09 */ /********************************************************************/ EXPORT SYMBOL("gzopen") EXPORT SYMBOL("gzdopen") EXPORT SYMBOL("gzsetparams") EXPORT SYMBOL("gzread") EXPORT SYMBOL("gzwrite") EXPORT SYMBOL("gzprintf") EXPORT SYMBOL("gzputs") EXPORT SYMBOL("gzgets") EXPORT SYMBOL("gzputc") EXPORT SYMBOL("gzgetc") EXPORT SYMBOL("gzflush") EXPORT SYMBOL("gzseek") EXPORT SYMBOL("gzrewind") EXPORT SYMBOL("gztell") EXPORT SYMBOL("gzeof") EXPORT SYMBOL("gzclose") EXPORT SYMBOL("gzerror") /********************************************************************/ /* *MODULE INFLATE ZLIB 01/02/01 00:15:09 */ /********************************************************************/ EXPORT SYMBOL("inflate") EXPORT SYMBOL("inflateEnd") EXPORT SYMBOL("inflateSetDictionary") EXPORT SYMBOL("inflateSync") EXPORT SYMBOL("inflateReset") EXPORT SYMBOL("inflateInit_") EXPORT SYMBOL("inflateInit2_") EXPORT SYMBOL("inflateSyncPoint") /********************************************************************/ /* *MODULE UNCOMPR ZLIB 01/02/01 00:15:09 */ /********************************************************************/ EXPORT SYMBOL("uncompress") /********************************************************************/ /* *MODULE ZUTIL ZLIB 01/02/01 00:15:09 */ /********************************************************************/ EXPORT SYMBOL("zlibVersion") EXPORT SYMBOL("zError") /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /* Version 1.2.1 additional entry points. */ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /********************************************************************/ /* *MODULE COMPRESS ZLIB 01/02/01 00:15:09 */ /********************************************************************/ EXPORT SYMBOL("compressBound") /********************************************************************/ /* *MODULE DEFLATE ZLIB 01/02/01 00:15:09 */ /********************************************************************/ EXPORT SYMBOL("deflateBound") /********************************************************************/ /* *MODULE GZIO ZLIB 01/02/01 00:15:09 */ /********************************************************************/ EXPORT SYMBOL("gzungetc") EXPORT SYMBOL("gzclearerr") /********************************************************************/ /* *MODULE INFBACK ZLIB 01/02/01 00:15:09 */ /********************************************************************/ EXPORT SYMBOL("inflateBack") EXPORT SYMBOL("inflateBackEnd") EXPORT SYMBOL("inflateBackInit_") /********************************************************************/ /* *MODULE INFLATE ZLIB 01/02/01 00:15:09 */ /********************************************************************/ EXPORT SYMBOL("inflateCopy") /********************************************************************/ /* *MODULE ZUTIL ZLIB 01/02/01 00:15:09 */ /********************************************************************/ EXPORT SYMBOL("zlibCompileFlags") ENDPGMEXP sks-ecc-0.93/zlib/as400/zlib.inc0000644000175000017500000005055610604550750015176 0ustar nachonacho * ZLIB.INC - Interface to the general purpose compression library * * ILE RPG400 version by Patrick Monnerat, DATASPHERE. * Version 1.2.3 * * * WARNING: * Procedures inflateInit(), inflateInit2(), deflateInit(), * deflateInit2() and inflateBackInit() need to be called with * two additional arguments: * the package version string and the stream control structure. * size. This is needed because RPG lacks some macro feature. * Call these procedures as: * inflateInit(...: ZLIB_VERSION: %size(z_stream)) * /if not defined(ZLIB_H_) /define ZLIB_H_ * ************************************************************************** * Constants ************************************************************************** * * Versioning information. * D ZLIB_VERSION C '1.2.3' D ZLIB_VERNUM C X'1230' * * Other equates. * D Z_NO_FLUSH C 0 D Z_SYNC_FLUSH C 2 D Z_FULL_FLUSH C 3 D Z_FINISH C 4 D Z_BLOCK C 5 * D Z_OK C 0 D Z_STREAM_END C 1 D Z_NEED_DICT C 2 D Z_ERRNO C -1 D Z_STREAM_ERROR C -2 D Z_DATA_ERROR C -3 D Z_MEM_ERROR C -4 D Z_BUF_ERROR C -5 DZ_VERSION_ERROR C -6 * D Z_NO_COMPRESSION... D C 0 D Z_BEST_SPEED C 1 D Z_BEST_COMPRESSION... D C 9 D Z_DEFAULT_COMPRESSION... D C -1 * D Z_FILTERED C 1 D Z_HUFFMAN_ONLY C 2 D Z_RLE C 3 D Z_DEFAULT_STRATEGY... D C 0 * D Z_BINARY C 0 D Z_ASCII C 1 D Z_UNKNOWN C 2 * D Z_DEFLATED C 8 * D Z_NULL C 0 * ************************************************************************** * Types ************************************************************************** * D z_streamp S * Stream struct ptr D gzFile S * File pointer D z_off_t S 10i 0 Stream offsets * ************************************************************************** * Structures ************************************************************************** * * The GZIP encode/decode stream support structure. * D z_stream DS align based(z_streamp) D zs_next_in * Next input byte D zs_avail_in 10U 0 Byte cnt at next_in D zs_total_in 10U 0 Total bytes read D zs_next_out * Output buffer ptr D zs_avail_out 10U 0 Room left @ next_out D zs_total_out 10U 0 Total bytes written D zs_msg * Last errmsg or null D zs_state * Internal state D zs_zalloc * procptr Int. state allocator D zs_free * procptr Int. state dealloc. D zs_opaque * Private alloc. data D zs_data_type 10i 0 ASC/BIN best guess D zs_adler 10u 0 Uncompr. adler32 val D 10U 0 Reserved D 10U 0 Ptr. alignment * ************************************************************************** * Utility function prototypes ************************************************************************** * D compress PR 10I 0 extproc('compress') D dest 32767 options(*varsize) Destination buffer D destLen 10U 0 Destination length D source 32767 const options(*varsize) Source buffer D sourceLen 10u 0 value Source length * D compress2 PR 10I 0 extproc('compress2') D dest 32767 options(*varsize) Destination buffer D destLen 10U 0 Destination length D source 32767 const options(*varsize) Source buffer D sourceLen 10U 0 value Source length D level 10I 0 value Compression level * D compressBound PR 10U 0 extproc('compressBound') D sourceLen 10U 0 value * D uncompress PR 10I 0 extproc('uncompress') D dest 32767 options(*varsize) Destination buffer D destLen 10U 0 Destination length D source 32767 const options(*varsize) Source buffer D sourceLen 10U 0 value Source length * D gzopen PR extproc('gzopen') D like(gzFile) D path * value options(*string) File pathname D mode * value options(*string) Open mode * D gzdopen PR extproc('gzdopen') D like(gzFile) D fd 10i 0 value File descriptor D mode * value options(*string) Open mode * D gzsetparams PR 10I 0 extproc('gzsetparams') D file value like(gzFile) File pointer D level 10I 0 value D strategy 10i 0 value * D gzread PR 10I 0 extproc('gzread') D file value like(gzFile) File pointer D buf 32767 options(*varsize) Buffer D len 10u 0 value Buffer length * D gzwrite PR 10I 0 extproc('gzwrite') D file value like(gzFile) File pointer D buf 32767 const options(*varsize) Buffer D len 10u 0 value Buffer length * D gzputs PR 10I 0 extproc('gzputs') D file value like(gzFile) File pointer D s * value options(*string) String to output * D gzgets PR * extproc('gzgets') D file value like(gzFile) File pointer D buf 32767 options(*varsize) Read buffer D len 10i 0 value Buffer length * D gzflush PR 10i 0 extproc('gzflush') D file value like(gzFile) File pointer D flush 10I 0 value Type of flush * D gzseek PR extproc('gzseek') D like(z_off_t) D file value like(gzFile) File pointer D offset value like(z_off_t) Offset D whence 10i 0 value Origin * D gzrewind PR 10i 0 extproc('gzrewind') D file value like(gzFile) File pointer * D gztell PR extproc('gztell') D like(z_off_t) D file value like(gzFile) File pointer * D gzeof PR 10i 0 extproc('gzeof') D file value like(gzFile) File pointer * D gzclose PR 10i 0 extproc('gzclose') D file value like(gzFile) File pointer * D gzerror PR * extproc('gzerror') Error string D file value like(gzFile) File pointer D errnum 10I 0 Error code * D gzclearerr PR extproc('gzclearerr') D file value like(gzFile) File pointer * ************************************************************************** * Basic function prototypes ************************************************************************** * D zlibVersion PR * extproc('zlibVersion') Version string * D deflateInit PR 10I 0 extproc('deflateInit_') Init. compression D strm like(z_stream) Compression stream D level 10I 0 value Compression level D version * value options(*string) Version string D stream_size 10i 0 value Stream struct. size * D deflate PR 10I 0 extproc('deflate') Compress data D strm like(z_stream) Compression stream D flush 10I 0 value Flush type required * D deflateEnd PR 10I 0 extproc('deflateEnd') Termin. compression D strm like(z_stream) Compression stream * D inflateInit PR 10I 0 extproc('inflateInit_') Init. expansion D strm like(z_stream) Expansion stream D version * value options(*string) Version string D stream_size 10i 0 value Stream struct. size * D inflate PR 10I 0 extproc('inflate') Expand data D strm like(z_stream) Expansion stream D flush 10I 0 value Flush type required * D inflateEnd PR 10I 0 extproc('inflateEnd') Termin. expansion D strm like(z_stream) Expansion stream * ************************************************************************** * Advanced function prototypes ************************************************************************** * D deflateInit2 PR 10I 0 extproc('deflateInit2_') Init. compression D strm like(z_stream) Compression stream D level 10I 0 value Compression level D method 10I 0 value Compression method D windowBits 10I 0 value log2(window size) D memLevel 10I 0 value Mem/cmpress tradeoff D strategy 10I 0 value Compression stategy D version * value options(*string) Version string D stream_size 10i 0 value Stream struct. size * D deflateSetDictionary... D PR 10I 0 extproc('deflateSetDictionary') Init. dictionary D strm like(z_stream) Compression stream D dictionary 32767 const options(*varsize) Dictionary bytes D dictLength 10U 0 value Dictionary length * D deflateCopy PR 10I 0 extproc('deflateCopy') Compress strm 2 strm D dest like(z_stream) Destination stream D source like(z_stream) Source stream * D deflateReset PR 10I 0 extproc('deflateReset') End and init. stream D strm like(z_stream) Compression stream * D deflateParams PR 10I 0 extproc('deflateParams') Change level & strat D strm like(z_stream) Compression stream D level 10I 0 value Compression level D strategy 10I 0 value Compression stategy * D deflateBound PR 10U 0 extproc('deflateBound') Change level & strat D strm like(z_stream) Compression stream D sourcelen 10U 0 value Compression level * D deflatePrime PR 10I 0 extproc('deflatePrime') Change level & strat D strm like(z_stream) Compression stream D bits 10I 0 value Number of bits to insert D value 10I 0 value Bits to insert * D inflateInit2 PR 10I 0 extproc('inflateInit2_') Init. expansion D strm like(z_stream) Expansion stream D windowBits 10I 0 value log2(window size) D version * value options(*string) Version string D stream_size 10i 0 value Stream struct. size * D inflateSetDictionary... D PR 10I 0 extproc('inflateSetDictionary') Init. dictionary D strm like(z_stream) Expansion stream D dictionary 32767 const options(*varsize) Dictionary bytes D dictLength 10U 0 value Dictionary length * D inflateSync PR 10I 0 extproc('inflateSync') Sync. expansion D strm like(z_stream) Expansion stream * D inflateCopy PR 10I 0 extproc('inflateCopy') D dest like(z_stream) Destination stream D source like(z_stream) Source stream * D inflateReset PR 10I 0 extproc('inflateReset') End and init. stream D strm like(z_stream) Expansion stream * D inflateBackInit... D PR 10I 0 extproc('inflateBackInit_') D strm like(z_stream) Expansion stream D windowBits 10I 0 value Log2(buffer size) D window 32767 options(*varsize) Buffer D version * value options(*string) Version string D stream_size 10i 0 value Stream struct. size * D inflateBack PR 10I 0 extproc('inflateBack') D strm like(z_stream) Expansion stream D in * value procptr Input function D in_desc * value Input descriptor D out * value procptr Output function D out_desc * value Output descriptor * D inflateBackEnd PR 10I 0 extproc('inflateBackEnd') D strm like(z_stream) Expansion stream * D zlibCompileFlags... D PR 10U 0 extproc('zlibCompileFlags') * ************************************************************************** * Checksum function prototypes ************************************************************************** * D adler32 PR 10U 0 extproc('adler32') New checksum D adler 10U 0 value Old checksum D buf 32767 const options(*varsize) Bytes to accumulate D len 10U 0 value Buffer length * D crc32 PR 10U 0 extproc('crc32') New checksum D crc 10U 0 value Old checksum D buf 32767 const options(*varsize) Bytes to accumulate D len 10U 0 value Buffer length * ************************************************************************** * Miscellaneous function prototypes ************************************************************************** * D zError PR * extproc('zError') Error string D err 10I 0 value Error code * D inflateSyncPoint... D PR 10I 0 extproc('inflateSyncPoint') D strm like(z_stream) Expansion stream * D get_crc_table PR * extproc('get_crc_table') Ptr to ulongs * /endif sks-ecc-0.93/zlib/as400/compile.clp0000644000175000017500000001542510604550750015667 0ustar nachonacho/******************************************************************************/ /* */ /* ZLIB */ /* */ /* Compile sources into modules and link them into a service program. */ /* */ /******************************************************************************/ PGM /* Configuration adjustable parameters. */ DCL VAR(&SRCLIB) TYPE(*CHAR) LEN(10) + VALUE('ZLIB') /* Source library. */ DCL VAR(&SRCFILE) TYPE(*CHAR) LEN(10) + VALUE('SOURCES') /* Source member file. */ DCL VAR(&CTLFILE) TYPE(*CHAR) LEN(10) + VALUE('TOOLS') /* Control member file. */ DCL VAR(&MODLIB) TYPE(*CHAR) LEN(10) + VALUE('ZLIB') /* Module library. */ DCL VAR(&SRVLIB) TYPE(*CHAR) LEN(10) + VALUE('LGPL') /* Service program library. */ DCL VAR(&CFLAGS) TYPE(*CHAR) + VALUE('OPTIMIZE(40)') /* Compile options. */ /* Working storage. */ DCL VAR(&CMDLEN) TYPE(*DEC) LEN(15 5) VALUE(300) /* Command length. */ DCL VAR(&CMD) TYPE(*CHAR) LEN(512) /* Compile sources into modules. */ CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT + '/ADLER32) SRCFILE(' *TCAT + &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT + ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS) CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN) CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT + '/COMPRESS) SRCFILE(' *TCAT + &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT + ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS) CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN) CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT + '/CRC32) SRCFILE(' *TCAT + &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT + ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS) CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN) CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT + '/DEFLATE) SRCFILE(' *TCAT + &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT + ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS) CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN) CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT + '/GZIO) SRCFILE(' *TCAT + &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT + ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS) CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN) CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT + '/INFBACK) SRCFILE(' *TCAT + &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT + ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS) CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN) CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT + '/INFFAST) SRCFILE(' *TCAT + &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT + ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS) CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN) CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT + '/INFLATE) SRCFILE(' *TCAT + &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT + ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS) CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN) CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT + '/INFTREES) SRCFILE(' *TCAT + &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT + ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS) CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN) CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT + '/TREES) SRCFILE(' *TCAT + &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT + ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS) CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN) CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT + '/UNCOMPR) SRCFILE(' *TCAT + &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT + ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS) CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN) CHGVAR VAR(&CMD) VALUE('CRTCMOD MODULE(' *TCAT &MODLIB *TCAT + '/ZUTIL) SRCFILE(' *TCAT + &SRCLIB *TCAT '/' *TCAT &SRCFILE *TCAT + ') SYSIFCOPT(*IFSIO)' *BCAT &CFLAGS) CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN) /* Link modules into a service program. */ CRTSRVPGM SRVPGM(&SRVLIB/ZLIB) + MODULE(&MODLIB/ADLER32 &MODLIB/COMPRESS + &MODLIB/CRC32 &MODLIB/DEFLATE + &MODLIB/GZIO &MODLIB/INFBACK + &MODLIB/INFFAST &MODLIB/INFLATE + &MODLIB/INFTREES &MODLIB/TREES + &MODLIB/UNCOMPR &MODLIB/ZUTIL) + SRCFILE(&SRCLIB/&CTLFILE) SRCMBR(BNDSRC) + TEXT('ZLIB 1.2.3') TGTRLS(V4R4M0) ENDPGM sks-ecc-0.93/zlib/zlib.30000644000175000017500000001060610604550750013730 0ustar nachonacho.TH ZLIB 3 "18 July 2005" .SH NAME zlib \- compression/decompression library .SH SYNOPSIS [see .I zlib.h for full description] .SH DESCRIPTION The .I zlib library is a general purpose data compression library. The code is thread safe. It 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. .LP 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. .LP The library also supports reading and writing files in .IR gzip (1) (.gz) format with an interface similar to that of stdio. .LP 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. .LP All functions of the compression library are documented in the file .IR zlib.h . The distribution source includes examples of use of the library in the files .I example.c and .IR minigzip.c . .LP Changes to this version are documented in the file .I ChangeLog that accompanies the source, and are concerned primarily with bug fixes and portability enhancements. .LP A Java implementation of .I zlib is available in the Java Development Kit 1.1: .IP http://www.javasoft.com/products/JDK/1.1/docs/api/Package-java.util.zip.html .LP A Perl interface to .IR zlib , written by Paul Marquess (pmqs@cpan.org), is available at CPAN (Comprehensive Perl Archive Network) sites, including: .IP http://www.cpan.org/modules/by-module/Compress/ .LP A Python interface to .IR zlib , written by A.M. Kuchling (amk@magnet.com), is available in Python 1.5 and later versions: .IP http://www.python.org/doc/lib/module-zlib.html .LP A .I zlib binding for .IR tcl (1), written by Andreas Kupries (a.kupries@westend.com), is availlable at: .IP http://www.westend.com/~kupries/doc/trf/man/man.html .LP An experimental package to read and write files in .zip format, written on top of .I zlib by Gilles Vollant (info@winimage.com), is available at: .IP http://www.winimage.com/zLibDll/unzip.html and also in the .I contrib/minizip directory of the main .I zlib web site. .SH "SEE ALSO" The .I zlib web site can be found at either of these locations: .IP http://www.zlib.org .br http://www.gzip.org/zlib/ .LP The data format used by the zlib library is described by RFC (Request for Comments) 1950 to 1952 in the files: .IP http://www.ietf.org/rfc/rfc1950.txt (concerning zlib format) .br http://www.ietf.org/rfc/rfc1951.txt (concerning deflate format) .br http://www.ietf.org/rfc/rfc1952.txt (concerning gzip format) .LP These documents are also available in other formats from: .IP ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html .LP Mark Nelson (markn@ieee.org) wrote an article about .I zlib for the Jan. 1997 issue of Dr. Dobb's Journal; a copy of the article is available at: .IP http://dogma.net/markn/articles/zlibtool/zlibtool.htm .SH "REPORTING PROBLEMS" Before reporting a problem, please check the .I zlib web site to verify that you have the latest version of .IR zlib ; otherwise, obtain the latest version and see if the problem still exists. Please read the .I zlib FAQ at: .IP http://www.gzip.org/zlib/zlib_faq.html .LP before asking for help. Send questions and/or comments to zlib@gzip.org, or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). .SH AUTHORS Version 1.2.3 Copyright (C) 1995-2005 Jean-loup Gailly (jloup@gzip.org) and Mark Adler (madler@alumni.caltech.edu). .LP 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. See the distribution directory with respect to requirements governing redistribution. The deflate format used by .I zlib was defined by Phil Katz. The deflate and .I zlib specifications were written by L. Peter Deutsch. Thanks to all the people who reported problems and suggested various improvements in .IR zlib ; who are too numerous to cite here. .LP UNIX manual page by R. P. C. Rodgers, U.S. National Library of Medicine (rodgers@nlm.nih.gov). .\" end of man page sks-ecc-0.93/zlib/amiga/0000755000175000017500000000000010604550750013757 5ustar nachonachosks-ecc-0.93/zlib/amiga/Makefile.sas0000600000175000017500000000325710604550750016203 0ustar nachonacho# SMakefile for zlib # Modified from the standard UNIX Makefile Copyright Jean-loup Gailly # Osma Ahvenlampi # Amiga, SAS/C 6.56 & Smake CC=sc CFLAGS=OPT #CFLAGS=OPT CPU=68030 #CFLAGS=DEBUG=LINE LDFLAGS=LIB z.lib SCOPTIONS=OPTSCHED OPTINLINE OPTALIAS OPTTIME OPTINLOCAL STRMERGE \ NOICONS PARMS=BOTH NOSTACKCHECK UTILLIB NOVERSION ERRORREXX \ DEF=POSTINC OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ zutil.o inflate.o infback.o inftrees.o inffast.o TEST_OBJS = example.o minigzip.o all: SCOPTIONS example minigzip check: test test: all example echo hello world | minigzip | minigzip -d install: z.lib copy clone zlib.h zconf.h INCLUDE: copy clone z.lib LIB: z.lib: $(OBJS) oml z.lib r $(OBJS) example: example.o z.lib $(CC) $(CFLAGS) LINK TO $@ example.o $(LDFLAGS) minigzip: minigzip.o z.lib $(CC) $(CFLAGS) LINK TO $@ minigzip.o $(LDFLAGS) mostlyclean: clean clean: -delete force quiet example minigzip *.o z.lib foo.gz *.lnk SCOPTIONS SCOPTIONS: Makefile.sas copy to $@ for his contribution of faster * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing * tables for updating the shift register in one step with three exclusive-ors * instead of four steps with four exclusive-ors. This results in about a * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. */ /* @(#) $Id$ */ /* Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore protection on the static variables used to control the first-use generation of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should first call get_crc_table() to initialize the tables before allowing more than one thread to use crc32(). */ #ifdef MAKECRCH # include # ifndef DYNAMIC_CRC_TABLE # define DYNAMIC_CRC_TABLE # endif /* !DYNAMIC_CRC_TABLE */ #endif /* MAKECRCH */ #include "zutil.h" /* for STDC and FAR definitions */ #define local static /* Find a four-byte integer type for crc32_little() and crc32_big(). */ #ifndef NOBYFOUR # ifdef STDC /* need ANSI C limits.h to determine sizes */ # include # define BYFOUR # if (UINT_MAX == 0xffffffffUL) typedef unsigned int u4; # else # if (ULONG_MAX == 0xffffffffUL) typedef unsigned long u4; # else # if (USHRT_MAX == 0xffffffffUL) typedef unsigned short u4; # else # undef BYFOUR /* can't find a four-byte integer type! */ # endif # endif # endif # endif /* STDC */ #endif /* !NOBYFOUR */ /* Definitions for doing the crc four data bytes at a time. */ #ifdef BYFOUR # define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \ (((w)&0xff00)<<8)+(((w)&0xff)<<24)) local unsigned long crc32_little OF((unsigned long, const unsigned char FAR *, unsigned)); local unsigned long crc32_big OF((unsigned long, const unsigned char FAR *, unsigned)); # define TBLS 8 #else # define TBLS 1 #endif /* BYFOUR */ /* Local functions for crc concatenation */ local unsigned long gf2_matrix_times OF((unsigned long *mat, unsigned long vec)); local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); #ifdef DYNAMIC_CRC_TABLE local volatile int crc_table_empty = 1; local unsigned long FAR crc_table[TBLS][256]; local void make_crc_table OF((void)); #ifdef MAKECRCH local void write_table OF((FILE *, const unsigned long FAR *)); #endif /* MAKECRCH */ /* Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. Polynomials over GF(2) are represented in binary, one bit per coefficient, with the lowest powers in the most significant bit. Then adding polynomials is just exclusive-or, and multiplying a polynomial by x is a right shift by one. If we call the above polynomial p, and represent a byte as the polynomial q, also with the lowest power in the most significant bit (so the byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, where a mod b means the remainder after dividing a by b. This calculation is done using the shift-register method of multiplying and taking the remainder. The register is initialized to zero, and for each incoming bit, x^32 is added mod p to the register if the bit is a one (where x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by x (which is shifting right by one and adding x^32 mod p if the bit shifted out is a one). We start with the highest power (least significant bit) of q and repeat for all eight bits of q. The first table is simply the CRC of all possible eight bit values. This is all the information needed to generate CRCs on data a byte at a time for all combinations of CRC register values and incoming bytes. The remaining tables allow for word-at-a-time CRC calculation for both big-endian and little- endian machines, where a word is four bytes. */ local void make_crc_table() { unsigned long c; int n, k; unsigned long poly; /* polynomial exclusive-or pattern */ /* terms of polynomial defining this crc (except x^32): */ static volatile int first = 1; /* flag to limit concurrent making */ static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; /* See if another task is already doing this (not thread-safe, but better than nothing -- significantly reduces duration of vulnerability in case the advice about DYNAMIC_CRC_TABLE is ignored) */ if (first) { first = 0; /* make exclusive-or pattern from polynomial (0xedb88320UL) */ poly = 0UL; for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) poly |= 1UL << (31 - p[n]); /* generate a crc for every 8-bit value */ for (n = 0; n < 256; n++) { c = (unsigned long)n; for (k = 0; k < 8; k++) c = c & 1 ? poly ^ (c >> 1) : c >> 1; crc_table[0][n] = c; } #ifdef BYFOUR /* generate crc for each value followed by one, two, and three zeros, and then the byte reversal of those as well as the first table */ for (n = 0; n < 256; n++) { c = crc_table[0][n]; crc_table[4][n] = REV(c); for (k = 1; k < 4; k++) { c = crc_table[0][c & 0xff] ^ (c >> 8); crc_table[k][n] = c; crc_table[k + 4][n] = REV(c); } } #endif /* BYFOUR */ crc_table_empty = 0; } else { /* not first */ /* wait for the other guy to finish (not efficient, but rare) */ while (crc_table_empty) ; } #ifdef MAKECRCH /* write out CRC tables to crc32.h */ { FILE *out; out = fopen("crc32.h", "w"); if (out == NULL) return; fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); fprintf(out, "local const unsigned long FAR "); fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); write_table(out, crc_table[0]); # ifdef BYFOUR fprintf(out, "#ifdef BYFOUR\n"); for (k = 1; k < 8; k++) { fprintf(out, " },\n {\n"); write_table(out, crc_table[k]); } fprintf(out, "#endif\n"); # endif /* BYFOUR */ fprintf(out, " }\n};\n"); fclose(out); } #endif /* MAKECRCH */ } #ifdef MAKECRCH local void write_table(out, table) FILE *out; const unsigned long FAR *table; { int n; for (n = 0; n < 256; n++) fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); } #endif /* MAKECRCH */ #else /* !DYNAMIC_CRC_TABLE */ /* ======================================================================== * Tables of CRC-32s of all single-byte values, made by make_crc_table(). */ #include "crc32.h" #endif /* DYNAMIC_CRC_TABLE */ /* ========================================================================= * This function can be used by asm versions of crc32() */ const unsigned long FAR * ZEXPORT get_crc_table() { #ifdef DYNAMIC_CRC_TABLE if (crc_table_empty) make_crc_table(); #endif /* DYNAMIC_CRC_TABLE */ return (const unsigned long FAR *)crc_table; } /* ========================================================================= */ #define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 /* ========================================================================= */ unsigned long ZEXPORT crc32(crc, buf, len) unsigned long crc; const unsigned char FAR *buf; unsigned len; { if (buf == Z_NULL) return 0UL; #ifdef DYNAMIC_CRC_TABLE if (crc_table_empty) make_crc_table(); #endif /* DYNAMIC_CRC_TABLE */ #ifdef BYFOUR if (sizeof(void *) == sizeof(ptrdiff_t)) { u4 endian; endian = 1; if (*((unsigned char *)(&endian))) return crc32_little(crc, buf, len); else return crc32_big(crc, buf, len); } #endif /* BYFOUR */ crc = crc ^ 0xffffffffUL; while (len >= 8) { DO8; len -= 8; } if (len) do { DO1; } while (--len); return crc ^ 0xffffffffUL; } #ifdef BYFOUR /* ========================================================================= */ #define DOLIT4 c ^= *buf4++; \ c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] #define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 /* ========================================================================= */ local unsigned long crc32_little(crc, buf, len) unsigned long crc; const unsigned char FAR *buf; unsigned len; { register u4 c; register const u4 FAR *buf4; c = (u4)crc; c = ~c; while (len && ((ptrdiff_t)buf & 3)) { c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); len--; } buf4 = (const u4 FAR *)(const void FAR *)buf; while (len >= 32) { DOLIT32; len -= 32; } while (len >= 4) { DOLIT4; len -= 4; } buf = (const unsigned char FAR *)buf4; if (len) do { c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); } while (--len); c = ~c; return (unsigned long)c; } /* ========================================================================= */ #define DOBIG4 c ^= *++buf4; \ c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] #define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 /* ========================================================================= */ local unsigned long crc32_big(crc, buf, len) unsigned long crc; const unsigned char FAR *buf; unsigned len; { register u4 c; register const u4 FAR *buf4; c = REV((u4)crc); c = ~c; while (len && ((ptrdiff_t)buf & 3)) { c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); len--; } buf4 = (const u4 FAR *)(const void FAR *)buf; buf4--; while (len >= 32) { DOBIG32; len -= 32; } while (len >= 4) { DOBIG4; len -= 4; } buf4++; buf = (const unsigned char FAR *)buf4; if (len) do { c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); } while (--len); c = ~c; return (unsigned long)(REV(c)); } #endif /* BYFOUR */ #define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ /* ========================================================================= */ local unsigned long gf2_matrix_times(mat, vec) unsigned long *mat; unsigned long vec; { unsigned long sum; sum = 0; while (vec) { if (vec & 1) sum ^= *mat; vec >>= 1; mat++; } return sum; } /* ========================================================================= */ local void gf2_matrix_square(square, mat) unsigned long *square; unsigned long *mat; { int n; for (n = 0; n < GF2_DIM; n++) square[n] = gf2_matrix_times(mat, mat[n]); } /* ========================================================================= */ uLong ZEXPORT crc32_combine(crc1, crc2, len2) uLong crc1; uLong crc2; z_off_t len2; { int n; unsigned long row; unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ /* degenerate case */ if (len2 == 0) return crc1; /* put operator for one zero bit in odd */ odd[0] = 0xedb88320L; /* CRC-32 polynomial */ row = 1; for (n = 1; n < GF2_DIM; n++) { odd[n] = row; row <<= 1; } /* put operator for two zero bits in even */ gf2_matrix_square(even, odd); /* put operator for four zero bits in odd */ gf2_matrix_square(odd, even); /* apply len2 zeros to crc1 (first square will put the operator for one zero byte, eight zero bits, in even) */ do { /* apply zeros operator for this bit of len2 */ gf2_matrix_square(even, odd); if (len2 & 1) crc1 = gf2_matrix_times(even, crc1); len2 >>= 1; /* if no more bits set, then done */ if (len2 == 0) break; /* another iteration of the loop with odd and even swapped */ gf2_matrix_square(odd, even); if (len2 & 1) crc1 = gf2_matrix_times(odd, crc1); len2 >>= 1; /* if no more bits set, then done */ } while (len2 != 0); /* return combined crc */ crc1 ^= crc2; return crc1; } sks-ecc-0.93/zlib/inftrees.h0000644000175000017500000000450510604550750014675 0ustar nachonacho/* inftrees.h -- header to use inftrees.c * Copyright (C) 1995-2005 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ /* Structure for decoding tables. Each entry provides either the information needed to do the operation requested by the code that indexed that table entry, or it provides a pointer to another table that indexes more bits of the code. op indicates whether the entry is a pointer to another table, a literal, a length or distance, an end-of-block, or an invalid code. For a table pointer, the low four bits of op is the number of index bits of that table. For a length or distance, the low four bits of op is the number of extra bits to get after the code. bits is the number of bits in this code or part of the code to drop off of the bit buffer. val is the actual byte to output in the case of a literal, the base length or distance, or the offset from the current table to the next table. Each entry is four bytes. */ typedef struct { unsigned char op; /* operation, extra bits, table bits */ unsigned char bits; /* bits in this part of the code */ unsigned short val; /* offset in table or code value */ } code; /* op values as set by inflate_table(): 00000000 - literal 0000tttt - table link, tttt != 0 is the number of table index bits 0001eeee - length or distance, eeee is the number of extra bits 01100000 - end of block 01000000 - invalid code */ /* Maximum size of dynamic tree. The maximum found in a long but non- exhaustive search was 1444 code structures (852 for length/literals and 592 for distances, the latter actually the result of an exhaustive search). The true maximum is not known, but the value below is more than safe. */ #define ENOUGH 2048 #define MAXD 592 /* Type of code to build for inftable() */ typedef enum { CODES, LENS, DISTS } codetype; extern int inflate_table OF((codetype type, unsigned short FAR *lens, unsigned codes, code FAR * FAR *table, unsigned FAR *bits, unsigned short FAR *work)); sks-ecc-0.93/zlib/zutil.c0000644000175000017500000001574010604550750014223 0ustar nachonacho/* zutil.c -- target dependent utility functions for the compression library * Copyright (C) 1995-2005 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #include "zutil.h" #ifndef NO_DUMMY_DECL struct internal_state {int dummy;}; /* for buggy compilers */ #endif const char * const z_errmsg[10] = { "need dictionary", /* Z_NEED_DICT 2 */ "stream end", /* Z_STREAM_END 1 */ "", /* Z_OK 0 */ "file error", /* Z_ERRNO (-1) */ "stream error", /* Z_STREAM_ERROR (-2) */ "data error", /* Z_DATA_ERROR (-3) */ "insufficient memory", /* Z_MEM_ERROR (-4) */ "buffer error", /* Z_BUF_ERROR (-5) */ "incompatible version",/* Z_VERSION_ERROR (-6) */ ""}; const char * ZEXPORT zlibVersion() { return ZLIB_VERSION; } uLong ZEXPORT zlibCompileFlags() { uLong flags; flags = 0; switch (sizeof(uInt)) { case 2: break; case 4: flags += 1; break; case 8: flags += 2; break; default: flags += 3; } switch (sizeof(uLong)) { case 2: break; case 4: flags += 1 << 2; break; case 8: flags += 2 << 2; break; default: flags += 3 << 2; } switch (sizeof(voidpf)) { case 2: break; case 4: flags += 1 << 4; break; case 8: flags += 2 << 4; break; default: flags += 3 << 4; } switch (sizeof(z_off_t)) { case 2: break; case 4: flags += 1 << 6; break; case 8: flags += 2 << 6; break; default: flags += 3 << 6; } #ifdef DEBUG flags += 1 << 8; #endif #if defined(ASMV) || defined(ASMINF) flags += 1 << 9; #endif #ifdef ZLIB_WINAPI flags += 1 << 10; #endif #ifdef BUILDFIXED flags += 1 << 12; #endif #ifdef DYNAMIC_CRC_TABLE flags += 1 << 13; #endif #ifdef NO_GZCOMPRESS flags += 1L << 16; #endif #ifdef NO_GZIP flags += 1L << 17; #endif #ifdef PKZIP_BUG_WORKAROUND flags += 1L << 20; #endif #ifdef FASTEST flags += 1L << 21; #endif #ifdef STDC # ifdef NO_vsnprintf flags += 1L << 25; # ifdef HAS_vsprintf_void flags += 1L << 26; # endif # else # ifdef HAS_vsnprintf_void flags += 1L << 26; # endif # endif #else flags += 1L << 24; # ifdef NO_snprintf flags += 1L << 25; # ifdef HAS_sprintf_void flags += 1L << 26; # endif # else # ifdef HAS_snprintf_void flags += 1L << 26; # endif # endif #endif return flags; } #ifdef DEBUG # ifndef verbose # define verbose 0 # endif int z_verbose = verbose; void z_error (m) char *m; { fprintf(stderr, "%s\n", m); exit(1); } #endif /* exported to allow conversion of error code to string for compress() and * uncompress() */ const char * ZEXPORT zError(err) int err; { return ERR_MSG(err); } #if defined(_WIN32_WCE) /* The Microsoft C Run-Time Library for Windows CE doesn't have * errno. We define it as a global variable to simplify porting. * Its value is always 0 and should not be used. */ int errno = 0; #endif #ifndef HAVE_MEMCPY void zmemcpy(dest, source, len) Bytef* dest; const Bytef* source; uInt len; { if (len == 0) return; do { *dest++ = *source++; /* ??? to be unrolled */ } while (--len != 0); } int zmemcmp(s1, s2, len) const Bytef* s1; const Bytef* s2; uInt len; { uInt j; for (j = 0; j < len; j++) { if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; } return 0; } void zmemzero(dest, len) Bytef* dest; uInt len; { if (len == 0) return; do { *dest++ = 0; /* ??? to be unrolled */ } while (--len != 0); } #endif #ifdef SYS16BIT #ifdef __TURBOC__ /* Turbo C in 16-bit mode */ # define MY_ZCALLOC /* Turbo C malloc() does not allow dynamic allocation of 64K bytes * and farmalloc(64K) returns a pointer with an offset of 8, so we * must fix the pointer. Warning: the pointer must be put back to its * original form in order to free it, use zcfree(). */ #define MAX_PTR 10 /* 10*64K = 640K */ local int next_ptr = 0; typedef struct ptr_table_s { voidpf org_ptr; voidpf new_ptr; } ptr_table; local ptr_table table[MAX_PTR]; /* This table is used to remember the original form of pointers * to large buffers (64K). Such pointers are normalized with a zero offset. * Since MSDOS is not a preemptive multitasking OS, this table is not * protected from concurrent access. This hack doesn't work anyway on * a protected system like OS/2. Use Microsoft C instead. */ voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) { voidpf buf = opaque; /* just to make some compilers happy */ ulg bsize = (ulg)items*size; /* If we allocate less than 65520 bytes, we assume that farmalloc * will return a usable pointer which doesn't have to be normalized. */ if (bsize < 65520L) { buf = farmalloc(bsize); if (*(ush*)&buf != 0) return buf; } else { buf = farmalloc(bsize + 16L); } if (buf == NULL || next_ptr >= MAX_PTR) return NULL; table[next_ptr].org_ptr = buf; /* Normalize the pointer to seg:0 */ *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; *(ush*)&buf = 0; table[next_ptr++].new_ptr = buf; return buf; } void zcfree (voidpf opaque, voidpf ptr) { int n; if (*(ush*)&ptr != 0) { /* object < 64K */ farfree(ptr); return; } /* Find the original pointer */ for (n = 0; n < next_ptr; n++) { if (ptr != table[n].new_ptr) continue; farfree(table[n].org_ptr); while (++n < next_ptr) { table[n-1] = table[n]; } next_ptr--; return; } ptr = opaque; /* just to make some compilers happy */ Assert(0, "zcfree: ptr not found"); } #endif /* __TURBOC__ */ #ifdef M_I86 /* Microsoft C in 16-bit mode */ # define MY_ZCALLOC #if (!defined(_MSC_VER) || (_MSC_VER <= 600)) # define _halloc halloc # define _hfree hfree #endif voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) { if (opaque) opaque = 0; /* to make compiler happy */ return _halloc((long)items, size); } void zcfree (voidpf opaque, voidpf ptr) { if (opaque) opaque = 0; /* to make compiler happy */ _hfree(ptr); } #endif /* M_I86 */ #endif /* SYS16BIT */ #ifndef MY_ZCALLOC /* Any system without a special alloc function */ #ifndef STDC extern voidp malloc OF((uInt size)); extern voidp calloc OF((uInt items, uInt size)); extern void free OF((voidpf ptr)); #endif voidpf zcalloc (opaque, items, size) voidpf opaque; unsigned items; unsigned size; { if (opaque) items += size - size; /* make compiler happy */ return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : (voidpf)calloc(items, size); } void zcfree (opaque, ptr) voidpf opaque; voidpf ptr; { free(ptr); if (opaque) return; /* make compiler happy */ } #endif /* MY_ZCALLOC */ sks-ecc-0.93/zlib/trees.h0000644000175000017500000002037410604550750014202 0ustar nachonacho/* header created automatically with -DGEN_TREES_H */ local const ct_data static_ltree[L_CODES+2] = { {{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, {{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, {{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, {{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, {{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, {{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, {{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, {{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, {{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, {{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, {{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, {{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, {{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, {{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, {{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, {{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, {{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, {{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, {{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, {{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, {{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, {{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, {{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, {{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, {{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, {{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, {{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, {{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, {{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, {{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, {{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, {{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, {{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, {{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, {{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, {{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, {{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, {{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, {{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, {{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, {{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, {{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, {{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, {{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, {{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, {{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, {{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, {{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, {{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, {{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, {{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, {{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, {{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, {{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, {{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, {{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, {{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, {{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} }; local const ct_data static_dtree[D_CODES] = { {{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, {{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, {{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, {{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, {{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} }; const uch _dist_code[DIST_CODE_LEN] = { 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 }; const uch _length_code[MAX_MATCH-MIN_MATCH+1]= { 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 }; local const int base_length[LENGTH_CODES] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 0 }; local const int base_dist[D_CODES] = { 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 }; sks-ecc-0.93/zlib/README0000644000175000017500000001310010604550750013554 0ustar nachonachoZLIB DATA COMPRESSION LIBRARY zlib 1.2.3 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). These documents are also available in other formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html All functions of the compression library are documented in the file zlib.h (volunteer to write man pages welcome, contact zlib@gzip.org). A usage example of the library is given in the file example.c which also tests that the library is working correctly. Another example is given in the file minigzip.c. The compression library itself is composed of all source files except example.c and minigzip.c. To compile all files and run the test program, follow the instructions given at the top of Makefile. In short "make test; make install" should work for most machines. For Unix: "./configure; make test; make install". For MSDOS, use one of the special makefiles such as Makefile.msc. For VMS, use make_vms.com. Questions about zlib should be sent to , or to Gilles Vollant for the Windows DLL version. The zlib home page is http://www.zlib.org or http://www.gzip.org/zlib/ Before reporting a problem, please check this site to verify that you have the latest version of zlib; otherwise get the latest version and check whether the problem still exists or not. PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html before asking for help. Mark Nelson wrote an article about zlib for the Jan. 1997 issue of Dr. Dobb's Journal; a copy of the article is available in http://dogma.net/markn/articles/zlibtool/zlibtool.htm The changes made in version 1.2.3 are documented in the file ChangeLog. Unsupported third party contributions are provided in directory "contrib". A Java implementation of zlib is available in the Java Development Kit http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/package-summary.html See the zlib home page http://www.zlib.org for details. A Perl interface to zlib written by Paul Marquess is in the CPAN (Comprehensive Perl Archive Network) sites http://www.cpan.org/modules/by-module/Compress/ A Python interface to zlib written by A.M. Kuchling is available in Python 1.5 and later versions, see http://www.python.org/doc/lib/module-zlib.html A zlib binding for TCL written by Andreas Kupries is availlable at http://www.oche.de/~akupries/soft/trf/trf_zip.html An experimental package to read and write files in .zip format, written on top of zlib by Gilles Vollant , is available in the contrib/minizip directory of zlib. Notes for some targets: - For Windows DLL versions, please see win32/DLL_FAQ.txt - For 64-bit Irix, deflate.c must be compiled without any optimization. With -O, one libpng test fails. The test works in 32 bit mode (with the -n32 compiler flag). The compiler bug has been reported to SGI. - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works when compiled with cc. - On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is necessary to get gzprintf working correctly. This is done by configure. - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with other compilers. Use "make test" to check your compiler. - gzdopen is not supported on RISCOS, BEOS and by some Mac compilers. - For PalmOs, see http://palmzlib.sourceforge.net/ - When building a shared, i.e. dynamic library on Mac OS X, the library must be installed before testing (do "make install" before "make test"), since the library location is specified in the library. Acknowledgments: The deflate format used by zlib was defined by Phil Katz. The deflate and zlib specifications were written by L. Peter Deutsch. Thanks to all the people who reported problems and suggested various improvements in zlib; they are too numerous to cite here. Copyright notice: (C) 1995-2004 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 If you use the zlib library in a product, we would appreciate *not* receiving lengthy legal documents to sign. The sources are provided for free but without warranty of any kind. The library has been entirely written by Jean-loup Gailly and Mark Adler; it does not include third-party code. If you redistribute modified sources, we would appreciate that you include in the file ChangeLog history information documenting your changes. Please read the FAQ for more information on the distribution of modified source versions. sks-ecc-0.93/zlib/crc32.h0000644000175000017500000007355010604550750014000 0ustar nachonacho/* crc32.h -- tables for rapid CRC calculation * Generated automatically by crc32.c */ local const unsigned long FAR crc_table[TBLS][256] = { { 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, 0x2d02ef8dUL #ifdef BYFOUR }, { 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, 0x9324fd72UL }, { 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, 0xbe9834edUL }, { 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, 0xde0506f1UL }, { 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, 0x8def022dUL }, { 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, 0x72fd2493UL }, { 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, 0xed3498beUL }, { 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, 0xf10605deUL #endif } }; sks-ecc-0.93/zlib/examples/0000755000175000017500000000000010604550750014517 5ustar nachonachosks-ecc-0.93/zlib/examples/gzappend.c0000644000175000017500000004070610604550750016502 0ustar nachonacho/* gzappend -- command to append to a gzip file Copyright (C) 2003 Mark Adler, all rights reserved version 1.1, 4 Nov 2003 This software is provided 'as-is', without any express or implied warranty. In no event will the author 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. Mark Adler madler@alumni.caltech.edu */ /* * Change history: * * 1.0 19 Oct 2003 - First version * 1.1 4 Nov 2003 - Expand and clarify some comments and notes * - Add version and copyright to help * - Send help to stdout instead of stderr * - Add some preemptive typecasts * - Add L to constants in lseek() calls * - Remove some debugging information in error messages * - Use new data_type definition for zlib 1.2.1 * - Simplfy and unify file operations * - Finish off gzip file in gztack() * - Use deflatePrime() instead of adding empty blocks * - Keep gzip file clean on appended file read errors * - Use in-place rotate instead of auxiliary buffer * (Why you ask? Because it was fun to write!) */ /* gzappend takes a gzip file and appends to it, compressing files from the command line or data from stdin. The gzip file is written to directly, to avoid copying that file, in case it's large. Note that this results in the unfriendly behavior that if gzappend fails, the gzip file is corrupted. This program was written to illustrate the use of the new Z_BLOCK option of zlib 1.2.x's inflate() function. This option returns from inflate() at each block boundary to facilitate locating and modifying the last block bit at the start of the final deflate block. Also whether using Z_BLOCK or not, another required feature of zlib 1.2.x is that inflate() now provides the number of unusued bits in the last input byte used. gzappend will not work with versions of zlib earlier than 1.2.1. gzappend first decompresses the gzip file internally, discarding all but the last 32K of uncompressed data, and noting the location of the last block bit and the number of unused bits in the last byte of the compressed data. The gzip trailer containing the CRC-32 and length of the uncompressed data is verified. This trailer will be later overwritten. Then the last block bit is cleared by seeking back in the file and rewriting the byte that contains it. Seeking forward, the last byte of the compressed data is saved along with the number of unused bits to initialize deflate. A deflate process is initialized, using the last 32K of the uncompressed data from the gzip file to initialize the dictionary. If the total uncompressed data was less than 32K, then all of it is used to initialize the dictionary. The deflate output bit buffer is also initialized with the last bits from the original deflate stream. From here on, the data to append is simply compressed using deflate, and written to the gzip file. When that is complete, the new CRC-32 and uncompressed length are written as the trailer of the gzip file. */ #include #include #include #include #include #include "zlib.h" #define local static #define LGCHUNK 14 #define CHUNK (1U << LGCHUNK) #define DSIZE 32768U /* print an error message and terminate with extreme prejudice */ local void bye(char *msg1, char *msg2) { fprintf(stderr, "gzappend error: %s%s\n", msg1, msg2); exit(1); } /* return the greatest common divisor of a and b using Euclid's algorithm, modified to be fast when one argument much greater than the other, and coded to avoid unnecessary swapping */ local unsigned gcd(unsigned a, unsigned b) { unsigned c; while (a && b) if (a > b) { c = b; while (a - c >= c) c <<= 1; a -= c; } else { c = a; while (b - c >= c) c <<= 1; b -= c; } return a + b; } /* rotate list[0..len-1] left by rot positions, in place */ local void rotate(unsigned char *list, unsigned len, unsigned rot) { unsigned char tmp; unsigned cycles; unsigned char *start, *last, *to, *from; /* normalize rot and handle degenerate cases */ if (len < 2) return; if (rot >= len) rot %= len; if (rot == 0) return; /* pointer to last entry in list */ last = list + (len - 1); /* do simple left shift by one */ if (rot == 1) { tmp = *list; memcpy(list, list + 1, len - 1); *last = tmp; return; } /* do simple right shift by one */ if (rot == len - 1) { tmp = *last; memmove(list + 1, list, len - 1); *list = tmp; return; } /* otherwise do rotate as a set of cycles in place */ cycles = gcd(len, rot); /* number of cycles */ do { start = from = list + cycles; /* start index is arbitrary */ tmp = *from; /* save entry to be overwritten */ for (;;) { to = from; /* next step in cycle */ from += rot; /* go right rot positions */ if (from > last) from -= len; /* (pointer better not wrap) */ if (from == start) break; /* all but one shifted */ *to = *from; /* shift left */ } *to = tmp; /* complete the circle */ } while (--cycles); } /* structure for gzip file read operations */ typedef struct { int fd; /* file descriptor */ int size; /* 1 << size is bytes in buf */ unsigned left; /* bytes available at next */ unsigned char *buf; /* buffer */ unsigned char *next; /* next byte in buffer */ char *name; /* file name for error messages */ } file; /* reload buffer */ local int readin(file *in) { int len; len = read(in->fd, in->buf, 1 << in->size); if (len == -1) bye("error reading ", in->name); in->left = (unsigned)len; in->next = in->buf; return len; } /* read from file in, exit if end-of-file */ local int readmore(file *in) { if (readin(in) == 0) bye("unexpected end of ", in->name); return 0; } #define read1(in) (in->left == 0 ? readmore(in) : 0, \ in->left--, *(in->next)++) /* skip over n bytes of in */ local void skip(file *in, unsigned n) { unsigned bypass; if (n > in->left) { n -= in->left; bypass = n & ~((1U << in->size) - 1); if (bypass) { if (lseek(in->fd, (off_t)bypass, SEEK_CUR) == -1) bye("seeking ", in->name); n -= bypass; } readmore(in); if (n > in->left) bye("unexpected end of ", in->name); } in->left -= n; in->next += n; } /* read a four-byte unsigned integer, little-endian, from in */ unsigned long read4(file *in) { unsigned long val; val = read1(in); val += (unsigned)read1(in) << 8; val += (unsigned long)read1(in) << 16; val += (unsigned long)read1(in) << 24; return val; } /* skip over gzip header */ local void gzheader(file *in) { int flags; unsigned n; if (read1(in) != 31 || read1(in) != 139) bye(in->name, " not a gzip file"); if (read1(in) != 8) bye("unknown compression method in", in->name); flags = read1(in); if (flags & 0xe0) bye("unknown header flags set in", in->name); skip(in, 6); if (flags & 4) { n = read1(in); n += (unsigned)(read1(in)) << 8; skip(in, n); } if (flags & 8) while (read1(in) != 0) ; if (flags & 16) while (read1(in) != 0) ; if (flags & 2) skip(in, 2); } /* decompress gzip file "name", return strm with a deflate stream ready to continue compression of the data in the gzip file, and return a file descriptor pointing to where to write the compressed data -- the deflate stream is initialized to compress using level "level" */ local int gzscan(char *name, z_stream *strm, int level) { int ret, lastbit, left, full; unsigned have; unsigned long crc, tot; unsigned char *window; off_t lastoff, end; file gz; /* open gzip file */ gz.name = name; gz.fd = open(name, O_RDWR, 0); if (gz.fd == -1) bye("cannot open ", name); gz.buf = malloc(CHUNK); if (gz.buf == NULL) bye("out of memory", ""); gz.size = LGCHUNK; gz.left = 0; /* skip gzip header */ gzheader(&gz); /* prepare to decompress */ window = malloc(DSIZE); if (window == NULL) bye("out of memory", ""); strm->zalloc = Z_NULL; strm->zfree = Z_NULL; strm->opaque = Z_NULL; ret = inflateInit2(strm, -15); if (ret != Z_OK) bye("out of memory", " or library mismatch"); /* decompress the deflate stream, saving append information */ lastbit = 0; lastoff = lseek(gz.fd, 0L, SEEK_CUR) - gz.left; left = 0; strm->avail_in = gz.left; strm->next_in = gz.next; crc = crc32(0L, Z_NULL, 0); have = full = 0; do { /* if needed, get more input */ if (strm->avail_in == 0) { readmore(&gz); strm->avail_in = gz.left; strm->next_in = gz.next; } /* set up output to next available section of sliding window */ strm->avail_out = DSIZE - have; strm->next_out = window + have; /* inflate and check for errors */ ret = inflate(strm, Z_BLOCK); if (ret == Z_STREAM_ERROR) bye("internal stream error!", ""); if (ret == Z_MEM_ERROR) bye("out of memory", ""); if (ret == Z_DATA_ERROR) bye("invalid compressed data--format violated in", name); /* update crc and sliding window pointer */ crc = crc32(crc, window + have, DSIZE - have - strm->avail_out); if (strm->avail_out) have = DSIZE - strm->avail_out; else { have = 0; full = 1; } /* process end of block */ if (strm->data_type & 128) { if (strm->data_type & 64) left = strm->data_type & 0x1f; else { lastbit = strm->data_type & 0x1f; lastoff = lseek(gz.fd, 0L, SEEK_CUR) - strm->avail_in; } } } while (ret != Z_STREAM_END); inflateEnd(strm); gz.left = strm->avail_in; gz.next = strm->next_in; /* save the location of the end of the compressed data */ end = lseek(gz.fd, 0L, SEEK_CUR) - gz.left; /* check gzip trailer and save total for deflate */ if (crc != read4(&gz)) bye("invalid compressed data--crc mismatch in ", name); tot = strm->total_out; if ((tot & 0xffffffffUL) != read4(&gz)) bye("invalid compressed data--length mismatch in", name); /* if not at end of file, warn */ if (gz.left || readin(&gz)) fprintf(stderr, "gzappend warning: junk at end of gzip file overwritten\n"); /* clear last block bit */ lseek(gz.fd, lastoff - (lastbit != 0), SEEK_SET); if (read(gz.fd, gz.buf, 1) != 1) bye("reading after seek on ", name); *gz.buf = (unsigned char)(*gz.buf ^ (1 << ((8 - lastbit) & 7))); lseek(gz.fd, -1L, SEEK_CUR); if (write(gz.fd, gz.buf, 1) != 1) bye("writing after seek to ", name); /* if window wrapped, build dictionary from window by rotating */ if (full) { rotate(window, DSIZE, have); have = DSIZE; } /* set up deflate stream with window, crc, total_in, and leftover bits */ ret = deflateInit2(strm, level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY); if (ret != Z_OK) bye("out of memory", ""); deflateSetDictionary(strm, window, have); strm->adler = crc; strm->total_in = tot; if (left) { lseek(gz.fd, --end, SEEK_SET); if (read(gz.fd, gz.buf, 1) != 1) bye("reading after seek on ", name); deflatePrime(strm, 8 - left, *gz.buf); } lseek(gz.fd, end, SEEK_SET); /* clean up and return */ free(window); free(gz.buf); return gz.fd; } /* append file "name" to gzip file gd using deflate stream strm -- if last is true, then finish off the deflate stream at the end */ local void gztack(char *name, int gd, z_stream *strm, int last) { int fd, len, ret; unsigned left; unsigned char *in, *out; /* open file to compress and append */ fd = 0; if (name != NULL) { fd = open(name, O_RDONLY, 0); if (fd == -1) fprintf(stderr, "gzappend warning: %s not found, skipping ...\n", name); } /* allocate buffers */ in = fd == -1 ? NULL : malloc(CHUNK); out = malloc(CHUNK); if (out == NULL) bye("out of memory", ""); /* compress input file and append to gzip file */ do { /* get more input */ len = fd == -1 ? 0 : read(fd, in, CHUNK); if (len == -1) { fprintf(stderr, "gzappend warning: error reading %s, skipping rest ...\n", name); len = 0; } strm->avail_in = (unsigned)len; strm->next_in = in; if (len) strm->adler = crc32(strm->adler, in, (unsigned)len); /* compress and write all available output */ do { strm->avail_out = CHUNK; strm->next_out = out; ret = deflate(strm, last && len == 0 ? Z_FINISH : Z_NO_FLUSH); left = CHUNK - strm->avail_out; while (left) { len = write(gd, out + CHUNK - strm->avail_out - left, left); if (len == -1) bye("writing gzip file", ""); left -= (unsigned)len; } } while (strm->avail_out == 0 && ret != Z_STREAM_END); } while (len != 0); /* write trailer after last entry */ if (last) { deflateEnd(strm); out[0] = (unsigned char)(strm->adler); out[1] = (unsigned char)(strm->adler >> 8); out[2] = (unsigned char)(strm->adler >> 16); out[3] = (unsigned char)(strm->adler >> 24); out[4] = (unsigned char)(strm->total_in); out[5] = (unsigned char)(strm->total_in >> 8); out[6] = (unsigned char)(strm->total_in >> 16); out[7] = (unsigned char)(strm->total_in >> 24); len = 8; do { ret = write(gd, out + 8 - len, len); if (ret == -1) bye("writing gzip file", ""); len -= ret; } while (len); close(gd); } /* clean up and return */ free(out); if (in != NULL) free(in); if (fd > 0) close(fd); } /* process the compression level option if present, scan the gzip file, and append the specified files, or append the data from stdin if no other file names are provided on the command line -- the gzip file must be writable and seekable */ int main(int argc, char **argv) { int gd, level; z_stream strm; /* ignore command name */ argv++; /* provide usage if no arguments */ if (*argv == NULL) { printf("gzappend 1.1 (4 Nov 2003) Copyright (C) 2003 Mark Adler\n"); printf( "usage: gzappend [-level] file.gz [ addthis [ andthis ... ]]\n"); return 0; } /* set compression level */ level = Z_DEFAULT_COMPRESSION; if (argv[0][0] == '-') { if (argv[0][1] < '0' || argv[0][1] > '9' || argv[0][2] != 0) bye("invalid compression level", ""); level = argv[0][1] - '0'; if (*++argv == NULL) bye("no gzip file name after options", ""); } /* prepare to append to gzip file */ gd = gzscan(*argv++, &strm, level); /* append files on command line, or from stdin if none */ if (*argv == NULL) gztack(NULL, gd, &strm, 1); else do { gztack(*argv, gd, &strm, argv[1] == NULL); } while (*++argv != NULL); return 0; } sks-ecc-0.93/zlib/examples/gzlog.c0000644000175000017500000002641410604550750016014 0ustar nachonacho/* * gzlog.c * Copyright (C) 2004 Mark Adler * For conditions of distribution and use, see copyright notice in gzlog.h * version 1.0, 26 Nov 2004 * */ #include /* memcmp() */ #include /* malloc(), free(), NULL */ #include /* size_t, off_t */ #include /* read(), close(), sleep(), ftruncate(), */ /* lseek() */ #include /* open() */ #include /* flock() */ #include "zlib.h" /* deflateInit2(), deflate(), deflateEnd() */ #include "gzlog.h" /* interface */ #define local static /* log object structure */ typedef struct { int id; /* object identifier */ int fd; /* log file descriptor */ off_t extra; /* offset of extra "ap" subfield */ off_t mark_off; /* offset of marked data */ off_t last_off; /* offset of last block */ unsigned long crc; /* uncompressed crc */ unsigned long len; /* uncompressed length (modulo 2^32) */ unsigned stored; /* length of current stored block */ } gz_log; #define GZLOGID 19334 /* gz_log object identifier */ #define LOCK_RETRY 1 /* retry lock once a second */ #define LOCK_PATIENCE 1200 /* try about twenty minutes before forcing */ /* acquire a lock on a file */ local int lock(int fd) { int patience; /* try to lock every LOCK_RETRY seconds for LOCK_PATIENCE seconds */ patience = LOCK_PATIENCE; do { if (flock(fd, LOCK_EX + LOCK_NB) == 0) return 0; (void)sleep(LOCK_RETRY); patience -= LOCK_RETRY; } while (patience > 0); /* we've run out of patience -- give up */ return -1; } /* release lock */ local void unlock(int fd) { (void)flock(fd, LOCK_UN); } /* release a log object */ local void log_clean(gz_log *log) { unlock(log->fd); (void)close(log->fd); free(log); } /* read an unsigned long from a byte buffer little-endian */ local unsigned long make_ulg(unsigned char *buf) { int n; unsigned long val; val = (unsigned long)(*buf++); for (n = 8; n < 32; n += 8) val += (unsigned long)(*buf++) << n; return val; } /* read an off_t from a byte buffer little-endian */ local off_t make_off(unsigned char *buf) { int n; off_t val; val = (off_t)(*buf++); for (n = 8; n < 64; n += 8) val += (off_t)(*buf++) << n; return val; } /* write an unsigned long little-endian to byte buffer */ local void dice_ulg(unsigned long val, unsigned char *buf) { int n; for (n = 0; n < 4; n++) { *buf++ = val & 0xff; val >>= 8; } } /* write an off_t little-endian to byte buffer */ local void dice_off(off_t val, unsigned char *buf) { int n; for (n = 0; n < 8; n++) { *buf++ = val & 0xff; val >>= 8; } } /* initial, empty gzip file for appending */ local char empty_gz[] = { 0x1f, 0x8b, /* magic gzip id */ 8, /* compression method is deflate */ 4, /* there is an extra field */ 0, 0, 0, 0, /* no modification time provided */ 0, 0xff, /* no extra flags, no OS */ 20, 0, 'a', 'p', 16, 0, /* extra field with "ap" subfield */ 32, 0, 0, 0, 0, 0, 0, 0, /* offset of uncompressed data */ 32, 0, 0, 0, 0, 0, 0, 0, /* offset of last block */ 1, 0, 0, 0xff, 0xff, /* empty stored block (last) */ 0, 0, 0, 0, /* crc */ 0, 0, 0, 0 /* uncompressed length */ }; /* initialize a log object with locking */ void *gzlog_open(char *path) { unsigned xlen; unsigned char temp[20]; unsigned sub_len; int good; gz_log *log; /* allocate log structure */ log = malloc(sizeof(gz_log)); if (log == NULL) return NULL; log->id = GZLOGID; /* open file, creating it if necessary, and locking it */ log->fd = open(path, O_RDWR | O_CREAT, 0600); if (log->fd < 0) { free(log); return NULL; } if (lock(log->fd)) { close(log->fd); free(log); return NULL; } /* if file is empty, write new gzip stream */ if (lseek(log->fd, 0, SEEK_END) == 0) { if (write(log->fd, empty_gz, sizeof(empty_gz)) != sizeof(empty_gz)) { log_clean(log); return NULL; } } /* check gzip header */ (void)lseek(log->fd, 0, SEEK_SET); if (read(log->fd, temp, 12) != 12 || temp[0] != 0x1f || temp[1] != 0x8b || temp[2] != 8 || (temp[3] & 4) == 0) { log_clean(log); return NULL; } /* process extra field to find "ap" sub-field */ xlen = temp[10] + (temp[11] << 8); good = 0; while (xlen) { if (xlen < 4 || read(log->fd, temp, 4) != 4) break; sub_len = temp[2]; sub_len += temp[3] << 8; xlen -= 4; if (memcmp(temp, "ap", 2) == 0 && sub_len == 16) { good = 1; break; } if (xlen < sub_len) break; (void)lseek(log->fd, sub_len, SEEK_CUR); xlen -= sub_len; } if (!good) { log_clean(log); return NULL; } /* read in "ap" sub-field */ log->extra = lseek(log->fd, 0, SEEK_CUR); if (read(log->fd, temp, 16) != 16) { log_clean(log); return NULL; } log->mark_off = make_off(temp); log->last_off = make_off(temp + 8); /* get crc, length of gzip file */ (void)lseek(log->fd, log->last_off, SEEK_SET); if (read(log->fd, temp, 13) != 13 || memcmp(temp, "\001\000\000\377\377", 5) != 0) { log_clean(log); return NULL; } log->crc = make_ulg(temp + 5); log->len = make_ulg(temp + 9); /* set up to write over empty last block */ (void)lseek(log->fd, log->last_off + 5, SEEK_SET); log->stored = 0; return (void *)log; } /* maximum amount to put in a stored block before starting a new one */ #define MAX_BLOCK 16384 /* write a block to a log object */ int gzlog_write(void *obj, char *data, size_t len) { size_t some; unsigned char temp[5]; gz_log *log; /* check object */ log = (gz_log *)obj; if (log == NULL || log->id != GZLOGID) return 1; /* write stored blocks until all of the input is written */ do { some = MAX_BLOCK - log->stored; if (some > len) some = len; if (write(log->fd, data, some) != some) return 1; log->crc = crc32(log->crc, data, some); log->len += some; len -= some; data += some; log->stored += some; /* if the stored block is full, end it and start another */ if (log->stored == MAX_BLOCK) { (void)lseek(log->fd, log->last_off, SEEK_SET); temp[0] = 0; dice_ulg(log->stored + ((unsigned long)(~log->stored) << 16), temp + 1); if (write(log->fd, temp, 5) != 5) return 1; log->last_off = lseek(log->fd, log->stored, SEEK_CUR); (void)lseek(log->fd, 5, SEEK_CUR); log->stored = 0; } } while (len); return 0; } /* recompress the remaining stored deflate data in place */ local int recomp(gz_log *log) { z_stream strm; size_t len, max; unsigned char *in; unsigned char *out; unsigned char temp[16]; /* allocate space and read it all in (it's around 1 MB) */ len = log->last_off - log->mark_off; max = len + (len >> 12) + (len >> 14) + 11; out = malloc(max); if (out == NULL) return 1; in = malloc(len); if (in == NULL) { free(out); return 1; } (void)lseek(log->fd, log->mark_off, SEEK_SET); if (read(log->fd, in, len) != len) { free(in); free(out); return 1; } /* recompress in memory, decoding stored data as we go */ /* note: this assumes that unsigned is four bytes or more */ /* consider not making that assumption */ strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; if (deflateInit2(&strm, Z_BEST_COMPRESSION, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) { free(in); free(out); return 1; } strm.next_in = in; strm.avail_out = max; strm.next_out = out; while (len >= 5) { if (strm.next_in[0] != 0) break; strm.avail_in = strm.next_in[1] + (strm.next_in[2] << 8); strm.next_in += 5; len -= 5; if (strm.avail_in != 0) { if (len < strm.avail_in) break; len -= strm.avail_in; (void)deflate(&strm, Z_NO_FLUSH); if (strm.avail_in != 0 || strm.avail_out == 0) break; } } (void)deflate(&strm, Z_SYNC_FLUSH); (void)deflateEnd(&strm); free(in); if (len != 0 || strm.avail_out == 0) { free(out); return 1; } /* overwrite stored data with compressed data */ (void)lseek(log->fd, log->mark_off, SEEK_SET); len = max - strm.avail_out; if (write(log->fd, out, len) != len) { free(out); return 1; } free(out); /* write last empty block, crc, and length */ log->mark_off = log->last_off = lseek(log->fd, 0, SEEK_CUR); temp[0] = 1; dice_ulg(0xffffL << 16, temp + 1); dice_ulg(log->crc, temp + 5); dice_ulg(log->len, temp + 9); if (write(log->fd, temp, 13) != 13) return 1; /* truncate file to discard remaining stored data and old trailer */ ftruncate(log->fd, lseek(log->fd, 0, SEEK_CUR)); /* update extra field to point to new last empty block */ (void)lseek(log->fd, log->extra, SEEK_SET); dice_off(log->mark_off, temp); dice_off(log->last_off, temp + 8); if (write(log->fd, temp, 16) != 16) return 1; return 0; } /* maximum accumulation of stored blocks before compressing */ #define MAX_STORED 1048576 /* close log object */ int gzlog_close(void *obj) { unsigned char temp[8]; gz_log *log; /* check object */ log = (gz_log *)obj; if (log == NULL || log->id != GZLOGID) return 1; /* go to start of most recent block being written */ (void)lseek(log->fd, log->last_off, SEEK_SET); /* if some stuff was put there, update block */ if (log->stored) { temp[0] = 0; dice_ulg(log->stored + ((unsigned long)(~log->stored) << 16), temp + 1); if (write(log->fd, temp, 5) != 5) return 1; log->last_off = lseek(log->fd, log->stored, SEEK_CUR); } /* write last block (empty) */ if (write(log->fd, "\001\000\000\377\377", 5) != 5) return 1; /* write updated crc and uncompressed length */ dice_ulg(log->crc, temp); dice_ulg(log->len, temp + 4); if (write(log->fd, temp, 8) != 8) return 1; /* put offset of that last block in gzip extra block */ (void)lseek(log->fd, log->extra + 8, SEEK_SET); dice_off(log->last_off, temp); if (write(log->fd, temp, 8) != 8) return 1; /* if more than 1 MB stored, then time to compress it */ if (log->last_off - log->mark_off > MAX_STORED) { if (recomp(log)) return 1; } /* unlock and close file */ log_clean(log); return 0; } sks-ecc-0.93/zlib/examples/zpipe.c0000644000175000017500000001326710604550750016023 0ustar nachonacho/* zpipe.c: example of proper use of zlib's inflate() and deflate() Not copyrighted -- provided to the public domain Version 1.2 9 November 2004 Mark Adler */ /* Version history: 1.0 30 Oct 2004 First version 1.1 8 Nov 2004 Add void casting for unused return values Use switch statement for inflate() return values 1.2 9 Nov 2004 Add assertions to document zlib guarantees 1.3 6 Apr 2005 Remove incorrect assertion in inf() */ #include #include #include #include "zlib.h" #define CHUNK 16384 /* Compress from file source to file dest until EOF on source. def() returns Z_OK on success, Z_MEM_ERROR if memory could not be allocated for processing, Z_STREAM_ERROR if an invalid compression level is supplied, Z_VERSION_ERROR if the version of zlib.h and the version of the library linked do not match, or Z_ERRNO if there is an error reading or writing the files. */ int def(FILE *source, FILE *dest, int level) { int ret, flush; unsigned have; z_stream strm; char in[CHUNK]; char out[CHUNK]; /* allocate deflate state */ strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; ret = deflateInit(&strm, level); if (ret != Z_OK) return ret; /* compress until end of file */ do { strm.avail_in = fread(in, 1, CHUNK, source); if (ferror(source)) { (void)deflateEnd(&strm); return Z_ERRNO; } flush = feof(source) ? Z_FINISH : Z_NO_FLUSH; strm.next_in = in; /* run deflate() on input until output buffer not full, finish compression if all of source has been read in */ do { strm.avail_out = CHUNK; strm.next_out = out; ret = deflate(&strm, flush); /* no bad return value */ assert(ret != Z_STREAM_ERROR); /* state not clobbered */ have = CHUNK - strm.avail_out; if (fwrite(out, 1, have, dest) != have || ferror(dest)) { (void)deflateEnd(&strm); return Z_ERRNO; } } while (strm.avail_out == 0); assert(strm.avail_in == 0); /* all input will be used */ /* done when last data in file processed */ } while (flush != Z_FINISH); assert(ret == Z_STREAM_END); /* stream will be complete */ /* clean up and return */ (void)deflateEnd(&strm); return Z_OK; } /* Decompress from file source to file dest until stream ends or EOF. inf() returns Z_OK on success, Z_MEM_ERROR if memory could not be allocated for processing, Z_DATA_ERROR if the deflate data is invalid or incomplete, Z_VERSION_ERROR if the version of zlib.h and the version of the library linked do not match, or Z_ERRNO if there is an error reading or writing the files. */ int inf(FILE *source, FILE *dest) { int ret; unsigned have; z_stream strm; char in[CHUNK]; char out[CHUNK]; /* allocate inflate state */ strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; strm.avail_in = 0; strm.next_in = Z_NULL; ret = inflateInit(&strm); if (ret != Z_OK) return ret; /* decompress until deflate stream ends or end of file */ do { strm.avail_in = fread(in, 1, CHUNK, source); if (ferror(source)) { (void)inflateEnd(&strm); return Z_ERRNO; } if (strm.avail_in == 0) break; strm.next_in = in; /* run inflate() on input until output buffer not full */ do { strm.avail_out = CHUNK; strm.next_out = out; ret = inflate(&strm, Z_NO_FLUSH); assert(ret != Z_STREAM_ERROR); /* state not clobbered */ switch (ret) { case Z_NEED_DICT: ret = Z_DATA_ERROR; /* and fall through */ case Z_DATA_ERROR: case Z_MEM_ERROR: (void)inflateEnd(&strm); return ret; } have = CHUNK - strm.avail_out; if (fwrite(out, 1, have, dest) != have || ferror(dest)) { (void)inflateEnd(&strm); return Z_ERRNO; } } while (strm.avail_out == 0); /* done when inflate() says it's done */ } while (ret != Z_STREAM_END); /* clean up and return */ (void)inflateEnd(&strm); return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR; } /* report a zlib or i/o error */ void zerr(int ret) { fputs("zpipe: ", stderr); switch (ret) { case Z_ERRNO: if (ferror(stdin)) fputs("error reading stdin\n", stderr); if (ferror(stdout)) fputs("error writing stdout\n", stderr); break; case Z_STREAM_ERROR: fputs("invalid compression level\n", stderr); break; case Z_DATA_ERROR: fputs("invalid or incomplete deflate data\n", stderr); break; case Z_MEM_ERROR: fputs("out of memory\n", stderr); break; case Z_VERSION_ERROR: fputs("zlib version mismatch!\n", stderr); } } /* compress or decompress from stdin to stdout */ int main(int argc, char **argv) { int ret; /* do compression if no arguments */ if (argc == 1) { ret = def(stdin, stdout, Z_DEFAULT_COMPRESSION); if (ret != Z_OK) zerr(ret); return ret; } /* do decompression if -d specified */ else if (argc == 2 && strcmp(argv[1], "-d") == 0) { ret = inf(stdin, stdout); if (ret != Z_OK) zerr(ret); return ret; } /* otherwise, report usage */ else { fputs("zpipe usage: zpipe [-d] < source > dest\n", stderr); return 1; } } sks-ecc-0.93/zlib/examples/zlib_how.html0000644000175000017500000006773710604550750017246 0ustar nachonacho zlib Usage Example

zlib Usage Example

We often get questions about how the deflate() and inflate() functions should be used. Users wonder when they should provide more input, when they should use more output, what to do with a Z_BUF_ERROR, how to make sure the process terminates properly, and so on. So for those who have read zlib.h (a few times), and would like further edification, below is an annotated example in C of simple routines to compress and decompress from an input file to an output file using deflate() and inflate() respectively. The annotations are interspersed between lines of the code. So please read between the lines. We hope this helps explain some of the intricacies of zlib.

Without further adieu, here is the program zpipe.c:


/* zpipe.c: example of proper use of zlib's inflate() and deflate()
   Not copyrighted -- provided to the public domain
   Version 1.2  9 November 2004  Mark Adler */

/* Version history:
   1.0  30 Oct 2004  First version
   1.1   8 Nov 2004  Add void casting for unused return values
                     Use switch statement for inflate() return values
   1.2   9 Nov 2004  Add assertions to document zlib guarantees
 */
We now include the header files for the required definitions. From stdio.h we use fopen(), fread(), fwrite(), feof(), ferror(), and fclose() for file i/o, and fputs() for error messages. From string.h we use strcmp() for command line argument processing. From assert.h we use the assert() macro. From zlib.h we use the basic compression functions deflateInit(), deflate(), and deflateEnd(), and the basic decompression functions inflateInit(), inflate(), and inflateEnd().

#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "zlib.h"
CHUNK is simply the buffer size for feeding data to and pulling data from the zlib routines. Larger buffer sizes would be more efficient, especially for inflate(). If the memory is available, buffers sizes on the order of 128K or 256K bytes should be used.

#define CHUNK 16384
The def() routine compresses data from an input file to an output file. The output data will be in the zlib format, which is different from the gzip or zip formats. The zlib format has a very small header of only two bytes to identify it as a zlib stream and to provide decoding information, and a four-byte trailer with a fast check value to verify the integrity of the uncompressed data after decoding.

/* Compress from file source to file dest until EOF on source.
   def() returns Z_OK on success, Z_MEM_ERROR if memory could not be
   allocated for processing, Z_STREAM_ERROR if an invalid compression
   level is supplied, Z_VERSION_ERROR if the version of zlib.h and the
   version of the library linked do not match, or Z_ERRNO if there is
   an error reading or writing the files. */
int def(FILE *source, FILE *dest, int level)
{
Here are the local variables for def(). ret will be used for zlib return codes. flush will keep track of the current flushing state for deflate(), which is either no flushing, or flush to completion after the end of the input file is reached. have is the amount of data returned from deflate(). The strm structure is used to pass information to and from the zlib routines, and to maintain the deflate() state. in and out are the input and output buffers for deflate().

    int ret, flush;
    unsigned have;
    z_stream strm;
    char in[CHUNK];
    char out[CHUNK];
The first thing we do is to initialize the zlib state for compression using deflateInit(). This must be done before the first use of deflate(). The zalloc, zfree, and opaque fields in the strm structure must be initialized before calling deflateInit(). Here they are set to the zlib constant Z_NULL to request that zlib use the default memory allocation routines. An application may also choose to provide custom memory allocation routines here. deflateInit() will allocate on the order of 256K bytes for the internal state. (See zlib Technical Details.)

deflateInit() is called with a pointer to the structure to be initialized and the compression level, which is an integer in the range of -1 to 9. Lower compression levels result in faster execution, but less compression. Higher levels result in greater compression, but slower execution. The zlib constant Z_DEFAULT_COMPRESSION, equal to -1, provides a good compromise between compression and speed and is equivalent to level 6. Level 0 actually does no compression at all, and in fact expands the data slightly to produce the zlib format (it is not a byte-for-byte copy of the input). More advanced applications of zlib may use deflateInit2() here instead. Such an application may want to reduce how much memory will be used, at some price in compression. Or it may need to request a gzip header and trailer instead of a zlib header and trailer, or raw encoding with no header or trailer at all.

We must check the return value of deflateInit() against the zlib constant Z_OK to make sure that it was able to allocate memory for the internal state, and that the provided arguments were valid. deflateInit() will also check that the version of zlib that the zlib.h file came from matches the version of zlib actually linked with the program. This is especially important for environments in which zlib is a shared library.

Note that an application can initialize multiple, independent zlib streams, which can operate in parallel. The state information maintained in the structure allows the zlib routines to be reentrant.


    /* allocate deflate state */
    strm.zalloc = Z_NULL;
    strm.zfree = Z_NULL;
    strm.opaque = Z_NULL;
    ret = deflateInit(&strm, level);
    if (ret != Z_OK)
        return ret;
With the pleasantries out of the way, now we can get down to business. The outer do-loop reads all of the input file and exits at the bottom of the loop once end-of-file is reached. This loop contains the only call of deflate(). So we must make sure that all of the input data has been processed and that all of the output data has been generated and consumed before we fall out of the loop at the bottom.

    /* compress until end of file */
    do {
We start off by reading data from the input file. The number of bytes read is put directly into avail_in, and a pointer to those bytes is put into next_in. We also check to see if end-of-file on the input has been reached. If we are at the end of file, then flush is set to the zlib constant Z_FINISH, which is later passed to deflate() to indicate that this is the last chunk of input data to compress. We need to use feof() to check for end-of-file as opposed to seeing if fewer than CHUNK bytes have been read. The reason is that if the input file length is an exact multiple of CHUNK, we will miss the fact that we got to the end-of-file, and not know to tell deflate() to finish up the compressed stream. If we are not yet at the end of the input, then the zlib constant Z_NO_FLUSH will be passed to deflate to indicate that we are still in the middle of the uncompressed data.

If there is an error in reading from the input file, the process is aborted with deflateEnd() being called to free the allocated zlib state before returning the error. We wouldn't want a memory leak, now would we? deflateEnd() can be called at any time after the state has been initialized. Once that's done, deflateInit() (or deflateInit2()) would have to be called to start a new compression process. There is no point here in checking the deflateEnd() return code. The deallocation can't fail.


        strm.avail_in = fread(in, 1, CHUNK, source);
        if (ferror(source)) {
            (void)deflateEnd(&strm);
            return Z_ERRNO;
        }
        flush = feof(source) ? Z_FINISH : Z_NO_FLUSH;
        strm.next_in = in;
The inner do-loop passes our chunk of input data to deflate(), and then keeps calling deflate() until it is done producing output. Once there is no more new output, deflate() is guaranteed to have consumed all of the input, i.e., avail_in will be zero.

        /* run deflate() on input until output buffer not full, finish
           compression if all of source has been read in */
        do {
Output space is provided to deflate() by setting avail_out to the number of available output bytes and next_out to a pointer to that space.

            strm.avail_out = CHUNK;
            strm.next_out = out;
Now we call the compression engine itself, deflate(). It takes as many of the avail_in bytes at next_in as it can process, and writes as many as avail_out bytes to next_out. Those counters and pointers are then updated past the input data consumed and the output data written. It is the amount of output space available that may limit how much input is consumed. Hence the inner loop to make sure that all of the input is consumed by providing more output space each time. Since avail_in and next_in are updated by deflate(), we don't have to mess with those between deflate() calls until it's all used up.

The parameters to deflate() are a pointer to the strm structure containing the input and output information and the internal compression engine state, and a parameter indicating whether and how to flush data to the output. Normally deflate will consume several K bytes of input data before producing any output (except for the header), in order to accumulate statistics on the data for optimum compression. It will then put out a burst of compressed data, and proceed to consume more input before the next burst. Eventually, deflate() must be told to terminate the stream, complete the compression with provided input data, and write out the trailer check value. deflate() will continue to compress normally as long as the flush parameter is Z_NO_FLUSH. Once the Z_FINISH parameter is provided, deflate() will begin to complete the compressed output stream. However depending on how much output space is provided, deflate() may have to be called several times until it has provided the complete compressed stream, even after it has consumed all of the input. The flush parameter must continue to be Z_FINISH for those subsequent calls.

There are other values of the flush parameter that are used in more advanced applications. You can force deflate() to produce a burst of output that encodes all of the input data provided so far, even if it wouldn't have otherwise, for example to control data latency on a link with compressed data. You can also ask that deflate() do that as well as erase any history up to that point so that what follows can be decompressed independently, for example for random access applications. Both requests will degrade compression by an amount depending on how often such requests are made.

deflate() has a return value that can indicate errors, yet we do not check it here. Why not? Well, it turns out that deflate() can do no wrong here. Let's go through deflate()'s return values and dispense with them one by one. The possible values are Z_OK, Z_STREAM_END, Z_STREAM_ERROR, or Z_BUF_ERROR. Z_OK is, well, ok. Z_STREAM_END is also ok and will be returned for the last call of deflate(). This is already guaranteed by calling deflate() with Z_FINISH until it has no more output. Z_STREAM_ERROR is only possible if the stream is not initialized properly, but we did initialize it properly. There is no harm in checking for Z_STREAM_ERROR here, for example to check for the possibility that some other part of the application inadvertently clobbered the memory containing the zlib state. Z_BUF_ERROR will be explained further below, but suffice it to say that this is simply an indication that deflate() could not consume more input or produce more output. deflate() can be called again with more output space or more available input, which it will be in this code.


            ret = deflate(&strm, flush);    /* no bad return value */
            assert(ret != Z_STREAM_ERROR);  /* state not clobbered */
Now we compute how much output deflate() provided on the last call, which is the difference between how much space was provided before the call, and how much output space is still available after the call. Then that data, if any, is written to the output file. We can then reuse the output buffer for the next call of deflate(). Again if there is a file i/o error, we call deflateEnd() before returning to avoid a memory leak.

            have = CHUNK - strm.avail_out;
            if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
                (void)deflateEnd(&strm);
                return Z_ERRNO;
            }
The inner do-loop is repeated until the last deflate() call fails to fill the provided output buffer. Then we know that deflate() has done as much as it can with the provided input, and that all of that input has been consumed. We can then fall out of this loop and reuse the input buffer.

The way we tell that deflate() has no more output is by seeing that it did not fill the output buffer, leaving avail_out greater than zero. However suppose that deflate() has no more output, but just so happened to exactly fill the output buffer! avail_out is zero, and we can't tell that deflate() has done all it can. As far as we know, deflate() has more output for us. So we call it again. But now deflate() produces no output at all, and avail_out remains unchanged as CHUNK. That deflate() call wasn't able to do anything, either consume input or produce output, and so it returns Z_BUF_ERROR. (See, I told you I'd cover this later.) However this is not a problem at all. Now we finally have the desired indication that deflate() is really done, and so we drop out of the inner loop to provide more input to deflate().

With flush set to Z_FINISH, this final set of deflate() calls will complete the output stream. Once that is done, subsequent calls of deflate() would return Z_STREAM_ERROR if the flush parameter is not Z_FINISH, and do no more processing until the state is reinitialized.

Some applications of zlib have two loops that call deflate() instead of the single inner loop we have here. The first loop would call without flushing and feed all of the data to deflate(). The second loop would call deflate() with no more data and the Z_FINISH parameter to complete the process. As you can see from this example, that can be avoided by simply keeping track of the current flush state.


        } while (strm.avail_out == 0);
        assert(strm.avail_in == 0);     /* all input will be used */
Now we check to see if we have already processed all of the input file. That information was saved in the flush variable, so we see if that was set to Z_FINISH. If so, then we're done and we fall out of the outer loop. We're guaranteed to get Z_STREAM_END from the last deflate() call, since we ran it until the last chunk of input was consumed and all of the output was generated.

        /* done when last data in file processed */
    } while (flush != Z_FINISH);
    assert(ret == Z_STREAM_END);        /* stream will be complete */
The process is complete, but we still need to deallocate the state to avoid a memory leak (or rather more like a memory hemorrhage if you didn't do this). Then finally we can return with a happy return value.

    /* clean up and return */
    (void)deflateEnd(&strm);
    return Z_OK;
}
Now we do the same thing for decompression in the inf() routine. inf() decompresses what is hopefully a valid zlib stream from the input file and writes the uncompressed data to the output file. Much of the discussion above for def() applies to inf() as well, so the discussion here will focus on the differences between the two.

/* Decompress from file source to file dest until stream ends or EOF.
   inf() returns Z_OK on success, Z_MEM_ERROR if memory could not be
   allocated for processing, Z_DATA_ERROR if the deflate data is
   invalid or incomplete, Z_VERSION_ERROR if the version of zlib.h and
   the version of the library linked do not match, or Z_ERRNO if there
   is an error reading or writing the files. */
int inf(FILE *source, FILE *dest)
{
The local variables have the same functionality as they do for def(). The only difference is that there is no flush variable, since inflate() can tell from the zlib stream itself when the stream is complete.

    int ret;
    unsigned have;
    z_stream strm;
    char in[CHUNK];
    char out[CHUNK];
The initialization of the state is the same, except that there is no compression level, of course, and two more elements of the structure are initialized. avail_in and next_in must be initialized before calling inflateInit(). This is because the application has the option to provide the start of the zlib stream in order for inflateInit() to have access to information about the compression method to aid in memory allocation. In the current implementation of zlib (up through versions 1.2.x), the method-dependent memory allocations are deferred to the first call of inflate() anyway. However those fields must be initialized since later versions of zlib that provide more compression methods may take advantage of this interface. In any case, no decompression is performed by inflateInit(), so the avail_out and next_out fields do not need to be initialized before calling.

Here avail_in is set to zero and next_in is set to Z_NULL to indicate that no input data is being provided.


    /* allocate inflate state */
    strm.zalloc = Z_NULL;
    strm.zfree = Z_NULL;
    strm.opaque = Z_NULL;
    strm.avail_in = 0;
    strm.next_in = Z_NULL;
    ret = inflateInit(&strm);
    if (ret != Z_OK)
        return ret;
The outer do-loop decompresses input until inflate() indicates that it has reached the end of the compressed data and has produced all of the uncompressed output. This is in contrast to def() which processes all of the input file. If end-of-file is reached before the compressed data self-terminates, then the compressed data is incomplete and an error is returned.

    /* decompress until deflate stream ends or end of file */
    do {
We read input data and set the strm structure accordingly. If we've reached the end of the input file, then we leave the outer loop and report an error, since the compressed data is incomplete. Note that we may read more data than is eventually consumed by inflate(), if the input file continues past the zlib stream. For applications where zlib streams are embedded in other data, this routine would need to be modified to return the unused data, or at least indicate how much of the input data was not used, so the application would know where to pick up after the zlib stream.

        strm.avail_in = fread(in, 1, CHUNK, source);
        if (ferror(source)) {
            (void)inflateEnd(&strm);
            return Z_ERRNO;
        }
        if (strm.avail_in == 0)
            break;
        strm.next_in = in;
The inner do-loop has the same function it did in def(), which is to keep calling inflate() until has generated all of the output it can with the provided input.

        /* run inflate() on input until output buffer not full */
        do {
Just like in def(), the same output space is provided for each call of inflate().

            strm.avail_out = CHUNK;
            strm.next_out = out;
Now we run the decompression engine itself. There is no need to adjust the flush parameter, since the zlib format is self-terminating. The main difference here is that there are return values that we need to pay attention to. Z_DATA_ERROR indicates that inflate() detected an error in the zlib compressed data format, which means that either the data is not a zlib stream to begin with, or that the data was corrupted somewhere along the way since it was compressed. The other error to be processed is Z_MEM_ERROR, which can occur since memory allocation is deferred until inflate() needs it, unlike deflate(), whose memory is allocated at the start by deflateInit().

Advanced applications may use deflateSetDictionary() to prime deflate() with a set of likely data to improve the first 32K or so of compression. This is noted in the zlib header, so inflate() requests that that dictionary be provided before it can start to decompress. Without the dictionary, correct decompression is not possible. For this routine, we have no idea what the dictionary is, so the Z_NEED_DICT indication is converted to a Z_DATA_ERROR.

inflate() can also return Z_STREAM_ERROR, which should not be possible here, but could be checked for as noted above for def(). Z_BUF_ERROR does not need to be checked for here, for the same reasons noted for def(). Z_STREAM_END will be checked for later.


            ret = inflate(&strm, Z_NO_FLUSH);
            assert(ret != Z_STREAM_ERROR);  /* state not clobbered */
            switch (ret) {
            case Z_NEED_DICT:
                ret = Z_DATA_ERROR;     /* and fall through */
            case Z_DATA_ERROR:
            case Z_MEM_ERROR:
                (void)inflateEnd(&strm);
                return ret;
            }
The output of inflate() is handled identically to that of deflate().

            have = CHUNK - strm.avail_out;
            if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
                (void)inflateEnd(&strm);
                return Z_ERRNO;
            }
The inner do-loop ends when inflate() has no more output as indicated by not filling the output buffer, just as for deflate(). In this case, we cannot assert that strm.avail_in will be zero, since the deflate stream may end before the file does.

        } while (strm.avail_out == 0);
The outer do-loop ends when inflate() reports that it has reached the end of the input zlib stream, has completed the decompression and integrity check, and has provided all of the output. This is indicated by the inflate() return value Z_STREAM_END. The inner loop is guaranteed to leave ret equal to Z_STREAM_END if the last chunk of the input file read contained the end of the zlib stream. So if the return value is not Z_STREAM_END, the loop continues to read more input.

        /* done when inflate() says it's done */
    } while (ret != Z_STREAM_END);
At this point, decompression successfully completed, or we broke out of the loop due to no more data being available from the input file. If the last inflate() return value is not Z_STREAM_END, then the zlib stream was incomplete and a data error is returned. Otherwise, we return with a happy return value. Of course, inflateEnd() is called first to avoid a memory leak.

    /* clean up and return */
    (void)inflateEnd(&strm);
    return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
}
That ends the routines that directly use zlib. The following routines make this a command-line program by running data through the above routines from stdin to stdout, and handling any errors reported by def() or inf().

zerr() is used to interpret the possible error codes from def() and inf(), as detailed in their comments above, and print out an error message. Note that these are only a subset of the possible return values from deflate() and inflate().


/* report a zlib or i/o error */
void zerr(int ret)
{
    fputs("zpipe: ", stderr);
    switch (ret) {
    case Z_ERRNO:
        if (ferror(stdin))
            fputs("error reading stdin\n", stderr);
        if (ferror(stdout))
            fputs("error writing stdout\n", stderr);
        break;
    case Z_STREAM_ERROR:
        fputs("invalid compression level\n", stderr);
        break;
    case Z_DATA_ERROR:
        fputs("invalid or incomplete deflate data\n", stderr);
        break;
    case Z_MEM_ERROR:
        fputs("out of memory\n", stderr);
        break;
    case Z_VERSION_ERROR:
        fputs("zlib version mismatch!\n", stderr);
    }
}
Here is the main() routine used to test def() and inf(). The zpipe command is simply a compression pipe from stdin to stdout, if no arguments are given, or it is a decompression pipe if zpipe -d is used. If any other arguments are provided, no compression or decompression is performed. Instead a usage message is displayed. Examples are zpipe < foo.txt > foo.txt.z to compress, and zpipe -d < foo.txt.z > foo.txt to decompress.

/* compress or decompress from stdin to stdout */
int main(int argc, char **argv)
{
    int ret;

    /* do compression if no arguments */
    if (argc == 1) {
        ret = def(stdin, stdout, Z_DEFAULT_COMPRESSION);
        if (ret != Z_OK)
            zerr(ret);
        return ret;
    }

    /* do decompression if -d specified */
    else if (argc == 2 && strcmp(argv[1], "-d") == 0) {
        ret = inf(stdin, stdout);
        if (ret != Z_OK)
            zerr(ret);
        return ret;
    }

    /* otherwise, report usage */
    else {
        fputs("zpipe usage: zpipe [-d] < source > dest\n", stderr);
        return 1;
    }
}

Copyright (c) 2004 by Mark Adler
Last modified 13 November 2004
sks-ecc-0.93/zlib/examples/gzlog.h0000644000175000017500000000552310604550750016017 0ustar nachonacho/* gzlog.h Copyright (C) 2004 Mark Adler, all rights reserved version 1.0, 26 Nov 2004 This software is provided 'as-is', without any express or implied warranty. In no event will the author 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. Mark Adler madler@alumni.caltech.edu */ /* The gzlog object allows writing short messages to a gzipped log file, opening the log file locked for small bursts, and then closing it. The log object works by appending stored data to the gzip file until 1 MB has been accumulated. At that time, the stored data is compressed, and replaces the uncompressed data in the file. The log file is truncated to its new size at that time. After closing, the log file is always valid gzip file that can decompressed to recover what was written. A gzip header "extra" field contains two file offsets for appending. The first points to just after the last compressed data. The second points to the last stored block in the deflate stream, which is empty. All of the data between those pointers is uncompressed. */ /* Open a gzlog object, creating the log file if it does not exist. Return NULL on error. Note that gzlog_open() could take a long time to return if there is difficulty in locking the file. */ void *gzlog_open(char *path); /* Write to a gzlog object. Return non-zero on error. This function will simply write data to the file uncompressed. Compression of the data will not occur until gzlog_close() is called. It is expected that gzlog_write() is used for a short message, and then gzlog_close() is called. If a large amount of data is to be written, then the application should write no more than 1 MB at a time with gzlog_write() before calling gzlog_close() and then gzlog_open() again. */ int gzlog_write(void *log, char *data, size_t len); /* Close a gzlog object. Return non-zero on error. The log file is locked until this function is called. This function will compress stored data at the end of the gzip file if at least 1 MB has been accumulated. Note that the file will not be a valid gzip file until this function completes. */ int gzlog_close(void *log); sks-ecc-0.93/zlib/examples/gun.c0000644000175000017500000006163310604550750015465 0ustar nachonacho/* gun.c -- simple gunzip to give an example of the use of inflateBack() * Copyright (C) 2003, 2005 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h Version 1.3 12 June 2005 Mark Adler */ /* Version history: 1.0 16 Feb 2003 First version for testing of inflateBack() 1.1 21 Feb 2005 Decompress concatenated gzip streams Remove use of "this" variable (C++ keyword) Fix return value for in() Improve allocation failure checking Add typecasting for void * structures Add -h option for command version and usage Add a bunch of comments 1.2 20 Mar 2005 Add Unix compress (LZW) decompression Copy file attributes from input file to output file 1.3 12 Jun 2005 Add casts for error messages [Oberhumer] */ /* gun [ -t ] [ name ... ] decompresses the data in the named gzip files. If no arguments are given, gun will decompress from stdin to stdout. The names must end in .gz, -gz, .z, -z, _z, or .Z. The uncompressed data will be written to a file name with the suffix stripped. On success, the original file is deleted. On failure, the output file is deleted. For most failures, the command will continue to process the remaining names on the command line. A memory allocation failure will abort the command. If -t is specified, then the listed files or stdin will be tested as gzip files for integrity (without checking for a proper suffix), no output will be written, and no files will be deleted. Like gzip, gun allows concatenated gzip streams and will decompress them, writing all of the uncompressed data to the output. Unlike gzip, gun allows an empty file on input, and will produce no error writing an empty output file. gun will also decompress files made by Unix compress, which uses LZW compression. These files are automatically detected by virtue of their magic header bytes. Since the end of Unix compress stream is marked by the end-of-file, they cannot be concantenated. If a Unix compress stream is encountered in an input file, it is the last stream in that file. Like gunzip and uncompress, the file attributes of the orignal compressed file are maintained in the final uncompressed file, to the extent that the user permissions allow it. On my Mac OS X PowerPC G4, gun is almost twice as fast as gunzip (version 1.2.4) is on the same file, when gun is linked with zlib 1.2.2. Also the LZW decompression provided by gun is about twice as fast as the standard Unix uncompress command. */ /* external functions and related types and constants */ #include /* fprintf() */ #include /* malloc(), free() */ #include /* strerror(), strcmp(), strlen(), memcpy() */ #include /* errno */ #include /* open() */ #include /* read(), write(), close(), chown(), unlink() */ #include #include /* stat(), chmod() */ #include /* utime() */ #include "zlib.h" /* inflateBackInit(), inflateBack(), */ /* inflateBackEnd(), crc32() */ /* function declaration */ #define local static /* buffer constants */ #define SIZE 32768U /* input and output buffer sizes */ #define PIECE 16384 /* limits i/o chunks for 16-bit int case */ /* structure for infback() to pass to input function in() -- it maintains the input file and a buffer of size SIZE */ struct ind { int infile; unsigned char *inbuf; }; /* Load input buffer, assumed to be empty, and return bytes loaded and a pointer to them. read() is called until the buffer is full, or until it returns end-of-file or error. Return 0 on error. */ local unsigned in(void *in_desc, unsigned char **buf) { int ret; unsigned len; unsigned char *next; struct ind *me = (struct ind *)in_desc; next = me->inbuf; *buf = next; len = 0; do { ret = PIECE; if ((unsigned)ret > SIZE - len) ret = (int)(SIZE - len); ret = (int)read(me->infile, next, ret); if (ret == -1) { len = 0; break; } next += ret; len += ret; } while (ret != 0 && len < SIZE); return len; } /* structure for infback() to pass to output function out() -- it maintains the output file, a running CRC-32 check on the output and the total number of bytes output, both for checking against the gzip trailer. (The length in the gzip trailer is stored modulo 2^32, so it's ok if a long is 32 bits and the output is greater than 4 GB.) */ struct outd { int outfile; int check; /* true if checking crc and total */ unsigned long crc; unsigned long total; }; /* Write output buffer and update the CRC-32 and total bytes written. write() is called until all of the output is written or an error is encountered. On success out() returns 0. For a write failure, out() returns 1. If the output file descriptor is -1, then nothing is written. */ local int out(void *out_desc, unsigned char *buf, unsigned len) { int ret; struct outd *me = (struct outd *)out_desc; if (me->check) { me->crc = crc32(me->crc, buf, len); me->total += len; } if (me->outfile != -1) do { ret = PIECE; if ((unsigned)ret > len) ret = (int)len; ret = (int)write(me->outfile, buf, ret); if (ret == -1) return 1; buf += ret; len -= ret; } while (len != 0); return 0; } /* next input byte macro for use inside lunpipe() and gunpipe() */ #define NEXT() (have ? 0 : (have = in(indp, &next)), \ last = have ? (have--, (int)(*next++)) : -1) /* memory for gunpipe() and lunpipe() -- the first 256 entries of prefix[] and suffix[] are never used, could have offset the index, but it's faster to waste the memory */ unsigned char inbuf[SIZE]; /* input buffer */ unsigned char outbuf[SIZE]; /* output buffer */ unsigned short prefix[65536]; /* index to LZW prefix string */ unsigned char suffix[65536]; /* one-character LZW suffix */ unsigned char match[65280 + 2]; /* buffer for reversed match or gzip 32K sliding window */ /* throw out what's left in the current bits byte buffer (this is a vestigial aspect of the compressed data format derived from an implementation that made use of a special VAX machine instruction!) */ #define FLUSHCODE() \ do { \ left = 0; \ rem = 0; \ if (chunk > have) { \ chunk -= have; \ have = 0; \ if (NEXT() == -1) \ break; \ chunk--; \ if (chunk > have) { \ chunk = have = 0; \ break; \ } \ } \ have -= chunk; \ next += chunk; \ chunk = 0; \ } while (0) /* Decompress a compress (LZW) file from indp to outfile. The compress magic header (two bytes) has already been read and verified. There are have bytes of buffered input at next. strm is used for passing error information back to gunpipe(). lunpipe() will return Z_OK on success, Z_BUF_ERROR for an unexpected end of file, read error, or write error (a write error indicated by strm->next_in not equal to Z_NULL), or Z_DATA_ERROR for invalid input. */ local int lunpipe(unsigned have, unsigned char *next, struct ind *indp, int outfile, z_stream *strm) { int last; /* last byte read by NEXT(), or -1 if EOF */ int chunk; /* bytes left in current chunk */ int left; /* bits left in rem */ unsigned rem; /* unused bits from input */ int bits; /* current bits per code */ unsigned code; /* code, table traversal index */ unsigned mask; /* mask for current bits codes */ int max; /* maximum bits per code for this stream */ int flags; /* compress flags, then block compress flag */ unsigned end; /* last valid entry in prefix/suffix tables */ unsigned temp; /* current code */ unsigned prev; /* previous code */ unsigned final; /* last character written for previous code */ unsigned stack; /* next position for reversed string */ unsigned outcnt; /* bytes in output buffer */ struct outd outd; /* output structure */ /* set up output */ outd.outfile = outfile; outd.check = 0; /* process remainder of compress header -- a flags byte */ flags = NEXT(); if (last == -1) return Z_BUF_ERROR; if (flags & 0x60) { strm->msg = (char *)"unknown lzw flags set"; return Z_DATA_ERROR; } max = flags & 0x1f; if (max < 9 || max > 16) { strm->msg = (char *)"lzw bits out of range"; return Z_DATA_ERROR; } if (max == 9) /* 9 doesn't really mean 9 */ max = 10; flags &= 0x80; /* true if block compress */ /* clear table */ bits = 9; mask = 0x1ff; end = flags ? 256 : 255; /* set up: get first 9-bit code, which is the first decompressed byte, but don't create a table entry until the next code */ if (NEXT() == -1) /* no compressed data is ok */ return Z_OK; final = prev = (unsigned)last; /* low 8 bits of code */ if (NEXT() == -1) /* missing a bit */ return Z_BUF_ERROR; if (last & 1) { /* code must be < 256 */ strm->msg = (char *)"invalid lzw code"; return Z_DATA_ERROR; } rem = (unsigned)last >> 1; /* remaining 7 bits */ left = 7; chunk = bits - 2; /* 7 bytes left in this chunk */ outbuf[0] = (unsigned char)final; /* write first decompressed byte */ outcnt = 1; /* decode codes */ stack = 0; for (;;) { /* if the table will be full after this, increment the code size */ if (end >= mask && bits < max) { FLUSHCODE(); bits++; mask <<= 1; mask++; } /* get a code of length bits */ if (chunk == 0) /* decrement chunk modulo bits */ chunk = bits; code = rem; /* low bits of code */ if (NEXT() == -1) { /* EOF is end of compressed data */ /* write remaining buffered output */ if (outcnt && out(&outd, outbuf, outcnt)) { strm->next_in = outbuf; /* signal write error */ return Z_BUF_ERROR; } return Z_OK; } code += (unsigned)last << left; /* middle (or high) bits of code */ left += 8; chunk--; if (bits > left) { /* need more bits */ if (NEXT() == -1) /* can't end in middle of code */ return Z_BUF_ERROR; code += (unsigned)last << left; /* high bits of code */ left += 8; chunk--; } code &= mask; /* mask to current code length */ left -= bits; /* number of unused bits */ rem = (unsigned)last >> (8 - left); /* unused bits from last byte */ /* process clear code (256) */ if (code == 256 && flags) { FLUSHCODE(); bits = 9; /* initialize bits and mask */ mask = 0x1ff; end = 255; /* empty table */ continue; /* get next code */ } /* special code to reuse last match */ temp = code; /* save the current code */ if (code > end) { /* Be picky on the allowed code here, and make sure that the code we drop through (prev) will be a valid index so that random input does not cause an exception. The code != end + 1 check is empirically derived, and not checked in the original uncompress code. If this ever causes a problem, that check could be safely removed. Leaving this check in greatly improves gun's ability to detect random or corrupted input after a compress header. In any case, the prev > end check must be retained. */ if (code != end + 1 || prev > end) { strm->msg = (char *)"invalid lzw code"; return Z_DATA_ERROR; } match[stack++] = (unsigned char)final; code = prev; } /* walk through linked list to generate output in reverse order */ while (code >= 256) { match[stack++] = suffix[code]; code = prefix[code]; } match[stack++] = (unsigned char)code; final = code; /* link new table entry */ if (end < mask) { end++; prefix[end] = (unsigned short)prev; suffix[end] = (unsigned char)final; } /* set previous code for next iteration */ prev = temp; /* write output in forward order */ while (stack > SIZE - outcnt) { while (outcnt < SIZE) outbuf[outcnt++] = match[--stack]; if (out(&outd, outbuf, outcnt)) { strm->next_in = outbuf; /* signal write error */ return Z_BUF_ERROR; } outcnt = 0; } do { outbuf[outcnt++] = match[--stack]; } while (stack); /* loop for next code with final and prev as the last match, rem and left provide the first 0..7 bits of the next code, end is the last valid table entry */ } } /* Decompress a gzip file from infile to outfile. strm is assumed to have been successfully initialized with inflateBackInit(). The input file may consist of a series of gzip streams, in which case all of them will be decompressed to the output file. If outfile is -1, then the gzip stream(s) integrity is checked and nothing is written. The return value is a zlib error code: Z_MEM_ERROR if out of memory, Z_DATA_ERROR if the header or the compressed data is invalid, or if the trailer CRC-32 check or length doesn't match, Z_BUF_ERROR if the input ends prematurely or a write error occurs, or Z_ERRNO if junk (not a another gzip stream) follows a valid gzip stream. */ local int gunpipe(z_stream *strm, int infile, int outfile) { int ret, first, last; unsigned have, flags, len; unsigned char *next; struct ind ind, *indp; struct outd outd; /* setup input buffer */ ind.infile = infile; ind.inbuf = inbuf; indp = &ind; /* decompress concatenated gzip streams */ have = 0; /* no input data read in yet */ first = 1; /* looking for first gzip header */ strm->next_in = Z_NULL; /* so Z_BUF_ERROR means EOF */ for (;;) { /* look for the two magic header bytes for a gzip stream */ if (NEXT() == -1) { ret = Z_OK; break; /* empty gzip stream is ok */ } if (last != 31 || (NEXT() != 139 && last != 157)) { strm->msg = (char *)"incorrect header check"; ret = first ? Z_DATA_ERROR : Z_ERRNO; break; /* not a gzip or compress header */ } first = 0; /* next non-header is junk */ /* process a compress (LZW) file -- can't be concatenated after this */ if (last == 157) { ret = lunpipe(have, next, indp, outfile, strm); break; } /* process remainder of gzip header */ ret = Z_BUF_ERROR; if (NEXT() != 8) { /* only deflate method allowed */ if (last == -1) break; strm->msg = (char *)"unknown compression method"; ret = Z_DATA_ERROR; break; } flags = NEXT(); /* header flags */ NEXT(); /* discard mod time, xflgs, os */ NEXT(); NEXT(); NEXT(); NEXT(); NEXT(); if (last == -1) break; if (flags & 0xe0) { strm->msg = (char *)"unknown header flags set"; ret = Z_DATA_ERROR; break; } if (flags & 4) { /* extra field */ len = NEXT(); len += (unsigned)(NEXT()) << 8; if (last == -1) break; while (len > have) { len -= have; have = 0; if (NEXT() == -1) break; len--; } if (last == -1) break; have -= len; next += len; } if (flags & 8) /* file name */ while (NEXT() != 0 && last != -1) ; if (flags & 16) /* comment */ while (NEXT() != 0 && last != -1) ; if (flags & 2) { /* header crc */ NEXT(); NEXT(); } if (last == -1) break; /* set up output */ outd.outfile = outfile; outd.check = 1; outd.crc = crc32(0L, Z_NULL, 0); outd.total = 0; /* decompress data to output */ strm->next_in = next; strm->avail_in = have; ret = inflateBack(strm, in, indp, out, &outd); if (ret != Z_STREAM_END) break; next = strm->next_in; have = strm->avail_in; strm->next_in = Z_NULL; /* so Z_BUF_ERROR means EOF */ /* check trailer */ ret = Z_BUF_ERROR; if (NEXT() != (outd.crc & 0xff) || NEXT() != ((outd.crc >> 8) & 0xff) || NEXT() != ((outd.crc >> 16) & 0xff) || NEXT() != ((outd.crc >> 24) & 0xff)) { /* crc error */ if (last != -1) { strm->msg = (char *)"incorrect data check"; ret = Z_DATA_ERROR; } break; } if (NEXT() != (outd.total & 0xff) || NEXT() != ((outd.total >> 8) & 0xff) || NEXT() != ((outd.total >> 16) & 0xff) || NEXT() != ((outd.total >> 24) & 0xff)) { /* length error */ if (last != -1) { strm->msg = (char *)"incorrect length check"; ret = Z_DATA_ERROR; } break; } /* go back and look for another gzip stream */ } /* clean up and return */ return ret; } /* Copy file attributes, from -> to, as best we can. This is best effort, so no errors are reported. The mode bits, including suid, sgid, and the sticky bit are copied (if allowed), the owner's user id and group id are copied (again if allowed), and the access and modify times are copied. */ local void copymeta(char *from, char *to) { struct stat was; struct utimbuf when; /* get all of from's Unix meta data, return if not a regular file */ if (stat(from, &was) != 0 || (was.st_mode & S_IFMT) != S_IFREG) return; /* set to's mode bits, ignore errors */ (void)chmod(to, was.st_mode & 07777); /* copy owner's user and group, ignore errors */ (void)chown(to, was.st_uid, was.st_gid); /* copy access and modify times, ignore errors */ when.actime = was.st_atime; when.modtime = was.st_mtime; (void)utime(to, &when); } /* Decompress the file inname to the file outnname, of if test is true, just decompress without writing and check the gzip trailer for integrity. If inname is NULL or an empty string, read from stdin. If outname is NULL or an empty string, write to stdout. strm is a pre-initialized inflateBack structure. When appropriate, copy the file attributes from inname to outname. gunzip() returns 1 if there is an out-of-memory error or an unexpected return code from gunpipe(). Otherwise it returns 0. */ local int gunzip(z_stream *strm, char *inname, char *outname, int test) { int ret; int infile, outfile; /* open files */ if (inname == NULL || *inname == 0) { inname = "-"; infile = 0; /* stdin */ } else { infile = open(inname, O_RDONLY, 0); if (infile == -1) { fprintf(stderr, "gun cannot open %s\n", inname); return 0; } } if (test) outfile = -1; else if (outname == NULL || *outname == 0) { outname = "-"; outfile = 1; /* stdout */ } else { outfile = open(outname, O_CREAT | O_TRUNC | O_WRONLY, 0666); if (outfile == -1) { close(infile); fprintf(stderr, "gun cannot create %s\n", outname); return 0; } } errno = 0; /* decompress */ ret = gunpipe(strm, infile, outfile); if (outfile > 2) close(outfile); if (infile > 2) close(infile); /* interpret result */ switch (ret) { case Z_OK: case Z_ERRNO: if (infile > 2 && outfile > 2) { copymeta(inname, outname); /* copy attributes */ unlink(inname); } if (ret == Z_ERRNO) fprintf(stderr, "gun warning: trailing garbage ignored in %s\n", inname); break; case Z_DATA_ERROR: if (outfile > 2) unlink(outname); fprintf(stderr, "gun data error on %s: %s\n", inname, strm->msg); break; case Z_MEM_ERROR: if (outfile > 2) unlink(outname); fprintf(stderr, "gun out of memory error--aborting\n"); return 1; case Z_BUF_ERROR: if (outfile > 2) unlink(outname); if (strm->next_in != Z_NULL) { fprintf(stderr, "gun write error on %s: %s\n", outname, strerror(errno)); } else if (errno) { fprintf(stderr, "gun read error on %s: %s\n", inname, strerror(errno)); } else { fprintf(stderr, "gun unexpected end of file on %s\n", inname); } break; default: if (outfile > 2) unlink(outname); fprintf(stderr, "gun internal error--aborting\n"); return 1; } return 0; } /* Process the gun command line arguments. See the command syntax near the beginning of this source file. */ int main(int argc, char **argv) { int ret, len, test; char *outname; unsigned char *window; z_stream strm; /* initialize inflateBack state for repeated use */ window = match; /* reuse LZW match buffer */ strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; ret = inflateBackInit(&strm, 15, window); if (ret != Z_OK) { fprintf(stderr, "gun out of memory error--aborting\n"); return 1; } /* decompress each file to the same name with the suffix removed */ argc--; argv++; test = 0; if (argc && strcmp(*argv, "-h") == 0) { fprintf(stderr, "gun 1.3 (12 Jun 2005)\n"); fprintf(stderr, "Copyright (c) 2005 Mark Adler\n"); fprintf(stderr, "usage: gun [-t] [file1.gz [file2.Z ...]]\n"); return 0; } if (argc && strcmp(*argv, "-t") == 0) { test = 1; argc--; argv++; } if (argc) do { if (test) outname = NULL; else { len = (int)strlen(*argv); if (strcmp(*argv + len - 3, ".gz") == 0 || strcmp(*argv + len - 3, "-gz") == 0) len -= 3; else if (strcmp(*argv + len - 2, ".z") == 0 || strcmp(*argv + len - 2, "-z") == 0 || strcmp(*argv + len - 2, "_z") == 0 || strcmp(*argv + len - 2, ".Z") == 0) len -= 2; else { fprintf(stderr, "gun error: no gz type on %s--skipping\n", *argv); continue; } outname = malloc(len + 1); if (outname == NULL) { fprintf(stderr, "gun out of memory error--aborting\n"); ret = 1; break; } memcpy(outname, *argv, len); outname[len] = 0; } ret = gunzip(&strm, *argv, outname, test); if (outname != NULL) free(outname); if (ret) break; } while (argv++, --argc); else ret = gunzip(&strm, NULL, NULL, test); /* clean up */ inflateBackEnd(&strm); return ret; } sks-ecc-0.93/zlib/examples/gzjoin.c0000644000175000017500000003327610604550750016176 0ustar nachonacho/* gzjoin -- command to join gzip files into one gzip file Copyright (C) 2004 Mark Adler, all rights reserved version 1.0, 11 Dec 2004 This software is provided 'as-is', without any express or implied warranty. In no event will the author 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. Mark Adler madler@alumni.caltech.edu */ /* * Change history: * * 1.0 11 Dec 2004 - First version * 1.1 12 Jun 2005 - Changed ssize_t to long for portability */ /* gzjoin takes one or more gzip files on the command line and writes out a single gzip file that will uncompress to the concatenation of the uncompressed data from the individual gzip files. gzjoin does this without having to recompress any of the data and without having to calculate a new crc32 for the concatenated uncompressed data. gzjoin does however have to decompress all of the input data in order to find the bits in the compressed data that need to be modified to concatenate the streams. gzjoin does not do an integrity check on the input gzip files other than checking the gzip header and decompressing the compressed data. They are otherwise assumed to be complete and correct. Each joint between gzip files removes at least 18 bytes of previous trailer and subsequent header, and inserts an average of about three bytes to the compressed data in order to connect the streams. The output gzip file has a minimal ten-byte gzip header with no file name or modification time. This program was written to illustrate the use of the Z_BLOCK option of inflate() and the crc32_combine() function. gzjoin will not compile with versions of zlib earlier than 1.2.3. */ #include /* fputs(), fprintf(), fwrite(), putc() */ #include /* exit(), malloc(), free() */ #include /* open() */ #include /* close(), read(), lseek() */ #include "zlib.h" /* crc32(), crc32_combine(), inflateInit2(), inflate(), inflateEnd() */ #define local static /* exit with an error (return a value to allow use in an expression) */ local int bail(char *why1, char *why2) { fprintf(stderr, "gzjoin error: %s%s, output incomplete\n", why1, why2); exit(1); return 0; } /* -- simple buffered file input with access to the buffer -- */ #define CHUNK 32768 /* must be a power of two and fit in unsigned */ /* bin buffered input file type */ typedef struct { char *name; /* name of file for error messages */ int fd; /* file descriptor */ unsigned left; /* bytes remaining at next */ unsigned char *next; /* next byte to read */ unsigned char *buf; /* allocated buffer of length CHUNK */ } bin; /* close a buffered file and free allocated memory */ local void bclose(bin *in) { if (in != NULL) { if (in->fd != -1) close(in->fd); if (in->buf != NULL) free(in->buf); free(in); } } /* open a buffered file for input, return a pointer to type bin, or NULL on failure */ local bin *bopen(char *name) { bin *in; in = malloc(sizeof(bin)); if (in == NULL) return NULL; in->buf = malloc(CHUNK); in->fd = open(name, O_RDONLY, 0); if (in->buf == NULL || in->fd == -1) { bclose(in); return NULL; } in->left = 0; in->next = in->buf; in->name = name; return in; } /* load buffer from file, return -1 on read error, 0 or 1 on success, with 1 indicating that end-of-file was reached */ local int bload(bin *in) { long len; if (in == NULL) return -1; if (in->left != 0) return 0; in->next = in->buf; do { len = (long)read(in->fd, in->buf + in->left, CHUNK - in->left); if (len < 0) return -1; in->left += (unsigned)len; } while (len != 0 && in->left < CHUNK); return len == 0 ? 1 : 0; } /* get a byte from the file, bail if end of file */ #define bget(in) (in->left ? 0 : bload(in), \ in->left ? (in->left--, *(in->next)++) : \ bail("unexpected end of file on ", in->name)) /* get a four-byte little-endian unsigned integer from file */ local unsigned long bget4(bin *in) { unsigned long val; val = bget(in); val += (unsigned long)(bget(in)) << 8; val += (unsigned long)(bget(in)) << 16; val += (unsigned long)(bget(in)) << 24; return val; } /* skip bytes in file */ local void bskip(bin *in, unsigned skip) { /* check pointer */ if (in == NULL) return; /* easy case -- skip bytes in buffer */ if (skip <= in->left) { in->left -= skip; in->next += skip; return; } /* skip what's in buffer, discard buffer contents */ skip -= in->left; in->left = 0; /* seek past multiples of CHUNK bytes */ if (skip > CHUNK) { unsigned left; left = skip & (CHUNK - 1); if (left == 0) { /* exact number of chunks: seek all the way minus one byte to check for end-of-file with a read */ lseek(in->fd, skip - 1, SEEK_CUR); if (read(in->fd, in->buf, 1) != 1) bail("unexpected end of file on ", in->name); return; } /* skip the integral chunks, update skip with remainder */ lseek(in->fd, skip - left, SEEK_CUR); skip = left; } /* read more input and skip remainder */ bload(in); if (skip > in->left) bail("unexpected end of file on ", in->name); in->left -= skip; in->next += skip; } /* -- end of buffered input functions -- */ /* skip the gzip header from file in */ local void gzhead(bin *in) { int flags; /* verify gzip magic header and compression method */ if (bget(in) != 0x1f || bget(in) != 0x8b || bget(in) != 8) bail(in->name, " is not a valid gzip file"); /* get and verify flags */ flags = bget(in); if ((flags & 0xe0) != 0) bail("unknown reserved bits set in ", in->name); /* skip modification time, extra flags, and os */ bskip(in, 6); /* skip extra field if present */ if (flags & 4) { unsigned len; len = bget(in); len += (unsigned)(bget(in)) << 8; bskip(in, len); } /* skip file name if present */ if (flags & 8) while (bget(in) != 0) ; /* skip comment if present */ if (flags & 16) while (bget(in) != 0) ; /* skip header crc if present */ if (flags & 2) bskip(in, 2); } /* write a four-byte little-endian unsigned integer to out */ local void put4(unsigned long val, FILE *out) { putc(val & 0xff, out); putc((val >> 8) & 0xff, out); putc((val >> 16) & 0xff, out); putc((val >> 24) & 0xff, out); } /* Load up zlib stream from buffered input, bail if end of file */ local void zpull(z_streamp strm, bin *in) { if (in->left == 0) bload(in); if (in->left == 0) bail("unexpected end of file on ", in->name); strm->avail_in = in->left; strm->next_in = in->next; } /* Write header for gzip file to out and initialize trailer. */ local void gzinit(unsigned long *crc, unsigned long *tot, FILE *out) { fwrite("\x1f\x8b\x08\0\0\0\0\0\0\xff", 1, 10, out); *crc = crc32(0L, Z_NULL, 0); *tot = 0; } /* Copy the compressed data from name, zeroing the last block bit of the last block if clr is true, and adding empty blocks as needed to get to a byte boundary. If clr is false, then the last block becomes the last block of the output, and the gzip trailer is written. crc and tot maintains the crc and length (modulo 2^32) of the output for the trailer. The resulting gzip file is written to out. gzinit() must be called before the first call of gzcopy() to write the gzip header and to initialize crc and tot. */ local void gzcopy(char *name, int clr, unsigned long *crc, unsigned long *tot, FILE *out) { int ret; /* return value from zlib functions */ int pos; /* where the "last block" bit is in byte */ int last; /* true if processing the last block */ bin *in; /* buffered input file */ unsigned char *start; /* start of compressed data in buffer */ unsigned char *junk; /* buffer for uncompressed data -- discarded */ z_off_t len; /* length of uncompressed data (support > 4 GB) */ z_stream strm; /* zlib inflate stream */ /* open gzip file and skip header */ in = bopen(name); if (in == NULL) bail("could not open ", name); gzhead(in); /* allocate buffer for uncompressed data and initialize raw inflate stream */ junk = malloc(CHUNK); strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; strm.avail_in = 0; strm.next_in = Z_NULL; ret = inflateInit2(&strm, -15); if (junk == NULL || ret != Z_OK) bail("out of memory", ""); /* inflate and copy compressed data, clear last-block bit if requested */ len = 0; zpull(&strm, in); start = strm.next_in; last = start[0] & 1; if (last && clr) start[0] &= ~1; strm.avail_out = 0; for (;;) { /* if input used and output done, write used input and get more */ if (strm.avail_in == 0 && strm.avail_out != 0) { fwrite(start, 1, strm.next_in - start, out); start = in->buf; in->left = 0; zpull(&strm, in); } /* decompress -- return early when end-of-block reached */ strm.avail_out = CHUNK; strm.next_out = junk; ret = inflate(&strm, Z_BLOCK); switch (ret) { case Z_MEM_ERROR: bail("out of memory", ""); case Z_DATA_ERROR: bail("invalid compressed data in ", in->name); } /* update length of uncompressed data */ len += CHUNK - strm.avail_out; /* check for block boundary (only get this when block copied out) */ if (strm.data_type & 128) { /* if that was the last block, then done */ if (last) break; /* number of unused bits in last byte */ pos = strm.data_type & 7; /* find the next last-block bit */ if (pos != 0) { /* next last-block bit is in last used byte */ pos = 0x100 >> pos; last = strm.next_in[-1] & pos; if (last && clr) strm.next_in[-1] &= ~pos; } else { /* next last-block bit is in next unused byte */ if (strm.avail_in == 0) { /* don't have that byte yet -- get it */ fwrite(start, 1, strm.next_in - start, out); start = in->buf; in->left = 0; zpull(&strm, in); } last = strm.next_in[0] & 1; if (last && clr) strm.next_in[0] &= ~1; } } } /* update buffer with unused input */ in->left = strm.avail_in; in->next = strm.next_in; /* copy used input, write empty blocks to get to byte boundary */ pos = strm.data_type & 7; fwrite(start, 1, in->next - start - 1, out); last = in->next[-1]; if (pos == 0 || !clr) /* already at byte boundary, or last file: write last byte */ putc(last, out); else { /* append empty blocks to last byte */ last &= ((0x100 >> pos) - 1); /* assure unused bits are zero */ if (pos & 1) { /* odd -- append an empty stored block */ putc(last, out); if (pos == 1) putc(0, out); /* two more bits in block header */ fwrite("\0\0\xff\xff", 1, 4, out); } else { /* even -- append 1, 2, or 3 empty fixed blocks */ switch (pos) { case 6: putc(last | 8, out); last = 0; case 4: putc(last | 0x20, out); last = 0; case 2: putc(last | 0x80, out); putc(0, out); } } } /* update crc and tot */ *crc = crc32_combine(*crc, bget4(in), len); *tot += (unsigned long)len; /* clean up */ inflateEnd(&strm); free(junk); bclose(in); /* write trailer if this is the last gzip file */ if (!clr) { put4(*crc, out); put4(*tot, out); } } /* join the gzip files on the command line, write result to stdout */ int main(int argc, char **argv) { unsigned long crc, tot; /* running crc and total uncompressed length */ /* skip command name */ argc--; argv++; /* show usage if no arguments */ if (argc == 0) { fputs("gzjoin usage: gzjoin f1.gz [f2.gz [f3.gz ...]] > fjoin.gz\n", stderr); return 0; } /* join gzip files on command line and write to stdout */ gzinit(&crc, &tot, stdout); while (argc--) gzcopy(*argv++, argc, &crc, &tot, stdout); /* done */ return 0; } sks-ecc-0.93/zlib/examples/fitblk.c0000644000175000017500000002062210604550750016140 0ustar nachonacho/* fitblk.c: example of fitting compressed output to a specified size Not copyrighted -- provided to the public domain Version 1.1 25 November 2004 Mark Adler */ /* Version history: 1.0 24 Nov 2004 First version 1.1 25 Nov 2004 Change deflateInit2() to deflateInit() Use fixed-size, stack-allocated raw buffers Simplify code moving compression to subroutines Use assert() for internal errors Add detailed description of approach */ /* Approach to just fitting a requested compressed size: fitblk performs three compression passes on a portion of the input data in order to determine how much of that input will compress to nearly the requested output block size. The first pass generates enough deflate blocks to produce output to fill the requested output size plus a specfied excess amount (see the EXCESS define below). The last deflate block may go quite a bit past that, but is discarded. The second pass decompresses and recompresses just the compressed data that fit in the requested plus excess sized buffer. The deflate process is terminated after that amount of input, which is less than the amount consumed on the first pass. The last deflate block of the result will be of a comparable size to the final product, so that the header for that deflate block and the compression ratio for that block will be about the same as in the final product. The third compression pass decompresses the result of the second step, but only the compressed data up to the requested size minus an amount to allow the compressed stream to complete (see the MARGIN define below). That will result in a final compressed stream whose length is less than or equal to the requested size. Assuming sufficient input and a requested size greater than a few hundred bytes, the shortfall will typically be less than ten bytes. If the input is short enough that the first compression completes before filling the requested output size, then that compressed stream is return with no recompression. EXCESS is chosen to be just greater than the shortfall seen in a two pass approach similar to the above. That shortfall is due to the last deflate block compressing more efficiently with a smaller header on the second pass. EXCESS is set to be large enough so that there is enough uncompressed data for the second pass to fill out the requested size, and small enough so that the final deflate block of the second pass will be close in size to the final deflate block of the third and final pass. MARGIN is chosen to be just large enough to assure that the final compression has enough room to complete in all cases. */ #include #include #include #include "zlib.h" #define local static /* print nastygram and leave */ local void quit(char *why) { fprintf(stderr, "fitblk abort: %s\n", why); exit(1); } #define RAWLEN 4096 /* intermediate uncompressed buffer size */ /* compress from file to def until provided buffer is full or end of input reached; return last deflate() return value, or Z_ERRNO if there was read error on the file */ local int partcompress(FILE *in, z_streamp def) { int ret, flush; unsigned char raw[RAWLEN]; flush = Z_NO_FLUSH; do { def->avail_in = fread(raw, 1, RAWLEN, in); if (ferror(in)) return Z_ERRNO; def->next_in = raw; if (feof(in)) flush = Z_FINISH; ret = deflate(def, flush); assert(ret != Z_STREAM_ERROR); } while (def->avail_out != 0 && flush == Z_NO_FLUSH); return ret; } /* recompress from inf's input to def's output; the input for inf and the output for def are set in those structures before calling; return last deflate() return value, or Z_MEM_ERROR if inflate() was not able to allocate enough memory when it needed to */ local int recompress(z_streamp inf, z_streamp def) { int ret, flush; unsigned char raw[RAWLEN]; flush = Z_NO_FLUSH; do { /* decompress */ inf->avail_out = RAWLEN; inf->next_out = raw; ret = inflate(inf, Z_NO_FLUSH); assert(ret != Z_STREAM_ERROR && ret != Z_DATA_ERROR && ret != Z_NEED_DICT); if (ret == Z_MEM_ERROR) return ret; /* compress what was decompresed until done or no room */ def->avail_in = RAWLEN - inf->avail_out; def->next_in = raw; if (inf->avail_out != 0) flush = Z_FINISH; ret = deflate(def, flush); assert(ret != Z_STREAM_ERROR); } while (ret != Z_STREAM_END && def->avail_out != 0); return ret; } #define EXCESS 256 /* empirically determined stream overage */ #define MARGIN 8 /* amount to back off for completion */ /* compress from stdin to fixed-size block on stdout */ int main(int argc, char **argv) { int ret; /* return code */ unsigned size; /* requested fixed output block size */ unsigned have; /* bytes written by deflate() call */ unsigned char *blk; /* intermediate and final stream */ unsigned char *tmp; /* close to desired size stream */ z_stream def, inf; /* zlib deflate and inflate states */ /* get requested output size */ if (argc != 2) quit("need one argument: size of output block"); ret = strtol(argv[1], argv + 1, 10); if (argv[1][0] != 0) quit("argument must be a number"); if (ret < 8) /* 8 is minimum zlib stream size */ quit("need positive size of 8 or greater"); size = (unsigned)ret; /* allocate memory for buffers and compression engine */ blk = malloc(size + EXCESS); def.zalloc = Z_NULL; def.zfree = Z_NULL; def.opaque = Z_NULL; ret = deflateInit(&def, Z_DEFAULT_COMPRESSION); if (ret != Z_OK || blk == NULL) quit("out of memory"); /* compress from stdin until output full, or no more input */ def.avail_out = size + EXCESS; def.next_out = blk; ret = partcompress(stdin, &def); if (ret == Z_ERRNO) quit("error reading input"); /* if it all fit, then size was undersubscribed -- done! */ if (ret == Z_STREAM_END && def.avail_out >= EXCESS) { /* write block to stdout */ have = size + EXCESS - def.avail_out; if (fwrite(blk, 1, have, stdout) != have || ferror(stdout)) quit("error writing output"); /* clean up and print results to stderr */ ret = deflateEnd(&def); assert(ret != Z_STREAM_ERROR); free(blk); fprintf(stderr, "%u bytes unused out of %u requested (all input)\n", size - have, size); return 0; } /* it didn't all fit -- set up for recompression */ inf.zalloc = Z_NULL; inf.zfree = Z_NULL; inf.opaque = Z_NULL; inf.avail_in = 0; inf.next_in = Z_NULL; ret = inflateInit(&inf); tmp = malloc(size + EXCESS); if (ret != Z_OK || tmp == NULL) quit("out of memory"); ret = deflateReset(&def); assert(ret != Z_STREAM_ERROR); /* do first recompression close to the right amount */ inf.avail_in = size + EXCESS; inf.next_in = blk; def.avail_out = size + EXCESS; def.next_out = tmp; ret = recompress(&inf, &def); if (ret == Z_MEM_ERROR) quit("out of memory"); /* set up for next reocmpression */ ret = inflateReset(&inf); assert(ret != Z_STREAM_ERROR); ret = deflateReset(&def); assert(ret != Z_STREAM_ERROR); /* do second and final recompression (third compression) */ inf.avail_in = size - MARGIN; /* assure stream will complete */ inf.next_in = tmp; def.avail_out = size; def.next_out = blk; ret = recompress(&inf, &def); if (ret == Z_MEM_ERROR) quit("out of memory"); assert(ret == Z_STREAM_END); /* otherwise MARGIN too small */ /* done -- write block to stdout */ have = size - def.avail_out; if (fwrite(blk, 1, have, stdout) != have || ferror(stdout)) quit("error writing output"); /* clean up and print results to stderr */ free(tmp); ret = inflateEnd(&inf); assert(ret != Z_STREAM_ERROR); ret = deflateEnd(&def); assert(ret != Z_STREAM_ERROR); free(blk); fprintf(stderr, "%u bytes unused out of %u requested (%lu input)\n", size - have, size, def.total_in); return 0; } sks-ecc-0.93/zlib/examples/zran.c0000644000175000017500000003571210604550750015645 0ustar nachonacho/* zran.c -- example of zlib/gzip stream indexing and random access * Copyright (C) 2005 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h Version 1.0 29 May 2005 Mark Adler */ /* Illustrate the use of Z_BLOCK, inflatePrime(), and inflateSetDictionary() for random access of a compressed file. A file containing a zlib or gzip stream is provided on the command line. The compressed stream is decoded in its entirety, and an index built with access points about every SPAN bytes in the uncompressed output. The compressed file is left open, and can then be read randomly, having to decompress on the average SPAN/2 uncompressed bytes before getting to the desired block of data. An access point can be created at the start of any deflate block, by saving the starting file offset and bit of that block, and the 32K bytes of uncompressed data that precede that block. Also the uncompressed offset of that block is saved to provide a referece for locating a desired starting point in the uncompressed stream. build_index() works by decompressing the input zlib or gzip stream a block at a time, and at the end of each block deciding if enough uncompressed data has gone by to justify the creation of a new access point. If so, that point is saved in a data structure that grows as needed to accommodate the points. To use the index, an offset in the uncompressed data is provided, for which the latest accees point at or preceding that offset is located in the index. The input file is positioned to the specified location in the index, and if necessary the first few bits of the compressed data is read from the file. inflate is initialized with those bits and the 32K of uncompressed data, and the decompression then proceeds until the desired offset in the file is reached. Then the decompression continues to read the desired uncompressed data from the file. Another approach would be to generate the index on demand. In that case, requests for random access reads from the compressed data would try to use the index, but if a read far enough past the end of the index is required, then further index entries would be generated and added. There is some fair bit of overhead to starting inflation for the random access, mainly copying the 32K byte dictionary. So if small pieces of the file are being accessed, it would make sense to implement a cache to hold some lookahead and avoid many calls to extract() for small lengths. Another way to build an index would be to use inflateCopy(). That would not be constrained to have access points at block boundaries, but requires more memory per access point, and also cannot be saved to file due to the use of pointers in the state. The approach here allows for storage of the index in a file. */ #include #include #include #include "zlib.h" #define local static #define SPAN 1048576L /* desired distance between access points */ #define WINSIZE 32768U /* sliding window size */ #define CHUNK 16384 /* file input buffer size */ /* access point entry */ struct point { off_t out; /* corresponding offset in uncompressed data */ off_t in; /* offset in input file of first full byte */ int bits; /* number of bits (1-7) from byte at in - 1, or 0 */ unsigned char window[WINSIZE]; /* preceding 32K of uncompressed data */ }; /* access point list */ struct access { int have; /* number of list entries filled in */ int size; /* number of list entries allocated */ struct point *list; /* allocated list */ }; /* Deallocate an index built by build_index() */ local void free_index(struct access *index) { if (index != NULL) { free(index->list); free(index); } } /* Add an entry to the access point list. If out of memory, deallocate the existing list and return NULL. */ local struct access *addpoint(struct access *index, int bits, off_t in, off_t out, unsigned left, unsigned char *window) { struct point *next; /* if list is empty, create it (start with eight points) */ if (index == NULL) { index = malloc(sizeof(struct access)); if (index == NULL) return NULL; index->list = malloc(sizeof(struct point) << 3); if (index->list == NULL) { free(index); return NULL; } index->size = 8; index->have = 0; } /* if list is full, make it bigger */ else if (index->have == index->size) { index->size <<= 1; next = realloc(index->list, sizeof(struct point) * index->size); if (next == NULL) { free_index(index); return NULL; } index->list = next; } /* fill in entry and increment how many we have */ next = index->list + index->have; next->bits = bits; next->in = in; next->out = out; if (left) memcpy(next->window, window + WINSIZE - left, left); if (left < WINSIZE) memcpy(next->window + left, window, WINSIZE - left); index->have++; /* return list, possibly reallocated */ return index; } /* Make one entire pass through the compressed stream and build an index, with access points about every span bytes of uncompressed output -- span is chosen to balance the speed of random access against the memory requirements of the list, about 32K bytes per access point. Note that data after the end of the first zlib or gzip stream in the file is ignored. build_index() returns the number of access points on success (>= 1), Z_MEM_ERROR for out of memory, Z_DATA_ERROR for an error in the input file, or Z_ERRNO for a file read error. On success, *built points to the resulting index. */ local int build_index(FILE *in, off_t span, struct access **built) { int ret; off_t totin, totout; /* our own total counters to avoid 4GB limit */ off_t last; /* totout value of last access point */ struct access *index; /* access points being generated */ z_stream strm; unsigned char input[CHUNK]; unsigned char window[WINSIZE]; /* initialize inflate */ strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; strm.avail_in = 0; strm.next_in = Z_NULL; ret = inflateInit2(&strm, 47); /* automatic zlib or gzip decoding */ if (ret != Z_OK) return ret; /* inflate the input, maintain a sliding window, and build an index -- this also validates the integrity of the compressed data using the check information at the end of the gzip or zlib stream */ totin = totout = last = 0; index = NULL; /* will be allocated by first addpoint() */ strm.avail_out = 0; do { /* get some compressed data from input file */ strm.avail_in = fread(input, 1, CHUNK, in); if (ferror(in)) { ret = Z_ERRNO; goto build_index_error; } if (strm.avail_in == 0) { ret = Z_DATA_ERROR; goto build_index_error; } strm.next_in = input; /* process all of that, or until end of stream */ do { /* reset sliding window if necessary */ if (strm.avail_out == 0) { strm.avail_out = WINSIZE; strm.next_out = window; } /* inflate until out of input, output, or at end of block -- update the total input and output counters */ totin += strm.avail_in; totout += strm.avail_out; ret = inflate(&strm, Z_BLOCK); /* return at end of block */ totin -= strm.avail_in; totout -= strm.avail_out; if (ret == Z_NEED_DICT) ret = Z_DATA_ERROR; if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR) goto build_index_error; if (ret == Z_STREAM_END) break; /* if at end of block, consider adding an index entry (note that if data_type indicates an end-of-block, then all of the uncompressed data from that block has been delivered, and none of the compressed data after that block has been consumed, except for up to seven bits) -- the totout == 0 provides an entry point after the zlib or gzip header, and assures that the index always has at least one access point; we avoid creating an access point after the last block by checking bit 6 of data_type */ if ((strm.data_type & 128) && !(strm.data_type & 64) && (totout == 0 || totout - last > span)) { index = addpoint(index, strm.data_type & 7, totin, totout, strm.avail_out, window); if (index == NULL) { ret = Z_MEM_ERROR; goto build_index_error; } last = totout; } } while (strm.avail_in != 0); } while (ret != Z_STREAM_END); /* clean up and return index (release unused entries in list) */ (void)inflateEnd(&strm); index = realloc(index, sizeof(struct point) * index->have); index->size = index->have; *built = index; return index->size; /* return error */ build_index_error: (void)inflateEnd(&strm); if (index != NULL) free_index(index); return ret; } /* Use the index to read len bytes from offset into buf, return bytes read or negative for error (Z_DATA_ERROR or Z_MEM_ERROR). If data is requested past the end of the uncompressed data, then extract() will return a value less than len, indicating how much as actually read into buf. This function should not return a data error unless the file was modified since the index was generated. extract() may also return Z_ERRNO if there is an error on reading or seeking the input file. */ local int extract(FILE *in, struct access *index, off_t offset, unsigned char *buf, int len) { int ret, skip; z_stream strm; struct point *here; unsigned char input[CHUNK]; unsigned char discard[WINSIZE]; /* proceed only if something reasonable to do */ if (len < 0) return 0; /* find where in stream to start */ here = index->list; ret = index->have; while (--ret && here[1].out <= offset) here++; /* initialize file and inflate state to start there */ strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; strm.avail_in = 0; strm.next_in = Z_NULL; ret = inflateInit2(&strm, -15); /* raw inflate */ if (ret != Z_OK) return ret; ret = fseeko(in, here->in - (here->bits ? 1 : 0), SEEK_SET); if (ret == -1) goto extract_ret; if (here->bits) { ret = getc(in); if (ret == -1) { ret = ferror(in) ? Z_ERRNO : Z_DATA_ERROR; goto extract_ret; } (void)inflatePrime(&strm, here->bits, ret >> (8 - here->bits)); } (void)inflateSetDictionary(&strm, here->window, WINSIZE); /* skip uncompressed bytes until offset reached, then satisfy request */ offset -= here->out; strm.avail_in = 0; skip = 1; /* while skipping to offset */ do { /* define where to put uncompressed data, and how much */ if (offset == 0 && skip) { /* at offset now */ strm.avail_out = len; strm.next_out = buf; skip = 0; /* only do this once */ } if (offset > WINSIZE) { /* skip WINSIZE bytes */ strm.avail_out = WINSIZE; strm.next_out = discard; offset -= WINSIZE; } else if (offset != 0) { /* last skip */ strm.avail_out = (unsigned)offset; strm.next_out = discard; offset = 0; } /* uncompress until avail_out filled, or end of stream */ do { if (strm.avail_in == 0) { strm.avail_in = fread(input, 1, CHUNK, in); if (ferror(in)) { ret = Z_ERRNO; goto extract_ret; } if (strm.avail_in == 0) { ret = Z_DATA_ERROR; goto extract_ret; } strm.next_in = input; } ret = inflate(&strm, Z_NO_FLUSH); /* normal inflate */ if (ret == Z_NEED_DICT) ret = Z_DATA_ERROR; if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR) goto extract_ret; if (ret == Z_STREAM_END) break; } while (strm.avail_out != 0); /* if reach end of stream, then don't keep trying to get more */ if (ret == Z_STREAM_END) break; /* do until offset reached and requested data read, or stream ends */ } while (skip); /* compute number of uncompressed bytes read after offset */ ret = skip ? 0 : len - strm.avail_out; /* clean up and return bytes read or error */ extract_ret: (void)inflateEnd(&strm); return ret; } /* Demonstrate the use of build_index() and extract() by processing the file provided on the command line, and the extracting 16K from about 2/3rds of the way through the uncompressed output, and writing that to stdout. */ int main(int argc, char **argv) { int len; off_t offset; FILE *in; struct access *index; unsigned char buf[CHUNK]; /* open input file */ if (argc != 2) { fprintf(stderr, "usage: zran file.gz\n"); return 1; } in = fopen(argv[1], "rb"); if (in == NULL) { fprintf(stderr, "zran: could not open %s for reading\n", argv[1]); return 1; } /* build index */ len = build_index(in, SPAN, &index); if (len < 0) { fclose(in); switch (len) { case Z_MEM_ERROR: fprintf(stderr, "zran: out of memory\n"); break; case Z_DATA_ERROR: fprintf(stderr, "zran: compressed data error in %s\n", argv[1]); break; case Z_ERRNO: fprintf(stderr, "zran: read error on %s\n", argv[1]); break; default: fprintf(stderr, "zran: error %d while building index\n", len); } return 1; } fprintf(stderr, "zran: built index with %d access points\n", len); /* use index by reading some bytes from an arbitrary offset */ offset = (index->list[index->have - 1].out << 1) / 3; len = extract(in, index, offset, buf, CHUNK); if (len < 0) fprintf(stderr, "zran: extraction failed: %s error\n", len == Z_MEM_ERROR ? "out of memory" : "input corrupted"); else { fwrite(buf, 1, len, stdout); fprintf(stderr, "zran: extracted %d bytes at %llu\n", len, offset); } /* clean up and exit */ free_index(index); fclose(in); return 0; } sks-ecc-0.93/zlib/examples/README.examples0000644000175000017500000000275310604550750017223 0ustar nachonachoThis directory contains examples of the use of zlib. fitblk.c compress just enough input to nearly fill a requested output size - zlib isn't designed to do this, but fitblk does it anyway gun.c uncompress a gzip file - illustrates the use of inflateBack() for high speed file-to-file decompression using call-back functions - is approximately twice as fast as gzip -d - also provides Unix uncompress functionality, again twice as fast gzappend.c append to a gzip file - illustrates the use of the Z_BLOCK flush parameter for inflate() - illustrates the use of deflatePrime() to start at any bit gzjoin.c join gzip files without recalculating the crc or recompressing - illustrates the use of the Z_BLOCK flush parameter for inflate() - illustrates the use of crc32_combine() gzlog.c gzlog.h efficiently maintain a message log file in gzip format - illustrates use of raw deflate and Z_SYNC_FLUSH - illustrates use of gzip header extra field zlib_how.html painfully comprehensive description of zpipe.c (see below) - describes in excruciating detail the use of deflate() and inflate() zpipe.c reads and writes zlib streams from stdin to stdout - illustrates the proper use of deflate() and inflate() - deeply commented in zlib_how.html (see above) zran.c index a zlib or gzip stream and randomly access it - illustrates the use of Z_BLOCK, inflatePrime(), and inflateSetDictionary() to provide random access sks-ecc-0.93/zlib/contrib/0000755000175000017500000000000010604550750014341 5ustar nachonachosks-ecc-0.93/zlib/contrib/README.contrib0000644000175000017500000000521410604550750016662 0ustar nachonachoAll files under this contrib directory are UNSUPPORTED. There were provided by users of zlib and were not tested by the authors of zlib. Use at your own risk. Please contact the authors of the contributions for help about these, not the zlib authors. Thanks. ada/ by Dmitriy Anisimkov Support for Ada See http://zlib-ada.sourceforge.net/ asm586/ asm686/ by Brian Raiter asm code for Pentium and PPro/PII, using the AT&T (GNU as) syntax See http://www.muppetlabs.com/~breadbox/software/assembly.html blast/ by Mark Adler Decompressor for output of PKWare Data Compression Library (DCL) delphi/ by Cosmin Truta Support for Delphi and C++ Builder dotzlib/ by Henrik Ravn Support for Microsoft .Net and Visual C++ .Net infback9/ by Mark Adler Unsupported diffs to infback to decode the deflate64 format inflate86/ by Chris Anderson Tuned x86 gcc asm code to replace inflate_fast() iostream/ by Kevin Ruland A C++ I/O streams interface to the zlib gz* functions iostream2/ by Tyge Løvset Another C++ I/O streams interface iostream3/ by Ludwig Schwardt and Kevin Ruland Yet another C++ I/O streams interface masm686/ by Dan Higdon and Chuck Walbourn asm code for Pentium Pro/PII, using the MASM syntax masmx64/ by Gilles Vollant x86 64-bit (AMD64 and Intel EM64t) code for x64 assembler to replace longest_match() and inflate_fast() masmx86/ by Gilles Vollant x86 asm code to replace longest_match() and inflate_fast(), for Visual C++ and MASM minizip/ by Gilles Vollant Mini zip and unzip based on zlib See http://www.winimage.com/zLibDll/unzip.html pascal/ by Bob Dellaca et al. Support for Pascal puff/ by Mark Adler Small, low memory usage inflate. Also serves to provide an unambiguous description of the deflate format. testzlib/ by Gilles Vollant Example of the use of zlib untgz/ by Pedro A. Aranda Gutierrez A very simple tar.gz file extractor using zlib vstudio/ by Gilles Vollant Building a minizip-enhanced zlib with Microsoft Visual Studio sks-ecc-0.93/zlib/contrib/iostream/0000755000175000017500000000000010604550750016164 5ustar nachonachosks-ecc-0.93/zlib/contrib/iostream/test.cpp0000644000175000017500000000101610604550750017645 0ustar nachonacho #include "zfstream.h" int main() { // Construct a stream object with this filebuffer. Anything sent // to this stream will go to standard out. gzofstream os( 1, ios::out ); // This text is getting compressed and sent to stdout. // To prove this, run 'test | zcat'. os << "Hello, Mommy" << endl; os << setcompressionlevel( Z_NO_COMPRESSION ); os << "hello, hello, hi, ho!" << endl; setcompressionlevel( os, Z_DEFAULT_COMPRESSION ) << "I'm compressing again" << endl; os.close(); return 0; } sks-ecc-0.93/zlib/contrib/iostream/zfstream.cpp0000644000175000017500000001177010604550750020531 0ustar nachonacho #include "zfstream.h" gzfilebuf::gzfilebuf() : file(NULL), mode(0), own_file_descriptor(0) { } gzfilebuf::~gzfilebuf() { sync(); if ( own_file_descriptor ) close(); } gzfilebuf *gzfilebuf::open( const char *name, int io_mode ) { if ( is_open() ) return NULL; char char_mode[10]; char *p = char_mode; if ( io_mode & ios::in ) { mode = ios::in; *p++ = 'r'; } else if ( io_mode & ios::app ) { mode = ios::app; *p++ = 'a'; } else { mode = ios::out; *p++ = 'w'; } if ( io_mode & ios::binary ) { mode |= ios::binary; *p++ = 'b'; } // Hard code the compression level if ( io_mode & (ios::out|ios::app )) { *p++ = '9'; } // Put the end-of-string indicator *p = '\0'; if ( (file = gzopen(name, char_mode)) == NULL ) return NULL; own_file_descriptor = 1; return this; } gzfilebuf *gzfilebuf::attach( int file_descriptor, int io_mode ) { if ( is_open() ) return NULL; char char_mode[10]; char *p = char_mode; if ( io_mode & ios::in ) { mode = ios::in; *p++ = 'r'; } else if ( io_mode & ios::app ) { mode = ios::app; *p++ = 'a'; } else { mode = ios::out; *p++ = 'w'; } if ( io_mode & ios::binary ) { mode |= ios::binary; *p++ = 'b'; } // Hard code the compression level if ( io_mode & (ios::out|ios::app )) { *p++ = '9'; } // Put the end-of-string indicator *p = '\0'; if ( (file = gzdopen(file_descriptor, char_mode)) == NULL ) return NULL; own_file_descriptor = 0; return this; } gzfilebuf *gzfilebuf::close() { if ( is_open() ) { sync(); gzclose( file ); file = NULL; } return this; } int gzfilebuf::setcompressionlevel( int comp_level ) { return gzsetparams(file, comp_level, -2); } int gzfilebuf::setcompressionstrategy( int comp_strategy ) { return gzsetparams(file, -2, comp_strategy); } streampos gzfilebuf::seekoff( streamoff off, ios::seek_dir dir, int which ) { return streampos(EOF); } int gzfilebuf::underflow() { // If the file hasn't been opened for reading, error. if ( !is_open() || !(mode & ios::in) ) return EOF; // if a buffer doesn't exists, allocate one. if ( !base() ) { if ( (allocate()) == EOF ) return EOF; setp(0,0); } else { if ( in_avail() ) return (unsigned char) *gptr(); if ( out_waiting() ) { if ( flushbuf() == EOF ) return EOF; } } // Attempt to fill the buffer. int result = fillbuf(); if ( result == EOF ) { // disable get area setg(0,0,0); return EOF; } return (unsigned char) *gptr(); } int gzfilebuf::overflow( int c ) { if ( !is_open() || !(mode & ios::out) ) return EOF; if ( !base() ) { if ( allocate() == EOF ) return EOF; setg(0,0,0); } else { if (in_avail()) { return EOF; } if (out_waiting()) { if (flushbuf() == EOF) return EOF; } } int bl = blen(); setp( base(), base() + bl); if ( c != EOF ) { *pptr() = c; pbump(1); } return 0; } int gzfilebuf::sync() { if ( !is_open() ) return EOF; if ( out_waiting() ) return flushbuf(); return 0; } int gzfilebuf::flushbuf() { int n; char *q; q = pbase(); n = pptr() - q; if ( gzwrite( file, q, n) < n ) return EOF; setp(0,0); return 0; } int gzfilebuf::fillbuf() { int required; char *p; p = base(); required = blen(); int t = gzread( file, p, required ); if ( t <= 0) return EOF; setg( base(), base(), base()+t); return t; } gzfilestream_common::gzfilestream_common() : ios( gzfilestream_common::rdbuf() ) { } gzfilestream_common::~gzfilestream_common() { } void gzfilestream_common::attach( int fd, int io_mode ) { if ( !buffer.attach( fd, io_mode) ) clear( ios::failbit | ios::badbit ); else clear(); } void gzfilestream_common::open( const char *name, int io_mode ) { if ( !buffer.open( name, io_mode ) ) clear( ios::failbit | ios::badbit ); else clear(); } void gzfilestream_common::close() { if ( !buffer.close() ) clear( ios::failbit | ios::badbit ); } gzfilebuf *gzfilestream_common::rdbuf() { return &buffer; } gzifstream::gzifstream() : ios( gzfilestream_common::rdbuf() ) { clear( ios::badbit ); } gzifstream::gzifstream( const char *name, int io_mode ) : ios( gzfilestream_common::rdbuf() ) { gzfilestream_common::open( name, io_mode ); } gzifstream::gzifstream( int fd, int io_mode ) : ios( gzfilestream_common::rdbuf() ) { gzfilestream_common::attach( fd, io_mode ); } gzifstream::~gzifstream() { } gzofstream::gzofstream() : ios( gzfilestream_common::rdbuf() ) { clear( ios::badbit ); } gzofstream::gzofstream( const char *name, int io_mode ) : ios( gzfilestream_common::rdbuf() ) { gzfilestream_common::open( name, io_mode ); } gzofstream::gzofstream( int fd, int io_mode ) : ios( gzfilestream_common::rdbuf() ) { gzfilestream_common::attach( fd, io_mode ); } gzofstream::~gzofstream() { } sks-ecc-0.93/zlib/contrib/iostream/zfstream.h0000644000175000017500000000464310604550750020177 0ustar nachonacho #ifndef zfstream_h #define zfstream_h #include #include "zlib.h" class gzfilebuf : public streambuf { public: gzfilebuf( ); virtual ~gzfilebuf(); gzfilebuf *open( const char *name, int io_mode ); gzfilebuf *attach( int file_descriptor, int io_mode ); gzfilebuf *close(); int setcompressionlevel( int comp_level ); int setcompressionstrategy( int comp_strategy ); inline int is_open() const { return (file !=NULL); } virtual streampos seekoff( streamoff, ios::seek_dir, int ); virtual int sync(); protected: virtual int underflow(); virtual int overflow( int = EOF ); private: gzFile file; short mode; short own_file_descriptor; int flushbuf(); int fillbuf(); }; class gzfilestream_common : virtual public ios { friend class gzifstream; friend class gzofstream; friend gzofstream &setcompressionlevel( gzofstream &, int ); friend gzofstream &setcompressionstrategy( gzofstream &, int ); public: virtual ~gzfilestream_common(); void attach( int fd, int io_mode ); void open( const char *name, int io_mode ); void close(); protected: gzfilestream_common(); private: gzfilebuf *rdbuf(); gzfilebuf buffer; }; class gzifstream : public gzfilestream_common, public istream { public: gzifstream(); gzifstream( const char *name, int io_mode = ios::in ); gzifstream( int fd, int io_mode = ios::in ); virtual ~gzifstream(); }; class gzofstream : public gzfilestream_common, public ostream { public: gzofstream(); gzofstream( const char *name, int io_mode = ios::out ); gzofstream( int fd, int io_mode = ios::out ); virtual ~gzofstream(); }; template class gzomanip { friend gzofstream &operator<<(gzofstream &, const gzomanip &); public: gzomanip(gzofstream &(*f)(gzofstream &, T), T v) : func(f), val(v) { } private: gzofstream &(*func)(gzofstream &, T); T val; }; template gzofstream &operator<<(gzofstream &s, const gzomanip &m) { return (*m.func)(s, m.val); } inline gzofstream &setcompressionlevel( gzofstream &s, int l ) { (s.rdbuf())->setcompressionlevel(l); return s; } inline gzofstream &setcompressionstrategy( gzofstream &s, int l ) { (s.rdbuf())->setcompressionstrategy(l); return s; } inline gzomanip setcompressionlevel(int l) { return gzomanip(&setcompressionlevel,l); } inline gzomanip setcompressionstrategy(int l) { return gzomanip(&setcompressionstrategy,l); } #endif sks-ecc-0.93/zlib/contrib/asm586/0000755000175000017500000000000010604550750015364 5ustar nachonachosks-ecc-0.93/zlib/contrib/asm586/match.S0000600000175000017500000002510110604550750016573 0ustar nachonacho/* match.s -- Pentium-optimized version of longest_match() * Written for zlib 1.1.2 * Copyright (C) 1998 Brian Raiter * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License. */ #ifndef NO_UNDERLINE #define match_init _match_init #define longest_match _longest_match #endif #define MAX_MATCH (258) #define MIN_MATCH (3) #define MIN_LOOKAHEAD (MAX_MATCH + MIN_MATCH + 1) #define MAX_MATCH_8 ((MAX_MATCH + 7) & ~7) /* stack frame offsets */ #define wmask 0 /* local copy of s->wmask */ #define window 4 /* local copy of s->window */ #define windowbestlen 8 /* s->window + bestlen */ #define chainlenscanend 12 /* high word: current chain len */ /* low word: last bytes sought */ #define scanstart 16 /* first two bytes of string */ #define scanalign 20 /* dword-misalignment of string */ #define nicematch 24 /* a good enough match size */ #define bestlen 28 /* size of best match so far */ #define scan 32 /* ptr to string wanting match */ #define LocalVarsSize (36) /* saved ebx 36 */ /* saved edi 40 */ /* saved esi 44 */ /* saved ebp 48 */ /* return address 52 */ #define deflatestate 56 /* the function arguments */ #define curmatch 60 /* Offsets for fields in the deflate_state structure. These numbers * are calculated from the definition of deflate_state, with the * assumption that the compiler will dword-align the fields. (Thus, * changing the definition of deflate_state could easily cause this * program to crash horribly, without so much as a warning at * compile time. Sigh.) */ /* All the +zlib1222add offsets are due to the addition of fields * in zlib in the deflate_state structure since the asm code was first written * (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)"). * (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0"). * if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8"). */ #define zlib1222add (8) #define dsWSize (36+zlib1222add) #define dsWMask (44+zlib1222add) #define dsWindow (48+zlib1222add) #define dsPrev (56+zlib1222add) #define dsMatchLen (88+zlib1222add) #define dsPrevMatch (92+zlib1222add) #define dsStrStart (100+zlib1222add) #define dsMatchStart (104+zlib1222add) #define dsLookahead (108+zlib1222add) #define dsPrevLen (112+zlib1222add) #define dsMaxChainLen (116+zlib1222add) #define dsGoodMatch (132+zlib1222add) #define dsNiceMatch (136+zlib1222add) .file "match.S" .globl match_init, longest_match .text /* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */ longest_match: /* Save registers that the compiler may be using, and adjust %esp to */ /* make room for our stack frame. */ pushl %ebp pushl %edi pushl %esi pushl %ebx subl $LocalVarsSize, %esp /* Retrieve the function arguments. %ecx will hold cur_match */ /* throughout the entire function. %edx will hold the pointer to the */ /* deflate_state structure during the function's setup (before */ /* entering the main loop). */ movl deflatestate(%esp), %edx movl curmatch(%esp), %ecx /* if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; */ movl dsNiceMatch(%edx), %eax movl dsLookahead(%edx), %ebx cmpl %eax, %ebx jl LookaheadLess movl %eax, %ebx LookaheadLess: movl %ebx, nicematch(%esp) /* register Bytef *scan = s->window + s->strstart; */ movl dsWindow(%edx), %esi movl %esi, window(%esp) movl dsStrStart(%edx), %ebp lea (%esi,%ebp), %edi movl %edi, scan(%esp) /* Determine how many bytes the scan ptr is off from being */ /* dword-aligned. */ movl %edi, %eax negl %eax andl $3, %eax movl %eax, scanalign(%esp) /* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */ /* s->strstart - (IPos)MAX_DIST(s) : NIL; */ movl dsWSize(%edx), %eax subl $MIN_LOOKAHEAD, %eax subl %eax, %ebp jg LimitPositive xorl %ebp, %ebp LimitPositive: /* unsigned chain_length = s->max_chain_length; */ /* if (s->prev_length >= s->good_match) { */ /* chain_length >>= 2; */ /* } */ movl dsPrevLen(%edx), %eax movl dsGoodMatch(%edx), %ebx cmpl %ebx, %eax movl dsMaxChainLen(%edx), %ebx jl LastMatchGood shrl $2, %ebx LastMatchGood: /* chainlen is decremented once beforehand so that the function can */ /* use the sign flag instead of the zero flag for the exit test. */ /* It is then shifted into the high word, to make room for the scanend */ /* scanend value, which it will always accompany. */ decl %ebx shll $16, %ebx /* int best_len = s->prev_length; */ movl dsPrevLen(%edx), %eax movl %eax, bestlen(%esp) /* Store the sum of s->window + best_len in %esi locally, and in %esi. */ addl %eax, %esi movl %esi, windowbestlen(%esp) /* register ush scan_start = *(ushf*)scan; */ /* register ush scan_end = *(ushf*)(scan+best_len-1); */ movw (%edi), %bx movw %bx, scanstart(%esp) movw -1(%edi,%eax), %bx movl %ebx, chainlenscanend(%esp) /* Posf *prev = s->prev; */ /* uInt wmask = s->w_mask; */ movl dsPrev(%edx), %edi movl dsWMask(%edx), %edx mov %edx, wmask(%esp) /* Jump into the main loop. */ jmp LoopEntry .balign 16 /* do { * match = s->window + cur_match; * if (*(ushf*)(match+best_len-1) != scan_end || * *(ushf*)match != scan_start) continue; * [...] * } while ((cur_match = prev[cur_match & wmask]) > limit * && --chain_length != 0); * * Here is the inner loop of the function. The function will spend the * majority of its time in this loop, and majority of that time will * be spent in the first ten instructions. * * Within this loop: * %ebx = chainlenscanend - i.e., ((chainlen << 16) | scanend) * %ecx = curmatch * %edx = curmatch & wmask * %esi = windowbestlen - i.e., (window + bestlen) * %edi = prev * %ebp = limit * * Two optimization notes on the choice of instructions: * * The first instruction uses a 16-bit address, which costs an extra, * unpairable cycle. This is cheaper than doing a 32-bit access and * zeroing the high word, due to the 3-cycle misalignment penalty which * would occur half the time. This also turns out to be cheaper than * doing two separate 8-bit accesses, as the memory is so rarely in the * L1 cache. * * The window buffer, however, apparently spends a lot of time in the * cache, and so it is faster to retrieve the word at the end of the * match string with two 8-bit loads. The instructions that test the * word at the beginning of the match string, however, are executed * much less frequently, and there it was cheaper to use 16-bit * instructions, which avoided the necessity of saving off and * subsequently reloading one of the other registers. */ LookupLoop: /* 1 U & V */ movw (%edi,%edx,2), %cx /* 2 U pipe */ movl wmask(%esp), %edx /* 2 V pipe */ cmpl %ebp, %ecx /* 3 U pipe */ jbe LeaveNow /* 3 V pipe */ subl $0x00010000, %ebx /* 4 U pipe */ js LeaveNow /* 4 V pipe */ LoopEntry: movb -1(%esi,%ecx), %al /* 5 U pipe */ andl %ecx, %edx /* 5 V pipe */ cmpb %bl, %al /* 6 U pipe */ jnz LookupLoop /* 6 V pipe */ movb (%esi,%ecx), %ah cmpb %bh, %ah jnz LookupLoop movl window(%esp), %eax movw (%eax,%ecx), %ax cmpw scanstart(%esp), %ax jnz LookupLoop /* Store the current value of chainlen. */ movl %ebx, chainlenscanend(%esp) /* Point %edi to the string under scrutiny, and %esi to the string we */ /* are hoping to match it up with. In actuality, %esi and %edi are */ /* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */ /* initialized to -(MAX_MATCH_8 - scanalign). */ movl window(%esp), %esi movl scan(%esp), %edi addl %ecx, %esi movl scanalign(%esp), %eax movl $(-MAX_MATCH_8), %edx lea MAX_MATCH_8(%edi,%eax), %edi lea MAX_MATCH_8(%esi,%eax), %esi /* Test the strings for equality, 8 bytes at a time. At the end, * adjust %edx so that it is offset to the exact byte that mismatched. * * We already know at this point that the first three bytes of the * strings match each other, and they can be safely passed over before * starting the compare loop. So what this code does is skip over 0-3 * bytes, as much as necessary in order to dword-align the %edi * pointer. (%esi will still be misaligned three times out of four.) * * It should be confessed that this loop usually does not represent * much of the total running time. Replacing it with a more * straightforward "rep cmpsb" would not drastically degrade * performance. */ LoopCmps: movl (%esi,%edx), %eax movl (%edi,%edx), %ebx xorl %ebx, %eax jnz LeaveLoopCmps movl 4(%esi,%edx), %eax movl 4(%edi,%edx), %ebx xorl %ebx, %eax jnz LeaveLoopCmps4 addl $8, %edx jnz LoopCmps jmp LenMaximum LeaveLoopCmps4: addl $4, %edx LeaveLoopCmps: testl $0x0000FFFF, %eax jnz LenLower addl $2, %edx shrl $16, %eax LenLower: subb $1, %al adcl $0, %edx /* Calculate the length of the match. If it is longer than MAX_MATCH, */ /* then automatically accept it as the best possible match and leave. */ lea (%edi,%edx), %eax movl scan(%esp), %edi subl %edi, %eax cmpl $MAX_MATCH, %eax jge LenMaximum /* If the length of the match is not longer than the best match we */ /* have so far, then forget it and return to the lookup loop. */ movl deflatestate(%esp), %edx movl bestlen(%esp), %ebx cmpl %ebx, %eax jg LongerMatch movl chainlenscanend(%esp), %ebx movl windowbestlen(%esp), %esi movl dsPrev(%edx), %edi movl wmask(%esp), %edx andl %ecx, %edx jmp LookupLoop /* s->match_start = cur_match; */ /* best_len = len; */ /* if (len >= nice_match) break; */ /* scan_end = *(ushf*)(scan+best_len-1); */ LongerMatch: movl nicematch(%esp), %ebx movl %eax, bestlen(%esp) movl %ecx, dsMatchStart(%edx) cmpl %ebx, %eax jge LeaveNow movl window(%esp), %esi addl %eax, %esi movl %esi, windowbestlen(%esp) movl chainlenscanend(%esp), %ebx movw -1(%edi,%eax), %bx movl dsPrev(%edx), %edi movl %ebx, chainlenscanend(%esp) movl wmask(%esp), %edx andl %ecx, %edx jmp LookupLoop /* Accept the current string, with the maximum possible length. */ LenMaximum: movl deflatestate(%esp), %edx movl $MAX_MATCH, bestlen(%esp) movl %ecx, dsMatchStart(%edx) /* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */ /* return s->lookahead; */ LeaveNow: movl deflatestate(%esp), %edx movl bestlen(%esp), %ebx movl dsLookahead(%edx), %eax cmpl %eax, %ebx jg LookaheadRet movl %ebx, %eax LookaheadRet: /* Restore the stack and return from whence we came. */ addl $LocalVarsSize, %esp popl %ebx popl %esi popl %edi popl %ebp match_init: ret sks-ecc-0.93/zlib/contrib/asm586/README.5860000644000175000017500000000311710604550750016567 0ustar nachonachoThis is a patched version of zlib modified to use Pentium-optimized assembly code in the deflation algorithm. The files changed/added by this patch are: README.586 match.S The effectiveness of these modifications is a bit marginal, as the the program's bottleneck seems to be mostly L1-cache contention, for which there is no real way to work around without rewriting the basic algorithm. The speedup on average is around 5-10% (which is generally less than the amount of variance between subsequent executions). However, when used at level 9 compression, the cache contention can drop enough for the assembly version to achieve 10-20% speedup (and sometimes more, depending on the amount of overall redundancy in the files). Even here, though, cache contention can still be the limiting factor, depending on the nature of the program using the zlib library. This may also mean that better improvements will be seen on a Pentium with MMX, which suffers much less from L1-cache contention, but I have not yet verified this. Note that this code has been tailored for the Pentium in particular, and will not perform well on the Pentium Pro (due to the use of a partial register in the inner loop). If you are using an assembler other than GNU as, you will have to translate match.S to use your assembler's syntax. (Have fun.) Brian Raiter breadbox@muppetlabs.com April, 1998 Added for zlib 1.1.3: The patches come from http://www.muppetlabs.com/~breadbox/software/assembly.html To compile zlib with this asm file, copy match.S to the zlib directory then do: CFLAGS="-O3 -DASMV" ./configure make OBJA=match.o sks-ecc-0.93/zlib/contrib/iostream2/0000755000175000017500000000000010604550750016246 5ustar nachonachosks-ecc-0.93/zlib/contrib/iostream2/zstream.h0000644000175000017500000002210310604550750020102 0ustar nachonacho/* * * Copyright (c) 1997 * Christian Michelsen Research AS * Advanced Computing * Fantoftvegen 38, 5036 BERGEN, Norway * http://www.cmr.no * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Christian Michelsen Research AS makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * */ #ifndef ZSTREAM__H #define ZSTREAM__H /* * zstream.h - C++ interface to the 'zlib' general purpose compression library * $Id: zstream.h 1.1 1997-06-25 12:00:56+02 tyge Exp tyge $ */ #include #include #include #include "zlib.h" #if defined(_WIN32) # include # include # define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) #else # define SET_BINARY_MODE(file) #endif class zstringlen { public: zstringlen(class izstream&); zstringlen(class ozstream&, const char*); size_t value() const { return val.word; } private: struct Val { unsigned char byte; size_t word; } val; }; // ----------------------------- izstream ----------------------------- class izstream { public: izstream() : m_fp(0) {} izstream(FILE* fp) : m_fp(0) { open(fp); } izstream(const char* name) : m_fp(0) { open(name); } ~izstream() { close(); } /* Opens a gzip (.gz) file for reading. * open() can be used to read a file which is not in gzip format; * in this case read() will directly read from the file without * decompression. errno can be checked to distinguish two error * cases (if errno is zero, the zlib error is Z_MEM_ERROR). */ void open(const char* name) { if (m_fp) close(); m_fp = ::gzopen(name, "rb"); } void open(FILE* fp) { SET_BINARY_MODE(fp); if (m_fp) close(); m_fp = ::gzdopen(fileno(fp), "rb"); } /* Flushes all pending input if necessary, closes the compressed file * and deallocates all the (de)compression state. The return value is * the zlib error number (see function error() below). */ int close() { int r = ::gzclose(m_fp); m_fp = 0; return r; } /* Binary read the given number of bytes from the compressed file. */ int read(void* buf, size_t len) { return ::gzread(m_fp, buf, len); } /* 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. */ const char* error(int* errnum) { return ::gzerror(m_fp, errnum); } gzFile fp() { return m_fp; } private: gzFile m_fp; }; /* * Binary read the given (array of) object(s) from the compressed file. * If the input file was not in gzip format, read() copies the objects number * of bytes into the buffer. * returns the number of uncompressed bytes actually read * (0 for end of file, -1 for error). */ template inline int read(izstream& zs, T* x, Items items) { return ::gzread(zs.fp(), x, items*sizeof(T)); } /* * Binary input with the '>' operator. */ template inline izstream& operator>(izstream& zs, T& x) { ::gzread(zs.fp(), &x, sizeof(T)); return zs; } inline zstringlen::zstringlen(izstream& zs) { zs > val.byte; if (val.byte == 255) zs > val.word; else val.word = val.byte; } /* * Read length of string + the string with the '>' operator. */ inline izstream& operator>(izstream& zs, char* x) { zstringlen len(zs); ::gzread(zs.fp(), x, len.value()); x[len.value()] = '\0'; return zs; } inline char* read_string(izstream& zs) { zstringlen len(zs); char* x = new char[len.value()+1]; ::gzread(zs.fp(), x, len.value()); x[len.value()] = '\0'; return x; } // ----------------------------- ozstream ----------------------------- class ozstream { public: ozstream() : m_fp(0), m_os(0) { } ozstream(FILE* fp, int level = Z_DEFAULT_COMPRESSION) : m_fp(0), m_os(0) { open(fp, level); } ozstream(const char* name, int level = Z_DEFAULT_COMPRESSION) : m_fp(0), m_os(0) { open(name, level); } ~ozstream() { close(); } /* Opens a gzip (.gz) file for writing. * The compression level parameter should be in 0..9 * errno can be checked to distinguish two error cases * (if errno is zero, the zlib error is Z_MEM_ERROR). */ void open(const char* name, int level = Z_DEFAULT_COMPRESSION) { char mode[4] = "wb\0"; if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level; if (m_fp) close(); m_fp = ::gzopen(name, mode); } /* open from a FILE pointer. */ void open(FILE* fp, int level = Z_DEFAULT_COMPRESSION) { SET_BINARY_MODE(fp); char mode[4] = "wb\0"; if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level; if (m_fp) close(); m_fp = ::gzdopen(fileno(fp), mode); } /* 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 error() below). */ int close() { if (m_os) { ::gzwrite(m_fp, m_os->str(), m_os->pcount()); delete[] m_os->str(); delete m_os; m_os = 0; } int r = ::gzclose(m_fp); m_fp = 0; return r; } /* Binary write the given number of bytes into the compressed file. */ int write(const void* buf, size_t len) { return ::gzwrite(m_fp, (voidp) buf, len); } /* 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). flush() returns Z_OK if * the flush_ parameter is Z_FINISH and all output could be flushed. * flush() should be called only when strictly necessary because it can * degrade compression. */ int flush(int _flush) { os_flush(); return ::gzflush(m_fp, _flush); } /* 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. */ const char* error(int* errnum) { return ::gzerror(m_fp, errnum); } gzFile fp() { return m_fp; } ostream& os() { if (m_os == 0) m_os = new ostrstream; return *m_os; } void os_flush() { if (m_os && m_os->pcount()>0) { ostrstream* oss = new ostrstream; oss->fill(m_os->fill()); oss->flags(m_os->flags()); oss->precision(m_os->precision()); oss->width(m_os->width()); ::gzwrite(m_fp, m_os->str(), m_os->pcount()); delete[] m_os->str(); delete m_os; m_os = oss; } } private: gzFile m_fp; ostrstream* m_os; }; /* * Binary write the given (array of) object(s) into the compressed file. * returns the number of uncompressed bytes actually written * (0 in case of error). */ template inline int write(ozstream& zs, const T* x, Items items) { return ::gzwrite(zs.fp(), (voidp) x, items*sizeof(T)); } /* * Binary output with the '<' operator. */ template inline ozstream& operator<(ozstream& zs, const T& x) { ::gzwrite(zs.fp(), (voidp) &x, sizeof(T)); return zs; } inline zstringlen::zstringlen(ozstream& zs, const char* x) { val.byte = 255; val.word = ::strlen(x); if (val.word < 255) zs < (val.byte = val.word); else zs < val; } /* * Write length of string + the string with the '<' operator. */ inline ozstream& operator<(ozstream& zs, const char* x) { zstringlen len(zs, x); ::gzwrite(zs.fp(), (voidp) x, len.value()); return zs; } #ifdef _MSC_VER inline ozstream& operator<(ozstream& zs, char* const& x) { return zs < (const char*) x; } #endif /* * Ascii write with the << operator; */ template inline ostream& operator<<(ozstream& zs, const T& x) { zs.os_flush(); return zs.os() << x; } #endif sks-ecc-0.93/zlib/contrib/iostream2/zstream_test.cpp0000644000175000017500000000130710604550750021477 0ustar nachonacho#include "zstream.h" #include #include #include void main() { char h[256] = "Hello"; char* g = "Goodbye"; ozstream out("temp.gz"); out < "This works well" < h < g; out.close(); izstream in("temp.gz"); // read it back char *x = read_string(in), *y = new char[256], z[256]; in > y > z; in.close(); cout << x << endl << y << endl << z << endl; out.open("temp.gz"); // try ascii output; zcat temp.gz to see the results out << setw(50) << setfill('#') << setprecision(20) << x << endl << y << endl << z << endl; out << z << endl << y << endl << x << endl; out << 1.1234567890123456789 << endl; delete[] x; delete[] y; } sks-ecc-0.93/zlib/contrib/vstudio/0000755000175000017500000000000010604550750016036 5ustar nachonachosks-ecc-0.93/zlib/contrib/vstudio/readme.txt0000644000175000017500000000574010604550750020042 0ustar nachonachoBuilding instructions for the DLL versions of Zlib 1.2.3 ======================================================== This directory contains projects that build zlib and minizip using Microsoft Visual C++ 7.0/7.1, and Visual C++ . You don't need to build these projects yourself. You can download the binaries from: http://www.winimage.com/zLibDll More information can be found at this site. Build instructions for Visual Studio 7.x (32 bits) -------------------------------------------------- - Uncompress current zlib, including all contrib/* files - Download the crtdll library from http://www.winimage.com/zLibDll/crtdll.zip Unzip crtdll.zip to extract crtdll.lib on contrib\vstudio\vc7. - Open contrib\vstudio\vc7\zlibvc.sln with Microsoft Visual C++ 7.x (Visual Studio .Net 2002 or 2003). Build instructions for Visual Studio 2005 (32 bits or 64 bits) -------------------------------------------------------------- - Uncompress current zlib, including all contrib/* files - For 32 bits only: download the crtdll library from http://www.winimage.com/zLibDll/crtdll.zip Unzip crtdll.zip to extract crtdll.lib on contrib\vstudio\vc8. - Open contrib\vstudio\vc8\zlibvc.sln with Microsoft Visual C++ 8.0 Build instructions for Visual Studio 2005 64 bits, PSDK compiler ---------------------------------------------------------------- at the time of writing this text file, Visual Studio 2005 (and Microsoft Visual C++ 8.0) is on the beta 2 stage. Using you can get the free 64 bits compiler from Platform SDK, which is NOT a beta, and compile using the Visual studio 2005 IDE see http://www.winimage.com/misc/sdk64onvs2005/ for instruction - Uncompress current zlib, including all contrib/* files - start Visual Studio 2005 from a platform SDK command prompt, using the /useenv switch - Open contrib\vstudio\vc8\zlibvc.sln with Microsoft Visual C++ 8.0 Important --------- - To use zlibwapi.dll in your application, you must define the macro ZLIB_WINAPI when compiling your application's source files. Additional notes ---------------- - This DLL, named zlibwapi.dll, is compatible to the old zlib.dll built by Gilles Vollant from the zlib 1.1.x sources, and distributed at http://www.winimage.com/zLibDll It uses the WINAPI calling convention for the exported functions, and includes the minizip functionality. If your application needs that particular build of zlib.dll, you can rename zlibwapi.dll to zlib.dll. - The new DLL was renamed because there exist several incompatible versions of zlib.dll on the Internet. - There is also an official DLL build of zlib, named zlib1.dll. This one is exporting the functions using the CDECL convention. See the file win32\DLL_FAQ.txt found in this zlib distribution. - There used to be a ZLIB_DLL macro in zlib 1.1.x, but now this symbol has a slightly different effect. To avoid compatibility problems, do not define it here. Gilles Vollant info@winimage.com sks-ecc-0.93/zlib/contrib/vstudio/vc8/0000755000175000017500000000000010604550750016536 5ustar nachonachosks-ecc-0.93/zlib/contrib/vstudio/vc8/minizip.vcproj0000644000175000017500000003062110604550750021444 0ustar nachonacho sks-ecc-0.93/zlib/contrib/vstudio/vc8/zlibvc.sln0000644000175000017500000002463110604550750020553 0ustar nachonacho Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestZlibDll", "testzlibdll.vcproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}" ProjectSection(ProjectDependencies) = postProject {8FD826F8-3739-44E6-8CC8-997122E53B8D} = {8FD826F8-3739-44E6-8CC8-997122E53B8D} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}" ProjectSection(ProjectDependencies) = postProject {8FD826F8-3739-44E6-8CC8-997122E53B8D} = {8FD826F8-3739-44E6-8CC8-997122E53B8D} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}" ProjectSection(ProjectDependencies) = postProject {8FD826F8-3739-44E6-8CC8-997122E53B8D} = {8FD826F8-3739-44E6-8CC8-997122E53B8D} EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Itanium = Debug|Itanium Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Itanium = Release|Itanium Release|Win32 = Release|Win32 Release|x64 = Release|x64 ReleaseWithoutAsm|Itanium = ReleaseWithoutAsm|Itanium ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32 ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.ActiveCfg = Debug|Itanium {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.Build.0 = Debug|Itanium {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.ActiveCfg = Release|Itanium {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.Build.0 = Release|Itanium {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = ReleaseWithoutAsm|x64 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = ReleaseWithoutAsm|x64 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.ActiveCfg = Debug|Itanium {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.Build.0 = Debug|Itanium {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.ActiveCfg = Release|Itanium {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.Build.0 = Release|Itanium {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Itanium {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.Build.0 = Debug|Itanium {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Itanium {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.Build.0 = Release|Itanium {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.ActiveCfg = Debug|Itanium {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.Build.0 = Debug|Itanium {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64 {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64 {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.ActiveCfg = Release|Itanium {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.Build.0 = Release|Itanium {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64 {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64 {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Itanium {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|Itanium {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Itanium {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.Build.0 = Debug|Itanium {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Itanium {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.Build.0 = Release|Itanium {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Itanium {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|Itanium {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.ActiveCfg = Debug|Itanium {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.Build.0 = Debug|Itanium {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.ActiveCfg = Release|Itanium {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.Build.0 = Release|Itanium {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Itanium {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|Itanium EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal sks-ecc-0.93/zlib/contrib/vstudio/vc8/zlib.rc0000644000175000017500000000164110604550750020026 0ustar nachonacho#include #define IDR_VERSION1 1 IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE FILEVERSION 1,2,3,0 PRODUCTVERSION 1,2,3,0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS 0 FILEOS VOS_DOS_WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE 0 // not used BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904E4" //language ID = U.S. English, char set = Windows, Multilingual BEGIN VALUE "FileDescription", "zlib data compression library\0" VALUE "FileVersion", "1.2.3.0\0" VALUE "InternalName", "zlib\0" VALUE "OriginalFilename", "zlib.dll\0" VALUE "ProductName", "ZLib.DLL\0" VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" VALUE "LegalCopyright", "(C) 1995-2003 Jean-loup Gailly & Mark Adler\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x0409, 1252 END END sks-ecc-0.93/zlib/contrib/vstudio/vc8/testzlib.vcproj0000644000175000017500000005012610604550750021627 0ustar nachonacho sks-ecc-0.93/zlib/contrib/vstudio/vc8/miniunz.vcproj0000644000175000017500000003111310604550750021453 0ustar nachonacho sks-ecc-0.93/zlib/contrib/vstudio/vc8/testzlibdll.vcproj0000644000175000017500000003121110604550750022315 0ustar nachonacho sks-ecc-0.93/zlib/contrib/vstudio/vc8/zlibvc.def0000644000175000017500000001060310604550750020507 0ustar nachonacho VERSION 1.23 HEAPSIZE 1048576,8192 EXPORTS adler32 @1 compress @2 crc32 @3 deflate @4 deflateCopy @5 deflateEnd @6 deflateInit2_ @7 deflateInit_ @8 deflateParams @9 deflateReset @10 deflateSetDictionary @11 gzclose @12 gzdopen @13 gzerror @14 gzflush @15 gzopen @16 gzread @17 gzwrite @18 inflate @19 inflateEnd @20 inflateInit2_ @21 inflateInit_ @22 inflateReset @23 inflateSetDictionary @24 inflateSync @25 uncompress @26 zlibVersion @27 gzprintf @28 gzputc @29 gzgetc @30 gzseek @31 gzrewind @32 gztell @33 gzeof @34 gzsetparams @35 zError @36 inflateSyncPoint @37 get_crc_table @38 compress2 @39 gzputs @40 gzgets @41 inflateCopy @42 inflateBackInit_ @43 inflateBack @44 inflateBackEnd @45 compressBound @46 deflateBound @47 gzclearerr @48 gzungetc @49 zlibCompileFlags @50 deflatePrime @51 unzOpen @61 unzClose @62 unzGetGlobalInfo @63 unzGetCurrentFileInfo @64 unzGoToFirstFile @65 unzGoToNextFile @66 unzOpenCurrentFile @67 unzReadCurrentFile @68 unzOpenCurrentFile3 @69 unztell @70 unzeof @71 unzCloseCurrentFile @72 unzGetGlobalComment @73 unzStringFileNameCompare @74 unzLocateFile @75 unzGetLocalExtrafield @76 unzOpen2 @77 unzOpenCurrentFile2 @78 unzOpenCurrentFilePassword @79 zipOpen @80 zipOpenNewFileInZip @81 zipWriteInFileInZip @82 zipCloseFileInZip @83 zipClose @84 zipOpenNewFileInZip2 @86 zipCloseFileInZipRaw @87 zipOpen2 @88 zipOpenNewFileInZip3 @89 unzGetFilePos @100 unzGoToFilePos @101 fill_win32_filefunc @110 sks-ecc-0.93/zlib/contrib/vstudio/vc8/zlibvc.vcproj0000644000175000017500000007013210604550750021257 0ustar nachonacho sks-ecc-0.93/zlib/contrib/vstudio/vc8/zlibstat.vcproj0000644000175000017500000004720310604550750021625 0ustar nachonacho sks-ecc-0.93/zlib/contrib/vstudio/vc7/0000755000175000017500000000000010604550750016535 5ustar nachonachosks-ecc-0.93/zlib/contrib/vstudio/vc7/minizip.vcproj0000644000175000017500000000622510604550750021446 0ustar nachonacho sks-ecc-0.93/zlib/contrib/vstudio/vc7/zlibvc.sln0000644000175000017500000001231510604550750020546 0ustar nachonachoMicrosoft Visual Studio Solution File, Format Version 7.00 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testZlibDll", "testzlib.vcproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654C}" EndProject Global GlobalSection(SolutionConfiguration) = preSolution ConfigName.0 = Debug ConfigName.1 = Release ConfigName.2 = ReleaseAxp ConfigName.3 = ReleaseWithoutAsm ConfigName.4 = ReleaseWithoutCrtdll EndGlobalSection GlobalSection(ProjectDependencies) = postSolution EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug.ActiveCfg = Debug|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug.Build.0 = Debug|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release.ActiveCfg = Release|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release.Build.0 = Release|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseAxp.ActiveCfg = ReleaseAxp|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseAxp.Build.0 = ReleaseAxp|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm.ActiveCfg = ReleaseWithoutAsm|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm.Build.0 = ReleaseWithoutAsm|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutCrtdll.ActiveCfg = ReleaseAxp|Win32 {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutCrtdll.Build.0 = ReleaseAxp|Win32 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug.ActiveCfg = Debug|Win32 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug.Build.0 = Debug|Win32 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release.ActiveCfg = Release|Win32 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release.Build.0 = Release|Win32 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseAxp.ActiveCfg = ReleaseAxp|Win32 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseAxp.Build.0 = ReleaseAxp|Win32 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm.ActiveCfg = ReleaseWithoutAsm|Win32 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm.Build.0 = ReleaseWithoutAsm|Win32 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutCrtdll.ActiveCfg = ReleaseWithoutCrtdll|Win32 {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutCrtdll.Build.0 = ReleaseWithoutCrtdll|Win32 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug.ActiveCfg = Debug|Win32 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug.Build.0 = Debug|Win32 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release.ActiveCfg = Release|Win32 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release.Build.0 = Release|Win32 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseAxp.ActiveCfg = Release|Win32 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseAxp.Build.0 = Release|Win32 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm.ActiveCfg = Release|Win32 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm.Build.0 = Release|Win32 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutCrtdll.ActiveCfg = Release|Win32 {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutCrtdll.Build.0 = Release|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug.ActiveCfg = Debug|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug.Build.0 = Debug|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release.ActiveCfg = Release|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release.Build.0 = Release|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseAxp.ActiveCfg = Release|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseAxp.Build.0 = Release|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm.ActiveCfg = Release|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm.Build.0 = Release|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutCrtdll.ActiveCfg = Release|Win32 {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutCrtdll.Build.0 = Release|Win32 {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.Debug.ActiveCfg = Debug|Win32 {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.Debug.Build.0 = Debug|Win32 {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.Release.ActiveCfg = Release|Win32 {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.Release.Build.0 = Release|Win32 {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.ReleaseAxp.ActiveCfg = Release|Win32 {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.ReleaseAxp.Build.0 = Release|Win32 {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.ReleaseWithoutAsm.ActiveCfg = Release|Win32 {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.ReleaseWithoutAsm.Build.0 = Release|Win32 {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.ReleaseWithoutCrtdll.ActiveCfg = Release|Win32 {AA6666AA-E09F-4135-9C0C-4FE50C3C654C}.ReleaseWithoutCrtdll.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal sks-ecc-0.93/zlib/contrib/vstudio/vc7/zlib.rc0000644000175000017500000000164110604550750020025 0ustar nachonacho#include #define IDR_VERSION1 1 IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE FILEVERSION 1,2,3,0 PRODUCTVERSION 1,2,3,0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS 0 FILEOS VOS_DOS_WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE 0 // not used BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904E4" //language ID = U.S. English, char set = Windows, Multilingual BEGIN VALUE "FileDescription", "zlib data compression library\0" VALUE "FileVersion", "1.2.3.0\0" VALUE "InternalName", "zlib\0" VALUE "OriginalFilename", "zlib.dll\0" VALUE "ProductName", "ZLib.DLL\0" VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" VALUE "LegalCopyright", "(C) 1995-2003 Jean-loup Gailly & Mark Adler\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x0409, 1252 END END sks-ecc-0.93/zlib/contrib/vstudio/vc7/testzlib.vcproj0000644000175000017500000000620210604550750021622 0ustar nachonacho sks-ecc-0.93/zlib/contrib/vstudio/vc7/miniunz.vcproj0000644000175000017500000000622510604550750021460 0ustar nachonacho sks-ecc-0.93/zlib/contrib/vstudio/vc7/zlibvc.def0000644000175000017500000001060310604550750020506 0ustar nachonacho VERSION 1.23 HEAPSIZE 1048576,8192 EXPORTS adler32 @1 compress @2 crc32 @3 deflate @4 deflateCopy @5 deflateEnd @6 deflateInit2_ @7 deflateInit_ @8 deflateParams @9 deflateReset @10 deflateSetDictionary @11 gzclose @12 gzdopen @13 gzerror @14 gzflush @15 gzopen @16 gzread @17 gzwrite @18 inflate @19 inflateEnd @20 inflateInit2_ @21 inflateInit_ @22 inflateReset @23 inflateSetDictionary @24 inflateSync @25 uncompress @26 zlibVersion @27 gzprintf @28 gzputc @29 gzgetc @30 gzseek @31 gzrewind @32 gztell @33 gzeof @34 gzsetparams @35 zError @36 inflateSyncPoint @37 get_crc_table @38 compress2 @39 gzputs @40 gzgets @41 inflateCopy @42 inflateBackInit_ @43 inflateBack @44 inflateBackEnd @45 compressBound @46 deflateBound @47 gzclearerr @48 gzungetc @49 zlibCompileFlags @50 deflatePrime @51 unzOpen @61 unzClose @62 unzGetGlobalInfo @63 unzGetCurrentFileInfo @64 unzGoToFirstFile @65 unzGoToNextFile @66 unzOpenCurrentFile @67 unzReadCurrentFile @68 unzOpenCurrentFile3 @69 unztell @70 unzeof @71 unzCloseCurrentFile @72 unzGetGlobalComment @73 unzStringFileNameCompare @74 unzLocateFile @75 unzGetLocalExtrafield @76 unzOpen2 @77 unzOpenCurrentFile2 @78 unzOpenCurrentFilePassword @79 zipOpen @80 zipOpenNewFileInZip @81 zipWriteInFileInZip @82 zipCloseFileInZip @83 zipClose @84 zipOpenNewFileInZip2 @86 zipCloseFileInZipRaw @87 zipOpen2 @88 zipOpenNewFileInZip3 @89 unzGetFilePos @100 unzGoToFilePos @101 fill_win32_filefunc @110 sks-ecc-0.93/zlib/contrib/vstudio/vc7/zlibvc.vcproj0000644000175000017500000003077010604550750021262 0ustar nachonacho sks-ecc-0.93/zlib/contrib/vstudio/vc7/zlibstat.vcproj0000644000175000017500000001465410604550750021630 0ustar nachonacho sks-ecc-0.93/zlib/contrib/puff/0000755000175000017500000000000010604550750015301 5ustar nachonachosks-ecc-0.93/zlib/contrib/puff/puff.c0000644000175000017500000011025410604550750016410 0ustar nachonacho/* * puff.c * Copyright (C) 2002-2004 Mark Adler * For conditions of distribution and use, see copyright notice in puff.h * version 1.8, 9 Jan 2004 * * puff.c is a simple inflate written to be an unambiguous way to specify the * deflate format. It is not written for speed but rather simplicity. As a * side benefit, this code might actually be useful when small code is more * important than speed, such as bootstrap applications. For typical deflate * data, zlib's inflate() is about four times as fast as puff(). zlib's * inflate compiles to around 20K on my machine, whereas puff.c compiles to * around 4K on my machine (a PowerPC using GNU cc). If the faster decode() * function here is used, then puff() is only twice as slow as zlib's * inflate(). * * All dynamically allocated memory comes from the stack. The stack required * is less than 2K bytes. This code is compatible with 16-bit int's and * assumes that long's are at least 32 bits. puff.c uses the short data type, * assumed to be 16 bits, for arrays in order to to conserve memory. The code * works whether integers are stored big endian or little endian. * * In the comments below are "Format notes" that describe the inflate process * and document some of the less obvious aspects of the format. This source * code is meant to supplement RFC 1951, which formally describes the deflate * format: * * http://www.zlib.org/rfc-deflate.html */ /* * Change history: * * 1.0 10 Feb 2002 - First version * 1.1 17 Feb 2002 - Clarifications of some comments and notes * - Update puff() dest and source pointers on negative * errors to facilitate debugging deflators * - Remove longest from struct huffman -- not needed * - Simplify offs[] index in construct() * - Add input size and checking, using longjmp() to * maintain easy readability * - Use short data type for large arrays * - Use pointers instead of long to specify source and * destination sizes to avoid arbitrary 4 GB limits * 1.2 17 Mar 2002 - Add faster version of decode(), doubles speed (!), * but leave simple version for readabilty * - Make sure invalid distances detected if pointers * are 16 bits * - Fix fixed codes table error * - Provide a scanning mode for determining size of * uncompressed data * 1.3 20 Mar 2002 - Go back to lengths for puff() parameters [Jean-loup] * - Add a puff.h file for the interface * - Add braces in puff() for else do [Jean-loup] * - Use indexes instead of pointers for readability * 1.4 31 Mar 2002 - Simplify construct() code set check * - Fix some comments * - Add FIXLCODES #define * 1.5 6 Apr 2002 - Minor comment fixes * 1.6 7 Aug 2002 - Minor format changes * 1.7 3 Mar 2003 - Added test code for distribution * - Added zlib-like license * 1.8 9 Jan 2004 - Added some comments on no distance codes case */ #include /* for setjmp(), longjmp(), and jmp_buf */ #include "puff.h" /* prototype for puff() */ #define local static /* for local function definitions */ #define NIL ((unsigned char *)0) /* for no output option */ /* * Maximums for allocations and loops. It is not useful to change these -- * they are fixed by the deflate format. */ #define MAXBITS 15 /* maximum bits in a code */ #define MAXLCODES 286 /* maximum number of literal/length codes */ #define MAXDCODES 30 /* maximum number of distance codes */ #define MAXCODES (MAXLCODES+MAXDCODES) /* maximum codes lengths to read */ #define FIXLCODES 288 /* number of fixed literal/length codes */ /* input and output state */ struct state { /* output state */ unsigned char *out; /* output buffer */ unsigned long outlen; /* available space at out */ unsigned long outcnt; /* bytes written to out so far */ /* input state */ unsigned char *in; /* input buffer */ unsigned long inlen; /* available input at in */ unsigned long incnt; /* bytes read so far */ int bitbuf; /* bit buffer */ int bitcnt; /* number of bits in bit buffer */ /* input limit error return state for bits() and decode() */ jmp_buf env; }; /* * Return need bits from the input stream. This always leaves less than * eight bits in the buffer. bits() works properly for need == 0. * * Format notes: * * - Bits are stored in bytes from the least significant bit to the most * significant bit. Therefore bits are dropped from the bottom of the bit * buffer, using shift right, and new bytes are appended to the top of the * bit buffer, using shift left. */ local int bits(struct state *s, int need) { long val; /* bit accumulator (can use up to 20 bits) */ /* load at least need bits into val */ val = s->bitbuf; while (s->bitcnt < need) { if (s->incnt == s->inlen) longjmp(s->env, 1); /* out of input */ val |= (long)(s->in[s->incnt++]) << s->bitcnt; /* load eight bits */ s->bitcnt += 8; } /* drop need bits and update buffer, always zero to seven bits left */ s->bitbuf = (int)(val >> need); s->bitcnt -= need; /* return need bits, zeroing the bits above that */ return (int)(val & ((1L << need) - 1)); } /* * Process a stored block. * * Format notes: * * - After the two-bit stored block type (00), the stored block length and * stored bytes are byte-aligned for fast copying. Therefore any leftover * bits in the byte that has the last bit of the type, as many as seven, are * discarded. The value of the discarded bits are not defined and should not * be checked against any expectation. * * - The second inverted copy of the stored block length does not have to be * checked, but it's probably a good idea to do so anyway. * * - A stored block can have zero length. This is sometimes used to byte-align * subsets of the compressed data for random access or partial recovery. */ local int stored(struct state *s) { unsigned len; /* length of stored block */ /* discard leftover bits from current byte (assumes s->bitcnt < 8) */ s->bitbuf = 0; s->bitcnt = 0; /* get length and check against its one's complement */ if (s->incnt + 4 > s->inlen) return 2; /* not enough input */ len = s->in[s->incnt++]; len |= s->in[s->incnt++] << 8; if (s->in[s->incnt++] != (~len & 0xff) || s->in[s->incnt++] != ((~len >> 8) & 0xff)) return -2; /* didn't match complement! */ /* copy len bytes from in to out */ if (s->incnt + len > s->inlen) return 2; /* not enough input */ if (s->out != NIL) { if (s->outcnt + len > s->outlen) return 1; /* not enough output space */ while (len--) s->out[s->outcnt++] = s->in[s->incnt++]; } else { /* just scanning */ s->outcnt += len; s->incnt += len; } /* done with a valid stored block */ return 0; } /* * Huffman code decoding tables. count[1..MAXBITS] is the number of symbols of * each length, which for a canonical code are stepped through in order. * symbol[] are the symbol values in canonical order, where the number of * entries is the sum of the counts in count[]. The decoding process can be * seen in the function decode() below. */ struct huffman { short *count; /* number of symbols of each length */ short *symbol; /* canonically ordered symbols */ }; /* * Decode a code from the stream s using huffman table h. Return the symbol or * a negative value if there is an error. If all of the lengths are zero, i.e. * an empty code, or if the code is incomplete and an invalid code is received, * then -9 is returned after reading MAXBITS bits. * * Format notes: * * - The codes as stored in the compressed data are bit-reversed relative to * a simple integer ordering of codes of the same lengths. Hence below the * bits are pulled from the compressed data one at a time and used to * build the code value reversed from what is in the stream in order to * permit simple integer comparisons for decoding. A table-based decoding * scheme (as used in zlib) does not need to do this reversal. * * - The first code for the shortest length is all zeros. Subsequent codes of * the same length are simply integer increments of the previous code. When * moving up a length, a zero bit is appended to the code. For a complete * code, the last code of the longest length will be all ones. * * - Incomplete codes are handled by this decoder, since they are permitted * in the deflate format. See the format notes for fixed() and dynamic(). */ #ifdef SLOW local int decode(struct state *s, struct huffman *h) { int len; /* current number of bits in code */ int code; /* len bits being decoded */ int first; /* first code of length len */ int count; /* number of codes of length len */ int index; /* index of first code of length len in symbol table */ code = first = index = 0; for (len = 1; len <= MAXBITS; len++) { code |= bits(s, 1); /* get next bit */ count = h->count[len]; if (code < first + count) /* if length len, return symbol */ return h->symbol[index + (code - first)]; index += count; /* else update for next length */ first += count; first <<= 1; code <<= 1; } return -9; /* ran out of codes */ } /* * A faster version of decode() for real applications of this code. It's not * as readable, but it makes puff() twice as fast. And it only makes the code * a few percent larger. */ #else /* !SLOW */ local int decode(struct state *s, struct huffman *h) { int len; /* current number of bits in code */ int code; /* len bits being decoded */ int first; /* first code of length len */ int count; /* number of codes of length len */ int index; /* index of first code of length len in symbol table */ int bitbuf; /* bits from stream */ int left; /* bits left in next or left to process */ short *next; /* next number of codes */ bitbuf = s->bitbuf; left = s->bitcnt; code = first = index = 0; len = 1; next = h->count + 1; while (1) { while (left--) { code |= bitbuf & 1; bitbuf >>= 1; count = *next++; if (code < first + count) { /* if length len, return symbol */ s->bitbuf = bitbuf; s->bitcnt = (s->bitcnt - len) & 7; return h->symbol[index + (code - first)]; } index += count; /* else update for next length */ first += count; first <<= 1; code <<= 1; len++; } left = (MAXBITS+1) - len; if (left == 0) break; if (s->incnt == s->inlen) longjmp(s->env, 1); /* out of input */ bitbuf = s->in[s->incnt++]; if (left > 8) left = 8; } return -9; /* ran out of codes */ } #endif /* SLOW */ /* * Given the list of code lengths length[0..n-1] representing a canonical * Huffman code for n symbols, construct the tables required to decode those * codes. Those tables are the number of codes of each length, and the symbols * sorted by length, retaining their original order within each length. The * return value is zero for a complete code set, negative for an over- * subscribed code set, and positive for an incomplete code set. The tables * can be used if the return value is zero or positive, but they cannot be used * if the return value is negative. If the return value is zero, it is not * possible for decode() using that table to return an error--any stream of * enough bits will resolve to a symbol. If the return value is positive, then * it is possible for decode() using that table to return an error for received * codes past the end of the incomplete lengths. * * Not used by decode(), but used for error checking, h->count[0] is the number * of the n symbols not in the code. So n - h->count[0] is the number of * codes. This is useful for checking for incomplete codes that have more than * one symbol, which is an error in a dynamic block. * * Assumption: for all i in 0..n-1, 0 <= length[i] <= MAXBITS * This is assured by the construction of the length arrays in dynamic() and * fixed() and is not verified by construct(). * * Format notes: * * - Permitted and expected examples of incomplete codes are one of the fixed * codes and any code with a single symbol which in deflate is coded as one * bit instead of zero bits. See the format notes for fixed() and dynamic(). * * - Within a given code length, the symbols are kept in ascending order for * the code bits definition. */ local int construct(struct huffman *h, short *length, int n) { int symbol; /* current symbol when stepping through length[] */ int len; /* current length when stepping through h->count[] */ int left; /* number of possible codes left of current length */ short offs[MAXBITS+1]; /* offsets in symbol table for each length */ /* count number of codes of each length */ for (len = 0; len <= MAXBITS; len++) h->count[len] = 0; for (symbol = 0; symbol < n; symbol++) (h->count[length[symbol]])++; /* assumes lengths are within bounds */ if (h->count[0] == n) /* no codes! */ return 0; /* complete, but decode() will fail */ /* check for an over-subscribed or incomplete set of lengths */ left = 1; /* one possible code of zero length */ for (len = 1; len <= MAXBITS; len++) { left <<= 1; /* one more bit, double codes left */ left -= h->count[len]; /* deduct count from possible codes */ if (left < 0) return left; /* over-subscribed--return negative */ } /* left > 0 means incomplete */ /* generate offsets into symbol table for each length for sorting */ offs[1] = 0; for (len = 1; len < MAXBITS; len++) offs[len + 1] = offs[len] + h->count[len]; /* * put symbols in table sorted by length, by symbol order within each * length */ for (symbol = 0; symbol < n; symbol++) if (length[symbol] != 0) h->symbol[offs[length[symbol]]++] = symbol; /* return zero for complete set, positive for incomplete set */ return left; } /* * Decode literal/length and distance codes until an end-of-block code. * * Format notes: * * - Compressed data that is after the block type if fixed or after the code * description if dynamic is a combination of literals and length/distance * pairs terminated by and end-of-block code. Literals are simply Huffman * coded bytes. A length/distance pair is a coded length followed by a * coded distance to represent a string that occurs earlier in the * uncompressed data that occurs again at the current location. * * - Literals, lengths, and the end-of-block code are combined into a single * code of up to 286 symbols. They are 256 literals (0..255), 29 length * symbols (257..285), and the end-of-block symbol (256). * * - There are 256 possible lengths (3..258), and so 29 symbols are not enough * to represent all of those. Lengths 3..10 and 258 are in fact represented * by just a length symbol. Lengths 11..257 are represented as a symbol and * some number of extra bits that are added as an integer to the base length * of the length symbol. The number of extra bits is determined by the base * length symbol. These are in the static arrays below, lens[] for the base * lengths and lext[] for the corresponding number of extra bits. * * - The reason that 258 gets its own symbol is that the longest length is used * often in highly redundant files. Note that 258 can also be coded as the * base value 227 plus the maximum extra value of 31. While a good deflate * should never do this, it is not an error, and should be decoded properly. * * - If a length is decoded, including its extra bits if any, then it is * followed a distance code. There are up to 30 distance symbols. Again * there are many more possible distances (1..32768), so extra bits are added * to a base value represented by the symbol. The distances 1..4 get their * own symbol, but the rest require extra bits. The base distances and * corresponding number of extra bits are below in the static arrays dist[] * and dext[]. * * - Literal bytes are simply written to the output. A length/distance pair is * an instruction to copy previously uncompressed bytes to the output. The * copy is from distance bytes back in the output stream, copying for length * bytes. * * - Distances pointing before the beginning of the output data are not * permitted. * * - Overlapped copies, where the length is greater than the distance, are * allowed and common. For example, a distance of one and a length of 258 * simply copies the last byte 258 times. A distance of four and a length of * twelve copies the last four bytes three times. A simple forward copy * ignoring whether the length is greater than the distance or not implements * this correctly. You should not use memcpy() since its behavior is not * defined for overlapped arrays. You should not use memmove() or bcopy() * since though their behavior -is- defined for overlapping arrays, it is * defined to do the wrong thing in this case. */ local int codes(struct state *s, struct huffman *lencode, struct huffman *distcode) { int symbol; /* decoded symbol */ int len; /* length for copy */ unsigned dist; /* distance for copy */ static const short lens[29] = { /* Size base for length codes 257..285 */ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258}; static const short lext[29] = { /* Extra bits for length codes 257..285 */ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0}; static const short dists[30] = { /* Offset base for distance codes 0..29 */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577}; static const short dext[30] = { /* Extra bits for distance codes 0..29 */ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}; /* decode literals and length/distance pairs */ do { symbol = decode(s, lencode); if (symbol < 0) return symbol; /* invalid symbol */ if (symbol < 256) { /* literal: symbol is the byte */ /* write out the literal */ if (s->out != NIL) { if (s->outcnt == s->outlen) return 1; s->out[s->outcnt] = symbol; } s->outcnt++; } else if (symbol > 256) { /* length */ /* get and compute length */ symbol -= 257; if (symbol >= 29) return -9; /* invalid fixed code */ len = lens[symbol] + bits(s, lext[symbol]); /* get and check distance */ symbol = decode(s, distcode); if (symbol < 0) return symbol; /* invalid symbol */ dist = dists[symbol] + bits(s, dext[symbol]); if (dist > s->outcnt) return -10; /* distance too far back */ /* copy length bytes from distance bytes back */ if (s->out != NIL) { if (s->outcnt + len > s->outlen) return 1; while (len--) { s->out[s->outcnt] = s->out[s->outcnt - dist]; s->outcnt++; } } else s->outcnt += len; } } while (symbol != 256); /* end of block symbol */ /* done with a valid fixed or dynamic block */ return 0; } /* * Process a fixed codes block. * * Format notes: * * - This block type can be useful for compressing small amounts of data for * which the size of the code descriptions in a dynamic block exceeds the * benefit of custom codes for that block. For fixed codes, no bits are * spent on code descriptions. Instead the code lengths for literal/length * codes and distance codes are fixed. The specific lengths for each symbol * can be seen in the "for" loops below. * * - The literal/length code is complete, but has two symbols that are invalid * and should result in an error if received. This cannot be implemented * simply as an incomplete code since those two symbols are in the "middle" * of the code. They are eight bits long and the longest literal/length\ * code is nine bits. Therefore the code must be constructed with those * symbols, and the invalid symbols must be detected after decoding. * * - The fixed distance codes also have two invalid symbols that should result * in an error if received. Since all of the distance codes are the same * length, this can be implemented as an incomplete code. Then the invalid * codes are detected while decoding. */ local int fixed(struct state *s) { static int virgin = 1; static short lencnt[MAXBITS+1], lensym[FIXLCODES]; static short distcnt[MAXBITS+1], distsym[MAXDCODES]; static struct huffman lencode = {lencnt, lensym}; static struct huffman distcode = {distcnt, distsym}; /* build fixed huffman tables if first call (may not be thread safe) */ if (virgin) { int symbol; short lengths[FIXLCODES]; /* literal/length table */ for (symbol = 0; symbol < 144; symbol++) lengths[symbol] = 8; for (; symbol < 256; symbol++) lengths[symbol] = 9; for (; symbol < 280; symbol++) lengths[symbol] = 7; for (; symbol < FIXLCODES; symbol++) lengths[symbol] = 8; construct(&lencode, lengths, FIXLCODES); /* distance table */ for (symbol = 0; symbol < MAXDCODES; symbol++) lengths[symbol] = 5; construct(&distcode, lengths, MAXDCODES); /* do this just once */ virgin = 0; } /* decode data until end-of-block code */ return codes(s, &lencode, &distcode); } /* * Process a dynamic codes block. * * Format notes: * * - A dynamic block starts with a description of the literal/length and * distance codes for that block. New dynamic blocks allow the compressor to * rapidly adapt to changing data with new codes optimized for that data. * * - The codes used by the deflate format are "canonical", which means that * the actual bits of the codes are generated in an unambiguous way simply * from the number of bits in each code. Therefore the code descriptions * are simply a list of code lengths for each symbol. * * - The code lengths are stored in order for the symbols, so lengths are * provided for each of the literal/length symbols, and for each of the * distance symbols. * * - If a symbol is not used in the block, this is represented by a zero as * as the code length. This does not mean a zero-length code, but rather * that no code should be created for this symbol. There is no way in the * deflate format to represent a zero-length code. * * - The maximum number of bits in a code is 15, so the possible lengths for * any code are 1..15. * * - The fact that a length of zero is not permitted for a code has an * interesting consequence. Normally if only one symbol is used for a given * code, then in fact that code could be represented with zero bits. However * in deflate, that code has to be at least one bit. So for example, if * only a single distance base symbol appears in a block, then it will be * represented by a single code of length one, in particular one 0 bit. This * is an incomplete code, since if a 1 bit is received, it has no meaning, * and should result in an error. So incomplete distance codes of one symbol * should be permitted, and the receipt of invalid codes should be handled. * * - It is also possible to have a single literal/length code, but that code * must be the end-of-block code, since every dynamic block has one. This * is not the most efficient way to create an empty block (an empty fixed * block is fewer bits), but it is allowed by the format. So incomplete * literal/length codes of one symbol should also be permitted. * * - If there are only literal codes and no lengths, then there are no distance * codes. This is represented by one distance code with zero bits. * * - The list of up to 286 length/literal lengths and up to 30 distance lengths * are themselves compressed using Huffman codes and run-length encoding. In * the list of code lengths, a 0 symbol means no code, a 1..15 symbol means * that length, and the symbols 16, 17, and 18 are run-length instructions. * Each of 16, 17, and 18 are follwed by extra bits to define the length of * the run. 16 copies the last length 3 to 6 times. 17 represents 3 to 10 * zero lengths, and 18 represents 11 to 138 zero lengths. Unused symbols * are common, hence the special coding for zero lengths. * * - The symbols for 0..18 are Huffman coded, and so that code must be * described first. This is simply a sequence of up to 19 three-bit values * representing no code (0) or the code length for that symbol (1..7). * * - A dynamic block starts with three fixed-size counts from which is computed * the number of literal/length code lengths, the number of distance code * lengths, and the number of code length code lengths (ok, you come up with * a better name!) in the code descriptions. For the literal/length and * distance codes, lengths after those provided are considered zero, i.e. no * code. The code length code lengths are received in a permuted order (see * the order[] array below) to make a short code length code length list more * likely. As it turns out, very short and very long codes are less likely * to be seen in a dynamic code description, hence what may appear initially * to be a peculiar ordering. * * - Given the number of literal/length code lengths (nlen) and distance code * lengths (ndist), then they are treated as one long list of nlen + ndist * code lengths. Therefore run-length coding can and often does cross the * boundary between the two sets of lengths. * * - So to summarize, the code description at the start of a dynamic block is * three counts for the number of code lengths for the literal/length codes, * the distance codes, and the code length codes. This is followed by the * code length code lengths, three bits each. This is used to construct the * code length code which is used to read the remainder of the lengths. Then * the literal/length code lengths and distance lengths are read as a single * set of lengths using the code length codes. Codes are constructed from * the resulting two sets of lengths, and then finally you can start * decoding actual compressed data in the block. * * - For reference, a "typical" size for the code description in a dynamic * block is around 80 bytes. */ local int dynamic(struct state *s) { int nlen, ndist, ncode; /* number of lengths in descriptor */ int index; /* index of lengths[] */ int err; /* construct() return value */ short lengths[MAXCODES]; /* descriptor code lengths */ short lencnt[MAXBITS+1], lensym[MAXLCODES]; /* lencode memory */ short distcnt[MAXBITS+1], distsym[MAXDCODES]; /* distcode memory */ struct huffman lencode = {lencnt, lensym}; /* length code */ struct huffman distcode = {distcnt, distsym}; /* distance code */ static const short order[19] = /* permutation of code length codes */ {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; /* get number of lengths in each table, check lengths */ nlen = bits(s, 5) + 257; ndist = bits(s, 5) + 1; ncode = bits(s, 4) + 4; if (nlen > MAXLCODES || ndist > MAXDCODES) return -3; /* bad counts */ /* read code length code lengths (really), missing lengths are zero */ for (index = 0; index < ncode; index++) lengths[order[index]] = bits(s, 3); for (; index < 19; index++) lengths[order[index]] = 0; /* build huffman table for code lengths codes (use lencode temporarily) */ err = construct(&lencode, lengths, 19); if (err != 0) return -4; /* require complete code set here */ /* read length/literal and distance code length tables */ index = 0; while (index < nlen + ndist) { int symbol; /* decoded value */ int len; /* last length to repeat */ symbol = decode(s, &lencode); if (symbol < 16) /* length in 0..15 */ lengths[index++] = symbol; else { /* repeat instruction */ len = 0; /* assume repeating zeros */ if (symbol == 16) { /* repeat last length 3..6 times */ if (index == 0) return -5; /* no last length! */ len = lengths[index - 1]; /* last length */ symbol = 3 + bits(s, 2); } else if (symbol == 17) /* repeat zero 3..10 times */ symbol = 3 + bits(s, 3); else /* == 18, repeat zero 11..138 times */ symbol = 11 + bits(s, 7); if (index + symbol > nlen + ndist) return -6; /* too many lengths! */ while (symbol--) /* repeat last or zero symbol times */ lengths[index++] = len; } } /* build huffman table for literal/length codes */ err = construct(&lencode, lengths, nlen); if (err < 0 || (err > 0 && nlen - lencode.count[0] != 1)) return -7; /* only allow incomplete codes if just one code */ /* build huffman table for distance codes */ err = construct(&distcode, lengths + nlen, ndist); if (err < 0 || (err > 0 && ndist - distcode.count[0] != 1)) return -8; /* only allow incomplete codes if just one code */ /* decode data until end-of-block code */ return codes(s, &lencode, &distcode); } /* * Inflate source to dest. On return, destlen and sourcelen are updated to the * size of the uncompressed data and the size of the deflate data respectively. * On success, the return value of puff() is zero. If there is an error in the * source data, i.e. it is not in the deflate format, then a negative value is * returned. If there is not enough input available or there is not enough * output space, then a positive error is returned. In that case, destlen and * sourcelen are not updated to facilitate retrying from the beginning with the * provision of more input data or more output space. In the case of invalid * inflate data (a negative error), the dest and source pointers are updated to * facilitate the debugging of deflators. * * puff() also has a mode to determine the size of the uncompressed output with * no output written. For this dest must be (unsigned char *)0. In this case, * the input value of *destlen is ignored, and on return *destlen is set to the * size of the uncompressed output. * * The return codes are: * * 2: available inflate data did not terminate * 1: output space exhausted before completing inflate * 0: successful inflate * -1: invalid block type (type == 3) * -2: stored block length did not match one's complement * -3: dynamic block code description: too many length or distance codes * -4: dynamic block code description: code lengths codes incomplete * -5: dynamic block code description: repeat lengths with no first length * -6: dynamic block code description: repeat more than specified lengths * -7: dynamic block code description: invalid literal/length code lengths * -8: dynamic block code description: invalid distance code lengths * -9: invalid literal/length or distance code in fixed or dynamic block * -10: distance is too far back in fixed or dynamic block * * Format notes: * * - Three bits are read for each block to determine the kind of block and * whether or not it is the last block. Then the block is decoded and the * process repeated if it was not the last block. * * - The leftover bits in the last byte of the deflate data after the last * block (if it was a fixed or dynamic block) are undefined and have no * expected values to check. */ int puff(unsigned char *dest, /* pointer to destination pointer */ unsigned long *destlen, /* amount of output space */ unsigned char *source, /* pointer to source data pointer */ unsigned long *sourcelen) /* amount of input available */ { struct state s; /* input/output state */ int last, type; /* block information */ int err; /* return value */ /* initialize output state */ s.out = dest; s.outlen = *destlen; /* ignored if dest is NIL */ s.outcnt = 0; /* initialize input state */ s.in = source; s.inlen = *sourcelen; s.incnt = 0; s.bitbuf = 0; s.bitcnt = 0; /* return if bits() or decode() tries to read past available input */ if (setjmp(s.env) != 0) /* if came back here via longjmp() */ err = 2; /* then skip do-loop, return error */ else { /* process blocks until last block or error */ do { last = bits(&s, 1); /* one if last block */ type = bits(&s, 2); /* block type 0..3 */ err = type == 0 ? stored(&s) : (type == 1 ? fixed(&s) : (type == 2 ? dynamic(&s) : -1)); /* type == 3, invalid */ if (err != 0) break; /* return with error */ } while (!last); } /* update the lengths and return */ if (err <= 0) { *destlen = s.outcnt; *sourcelen = s.incnt; } return err; } #ifdef TEST /* Example of how to use puff() */ #include #include #include #include local unsigned char *yank(char *name, unsigned long *len) { unsigned long size; unsigned char *buf; FILE *in; struct stat s; *len = 0; if (stat(name, &s)) return NULL; if ((s.st_mode & S_IFMT) != S_IFREG) return NULL; size = (unsigned long)(s.st_size); if (size == 0 || (off_t)size != s.st_size) return NULL; in = fopen(name, "r"); if (in == NULL) return NULL; buf = malloc(size); if (buf != NULL && fread(buf, 1, size, in) != size) { free(buf); buf = NULL; } fclose(in); *len = size; return buf; } int main(int argc, char **argv) { int ret; unsigned char *source; unsigned long len, sourcelen, destlen; if (argc < 2) return 2; source = yank(argv[1], &len); if (source == NULL) return 2; sourcelen = len; ret = puff(NIL, &destlen, source, &sourcelen); if (ret) printf("puff() failed with return code %d\n", ret); else { printf("puff() succeeded uncompressing %lu bytes\n", destlen); if (sourcelen < len) printf("%lu compressed bytes unused\n", len - sourcelen); } free(source); return ret; } #endif sks-ecc-0.93/zlib/contrib/puff/README0000644000175000017500000000600410604550750016161 0ustar nachonachoPuff -- A Simple Inflate 3 Mar 2003 Mark Adler madler@alumni.caltech.edu What this is -- puff.c provides the routine puff() to decompress the deflate data format. It does so more slowly than zlib, but the code is about one-fifth the size of the inflate code in zlib, and written to be very easy to read. Why I wrote this -- puff.c was written to document the deflate format unambiguously, by virtue of being working C code. It is meant to supplement RFC 1951, which formally describes the deflate format. I have received many questions on details of the deflate format, and I hope that reading this code will answer those questions. puff.c is heavily commented with details of the deflate format, especially those little nooks and cranies of the format that might not be obvious from a specification. puff.c may also be useful in applications where code size or memory usage is a very limited resource, and speed is not as important. How to use it -- Well, most likely you should just be reading puff.c and using zlib for actual applications, but if you must ... Include puff.h in your code, which provides this prototype: int puff(unsigned char *dest, /* pointer to destination pointer */ unsigned long *destlen, /* amount of output space */ unsigned char *source, /* pointer to source data pointer */ unsigned long *sourcelen); /* amount of input available */ Then you can call puff() to decompress a deflate stream that is in memory in its entirety at source, to a sufficiently sized block of memory for the decompressed data at dest. puff() is the only external symbol in puff.c The only C library functions that puff.c needs are setjmp() and longjmp(), which are used to simplify error checking in the code to improve readabilty. puff.c does no memory allocation, and uses less than 2K bytes off of the stack. If destlen is not enough space for the uncompressed data, then inflate will return an error without writing more than destlen bytes. Note that this means that in order to decompress the deflate data successfully, you need to know the size of the uncompressed data ahead of time. If needed, puff() can determine the size of the uncompressed data with no output space. This is done by passing dest equal to (unsigned char *)0. Then the initial value of *destlen is ignored and *destlen is set to the length of the uncompressed data. So if the size of the uncompressed data is not known, then two passes of puff() can be used--first to determine the size, and second to do the actual inflation after allocating the appropriate memory. Not pretty, but it works. (This is one of the reasons you should be using zlib.) The deflate format is self-terminating. If the deflate stream does not end in *sourcelen bytes, puff() will return an error without reading at or past endsource. On return, *sourcelen is updated to the amount of input data consumed, and *destlen is updated to the size of the uncompressed data. See the comments in puff.c for the possible return codes for puff(). sks-ecc-0.93/zlib/contrib/puff/zeros.raw0000644000175000017500000000227510604550750017164 0ustar nachonachoíÁàùS_áUpsks-ecc-0.93/zlib/contrib/puff/Makefile0000644000175000017500000000014510604550750016741 0ustar nachonachopuff: puff.c puff.h cc -DTEST -o puff puff.c test: puff puff zeros.raw clean: rm -f puff puff.o sks-ecc-0.93/zlib/contrib/puff/puff.h0000644000175000017500000000246010604550750016414 0ustar nachonacho/* puff.h Copyright (C) 2002, 2003 Mark Adler, all rights reserved version 1.7, 3 Mar 2002 This software is provided 'as-is', without any express or implied warranty. In no event will the author 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. Mark Adler madler@alumni.caltech.edu */ /* * See puff.c for purpose and usage. */ int puff(unsigned char *dest, /* pointer to destination pointer */ unsigned long *destlen, /* amount of output space */ unsigned char *source, /* pointer to source data pointer */ unsigned long *sourcelen); /* amount of input available */ sks-ecc-0.93/zlib/contrib/blast/0000755000175000017500000000000010604550750015446 5ustar nachonachosks-ecc-0.93/zlib/contrib/blast/test.pk0000644000175000017500000000001010604550750016750 0ustar nachonacho‚$%€sks-ecc-0.93/zlib/contrib/blast/README0000644000175000017500000000011210604550750016320 0ustar nachonachoRead blast.h for purpose and usage. Mark Adler madler@alumni.caltech.edu sks-ecc-0.93/zlib/contrib/blast/Makefile0000644000175000017500000000017710604550750017113 0ustar nachonachoblast: blast.c blast.h cc -DTEST -o blast blast.c test: blast blast < test.pk | cmp - test.txt clean: rm -f blast blast.o sks-ecc-0.93/zlib/contrib/blast/blast.c0000644000175000017500000004202110604550750016716 0ustar nachonacho/* blast.c * Copyright (C) 2003 Mark Adler * For conditions of distribution and use, see copyright notice in blast.h * version 1.1, 16 Feb 2003 * * blast.c decompresses data compressed by the PKWare Compression Library. * This function provides functionality similar to the explode() function of * the PKWare library, hence the name "blast". * * This decompressor is based on the excellent format description provided by * Ben Rudiak-Gould in comp.compression on August 13, 2001. Interestingly, the * example Ben provided in the post is incorrect. The distance 110001 should * instead be 111000. When corrected, the example byte stream becomes: * * 00 04 82 24 25 8f 80 7f * * which decompresses to "AIAIAIAIAIAIA" (without the quotes). */ /* * Change history: * * 1.0 12 Feb 2003 - First version * 1.1 16 Feb 2003 - Fixed distance check for > 4 GB uncompressed data */ #include /* for setjmp(), longjmp(), and jmp_buf */ #include "blast.h" /* prototype for blast() */ #define local static /* for local function definitions */ #define MAXBITS 13 /* maximum code length */ #define MAXWIN 4096 /* maximum window size */ /* input and output state */ struct state { /* input state */ blast_in infun; /* input function provided by user */ void *inhow; /* opaque information passed to infun() */ unsigned char *in; /* next input location */ unsigned left; /* available input at in */ int bitbuf; /* bit buffer */ int bitcnt; /* number of bits in bit buffer */ /* input limit error return state for bits() and decode() */ jmp_buf env; /* output state */ blast_out outfun; /* output function provided by user */ void *outhow; /* opaque information passed to outfun() */ unsigned next; /* index of next write location in out[] */ int first; /* true to check distances (for first 4K) */ unsigned char out[MAXWIN]; /* output buffer and sliding window */ }; /* * Return need bits from the input stream. This always leaves less than * eight bits in the buffer. bits() works properly for need == 0. * * Format notes: * * - Bits are stored in bytes from the least significant bit to the most * significant bit. Therefore bits are dropped from the bottom of the bit * buffer, using shift right, and new bytes are appended to the top of the * bit buffer, using shift left. */ local int bits(struct state *s, int need) { int val; /* bit accumulator */ /* load at least need bits into val */ val = s->bitbuf; while (s->bitcnt < need) { if (s->left == 0) { s->left = s->infun(s->inhow, &(s->in)); if (s->left == 0) longjmp(s->env, 1); /* out of input */ } val |= (int)(*(s->in)++) << s->bitcnt; /* load eight bits */ s->left--; s->bitcnt += 8; } /* drop need bits and update buffer, always zero to seven bits left */ s->bitbuf = val >> need; s->bitcnt -= need; /* return need bits, zeroing the bits above that */ return val & ((1 << need) - 1); } /* * Huffman code decoding tables. count[1..MAXBITS] is the number of symbols of * each length, which for a canonical code are stepped through in order. * symbol[] are the symbol values in canonical order, where the number of * entries is the sum of the counts in count[]. The decoding process can be * seen in the function decode() below. */ struct huffman { short *count; /* number of symbols of each length */ short *symbol; /* canonically ordered symbols */ }; /* * Decode a code from the stream s using huffman table h. Return the symbol or * a negative value if there is an error. If all of the lengths are zero, i.e. * an empty code, or if the code is incomplete and an invalid code is received, * then -9 is returned after reading MAXBITS bits. * * Format notes: * * - The codes as stored in the compressed data are bit-reversed relative to * a simple integer ordering of codes of the same lengths. Hence below the * bits are pulled from the compressed data one at a time and used to * build the code value reversed from what is in the stream in order to * permit simple integer comparisons for decoding. * * - The first code for the shortest length is all ones. Subsequent codes of * the same length are simply integer decrements of the previous code. When * moving up a length, a one bit is appended to the code. For a complete * code, the last code of the longest length will be all zeros. To support * this ordering, the bits pulled during decoding are inverted to apply the * more "natural" ordering starting with all zeros and incrementing. */ local int decode(struct state *s, struct huffman *h) { int len; /* current number of bits in code */ int code; /* len bits being decoded */ int first; /* first code of length len */ int count; /* number of codes of length len */ int index; /* index of first code of length len in symbol table */ int bitbuf; /* bits from stream */ int left; /* bits left in next or left to process */ short *next; /* next number of codes */ bitbuf = s->bitbuf; left = s->bitcnt; code = first = index = 0; len = 1; next = h->count + 1; while (1) { while (left--) { code |= (bitbuf & 1) ^ 1; /* invert code */ bitbuf >>= 1; count = *next++; if (code < first + count) { /* if length len, return symbol */ s->bitbuf = bitbuf; s->bitcnt = (s->bitcnt - len) & 7; return h->symbol[index + (code - first)]; } index += count; /* else update for next length */ first += count; first <<= 1; code <<= 1; len++; } left = (MAXBITS+1) - len; if (left == 0) break; if (s->left == 0) { s->left = s->infun(s->inhow, &(s->in)); if (s->left == 0) longjmp(s->env, 1); /* out of input */ } bitbuf = *(s->in)++; s->left--; if (left > 8) left = 8; } return -9; /* ran out of codes */ } /* * Given a list of repeated code lengths rep[0..n-1], where each byte is a * count (high four bits + 1) and a code length (low four bits), generate the * list of code lengths. This compaction reduces the size of the object code. * Then given the list of code lengths length[0..n-1] representing a canonical * Huffman code for n symbols, construct the tables required to decode those * codes. Those tables are the number of codes of each length, and the symbols * sorted by length, retaining their original order within each length. The * return value is zero for a complete code set, negative for an over- * subscribed code set, and positive for an incomplete code set. The tables * can be used if the return value is zero or positive, but they cannot be used * if the return value is negative. If the return value is zero, it is not * possible for decode() using that table to return an error--any stream of * enough bits will resolve to a symbol. If the return value is positive, then * it is possible for decode() using that table to return an error for received * codes past the end of the incomplete lengths. */ local int construct(struct huffman *h, const unsigned char *rep, int n) { int symbol; /* current symbol when stepping through length[] */ int len; /* current length when stepping through h->count[] */ int left; /* number of possible codes left of current length */ short offs[MAXBITS+1]; /* offsets in symbol table for each length */ short length[256]; /* code lengths */ /* convert compact repeat counts into symbol bit length list */ symbol = 0; do { len = *rep++; left = (len >> 4) + 1; len &= 15; do { length[symbol++] = len; } while (--left); } while (--n); n = symbol; /* count number of codes of each length */ for (len = 0; len <= MAXBITS; len++) h->count[len] = 0; for (symbol = 0; symbol < n; symbol++) (h->count[length[symbol]])++; /* assumes lengths are within bounds */ if (h->count[0] == n) /* no codes! */ return 0; /* complete, but decode() will fail */ /* check for an over-subscribed or incomplete set of lengths */ left = 1; /* one possible code of zero length */ for (len = 1; len <= MAXBITS; len++) { left <<= 1; /* one more bit, double codes left */ left -= h->count[len]; /* deduct count from possible codes */ if (left < 0) return left; /* over-subscribed--return negative */ } /* left > 0 means incomplete */ /* generate offsets into symbol table for each length for sorting */ offs[1] = 0; for (len = 1; len < MAXBITS; len++) offs[len + 1] = offs[len] + h->count[len]; /* * put symbols in table sorted by length, by symbol order within each * length */ for (symbol = 0; symbol < n; symbol++) if (length[symbol] != 0) h->symbol[offs[length[symbol]]++] = symbol; /* return zero for complete set, positive for incomplete set */ return left; } /* * Decode PKWare Compression Library stream. * * Format notes: * * - First byte is 0 if literals are uncoded or 1 if they are coded. Second * byte is 4, 5, or 6 for the number of extra bits in the distance code. * This is the base-2 logarithm of the dictionary size minus six. * * - Compressed data is a combination of literals and length/distance pairs * terminated by an end code. Literals are either Huffman coded or * uncoded bytes. A length/distance pair is a coded length followed by a * coded distance to represent a string that occurs earlier in the * uncompressed data that occurs again at the current location. * * - A bit preceding a literal or length/distance pair indicates which comes * next, 0 for literals, 1 for length/distance. * * - If literals are uncoded, then the next eight bits are the literal, in the * normal bit order in th stream, i.e. no bit-reversal is needed. Similarly, * no bit reversal is needed for either the length extra bits or the distance * extra bits. * * - Literal bytes are simply written to the output. A length/distance pair is * an instruction to copy previously uncompressed bytes to the output. The * copy is from distance bytes back in the output stream, copying for length * bytes. * * - Distances pointing before the beginning of the output data are not * permitted. * * - Overlapped copies, where the length is greater than the distance, are * allowed and common. For example, a distance of one and a length of 518 * simply copies the last byte 518 times. A distance of four and a length of * twelve copies the last four bytes three times. A simple forward copy * ignoring whether the length is greater than the distance or not implements * this correctly. */ local int decomp(struct state *s) { int lit; /* true if literals are coded */ int dict; /* log2(dictionary size) - 6 */ int symbol; /* decoded symbol, extra bits for distance */ int len; /* length for copy */ int dist; /* distance for copy */ int copy; /* copy counter */ unsigned char *from, *to; /* copy pointers */ static int virgin = 1; /* build tables once */ static short litcnt[MAXBITS+1], litsym[256]; /* litcode memory */ static short lencnt[MAXBITS+1], lensym[16]; /* lencode memory */ static short distcnt[MAXBITS+1], distsym[64]; /* distcode memory */ static struct huffman litcode = {litcnt, litsym}; /* length code */ static struct huffman lencode = {lencnt, lensym}; /* length code */ static struct huffman distcode = {distcnt, distsym};/* distance code */ /* bit lengths of literal codes */ static const unsigned char litlen[] = { 11, 124, 8, 7, 28, 7, 188, 13, 76, 4, 10, 8, 12, 10, 12, 10, 8, 23, 8, 9, 7, 6, 7, 8, 7, 6, 55, 8, 23, 24, 12, 11, 7, 9, 11, 12, 6, 7, 22, 5, 7, 24, 6, 11, 9, 6, 7, 22, 7, 11, 38, 7, 9, 8, 25, 11, 8, 11, 9, 12, 8, 12, 5, 38, 5, 38, 5, 11, 7, 5, 6, 21, 6, 10, 53, 8, 7, 24, 10, 27, 44, 253, 253, 253, 252, 252, 252, 13, 12, 45, 12, 45, 12, 61, 12, 45, 44, 173}; /* bit lengths of length codes 0..15 */ static const unsigned char lenlen[] = {2, 35, 36, 53, 38, 23}; /* bit lengths of distance codes 0..63 */ static const unsigned char distlen[] = {2, 20, 53, 230, 247, 151, 248}; static const short base[16] = { /* base for length codes */ 3, 2, 4, 5, 6, 7, 8, 9, 10, 12, 16, 24, 40, 72, 136, 264}; static const char extra[16] = { /* extra bits for length codes */ 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8}; /* set up decoding tables (once--might not be thread-safe) */ if (virgin) { construct(&litcode, litlen, sizeof(litlen)); construct(&lencode, lenlen, sizeof(lenlen)); construct(&distcode, distlen, sizeof(distlen)); virgin = 0; } /* read header */ lit = bits(s, 8); if (lit > 1) return -1; dict = bits(s, 8); if (dict < 4 || dict > 6) return -2; /* decode literals and length/distance pairs */ do { if (bits(s, 1)) { /* get length */ symbol = decode(s, &lencode); len = base[symbol] + bits(s, extra[symbol]); if (len == 519) break; /* end code */ /* get distance */ symbol = len == 2 ? 2 : dict; dist = decode(s, &distcode) << symbol; dist += bits(s, symbol); dist++; if (s->first && dist > s->next) return -3; /* distance too far back */ /* copy length bytes from distance bytes back */ do { to = s->out + s->next; from = to - dist; copy = MAXWIN; if (s->next < dist) { from += copy; copy = dist; } copy -= s->next; if (copy > len) copy = len; len -= copy; s->next += copy; do { *to++ = *from++; } while (--copy); if (s->next == MAXWIN) { if (s->outfun(s->outhow, s->out, s->next)) return 1; s->next = 0; s->first = 0; } } while (len != 0); } else { /* get literal and write it */ symbol = lit ? decode(s, &litcode) : bits(s, 8); s->out[s->next++] = symbol; if (s->next == MAXWIN) { if (s->outfun(s->outhow, s->out, s->next)) return 1; s->next = 0; s->first = 0; } } } while (1); return 0; } /* See comments in blast.h */ int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow) { struct state s; /* input/output state */ int err; /* return value */ /* initialize input state */ s.infun = infun; s.inhow = inhow; s.left = 0; s.bitbuf = 0; s.bitcnt = 0; /* initialize output state */ s.outfun = outfun; s.outhow = outhow; s.next = 0; s.first = 1; /* return if bits() or decode() tries to read past available input */ if (setjmp(s.env) != 0) /* if came back here via longjmp(), */ err = 2; /* then skip decomp(), return error */ else err = decomp(&s); /* decompress */ /* write any leftover output and update the error code if needed */ if (err != 1 && s.next && s.outfun(s.outhow, s.out, s.next) && err == 0) err = 1; return err; } #ifdef TEST /* Example of how to use blast() */ #include #include #define CHUNK 16384 local unsigned inf(void *how, unsigned char **buf) { static unsigned char hold[CHUNK]; *buf = hold; return fread(hold, 1, CHUNK, (FILE *)how); } local int outf(void *how, unsigned char *buf, unsigned len) { return fwrite(buf, 1, len, (FILE *)how) != len; } /* Decompress a PKWare Compression Library stream from stdin to stdout */ int main(void) { int ret, n; /* decompress to stdout */ ret = blast(inf, stdin, outf, stdout); if (ret != 0) fprintf(stderr, "blast error: %d\n", ret); /* see if there are any leftover bytes */ n = 0; while (getchar() != EOF) n++; if (n) fprintf(stderr, "blast warning: %d unused bytes of input\n", n); /* return blast() error code */ return ret; } #endif sks-ecc-0.93/zlib/contrib/blast/test.txt0000644000175000017500000000001510604550750017162 0ustar nachonachoAIAIAIAIAIAIAsks-ecc-0.93/zlib/contrib/blast/blast.h0000644000175000017500000000624510604550750016733 0ustar nachonacho/* blast.h -- interface for blast.c Copyright (C) 2003 Mark Adler version 1.1, 16 Feb 2003 This software is provided 'as-is', without any express or implied warranty. In no event will the author 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. Mark Adler madler@alumni.caltech.edu */ /* * blast() decompresses the PKWare Data Compression Library (DCL) compressed * format. It provides the same functionality as the explode() function in * that library. (Note: PKWare overused the "implode" verb, and the format * used by their library implode() function is completely different and * incompatible with the implode compression method supported by PKZIP.) */ typedef unsigned (*blast_in)(void *how, unsigned char **buf); typedef int (*blast_out)(void *how, unsigned char *buf, unsigned len); /* Definitions for input/output functions passed to blast(). See below for * what the provided functions need to do. */ int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow); /* Decompress input to output using the provided infun() and outfun() calls. * On success, the return value of blast() is zero. If there is an error in * the source data, i.e. it is not in the proper format, then a negative value * is returned. If there is not enough input available or there is not enough * output space, then a positive error is returned. * * The input function is invoked: len = infun(how, &buf), where buf is set by * infun() to point to the input buffer, and infun() returns the number of * available bytes there. If infun() returns zero, then blast() returns with * an input error. (blast() only asks for input if it needs it.) inhow is for * use by the application to pass an input descriptor to infun(), if desired. * * The output function is invoked: err = outfun(how, buf, len), where the bytes * to be written are buf[0..len-1]. If err is not zero, then blast() returns * with an output error. outfun() is always called with len <= 4096. outhow * is for use by the application to pass an output descriptor to outfun(), if * desired. * * The return codes are: * * 2: ran out of input before completing decompression * 1: output error before completing decompression * 0: successful decompression * -1: literal flag not zero or one * -2: dictionary size not in 4..6 * -3: distance is too far back * * At the bottom of blast.c is an example program that uses blast() that can be * compiled to produce a command-line decompression filter by defining TEST. */ sks-ecc-0.93/zlib/contrib/delphi/0000755000175000017500000000000010604550750015606 5ustar nachonachosks-ecc-0.93/zlib/contrib/delphi/readme.txt0000644000175000017500000000470410604550750017611 0ustar nachonacho Overview ======== This directory contains an update to the ZLib interface unit, distributed by Borland as a Delphi supplemental component. The original ZLib unit is Copyright (c) 1997,99 Borland Corp., and is based on zlib version 1.0.4. There are a series of bugs and security problems associated with that old zlib version, and we recommend the users to update their ZLib unit. Summary of modifications ======================== - Improved makefile, adapted to zlib version 1.2.1. - Some field types from TZStreamRec are changed from Integer to Longint, for consistency with the zlib.h header, and for 64-bit readiness. - The zlib_version constant is updated. - The new Z_RLE strategy has its corresponding symbolic constant. - The allocation and deallocation functions and function types (TAlloc, TFree, zlibAllocMem and zlibFreeMem) are now cdecl, and _malloc and _free are added as C RTL stubs. As a result, the original C sources of zlib can be compiled out of the box, and linked to the ZLib unit. Suggestions for improvements ============================ Currently, the ZLib unit provides only a limited wrapper around the zlib library, and much of the original zlib functionality is missing. Handling compressed file formats like ZIP/GZIP or PNG cannot be implemented without having this functionality. Applications that handle these formats are either using their own, duplicated code, or not using the ZLib unit at all. Here are a few suggestions: - Checksum class wrappers around adler32() and crc32(), similar to the Java classes that implement the java.util.zip.Checksum interface. - The ability to read and write raw deflate streams, without the zlib stream header and trailer. Raw deflate streams are used in the ZIP file format. - The ability to read and write gzip streams, used in the GZIP file format, and normally produced by the gzip program. - The ability to select a different compression strategy, useful to PNG and MNG image compression, and to multimedia compression in general. Besides the compression level TCompressionLevel = (clNone, clFastest, clDefault, clMax); which, in fact, could have used the 'z' prefix and avoided TColor-like symbols TCompressionLevel = (zcNone, zcFastest, zcDefault, zcMax); there could be a compression strategy TCompressionStrategy = (zsDefault, zsFiltered, zsHuffmanOnly, zsRle); - ZIP and GZIP stream handling via TStreams. -- Cosmin Truta sks-ecc-0.93/zlib/contrib/delphi/ZLib.pas0000644000175000017500000004003410604550750017154 0ustar nachonacho{*******************************************************} { } { Borland Delphi Supplemental Components } { ZLIB Data Compression Interface Unit } { } { Copyright (c) 1997,99 Borland Corporation } { } {*******************************************************} { Updated for zlib 1.2.x by Cosmin Truta } unit ZLib; interface uses SysUtils, Classes; type TAlloc = function (AppData: Pointer; Items, Size: Integer): Pointer; cdecl; TFree = procedure (AppData, Block: Pointer); cdecl; // Internal structure. Ignore. TZStreamRec = packed record next_in: PChar; // next input byte avail_in: Integer; // number of bytes available at next_in total_in: Longint; // total nb of input bytes read so far next_out: PChar; // next output byte should be put here avail_out: Integer; // remaining free space at next_out total_out: Longint; // total nb of bytes output so far msg: PChar; // last error message, NULL if no error internal: Pointer; // not visible by applications zalloc: TAlloc; // used to allocate the internal state zfree: TFree; // used to free the internal state AppData: Pointer; // private data object passed to zalloc and zfree data_type: Integer; // best guess about the data type: ascii or binary adler: Longint; // adler32 value of the uncompressed data reserved: Longint; // reserved for future use end; // Abstract ancestor class TCustomZlibStream = class(TStream) private FStrm: TStream; FStrmPos: Integer; FOnProgress: TNotifyEvent; FZRec: TZStreamRec; FBuffer: array [Word] of Char; protected procedure Progress(Sender: TObject); dynamic; property OnProgress: TNotifyEvent read FOnProgress write FOnProgress; constructor Create(Strm: TStream); end; { TCompressionStream compresses data on the fly as data is written to it, and stores the compressed data to another stream. TCompressionStream is write-only and strictly sequential. Reading from the stream will raise an exception. Using Seek to move the stream pointer will raise an exception. Output data is cached internally, written to the output stream only when the internal output buffer is full. All pending output data is flushed when the stream is destroyed. The Position property returns the number of uncompressed bytes of data that have been written to the stream so far. CompressionRate returns the on-the-fly percentage by which the original data has been compressed: (1 - (CompressedBytes / UncompressedBytes)) * 100 If raw data size = 100 and compressed data size = 25, the CompressionRate is 75% The OnProgress event is called each time the output buffer is filled and written to the output stream. This is useful for updating a progress indicator when you are writing a large chunk of data to the compression stream in a single call.} TCompressionLevel = (clNone, clFastest, clDefault, clMax); TCompressionStream = class(TCustomZlibStream) private function GetCompressionRate: Single; public constructor Create(CompressionLevel: TCompressionLevel; Dest: TStream); destructor Destroy; override; function Read(var Buffer; Count: Longint): Longint; override; function Write(const Buffer; Count: Longint): Longint; override; function Seek(Offset: Longint; Origin: Word): Longint; override; property CompressionRate: Single read GetCompressionRate; property OnProgress; end; { TDecompressionStream decompresses data on the fly as data is read from it. Compressed data comes from a separate source stream. TDecompressionStream is read-only and unidirectional; you can seek forward in the stream, but not backwards. The special case of setting the stream position to zero is allowed. Seeking forward decompresses data until the requested position in the uncompressed data has been reached. Seeking backwards, seeking relative to the end of the stream, requesting the size of the stream, and writing to the stream will raise an exception. The Position property returns the number of bytes of uncompressed data that have been read from the stream so far. The OnProgress event is called each time the internal input buffer of compressed data is exhausted and the next block is read from the input stream. This is useful for updating a progress indicator when you are reading a large chunk of data from the decompression stream in a single call.} TDecompressionStream = class(TCustomZlibStream) public constructor Create(Source: TStream); destructor Destroy; override; function Read(var Buffer; Count: Longint): Longint; override; function Write(const Buffer; Count: Longint): Longint; override; function Seek(Offset: Longint; Origin: Word): Longint; override; property OnProgress; end; { CompressBuf compresses data, buffer to buffer, in one call. In: InBuf = ptr to compressed data InBytes = number of bytes in InBuf Out: OutBuf = ptr to newly allocated buffer containing decompressed data OutBytes = number of bytes in OutBuf } procedure CompressBuf(const InBuf: Pointer; InBytes: Integer; out OutBuf: Pointer; out OutBytes: Integer); { DecompressBuf decompresses data, buffer to buffer, in one call. In: InBuf = ptr to compressed data InBytes = number of bytes in InBuf OutEstimate = zero, or est. size of the decompressed data Out: OutBuf = ptr to newly allocated buffer containing decompressed data OutBytes = number of bytes in OutBuf } procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer; OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer); { DecompressToUserBuf decompresses data, buffer to buffer, in one call. In: InBuf = ptr to compressed data InBytes = number of bytes in InBuf Out: OutBuf = ptr to user-allocated buffer to contain decompressed data BufSize = number of bytes in OutBuf } procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer; const OutBuf: Pointer; BufSize: Integer); const zlib_version = '1.2.3'; type EZlibError = class(Exception); ECompressionError = class(EZlibError); EDecompressionError = class(EZlibError); implementation uses ZLibConst; const Z_NO_FLUSH = 0; Z_PARTIAL_FLUSH = 1; Z_SYNC_FLUSH = 2; Z_FULL_FLUSH = 3; Z_FINISH = 4; Z_OK = 0; Z_STREAM_END = 1; Z_NEED_DICT = 2; Z_ERRNO = (-1); Z_STREAM_ERROR = (-2); Z_DATA_ERROR = (-3); Z_MEM_ERROR = (-4); Z_BUF_ERROR = (-5); Z_VERSION_ERROR = (-6); Z_NO_COMPRESSION = 0; Z_BEST_SPEED = 1; Z_BEST_COMPRESSION = 9; Z_DEFAULT_COMPRESSION = (-1); Z_FILTERED = 1; Z_HUFFMAN_ONLY = 2; Z_RLE = 3; Z_DEFAULT_STRATEGY = 0; Z_BINARY = 0; Z_ASCII = 1; Z_UNKNOWN = 2; Z_DEFLATED = 8; {$L adler32.obj} {$L compress.obj} {$L crc32.obj} {$L deflate.obj} {$L infback.obj} {$L inffast.obj} {$L inflate.obj} {$L inftrees.obj} {$L trees.obj} {$L uncompr.obj} {$L zutil.obj} procedure adler32; external; procedure compressBound; external; procedure crc32; external; procedure deflateInit2_; external; procedure deflateParams; external; function _malloc(Size: Integer): Pointer; cdecl; begin Result := AllocMem(Size); end; procedure _free(Block: Pointer); cdecl; begin FreeMem(Block); end; procedure _memset(P: Pointer; B: Byte; count: Integer); cdecl; begin FillChar(P^, count, B); end; procedure _memcpy(dest, source: Pointer; count: Integer); cdecl; begin Move(source^, dest^, count); end; // deflate compresses data function deflateInit_(var strm: TZStreamRec; level: Integer; version: PChar; recsize: Integer): Integer; external; function deflate(var strm: TZStreamRec; flush: Integer): Integer; external; function deflateEnd(var strm: TZStreamRec): Integer; external; // inflate decompresses data function inflateInit_(var strm: TZStreamRec; version: PChar; recsize: Integer): Integer; external; function inflate(var strm: TZStreamRec; flush: Integer): Integer; external; function inflateEnd(var strm: TZStreamRec): Integer; external; function inflateReset(var strm: TZStreamRec): Integer; external; function zlibAllocMem(AppData: Pointer; Items, Size: Integer): Pointer; cdecl; begin // GetMem(Result, Items*Size); Result := AllocMem(Items * Size); end; procedure zlibFreeMem(AppData, Block: Pointer); cdecl; begin FreeMem(Block); end; {function zlibCheck(code: Integer): Integer; begin Result := code; if code < 0 then raise EZlibError.Create('error'); //!! end;} function CCheck(code: Integer): Integer; begin Result := code; if code < 0 then raise ECompressionError.Create('error'); //!! end; function DCheck(code: Integer): Integer; begin Result := code; if code < 0 then raise EDecompressionError.Create('error'); //!! end; procedure CompressBuf(const InBuf: Pointer; InBytes: Integer; out OutBuf: Pointer; out OutBytes: Integer); var strm: TZStreamRec; P: Pointer; begin FillChar(strm, sizeof(strm), 0); strm.zalloc := zlibAllocMem; strm.zfree := zlibFreeMem; OutBytes := ((InBytes + (InBytes div 10) + 12) + 255) and not 255; GetMem(OutBuf, OutBytes); try strm.next_in := InBuf; strm.avail_in := InBytes; strm.next_out := OutBuf; strm.avail_out := OutBytes; CCheck(deflateInit_(strm, Z_BEST_COMPRESSION, zlib_version, sizeof(strm))); try while CCheck(deflate(strm, Z_FINISH)) <> Z_STREAM_END do begin P := OutBuf; Inc(OutBytes, 256); ReallocMem(OutBuf, OutBytes); strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P))); strm.avail_out := 256; end; finally CCheck(deflateEnd(strm)); end; ReallocMem(OutBuf, strm.total_out); OutBytes := strm.total_out; except FreeMem(OutBuf); raise end; end; procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer; OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer); var strm: TZStreamRec; P: Pointer; BufInc: Integer; begin FillChar(strm, sizeof(strm), 0); strm.zalloc := zlibAllocMem; strm.zfree := zlibFreeMem; BufInc := (InBytes + 255) and not 255; if OutEstimate = 0 then OutBytes := BufInc else OutBytes := OutEstimate; GetMem(OutBuf, OutBytes); try strm.next_in := InBuf; strm.avail_in := InBytes; strm.next_out := OutBuf; strm.avail_out := OutBytes; DCheck(inflateInit_(strm, zlib_version, sizeof(strm))); try while DCheck(inflate(strm, Z_NO_FLUSH)) <> Z_STREAM_END do begin P := OutBuf; Inc(OutBytes, BufInc); ReallocMem(OutBuf, OutBytes); strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P))); strm.avail_out := BufInc; end; finally DCheck(inflateEnd(strm)); end; ReallocMem(OutBuf, strm.total_out); OutBytes := strm.total_out; except FreeMem(OutBuf); raise end; end; procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer; const OutBuf: Pointer; BufSize: Integer); var strm: TZStreamRec; begin FillChar(strm, sizeof(strm), 0); strm.zalloc := zlibAllocMem; strm.zfree := zlibFreeMem; strm.next_in := InBuf; strm.avail_in := InBytes; strm.next_out := OutBuf; strm.avail_out := BufSize; DCheck(inflateInit_(strm, zlib_version, sizeof(strm))); try if DCheck(inflate(strm, Z_FINISH)) <> Z_STREAM_END then raise EZlibError.CreateRes(@sTargetBufferTooSmall); finally DCheck(inflateEnd(strm)); end; end; // TCustomZlibStream constructor TCustomZLibStream.Create(Strm: TStream); begin inherited Create; FStrm := Strm; FStrmPos := Strm.Position; FZRec.zalloc := zlibAllocMem; FZRec.zfree := zlibFreeMem; end; procedure TCustomZLibStream.Progress(Sender: TObject); begin if Assigned(FOnProgress) then FOnProgress(Sender); end; // TCompressionStream constructor TCompressionStream.Create(CompressionLevel: TCompressionLevel; Dest: TStream); const Levels: array [TCompressionLevel] of ShortInt = (Z_NO_COMPRESSION, Z_BEST_SPEED, Z_DEFAULT_COMPRESSION, Z_BEST_COMPRESSION); begin inherited Create(Dest); FZRec.next_out := FBuffer; FZRec.avail_out := sizeof(FBuffer); CCheck(deflateInit_(FZRec, Levels[CompressionLevel], zlib_version, sizeof(FZRec))); end; destructor TCompressionStream.Destroy; begin FZRec.next_in := nil; FZRec.avail_in := 0; try if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; while (CCheck(deflate(FZRec, Z_FINISH)) <> Z_STREAM_END) and (FZRec.avail_out = 0) do begin FStrm.WriteBuffer(FBuffer, sizeof(FBuffer)); FZRec.next_out := FBuffer; FZRec.avail_out := sizeof(FBuffer); end; if FZRec.avail_out < sizeof(FBuffer) then FStrm.WriteBuffer(FBuffer, sizeof(FBuffer) - FZRec.avail_out); finally deflateEnd(FZRec); end; inherited Destroy; end; function TCompressionStream.Read(var Buffer; Count: Longint): Longint; begin raise ECompressionError.CreateRes(@sInvalidStreamOp); end; function TCompressionStream.Write(const Buffer; Count: Longint): Longint; begin FZRec.next_in := @Buffer; FZRec.avail_in := Count; if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; while (FZRec.avail_in > 0) do begin CCheck(deflate(FZRec, 0)); if FZRec.avail_out = 0 then begin FStrm.WriteBuffer(FBuffer, sizeof(FBuffer)); FZRec.next_out := FBuffer; FZRec.avail_out := sizeof(FBuffer); FStrmPos := FStrm.Position; Progress(Self); end; end; Result := Count; end; function TCompressionStream.Seek(Offset: Longint; Origin: Word): Longint; begin if (Offset = 0) and (Origin = soFromCurrent) then Result := FZRec.total_in else raise ECompressionError.CreateRes(@sInvalidStreamOp); end; function TCompressionStream.GetCompressionRate: Single; begin if FZRec.total_in = 0 then Result := 0 else Result := (1.0 - (FZRec.total_out / FZRec.total_in)) * 100.0; end; // TDecompressionStream constructor TDecompressionStream.Create(Source: TStream); begin inherited Create(Source); FZRec.next_in := FBuffer; FZRec.avail_in := 0; DCheck(inflateInit_(FZRec, zlib_version, sizeof(FZRec))); end; destructor TDecompressionStream.Destroy; begin FStrm.Seek(-FZRec.avail_in, 1); inflateEnd(FZRec); inherited Destroy; end; function TDecompressionStream.Read(var Buffer; Count: Longint): Longint; begin FZRec.next_out := @Buffer; FZRec.avail_out := Count; if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; while (FZRec.avail_out > 0) do begin if FZRec.avail_in = 0 then begin FZRec.avail_in := FStrm.Read(FBuffer, sizeof(FBuffer)); if FZRec.avail_in = 0 then begin Result := Count - FZRec.avail_out; Exit; end; FZRec.next_in := FBuffer; FStrmPos := FStrm.Position; Progress(Self); end; CCheck(inflate(FZRec, 0)); end; Result := Count; end; function TDecompressionStream.Write(const Buffer; Count: Longint): Longint; begin raise EDecompressionError.CreateRes(@sInvalidStreamOp); end; function TDecompressionStream.Seek(Offset: Longint; Origin: Word): Longint; var I: Integer; Buf: array [0..4095] of Char; begin if (Offset = 0) and (Origin = soFromBeginning) then begin DCheck(inflateReset(FZRec)); FZRec.next_in := FBuffer; FZRec.avail_in := 0; FStrm.Position := 0; FStrmPos := 0; end else if ( (Offset >= 0) and (Origin = soFromCurrent)) or ( ((Offset - FZRec.total_out) > 0) and (Origin = soFromBeginning)) then begin if Origin = soFromBeginning then Dec(Offset, FZRec.total_out); if Offset > 0 then begin for I := 1 to Offset div sizeof(Buf) do ReadBuffer(Buf, sizeof(Buf)); ReadBuffer(Buf, Offset mod sizeof(Buf)); end; end else raise EDecompressionError.CreateRes(@sInvalidStreamOp); Result := FZRec.total_out; end; end. sks-ecc-0.93/zlib/contrib/delphi/ZLibConst.pas0000644000175000017500000000027210604550750020163 0ustar nachonachounit ZLibConst; interface resourcestring sTargetBufferTooSmall = 'ZLib error: target buffer may be too small'; sInvalidStreamOp = 'Invalid stream operation'; implementation end. sks-ecc-0.93/zlib/contrib/delphi/zlibd32.mak0000644000175000017500000000412510604550750017553 0ustar nachonacho# Makefile for zlib # For use with Delphi and C++ Builder under Win32 # Updated for zlib 1.2.x by Cosmin Truta # ------------ Borland C++ ------------ # This project uses the Delphi (fastcall/register) calling convention: LOC = -DZEXPORT=__fastcall -DZEXPORTVA=__cdecl CC = bcc32 LD = bcc32 AR = tlib # do not use "-pr" in CFLAGS CFLAGS = -a -d -k- -O2 $(LOC) LDFLAGS = # variables ZLIB_LIB = zlib.lib OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj # targets all: $(ZLIB_LIB) example.exe minigzip.exe .c.obj: $(CC) -c $(CFLAGS) $*.c adler32.obj: adler32.c zlib.h zconf.h compress.obj: compress.c zlib.h zconf.h crc32.obj: crc32.c zlib.h zconf.h crc32.h deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h gzio.obj: gzio.c zutil.h zlib.h zconf.h infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inffixed.h inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inffixed.h inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h uncompr.obj: uncompr.c zlib.h zconf.h zutil.obj: zutil.c zutil.h zlib.h zconf.h example.obj: example.c zlib.h zconf.h minigzip.obj: minigzip.c zlib.h zconf.h # For the sake of the old Borland make, # the command line is cut to fit in the MS-DOS 128 byte limit: $(ZLIB_LIB): $(OBJ1) $(OBJ2) -del $(ZLIB_LIB) $(AR) $(ZLIB_LIB) $(OBJP1) $(AR) $(ZLIB_LIB) $(OBJP2) # testing test: example.exe minigzip.exe example echo hello world | minigzip | minigzip -d example.exe: example.obj $(ZLIB_LIB) $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) minigzip.exe: minigzip.obj $(ZLIB_LIB) $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) # cleanup clean: -del *.obj -del *.exe -del *.lib -del *.tds -del zlib.bak -del foo.gz sks-ecc-0.93/zlib/contrib/asm686/0000755000175000017500000000000010604550750015365 5ustar nachonachosks-ecc-0.93/zlib/contrib/asm686/README.6860000644000175000017500000000203110604550750016563 0ustar nachonachoThis is a patched version of zlib, modified to use Pentium-Pro-optimized assembly code in the deflation algorithm. The files changed/added by this patch are: README.686 match.S The speedup that this patch provides varies, depending on whether the compiler used to build the original version of zlib falls afoul of the PPro's speed traps. My own tests show a speedup of around 10-20% at the default compression level, and 20-30% using -9, against a version compiled using gcc 2.7.2.3. Your mileage may vary. Note that this code has been tailored for the PPro/PII in particular, and will not perform particuarly well on a Pentium. If you are using an assembler other than GNU as, you will have to translate match.S to use your assembler's syntax. (Have fun.) Brian Raiter breadbox@muppetlabs.com April, 1998 Added for zlib 1.1.3: The patches come from http://www.muppetlabs.com/~breadbox/software/assembly.html To compile zlib with this asm file, copy match.S to the zlib directory then do: CFLAGS="-O3 -DASMV" ./configure make OBJA=match.o sks-ecc-0.93/zlib/contrib/asm686/match.S0000600000175000017500000002202610604550750016577 0ustar nachonacho/* match.s -- Pentium-Pro-optimized version of longest_match() * Written for zlib 1.1.2 * Copyright (C) 1998 Brian Raiter * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License. */ #ifndef NO_UNDERLINE #define match_init _match_init #define longest_match _longest_match #endif #define MAX_MATCH (258) #define MIN_MATCH (3) #define MIN_LOOKAHEAD (MAX_MATCH + MIN_MATCH + 1) #define MAX_MATCH_8 ((MAX_MATCH + 7) & ~7) /* stack frame offsets */ #define chainlenwmask 0 /* high word: current chain len */ /* low word: s->wmask */ #define window 4 /* local copy of s->window */ #define windowbestlen 8 /* s->window + bestlen */ #define scanstart 16 /* first two bytes of string */ #define scanend 12 /* last two bytes of string */ #define scanalign 20 /* dword-misalignment of string */ #define nicematch 24 /* a good enough match size */ #define bestlen 28 /* size of best match so far */ #define scan 32 /* ptr to string wanting match */ #define LocalVarsSize (36) /* saved ebx 36 */ /* saved edi 40 */ /* saved esi 44 */ /* saved ebp 48 */ /* return address 52 */ #define deflatestate 56 /* the function arguments */ #define curmatch 60 /* All the +zlib1222add offsets are due to the addition of fields * in zlib in the deflate_state structure since the asm code was first written * (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)"). * (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0"). * if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8"). */ #define zlib1222add (8) #define dsWSize (36+zlib1222add) #define dsWMask (44+zlib1222add) #define dsWindow (48+zlib1222add) #define dsPrev (56+zlib1222add) #define dsMatchLen (88+zlib1222add) #define dsPrevMatch (92+zlib1222add) #define dsStrStart (100+zlib1222add) #define dsMatchStart (104+zlib1222add) #define dsLookahead (108+zlib1222add) #define dsPrevLen (112+zlib1222add) #define dsMaxChainLen (116+zlib1222add) #define dsGoodMatch (132+zlib1222add) #define dsNiceMatch (136+zlib1222add) .file "match.S" .globl match_init, longest_match .text /* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */ longest_match: /* Save registers that the compiler may be using, and adjust %esp to */ /* make room for our stack frame. */ pushl %ebp pushl %edi pushl %esi pushl %ebx subl $LocalVarsSize, %esp /* Retrieve the function arguments. %ecx will hold cur_match */ /* throughout the entire function. %edx will hold the pointer to the */ /* deflate_state structure during the function's setup (before */ /* entering the main loop). */ movl deflatestate(%esp), %edx movl curmatch(%esp), %ecx /* uInt wmask = s->w_mask; */ /* unsigned chain_length = s->max_chain_length; */ /* if (s->prev_length >= s->good_match) { */ /* chain_length >>= 2; */ /* } */ movl dsPrevLen(%edx), %eax movl dsGoodMatch(%edx), %ebx cmpl %ebx, %eax movl dsWMask(%edx), %eax movl dsMaxChainLen(%edx), %ebx jl LastMatchGood shrl $2, %ebx LastMatchGood: /* chainlen is decremented once beforehand so that the function can */ /* use the sign flag instead of the zero flag for the exit test. */ /* It is then shifted into the high word, to make room for the wmask */ /* value, which it will always accompany. */ decl %ebx shll $16, %ebx orl %eax, %ebx movl %ebx, chainlenwmask(%esp) /* if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; */ movl dsNiceMatch(%edx), %eax movl dsLookahead(%edx), %ebx cmpl %eax, %ebx jl LookaheadLess movl %eax, %ebx LookaheadLess: movl %ebx, nicematch(%esp) /* register Bytef *scan = s->window + s->strstart; */ movl dsWindow(%edx), %esi movl %esi, window(%esp) movl dsStrStart(%edx), %ebp lea (%esi,%ebp), %edi movl %edi, scan(%esp) /* Determine how many bytes the scan ptr is off from being */ /* dword-aligned. */ movl %edi, %eax negl %eax andl $3, %eax movl %eax, scanalign(%esp) /* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */ /* s->strstart - (IPos)MAX_DIST(s) : NIL; */ movl dsWSize(%edx), %eax subl $MIN_LOOKAHEAD, %eax subl %eax, %ebp jg LimitPositive xorl %ebp, %ebp LimitPositive: /* int best_len = s->prev_length; */ movl dsPrevLen(%edx), %eax movl %eax, bestlen(%esp) /* Store the sum of s->window + best_len in %esi locally, and in %esi. */ addl %eax, %esi movl %esi, windowbestlen(%esp) /* register ush scan_start = *(ushf*)scan; */ /* register ush scan_end = *(ushf*)(scan+best_len-1); */ /* Posf *prev = s->prev; */ movzwl (%edi), %ebx movl %ebx, scanstart(%esp) movzwl -1(%edi,%eax), %ebx movl %ebx, scanend(%esp) movl dsPrev(%edx), %edi /* Jump into the main loop. */ movl chainlenwmask(%esp), %edx jmp LoopEntry .balign 16 /* do { * match = s->window + cur_match; * if (*(ushf*)(match+best_len-1) != scan_end || * *(ushf*)match != scan_start) continue; * [...] * } while ((cur_match = prev[cur_match & wmask]) > limit * && --chain_length != 0); * * Here is the inner loop of the function. The function will spend the * majority of its time in this loop, and majority of that time will * be spent in the first ten instructions. * * Within this loop: * %ebx = scanend * %ecx = curmatch * %edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) * %esi = windowbestlen - i.e., (window + bestlen) * %edi = prev * %ebp = limit */ LookupLoop: andl %edx, %ecx movzwl (%edi,%ecx,2), %ecx cmpl %ebp, %ecx jbe LeaveNow subl $0x00010000, %edx js LeaveNow LoopEntry: movzwl -1(%esi,%ecx), %eax cmpl %ebx, %eax jnz LookupLoop movl window(%esp), %eax movzwl (%eax,%ecx), %eax cmpl scanstart(%esp), %eax jnz LookupLoop /* Store the current value of chainlen. */ movl %edx, chainlenwmask(%esp) /* Point %edi to the string under scrutiny, and %esi to the string we */ /* are hoping to match it up with. In actuality, %esi and %edi are */ /* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */ /* initialized to -(MAX_MATCH_8 - scanalign). */ movl window(%esp), %esi movl scan(%esp), %edi addl %ecx, %esi movl scanalign(%esp), %eax movl $(-MAX_MATCH_8), %edx lea MAX_MATCH_8(%edi,%eax), %edi lea MAX_MATCH_8(%esi,%eax), %esi /* Test the strings for equality, 8 bytes at a time. At the end, * adjust %edx so that it is offset to the exact byte that mismatched. * * We already know at this point that the first three bytes of the * strings match each other, and they can be safely passed over before * starting the compare loop. So what this code does is skip over 0-3 * bytes, as much as necessary in order to dword-align the %edi * pointer. (%esi will still be misaligned three times out of four.) * * It should be confessed that this loop usually does not represent * much of the total running time. Replacing it with a more * straightforward "rep cmpsb" would not drastically degrade * performance. */ LoopCmps: movl (%esi,%edx), %eax xorl (%edi,%edx), %eax jnz LeaveLoopCmps movl 4(%esi,%edx), %eax xorl 4(%edi,%edx), %eax jnz LeaveLoopCmps4 addl $8, %edx jnz LoopCmps jmp LenMaximum LeaveLoopCmps4: addl $4, %edx LeaveLoopCmps: testl $0x0000FFFF, %eax jnz LenLower addl $2, %edx shrl $16, %eax LenLower: subb $1, %al adcl $0, %edx /* Calculate the length of the match. If it is longer than MAX_MATCH, */ /* then automatically accept it as the best possible match and leave. */ lea (%edi,%edx), %eax movl scan(%esp), %edi subl %edi, %eax cmpl $MAX_MATCH, %eax jge LenMaximum /* If the length of the match is not longer than the best match we */ /* have so far, then forget it and return to the lookup loop. */ movl deflatestate(%esp), %edx movl bestlen(%esp), %ebx cmpl %ebx, %eax jg LongerMatch movl windowbestlen(%esp), %esi movl dsPrev(%edx), %edi movl scanend(%esp), %ebx movl chainlenwmask(%esp), %edx jmp LookupLoop /* s->match_start = cur_match; */ /* best_len = len; */ /* if (len >= nice_match) break; */ /* scan_end = *(ushf*)(scan+best_len-1); */ LongerMatch: movl nicematch(%esp), %ebx movl %eax, bestlen(%esp) movl %ecx, dsMatchStart(%edx) cmpl %ebx, %eax jge LeaveNow movl window(%esp), %esi addl %eax, %esi movl %esi, windowbestlen(%esp) movzwl -1(%edi,%eax), %ebx movl dsPrev(%edx), %edi movl %ebx, scanend(%esp) movl chainlenwmask(%esp), %edx jmp LookupLoop /* Accept the current string, with the maximum possible length. */ LenMaximum: movl deflatestate(%esp), %edx movl $MAX_MATCH, bestlen(%esp) movl %ecx, dsMatchStart(%edx) /* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */ /* return s->lookahead; */ LeaveNow: movl deflatestate(%esp), %edx movl bestlen(%esp), %ebx movl dsLookahead(%edx), %eax cmpl %eax, %ebx jg LookaheadRet movl %ebx, %eax LookaheadRet: /* Restore the stack and return from whence we came. */ addl $LocalVarsSize, %esp popl %ebx popl %esi popl %edi popl %ebp match_init: ret sks-ecc-0.93/zlib/contrib/minizip/0000755000175000017500000000000010604550750016020 5ustar nachonachosks-ecc-0.93/zlib/contrib/minizip/unzip.c0000600000175000017500000014021410604550750017323 0ustar nachonacho/* unzip.c -- IO for uncompress .zip files using zlib Version 1.01e, February 12th, 2005 Copyright (C) 1998-2005 Gilles Vollant Read unzip.h for more info */ /* Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of compatibility with older software. The following is from the original crypt.c. Code woven in by Terry Thorsen 1/2003. */ /* Copyright (c) 1990-2000 Info-ZIP. All rights reserved. See the accompanying file LICENSE, version 2000-Apr-09 or later (the contents of which are also included in zip.h) for terms of use. If, for some reason, all these files are missing, the Info-ZIP license also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ /* crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] The encryption/decryption parts of this source code (as opposed to the non-echoing password parts) were originally written in Europe. The whole source package can be freely distributed, including from the USA. (Prior to January 2000, re-export from the US was a violation of US law.) */ /* This encryption code is a direct transcription of the algorithm from Roger Schlafly, described by Phil Katz in the file appnote.txt. This file (appnote.txt) is distributed with the PKZIP program (even in the version without encryption capabilities). */ #include #include #include #include "zlib.h" #include "unzip.h" #ifdef STDC # include # include # include #endif #ifdef NO_ERRNO_H extern int errno; #else # include #endif #ifndef local # define local static #endif /* compile with -Dlocal if your debugger can't find static symbols */ #ifndef CASESENSITIVITYDEFAULT_NO # if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) # define CASESENSITIVITYDEFAULT_NO # endif #endif #ifndef UNZ_BUFSIZE #define UNZ_BUFSIZE (16384) #endif #ifndef UNZ_MAXFILENAMEINZIP #define UNZ_MAXFILENAMEINZIP (256) #endif #ifndef ALLOC # define ALLOC(size) (malloc(size)) #endif #ifndef TRYFREE # define TRYFREE(p) {if (p) free(p);} #endif #define SIZECENTRALDIRITEM (0x2e) #define SIZEZIPLOCALHEADER (0x1e) const char unz_copyright[] = " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"; /* unz_file_info_interntal contain internal info about a file in zipfile*/ typedef struct unz_file_info_internal_s { uLong offset_curfile;/* relative offset of local header 4 bytes */ } unz_file_info_internal; /* file_in_zip_read_info_s contain internal information about a file in zipfile, when reading and decompress it */ typedef struct { char *read_buffer; /* internal buffer for compressed data */ z_stream stream; /* zLib stream structure for inflate */ uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ uLong stream_initialised; /* flag set if stream structure is initialised*/ uLong offset_local_extrafield;/* offset of the local extra field */ uInt size_local_extrafield;/* size of the local extra field */ uLong pos_local_extrafield; /* position in the local extra field in read*/ uLong crc32; /* crc32 of all data uncompressed */ uLong crc32_wait; /* crc32 we must obtain after decompress all */ uLong rest_read_compressed; /* number of byte to be decompressed */ uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ zlib_filefunc_def z_filefunc; voidpf filestream; /* io structore of the zipfile */ uLong compression_method; /* compression method (0==store) */ uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ int raw; } file_in_zip_read_info_s; /* unz_s contain internal information about the zipfile */ typedef struct { zlib_filefunc_def z_filefunc; voidpf filestream; /* io structore of the zipfile */ unz_global_info gi; /* public global information */ uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ uLong num_file; /* number of the current file in the zipfile*/ uLong pos_in_central_dir; /* pos of the current file in the central dir*/ uLong current_file_ok; /* flag about the usability of the current file*/ uLong central_pos; /* position of the beginning of the central dir*/ uLong size_central_dir; /* size of the central directory */ uLong offset_central_dir; /* offset of start of central directory with respect to the starting disk number */ unz_file_info cur_file_info; /* public info about the current file in zip*/ unz_file_info_internal cur_file_info_internal; /* private info about it*/ file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current file if we are decompressing it */ int encrypted; # ifndef NOUNCRYPT unsigned long keys[3]; /* keys defining the pseudo-random sequence */ const unsigned long* pcrc_32_tab; # endif } unz_s; #ifndef NOUNCRYPT #include "crypt.h" #endif /* =========================================================================== Read a byte from a gz_stream; update next_in and avail_in. Return EOF for end of file. IN assertion: the stream s has been sucessfully opened for reading. */ local int unzlocal_getByte OF(( const zlib_filefunc_def* pzlib_filefunc_def, voidpf filestream, int *pi)); local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi) const zlib_filefunc_def* pzlib_filefunc_def; voidpf filestream; int *pi; { unsigned char c; int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1); if (err==1) { *pi = (int)c; return UNZ_OK; } else { if (ZERROR(*pzlib_filefunc_def,filestream)) return UNZ_ERRNO; else return UNZ_EOF; } } /* =========================================================================== Reads a long in LSB order from the given gz_stream. Sets */ local int unzlocal_getShort OF(( const zlib_filefunc_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX) const zlib_filefunc_def* pzlib_filefunc_def; voidpf filestream; uLong *pX; { uLong x ; int i; int err; err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); x = (uLong)i; if (err==UNZ_OK) err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); x += ((uLong)i)<<8; if (err==UNZ_OK) *pX = x; else *pX = 0; return err; } local int unzlocal_getLong OF(( const zlib_filefunc_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX) const zlib_filefunc_def* pzlib_filefunc_def; voidpf filestream; uLong *pX; { uLong x ; int i; int err; err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); x = (uLong)i; if (err==UNZ_OK) err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); x += ((uLong)i)<<8; if (err==UNZ_OK) err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); x += ((uLong)i)<<16; if (err==UNZ_OK) err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); x += ((uLong)i)<<24; if (err==UNZ_OK) *pX = x; else *pX = 0; return err; } /* My own strcmpi / strcasecmp */ local int strcmpcasenosensitive_internal (fileName1,fileName2) const char* fileName1; const char* fileName2; { for (;;) { char c1=*(fileName1++); char c2=*(fileName2++); if ((c1>='a') && (c1<='z')) c1 -= 0x20; if ((c2>='a') && (c2<='z')) c2 -= 0x20; if (c1=='\0') return ((c2=='\0') ? 0 : -1); if (c2=='\0') return 1; if (c1c2) return 1; } } #ifdef CASESENSITIVITYDEFAULT_NO #define CASESENSITIVITYDEFAULTVALUE 2 #else #define CASESENSITIVITYDEFAULTVALUE 1 #endif #ifndef STRCMPCASENOSENTIVEFUNCTION #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal #endif /* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi or strcasecmp) If iCaseSenisivity = 0, case sensitivity is defaut of your operating system (like 1 on Unix, 2 on Windows) */ extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) const char* fileName1; const char* fileName2; int iCaseSensitivity; { if (iCaseSensitivity==0) iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; if (iCaseSensitivity==1) return strcmp(fileName1,fileName2); return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); } #ifndef BUFREADCOMMENT #define BUFREADCOMMENT (0x400) #endif /* Locate the Central directory of a zipfile (at the end, just before the global comment) */ local uLong unzlocal_SearchCentralDir OF(( const zlib_filefunc_def* pzlib_filefunc_def, voidpf filestream)); local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream) const zlib_filefunc_def* pzlib_filefunc_def; voidpf filestream; { unsigned char* buf; uLong uSizeFile; uLong uBackRead; uLong uMaxBack=0xffff; /* maximum size of global comment */ uLong uPosFound=0; if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) return 0; uSizeFile = ZTELL(*pzlib_filefunc_def,filestream); if (uMaxBack>uSizeFile) uMaxBack = uSizeFile; buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); if (buf==NULL) return 0; uBackRead = 4; while (uBackReaduMaxBack) uBackRead = uMaxBack; else uBackRead+=BUFREADCOMMENT; uReadPos = uSizeFile-uBackRead ; uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) break; if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) break; for (i=(int)uReadSize-3; (i--)>0;) if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) { uPosFound = uReadPos+i; break; } if (uPosFound!=0) break; } TRYFREE(buf); return uPosFound; } /* Open a Zip file. path contain the full pathname (by example, on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer "zlib/zlib114.zip". If the zipfile cannot be opened (file doesn't exist or in not valid), the return value is NULL. Else, the return value is a unzFile Handle, usable with other function of this unzip package. */ extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def) const char *path; zlib_filefunc_def* pzlib_filefunc_def; { unz_s us; unz_s *s; uLong central_pos,uL; uLong number_disk; /* number of the current dist, used for spaning ZIP, unsupported, always 0*/ uLong number_disk_with_CD; /* number the the disk with central dir, used for spaning ZIP, unsupported, always 0*/ uLong number_entry_CD; /* total number of entries in the central dir (same than number_entry on nospan) */ int err=UNZ_OK; if (unz_copyright[0]!=' ') return NULL; if (pzlib_filefunc_def==NULL) fill_fopen_filefunc(&us.z_filefunc); else us.z_filefunc = *pzlib_filefunc_def; us.filestream= (*(us.z_filefunc.zopen_file))(us.z_filefunc.opaque, path, ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_EXISTING); if (us.filestream==NULL) return NULL; central_pos = unzlocal_SearchCentralDir(&us.z_filefunc,us.filestream); if (central_pos==0) err=UNZ_ERRNO; if (ZSEEK(us.z_filefunc, us.filestream, central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) err=UNZ_ERRNO; /* the signature, already checked */ if (unzlocal_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) err=UNZ_ERRNO; /* number of this disk */ if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) err=UNZ_ERRNO; /* number of the disk with the start of the central directory */ if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) err=UNZ_ERRNO; /* total number of entries in the central dir on this disk */ if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK) err=UNZ_ERRNO; /* total number of entries in the central dir */ if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK) err=UNZ_ERRNO; if ((number_entry_CD!=us.gi.number_entry) || (number_disk_with_CD!=0) || (number_disk!=0)) err=UNZ_BADZIPFILE; /* size of the central directory */ if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK) err=UNZ_ERRNO; /* offset of start of central directory with respect to the starting disk number */ if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK) err=UNZ_ERRNO; /* zipfile comment length */ if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK) err=UNZ_ERRNO; if ((central_pospfile_in_zip_read!=NULL) unzCloseCurrentFile(file); ZCLOSE(s->z_filefunc, s->filestream); TRYFREE(s); return UNZ_OK; } /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) unzFile file; unz_global_info *pglobal_info; { unz_s* s; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; *pglobal_info=s->gi; return UNZ_OK; } /* Translate date/time from Dos format to tm_unz (readable more easilty) */ local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) uLong ulDosDate; tm_unz* ptm; { uLong uDate; uDate = (uLong)(ulDosDate>>16); ptm->tm_mday = (uInt)(uDate&0x1f) ; ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; } /* Get Info about the current file in the zipfile, with internal only info */ local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, unz_file_info *pfile_info, unz_file_info_internal *pfile_info_internal, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)); local int unzlocal_GetCurrentFileInfoInternal (file, pfile_info, pfile_info_internal, szFileName, fileNameBufferSize, extraField, extraFieldBufferSize, szComment, commentBufferSize) unzFile file; unz_file_info *pfile_info; unz_file_info_internal *pfile_info_internal; char *szFileName; uLong fileNameBufferSize; void *extraField; uLong extraFieldBufferSize; char *szComment; uLong commentBufferSize; { unz_s* s; unz_file_info file_info; unz_file_info_internal file_info_internal; int err=UNZ_OK; uLong uMagic; long lSeek=0; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; if (ZSEEK(s->z_filefunc, s->filestream, s->pos_in_central_dir+s->byte_before_the_zipfile, ZLIB_FILEFUNC_SEEK_SET)!=0) err=UNZ_ERRNO; /* we check the magic */ if (err==UNZ_OK) if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) err=UNZ_ERRNO; else if (uMagic!=0x02014b50) err=UNZ_BADZIPFILE; if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK) err=UNZ_ERRNO; unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) err=UNZ_ERRNO; lSeek+=file_info.size_filename; if ((err==UNZ_OK) && (szFileName!=NULL)) { uLong uSizeRead ; if (file_info.size_filename0) && (fileNameBufferSize>0)) if (ZREAD(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead) err=UNZ_ERRNO; lSeek -= uSizeRead; } if ((err==UNZ_OK) && (extraField!=NULL)) { uLong uSizeRead ; if (file_info.size_file_extraz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead) err=UNZ_ERRNO; lSeek += file_info.size_file_extra - uSizeRead; } else lSeek+=file_info.size_file_extra; if ((err==UNZ_OK) && (szComment!=NULL)) { uLong uSizeRead ; if (file_info.size_file_commentz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; if ((file_info.size_file_comment>0) && (commentBufferSize>0)) if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) err=UNZ_ERRNO; lSeek+=file_info.size_file_comment - uSizeRead; } else lSeek+=file_info.size_file_comment; if ((err==UNZ_OK) && (pfile_info!=NULL)) *pfile_info=file_info; if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) *pfile_info_internal=file_info_internal; return err; } /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetCurrentFileInfo (file, pfile_info, szFileName, fileNameBufferSize, extraField, extraFieldBufferSize, szComment, commentBufferSize) unzFile file; unz_file_info *pfile_info; char *szFileName; uLong fileNameBufferSize; void *extraField; uLong extraFieldBufferSize; char *szComment; uLong commentBufferSize; { return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, szFileName,fileNameBufferSize, extraField,extraFieldBufferSize, szComment,commentBufferSize); } /* Set the current file of the zipfile to the first file. return UNZ_OK if there is no problem */ extern int ZEXPORT unzGoToFirstFile (file) unzFile file; { int err=UNZ_OK; unz_s* s; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; s->pos_in_central_dir=s->offset_central_dir; s->num_file=0; err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, &s->cur_file_info_internal, NULL,0,NULL,0,NULL,0); s->current_file_ok = (err == UNZ_OK); return err; } /* Set the current file of the zipfile to the next file. return UNZ_OK if there is no problem return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ extern int ZEXPORT unzGoToNextFile (file) unzFile file; { unz_s* s; int err; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; if (!s->current_file_ok) return UNZ_END_OF_LIST_OF_FILE; if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */ if (s->num_file+1==s->gi.number_entry) return UNZ_END_OF_LIST_OF_FILE; s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; s->num_file++; err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, &s->cur_file_info_internal, NULL,0,NULL,0,NULL,0); s->current_file_ok = (err == UNZ_OK); return err; } /* Try locate the file szFileName in the zipfile. For the iCaseSensitivity signification, see unzipStringFileNameCompare return value : UNZ_OK if the file is found. It becomes the current file. UNZ_END_OF_LIST_OF_FILE if the file is not found */ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) unzFile file; const char *szFileName; int iCaseSensitivity; { unz_s* s; int err; /* We remember the 'current' position in the file so that we can jump * back there if we fail. */ unz_file_info cur_file_infoSaved; unz_file_info_internal cur_file_info_internalSaved; uLong num_fileSaved; uLong pos_in_central_dirSaved; if (file==NULL) return UNZ_PARAMERROR; if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) return UNZ_PARAMERROR; s=(unz_s*)file; if (!s->current_file_ok) return UNZ_END_OF_LIST_OF_FILE; /* Save the current state */ num_fileSaved = s->num_file; pos_in_central_dirSaved = s->pos_in_central_dir; cur_file_infoSaved = s->cur_file_info; cur_file_info_internalSaved = s->cur_file_info_internal; err = unzGoToFirstFile(file); while (err == UNZ_OK) { char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; err = unzGetCurrentFileInfo(file,NULL, szCurrentFileName,sizeof(szCurrentFileName)-1, NULL,0,NULL,0); if (err == UNZ_OK) { if (unzStringFileNameCompare(szCurrentFileName, szFileName,iCaseSensitivity)==0) return UNZ_OK; err = unzGoToNextFile(file); } } /* We failed, so restore the state of the 'current file' to where we * were. */ s->num_file = num_fileSaved ; s->pos_in_central_dir = pos_in_central_dirSaved ; s->cur_file_info = cur_file_infoSaved; s->cur_file_info_internal = cur_file_info_internalSaved; return err; } /* /////////////////////////////////////////// // Contributed by Ryan Haksi (mailto://cryogen@infoserve.net) // I need random access // // Further optimization could be realized by adding an ability // to cache the directory in memory. The goal being a single // comprehensive file read to put the file I need in a memory. */ /* typedef struct unz_file_pos_s { uLong pos_in_zip_directory; // offset in file uLong num_of_file; // # of file } unz_file_pos; */ extern int ZEXPORT unzGetFilePos(file, file_pos) unzFile file; unz_file_pos* file_pos; { unz_s* s; if (file==NULL || file_pos==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; if (!s->current_file_ok) return UNZ_END_OF_LIST_OF_FILE; file_pos->pos_in_zip_directory = s->pos_in_central_dir; file_pos->num_of_file = s->num_file; return UNZ_OK; } extern int ZEXPORT unzGoToFilePos(file, file_pos) unzFile file; unz_file_pos* file_pos; { unz_s* s; int err; if (file==NULL || file_pos==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; /* jump to the right spot */ s->pos_in_central_dir = file_pos->pos_in_zip_directory; s->num_file = file_pos->num_of_file; /* set the current file */ err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, &s->cur_file_info_internal, NULL,0,NULL,0,NULL,0); /* return results */ s->current_file_ok = (err == UNZ_OK); return err; } /* // Unzip Helper Functions - should be here? /////////////////////////////////////////// */ /* Read the local header of the current zipfile Check the coherency of the local header and info in the end of central directory about this file store in *piSizeVar the size of extra info in local header (filename and size of extra field data) */ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, poffset_local_extrafield, psize_local_extrafield) unz_s* s; uInt* piSizeVar; uLong *poffset_local_extrafield; uInt *psize_local_extrafield; { uLong uMagic,uData,uFlags; uLong size_filename; uLong size_extra_field; int err=UNZ_OK; *piSizeVar = 0; *poffset_local_extrafield = 0; *psize_local_extrafield = 0; if (ZSEEK(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile + s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) return UNZ_ERRNO; if (err==UNZ_OK) if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) err=UNZ_ERRNO; else if (uMagic!=0x04034b50) err=UNZ_BADZIPFILE; if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) err=UNZ_ERRNO; /* else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) err=UNZ_BADZIPFILE; */ if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) err=UNZ_BADZIPFILE; if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && (s->cur_file_info.compression_method!=Z_DEFLATED)) err=UNZ_BADZIPFILE; if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */ err=UNZ_ERRNO; if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */ err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */ err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */ err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK) err=UNZ_ERRNO; else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) err=UNZ_BADZIPFILE; *piSizeVar += (uInt)size_filename; if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK) err=UNZ_ERRNO; *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + size_filename; *psize_local_extrafield = (uInt)size_extra_field; *piSizeVar += (uInt)size_extra_field; return err; } /* Open for reading data the current file in the zipfile. If there is no error and the file is opened, the return value is UNZ_OK. */ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) unzFile file; int* method; int* level; int raw; const char* password; { int err=UNZ_OK; uInt iSizeVar; unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; uLong offset_local_extrafield; /* offset of the local extra field */ uInt size_local_extrafield; /* size of the local extra field */ # ifndef NOUNCRYPT char source[12]; # else if (password != NULL) return UNZ_PARAMERROR; # endif if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; if (!s->current_file_ok) return UNZ_PARAMERROR; if (s->pfile_in_zip_read != NULL) unzCloseCurrentFile(file); if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) return UNZ_BADZIPFILE; pfile_in_zip_read_info = (file_in_zip_read_info_s*) ALLOC(sizeof(file_in_zip_read_info_s)); if (pfile_in_zip_read_info==NULL) return UNZ_INTERNALERROR; pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; pfile_in_zip_read_info->pos_local_extrafield=0; pfile_in_zip_read_info->raw=raw; if (pfile_in_zip_read_info->read_buffer==NULL) { TRYFREE(pfile_in_zip_read_info); return UNZ_INTERNALERROR; } pfile_in_zip_read_info->stream_initialised=0; if (method!=NULL) *method = (int)s->cur_file_info.compression_method; if (level!=NULL) { *level = 6; switch (s->cur_file_info.flag & 0x06) { case 6 : *level = 1; break; case 4 : *level = 2; break; case 2 : *level = 9; break; } } if ((s->cur_file_info.compression_method!=0) && (s->cur_file_info.compression_method!=Z_DEFLATED)) err=UNZ_BADZIPFILE; pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; pfile_in_zip_read_info->crc32=0; pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method; pfile_in_zip_read_info->filestream=s->filestream; pfile_in_zip_read_info->z_filefunc=s->z_filefunc; pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; pfile_in_zip_read_info->stream.total_out = 0; if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw)) { pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; pfile_in_zip_read_info->stream.zfree = (free_func)0; pfile_in_zip_read_info->stream.opaque = (voidpf)0; pfile_in_zip_read_info->stream.next_in = (voidpf)0; pfile_in_zip_read_info->stream.avail_in = 0; err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); if (err == Z_OK) pfile_in_zip_read_info->stream_initialised=1; else { TRYFREE(pfile_in_zip_read_info); return err; } /* windowBits is passed < 0 to tell that there is no zlib header. * Note that in this case inflate *requires* an extra "dummy" byte * after the compressed stream in order to complete decompression and * return Z_STREAM_END. * In unzip, i don't wait absolutely Z_STREAM_END because I known the * size of both compressed and uncompressed data */ } pfile_in_zip_read_info->rest_read_compressed = s->cur_file_info.compressed_size ; pfile_in_zip_read_info->rest_read_uncompressed = s->cur_file_info.uncompressed_size ; pfile_in_zip_read_info->pos_in_zipfile = s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + iSizeVar; pfile_in_zip_read_info->stream.avail_in = (uInt)0; s->pfile_in_zip_read = pfile_in_zip_read_info; # ifndef NOUNCRYPT if (password != NULL) { int i; s->pcrc_32_tab = get_crc_table(); init_keys(password,s->keys,s->pcrc_32_tab); if (ZSEEK(s->z_filefunc, s->filestream, s->pfile_in_zip_read->pos_in_zipfile + s->pfile_in_zip_read->byte_before_the_zipfile, SEEK_SET)!=0) return UNZ_INTERNALERROR; if(ZREAD(s->z_filefunc, s->filestream,source, 12)<12) return UNZ_INTERNALERROR; for (i = 0; i<12; i++) zdecode(s->keys,s->pcrc_32_tab,source[i]); s->pfile_in_zip_read->pos_in_zipfile+=12; s->encrypted=1; } # endif return UNZ_OK; } extern int ZEXPORT unzOpenCurrentFile (file) unzFile file; { return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); } extern int ZEXPORT unzOpenCurrentFilePassword (file, password) unzFile file; const char* password; { return unzOpenCurrentFile3(file, NULL, NULL, 0, password); } extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw) unzFile file; int* method; int* level; int raw; { return unzOpenCurrentFile3(file, method, level, raw, NULL); } /* Read bytes from the current file. buf contain buffer where data must be copied len the size of buf. return the number of byte copied if somes bytes are copied return 0 if the end of file was reached return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ extern int ZEXPORT unzReadCurrentFile (file, buf, len) unzFile file; voidp buf; unsigned len; { int err=UNZ_OK; uInt iRead = 0; unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; if ((pfile_in_zip_read_info->read_buffer == NULL)) return UNZ_END_OF_LIST_OF_FILE; if (len==0) return 0; pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; pfile_in_zip_read_info->stream.avail_out = (uInt)len; if ((len>pfile_in_zip_read_info->rest_read_uncompressed) && (!(pfile_in_zip_read_info->raw))) pfile_in_zip_read_info->stream.avail_out = (uInt)pfile_in_zip_read_info->rest_read_uncompressed; if ((len>pfile_in_zip_read_info->rest_read_compressed+ pfile_in_zip_read_info->stream.avail_in) && (pfile_in_zip_read_info->raw)) pfile_in_zip_read_info->stream.avail_out = (uInt)pfile_in_zip_read_info->rest_read_compressed+ pfile_in_zip_read_info->stream.avail_in; while (pfile_in_zip_read_info->stream.avail_out>0) { if ((pfile_in_zip_read_info->stream.avail_in==0) && (pfile_in_zip_read_info->rest_read_compressed>0)) { uInt uReadThis = UNZ_BUFSIZE; if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed; if (uReadThis == 0) return UNZ_EOF; if (ZSEEK(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream, pfile_in_zip_read_info->pos_in_zipfile + pfile_in_zip_read_info->byte_before_the_zipfile, ZLIB_FILEFUNC_SEEK_SET)!=0) return UNZ_ERRNO; if (ZREAD(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream, pfile_in_zip_read_info->read_buffer, uReadThis)!=uReadThis) return UNZ_ERRNO; # ifndef NOUNCRYPT if(s->encrypted) { uInt i; for(i=0;iread_buffer[i] = zdecode(s->keys,s->pcrc_32_tab, pfile_in_zip_read_info->read_buffer[i]); } # endif pfile_in_zip_read_info->pos_in_zipfile += uReadThis; pfile_in_zip_read_info->rest_read_compressed-=uReadThis; pfile_in_zip_read_info->stream.next_in = (Bytef*)pfile_in_zip_read_info->read_buffer; pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; } if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) { uInt uDoCopy,i ; if ((pfile_in_zip_read_info->stream.avail_in == 0) && (pfile_in_zip_read_info->rest_read_compressed == 0)) return (iRead==0) ? UNZ_EOF : iRead; if (pfile_in_zip_read_info->stream.avail_out < pfile_in_zip_read_info->stream.avail_in) uDoCopy = pfile_in_zip_read_info->stream.avail_out ; else uDoCopy = pfile_in_zip_read_info->stream.avail_in ; for (i=0;istream.next_out+i) = *(pfile_in_zip_read_info->stream.next_in+i); pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, pfile_in_zip_read_info->stream.next_out, uDoCopy); pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; pfile_in_zip_read_info->stream.avail_in -= uDoCopy; pfile_in_zip_read_info->stream.avail_out -= uDoCopy; pfile_in_zip_read_info->stream.next_out += uDoCopy; pfile_in_zip_read_info->stream.next_in += uDoCopy; pfile_in_zip_read_info->stream.total_out += uDoCopy; iRead += uDoCopy; } else { uLong uTotalOutBefore,uTotalOutAfter; const Bytef *bufBefore; uLong uOutThis; int flush=Z_SYNC_FLUSH; uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; bufBefore = pfile_in_zip_read_info->stream.next_out; /* if ((pfile_in_zip_read_info->rest_read_uncompressed == pfile_in_zip_read_info->stream.avail_out) && (pfile_in_zip_read_info->rest_read_compressed == 0)) flush = Z_FINISH; */ err=inflate(&pfile_in_zip_read_info->stream,flush); if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL)) err = Z_DATA_ERROR; uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; uOutThis = uTotalOutAfter-uTotalOutBefore; pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis)); pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis; iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); if (err==Z_STREAM_END) return (iRead==0) ? UNZ_EOF : iRead; if (err!=Z_OK) break; } } if (err==Z_OK) return iRead; return err; } /* Give the current position in uncompressed data */ extern z_off_t ZEXPORT unztell (file) unzFile file; { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; return (z_off_t)pfile_in_zip_read_info->stream.total_out; } /* return 1 if the end of file was reached, 0 elsewhere */ extern int ZEXPORT unzeof (file) unzFile file; { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; if (pfile_in_zip_read_info->rest_read_uncompressed == 0) return 1; else return 0; } /* Read extra field from the current file (opened by unzOpenCurrentFile) This is the local-header version of the extra field (sometimes, there is more info in the local-header version than in the central-header) if buf==NULL, it return the size of the local extra field that can be read if buf!=NULL, len is the size of the buffer, the extra header is copied in buf. the return value is the number of bytes copied in buf, or (if <0) the error code */ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) unzFile file; voidp buf; unsigned len; { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; uInt read_now; uLong size_to_read; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; size_to_read = (pfile_in_zip_read_info->size_local_extrafield - pfile_in_zip_read_info->pos_local_extrafield); if (buf==NULL) return (int)size_to_read; if (len>size_to_read) read_now = (uInt)size_to_read; else read_now = (uInt)len ; if (read_now==0) return 0; if (ZSEEK(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream, pfile_in_zip_read_info->offset_local_extrafield + pfile_in_zip_read_info->pos_local_extrafield, ZLIB_FILEFUNC_SEEK_SET)!=0) return UNZ_ERRNO; if (ZREAD(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream, buf,read_now)!=read_now) return UNZ_ERRNO; return (int)read_now; } /* Close the file in zip opened with unzipOpenCurrentFile Return UNZ_CRCERROR if all the file was read but the CRC is not good */ extern int ZEXPORT unzCloseCurrentFile (file) unzFile file; { int err=UNZ_OK; unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) && (!pfile_in_zip_read_info->raw)) { if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) err=UNZ_CRCERROR; } TRYFREE(pfile_in_zip_read_info->read_buffer); pfile_in_zip_read_info->read_buffer = NULL; if (pfile_in_zip_read_info->stream_initialised) inflateEnd(&pfile_in_zip_read_info->stream); pfile_in_zip_read_info->stream_initialised = 0; TRYFREE(pfile_in_zip_read_info); s->pfile_in_zip_read=NULL; return err; } /* Get the global comment string of the ZipFile, in the szComment buffer. uSizeBuf is the size of the szComment buffer. return the number of byte copied or an error code <0 */ extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) unzFile file; char *szComment; uLong uSizeBuf; { int err=UNZ_OK; unz_s* s; uLong uReadThis ; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; uReadThis = uSizeBuf; if (uReadThis>s->gi.size_comment) uReadThis = s->gi.size_comment; if (ZSEEK(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0) return UNZ_ERRNO; if (uReadThis>0) { *szComment='\0'; if (ZREAD(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis) return UNZ_ERRNO; } if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) *(szComment+s->gi.size_comment)='\0'; return (int)uReadThis; } /* Additions by RX '2004 */ extern uLong ZEXPORT unzGetOffset (file) unzFile file; { unz_s* s; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; if (!s->current_file_ok) return 0; if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff) if (s->num_file==s->gi.number_entry) return 0; return s->pos_in_central_dir; } extern int ZEXPORT unzSetOffset (file, pos) unzFile file; uLong pos; { unz_s* s; int err; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; s->pos_in_central_dir = pos; s->num_file = s->gi.number_entry; /* hack */ err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, &s->cur_file_info_internal, NULL,0,NULL,0,NULL,0); s->current_file_ok = (err == UNZ_OK); return err; } sks-ecc-0.93/zlib/contrib/minizip/ioapi.c0000600000175000017500000000715610604550750017266 0ustar nachonacho/* ioapi.c -- IO base function header for compress/uncompress .zip files using zlib + zip or unzip API Version 1.01e, February 12th, 2005 Copyright (C) 1998-2005 Gilles Vollant */ #include #include #include #include "zlib.h" #include "ioapi.h" /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ #ifndef SEEK_CUR #define SEEK_CUR 1 #endif #ifndef SEEK_END #define SEEK_END 2 #endif #ifndef SEEK_SET #define SEEK_SET 0 #endif voidpf ZCALLBACK fopen_file_func OF(( voidpf opaque, const char* filename, int mode)); uLong ZCALLBACK fread_file_func OF(( voidpf opaque, voidpf stream, void* buf, uLong size)); uLong ZCALLBACK fwrite_file_func OF(( voidpf opaque, voidpf stream, const void* buf, uLong size)); long ZCALLBACK ftell_file_func OF(( voidpf opaque, voidpf stream)); long ZCALLBACK fseek_file_func OF(( voidpf opaque, voidpf stream, uLong offset, int origin)); int ZCALLBACK fclose_file_func OF(( voidpf opaque, voidpf stream)); int ZCALLBACK ferror_file_func OF(( voidpf opaque, voidpf stream)); voidpf ZCALLBACK fopen_file_func (opaque, filename, mode) voidpf opaque; const char* filename; int mode; { FILE* file = NULL; const char* mode_fopen = NULL; if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) mode_fopen = "rb"; else if (mode & ZLIB_FILEFUNC_MODE_EXISTING) mode_fopen = "r+b"; else if (mode & ZLIB_FILEFUNC_MODE_CREATE) mode_fopen = "wb"; if ((filename!=NULL) && (mode_fopen != NULL)) file = fopen(filename, mode_fopen); return file; } uLong ZCALLBACK fread_file_func (opaque, stream, buf, size) voidpf opaque; voidpf stream; void* buf; uLong size; { uLong ret; ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); return ret; } uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size) voidpf opaque; voidpf stream; const void* buf; uLong size; { uLong ret; ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); return ret; } long ZCALLBACK ftell_file_func (opaque, stream) voidpf opaque; voidpf stream; { long ret; ret = ftell((FILE *)stream); return ret; } long ZCALLBACK fseek_file_func (opaque, stream, offset, origin) voidpf opaque; voidpf stream; uLong offset; int origin; { int fseek_origin=0; long ret; switch (origin) { case ZLIB_FILEFUNC_SEEK_CUR : fseek_origin = SEEK_CUR; break; case ZLIB_FILEFUNC_SEEK_END : fseek_origin = SEEK_END; break; case ZLIB_FILEFUNC_SEEK_SET : fseek_origin = SEEK_SET; break; default: return -1; } ret = 0; fseek((FILE *)stream, offset, fseek_origin); return ret; } int ZCALLBACK fclose_file_func (opaque, stream) voidpf opaque; voidpf stream; { int ret; ret = fclose((FILE *)stream); return ret; } int ZCALLBACK ferror_file_func (opaque, stream) voidpf opaque; voidpf stream; { int ret; ret = ferror((FILE *)stream); return ret; } void fill_fopen_filefunc (pzlib_filefunc_def) zlib_filefunc_def* pzlib_filefunc_def; { pzlib_filefunc_def->zopen_file = fopen_file_func; pzlib_filefunc_def->zread_file = fread_file_func; pzlib_filefunc_def->zwrite_file = fwrite_file_func; pzlib_filefunc_def->ztell_file = ftell_file_func; pzlib_filefunc_def->zseek_file = fseek_file_func; pzlib_filefunc_def->zclose_file = fclose_file_func; pzlib_filefunc_def->zerror_file = ferror_file_func; pzlib_filefunc_def->opaque = NULL; } sks-ecc-0.93/zlib/contrib/minizip/ChangeLogUnzip0000600000175000017500000000400710604550750020611 0ustar nachonachoChange in 1.01e (12 feb 05) - Fix in zipOpen2 for globalcomment (Rolf Kalbermatter) - Fix possible memory leak in unzip.c (Zoran Stevanovic) Change in 1.01b (20 may 04) - Integrate patch from Debian package (submited by Mark Brown) - Add tools mztools from Xavier Roche Change in 1.01 (8 may 04) - fix buffer overrun risk in unzip.c (Xavier Roche) - fix a minor buffer insecurity in minizip.c (Mike Whittaker) Change in 1.00: (10 sept 03) - rename to 1.00 - cosmetic code change Change in 0.22: (19 May 03) - crypting support (unless you define NOCRYPT) - append file in existing zipfile Change in 0.21: (10 Mar 03) - bug fixes Change in 0.17: (27 Jan 02) - bug fixes Change in 0.16: (19 Jan 02) - Support of ioapi for virtualize zip file access Change in 0.15: (19 Mar 98) - fix memory leak in minizip.c Change in 0.14: (10 Mar 98) - fix bugs in minizip.c sample for zipping big file - fix problem in month in date handling - fix bug in unzlocal_GetCurrentFileInfoInternal in unzip.c for comment handling Change in 0.13: (6 Mar 98) - fix bugs in zip.c - add real minizip sample Change in 0.12: (4 Mar 98) - add zip.c and zip.h for creates .zip file - fix change_file_date in miniunz.c for Unix (Jean-loup Gailly) - fix miniunz.c for file without specific record for directory Change in 0.11: (3 Mar 98) - fix bug in unzGetCurrentFileInfo for get extra field and comment - enhance miniunz sample, remove the bad unztst.c sample Change in 0.10: (2 Mar 98) - fix bug in unzReadCurrentFile - rename unzip* to unz* function and structure - remove Windows-like hungary notation variable name - modify some structure in unzip.h - add somes comment in source - remove unzipGetcCurrentFile function - replace ZUNZEXPORT by ZEXPORT - add unzGetLocalExtrafield for get the local extrafield info - add a new sample, miniunz.c Change in 0.4: (25 Feb 98) - suppress the type unzipFileInZip. Only on file in the zipfile can be open at the same time - fix somes typo in code - added tm_unz structure in unzip_file_info (date/time in readable format) sks-ecc-0.93/zlib/contrib/minizip/zip.c0000600000175000017500000011075110604550750016763 0ustar nachonacho/* zip.c -- IO on .zip files using zlib Version 1.01e, February 12th, 2005 27 Dec 2004 Rolf Kalbermatter Modification to zipOpen2 to support globalComment retrieval. Copyright (C) 1998-2005 Gilles Vollant Read zip.h for more info */ #include #include #include #include #include "zlib.h" #include "zip.h" #ifdef STDC # include # include # include #endif #ifdef NO_ERRNO_H extern int errno; #else # include #endif #ifndef local # define local static #endif /* compile with -Dlocal if your debugger can't find static symbols */ #ifndef VERSIONMADEBY # define VERSIONMADEBY (0x0) /* platform depedent */ #endif #ifndef Z_BUFSIZE #define Z_BUFSIZE (16384) #endif #ifndef Z_MAXFILENAMEINZIP #define Z_MAXFILENAMEINZIP (256) #endif #ifndef ALLOC # define ALLOC(size) (malloc(size)) #endif #ifndef TRYFREE # define TRYFREE(p) {if (p) free(p);} #endif /* #define SIZECENTRALDIRITEM (0x2e) #define SIZEZIPLOCALHEADER (0x1e) */ /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ #ifndef SEEK_CUR #define SEEK_CUR 1 #endif #ifndef SEEK_END #define SEEK_END 2 #endif #ifndef SEEK_SET #define SEEK_SET 0 #endif #ifndef DEF_MEM_LEVEL #if MAX_MEM_LEVEL >= 8 # define DEF_MEM_LEVEL 8 #else # define DEF_MEM_LEVEL MAX_MEM_LEVEL #endif #endif const char zip_copyright[] = " zip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"; #define SIZEDATA_INDATABLOCK (4096-(4*4)) #define LOCALHEADERMAGIC (0x04034b50) #define CENTRALHEADERMAGIC (0x02014b50) #define ENDHEADERMAGIC (0x06054b50) #define FLAG_LOCALHEADER_OFFSET (0x06) #define CRC_LOCALHEADER_OFFSET (0x0e) #define SIZECENTRALHEADER (0x2e) /* 46 */ typedef struct linkedlist_datablock_internal_s { struct linkedlist_datablock_internal_s* next_datablock; uLong avail_in_this_block; uLong filled_in_this_block; uLong unused; /* for future use and alignement */ unsigned char data[SIZEDATA_INDATABLOCK]; } linkedlist_datablock_internal; typedef struct linkedlist_data_s { linkedlist_datablock_internal* first_block; linkedlist_datablock_internal* last_block; } linkedlist_data; typedef struct { z_stream stream; /* zLib stream structure for inflate */ int stream_initialised; /* 1 is stream is initialised */ uInt pos_in_buffered_data; /* last written byte in buffered_data */ uLong pos_local_header; /* offset of the local header of the file currenty writing */ char* central_header; /* central header data for the current file */ uLong size_centralheader; /* size of the central header for cur file */ uLong flag; /* flag of the file currently writing */ int method; /* compression method of file currenty wr.*/ int raw; /* 1 for directly writing raw data */ Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ uLong dosDate; uLong crc32; int encrypt; #ifndef NOCRYPT unsigned long keys[3]; /* keys defining the pseudo-random sequence */ const unsigned long* pcrc_32_tab; int crypt_header_size; #endif } curfile_info; typedef struct { zlib_filefunc_def z_filefunc; voidpf filestream; /* io structore of the zipfile */ linkedlist_data central_dir;/* datablock with central dir in construction*/ int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ curfile_info ci; /* info on the file curretly writing */ uLong begin_pos; /* position of the beginning of the zipfile */ uLong add_position_when_writting_offset; uLong number_entry; #ifndef NO_ADDFILEINEXISTINGZIP char *globalcomment; #endif } zip_internal; #ifndef NOCRYPT #define INCLUDECRYPTINGCODE_IFCRYPTALLOWED #include "crypt.h" #endif local linkedlist_datablock_internal* allocate_new_datablock() { linkedlist_datablock_internal* ldi; ldi = (linkedlist_datablock_internal*) ALLOC(sizeof(linkedlist_datablock_internal)); if (ldi!=NULL) { ldi->next_datablock = NULL ; ldi->filled_in_this_block = 0 ; ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ; } return ldi; } local void free_datablock(ldi) linkedlist_datablock_internal* ldi; { while (ldi!=NULL) { linkedlist_datablock_internal* ldinext = ldi->next_datablock; TRYFREE(ldi); ldi = ldinext; } } local void init_linkedlist(ll) linkedlist_data* ll; { ll->first_block = ll->last_block = NULL; } local void free_linkedlist(ll) linkedlist_data* ll; { free_datablock(ll->first_block); ll->first_block = ll->last_block = NULL; } local int add_data_in_datablock(ll,buf,len) linkedlist_data* ll; const void* buf; uLong len; { linkedlist_datablock_internal* ldi; const unsigned char* from_copy; if (ll==NULL) return ZIP_INTERNALERROR; if (ll->last_block == NULL) { ll->first_block = ll->last_block = allocate_new_datablock(); if (ll->first_block == NULL) return ZIP_INTERNALERROR; } ldi = ll->last_block; from_copy = (unsigned char*)buf; while (len>0) { uInt copy_this; uInt i; unsigned char* to_copy; if (ldi->avail_in_this_block==0) { ldi->next_datablock = allocate_new_datablock(); if (ldi->next_datablock == NULL) return ZIP_INTERNALERROR; ldi = ldi->next_datablock ; ll->last_block = ldi; } if (ldi->avail_in_this_block < len) copy_this = (uInt)ldi->avail_in_this_block; else copy_this = (uInt)len; to_copy = &(ldi->data[ldi->filled_in_this_block]); for (i=0;ifilled_in_this_block += copy_this; ldi->avail_in_this_block -= copy_this; from_copy += copy_this ; len -= copy_this; } return ZIP_OK; } /****************************************************************************/ #ifndef NO_ADDFILEINEXISTINGZIP /* =========================================================================== Inputs a long in LSB order to the given file nbByte == 1, 2 or 4 (byte, short or long) */ local int ziplocal_putValue OF((const zlib_filefunc_def* pzlib_filefunc_def, voidpf filestream, uLong x, int nbByte)); local int ziplocal_putValue (pzlib_filefunc_def, filestream, x, nbByte) const zlib_filefunc_def* pzlib_filefunc_def; voidpf filestream; uLong x; int nbByte; { unsigned char buf[4]; int n; for (n = 0; n < nbByte; n++) { buf[n] = (unsigned char)(x & 0xff); x >>= 8; } if (x != 0) { /* data overflow - hack for ZIP64 (X Roche) */ for (n = 0; n < nbByte; n++) { buf[n] = 0xff; } } if (ZWRITE(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte) return ZIP_ERRNO; else return ZIP_OK; } local void ziplocal_putValue_inmemory OF((void* dest, uLong x, int nbByte)); local void ziplocal_putValue_inmemory (dest, x, nbByte) void* dest; uLong x; int nbByte; { unsigned char* buf=(unsigned char*)dest; int n; for (n = 0; n < nbByte; n++) { buf[n] = (unsigned char)(x & 0xff); x >>= 8; } if (x != 0) { /* data overflow - hack for ZIP64 */ for (n = 0; n < nbByte; n++) { buf[n] = 0xff; } } } /****************************************************************************/ local uLong ziplocal_TmzDateToDosDate(ptm,dosDate) const tm_zip* ptm; uLong dosDate; { uLong year = (uLong)ptm->tm_year; if (year>1980) year-=1980; else if (year>80) year-=80; return (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) | ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour)); } /****************************************************************************/ local int ziplocal_getByte OF(( const zlib_filefunc_def* pzlib_filefunc_def, voidpf filestream, int *pi)); local int ziplocal_getByte(pzlib_filefunc_def,filestream,pi) const zlib_filefunc_def* pzlib_filefunc_def; voidpf filestream; int *pi; { unsigned char c; int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1); if (err==1) { *pi = (int)c; return ZIP_OK; } else { if (ZERROR(*pzlib_filefunc_def,filestream)) return ZIP_ERRNO; else return ZIP_EOF; } } /* =========================================================================== Reads a long in LSB order from the given gz_stream. Sets */ local int ziplocal_getShort OF(( const zlib_filefunc_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); local int ziplocal_getShort (pzlib_filefunc_def,filestream,pX) const zlib_filefunc_def* pzlib_filefunc_def; voidpf filestream; uLong *pX; { uLong x ; int i; int err; err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); x = (uLong)i; if (err==ZIP_OK) err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); x += ((uLong)i)<<8; if (err==ZIP_OK) *pX = x; else *pX = 0; return err; } local int ziplocal_getLong OF(( const zlib_filefunc_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX) const zlib_filefunc_def* pzlib_filefunc_def; voidpf filestream; uLong *pX; { uLong x ; int i; int err; err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); x = (uLong)i; if (err==ZIP_OK) err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); x += ((uLong)i)<<8; if (err==ZIP_OK) err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); x += ((uLong)i)<<16; if (err==ZIP_OK) err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); x += ((uLong)i)<<24; if (err==ZIP_OK) *pX = x; else *pX = 0; return err; } #ifndef BUFREADCOMMENT #define BUFREADCOMMENT (0x400) #endif /* Locate the Central directory of a zipfile (at the end, just before the global comment) */ local uLong ziplocal_SearchCentralDir OF(( const zlib_filefunc_def* pzlib_filefunc_def, voidpf filestream)); local uLong ziplocal_SearchCentralDir(pzlib_filefunc_def,filestream) const zlib_filefunc_def* pzlib_filefunc_def; voidpf filestream; { unsigned char* buf; uLong uSizeFile; uLong uBackRead; uLong uMaxBack=0xffff; /* maximum size of global comment */ uLong uPosFound=0; if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) return 0; uSizeFile = ZTELL(*pzlib_filefunc_def,filestream); if (uMaxBack>uSizeFile) uMaxBack = uSizeFile; buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); if (buf==NULL) return 0; uBackRead = 4; while (uBackReaduMaxBack) uBackRead = uMaxBack; else uBackRead+=BUFREADCOMMENT; uReadPos = uSizeFile-uBackRead ; uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) break; if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) break; for (i=(int)uReadSize-3; (i--)>0;) if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) { uPosFound = uReadPos+i; break; } if (uPosFound!=0) break; } TRYFREE(buf); return uPosFound; } #endif /* !NO_ADDFILEINEXISTINGZIP*/ /************************************************************/ extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc_def) const char *pathname; int append; zipcharpc* globalcomment; zlib_filefunc_def* pzlib_filefunc_def; { zip_internal ziinit; zip_internal* zi; int err=ZIP_OK; if (pzlib_filefunc_def==NULL) fill_fopen_filefunc(&ziinit.z_filefunc); else ziinit.z_filefunc = *pzlib_filefunc_def; ziinit.filestream = (*(ziinit.z_filefunc.zopen_file)) (ziinit.z_filefunc.opaque, pathname, (append == APPEND_STATUS_CREATE) ? (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) : (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_EXISTING)); if (ziinit.filestream == NULL) return NULL; ziinit.begin_pos = ZTELL(ziinit.z_filefunc,ziinit.filestream); ziinit.in_opened_file_inzip = 0; ziinit.ci.stream_initialised = 0; ziinit.number_entry = 0; ziinit.add_position_when_writting_offset = 0; init_linkedlist(&(ziinit.central_dir)); zi = (zip_internal*)ALLOC(sizeof(zip_internal)); if (zi==NULL) { ZCLOSE(ziinit.z_filefunc,ziinit.filestream); return NULL; } /* now we add file in a zipfile */ # ifndef NO_ADDFILEINEXISTINGZIP ziinit.globalcomment = NULL; if (append == APPEND_STATUS_ADDINZIP) { uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ uLong size_central_dir; /* size of the central directory */ uLong offset_central_dir; /* offset of start of central directory */ uLong central_pos,uL; uLong number_disk; /* number of the current dist, used for spaning ZIP, unsupported, always 0*/ uLong number_disk_with_CD; /* number the the disk with central dir, used for spaning ZIP, unsupported, always 0*/ uLong number_entry; uLong number_entry_CD; /* total number of entries in the central dir (same than number_entry on nospan) */ uLong size_comment; central_pos = ziplocal_SearchCentralDir(&ziinit.z_filefunc,ziinit.filestream); if (central_pos==0) err=ZIP_ERRNO; if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) err=ZIP_ERRNO; /* the signature, already checked */ if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&uL)!=ZIP_OK) err=ZIP_ERRNO; /* number of this disk */ if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk)!=ZIP_OK) err=ZIP_ERRNO; /* number of the disk with the start of the central directory */ if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk_with_CD)!=ZIP_OK) err=ZIP_ERRNO; /* total number of entries in the central dir on this disk */ if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry)!=ZIP_OK) err=ZIP_ERRNO; /* total number of entries in the central dir */ if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry_CD)!=ZIP_OK) err=ZIP_ERRNO; if ((number_entry_CD!=number_entry) || (number_disk_with_CD!=0) || (number_disk!=0)) err=ZIP_BADZIPFILE; /* size of the central directory */ if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&size_central_dir)!=ZIP_OK) err=ZIP_ERRNO; /* offset of start of central directory with respect to the starting disk number */ if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&offset_central_dir)!=ZIP_OK) err=ZIP_ERRNO; /* zipfile global comment length */ if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&size_comment)!=ZIP_OK) err=ZIP_ERRNO; if ((central_pos0) { ziinit.globalcomment = ALLOC(size_comment+1); if (ziinit.globalcomment) { size_comment = ZREAD(ziinit.z_filefunc, ziinit.filestream,ziinit.globalcomment,size_comment); ziinit.globalcomment[size_comment]=0; } } byte_before_the_zipfile = central_pos - (offset_central_dir+size_central_dir); ziinit.add_position_when_writting_offset = byte_before_the_zipfile; { uLong size_central_dir_to_read = size_central_dir; size_t buf_size = SIZEDATA_INDATABLOCK; void* buf_read = (void*)ALLOC(buf_size); if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, offset_central_dir + byte_before_the_zipfile, ZLIB_FILEFUNC_SEEK_SET) != 0) err=ZIP_ERRNO; while ((size_central_dir_to_read>0) && (err==ZIP_OK)) { uLong read_this = SIZEDATA_INDATABLOCK; if (read_this > size_central_dir_to_read) read_this = size_central_dir_to_read; if (ZREAD(ziinit.z_filefunc, ziinit.filestream,buf_read,read_this) != read_this) err=ZIP_ERRNO; if (err==ZIP_OK) err = add_data_in_datablock(&ziinit.central_dir,buf_read, (uLong)read_this); size_central_dir_to_read-=read_this; } TRYFREE(buf_read); } ziinit.begin_pos = byte_before_the_zipfile; ziinit.number_entry = number_entry_CD; if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) err=ZIP_ERRNO; } if (globalcomment) { *globalcomment = ziinit.globalcomment; } # endif /* !NO_ADDFILEINEXISTINGZIP*/ if (err != ZIP_OK) { # ifndef NO_ADDFILEINEXISTINGZIP TRYFREE(ziinit.globalcomment); # endif /* !NO_ADDFILEINEXISTINGZIP*/ TRYFREE(zi); return NULL; } else { *zi = ziinit; return (zipFile)zi; } } extern zipFile ZEXPORT zipOpen (pathname, append) const char *pathname; int append; { return zipOpen2(pathname,append,NULL,NULL); } extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, extrafield_local, size_extrafield_local, extrafield_global, size_extrafield_global, comment, method, level, raw, windowBits, memLevel, strategy, password, crcForCrypting) zipFile file; const char* filename; const zip_fileinfo* zipfi; const void* extrafield_local; uInt size_extrafield_local; const void* extrafield_global; uInt size_extrafield_global; const char* comment; int method; int level; int raw; int windowBits; int memLevel; int strategy; const char* password; uLong crcForCrypting; { zip_internal* zi; uInt size_filename; uInt size_comment; uInt i; int err = ZIP_OK; # ifdef NOCRYPT if (password != NULL) return ZIP_PARAMERROR; # endif if (file == NULL) return ZIP_PARAMERROR; if ((method!=0) && (method!=Z_DEFLATED)) return ZIP_PARAMERROR; zi = (zip_internal*)file; if (zi->in_opened_file_inzip == 1) { err = zipCloseFileInZip (file); if (err != ZIP_OK) return err; } if (filename==NULL) filename="-"; if (comment==NULL) size_comment = 0; else size_comment = (uInt)strlen(comment); size_filename = (uInt)strlen(filename); if (zipfi == NULL) zi->ci.dosDate = 0; else { if (zipfi->dosDate != 0) zi->ci.dosDate = zipfi->dosDate; else zi->ci.dosDate = ziplocal_TmzDateToDosDate(&zipfi->tmz_date,zipfi->dosDate); } zi->ci.flag = 0; if ((level==8) || (level==9)) zi->ci.flag |= 2; if ((level==2)) zi->ci.flag |= 4; if ((level==1)) zi->ci.flag |= 6; if (password != NULL) zi->ci.flag |= 1; zi->ci.crc32 = 0; zi->ci.method = method; zi->ci.encrypt = 0; zi->ci.stream_initialised = 0; zi->ci.pos_in_buffered_data = 0; zi->ci.raw = raw; zi->ci.pos_local_header = ZTELL(zi->z_filefunc,zi->filestream) ; zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + size_extrafield_global + size_comment; zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader); ziplocal_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4); /* version info */ ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)VERSIONMADEBY,2); ziplocal_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2); ziplocal_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2); ziplocal_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2); ziplocal_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4); ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/ ziplocal_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/ ziplocal_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/ ziplocal_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2); ziplocal_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2); ziplocal_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2); ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/ if (zipfi==NULL) ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2); else ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2); if (zipfi==NULL) ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); else ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4); ziplocal_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header- zi->add_position_when_writting_offset,4); for (i=0;ici.central_header+SIZECENTRALHEADER+i) = *(filename+i); for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+i) = *(((const char*)extrafield_global)+i); for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+ size_extrafield_global+i) = *(comment+i); if (zi->ci.central_header == NULL) return ZIP_INTERNALERROR; /* write the local header */ err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC,4); if (err==ZIP_OK) err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */ if (err==ZIP_OK) err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.flag,2); if (err==ZIP_OK) err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2); if (err==ZIP_OK) err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4); if (err==ZIP_OK) err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */ if (err==ZIP_OK) err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */ if (err==ZIP_OK) err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */ if (err==ZIP_OK) err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2); if (err==ZIP_OK) err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield_local,2); if ((err==ZIP_OK) && (size_filename>0)) if (ZWRITE(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename) err = ZIP_ERRNO; if ((err==ZIP_OK) && (size_extrafield_local>0)) if (ZWRITE(zi->z_filefunc,zi->filestream,extrafield_local,size_extrafield_local) !=size_extrafield_local) err = ZIP_ERRNO; zi->ci.stream.avail_in = (uInt)0; zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; zi->ci.stream.next_out = zi->ci.buffered_data; zi->ci.stream.total_in = 0; zi->ci.stream.total_out = 0; if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) { zi->ci.stream.zalloc = (alloc_func)0; zi->ci.stream.zfree = (free_func)0; zi->ci.stream.opaque = (voidpf)0; if (windowBits>0) windowBits = -windowBits; err = deflateInit2(&zi->ci.stream, level, Z_DEFLATED, windowBits, memLevel, strategy); if (err==Z_OK) zi->ci.stream_initialised = 1; } # ifndef NOCRYPT zi->ci.crypt_header_size = 0; if ((err==Z_OK) && (password != NULL)) { unsigned char bufHead[RAND_HEAD_LEN]; unsigned int sizeHead; zi->ci.encrypt = 1; zi->ci.pcrc_32_tab = get_crc_table(); /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/ sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting); zi->ci.crypt_header_size = sizeHead; if (ZWRITE(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead) err = ZIP_ERRNO; } # endif if (err==Z_OK) zi->in_opened_file_inzip = 1; return err; } extern int ZEXPORT zipOpenNewFileInZip2(file, filename, zipfi, extrafield_local, size_extrafield_local, extrafield_global, size_extrafield_global, comment, method, level, raw) zipFile file; const char* filename; const zip_fileinfo* zipfi; const void* extrafield_local; uInt size_extrafield_local; const void* extrafield_global; uInt size_extrafield_global; const char* comment; int method; int level; int raw; { return zipOpenNewFileInZip3 (file, filename, zipfi, extrafield_local, size_extrafield_local, extrafield_global, size_extrafield_global, comment, method, level, raw, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, NULL, 0); } extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, extrafield_local, size_extrafield_local, extrafield_global, size_extrafield_global, comment, method, level) zipFile file; const char* filename; const zip_fileinfo* zipfi; const void* extrafield_local; uInt size_extrafield_local; const void* extrafield_global; uInt size_extrafield_global; const char* comment; int method; int level; { return zipOpenNewFileInZip2 (file, filename, zipfi, extrafield_local, size_extrafield_local, extrafield_global, size_extrafield_global, comment, method, level, 0); } local int zipFlushWriteBuffer(zi) zip_internal* zi; { int err=ZIP_OK; if (zi->ci.encrypt != 0) { #ifndef NOCRYPT uInt i; int t; for (i=0;ici.pos_in_buffered_data;i++) zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, zi->ci.buffered_data[i],t); #endif } if (ZWRITE(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data) !=zi->ci.pos_in_buffered_data) err = ZIP_ERRNO; zi->ci.pos_in_buffered_data = 0; return err; } extern int ZEXPORT zipWriteInFileInZip (file, buf, len) zipFile file; const void* buf; unsigned len; { zip_internal* zi; int err=ZIP_OK; if (file == NULL) return ZIP_PARAMERROR; zi = (zip_internal*)file; if (zi->in_opened_file_inzip == 0) return ZIP_PARAMERROR; zi->ci.stream.next_in = (void*)buf; zi->ci.stream.avail_in = len; zi->ci.crc32 = crc32(zi->ci.crc32,buf,len); while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) { if (zi->ci.stream.avail_out == 0) { if (zipFlushWriteBuffer(zi) == ZIP_ERRNO) err = ZIP_ERRNO; zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; zi->ci.stream.next_out = zi->ci.buffered_data; } if(err != ZIP_OK) break; if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) { uLong uTotalOutBefore = zi->ci.stream.total_out; err=deflate(&zi->ci.stream, Z_NO_FLUSH); zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; } else { uInt copy_this,i; if (zi->ci.stream.avail_in < zi->ci.stream.avail_out) copy_this = zi->ci.stream.avail_in; else copy_this = zi->ci.stream.avail_out; for (i=0;ici.stream.next_out)+i) = *(((const char*)zi->ci.stream.next_in)+i); { zi->ci.stream.avail_in -= copy_this; zi->ci.stream.avail_out-= copy_this; zi->ci.stream.next_in+= copy_this; zi->ci.stream.next_out+= copy_this; zi->ci.stream.total_in+= copy_this; zi->ci.stream.total_out+= copy_this; zi->ci.pos_in_buffered_data += copy_this; } } } return err; } extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32) zipFile file; uLong uncompressed_size; uLong crc32; { zip_internal* zi; uLong compressed_size; int err=ZIP_OK; if (file == NULL) return ZIP_PARAMERROR; zi = (zip_internal*)file; if (zi->in_opened_file_inzip == 0) return ZIP_PARAMERROR; zi->ci.stream.avail_in = 0; if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) while (err==ZIP_OK) { uLong uTotalOutBefore; if (zi->ci.stream.avail_out == 0) { if (zipFlushWriteBuffer(zi) == ZIP_ERRNO) err = ZIP_ERRNO; zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; zi->ci.stream.next_out = zi->ci.buffered_data; } uTotalOutBefore = zi->ci.stream.total_out; err=deflate(&zi->ci.stream, Z_FINISH); zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; } if (err==Z_STREAM_END) err=ZIP_OK; /* this is normal */ if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK)) if (zipFlushWriteBuffer(zi)==ZIP_ERRNO) err = ZIP_ERRNO; if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) { err=deflateEnd(&zi->ci.stream); zi->ci.stream_initialised = 0; } if (!zi->ci.raw) { crc32 = (uLong)zi->ci.crc32; uncompressed_size = (uLong)zi->ci.stream.total_in; } compressed_size = (uLong)zi->ci.stream.total_out; # ifndef NOCRYPT compressed_size += zi->ci.crypt_header_size; # endif ziplocal_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/ ziplocal_putValue_inmemory(zi->ci.central_header+20, compressed_size,4); /*compr size*/ if (zi->ci.stream.data_type == Z_ASCII) ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2); ziplocal_putValue_inmemory(zi->ci.central_header+24, uncompressed_size,4); /*uncompr size*/ if (err==ZIP_OK) err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header, (uLong)zi->ci.size_centralheader); free(zi->ci.central_header); if (err==ZIP_OK) { long cur_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); if (ZSEEK(zi->z_filefunc,zi->filestream, zi->ci.pos_local_header + 14,ZLIB_FILEFUNC_SEEK_SET)!=0) err = ZIP_ERRNO; if (err==ZIP_OK) err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */ if (err==ZIP_OK) /* compressed size, unknown */ err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4); if (err==ZIP_OK) /* uncompressed size, unknown */ err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,uncompressed_size,4); if (ZSEEK(zi->z_filefunc,zi->filestream, cur_pos_inzip,ZLIB_FILEFUNC_SEEK_SET)!=0) err = ZIP_ERRNO; } zi->number_entry ++; zi->in_opened_file_inzip = 0; return err; } extern int ZEXPORT zipCloseFileInZip (file) zipFile file; { return zipCloseFileInZipRaw (file,0,0); } extern int ZEXPORT zipClose (file, global_comment) zipFile file; const char* global_comment; { zip_internal* zi; int err = 0; uLong size_centraldir = 0; uLong centraldir_pos_inzip; uInt size_global_comment; if (file == NULL) return ZIP_PARAMERROR; zi = (zip_internal*)file; if (zi->in_opened_file_inzip == 1) { err = zipCloseFileInZip (file); } #ifndef NO_ADDFILEINEXISTINGZIP if (global_comment==NULL) global_comment = zi->globalcomment; #endif if (global_comment==NULL) size_global_comment = 0; else size_global_comment = (uInt)strlen(global_comment); centraldir_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); if (err==ZIP_OK) { linkedlist_datablock_internal* ldi = zi->central_dir.first_block ; while (ldi!=NULL) { if ((err==ZIP_OK) && (ldi->filled_in_this_block>0)) if (ZWRITE(zi->z_filefunc,zi->filestream, ldi->data,ldi->filled_in_this_block) !=ldi->filled_in_this_block ) err = ZIP_ERRNO; size_centraldir += ldi->filled_in_this_block; ldi = ldi->next_datablock; } } free_datablock(zi->central_dir.first_block); if (err==ZIP_OK) /* Magic End */ err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4); if (err==ZIP_OK) /* number of this disk */ err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); if (err==ZIP_OK) /* number of the disk with the start of the central directory */ err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); if (err==ZIP_OK) /* total number of entries in the central dir */ err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); if (err==ZIP_OK) /* size of the central directory */ err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4); if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */ err = ziplocal_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4); if (err==ZIP_OK) /* zipfile comment length */ err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_global_comment,2); if ((err==ZIP_OK) && (size_global_comment>0)) if (ZWRITE(zi->z_filefunc,zi->filestream, global_comment,size_global_comment) != size_global_comment) err = ZIP_ERRNO; if (ZCLOSE(zi->z_filefunc,zi->filestream) != 0) if (err == ZIP_OK) err = ZIP_ERRNO; #ifndef NO_ADDFILEINEXISTINGZIP TRYFREE(zi->globalcomment); #endif TRYFREE(zi); return err; } sks-ecc-0.93/zlib/contrib/minizip/Makefile0000600000175000017500000000071110604550750017447 0ustar nachonachoCC=cc CFLAGS=-O -I../.. UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a .c.o: $(CC) -c $(CFLAGS) $*.c all: miniunz minizip miniunz: $(UNZ_OBJS) $(CC) $(CFLAGS) -o $@ $(UNZ_OBJS) minizip: $(ZIP_OBJS) $(CC) $(CFLAGS) -o $@ $(ZIP_OBJS) test: miniunz minizip ./minizip test readme.txt ./miniunz -l test.zip mv readme.txt readme.old ./miniunz test.zip clean: /bin/rm -f *.o *~ minizip miniunz sks-ecc-0.93/zlib/contrib/minizip/iowin32.c0000600000175000017500000001441310604550750017451 0ustar nachonacho/* iowin32.c -- IO base function header for compress/uncompress .zip files using zlib + zip or unzip API This IO API version uses the Win32 API (for Microsoft Windows) Version 1.01e, February 12th, 2005 Copyright (C) 1998-2005 Gilles Vollant */ #include #include "zlib.h" #include "ioapi.h" #include "iowin32.h" #ifndef INVALID_HANDLE_VALUE #define INVALID_HANDLE_VALUE (0xFFFFFFFF) #endif #ifndef INVALID_SET_FILE_POINTER #define INVALID_SET_FILE_POINTER ((DWORD)-1) #endif voidpf ZCALLBACK win32_open_file_func OF(( voidpf opaque, const char* filename, int mode)); uLong ZCALLBACK win32_read_file_func OF(( voidpf opaque, voidpf stream, void* buf, uLong size)); uLong ZCALLBACK win32_write_file_func OF(( voidpf opaque, voidpf stream, const void* buf, uLong size)); long ZCALLBACK win32_tell_file_func OF(( voidpf opaque, voidpf stream)); long ZCALLBACK win32_seek_file_func OF(( voidpf opaque, voidpf stream, uLong offset, int origin)); int ZCALLBACK win32_close_file_func OF(( voidpf opaque, voidpf stream)); int ZCALLBACK win32_error_file_func OF(( voidpf opaque, voidpf stream)); typedef struct { HANDLE hf; int error; } WIN32FILE_IOWIN; voidpf ZCALLBACK win32_open_file_func (opaque, filename, mode) voidpf opaque; const char* filename; int mode; { const char* mode_fopen = NULL; DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; HANDLE hFile = 0; voidpf ret=NULL; dwDesiredAccess = dwShareMode = dwFlagsAndAttributes = 0; if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) { dwDesiredAccess = GENERIC_READ; dwCreationDisposition = OPEN_EXISTING; dwShareMode = FILE_SHARE_READ; } else if (mode & ZLIB_FILEFUNC_MODE_EXISTING) { dwDesiredAccess = GENERIC_WRITE | GENERIC_READ; dwCreationDisposition = OPEN_EXISTING; } else if (mode & ZLIB_FILEFUNC_MODE_CREATE) { dwDesiredAccess = GENERIC_WRITE | GENERIC_READ; dwCreationDisposition = CREATE_ALWAYS; } if ((filename!=NULL) && (dwDesiredAccess != 0)) hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); if (hFile == INVALID_HANDLE_VALUE) hFile = NULL; if (hFile != NULL) { WIN32FILE_IOWIN w32fiow; w32fiow.hf = hFile; w32fiow.error = 0; ret = malloc(sizeof(WIN32FILE_IOWIN)); if (ret==NULL) CloseHandle(hFile); else *((WIN32FILE_IOWIN*)ret) = w32fiow; } return ret; } uLong ZCALLBACK win32_read_file_func (opaque, stream, buf, size) voidpf opaque; voidpf stream; void* buf; uLong size; { uLong ret=0; HANDLE hFile = NULL; if (stream!=NULL) hFile = ((WIN32FILE_IOWIN*)stream) -> hf; if (hFile != NULL) if (!ReadFile(hFile, buf, size, &ret, NULL)) { DWORD dwErr = GetLastError(); if (dwErr == ERROR_HANDLE_EOF) dwErr = 0; ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; } return ret; } uLong ZCALLBACK win32_write_file_func (opaque, stream, buf, size) voidpf opaque; voidpf stream; const void* buf; uLong size; { uLong ret=0; HANDLE hFile = NULL; if (stream!=NULL) hFile = ((WIN32FILE_IOWIN*)stream) -> hf; if (hFile !=NULL) if (!WriteFile(hFile, buf, size, &ret, NULL)) { DWORD dwErr = GetLastError(); if (dwErr == ERROR_HANDLE_EOF) dwErr = 0; ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; } return ret; } long ZCALLBACK win32_tell_file_func (opaque, stream) voidpf opaque; voidpf stream; { long ret=-1; HANDLE hFile = NULL; if (stream!=NULL) hFile = ((WIN32FILE_IOWIN*)stream) -> hf; if (hFile != NULL) { DWORD dwSet = SetFilePointer(hFile, 0, NULL, FILE_CURRENT); if (dwSet == INVALID_SET_FILE_POINTER) { DWORD dwErr = GetLastError(); ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; ret = -1; } else ret=(long)dwSet; } return ret; } long ZCALLBACK win32_seek_file_func (opaque, stream, offset, origin) voidpf opaque; voidpf stream; uLong offset; int origin; { DWORD dwMoveMethod=0xFFFFFFFF; HANDLE hFile = NULL; long ret=-1; if (stream!=NULL) hFile = ((WIN32FILE_IOWIN*)stream) -> hf; switch (origin) { case ZLIB_FILEFUNC_SEEK_CUR : dwMoveMethod = FILE_CURRENT; break; case ZLIB_FILEFUNC_SEEK_END : dwMoveMethod = FILE_END; break; case ZLIB_FILEFUNC_SEEK_SET : dwMoveMethod = FILE_BEGIN; break; default: return -1; } if (hFile != NULL) { DWORD dwSet = SetFilePointer(hFile, offset, NULL, dwMoveMethod); if (dwSet == INVALID_SET_FILE_POINTER) { DWORD dwErr = GetLastError(); ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; ret = -1; } else ret=0; } return ret; } int ZCALLBACK win32_close_file_func (opaque, stream) voidpf opaque; voidpf stream; { int ret=-1; if (stream!=NULL) { HANDLE hFile; hFile = ((WIN32FILE_IOWIN*)stream) -> hf; if (hFile != NULL) { CloseHandle(hFile); ret=0; } free(stream); } return ret; } int ZCALLBACK win32_error_file_func (opaque, stream) voidpf opaque; voidpf stream; { int ret=-1; if (stream!=NULL) { ret = ((WIN32FILE_IOWIN*)stream) -> error; } return ret; } void fill_win32_filefunc (pzlib_filefunc_def) zlib_filefunc_def* pzlib_filefunc_def; { pzlib_filefunc_def->zopen_file = win32_open_file_func; pzlib_filefunc_def->zread_file = win32_read_file_func; pzlib_filefunc_def->zwrite_file = win32_write_file_func; pzlib_filefunc_def->ztell_file = win32_tell_file_func; pzlib_filefunc_def->zseek_file = win32_seek_file_func; pzlib_filefunc_def->zclose_file = win32_close_file_func; pzlib_filefunc_def->zerror_file = win32_error_file_func; pzlib_filefunc_def->opaque=NULL; } sks-ecc-0.93/zlib/contrib/minizip/miniunz.c0000600000175000017500000003602510604550750017653 0ustar nachonacho/* miniunz.c Version 1.01e, February 12th, 2005 Copyright (C) 1998-2005 Gilles Vollant */ #include #include #include #include #include #include #ifdef unix # include # include #else # include # include #endif #include "unzip.h" #define CASESENSITIVITY (0) #define WRITEBUFFERSIZE (8192) #define MAXFILENAME (256) #ifdef WIN32 #define USEWIN32IOAPI #include "iowin32.h" #endif /* mini unzip, demo of unzip package usage : Usage : miniunz [-exvlo] file.zip [file_to_extract] [-d extractdir] list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT if it exists */ /* change_file_date : change the date/time of a file filename : the filename of the file where date/time must be modified dosdate : the new date at the MSDos format (4 bytes) tmu_date : the SAME new date at the tm_unz format */ void change_file_date(filename,dosdate,tmu_date) const char *filename; uLong dosdate; tm_unz tmu_date; { #ifdef WIN32 HANDLE hFile; FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite; hFile = CreateFile(filename,GENERIC_READ | GENERIC_WRITE, 0,NULL,OPEN_EXISTING,0,NULL); GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite); DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal); LocalFileTimeToFileTime(&ftLocal,&ftm); SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); CloseHandle(hFile); #else #ifdef unix struct utimbuf ut; struct tm newdate; newdate.tm_sec = tmu_date.tm_sec; newdate.tm_min=tmu_date.tm_min; newdate.tm_hour=tmu_date.tm_hour; newdate.tm_mday=tmu_date.tm_mday; newdate.tm_mon=tmu_date.tm_mon; if (tmu_date.tm_year > 1900) newdate.tm_year=tmu_date.tm_year - 1900; else newdate.tm_year=tmu_date.tm_year ; newdate.tm_isdst=-1; ut.actime=ut.modtime=mktime(&newdate); utime(filename,&ut); #endif #endif } /* mymkdir and change_file_date are not 100 % portable As I don't know well Unix, I wait feedback for the unix portion */ int mymkdir(dirname) const char* dirname; { int ret=0; #ifdef WIN32 ret = mkdir(dirname); #else #ifdef unix ret = mkdir (dirname,0775); #endif #endif return ret; } int makedir (newdir) char *newdir; { char *buffer ; char *p; int len = (int)strlen(newdir); if (len <= 0) return 0; buffer = (char*)malloc(len+1); strcpy(buffer,newdir); if (buffer[len-1] == '/') { buffer[len-1] = '\0'; } if (mymkdir(buffer) == 0) { free(buffer); return 1; } p = buffer+1; while (1) { char hold; while(*p && *p != '\\' && *p != '/') p++; hold = *p; *p = 0; if ((mymkdir(buffer) == -1) && (errno == ENOENT)) { printf("couldn't create directory %s\n",buffer); free(buffer); return 0; } if (hold == 0) break; *p++ = hold; } free(buffer); return 1; } void do_banner() { printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n"); printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); } void do_help() { printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \ " -e Extract without pathname (junk paths)\n" \ " -x Extract with pathname\n" \ " -v list files\n" \ " -l list files\n" \ " -d directory to extract into\n" \ " -o overwrite files without prompting\n" \ " -p extract crypted file using password\n\n"); } int do_list(uf) unzFile uf; { uLong i; unz_global_info gi; int err; err = unzGetGlobalInfo (uf,&gi); if (err!=UNZ_OK) printf("error %d with zipfile in unzGetGlobalInfo \n",err); printf(" Length Method Size Ratio Date Time CRC-32 Name\n"); printf(" ------ ------ ---- ----- ---- ---- ------ ----\n"); for (i=0;i0) ratio = (file_info.compressed_size*100)/file_info.uncompressed_size; /* display a '*' if the file is crypted */ if ((file_info.flag & 1) != 0) charCrypt='*'; if (file_info.compression_method==0) string_method="Stored"; else if (file_info.compression_method==Z_DEFLATED) { uInt iLevel=(uInt)((file_info.flag & 0x6)/2); if (iLevel==0) string_method="Defl:N"; else if (iLevel==1) string_method="Defl:X"; else if ((iLevel==2) || (iLevel==3)) string_method="Defl:F"; /* 2:fast , 3 : extra fast*/ } else string_method="Unkn. "; printf("%7lu %6s%c%7lu %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n", file_info.uncompressed_size,string_method, charCrypt, file_info.compressed_size, ratio, (uLong)file_info.tmu_date.tm_mon + 1, (uLong)file_info.tmu_date.tm_mday, (uLong)file_info.tmu_date.tm_year % 100, (uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min, (uLong)file_info.crc,filename_inzip); if ((i+1)='a') && (rep<='z')) rep -= 0x20; } while ((rep!='Y') && (rep!='N') && (rep!='A')); } if (rep == 'N') skip = 1; if (rep == 'A') *popt_overwrite=1; } if ((skip==0) && (err==UNZ_OK)) { fout=fopen(write_filename,"wb"); /* some zipfile don't contain directory alone before file */ if ((fout==NULL) && ((*popt_extract_without_path)==0) && (filename_withoutpath!=(char*)filename_inzip)) { char c=*(filename_withoutpath-1); *(filename_withoutpath-1)='\0'; makedir(write_filename); *(filename_withoutpath-1)=c; fout=fopen(write_filename,"wb"); } if (fout==NULL) { printf("error opening %s\n",write_filename); } } if (fout!=NULL) { printf(" extracting: %s\n",write_filename); do { err = unzReadCurrentFile(uf,buf,size_buf); if (err<0) { printf("error %d with zipfile in unzReadCurrentFile\n",err); break; } if (err>0) if (fwrite(buf,err,1,fout)!=1) { printf("error in writing extracted file\n"); err=UNZ_ERRNO; break; } } while (err>0); if (fout) fclose(fout); if (err==0) change_file_date(write_filename,file_info.dosDate, file_info.tmu_date); } if (err==UNZ_OK) { err = unzCloseCurrentFile (uf); if (err!=UNZ_OK) { printf("error %d with zipfile in unzCloseCurrentFile\n",err); } } else unzCloseCurrentFile(uf); /* don't lose the error */ } free(buf); return err; } int do_extract(uf,opt_extract_without_path,opt_overwrite,password) unzFile uf; int opt_extract_without_path; int opt_overwrite; const char* password; { uLong i; unz_global_info gi; int err; FILE* fout=NULL; err = unzGetGlobalInfo (uf,&gi); if (err!=UNZ_OK) printf("error %d with zipfile in unzGetGlobalInfo \n",err); for (i=0;i= 8 # define DEF_MEM_LEVEL 8 # else # define DEF_MEM_LEVEL MAX_MEM_LEVEL # endif #endif /* default memLevel */ /* tm_zip contain date/time info */ typedef struct tm_zip_s { uInt tm_sec; /* seconds after the minute - [0,59] */ uInt tm_min; /* minutes after the hour - [0,59] */ uInt tm_hour; /* hours since midnight - [0,23] */ uInt tm_mday; /* day of the month - [1,31] */ uInt tm_mon; /* months since January - [0,11] */ uInt tm_year; /* years - [1980..2044] */ } tm_zip; typedef struct { tm_zip tmz_date; /* date in understandable format */ uLong dosDate; /* if dos_date == 0, tmu_date is used */ /* uLong flag; */ /* general purpose bit flag 2 bytes */ uLong internal_fa; /* internal file attributes 2 bytes */ uLong external_fa; /* external file attributes 4 bytes */ } zip_fileinfo; typedef const char* zipcharpc; #define APPEND_STATUS_CREATE (0) #define APPEND_STATUS_CREATEAFTER (1) #define APPEND_STATUS_ADDINZIP (2) extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); /* Create a zipfile. pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on an Unix computer "zlib/zlib113.zip". if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip will be created at the end of the file. (useful if the file contain a self extractor code) if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will add files in existing zip (be sure you don't add file that doesn't exist) If the zipfile cannot be opened, the return value is NULL. Else, the return value is a zipFile Handle, usable with other function of this zip package. */ /* Note : there is no delete function into a zipfile. If you want delete file into a zipfile, you must open a zipfile, and create another Of couse, you can use RAW reading and writing to copy the file you did not want delte */ extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc_def)); extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, const char* filename, const zip_fileinfo* zipfi, const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global, uInt size_extrafield_global, const char* comment, int method, int level)); /* Open a file in the ZIP for writing. filename : the filename in zip (if NULL, '-' without quote will be used *zipfi contain supplemental information if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local contains the extrafield data the the local header if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global contains the extrafield data the the local header if comment != NULL, comment contain the comment string method contain the compression method (0 for store, Z_DEFLATED for deflate) level contain the level of compression (can be Z_DEFAULT_COMPRESSION) */ extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi, const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global, uInt size_extrafield_global, const char* comment, int method, int level, int raw)); /* Same than zipOpenNewFileInZip, except if raw=1, we write raw file */ extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, const char* filename, const zip_fileinfo* zipfi, const void* extrafield_local, uInt size_extrafield_local, const void* extrafield_global, uInt size_extrafield_global, const char* comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char* password, uLong crcForCtypting)); /* Same than zipOpenNewFileInZip2, except windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 password : crypting password (NULL for no crypting) crcForCtypting : crc of file to compress (needed for crypting) */ extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, const void* buf, unsigned len)); /* Write data in the zipfile */ extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); /* Close the current file in the zipfile */ extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, uLong uncompressed_size, uLong crc32)); /* Close the current file in the zipfile, for fiel opened with parameter raw=1 in zipOpenNewFileInZip2 uncompressed_size and crc32 are value for the uncompressed size */ extern int ZEXPORT zipClose OF((zipFile file, const char* global_comment)); /* Close the zipfile */ #ifdef __cplusplus } #endif #endif /* _zip_H */ sks-ecc-0.93/zlib/contrib/minizip/mztools.h0000600000175000017500000000125110604550750017667 0ustar nachonacho/* Additional tools for Minizip Code: Xavier Roche '2004 License: Same as ZLIB (www.gzip.org) */ #ifndef _zip_tools_H #define _zip_tools_H #ifdef __cplusplus extern "C" { #endif #ifndef _ZLIB_H #include "zlib.h" #endif #include "unzip.h" /* Repair a ZIP file (missing central directory) file: file to recover fileOut: output file after recovery fileOutTmp: temporary file name used for recovery */ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* fileOutTmp, uLong* nRecovered, uLong* bytesRecovered); #endif sks-ecc-0.93/zlib/contrib/minizip/iowin32.h0000600000175000017500000000064610604550750017461 0ustar nachonacho/* iowin32.h -- IO base function header for compress/uncompress .zip files using zlib + zip or unzip API This IO API version uses the Win32 API (for Microsoft Windows) Version 1.01e, February 12th, 2005 Copyright (C) 1998-2005 Gilles Vollant */ #include #ifdef __cplusplus extern "C" { #endif void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); #ifdef __cplusplus } #endif sks-ecc-0.93/zlib/contrib/minizip/minizip.c0000600000175000017500000002661610604550750017646 0ustar nachonacho/* minizip.c Version 1.01e, February 12th, 2005 Copyright (C) 1998-2005 Gilles Vollant */ #include #include #include #include #include #include #ifdef unix # include # include # include # include #else # include # include #endif #include "zip.h" #ifdef WIN32 #define USEWIN32IOAPI #include "iowin32.h" #endif #define WRITEBUFFERSIZE (16384) #define MAXFILENAME (256) #ifdef WIN32 uLong filetime(f, tmzip, dt) char *f; /* name of file to get info on */ tm_zip *tmzip; /* return value: access, modific. and creation times */ uLong *dt; /* dostime */ { int ret = 0; { FILETIME ftLocal; HANDLE hFind; WIN32_FIND_DATA ff32; hFind = FindFirstFile(f,&ff32); if (hFind != INVALID_HANDLE_VALUE) { FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal); FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0); FindClose(hFind); ret = 1; } } return ret; } #else #ifdef unix uLong filetime(f, tmzip, dt) char *f; /* name of file to get info on */ tm_zip *tmzip; /* return value: access, modific. and creation times */ uLong *dt; /* dostime */ { int ret=0; struct stat s; /* results of stat() */ struct tm* filedate; time_t tm_t=0; if (strcmp(f,"-")!=0) { char name[MAXFILENAME+1]; int len = strlen(f); if (len > MAXFILENAME) len = MAXFILENAME; strncpy(name, f,MAXFILENAME-1); /* strncpy doesnt append the trailing NULL, of the string is too long. */ name[ MAXFILENAME ] = '\0'; if (name[len - 1] == '/') name[len - 1] = '\0'; /* not all systems allow stat'ing a file with / appended */ if (stat(name,&s)==0) { tm_t = s.st_mtime; ret = 1; } } filedate = localtime(&tm_t); tmzip->tm_sec = filedate->tm_sec; tmzip->tm_min = filedate->tm_min; tmzip->tm_hour = filedate->tm_hour; tmzip->tm_mday = filedate->tm_mday; tmzip->tm_mon = filedate->tm_mon ; tmzip->tm_year = filedate->tm_year; return ret; } #else uLong filetime(f, tmzip, dt) char *f; /* name of file to get info on */ tm_zip *tmzip; /* return value: access, modific. and creation times */ uLong *dt; /* dostime */ { return 0; } #endif #endif int check_exist_file(filename) const char* filename; { FILE* ftestexist; int ret = 1; ftestexist = fopen(filename,"rb"); if (ftestexist==NULL) ret = 0; else fclose(ftestexist); return ret; } void do_banner() { printf("MiniZip 1.01b, demo of zLib + Zip package written by Gilles Vollant\n"); printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); } void do_help() { printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] file.zip [files_to_add]\n\n" \ " -o Overwrite existing file.zip\n" \ " -a Append to existing file.zip\n" \ " -0 Store only\n" \ " -1 Compress faster\n" \ " -9 Compress better\n\n"); } /* calculate the CRC32 of a file, because to encrypt a file, we need known the CRC32 of the file before */ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc) { unsigned long calculate_crc=0; int err=ZIP_OK; FILE * fin = fopen(filenameinzip,"rb"); unsigned long size_read = 0; unsigned long total_read = 0; if (fin==NULL) { err = ZIP_ERRNO; } if (err == ZIP_OK) do { err = ZIP_OK; size_read = (int)fread(buf,1,size_buf,fin); if (size_read < size_buf) if (feof(fin)==0) { printf("error in reading %s\n",filenameinzip); err = ZIP_ERRNO; } if (size_read>0) calculate_crc = crc32(calculate_crc,buf,size_read); total_read += size_read; } while ((err == ZIP_OK) && (size_read>0)); if (fin) fclose(fin); *result_crc=calculate_crc; printf("file %s crc %x\n",filenameinzip,calculate_crc); return err; } int main(argc,argv) int argc; char *argv[]; { int i; int opt_overwrite=0; int opt_compress_level=Z_DEFAULT_COMPRESSION; int zipfilenamearg = 0; char filename_try[MAXFILENAME+16]; int zipok; int err=0; int size_buf=0; void* buf=NULL; const char* password=NULL; do_banner(); if (argc==1) { do_help(); return 0; } else { for (i=1;i='0') && (c<='9')) opt_compress_level = c-'0'; if (((c=='p') || (c=='P')) && (i+1='a') && (rep<='z')) rep -= 0x20; } while ((rep!='Y') && (rep!='N') && (rep!='A')); if (rep=='N') zipok = 0; if (rep=='A') opt_overwrite = 2; } } if (zipok==1) { zipFile zf; int errclose; # ifdef USEWIN32IOAPI zlib_filefunc_def ffunc; fill_win32_filefunc(&ffunc); zf = zipOpen2(filename_try,(opt_overwrite==2) ? 2 : 0,NULL,&ffunc); # else zf = zipOpen(filename_try,(opt_overwrite==2) ? 2 : 0); # endif if (zf == NULL) { printf("error opening %s\n",filename_try); err= ZIP_ERRNO; } else printf("creating %s\n",filename_try); for (i=zipfilenamearg+1;(i='0') || (argv[i][1]<='9'))) && (strlen(argv[i]) == 2))) { FILE * fin; int size_read; const char* filenameinzip = argv[i]; zip_fileinfo zi; unsigned long crcFile=0; zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour = zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0; zi.dosDate = 0; zi.internal_fa = 0; zi.external_fa = 0; filetime(filenameinzip,&zi.tmz_date,&zi.dosDate); /* err = zipOpenNewFileInZip(zf,filenameinzip,&zi, NULL,0,NULL,0,NULL / * comment * /, (opt_compress_level != 0) ? Z_DEFLATED : 0, opt_compress_level); */ if ((password != NULL) && (err==ZIP_OK)) err = getFileCrc(filenameinzip,buf,size_buf,&crcFile); err = zipOpenNewFileInZip3(zf,filenameinzip,&zi, NULL,0,NULL,0,NULL /* comment*/, (opt_compress_level != 0) ? Z_DEFLATED : 0, opt_compress_level,0, /* -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, */ -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, password,crcFile); if (err != ZIP_OK) printf("error in opening %s in zipfile\n",filenameinzip); else { fin = fopen(filenameinzip,"rb"); if (fin==NULL) { err=ZIP_ERRNO; printf("error in opening %s for reading\n",filenameinzip); } } if (err == ZIP_OK) do { err = ZIP_OK; size_read = (int)fread(buf,1,size_buf,fin); if (size_read < size_buf) if (feof(fin)==0) { printf("error in reading %s\n",filenameinzip); err = ZIP_ERRNO; } if (size_read>0) { err = zipWriteInFileInZip (zf,buf,size_read); if (err<0) { printf("error in writing %s in the zipfile\n", filenameinzip); } } } while ((err == ZIP_OK) && (size_read>0)); if (fin) fclose(fin); if (err<0) err=ZIP_ERRNO; else { err = zipCloseFileInZip(zf); if (err!=ZIP_OK) printf("error in closing %s in the zipfile\n", filenameinzip); } } } errclose = zipClose(zf,NULL); if (errclose != ZIP_OK) printf("error in closing %s\n",filename_try); } else { do_help(); } free(buf); return 0; } sks-ecc-0.93/zlib/contrib/minizip/ioapi.h0000600000175000017500000000474710604550750017276 0ustar nachonacho/* ioapi.h -- IO base function header for compress/uncompress .zip files using zlib + zip or unzip API Version 1.01e, February 12th, 2005 Copyright (C) 1998-2005 Gilles Vollant */ #ifndef _ZLIBIOAPI_H #define _ZLIBIOAPI_H #define ZLIB_FILEFUNC_SEEK_CUR (1) #define ZLIB_FILEFUNC_SEEK_END (2) #define ZLIB_FILEFUNC_SEEK_SET (0) #define ZLIB_FILEFUNC_MODE_READ (1) #define ZLIB_FILEFUNC_MODE_WRITE (2) #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) #define ZLIB_FILEFUNC_MODE_EXISTING (4) #define ZLIB_FILEFUNC_MODE_CREATE (8) #ifndef ZCALLBACK #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) #define ZCALLBACK CALLBACK #else #define ZCALLBACK #endif #endif #ifdef __cplusplus extern "C" { #endif typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); typedef struct zlib_filefunc_def_s { open_file_func zopen_file; read_file_func zread_file; write_file_func zwrite_file; tell_file_func ztell_file; seek_file_func zseek_file; close_file_func zclose_file; testerror_file_func zerror_file; voidpf opaque; } zlib_filefunc_def; void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) #ifdef __cplusplus } #endif #endif sks-ecc-0.93/zlib/contrib/minizip/unzip.h0000600000175000017500000003125010604550750017327 0ustar nachonacho/* unzip.h -- IO for uncompress .zip files using zlib Version 1.01e, February 12th, 2005 Copyright (C) 1998-2005 Gilles Vollant This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g WinZip, InfoZip tools and compatible. Multi volume ZipFile (span) are not supported. Encryption compatible with pkzip 2.04g only supported Old compressions used by old PKZip 1.x are not supported I WAIT FEEDBACK at mail info@winimage.com Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution Condition of use and distribution are the same than zlib : 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. */ /* for more info about .ZIP format, see http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip http://www.info-zip.org/pub/infozip/doc/ PkWare has also a specification at : ftp://ftp.pkware.com/probdesc.zip */ #ifndef _unz_H #define _unz_H #ifdef __cplusplus extern "C" { #endif #ifndef _ZLIB_H #include "zlib.h" #endif #ifndef _ZLIBIOAPI_H #include "ioapi.h" #endif #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) /* like the STRICT of WIN32, we define a pointer that cannot be converted from (void*) without cast */ typedef struct TagunzFile__ { int unused; } unzFile__; typedef unzFile__ *unzFile; #else typedef voidp unzFile; #endif #define UNZ_OK (0) #define UNZ_END_OF_LIST_OF_FILE (-100) #define UNZ_ERRNO (Z_ERRNO) #define UNZ_EOF (0) #define UNZ_PARAMERROR (-102) #define UNZ_BADZIPFILE (-103) #define UNZ_INTERNALERROR (-104) #define UNZ_CRCERROR (-105) /* tm_unz contain date/time info */ typedef struct tm_unz_s { uInt tm_sec; /* seconds after the minute - [0,59] */ uInt tm_min; /* minutes after the hour - [0,59] */ uInt tm_hour; /* hours since midnight - [0,23] */ uInt tm_mday; /* day of the month - [1,31] */ uInt tm_mon; /* months since January - [0,11] */ uInt tm_year; /* years - [1980..2044] */ } tm_unz; /* unz_global_info structure contain global data about the ZIPfile These data comes from the end of central dir */ typedef struct unz_global_info_s { uLong number_entry; /* total number of entries in the central dir on this disk */ uLong size_comment; /* size of the global comment of the zipfile */ } unz_global_info; /* unz_file_info contain information about a file in the zipfile */ typedef struct unz_file_info_s { uLong version; /* version made by 2 bytes */ uLong version_needed; /* version needed to extract 2 bytes */ uLong flag; /* general purpose bit flag 2 bytes */ uLong compression_method; /* compression method 2 bytes */ uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ uLong crc; /* crc-32 4 bytes */ uLong compressed_size; /* compressed size 4 bytes */ uLong uncompressed_size; /* uncompressed size 4 bytes */ uLong size_filename; /* filename length 2 bytes */ uLong size_file_extra; /* extra field length 2 bytes */ uLong size_file_comment; /* file comment length 2 bytes */ uLong disk_num_start; /* disk number start 2 bytes */ uLong internal_fa; /* internal file attributes 2 bytes */ uLong external_fa; /* external file attributes 4 bytes */ tm_unz tmu_date; } unz_file_info; extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, const char* fileName2, int iCaseSensitivity)); /* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi or strcasecmp) If iCaseSenisivity = 0, case sensitivity is defaut of your operating system (like 1 on Unix, 2 on Windows) */ extern unzFile ZEXPORT unzOpen OF((const char *path)); /* Open a Zip file. path contain the full pathname (by example, on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer "zlib/zlib113.zip". If the zipfile cannot be opened (file don't exist or in not valid), the return value is NULL. Else, the return value is a unzFile Handle, usable with other function of this unzip package. */ extern unzFile ZEXPORT unzOpen2 OF((const char *path, zlib_filefunc_def* pzlib_filefunc_def)); /* Open a Zip file, like unzOpen, but provide a set of file low level API for read/write the zip file (see ioapi.h) */ extern int ZEXPORT unzClose OF((unzFile file)); /* Close a ZipFile opened with unzipOpen. If there is files inside the .Zip opened with unzOpenCurrentFile (see later), these files MUST be closed with unzipCloseCurrentFile before call unzipClose. return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, unz_global_info *pglobal_info)); /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetGlobalComment OF((unzFile file, char *szComment, uLong uSizeBuf)); /* Get the global comment string of the ZipFile, in the szComment buffer. uSizeBuf is the size of the szComment buffer. return the number of byte copied or an error code <0 */ /***************************************************************************/ /* Unzip package allow you browse the directory of the zipfile */ extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); /* Set the current file of the zipfile to the first file. return UNZ_OK if there is no problem */ extern int ZEXPORT unzGoToNextFile OF((unzFile file)); /* Set the current file of the zipfile to the next file. return UNZ_OK if there is no problem return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ extern int ZEXPORT unzLocateFile OF((unzFile file, const char *szFileName, int iCaseSensitivity)); /* Try locate the file szFileName in the zipfile. For the iCaseSensitivity signification, see unzStringFileNameCompare return value : UNZ_OK if the file is found. It becomes the current file. UNZ_END_OF_LIST_OF_FILE if the file is not found */ /* ****************************************** */ /* Ryan supplied functions */ /* unz_file_info contain information about a file in the zipfile */ typedef struct unz_file_pos_s { uLong pos_in_zip_directory; /* offset in zip file directory */ uLong num_of_file; /* # of file */ } unz_file_pos; extern int ZEXPORT unzGetFilePos( unzFile file, unz_file_pos* file_pos); extern int ZEXPORT unzGoToFilePos( unzFile file, unz_file_pos* file_pos); /* ****************************************** */ extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)); /* Get Info about the current file if pfile_info!=NULL, the *pfile_info structure will contain somes info about the current file if szFileName!=NULL, the filemane string will be copied in szFileName (fileNameBufferSize is the size of the buffer) if extraField!=NULL, the extra field information will be copied in extraField (extraFieldBufferSize is the size of the buffer). This is the Central-header version of the extra field if szComment!=NULL, the comment string of the file will be copied in szComment (commentBufferSize is the size of the buffer) */ /***************************************************************************/ /* for reading the content of the current zipfile, you can open it, read data from it, and close it (you can close it before reading all the file) */ extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); /* Open for reading data the current file in the zipfile. If there is no error, the return value is UNZ_OK. */ extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, const char* password)); /* Open for reading data the current file in the zipfile. password is a crypting password If there is no error, the return value is UNZ_OK. */ extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, int* method, int* level, int raw)); /* Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) if raw==1 *method will receive method of compression, *level will receive level of compression note : you can set level parameter as NULL (if you did not want known level, but you CANNOT set method parameter as NULL */ extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, int* method, int* level, int raw, const char* password)); /* Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) if raw==1 *method will receive method of compression, *level will receive level of compression note : you can set level parameter as NULL (if you did not want known level, but you CANNOT set method parameter as NULL */ extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); /* Close the file in zip opened with unzOpenCurrentFile Return UNZ_CRCERROR if all the file was read but the CRC is not good */ extern int ZEXPORT unzReadCurrentFile OF((unzFile file, voidp buf, unsigned len)); /* Read bytes from the current file (opened by unzOpenCurrentFile) buf contain buffer where data must be copied len the size of buf. return the number of byte copied if somes bytes are copied return 0 if the end of file was reached return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ extern z_off_t ZEXPORT unztell OF((unzFile file)); /* Give the current position in uncompressed data */ extern int ZEXPORT unzeof OF((unzFile file)); /* return 1 if the end of file was reached, 0 elsewhere */ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, voidp buf, unsigned len)); /* Read extra field from the current file (opened by unzOpenCurrentFile) This is the local-header version of the extra field (sometimes, there is more info in the local-header version than in the central-header) if buf==NULL, it return the size of the local extra field if buf!=NULL, len is the size of the buffer, the extra header is copied in buf. the return value is the number of bytes copied in buf, or (if <0) the error code */ /***************************************************************************/ /* Get the current file offset */ extern uLong ZEXPORT unzGetOffset (unzFile file); /* Set the current file offset */ extern int ZEXPORT unzSetOffset (unzFile file, uLong pos); #ifdef __cplusplus } #endif #endif /* _unz_H */ sks-ecc-0.93/zlib/contrib/minizip/mztools.c0000600000175000017500000001746110604550750017674 0ustar nachonacho/* Additional tools for Minizip Code: Xavier Roche '2004 License: Same as ZLIB (www.gzip.org) */ /* Code */ #include #include #include #include "zlib.h" #include "unzip.h" #define READ_8(adr) ((unsigned char)*(adr)) #define READ_16(adr) ( READ_8(adr) | (READ_8(adr+1) << 8) ) #define READ_32(adr) ( READ_16(adr) | (READ_16((adr)+2) << 16) ) #define WRITE_8(buff, n) do { \ *((unsigned char*)(buff)) = (unsigned char) ((n) & 0xff); \ } while(0) #define WRITE_16(buff, n) do { \ WRITE_8((unsigned char*)(buff), n); \ WRITE_8(((unsigned char*)(buff)) + 1, (n) >> 8); \ } while(0) #define WRITE_32(buff, n) do { \ WRITE_16((unsigned char*)(buff), (n) & 0xffff); \ WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \ } while(0) extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered) const char* file; const char* fileOut; const char* fileOutTmp; uLong* nRecovered; uLong* bytesRecovered; { int err = Z_OK; FILE* fpZip = fopen(file, "rb"); FILE* fpOut = fopen(fileOut, "wb"); FILE* fpOutCD = fopen(fileOutTmp, "wb"); if (fpZip != NULL && fpOut != NULL) { int entries = 0; uLong totalBytes = 0; char header[30]; char filename[256]; char extra[1024]; int offset = 0; int offsetCD = 0; while ( fread(header, 1, 30, fpZip) == 30 ) { int currentOffset = offset; /* File entry */ if (READ_32(header) == 0x04034b50) { unsigned int version = READ_16(header + 4); unsigned int gpflag = READ_16(header + 6); unsigned int method = READ_16(header + 8); unsigned int filetime = READ_16(header + 10); unsigned int filedate = READ_16(header + 12); unsigned int crc = READ_32(header + 14); /* crc */ unsigned int cpsize = READ_32(header + 18); /* compressed size */ unsigned int uncpsize = READ_32(header + 22); /* uncompressed sz */ unsigned int fnsize = READ_16(header + 26); /* file name length */ unsigned int extsize = READ_16(header + 28); /* extra field length */ filename[0] = extra[0] = '\0'; /* Header */ if (fwrite(header, 1, 30, fpOut) == 30) { offset += 30; } else { err = Z_ERRNO; break; } /* Filename */ if (fnsize > 0) { if (fread(filename, 1, fnsize, fpZip) == fnsize) { if (fwrite(filename, 1, fnsize, fpOut) == fnsize) { offset += fnsize; } else { err = Z_ERRNO; break; } } else { err = Z_ERRNO; break; } } else { err = Z_STREAM_ERROR; break; } /* Extra field */ if (extsize > 0) { if (fread(extra, 1, extsize, fpZip) == extsize) { if (fwrite(extra, 1, extsize, fpOut) == extsize) { offset += extsize; } else { err = Z_ERRNO; break; } } else { err = Z_ERRNO; break; } } /* Data */ { int dataSize = cpsize; if (dataSize == 0) { dataSize = uncpsize; } if (dataSize > 0) { char* data = malloc(dataSize); if (data != NULL) { if ((int)fread(data, 1, dataSize, fpZip) == dataSize) { if ((int)fwrite(data, 1, dataSize, fpOut) == dataSize) { offset += dataSize; totalBytes += dataSize; } else { err = Z_ERRNO; } } else { err = Z_ERRNO; } free(data); if (err != Z_OK) { break; } } else { err = Z_MEM_ERROR; break; } } } /* Central directory entry */ { char header[46]; char* comment = ""; int comsize = (int) strlen(comment); WRITE_32(header, 0x02014b50); WRITE_16(header + 4, version); WRITE_16(header + 6, version); WRITE_16(header + 8, gpflag); WRITE_16(header + 10, method); WRITE_16(header + 12, filetime); WRITE_16(header + 14, filedate); WRITE_32(header + 16, crc); WRITE_32(header + 20, cpsize); WRITE_32(header + 24, uncpsize); WRITE_16(header + 28, fnsize); WRITE_16(header + 30, extsize); WRITE_16(header + 32, comsize); WRITE_16(header + 34, 0); /* disk # */ WRITE_16(header + 36, 0); /* int attrb */ WRITE_32(header + 38, 0); /* ext attrb */ WRITE_32(header + 42, currentOffset); /* Header */ if (fwrite(header, 1, 46, fpOutCD) == 46) { offsetCD += 46; /* Filename */ if (fnsize > 0) { if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) { offsetCD += fnsize; } else { err = Z_ERRNO; break; } } else { err = Z_STREAM_ERROR; break; } /* Extra field */ if (extsize > 0) { if (fwrite(extra, 1, extsize, fpOutCD) == extsize) { offsetCD += extsize; } else { err = Z_ERRNO; break; } } /* Comment field */ if (comsize > 0) { if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) { offsetCD += comsize; } else { err = Z_ERRNO; break; } } } else { err = Z_ERRNO; break; } } /* Success */ entries++; } else { break; } } /* Final central directory */ { int entriesZip = entries; char header[22]; char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools"; int comsize = (int) strlen(comment); if (entriesZip > 0xffff) { entriesZip = 0xffff; } WRITE_32(header, 0x06054b50); WRITE_16(header + 4, 0); /* disk # */ WRITE_16(header + 6, 0); /* disk # */ WRITE_16(header + 8, entriesZip); /* hack */ WRITE_16(header + 10, entriesZip); /* hack */ WRITE_32(header + 12, offsetCD); /* size of CD */ WRITE_32(header + 16, offset); /* offset to CD */ WRITE_16(header + 20, comsize); /* comment */ /* Header */ if (fwrite(header, 1, 22, fpOutCD) == 22) { /* Comment field */ if (comsize > 0) { if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) { err = Z_ERRNO; } } } else { err = Z_ERRNO; } } /* Final merge (file + central directory) */ fclose(fpOutCD); if (err == Z_OK) { fpOutCD = fopen(fileOutTmp, "rb"); if (fpOutCD != NULL) { int nRead; char buffer[8192]; while ( (nRead = (int)fread(buffer, 1, sizeof(buffer), fpOutCD)) > 0) { if ((int)fwrite(buffer, 1, nRead, fpOut) != nRead) { err = Z_ERRNO; break; } } fclose(fpOutCD); } } /* Close */ fclose(fpZip); fclose(fpOut); /* Wipe temporary file */ (void)remove(fileOutTmp); /* Number of recovered entries */ if (err == Z_OK) { if (nRecovered != NULL) { *nRecovered = entries; } if (bytesRecovered != NULL) { *bytesRecovered = totalBytes; } } } else { err = Z_STREAM_ERROR; } return err; } sks-ecc-0.93/zlib/contrib/minizip/crypt.h0000600000175000017500000001115010604550750017320 0ustar nachonacho/* crypt.h -- base code for crypt/uncrypt ZIPfile Version 1.01e, February 12th, 2005 Copyright (C) 1998-2005 Gilles Vollant This code is a modified version of crypting code in Infozip distribution The encryption/decryption parts of this source code (as opposed to the non-echoing password parts) were originally written in Europe. The whole source package can be freely distributed, including from the USA. (Prior to January 2000, re-export from the US was a violation of US law.) This encryption code is a direct transcription of the algorithm from Roger Schlafly, described by Phil Katz in the file appnote.txt. This file (appnote.txt) is distributed with the PKZIP program (even in the version without encryption capabilities). If you don't need crypting in your application, just define symbols NOCRYPT and NOUNCRYPT. This code support the "Traditional PKWARE Encryption". The new AES encryption added on Zip format by Winzip (see the page http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong Encryption is not supported. */ #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) /*********************************************************************** * Return the next byte in the pseudo-random sequence */ static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) { unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an * unpredictable manner on 16-bit systems; not a problem * with any known compiler so far, though */ temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); } /*********************************************************************** * Update the encryption keys with the next byte of plain text */ static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c) { (*(pkeys+0)) = CRC32((*(pkeys+0)), c); (*(pkeys+1)) += (*(pkeys+0)) & 0xff; (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; { register int keyshift = (int)((*(pkeys+1)) >> 24); (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); } return c; } /*********************************************************************** * Initialize the encryption keys and the random header according to * the given password. */ static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab) { *(pkeys+0) = 305419896L; *(pkeys+1) = 591751049L; *(pkeys+2) = 878082192L; while (*passwd != '\0') { update_keys(pkeys,pcrc_32_tab,(int)*passwd); passwd++; } } #define zdecode(pkeys,pcrc_32_tab,c) \ (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) #define zencode(pkeys,pcrc_32_tab,c,t) \ (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c)) #ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED #define RAND_HEAD_LEN 12 /* "last resort" source for second part of crypt seed pattern */ # ifndef ZCR_SEED2 # define ZCR_SEED2 3141592654UL /* use PI as default pattern */ # endif static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) const char *passwd; /* password string */ unsigned char *buf; /* where to write header */ int bufSize; unsigned long* pkeys; const unsigned long* pcrc_32_tab; unsigned long crcForCrypting; { int n; /* index in random header */ int t; /* temporary */ int c; /* random byte */ unsigned char header[RAND_HEAD_LEN-2]; /* random header */ static unsigned calls = 0; /* ensure different random header each time */ if (bufSize> 7) & 0xff; header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t); } /* Encrypt random header (last two bytes is high word of crc) */ init_keys(passwd, pkeys, pcrc_32_tab); for (n = 0; n < RAND_HEAD_LEN-2; n++) { buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); } buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); return n; } #endif sks-ecc-0.93/zlib/contrib/masmx64/0000755000175000017500000000000010604550750015640 5ustar nachonachosks-ecc-0.93/zlib/contrib/masmx64/readme.txt0000644000175000017500000000211010604550750017630 0ustar nachonachoSummary ------- This directory contains ASM implementations of the functions longest_match() and inflate_fast(), for 64 bits x86 (both AMD64 and Intel EM64t), for use with Microsoft Macro Assembler (x64) for AMD64 and Microsoft C++ 64 bits. gvmat64.asm is written by Gilles Vollant (2005), by using Brian Raiter 686/32 bits assembly optimized version from Jean-loup Gailly original longest_match function inffasx64.asm and inffas8664.c were written by Chris Anderson, by optimizing original function from Mark Adler Use instructions ---------------- Copy these files into the zlib source directory. define ASMV and ASMINF in your project. Include inffas8664.c in your source tree, and inffasx64.obj and gvmat64.obj as object to link. Build instructions ------------------ run bld_64.bat with Microsoft Macro Assembler (x64) for AMD64 (ml64.exe) ml64.exe is given with Visual Studio 2005, Windows 2003 server DDK You can get Windows 2003 server DDK with ml64 and cl for AMD64 from http://www.microsoft.com/whdc/devtools/ddk/default.mspx for low price) sks-ecc-0.93/zlib/contrib/masmx64/inffasx64.asm0000644000175000017500000002444410604550750020162 0ustar nachonacho; inffasx64.asm is a hand tuned assembler version of inffast.c - fast decoding ; version for AMD64 on Windows using Microsoft C compiler ; ; inffasx64.asm is automatically convert from AMD64 portion of inffas86.c ; inffasx64.asm is called by inffas8664.c, which contain more info. ; to compile this file, I use option ; ml64.exe /Flinffasx64 /c /Zi inffasx64.asm ; with Microsoft Macro Assembler (x64) for AMD64 ; ; ml64.exe is given with Visual Studio 2005, Windows 2003 server DDK ; ; (you can get Windows 2003 server DDK with ml64 and cl.exe for AMD64 from ; http://www.microsoft.com/whdc/devtools/ddk/default.mspx for low price) ; .code inffas8664fnc PROC ; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and ; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp ; ; All registers must be preserved across the call, except for ; rax, rcx, rdx, r8, r-9, r10, and r11, which are scratch. mov [rsp-8],rsi mov [rsp-16],rdi mov [rsp-24],r12 mov [rsp-32],r13 mov [rsp-40],r14 mov [rsp-48],r15 mov [rsp-56],rbx mov rax,rcx mov [rax+8], rbp ; /* save regs rbp and rsp */ mov [rax], rsp mov rsp, rax ; /* make rsp point to &ar */ mov rsi, [rsp+16] ; /* rsi = in */ mov rdi, [rsp+32] ; /* rdi = out */ mov r9, [rsp+24] ; /* r9 = last */ mov r10, [rsp+48] ; /* r10 = end */ mov rbp, [rsp+64] ; /* rbp = lcode */ mov r11, [rsp+72] ; /* r11 = dcode */ mov rdx, [rsp+80] ; /* rdx = hold */ mov ebx, [rsp+88] ; /* ebx = bits */ mov r12d, [rsp+100] ; /* r12d = lmask */ mov r13d, [rsp+104] ; /* r13d = dmask */ ; /* r14d = len */ ; /* r15d = dist */ cld cmp r10, rdi je L_one_time ; /* if only one decode left */ cmp r9, rsi jne L_do_loop L_one_time: mov r8, r12 ; /* r8 = lmask */ cmp bl, 32 ja L_get_length_code_one_time lodsd ; /* eax = *(uint *)in++ */ mov cl, bl ; /* cl = bits, needs it for shifting */ add bl, 32 ; /* bits += 32 */ shl rax, cl or rdx, rax ; /* hold |= *((uint *)in)++ << bits */ jmp L_get_length_code_one_time ALIGN 4 L_while_test: cmp r10, rdi jbe L_break_loop cmp r9, rsi jbe L_break_loop L_do_loop: mov r8, r12 ; /* r8 = lmask */ cmp bl, 32 ja L_get_length_code ; /* if (32 < bits) */ lodsd ; /* eax = *(uint *)in++ */ mov cl, bl ; /* cl = bits, needs it for shifting */ add bl, 32 ; /* bits += 32 */ shl rax, cl or rdx, rax ; /* hold |= *((uint *)in)++ << bits */ L_get_length_code: and r8, rdx ; /* r8 &= hold */ mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */ mov cl, ah ; /* cl = this.bits */ sub bl, ah ; /* bits -= this.bits */ shr rdx, cl ; /* hold >>= this.bits */ test al, al jnz L_test_for_length_base ; /* if (op != 0) 45.7% */ mov r8, r12 ; /* r8 = lmask */ shr eax, 16 ; /* output this.val char */ stosb L_get_length_code_one_time: and r8, rdx ; /* r8 &= hold */ mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */ L_dolen: mov cl, ah ; /* cl = this.bits */ sub bl, ah ; /* bits -= this.bits */ shr rdx, cl ; /* hold >>= this.bits */ test al, al jnz L_test_for_length_base ; /* if (op != 0) 45.7% */ shr eax, 16 ; /* output this.val char */ stosb jmp L_while_test ALIGN 4 L_test_for_length_base: mov r14d, eax ; /* len = this */ shr r14d, 16 ; /* len = this.val */ mov cl, al test al, 16 jz L_test_for_second_level_length ; /* if ((op & 16) == 0) 8% */ and cl, 15 ; /* op &= 15 */ jz L_decode_distance ; /* if (!op) */ L_add_bits_to_len: sub bl, cl xor eax, eax inc eax shl eax, cl dec eax and eax, edx ; /* eax &= hold */ shr rdx, cl add r14d, eax ; /* len += hold & mask[op] */ L_decode_distance: mov r8, r13 ; /* r8 = dmask */ cmp bl, 32 ja L_get_distance_code ; /* if (32 < bits) */ lodsd ; /* eax = *(uint *)in++ */ mov cl, bl ; /* cl = bits, needs it for shifting */ add bl, 32 ; /* bits += 32 */ shl rax, cl or rdx, rax ; /* hold |= *((uint *)in)++ << bits */ L_get_distance_code: and r8, rdx ; /* r8 &= hold */ mov eax, [r11+r8*4] ; /* eax = dcode[hold & dmask] */ L_dodist: mov r15d, eax ; /* dist = this */ shr r15d, 16 ; /* dist = this.val */ mov cl, ah sub bl, ah ; /* bits -= this.bits */ shr rdx, cl ; /* hold >>= this.bits */ mov cl, al ; /* cl = this.op */ test al, 16 ; /* if ((op & 16) == 0) */ jz L_test_for_second_level_dist and cl, 15 ; /* op &= 15 */ jz L_check_dist_one L_add_bits_to_dist: sub bl, cl xor eax, eax inc eax shl eax, cl dec eax ; /* (1 << op) - 1 */ and eax, edx ; /* eax &= hold */ shr rdx, cl add r15d, eax ; /* dist += hold & ((1 << op) - 1) */ L_check_window: mov r8, rsi ; /* save in so from can use it's reg */ mov rax, rdi sub rax, [rsp+40] ; /* nbytes = out - beg */ cmp eax, r15d jb L_clip_window ; /* if (dist > nbytes) 4.2% */ mov ecx, r14d ; /* ecx = len */ mov rsi, rdi sub rsi, r15 ; /* from = out - dist */ sar ecx, 1 jnc L_copy_two ; /* if len % 2 == 0 */ rep movsw mov al, [rsi] mov [rdi], al inc rdi mov rsi, r8 ; /* move in back to %rsi, toss from */ jmp L_while_test L_copy_two: rep movsw mov rsi, r8 ; /* move in back to %rsi, toss from */ jmp L_while_test ALIGN 4 L_check_dist_one: cmp r15d, 1 ; /* if dist 1, is a memset */ jne L_check_window cmp [rsp+40], rdi ; /* if out == beg, outside window */ je L_check_window mov ecx, r14d ; /* ecx = len */ mov al, [rdi-1] mov ah, al sar ecx, 1 jnc L_set_two mov [rdi], al inc rdi L_set_two: rep stosw jmp L_while_test ALIGN 4 L_test_for_second_level_length: test al, 64 jnz L_test_for_end_of_block ; /* if ((op & 64) != 0) */ xor eax, eax inc eax shl eax, cl dec eax and eax, edx ; /* eax &= hold */ add eax, r14d ; /* eax += len */ mov eax, [rbp+rax*4] ; /* eax = lcode[val+(hold&mask[op])]*/ jmp L_dolen ALIGN 4 L_test_for_second_level_dist: test al, 64 jnz L_invalid_distance_code ; /* if ((op & 64) != 0) */ xor eax, eax inc eax shl eax, cl dec eax and eax, edx ; /* eax &= hold */ add eax, r15d ; /* eax += dist */ mov eax, [r11+rax*4] ; /* eax = dcode[val+(hold&mask[op])]*/ jmp L_dodist ALIGN 4 L_clip_window: mov ecx, eax ; /* ecx = nbytes */ mov eax, [rsp+92] ; /* eax = wsize, prepare for dist cmp */ neg ecx ; /* nbytes = -nbytes */ cmp eax, r15d jb L_invalid_distance_too_far ; /* if (dist > wsize) */ add ecx, r15d ; /* nbytes = dist - nbytes */ cmp dword ptr [rsp+96], 0 jne L_wrap_around_window ; /* if (write != 0) */ mov rsi, [rsp+56] ; /* from = window */ sub eax, ecx ; /* eax -= nbytes */ add rsi, rax ; /* from += wsize - nbytes */ mov eax, r14d ; /* eax = len */ cmp r14d, ecx jbe L_do_copy ; /* if (nbytes >= len) */ sub eax, ecx ; /* eax -= nbytes */ rep movsb mov rsi, rdi sub rsi, r15 ; /* from = &out[ -dist ] */ jmp L_do_copy ALIGN 4 L_wrap_around_window: mov eax, [rsp+96] ; /* eax = write */ cmp ecx, eax jbe L_contiguous_in_window ; /* if (write >= nbytes) */ mov esi, [rsp+92] ; /* from = wsize */ add rsi, [rsp+56] ; /* from += window */ add rsi, rax ; /* from += write */ sub rsi, rcx ; /* from -= nbytes */ sub ecx, eax ; /* nbytes -= write */ mov eax, r14d ; /* eax = len */ cmp eax, ecx jbe L_do_copy ; /* if (nbytes >= len) */ sub eax, ecx ; /* len -= nbytes */ rep movsb mov rsi, [rsp+56] ; /* from = window */ mov ecx, [rsp+96] ; /* nbytes = write */ cmp eax, ecx jbe L_do_copy ; /* if (nbytes >= len) */ sub eax, ecx ; /* len -= nbytes */ rep movsb mov rsi, rdi sub rsi, r15 ; /* from = out - dist */ jmp L_do_copy ALIGN 4 L_contiguous_in_window: mov rsi, [rsp+56] ; /* rsi = window */ add rsi, rax sub rsi, rcx ; /* from += write - nbytes */ mov eax, r14d ; /* eax = len */ cmp eax, ecx jbe L_do_copy ; /* if (nbytes >= len) */ sub eax, ecx ; /* len -= nbytes */ rep movsb mov rsi, rdi sub rsi, r15 ; /* from = out - dist */ jmp L_do_copy ; /* if (nbytes >= len) */ ALIGN 4 L_do_copy: mov ecx, eax ; /* ecx = len */ rep movsb mov rsi, r8 ; /* move in back to %esi, toss from */ jmp L_while_test L_test_for_end_of_block: test al, 32 jz L_invalid_literal_length_code mov dword ptr [rsp+116], 1 jmp L_break_loop_with_status L_invalid_literal_length_code: mov dword ptr [rsp+116], 2 jmp L_break_loop_with_status L_invalid_distance_code: mov dword ptr [rsp+116], 3 jmp L_break_loop_with_status L_invalid_distance_too_far: mov dword ptr [rsp+116], 4 jmp L_break_loop_with_status L_break_loop: mov dword ptr [rsp+116], 0 L_break_loop_with_status: ; /* put in, out, bits, and hold back into ar and pop esp */ mov [rsp+16], rsi ; /* in */ mov [rsp+32], rdi ; /* out */ mov [rsp+88], ebx ; /* bits */ mov [rsp+80], rdx ; /* hold */ mov rax, [rsp] ; /* restore rbp and rsp */ mov rbp, [rsp+8] mov rsp, rax mov rsi,[rsp-8] mov rdi,[rsp-16] mov r12,[rsp-24] mov r13,[rsp-32] mov r14,[rsp-40] mov r15,[rsp-48] mov rbx,[rsp-56] ret 0 ; : ; : "m" (ar) ; : "memory", "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", ; "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" ; ); inffas8664fnc ENDP ;_TEXT ENDS END sks-ecc-0.93/zlib/contrib/masmx64/inffasx64.obj0000644000175000017500000001343110604550750020146 0ustar nachonachod†ëŽBT'.text´ P`.data@PÀ.debug$S ËØ<@B.debug$T$0@BH‰t$øH‰|$ðL‰d$èL‰l$àL‰t$ØL‰|$ÐH‰\$ÈH‹ÁH‰hH‰ H‹àH‹t$H‹|$ L‹L$L‹T$0H‹l$@L‹\$HH‹T$P‹\$XD‹d$dD‹l$hüL;×tL;Îu*M‹Ä€û wP­ŠË€Ã HÓàH ÐëBfL;׆?L;Ά6M‹Ä€û w ­ŠË€Ã HÓàH ÐL#ÂB‹D…ŠÌ*ÜHÓê„Àu#M‹ÄÁèªL#ÂB‹D…ŠÌ*ÜHÓê„Àu Áèªë§ffD‹ðAÁîŠÈ¨„Ç€át*Ù3ÀÿÀÓàÿÈ#ÂHÓêDðM‹Å€û w ­ŠË€Ã HÓàH ÐL#ÂC‹ƒD‹øAÁïŠÌ*ÜHÓêŠÈ¨„€átP*Ù3ÀÿÀÓàÿÈ#ÂHÓêDøL‹ÆH‹ÇH+D$(A;Ç‚’A‹ÎH‹÷I+÷Ñùsóf¥ŠˆHÿÇI‹ðéÿþÿÿóf¥I‹ðéôþÿÿAƒÿu¼H9|$(tµA‹ÎŠGÿŠàÑùsˆHÿÇóf«éÎþÿÿf¨@…à3ÀÿÀÓàÿÈ#ÂAÆ‹D…éöþÿÿf¨@…Ø3ÀÿÀÓàÿÈ#ÂAÇA‹ƒé-ÿÿÿf‹È‹D$\÷ÙA;Ç‚¹Aσ|$`u!H‹t$8+ÁHðA‹ÆD;ñvo+Áó¤H‹÷I+÷ëcff‹D$`;Èv8‹t$\Ht$8HðH+ñ+ÈA‹Æ;Áv@+Áó¤H‹t$8‹L$`;Áv/+Áó¤H‹÷I+÷ë#ffH‹t$8HðH+ñA‹Æ;Áv+Áó¤H‹÷I+÷ëf‹Èó¤I‹ðéäýÿÿ¨ t ÇD$të&ÇD$tëÇD$tëÇD$tëÇD$tH‰t$H‰|$ ‰\$XH‰T$PH‹$H‹l$H‹àH‹t$øH‹|$ðL‹d$èL‹l$àL‹t$ØL‹|$ÐH‹\$ÈÃó/O:\zlib-1.2.2.2\contrib\masmx64\inffasx64.asmôJ”u© –,ßå” } µ¢òÀõ´€€€ €€ €!€"€#$€&&€*'€-)€0+€5,€:-€?.€D/€I0€N1€S2€W3€\4€a9€b:€e;€g<€j>€lB€oC€rD€tF€uG€wH€zI€}J€€K€„O€‡P€Q€R€–U€™V€œW€žY€ŸZ€¡[€¤\€§]€ª`€­a€²c€´d€¶e€¹g€»h€½j€Àk€Ãl€Äo€Çp€Ìs€Ît€Ðu€Ów€Õx€×z€Ú{€Û|€à€€ã€ç‚€é„€ë…€ñ†€ô‡€öŠ€ø‹€úŒ€ü€þŽ€€€‘€”€ •€–€˜€™€š€›€œ€Ÿ€ €#£€&¤€*¥€,¦€.§€1¨€3ª€5«€;¬€>­€@°€B±€D²€F³€H´€Jµ€L¶€O·€Rº€U»€X¼€]¾€`¿€fÁ€i€lÀoÅ€qÆ€sÈ€vÉ€xÊ€zË€}Í€€΀…Ñ€ˆÒ€‹Ó€×€”Ø€–Ù€›Ú€Ü€ Ý€£Þ€¥à€§ဩ‫〮怱瀸뀺ì€Àî€Âï€Äð€Æñ€Èò€Êó€Íô€Ñõ€Øù€Úú€àü€âý€äþ€æÿ€è€ê€í€ñ€ø€ú€þ € € € € €€€€€€ €#€%€'€)€,€/€4"€8#€:$€<&€@'€E(€H)€K*€M,€P-€R.€T0€V1€X2€]3€a4€c5€e7€g8€i9€l:€o;€t?€y@€|A€C€‚D€„E€†G€ˆH€ŠI€J€K€”O€–P€˜R€›S€ V€¢W€¤X€¬Y€®\€¶]€¸`€Àa€Âd€Êe€Ìh€Ôl€Ùm€Þn€âo€çq€ër€ðs€ów€øx€ýy€z€{€ |€}€€ñß4O:\zlib-1.2.2.2\contrib\masmx64\inffasx64.obj4Л Microsoft (R) Macro Assembler3inffas8664fncL_one_timeL_while_testL_do_loopL_get_length_code$L_get_length_code_one_timeL_dolen L_test_for_length_baseL_add_bits_to_lenL_decode_distanceL_get_distance_codeL_dodistL_add_bits_to_distL_check_windowL_copy_twoL_check_dist_oneL_set_two(L_test_for_second_level_length&L_test_for_second_level_distL_clip_windowL_wrap_around_window L_contiguous_in_windowL_do_copy!L_test_for_end_of_block'L_invalid_literal_length_code!L_invalid_distance_code$L_invalid_distance_too_farL_break_loop"L_break_loop_with_statusd h ¸ ¼ Ñ Õ ç ë ÿ      1  5  W  [  j  n  Œ   ©  ­  Æ  Ê  å  é  ù  ý      1  5  G  K  c  g  x  |  ¢  ¦  Ê  Î  ã  ç      % ) : ! > ! ] " a " † # Š # © $ ­ $ Ï % Ó % ç & ë & òñ@comp.id› }ÿÿ.text.data.debug$S <.debug$T$ $$000000l„*–4ªFÄL_dolenÌaàxöŠœL_dodist#°@ÃRÒ…Ýî®ø¸Ø4øB4Wtn”x ®®¸ÆÂáÌîÔinffas8664fncL_one_timeL_while_testL_do_loopL_get_length_codeL_get_length_code_one_timeL_test_for_length_baseL_add_bits_to_lenL_decode_distanceL_get_distance_codeL_add_bits_to_distL_check_windowL_copy_twoL_check_dist_oneL_set_twoL_test_for_second_level_lengthL_test_for_second_level_distL_clip_windowL_wrap_around_windowL_contiguous_in_windowL_do_copyL_test_for_end_of_blockL_invalid_literal_length_codeL_invalid_distance_codeL_invalid_distance_too_farL_break_loopL_break_loop_with_statussks-ecc-0.93/zlib/contrib/masmx64/gvmat64.obj0000644000175000017500000001002710604550750017624 0ustar nachonachod†fÓ×B .textØ´ P`.data@PÀ.debug$S„Œ ,@B.debug$T<È @BH‰|$ÐH‰t$ØH‰\$àH‰l$èD‹ÂL‰d$ðL‰l$ø‹¹ ‹±´‹AL‹™¤;þ|ÁëÿËÁã Ø‹¸‰\$ÀD‹‘œD;ÐDMÐD‰T$ÈL‹QP‹©”NlM‹ÍI÷ÝIƒå‹AD-3ÿ+èD‹™ NïK4E·!C·\ ÿH‹y`‹T$ÀfA;\0ÿ„šD#ÂF·GD;ņnêˆbfA;\0ÿtuD#ÂF·GD;ņIêˆ=fA;\0ÿtPD#ÂF·GD;ņ$êˆfA;\0ÿu‘ë)D#ÂF·GD;ņýêˆñfA;\0ÿ…fÿÿÿfG;$…[ÿÿÿ‰T$ÀK4HºøþÿÿÿÿÿÿI´5K¼ 2:H‹2H3:u&H‹D2H3D:uH‹D2H3D:uHƒÂëØHƒÂHƒÂ©ÿÿu©ÿÿÿÿu HƒÂHÁè f ÀuÁèHƒÂ,HƒÒH:I+Á=}=A;ÃK4H‹y`‹T$Àé&ÿÿÿD‹ØD‰˜;D$È}$J4B·\ÿH‹y`‹T$ÀéÿþÿÿA»D‰˜‹œD;ØANÃH‹t$ØH‹|$ÐH‹\$àH‹l$èL‹d$ðL‹l$øÃ asm686 with masm, optimised assembly code from Brian Raiter, written 1998, converted to amd 64 by Gilles Vollant 2005 Ãó*X:\modifzLib\contrib\masmx64\gvmat64.asmôŒT-`%Ç*”½+UÏ›»òØ„(€±€²€ ³€´€¸€º€»€!Æ€'Ç€-È€0É€6Ê€8Ë€:Ì€=Ô€?Õ€BÖ€D߀Jà€Ná€Uâ€Xã€\ä€aè€eé€kê€pï€sð€vñ€zø€}ù€‚û€„ü€†þ€€€” €˜€ž€¢€¦€¬€²€µ€º€½€Ã€É €Ï#€Õ$€×'€Ú)€ß*€â+€è,€î-€ô0€ú1€ü4€ÿ6€7€8€ 9€:€>€?€!@€#X€&Z€+[€.\€4]€:^€@b€Fc€Le€Qf€Wj€[q€_r€is€qt€yv€}w€Š€…‹€‰Œ€‹Ž€€•€—“€œ”€¡•€£—€§™€©š€­›€±ž€¶Ÿ€¸¡€½£€¿¥€Ã¦€Ç§€Ê¨€Ì«€Ï¬€Ó­€Õ®€Ù²€Ý³€à´€åµ€ç»€ê¼€ì¾€ðÀ€ôÁ€øÂ€ýʀˀ̀ Í€ πрҀӀԀ$Ù€*Ú€1ã€7ä€:å€>ë€Cì€Hí€Mî€Rï€Wð€\õ€×ü€×ý€ñŠ/X:\modifzLib\contrib\masmx64\gvmat64.obj4ÐvMicrosoft (R) Macro Assembler0match_init3××longest_matchLastMatchGoodLookupLoop1LoopEntry1LookupLoop2LoopEntry2LookupLoop4LoopEntry4LookupLoopLoopEntryLookupLoopIsZeroLoopCmpsLeaveLoopCmps16LeaveLoopCmps8LeaveLoopCmpsLenLower32LenLowerLongerMatchLenMaximumLeaveNow` d  ƒ µ ¹ Î Ò ç ë þ    + / A E X \ n r „ ˆ ™  µ ¹ É Í ä è þ    - 1 A E X \ n r òñ@comp.idv}ÿÿ.textØ.data.debug$S„,.debug$T< × $$000000=+²7ÏB×NôYüep#{@…LLoopCmps–©¦­µ±ÃÌLenLowerÓÎýÚ$LeaveNow1ålongest_matchmatch_initLastMatchGoodLookupLoop1LoopEntry1LookupLoop2LoopEntry2LookupLoop4LoopEntry4LookupLoopLoopEntryLookupLoopIsZeroLeaveLoopCmps16LeaveLoopCmps8LeaveLoopCmpsLenLower32LongerMatchLenMaximumsks-ecc-0.93/zlib/contrib/masmx64/gvmat64.asm0000644000175000017500000003530310604550750017636 0ustar nachonacho;uInt longest_match_x64( ; deflate_state *s, ; IPos cur_match); /* current match */ ; gvmat64.asm -- Asm portion of the optimized longest_match for 32 bits x86 ; Copyright (C) 1995-2005 Jean-loup Gailly, Brian Raiter and Gilles Vollant. ; ; File written by Gilles Vollant, by converting to assembly the longest_match ; from Jean-loup Gailly in deflate.c of zLib and infoZip zip. ; ; and by taking inspiration on asm686 with masm, optimised assembly code ; from Brian Raiter, written 1998 ; ; http://www.zlib.net ; http://www.winimage.com/zLibDll ; http://www.muppetlabs.com/~breadbox/software/assembly.html ; ; to compile this file for infozip Zip, I use option: ; ml64.exe /Flgvmat64 /c /Zi /DINFOZIP gvmat64.asm ; ; to compile this file for zLib, I use option: ; ml64.exe /Flgvmat64 /c /Zi gvmat64.asm ; Be carrefull to adapt zlib1222add below to your version of zLib ; (if you use a version of zLib before 1.0.4 or after 1.2.2.2, change ; value of zlib1222add later) ; ; This file compile with Microsoft Macro Assembler (x64) for AMD64 ; ; ml64.exe is given with Visual Studio 2005 and Windows 2003 server DDK ; ; (you can get Windows 2003 server DDK with ml64 and cl for AMD64 from ; http://www.microsoft.com/whdc/devtools/ddk/default.mspx for low price) ; ;uInt longest_match(s, cur_match) ; deflate_state *s; ; IPos cur_match; /* current match */ .code longest_match PROC ;LocalVarsSize equ 88 LocalVarsSize equ 72 ; register used : rax,rbx,rcx,rdx,rsi,rdi,r8,r9,r10,r11,r12 ; free register : r14,r15 ; register can be saved : rsp chainlenwmask equ rsp + 8 - LocalVarsSize ; high word: current chain len ; low word: s->wmask ;window equ rsp + xx - LocalVarsSize ; local copy of s->window ; stored in r10 ;windowbestlen equ rsp + xx - LocalVarsSize ; s->window + bestlen , use r10+r11 ;scanstart equ rsp + xx - LocalVarsSize ; first two bytes of string ; stored in r12w ;scanend equ rsp + xx - LocalVarsSize ; last two bytes of string use ebx ;scanalign equ rsp + xx - LocalVarsSize ; dword-misalignment of string r13 ;bestlen equ rsp + xx - LocalVarsSize ; size of best match so far -> r11d ;scan equ rsp + xx - LocalVarsSize ; ptr to string wanting match -> r9 IFDEF INFOZIP ELSE nicematch equ (rsp + 16 - LocalVarsSize) ; a good enough match size ENDIF save_rdi equ rsp + 24 - LocalVarsSize save_rsi equ rsp + 32 - LocalVarsSize save_rbx equ rsp + 40 - LocalVarsSize save_rbp equ rsp + 48 - LocalVarsSize save_r12 equ rsp + 56 - LocalVarsSize save_r13 equ rsp + 64 - LocalVarsSize ;save_r14 equ rsp + 72 - LocalVarsSize ;save_r15 equ rsp + 80 - LocalVarsSize ; all the +4 offsets are due to the addition of pending_buf_size (in zlib ; in the deflate_state structure since the asm code was first written ; (if you compile with zlib 1.0.4 or older, remove the +4). ; Note : these value are good with a 8 bytes boundary pack structure MAX_MATCH equ 258 MIN_MATCH equ 3 MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1) ;;; Offsets for fields in the deflate_state structure. These numbers ;;; are calculated from the definition of deflate_state, with the ;;; assumption that the compiler will dword-align the fields. (Thus, ;;; changing the definition of deflate_state could easily cause this ;;; program to crash horribly, without so much as a warning at ;;; compile time. Sigh.) ; all the +zlib1222add offsets are due to the addition of fields ; in zlib in the deflate_state structure since the asm code was first written ; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)"). ; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0"). ; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8"). IFDEF INFOZIP _DATA SEGMENT COMM window_size:DWORD ; WMask ; 7fff COMM window:BYTE:010040H COMM prev:WORD:08000H ; MatchLen : unused ; PrevMatch : unused COMM strstart:DWORD COMM match_start:DWORD ; Lookahead : ignore COMM prev_length:DWORD ; PrevLen COMM max_chain_length:DWORD COMM good_match:DWORD COMM nice_match:DWORD prev_ad equ OFFSET prev window_ad equ OFFSET window nicematch equ nice_match _DATA ENDS WMask equ 07fffh ELSE IFNDEF zlib1222add zlib1222add equ 8 ENDIF dsWSize equ 56+zlib1222add+(zlib1222add/2) dsWMask equ 64+zlib1222add+(zlib1222add/2) dsWindow equ 72+zlib1222add dsPrev equ 88+zlib1222add dsMatchLen equ 128+zlib1222add dsPrevMatch equ 132+zlib1222add dsStrStart equ 140+zlib1222add dsMatchStart equ 144+zlib1222add dsLookahead equ 148+zlib1222add dsPrevLen equ 152+zlib1222add dsMaxChainLen equ 156+zlib1222add dsGoodMatch equ 172+zlib1222add dsNiceMatch equ 176+zlib1222add window_size equ [ rcx + dsWSize] WMask equ [ rcx + dsWMask] window_ad equ [ rcx + dsWindow] prev_ad equ [ rcx + dsPrev] strstart equ [ rcx + dsStrStart] match_start equ [ rcx + dsMatchStart] Lookahead equ [ rcx + dsLookahead] ; 0ffffffffh on infozip prev_length equ [ rcx + dsPrevLen] max_chain_length equ [ rcx + dsMaxChainLen] good_match equ [ rcx + dsGoodMatch] nice_match equ [ rcx + dsNiceMatch] ENDIF ; parameter 1 in r8(deflate state s), param 2 in rdx (cur match) ; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and ; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp ; ; All registers must be preserved across the call, except for ; rax, rcx, rdx, r8, r9, r10, and r11, which are scratch. ;;; Save registers that the compiler may be using, and adjust esp to ;;; make room for our stack frame. ;;; Retrieve the function arguments. r8d will hold cur_match ;;; throughout the entire function. edx will hold the pointer to the ;;; deflate_state structure during the function's setup (before ;;; entering the main loop. ; parameter 1 in rcx (deflate_state* s), param 2 in edx -> r8 (cur match) ; this clear high 32 bits of r8, which can be garbage in both r8 and rdx mov [save_rdi],rdi mov [save_rsi],rsi mov [save_rbx],rbx mov [save_rbp],rbp IFDEF INFOZIP mov r8d,ecx ELSE mov r8d,edx ENDIF mov [save_r12],r12 mov [save_r13],r13 ; mov [save_r14],r14 ; mov [save_r15],r15 ;;; uInt wmask = s->w_mask; ;;; unsigned chain_length = s->max_chain_length; ;;; if (s->prev_length >= s->good_match) { ;;; chain_length >>= 2; ;;; } mov edi, prev_length mov esi, good_match mov eax, WMask mov ebx, max_chain_length cmp edi, esi jl LastMatchGood shr ebx, 2 LastMatchGood: ;;; chainlen is decremented once beforehand so that the function can ;;; use the sign flag instead of the zero flag for the exit test. ;;; It is then shifted into the high word, to make room for the wmask ;;; value, which it will always accompany. dec ebx shl ebx, 16 or ebx, eax ;;; on zlib only ;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; IFDEF INFOZIP mov [chainlenwmask], ebx ; on infozip nice_match = [nice_match] ELSE mov eax, nice_match mov [chainlenwmask], ebx mov r10d, Lookahead cmp r10d, eax cmovnl r10d, eax mov [nicematch],r10d ENDIF ;;; register Bytef *scan = s->window + s->strstart; mov r10, window_ad mov ebp, strstart lea r13, [r10 + rbp] ;;; Determine how many bytes the scan ptr is off from being ;;; dword-aligned. mov r9,r13 neg r13 and r13,3 ;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? ;;; s->strstart - (IPos)MAX_DIST(s) : NIL; IFDEF INFOZIP mov eax,07efah ; MAX_DIST = (WSIZE-MIN_LOOKAHEAD) (0x8000-(3+8+1)) ELSE mov eax, window_size sub eax, MIN_LOOKAHEAD ENDIF xor edi,edi sub ebp, eax mov r11d, prev_length cmovng ebp,edi ;;; int best_len = s->prev_length; ;;; Store the sum of s->window + best_len in esi locally, and in esi. lea rsi,[r10+r11] ;;; register ush scan_start = *(ushf*)scan; ;;; register ush scan_end = *(ushf*)(scan+best_len-1); ;;; Posf *prev = s->prev; movzx r12d,word ptr [r9] movzx ebx, word ptr [r9 + r11 - 1] mov rdi, prev_ad ;;; Jump into the main loop. mov edx, [chainlenwmask] cmp bx,word ptr [rsi + r8 - 1] jz LookupLoopIsZero LookupLoop1: and r8d, edx movzx r8d, word ptr [rdi + r8*2] cmp r8d, ebp jbe LeaveNow sub edx, 00010000h js LeaveNow LoopEntry1: cmp bx,word ptr [rsi + r8 - 1] jz LookupLoopIsZero LookupLoop2: and r8d, edx movzx r8d, word ptr [rdi + r8*2] cmp r8d, ebp jbe LeaveNow sub edx, 00010000h js LeaveNow LoopEntry2: cmp bx,word ptr [rsi + r8 - 1] jz LookupLoopIsZero LookupLoop4: and r8d, edx movzx r8d, word ptr [rdi + r8*2] cmp r8d, ebp jbe LeaveNow sub edx, 00010000h js LeaveNow LoopEntry4: cmp bx,word ptr [rsi + r8 - 1] jnz LookupLoop1 jmp LookupLoopIsZero ;;; do { ;;; match = s->window + cur_match; ;;; if (*(ushf*)(match+best_len-1) != scan_end || ;;; *(ushf*)match != scan_start) continue; ;;; [...] ;;; } while ((cur_match = prev[cur_match & wmask]) > limit ;;; && --chain_length != 0); ;;; ;;; Here is the inner loop of the function. The function will spend the ;;; majority of its time in this loop, and majority of that time will ;;; be spent in the first ten instructions. ;;; ;;; Within this loop: ;;; ebx = scanend ;;; r8d = curmatch ;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) ;;; esi = windowbestlen - i.e., (window + bestlen) ;;; edi = prev ;;; ebp = limit LookupLoop: and r8d, edx movzx r8d, word ptr [rdi + r8*2] cmp r8d, ebp jbe LeaveNow sub edx, 00010000h js LeaveNow LoopEntry: cmp bx,word ptr [rsi + r8 - 1] jnz LookupLoop1 LookupLoopIsZero: cmp r12w, word ptr [r10 + r8] jnz LookupLoop1 ;;; Store the current value of chainlen. mov [chainlenwmask], edx ;;; Point edi to the string under scrutiny, and esi to the string we ;;; are hoping to match it up with. In actuality, esi and edi are ;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is ;;; initialized to -(MAX_MATCH_8 - scanalign). lea rsi,[r8+r10] mov rdx, 0fffffffffffffef8h; -(MAX_MATCH_8) lea rsi, [rsi + r13 + 0108h] ;MAX_MATCH_8] lea rdi, [r9 + r13 + 0108h] ;MAX_MATCH_8] prefetcht1 [rsi+rdx] prefetcht1 [rdi+rdx] ;;; Test the strings for equality, 8 bytes at a time. At the end, ;;; adjust rdx so that it is offset to the exact byte that mismatched. ;;; ;;; We already know at this point that the first three bytes of the ;;; strings match each other, and they can be safely passed over before ;;; starting the compare loop. So what this code does is skip over 0-3 ;;; bytes, as much as necessary in order to dword-align the edi ;;; pointer. (rsi will still be misaligned three times out of four.) ;;; ;;; It should be confessed that this loop usually does not represent ;;; much of the total running time. Replacing it with a more ;;; straightforward "rep cmpsb" would not drastically degrade ;;; performance. LoopCmps: mov rax, [rsi + rdx] xor rax, [rdi + rdx] jnz LeaveLoopCmps mov rax, [rsi + rdx + 8] xor rax, [rdi + rdx + 8] jnz LeaveLoopCmps8 mov rax, [rsi + rdx + 8+8] xor rax, [rdi + rdx + 8+8] jnz LeaveLoopCmps16 add rdx,8+8+8 jmp short LoopCmps LeaveLoopCmps16: add rdx,8 LeaveLoopCmps8: add rdx,8 LeaveLoopCmps: test eax, 0000FFFFh jnz LenLower test eax,0ffffffffh jnz LenLower32 add rdx,4 shr rax,32 or ax,ax jnz LenLower LenLower32: shr eax,16 add rdx,2 LenLower: sub al, 1 adc rdx, 0 ;;; Calculate the length of the match. If it is longer than MAX_MATCH, ;;; then automatically accept it as the best possible match and leave. lea rax, [rdi + rdx] sub rax, r9 cmp eax, MAX_MATCH jge LenMaximum ;;; If the length of the match is not longer than the best match we ;;; have so far, then forget it and return to the lookup loop. ;/////////////////////////////////// cmp eax, r11d jg LongerMatch lea rsi,[r10+r11] mov rdi, prev_ad mov edx, [chainlenwmask] jmp LookupLoop ;;; s->match_start = cur_match; ;;; best_len = len; ;;; if (len >= nice_match) break; ;;; scan_end = *(ushf*)(scan+best_len-1); LongerMatch: mov r11d, eax mov match_start, r8d cmp eax, [nicematch] jge LeaveNow lea rsi,[r10+rax] movzx ebx, word ptr [r9 + rax - 1] mov rdi, prev_ad mov edx, [chainlenwmask] jmp LookupLoop ;;; Accept the current string, with the maximum possible length. LenMaximum: mov r11d,MAX_MATCH mov match_start, r8d ;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len; ;;; return s->lookahead; LeaveNow: IFDEF INFOZIP mov eax,r11d ELSE mov eax, Lookahead cmp r11d, eax cmovng eax, r11d ENDIF ;;; Restore the stack and return from whence we came. mov rsi,[save_rsi] mov rdi,[save_rdi] mov rbx,[save_rbx] mov rbp,[save_rbp] mov r12,[save_r12] mov r13,[save_r13] ; mov r14,[save_r14] ; mov r15,[save_r15] ret 0 ; please don't remove this string ! ; Your can freely use gvmat64 in any free or commercial app ; but it is far better don't remove the string in the binary! db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998, converted to amd 64 by Gilles Vollant 2005",0dh,0ah,0 longest_match ENDP match_init PROC ret 0 match_init ENDP END sks-ecc-0.93/zlib/contrib/masmx64/inffas8664.c0000644000175000017500000001664110604550750017612 0ustar nachonacho/* inffas8664.c is a hand tuned assembler version of inffast.c - fast decoding * version for AMD64 on Windows using Microsoft C compiler * * Copyright (C) 1995-2003 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h * * Copyright (C) 2003 Chris Anderson * Please use the copyright conditions above. * * 2005 - Adaptation to Microsoft C Compiler for AMD64 by Gilles Vollant * * inffas8664.c call function inffas8664fnc in inffasx64.asm * inffasx64.asm is automatically convert from AMD64 portion of inffas86.c * * Dec-29-2003 -- I added AMD64 inflate asm support. This version is also * slightly quicker on x86 systems because, instead of using rep movsb to copy * data, it uses rep movsw, which moves data in 2-byte chunks instead of single * bytes. I've tested the AMD64 code on a Fedora Core 1 + the x86_64 updates * from http://fedora.linux.duke.edu/fc1_x86_64 * which is running on an Athlon 64 3000+ / Gigabyte GA-K8VT800M system with * 1GB ram. The 64-bit version is about 4% faster than the 32-bit version, * when decompressing mozilla-source-1.3.tar.gz. * * Mar-13-2003 -- Most of this is derived from inffast.S which is derived from * the gcc -S output of zlib-1.2.0/inffast.c. Zlib-1.2.0 is in beta release at * the moment. I have successfully compiled and tested this code with gcc2.96, * gcc3.2, icc5.0, msvc6.0. It is very close to the speed of inffast.S * compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX * enabled. I will attempt to merge the MMX code into this version. Newer * versions of this and inffast.S can be found at * http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/ * */ #include #include "zutil.h" #include "inftrees.h" #include "inflate.h" #include "inffast.h" /* Mark Adler's comments from inffast.c: */ /* Decode literal, length, and distance codes and write out the resulting literal and match bytes until either not enough input or output is available, an end-of-block is encountered, or a data error is encountered. When large enough input and output buffers are supplied to inflate(), for example, a 16K input buffer and a 64K output buffer, more than 95% of the inflate execution time is spent in this routine. Entry assumptions: state->mode == LEN strm->avail_in >= 6 strm->avail_out >= 258 start >= strm->avail_out state->bits < 8 On return, state->mode is one of: LEN -- ran out of enough output space or enough available input TYPE -- reached end of block code, inflate() to interpret next block BAD -- error in block data Notes: - The maximum input bits used by a length/distance pair is 15 bits for the length code, 5 bits for the length extra, 15 bits for the distance code, and 13 bits for the distance extra. This totals 48 bits, or six bytes. Therefore if strm->avail_in >= 6, then there is enough input to avoid checking for available input while decoding. - The maximum bytes that a single length/distance pair can output is 258 bytes, which is the maximum length that can be coded. inflate_fast() requires strm->avail_out >= 258 for each loop to avoid checking for output space. */ typedef struct inffast_ar { /* 64 32 x86 x86_64 */ /* ar offset register */ /* 0 0 */ void *esp; /* esp save */ /* 8 4 */ void *ebp; /* ebp save */ /* 16 8 */ unsigned char FAR *in; /* esi rsi local strm->next_in */ /* 24 12 */ unsigned char FAR *last; /* r9 while in < last */ /* 32 16 */ unsigned char FAR *out; /* edi rdi local strm->next_out */ /* 40 20 */ unsigned char FAR *beg; /* inflate()'s init next_out */ /* 48 24 */ unsigned char FAR *end; /* r10 while out < end */ /* 56 28 */ unsigned char FAR *window;/* size of window, wsize!=0 */ /* 64 32 */ code const FAR *lcode; /* ebp rbp local strm->lencode */ /* 72 36 */ code const FAR *dcode; /* r11 local strm->distcode */ /* 80 40 */ size_t /*unsigned long */hold; /* edx rdx local strm->hold */ /* 88 44 */ unsigned bits; /* ebx rbx local strm->bits */ /* 92 48 */ unsigned wsize; /* window size */ /* 96 52 */ unsigned write; /* window write index */ /*100 56 */ unsigned lmask; /* r12 mask for lcode */ /*104 60 */ unsigned dmask; /* r13 mask for dcode */ /*108 64 */ unsigned len; /* r14 match length */ /*112 68 */ unsigned dist; /* r15 match distance */ /*116 72 */ unsigned status; /* set when state chng*/ } type_ar; #ifdef ASMINF void inflate_fast(strm, start) z_streamp strm; unsigned start; /* inflate()'s starting value for strm->avail_out */ { struct inflate_state FAR *state; type_ar ar; void inffas8664fnc(struct inffast_ar * par); #if (defined( __GNUC__ ) && defined( __amd64__ ) && ! defined( __i386 )) || (defined(_MSC_VER) && defined(_M_AMD64)) #define PAD_AVAIL_IN 6 #define PAD_AVAIL_OUT 258 #else #define PAD_AVAIL_IN 5 #define PAD_AVAIL_OUT 257 #endif /* copy state to local variables */ state = (struct inflate_state FAR *)strm->state; ar.in = strm->next_in; ar.last = ar.in + (strm->avail_in - PAD_AVAIL_IN); ar.out = strm->next_out; ar.beg = ar.out - (start - strm->avail_out); ar.end = ar.out + (strm->avail_out - PAD_AVAIL_OUT); ar.wsize = state->wsize; ar.write = state->write; ar.window = state->window; ar.hold = state->hold; ar.bits = state->bits; ar.lcode = state->lencode; ar.dcode = state->distcode; ar.lmask = (1U << state->lenbits) - 1; ar.dmask = (1U << state->distbits) - 1; /* decode literals and length/distances until end-of-block or not enough input data or output space */ /* align in on 1/2 hold size boundary */ while (((size_t)(void *)ar.in & (sizeof(ar.hold) / 2 - 1)) != 0) { ar.hold += (unsigned long)*ar.in++ << ar.bits; ar.bits += 8; } inffas8664fnc(&ar); if (ar.status > 1) { if (ar.status == 2) strm->msg = "invalid literal/length code"; else if (ar.status == 3) strm->msg = "invalid distance code"; else strm->msg = "invalid distance too far back"; state->mode = BAD; } else if ( ar.status == 1 ) { state->mode = TYPE; } /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ ar.len = ar.bits >> 3; ar.in -= ar.len; ar.bits -= ar.len << 3; ar.hold &= (1U << ar.bits) - 1; /* update state and return */ strm->next_in = ar.in; strm->next_out = ar.out; strm->avail_in = (unsigned)(ar.in < ar.last ? PAD_AVAIL_IN + (ar.last - ar.in) : PAD_AVAIL_IN - (ar.in - ar.last)); strm->avail_out = (unsigned)(ar.out < ar.end ? PAD_AVAIL_OUT + (ar.end - ar.out) : PAD_AVAIL_OUT - (ar.out - ar.end)); state->hold = (unsigned long)ar.hold; state->bits = ar.bits; return; } #endif sks-ecc-0.93/zlib/contrib/masmx64/bld_ml64.bat0000644000175000017500000000012610604550750017732 0ustar nachonachoml64.exe /Flinffasx64 /c /Zi inffasx64.asm ml64.exe /Flgvmat64 /c /Zi gvmat64.asm sks-ecc-0.93/zlib/contrib/ada/0000755000175000017500000000000010604550750015066 5ustar nachonachosks-ecc-0.93/zlib/contrib/ada/readme.txt0000644000175000017500000000420210604550750017062 0ustar nachonacho ZLib for Ada thick binding (ZLib.Ada) Release 1.3 ZLib.Ada is a thick binding interface to the popular ZLib data compression library, available at http://www.gzip.org/zlib/. It provides Ada-style access to the ZLib C library. Here are the main changes since ZLib.Ada 1.2: - Attension: ZLib.Read generic routine have a initialization requirement for Read_Last parameter now. It is a bit incompartible with previous version, but extends functionality, we could use new parameters Allow_Read_Some and Flush now. - Added Is_Open routines to ZLib and ZLib.Streams packages. - Add pragma Assert to check Stream_Element is 8 bit. - Fix extraction to buffer with exact known decompressed size. Error reported by Steve Sangwine. - Fix definition of ULong (changed to unsigned_long), fix regression on 64 bits computers. Patch provided by Pascal Obry. - Add Status_Error exception definition. - Add pragma Assertion that Ada.Streams.Stream_Element size is 8 bit. How to build ZLib.Ada under GNAT You should have the ZLib library already build on your computer, before building ZLib.Ada. Make the directory of ZLib.Ada sources current and issue the command: gnatmake test -largs -L -lz Or use the GNAT project file build for GNAT 3.15 or later: gnatmake -Pzlib.gpr -L How to build ZLib.Ada under Aonix ObjectAda for Win32 7.2.2 1. Make a project with all *.ads and *.adb files from the distribution. 2. Build the libz.a library from the ZLib C sources. 3. Rename libz.a to z.lib. 4. Add the library z.lib to the project. 5. Add the libc.lib library from the ObjectAda distribution to the project. 6. Build the executable using test.adb as a main procedure. How to use ZLib.Ada The source files test.adb and read.adb are small demo programs that show the main functionality of ZLib.Ada. The routines from the package specifications are commented. Homepage: http://zlib-ada.sourceforge.net/ Author: Dmitriy Anisimkov Contributors: Pascal Obry , Steve Sangwine sks-ecc-0.93/zlib/contrib/ada/zlib-streams.adb0000644000175000017500000001355410604550750020162 0ustar nachonacho---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: zlib-streams.adb,v 1.10 2004/05/31 10:53:40 vagul Exp $ with Ada.Unchecked_Deallocation; package body ZLib.Streams is ----------- -- Close -- ----------- procedure Close (Stream : in out Stream_Type) is procedure Free is new Ada.Unchecked_Deallocation (Stream_Element_Array, Buffer_Access); begin if Stream.Mode = Out_Stream or Stream.Mode = Duplex then -- We should flush the data written by the writer. Flush (Stream, Finish); Close (Stream.Writer); end if; if Stream.Mode = In_Stream or Stream.Mode = Duplex then Close (Stream.Reader); Free (Stream.Buffer); end if; end Close; ------------ -- Create -- ------------ procedure Create (Stream : out Stream_Type; Mode : in Stream_Mode; Back : in Stream_Access; Back_Compressed : in Boolean; Level : in Compression_Level := Default_Compression; Strategy : in Strategy_Type := Default_Strategy; Header : in Header_Type := Default; Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size; Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size) is subtype Buffer_Subtype is Stream_Element_Array (1 .. Read_Buffer_Size); procedure Init_Filter (Filter : in out Filter_Type; Compress : in Boolean); ----------------- -- Init_Filter -- ----------------- procedure Init_Filter (Filter : in out Filter_Type; Compress : in Boolean) is begin if Compress then Deflate_Init (Filter, Level, Strategy, Header => Header); else Inflate_Init (Filter, Header => Header); end if; end Init_Filter; begin Stream.Back := Back; Stream.Mode := Mode; if Mode = Out_Stream or Mode = Duplex then Init_Filter (Stream.Writer, Back_Compressed); Stream.Buffer_Size := Write_Buffer_Size; else Stream.Buffer_Size := 0; end if; if Mode = In_Stream or Mode = Duplex then Init_Filter (Stream.Reader, not Back_Compressed); Stream.Buffer := new Buffer_Subtype; Stream.Rest_First := Stream.Buffer'Last + 1; Stream.Rest_Last := Stream.Buffer'Last; end if; end Create; ----------- -- Flush -- ----------- procedure Flush (Stream : in out Stream_Type; Mode : in Flush_Mode := Sync_Flush) is Buffer : Stream_Element_Array (1 .. Stream.Buffer_Size); Last : Stream_Element_Offset; begin loop Flush (Stream.Writer, Buffer, Last, Mode); Ada.Streams.Write (Stream.Back.all, Buffer (1 .. Last)); exit when Last < Buffer'Last; end loop; end Flush; ------------- -- Is_Open -- ------------- function Is_Open (Stream : Stream_Type) return Boolean is begin return Is_Open (Stream.Reader) or else Is_Open (Stream.Writer); end Is_Open; ---------- -- Read -- ---------- procedure Read (Stream : in out Stream_Type; Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is procedure Read (Item : out Stream_Element_Array; Last : out Stream_Element_Offset); ---------- -- Read -- ---------- procedure Read (Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is begin Ada.Streams.Read (Stream.Back.all, Item, Last); end Read; procedure Read is new ZLib.Read (Read => Read, Buffer => Stream.Buffer.all, Rest_First => Stream.Rest_First, Rest_Last => Stream.Rest_Last); begin Read (Stream.Reader, Item, Last); end Read; ------------------- -- Read_Total_In -- ------------------- function Read_Total_In (Stream : in Stream_Type) return Count is begin return Total_In (Stream.Reader); end Read_Total_In; -------------------- -- Read_Total_Out -- -------------------- function Read_Total_Out (Stream : in Stream_Type) return Count is begin return Total_Out (Stream.Reader); end Read_Total_Out; ----------- -- Write -- ----------- procedure Write (Stream : in out Stream_Type; Item : in Stream_Element_Array) is procedure Write (Item : in Stream_Element_Array); ----------- -- Write -- ----------- procedure Write (Item : in Stream_Element_Array) is begin Ada.Streams.Write (Stream.Back.all, Item); end Write; procedure Write is new ZLib.Write (Write => Write, Buffer_Size => Stream.Buffer_Size); begin Write (Stream.Writer, Item, No_Flush); end Write; -------------------- -- Write_Total_In -- -------------------- function Write_Total_In (Stream : in Stream_Type) return Count is begin return Total_In (Stream.Writer); end Write_Total_In; --------------------- -- Write_Total_Out -- --------------------- function Write_Total_Out (Stream : in Stream_Type) return Count is begin return Total_Out (Stream.Writer); end Write_Total_Out; end ZLib.Streams; sks-ecc-0.93/zlib/contrib/ada/zlib-thin.adb0000644000175000017500000000640110604550750017437 0ustar nachonacho---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: zlib-thin.adb,v 1.8 2003/12/14 18:27:31 vagul Exp $ package body ZLib.Thin is ZLIB_VERSION : constant Chars_Ptr := zlibVersion; Z_Stream_Size : constant Int := Z_Stream'Size / System.Storage_Unit; -------------- -- Avail_In -- -------------- function Avail_In (Strm : in Z_Stream) return UInt is begin return Strm.Avail_In; end Avail_In; --------------- -- Avail_Out -- --------------- function Avail_Out (Strm : in Z_Stream) return UInt is begin return Strm.Avail_Out; end Avail_Out; ------------------ -- Deflate_Init -- ------------------ function Deflate_Init (strm : Z_Streamp; level : Int; method : Int; windowBits : Int; memLevel : Int; strategy : Int) return Int is begin return deflateInit2 (strm, level, method, windowBits, memLevel, strategy, ZLIB_VERSION, Z_Stream_Size); end Deflate_Init; ------------------ -- Inflate_Init -- ------------------ function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int is begin return inflateInit2 (strm, windowBits, ZLIB_VERSION, Z_Stream_Size); end Inflate_Init; ------------------------ -- Last_Error_Message -- ------------------------ function Last_Error_Message (Strm : in Z_Stream) return String is use Interfaces.C.Strings; begin if Strm.msg = Null_Ptr then return ""; else return Value (Strm.msg); end if; end Last_Error_Message; ------------ -- Set_In -- ------------ procedure Set_In (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt) is begin Strm.Next_In := Buffer; Strm.Avail_In := Size; end Set_In; ------------------ -- Set_Mem_Func -- ------------------ procedure Set_Mem_Func (Strm : in out Z_Stream; Opaque : in Voidp; Alloc : in alloc_func; Free : in free_func) is begin Strm.opaque := Opaque; Strm.zalloc := Alloc; Strm.zfree := Free; end Set_Mem_Func; ------------- -- Set_Out -- ------------- procedure Set_Out (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt) is begin Strm.Next_Out := Buffer; Strm.Avail_Out := Size; end Set_Out; -------------- -- Total_In -- -------------- function Total_In (Strm : in Z_Stream) return ULong is begin return Strm.Total_In; end Total_In; --------------- -- Total_Out -- --------------- function Total_Out (Strm : in Z_Stream) return ULong is begin return Strm.Total_Out; end Total_Out; end ZLib.Thin; sks-ecc-0.93/zlib/contrib/ada/read.adb0000644000175000017500000001023010604550750016445 0ustar nachonacho---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: read.adb,v 1.8 2004/05/31 10:53:40 vagul Exp $ -- Test/demo program for the generic read interface. with Ada.Numerics.Discrete_Random; with Ada.Streams; with Ada.Text_IO; with ZLib; procedure Read is use Ada.Streams; ------------------------------------ -- Test configuration parameters -- ------------------------------------ File_Size : Stream_Element_Offset := 100_000; Continuous : constant Boolean := False; -- If this constant is True, the test would be repeated again and again, -- with increment File_Size for every iteration. Header : constant ZLib.Header_Type := ZLib.Default; -- Do not use Header other than Default in ZLib versions 1.1.4 and older. Init_Random : constant := 8; -- We are using the same random sequence, in case of we catch bug, -- so we would be able to reproduce it. -- End -- Pack_Size : Stream_Element_Offset; Offset : Stream_Element_Offset; Filter : ZLib.Filter_Type; subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#; package Random_Elements is new Ada.Numerics.Discrete_Random (Visible_Symbols); Gen : Random_Elements.Generator; Period : constant Stream_Element_Offset := 200; -- Period constant variable for random generator not to be very random. -- Bigger period, harder random. Read_Buffer : Stream_Element_Array (1 .. 2048); Read_First : Stream_Element_Offset; Read_Last : Stream_Element_Offset; procedure Reset; procedure Read (Item : out Stream_Element_Array; Last : out Stream_Element_Offset); -- this procedure is for generic instantiation of -- ZLib.Read -- reading data from the File_In. procedure Read is new ZLib.Read (Read, Read_Buffer, Rest_First => Read_First, Rest_Last => Read_Last); ---------- -- Read -- ---------- procedure Read (Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is begin Last := Stream_Element_Offset'Min (Item'Last, Item'First + File_Size - Offset); for J in Item'First .. Last loop if J < Item'First + Period then Item (J) := Random_Elements.Random (Gen); else Item (J) := Item (J - Period); end if; Offset := Offset + 1; end loop; end Read; ----------- -- Reset -- ----------- procedure Reset is begin Random_Elements.Reset (Gen, Init_Random); Pack_Size := 0; Offset := 1; Read_First := Read_Buffer'Last + 1; Read_Last := Read_Buffer'Last; end Reset; begin Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version); loop for Level in ZLib.Compression_Level'Range loop Ada.Text_IO.Put ("Level =" & ZLib.Compression_Level'Image (Level)); -- Deflate using generic instantiation. ZLib.Deflate_Init (Filter, Level, Header => Header); Reset; Ada.Text_IO.Put (Stream_Element_Offset'Image (File_Size) & " ->"); loop declare Buffer : Stream_Element_Array (1 .. 1024); Last : Stream_Element_Offset; begin Read (Filter, Buffer, Last); Pack_Size := Pack_Size + Last - Buffer'First + 1; exit when Last < Buffer'Last; end; end loop; Ada.Text_IO.Put_Line (Stream_Element_Offset'Image (Pack_Size)); ZLib.Close (Filter); end loop; exit when not Continuous; File_Size := File_Size + 1; end loop; end Read; sks-ecc-0.93/zlib/contrib/ada/zlib.adb0000644000175000017500000004766010604550750016513 0ustar nachonacho---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2004 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: zlib.adb,v 1.31 2004/09/06 06:53:19 vagul Exp $ with Ada.Exceptions; with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; with Interfaces.C.Strings; with ZLib.Thin; package body ZLib is use type Thin.Int; type Z_Stream is new Thin.Z_Stream; type Return_Code_Enum is (OK, STREAM_END, NEED_DICT, ERRNO, STREAM_ERROR, DATA_ERROR, MEM_ERROR, BUF_ERROR, VERSION_ERROR); type Flate_Step_Function is access function (Strm : in Thin.Z_Streamp; Flush : in Thin.Int) return Thin.Int; pragma Convention (C, Flate_Step_Function); type Flate_End_Function is access function (Ctrm : in Thin.Z_Streamp) return Thin.Int; pragma Convention (C, Flate_End_Function); type Flate_Type is record Step : Flate_Step_Function; Done : Flate_End_Function; end record; subtype Footer_Array is Stream_Element_Array (1 .. 8); Simple_GZip_Header : constant Stream_Element_Array (1 .. 10) := (16#1f#, 16#8b#, -- Magic header 16#08#, -- Z_DEFLATED 16#00#, -- Flags 16#00#, 16#00#, 16#00#, 16#00#, -- Time 16#00#, -- XFlags 16#03# -- OS code ); -- The simplest gzip header is not for informational, but just for -- gzip format compatibility. -- Note that some code below is using assumption -- Simple_GZip_Header'Last > Footer_Array'Last, so do not make -- Simple_GZip_Header'Last <= Footer_Array'Last. Return_Code : constant array (Thin.Int range <>) of Return_Code_Enum := (0 => OK, 1 => STREAM_END, 2 => NEED_DICT, -1 => ERRNO, -2 => STREAM_ERROR, -3 => DATA_ERROR, -4 => MEM_ERROR, -5 => BUF_ERROR, -6 => VERSION_ERROR); Flate : constant array (Boolean) of Flate_Type := (True => (Step => Thin.Deflate'Access, Done => Thin.DeflateEnd'Access), False => (Step => Thin.Inflate'Access, Done => Thin.InflateEnd'Access)); Flush_Finish : constant array (Boolean) of Flush_Mode := (True => Finish, False => No_Flush); procedure Raise_Error (Stream : in Z_Stream); pragma Inline (Raise_Error); procedure Raise_Error (Message : in String); pragma Inline (Raise_Error); procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int); procedure Free is new Ada.Unchecked_Deallocation (Z_Stream, Z_Stream_Access); function To_Thin_Access is new Ada.Unchecked_Conversion (Z_Stream_Access, Thin.Z_Streamp); procedure Translate_GZip (Filter : in out Filter_Type; In_Data : in Ada.Streams.Stream_Element_Array; In_Last : out Ada.Streams.Stream_Element_Offset; Out_Data : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Flush : in Flush_Mode); -- Separate translate routine for make gzip header. procedure Translate_Auto (Filter : in out Filter_Type; In_Data : in Ada.Streams.Stream_Element_Array; In_Last : out Ada.Streams.Stream_Element_Offset; Out_Data : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Flush : in Flush_Mode); -- translate routine without additional headers. ----------------- -- Check_Error -- ----------------- procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int) is use type Thin.Int; begin if Code /= Thin.Z_OK then Raise_Error (Return_Code_Enum'Image (Return_Code (Code)) & ": " & Last_Error_Message (Stream)); end if; end Check_Error; ----------- -- Close -- ----------- procedure Close (Filter : in out Filter_Type; Ignore_Error : in Boolean := False) is Code : Thin.Int; begin if not Ignore_Error and then not Is_Open (Filter) then raise Status_Error; end if; Code := Flate (Filter.Compression).Done (To_Thin_Access (Filter.Strm)); if Ignore_Error or else Code = Thin.Z_OK then Free (Filter.Strm); else declare Error_Message : constant String := Last_Error_Message (Filter.Strm.all); begin Free (Filter.Strm); Ada.Exceptions.Raise_Exception (ZLib_Error'Identity, Return_Code_Enum'Image (Return_Code (Code)) & ": " & Error_Message); end; end if; end Close; ----------- -- CRC32 -- ----------- function CRC32 (CRC : in Unsigned_32; Data : in Ada.Streams.Stream_Element_Array) return Unsigned_32 is use Thin; begin return Unsigned_32 (crc32 (ULong (CRC), Data'Address, Data'Length)); end CRC32; procedure CRC32 (CRC : in out Unsigned_32; Data : in Ada.Streams.Stream_Element_Array) is begin CRC := CRC32 (CRC, Data); end CRC32; ------------------ -- Deflate_Init -- ------------------ procedure Deflate_Init (Filter : in out Filter_Type; Level : in Compression_Level := Default_Compression; Strategy : in Strategy_Type := Default_Strategy; Method : in Compression_Method := Deflated; Window_Bits : in Window_Bits_Type := Default_Window_Bits; Memory_Level : in Memory_Level_Type := Default_Memory_Level; Header : in Header_Type := Default) is use type Thin.Int; Win_Bits : Thin.Int := Thin.Int (Window_Bits); begin if Is_Open (Filter) then raise Status_Error; end if; -- We allow ZLib to make header only in case of default header type. -- Otherwise we would either do header by ourselfs, or do not do -- header at all. if Header = None or else Header = GZip then Win_Bits := -Win_Bits; end if; -- For the GZip CRC calculation and make headers. if Header = GZip then Filter.CRC := 0; Filter.Offset := Simple_GZip_Header'First; else Filter.Offset := Simple_GZip_Header'Last + 1; end if; Filter.Strm := new Z_Stream; Filter.Compression := True; Filter.Stream_End := False; Filter.Header := Header; if Thin.Deflate_Init (To_Thin_Access (Filter.Strm), Level => Thin.Int (Level), method => Thin.Int (Method), windowBits => Win_Bits, memLevel => Thin.Int (Memory_Level), strategy => Thin.Int (Strategy)) /= Thin.Z_OK then Raise_Error (Filter.Strm.all); end if; end Deflate_Init; ----------- -- Flush -- ----------- procedure Flush (Filter : in out Filter_Type; Out_Data : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Flush : in Flush_Mode) is No_Data : Stream_Element_Array := (1 .. 0 => 0); Last : Stream_Element_Offset; begin Translate (Filter, No_Data, Last, Out_Data, Out_Last, Flush); end Flush; ----------------------- -- Generic_Translate -- ----------------------- procedure Generic_Translate (Filter : in out ZLib.Filter_Type; In_Buffer_Size : in Integer := Default_Buffer_Size; Out_Buffer_Size : in Integer := Default_Buffer_Size) is In_Buffer : Stream_Element_Array (1 .. Stream_Element_Offset (In_Buffer_Size)); Out_Buffer : Stream_Element_Array (1 .. Stream_Element_Offset (Out_Buffer_Size)); Last : Stream_Element_Offset; In_Last : Stream_Element_Offset; In_First : Stream_Element_Offset; Out_Last : Stream_Element_Offset; begin Main : loop Data_In (In_Buffer, Last); In_First := In_Buffer'First; loop Translate (Filter => Filter, In_Data => In_Buffer (In_First .. Last), In_Last => In_Last, Out_Data => Out_Buffer, Out_Last => Out_Last, Flush => Flush_Finish (Last < In_Buffer'First)); if Out_Buffer'First <= Out_Last then Data_Out (Out_Buffer (Out_Buffer'First .. Out_Last)); end if; exit Main when Stream_End (Filter); -- The end of in buffer. exit when In_Last = Last; In_First := In_Last + 1; end loop; end loop Main; end Generic_Translate; ------------------ -- Inflate_Init -- ------------------ procedure Inflate_Init (Filter : in out Filter_Type; Window_Bits : in Window_Bits_Type := Default_Window_Bits; Header : in Header_Type := Default) is use type Thin.Int; Win_Bits : Thin.Int := Thin.Int (Window_Bits); procedure Check_Version; -- Check the latest header types compatibility. procedure Check_Version is begin if Version <= "1.1.4" then Raise_Error ("Inflate header type " & Header_Type'Image (Header) & " incompatible with ZLib version " & Version); end if; end Check_Version; begin if Is_Open (Filter) then raise Status_Error; end if; case Header is when None => Check_Version; -- Inflate data without headers determined -- by negative Win_Bits. Win_Bits := -Win_Bits; when GZip => Check_Version; -- Inflate gzip data defined by flag 16. Win_Bits := Win_Bits + 16; when Auto => Check_Version; -- Inflate with automatic detection -- of gzip or native header defined by flag 32. Win_Bits := Win_Bits + 32; when Default => null; end case; Filter.Strm := new Z_Stream; Filter.Compression := False; Filter.Stream_End := False; Filter.Header := Header; if Thin.Inflate_Init (To_Thin_Access (Filter.Strm), Win_Bits) /= Thin.Z_OK then Raise_Error (Filter.Strm.all); end if; end Inflate_Init; ------------- -- Is_Open -- ------------- function Is_Open (Filter : in Filter_Type) return Boolean is begin return Filter.Strm /= null; end Is_Open; ----------------- -- Raise_Error -- ----------------- procedure Raise_Error (Message : in String) is begin Ada.Exceptions.Raise_Exception (ZLib_Error'Identity, Message); end Raise_Error; procedure Raise_Error (Stream : in Z_Stream) is begin Raise_Error (Last_Error_Message (Stream)); end Raise_Error; ---------- -- Read -- ---------- procedure Read (Filter : in out Filter_Type; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; Flush : in Flush_Mode := No_Flush) is In_Last : Stream_Element_Offset; Item_First : Ada.Streams.Stream_Element_Offset := Item'First; V_Flush : Flush_Mode := Flush; begin pragma Assert (Rest_First in Buffer'First .. Buffer'Last + 1); pragma Assert (Rest_Last in Buffer'First - 1 .. Buffer'Last); loop if Rest_Last = Buffer'First - 1 then V_Flush := Finish; elsif Rest_First > Rest_Last then Read (Buffer, Rest_Last); Rest_First := Buffer'First; if Rest_Last < Buffer'First then V_Flush := Finish; end if; end if; Translate (Filter => Filter, In_Data => Buffer (Rest_First .. Rest_Last), In_Last => In_Last, Out_Data => Item (Item_First .. Item'Last), Out_Last => Last, Flush => V_Flush); Rest_First := In_Last + 1; exit when Stream_End (Filter) or else Last = Item'Last or else (Last >= Item'First and then Allow_Read_Some); Item_First := Last + 1; end loop; end Read; ---------------- -- Stream_End -- ---------------- function Stream_End (Filter : in Filter_Type) return Boolean is begin if Filter.Header = GZip and Filter.Compression then return Filter.Stream_End and then Filter.Offset = Footer_Array'Last + 1; else return Filter.Stream_End; end if; end Stream_End; -------------- -- Total_In -- -------------- function Total_In (Filter : in Filter_Type) return Count is begin return Count (Thin.Total_In (To_Thin_Access (Filter.Strm).all)); end Total_In; --------------- -- Total_Out -- --------------- function Total_Out (Filter : in Filter_Type) return Count is begin return Count (Thin.Total_Out (To_Thin_Access (Filter.Strm).all)); end Total_Out; --------------- -- Translate -- --------------- procedure Translate (Filter : in out Filter_Type; In_Data : in Ada.Streams.Stream_Element_Array; In_Last : out Ada.Streams.Stream_Element_Offset; Out_Data : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Flush : in Flush_Mode) is begin if Filter.Header = GZip and then Filter.Compression then Translate_GZip (Filter => Filter, In_Data => In_Data, In_Last => In_Last, Out_Data => Out_Data, Out_Last => Out_Last, Flush => Flush); else Translate_Auto (Filter => Filter, In_Data => In_Data, In_Last => In_Last, Out_Data => Out_Data, Out_Last => Out_Last, Flush => Flush); end if; end Translate; -------------------- -- Translate_Auto -- -------------------- procedure Translate_Auto (Filter : in out Filter_Type; In_Data : in Ada.Streams.Stream_Element_Array; In_Last : out Ada.Streams.Stream_Element_Offset; Out_Data : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Flush : in Flush_Mode) is use type Thin.Int; Code : Thin.Int; begin if not Is_Open (Filter) then raise Status_Error; end if; if Out_Data'Length = 0 and then In_Data'Length = 0 then raise Constraint_Error; end if; Set_Out (Filter.Strm.all, Out_Data'Address, Out_Data'Length); Set_In (Filter.Strm.all, In_Data'Address, In_Data'Length); Code := Flate (Filter.Compression).Step (To_Thin_Access (Filter.Strm), Thin.Int (Flush)); if Code = Thin.Z_STREAM_END then Filter.Stream_End := True; else Check_Error (Filter.Strm.all, Code); end if; In_Last := In_Data'Last - Stream_Element_Offset (Avail_In (Filter.Strm.all)); Out_Last := Out_Data'Last - Stream_Element_Offset (Avail_Out (Filter.Strm.all)); end Translate_Auto; -------------------- -- Translate_GZip -- -------------------- procedure Translate_GZip (Filter : in out Filter_Type; In_Data : in Ada.Streams.Stream_Element_Array; In_Last : out Ada.Streams.Stream_Element_Offset; Out_Data : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Flush : in Flush_Mode) is Out_First : Stream_Element_Offset; procedure Add_Data (Data : in Stream_Element_Array); -- Add data to stream from the Filter.Offset till necessary, -- used for add gzip headr/footer. procedure Put_32 (Item : in out Stream_Element_Array; Data : in Unsigned_32); pragma Inline (Put_32); -------------- -- Add_Data -- -------------- procedure Add_Data (Data : in Stream_Element_Array) is Data_First : Stream_Element_Offset renames Filter.Offset; Data_Last : Stream_Element_Offset; Data_Len : Stream_Element_Offset; -- -1 Out_Len : Stream_Element_Offset; -- -1 begin Out_First := Out_Last + 1; if Data_First > Data'Last then return; end if; Data_Len := Data'Last - Data_First; Out_Len := Out_Data'Last - Out_First; if Data_Len <= Out_Len then Out_Last := Out_First + Data_Len; Data_Last := Data'Last; else Out_Last := Out_Data'Last; Data_Last := Data_First + Out_Len; end if; Out_Data (Out_First .. Out_Last) := Data (Data_First .. Data_Last); Data_First := Data_Last + 1; Out_First := Out_Last + 1; end Add_Data; ------------ -- Put_32 -- ------------ procedure Put_32 (Item : in out Stream_Element_Array; Data : in Unsigned_32) is D : Unsigned_32 := Data; begin for J in Item'First .. Item'First + 3 loop Item (J) := Stream_Element (D and 16#FF#); D := Shift_Right (D, 8); end loop; end Put_32; begin Out_Last := Out_Data'First - 1; if not Filter.Stream_End then Add_Data (Simple_GZip_Header); Translate_Auto (Filter => Filter, In_Data => In_Data, In_Last => In_Last, Out_Data => Out_Data (Out_First .. Out_Data'Last), Out_Last => Out_Last, Flush => Flush); CRC32 (Filter.CRC, In_Data (In_Data'First .. In_Last)); end if; if Filter.Stream_End and then Out_Last <= Out_Data'Last then -- This detection method would work only when -- Simple_GZip_Header'Last > Footer_Array'Last if Filter.Offset = Simple_GZip_Header'Last + 1 then Filter.Offset := Footer_Array'First; end if; declare Footer : Footer_Array; begin Put_32 (Footer, Filter.CRC); Put_32 (Footer (Footer'First + 4 .. Footer'Last), Unsigned_32 (Total_In (Filter))); Add_Data (Footer); end; end if; end Translate_GZip; ------------- -- Version -- ------------- function Version return String is begin return Interfaces.C.Strings.Value (Thin.zlibVersion); end Version; ----------- -- Write -- ----------- procedure Write (Filter : in out Filter_Type; Item : in Ada.Streams.Stream_Element_Array; Flush : in Flush_Mode := No_Flush) is Buffer : Stream_Element_Array (1 .. Buffer_Size); In_Last : Stream_Element_Offset; Out_Last : Stream_Element_Offset; In_First : Stream_Element_Offset := Item'First; begin if Item'Length = 0 and Flush = No_Flush then return; end if; loop Translate (Filter => Filter, In_Data => Item (In_First .. Item'Last), In_Last => In_Last, Out_Data => Buffer, Out_Last => Out_Last, Flush => Flush); if Out_Last >= Buffer'First then Write (Buffer (1 .. Out_Last)); end if; exit when In_Last = Item'Last or Stream_End (Filter); In_First := In_Last + 1; end loop; end Write; end ZLib; sks-ecc-0.93/zlib/contrib/ada/test.adb0000644000175000017500000003157410604550750016527 0ustar nachonacho---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: test.adb,v 1.17 2003/08/12 12:13:30 vagul Exp $ -- The program has a few aims. -- 1. Test ZLib.Ada95 thick binding functionality. -- 2. Show the example of use main functionality of the ZLib.Ada95 binding. -- 3. Build this program automatically compile all ZLib.Ada95 packages under -- GNAT Ada95 compiler. with ZLib.Streams; with Ada.Streams.Stream_IO; with Ada.Numerics.Discrete_Random; with Ada.Text_IO; with Ada.Calendar; procedure Test is use Ada.Streams; use Stream_IO; ------------------------------------ -- Test configuration parameters -- ------------------------------------ File_Size : Count := 100_000; Continuous : constant Boolean := False; Header : constant ZLib.Header_Type := ZLib.Default; -- ZLib.None; -- ZLib.Auto; -- ZLib.GZip; -- Do not use Header other then Default in ZLib versions 1.1.4 -- and older. Strategy : constant ZLib.Strategy_Type := ZLib.Default_Strategy; Init_Random : constant := 10; -- End -- In_File_Name : constant String := "testzlib.in"; -- Name of the input file Z_File_Name : constant String := "testzlib.zlb"; -- Name of the compressed file. Out_File_Name : constant String := "testzlib.out"; -- Name of the decompressed file. File_In : File_Type; File_Out : File_Type; File_Back : File_Type; File_Z : ZLib.Streams.Stream_Type; Filter : ZLib.Filter_Type; Time_Stamp : Ada.Calendar.Time; procedure Generate_File; -- Generate file of spetsified size with some random data. -- The random data is repeatable, for the good compression. procedure Compare_Streams (Left, Right : in out Root_Stream_Type'Class); -- The procedure compearing data in 2 streams. -- It is for compare data before and after compression/decompression. procedure Compare_Files (Left, Right : String); -- Compare files. Based on the Compare_Streams. procedure Copy_Streams (Source, Target : in out Root_Stream_Type'Class; Buffer_Size : in Stream_Element_Offset := 1024); -- Copying data from one stream to another. It is for test stream -- interface of the library. procedure Data_In (Item : out Stream_Element_Array; Last : out Stream_Element_Offset); -- this procedure is for generic instantiation of -- ZLib.Generic_Translate. -- reading data from the File_In. procedure Data_Out (Item : in Stream_Element_Array); -- this procedure is for generic instantiation of -- ZLib.Generic_Translate. -- writing data to the File_Out. procedure Stamp; -- Store the timestamp to the local variable. procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count); -- Print the time statistic with the message. procedure Translate is new ZLib.Generic_Translate (Data_In => Data_In, Data_Out => Data_Out); -- This procedure is moving data from File_In to File_Out -- with compression or decompression, depend on initialization of -- Filter parameter. ------------------- -- Compare_Files -- ------------------- procedure Compare_Files (Left, Right : String) is Left_File, Right_File : File_Type; begin Open (Left_File, In_File, Left); Open (Right_File, In_File, Right); Compare_Streams (Stream (Left_File).all, Stream (Right_File).all); Close (Left_File); Close (Right_File); end Compare_Files; --------------------- -- Compare_Streams -- --------------------- procedure Compare_Streams (Left, Right : in out Ada.Streams.Root_Stream_Type'Class) is Left_Buffer, Right_Buffer : Stream_Element_Array (0 .. 16#FFF#); Left_Last, Right_Last : Stream_Element_Offset; begin loop Read (Left, Left_Buffer, Left_Last); Read (Right, Right_Buffer, Right_Last); if Left_Last /= Right_Last then Ada.Text_IO.Put_Line ("Compare error :" & Stream_Element_Offset'Image (Left_Last) & " /= " & Stream_Element_Offset'Image (Right_Last)); raise Constraint_Error; elsif Left_Buffer (0 .. Left_Last) /= Right_Buffer (0 .. Right_Last) then Ada.Text_IO.Put_Line ("ERROR: IN and OUT files is not equal."); raise Constraint_Error; end if; exit when Left_Last < Left_Buffer'Last; end loop; end Compare_Streams; ------------------ -- Copy_Streams -- ------------------ procedure Copy_Streams (Source, Target : in out Ada.Streams.Root_Stream_Type'Class; Buffer_Size : in Stream_Element_Offset := 1024) is Buffer : Stream_Element_Array (1 .. Buffer_Size); Last : Stream_Element_Offset; begin loop Read (Source, Buffer, Last); Write (Target, Buffer (1 .. Last)); exit when Last < Buffer'Last; end loop; end Copy_Streams; ------------- -- Data_In -- ------------- procedure Data_In (Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is begin Read (File_In, Item, Last); end Data_In; -------------- -- Data_Out -- -------------- procedure Data_Out (Item : in Stream_Element_Array) is begin Write (File_Out, Item); end Data_Out; ------------------- -- Generate_File -- ------------------- procedure Generate_File is subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#; package Random_Elements is new Ada.Numerics.Discrete_Random (Visible_Symbols); Gen : Random_Elements.Generator; Buffer : Stream_Element_Array := (1 .. 77 => 16#20#) & 10; Buffer_Count : constant Count := File_Size / Buffer'Length; -- Number of same buffers in the packet. Density : constant Count := 30; -- from 0 to Buffer'Length - 2; procedure Fill_Buffer (J, D : in Count); -- Change the part of the buffer. ----------------- -- Fill_Buffer -- ----------------- procedure Fill_Buffer (J, D : in Count) is begin for K in 0 .. D loop Buffer (Stream_Element_Offset ((J + K) mod (Buffer'Length - 1) + 1)) := Random_Elements.Random (Gen); end loop; end Fill_Buffer; begin Random_Elements.Reset (Gen, Init_Random); Create (File_In, Out_File, In_File_Name); Fill_Buffer (1, Buffer'Length - 2); for J in 1 .. Buffer_Count loop Write (File_In, Buffer); Fill_Buffer (J, Density); end loop; -- fill remain size. Write (File_In, Buffer (1 .. Stream_Element_Offset (File_Size - Buffer'Length * Buffer_Count))); Flush (File_In); Close (File_In); end Generate_File; --------------------- -- Print_Statistic -- --------------------- procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count) is use Ada.Calendar; use Ada.Text_IO; package Count_IO is new Integer_IO (ZLib.Count); Curr_Dur : Duration := Clock - Time_Stamp; begin Put (Msg); Set_Col (20); Ada.Text_IO.Put ("size ="); Count_IO.Put (Data_Size, Width => Stream_IO.Count'Image (File_Size)'Length); Put_Line (" duration =" & Duration'Image (Curr_Dur)); end Print_Statistic; ----------- -- Stamp -- ----------- procedure Stamp is begin Time_Stamp := Ada.Calendar.Clock; end Stamp; begin Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version); loop Generate_File; for Level in ZLib.Compression_Level'Range loop Ada.Text_IO.Put_Line ("Level =" & ZLib.Compression_Level'Image (Level)); -- Test generic interface. Open (File_In, In_File, In_File_Name); Create (File_Out, Out_File, Z_File_Name); Stamp; -- Deflate using generic instantiation. ZLib.Deflate_Init (Filter => Filter, Level => Level, Strategy => Strategy, Header => Header); Translate (Filter); Print_Statistic ("Generic compress", ZLib.Total_Out (Filter)); ZLib.Close (Filter); Close (File_In); Close (File_Out); Open (File_In, In_File, Z_File_Name); Create (File_Out, Out_File, Out_File_Name); Stamp; -- Inflate using generic instantiation. ZLib.Inflate_Init (Filter, Header => Header); Translate (Filter); Print_Statistic ("Generic decompress", ZLib.Total_Out (Filter)); ZLib.Close (Filter); Close (File_In); Close (File_Out); Compare_Files (In_File_Name, Out_File_Name); -- Test stream interface. -- Compress to the back stream. Open (File_In, In_File, In_File_Name); Create (File_Back, Out_File, Z_File_Name); Stamp; ZLib.Streams.Create (Stream => File_Z, Mode => ZLib.Streams.Out_Stream, Back => ZLib.Streams.Stream_Access (Stream (File_Back)), Back_Compressed => True, Level => Level, Strategy => Strategy, Header => Header); Copy_Streams (Source => Stream (File_In).all, Target => File_Z); -- Flushing internal buffers to the back stream. ZLib.Streams.Flush (File_Z, ZLib.Finish); Print_Statistic ("Write compress", ZLib.Streams.Write_Total_Out (File_Z)); ZLib.Streams.Close (File_Z); Close (File_In); Close (File_Back); -- Compare reading from original file and from -- decompression stream. Open (File_In, In_File, In_File_Name); Open (File_Back, In_File, Z_File_Name); ZLib.Streams.Create (Stream => File_Z, Mode => ZLib.Streams.In_Stream, Back => ZLib.Streams.Stream_Access (Stream (File_Back)), Back_Compressed => True, Header => Header); Stamp; Compare_Streams (Stream (File_In).all, File_Z); Print_Statistic ("Read decompress", ZLib.Streams.Read_Total_Out (File_Z)); ZLib.Streams.Close (File_Z); Close (File_In); Close (File_Back); -- Compress by reading from compression stream. Open (File_Back, In_File, In_File_Name); Create (File_Out, Out_File, Z_File_Name); ZLib.Streams.Create (Stream => File_Z, Mode => ZLib.Streams.In_Stream, Back => ZLib.Streams.Stream_Access (Stream (File_Back)), Back_Compressed => False, Level => Level, Strategy => Strategy, Header => Header); Stamp; Copy_Streams (Source => File_Z, Target => Stream (File_Out).all); Print_Statistic ("Read compress", ZLib.Streams.Read_Total_Out (File_Z)); ZLib.Streams.Close (File_Z); Close (File_Out); Close (File_Back); -- Decompress to decompression stream. Open (File_In, In_File, Z_File_Name); Create (File_Back, Out_File, Out_File_Name); ZLib.Streams.Create (Stream => File_Z, Mode => ZLib.Streams.Out_Stream, Back => ZLib.Streams.Stream_Access (Stream (File_Back)), Back_Compressed => False, Header => Header); Stamp; Copy_Streams (Source => Stream (File_In).all, Target => File_Z); Print_Statistic ("Write decompress", ZLib.Streams.Write_Total_Out (File_Z)); ZLib.Streams.Close (File_Z); Close (File_In); Close (File_Back); Compare_Files (In_File_Name, Out_File_Name); end loop; Ada.Text_IO.Put_Line (Count'Image (File_Size) & " Ok."); exit when not Continuous; File_Size := File_Size + 1; end loop; end Test; sks-ecc-0.93/zlib/contrib/ada/zlib-thin.ads0000644000175000017500000003671310604550750017471 0ustar nachonacho---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: zlib-thin.ads,v 1.11 2004/07/23 06:33:11 vagul Exp $ with Interfaces.C.Strings; with System; private package ZLib.Thin is -- From zconf.h MAX_MEM_LEVEL : constant := 9; -- zconf.h:105 -- zconf.h:105 MAX_WBITS : constant := 15; -- zconf.h:115 -- 32K LZ77 window -- zconf.h:115 SEEK_SET : constant := 8#0000#; -- zconf.h:244 -- Seek from beginning of file. -- zconf.h:244 SEEK_CUR : constant := 1; -- zconf.h:245 -- Seek from current position. -- zconf.h:245 SEEK_END : constant := 2; -- zconf.h:246 -- Set file pointer to EOF plus "offset" -- zconf.h:246 type Byte is new Interfaces.C.unsigned_char; -- 8 bits -- zconf.h:214 type UInt is new Interfaces.C.unsigned; -- 16 bits or more -- zconf.h:216 type Int is new Interfaces.C.int; type ULong is new Interfaces.C.unsigned_long; -- 32 bits or more -- zconf.h:217 subtype Chars_Ptr is Interfaces.C.Strings.chars_ptr; type ULong_Access is access ULong; type Int_Access is access Int; subtype Voidp is System.Address; -- zconf.h:232 subtype Byte_Access is Voidp; Nul : constant Voidp := System.Null_Address; -- end from zconf Z_NO_FLUSH : constant := 8#0000#; -- zlib.h:125 -- zlib.h:125 Z_PARTIAL_FLUSH : constant := 1; -- zlib.h:126 -- will be removed, use -- Z_SYNC_FLUSH instead -- zlib.h:126 Z_SYNC_FLUSH : constant := 2; -- zlib.h:127 -- zlib.h:127 Z_FULL_FLUSH : constant := 3; -- zlib.h:128 -- zlib.h:128 Z_FINISH : constant := 4; -- zlib.h:129 -- zlib.h:129 Z_OK : constant := 8#0000#; -- zlib.h:132 -- zlib.h:132 Z_STREAM_END : constant := 1; -- zlib.h:133 -- zlib.h:133 Z_NEED_DICT : constant := 2; -- zlib.h:134 -- zlib.h:134 Z_ERRNO : constant := -1; -- zlib.h:135 -- zlib.h:135 Z_STREAM_ERROR : constant := -2; -- zlib.h:136 -- zlib.h:136 Z_DATA_ERROR : constant := -3; -- zlib.h:137 -- zlib.h:137 Z_MEM_ERROR : constant := -4; -- zlib.h:138 -- zlib.h:138 Z_BUF_ERROR : constant := -5; -- zlib.h:139 -- zlib.h:139 Z_VERSION_ERROR : constant := -6; -- zlib.h:140 -- zlib.h:140 Z_NO_COMPRESSION : constant := 8#0000#; -- zlib.h:145 -- zlib.h:145 Z_BEST_SPEED : constant := 1; -- zlib.h:146 -- zlib.h:146 Z_BEST_COMPRESSION : constant := 9; -- zlib.h:147 -- zlib.h:147 Z_DEFAULT_COMPRESSION : constant := -1; -- zlib.h:148 -- zlib.h:148 Z_FILTERED : constant := 1; -- zlib.h:151 -- zlib.h:151 Z_HUFFMAN_ONLY : constant := 2; -- zlib.h:152 -- zlib.h:152 Z_DEFAULT_STRATEGY : constant := 8#0000#; -- zlib.h:153 -- zlib.h:153 Z_BINARY : constant := 8#0000#; -- zlib.h:156 -- zlib.h:156 Z_ASCII : constant := 1; -- zlib.h:157 -- zlib.h:157 Z_UNKNOWN : constant := 2; -- zlib.h:158 -- zlib.h:158 Z_DEFLATED : constant := 8; -- zlib.h:161 -- zlib.h:161 Z_NULL : constant := 8#0000#; -- zlib.h:164 -- for initializing zalloc, zfree, opaque -- zlib.h:164 type gzFile is new Voidp; -- zlib.h:646 type Z_Stream is private; type Z_Streamp is access all Z_Stream; -- zlib.h:89 type alloc_func is access function (Opaque : Voidp; Items : UInt; Size : UInt) return Voidp; -- zlib.h:63 type free_func is access procedure (opaque : Voidp; address : Voidp); function zlibVersion return Chars_Ptr; function Deflate (strm : Z_Streamp; flush : Int) return Int; function DeflateEnd (strm : Z_Streamp) return Int; function Inflate (strm : Z_Streamp; flush : Int) return Int; function InflateEnd (strm : Z_Streamp) return Int; function deflateSetDictionary (strm : Z_Streamp; dictionary : Byte_Access; dictLength : UInt) return Int; function deflateCopy (dest : Z_Streamp; source : Z_Streamp) return Int; -- zlib.h:478 function deflateReset (strm : Z_Streamp) return Int; -- zlib.h:495 function deflateParams (strm : Z_Streamp; level : Int; strategy : Int) return Int; -- zlib.h:506 function inflateSetDictionary (strm : Z_Streamp; dictionary : Byte_Access; dictLength : UInt) return Int; -- zlib.h:548 function inflateSync (strm : Z_Streamp) return Int; -- zlib.h:565 function inflateReset (strm : Z_Streamp) return Int; -- zlib.h:580 function compress (dest : Byte_Access; destLen : ULong_Access; source : Byte_Access; sourceLen : ULong) return Int; -- zlib.h:601 function compress2 (dest : Byte_Access; destLen : ULong_Access; source : Byte_Access; sourceLen : ULong; level : Int) return Int; -- zlib.h:615 function uncompress (dest : Byte_Access; destLen : ULong_Access; source : Byte_Access; sourceLen : ULong) return Int; function gzopen (path : Chars_Ptr; mode : Chars_Ptr) return gzFile; function gzdopen (fd : Int; mode : Chars_Ptr) return gzFile; function gzsetparams (file : gzFile; level : Int; strategy : Int) return Int; function gzread (file : gzFile; buf : Voidp; len : UInt) return Int; function gzwrite (file : in gzFile; buf : in Voidp; len : in UInt) return Int; function gzprintf (file : in gzFile; format : in Chars_Ptr) return Int; function gzputs (file : in gzFile; s : in Chars_Ptr) return Int; function gzgets (file : gzFile; buf : Chars_Ptr; len : Int) return Chars_Ptr; function gzputc (file : gzFile; char : Int) return Int; function gzgetc (file : gzFile) return Int; function gzflush (file : gzFile; flush : Int) return Int; function gzseek (file : gzFile; offset : Int; whence : Int) return Int; function gzrewind (file : gzFile) return Int; function gztell (file : gzFile) return Int; function gzeof (file : gzFile) return Int; function gzclose (file : gzFile) return Int; function gzerror (file : gzFile; errnum : Int_Access) return Chars_Ptr; function adler32 (adler : ULong; buf : Byte_Access; len : UInt) return ULong; function crc32 (crc : ULong; buf : Byte_Access; len : UInt) return ULong; function deflateInit (strm : Z_Streamp; level : Int; version : Chars_Ptr; stream_size : Int) return Int; function deflateInit2 (strm : Z_Streamp; level : Int; method : Int; windowBits : Int; memLevel : Int; strategy : Int; version : Chars_Ptr; stream_size : Int) return Int; function Deflate_Init (strm : Z_Streamp; level : Int; method : Int; windowBits : Int; memLevel : Int; strategy : Int) return Int; pragma Inline (Deflate_Init); function inflateInit (strm : Z_Streamp; version : Chars_Ptr; stream_size : Int) return Int; function inflateInit2 (strm : in Z_Streamp; windowBits : in Int; version : in Chars_Ptr; stream_size : in Int) return Int; function inflateBackInit (strm : in Z_Streamp; windowBits : in Int; window : in Byte_Access; version : in Chars_Ptr; stream_size : in Int) return Int; -- Size of window have to be 2**windowBits. function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int; pragma Inline (Inflate_Init); function zError (err : Int) return Chars_Ptr; function inflateSyncPoint (z : Z_Streamp) return Int; function get_crc_table return ULong_Access; -- Interface to the available fields of the z_stream structure. -- 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. procedure Set_In (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt); pragma Inline (Set_In); procedure Set_Out (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt); pragma Inline (Set_Out); procedure Set_Mem_Func (Strm : in out Z_Stream; Opaque : in Voidp; Alloc : in alloc_func; Free : in free_func); pragma Inline (Set_Mem_Func); function Last_Error_Message (Strm : in Z_Stream) return String; pragma Inline (Last_Error_Message); function Avail_Out (Strm : in Z_Stream) return UInt; pragma Inline (Avail_Out); function Avail_In (Strm : in Z_Stream) return UInt; pragma Inline (Avail_In); function Total_In (Strm : in Z_Stream) return ULong; pragma Inline (Total_In); function Total_Out (Strm : in Z_Stream) return ULong; pragma Inline (Total_Out); function inflateCopy (dest : in Z_Streamp; Source : in Z_Streamp) return Int; function compressBound (Source_Len : in ULong) return ULong; function deflateBound (Strm : in Z_Streamp; Source_Len : in ULong) return ULong; function gzungetc (C : in Int; File : in gzFile) return Int; function zlibCompileFlags return ULong; private type Z_Stream is record -- zlib.h:68 Next_In : Voidp := Nul; -- next input byte Avail_In : UInt := 0; -- number of bytes available at next_in Total_In : ULong := 0; -- total nb of input bytes read so far Next_Out : Voidp := Nul; -- next output byte should be put there Avail_Out : UInt := 0; -- remaining free space at next_out Total_Out : ULong := 0; -- total nb of bytes output so far msg : Chars_Ptr; -- last error message, NULL if no error state : Voidp; -- not visible by applications zalloc : alloc_func := null; -- used to allocate the internal state zfree : free_func := null; -- used to free the internal state opaque : Voidp; -- private data object passed to -- zalloc and zfree data_type : Int; -- best guess about the data type: -- ascii or binary adler : ULong; -- adler32 value of the uncompressed -- data reserved : ULong; -- reserved for future use end record; pragma Convention (C, Z_Stream); pragma Import (C, zlibVersion, "zlibVersion"); pragma Import (C, Deflate, "deflate"); pragma Import (C, DeflateEnd, "deflateEnd"); pragma Import (C, Inflate, "inflate"); pragma Import (C, InflateEnd, "inflateEnd"); pragma Import (C, deflateSetDictionary, "deflateSetDictionary"); pragma Import (C, deflateCopy, "deflateCopy"); pragma Import (C, deflateReset, "deflateReset"); pragma Import (C, deflateParams, "deflateParams"); pragma Import (C, inflateSetDictionary, "inflateSetDictionary"); pragma Import (C, inflateSync, "inflateSync"); pragma Import (C, inflateReset, "inflateReset"); pragma Import (C, compress, "compress"); pragma Import (C, compress2, "compress2"); pragma Import (C, uncompress, "uncompress"); pragma Import (C, gzopen, "gzopen"); pragma Import (C, gzdopen, "gzdopen"); pragma Import (C, gzsetparams, "gzsetparams"); pragma Import (C, gzread, "gzread"); pragma Import (C, gzwrite, "gzwrite"); pragma Import (C, gzprintf, "gzprintf"); pragma Import (C, gzputs, "gzputs"); pragma Import (C, gzgets, "gzgets"); pragma Import (C, gzputc, "gzputc"); pragma Import (C, gzgetc, "gzgetc"); pragma Import (C, gzflush, "gzflush"); pragma Import (C, gzseek, "gzseek"); pragma Import (C, gzrewind, "gzrewind"); pragma Import (C, gztell, "gztell"); pragma Import (C, gzeof, "gzeof"); pragma Import (C, gzclose, "gzclose"); pragma Import (C, gzerror, "gzerror"); pragma Import (C, adler32, "adler32"); pragma Import (C, crc32, "crc32"); pragma Import (C, deflateInit, "deflateInit_"); pragma Import (C, inflateInit, "inflateInit_"); pragma Import (C, deflateInit2, "deflateInit2_"); pragma Import (C, inflateInit2, "inflateInit2_"); pragma Import (C, zError, "zError"); pragma Import (C, inflateSyncPoint, "inflateSyncPoint"); pragma Import (C, get_crc_table, "get_crc_table"); -- since zlib 1.2.0: pragma Import (C, inflateCopy, "inflateCopy"); pragma Import (C, compressBound, "compressBound"); pragma Import (C, deflateBound, "deflateBound"); pragma Import (C, gzungetc, "gzungetc"); pragma Import (C, zlibCompileFlags, "zlibCompileFlags"); pragma Import (C, inflateBackInit, "inflateBackInit_"); -- I stopped binding the inflateBack routines, becouse realize that -- it does not support zlib and gzip headers for now, and have no -- symmetric deflateBack routines. -- ZLib-Ada is symmetric regarding deflate/inflate data transformation -- and has a similar generic callback interface for the -- deflate/inflate transformation based on the regular Deflate/Inflate -- routines. -- pragma Import (C, inflateBack, "inflateBack"); -- pragma Import (C, inflateBackEnd, "inflateBackEnd"); end ZLib.Thin; sks-ecc-0.93/zlib/contrib/ada/mtest.adb0000644000175000017500000001056310604550750016677 0ustar nachonacho---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- Continuous test for ZLib multithreading. If the test would fail -- we should provide thread safe allocation routines for the Z_Stream. -- -- $Id: mtest.adb,v 1.4 2004/07/23 07:49:54 vagul Exp $ with ZLib; with Ada.Streams; with Ada.Numerics.Discrete_Random; with Ada.Text_IO; with Ada.Exceptions; with Ada.Task_Identification; procedure MTest is use Ada.Streams; use ZLib; Stop : Boolean := False; pragma Atomic (Stop); subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#; package Random_Elements is new Ada.Numerics.Discrete_Random (Visible_Symbols); task type Test_Task; task body Test_Task is Buffer : Stream_Element_Array (1 .. 100_000); Gen : Random_Elements.Generator; Buffer_First : Stream_Element_Offset; Compare_First : Stream_Element_Offset; Deflate : Filter_Type; Inflate : Filter_Type; procedure Further (Item : in Stream_Element_Array); procedure Read_Buffer (Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); ------------- -- Further -- ------------- procedure Further (Item : in Stream_Element_Array) is procedure Compare (Item : in Stream_Element_Array); ------------- -- Compare -- ------------- procedure Compare (Item : in Stream_Element_Array) is Next_First : Stream_Element_Offset := Compare_First + Item'Length; begin if Buffer (Compare_First .. Next_First - 1) /= Item then raise Program_Error; end if; Compare_First := Next_First; end Compare; procedure Compare_Write is new ZLib.Write (Write => Compare); begin Compare_Write (Inflate, Item, No_Flush); end Further; ----------------- -- Read_Buffer -- ----------------- procedure Read_Buffer (Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset) is Buff_Diff : Stream_Element_Offset := Buffer'Last - Buffer_First; Next_First : Stream_Element_Offset; begin if Item'Length <= Buff_Diff then Last := Item'Last; Next_First := Buffer_First + Item'Length; Item := Buffer (Buffer_First .. Next_First - 1); Buffer_First := Next_First; else Last := Item'First + Buff_Diff; Item (Item'First .. Last) := Buffer (Buffer_First .. Buffer'Last); Buffer_First := Buffer'Last + 1; end if; end Read_Buffer; procedure Translate is new Generic_Translate (Data_In => Read_Buffer, Data_Out => Further); begin Random_Elements.Reset (Gen); Buffer := (others => 20); Main : loop for J in Buffer'Range loop Buffer (J) := Random_Elements.Random (Gen); Deflate_Init (Deflate); Inflate_Init (Inflate); Buffer_First := Buffer'First; Compare_First := Buffer'First; Translate (Deflate); if Compare_First /= Buffer'Last + 1 then raise Program_Error; end if; Ada.Text_IO.Put_Line (Ada.Task_Identification.Image (Ada.Task_Identification.Current_Task) & Stream_Element_Offset'Image (J) & ZLib.Count'Image (Total_Out (Deflate))); Close (Deflate); Close (Inflate); exit Main when Stop; end loop; end loop Main; exception when E : others => Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E)); Stop := True; end Test_Task; Test : array (1 .. 4) of Test_Task; pragma Unreferenced (Test); Dummy : Character; begin Ada.Text_IO.Get_Immediate (Dummy); Stop := True; end MTest; sks-ecc-0.93/zlib/contrib/ada/zlib.ads0000644000175000017500000003243210604550750016523 0ustar nachonacho------------------------------------------------------------------------------ -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2004 Dmitriy Anisimkov -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- ------------------------------------------------------------------------------ -- $Id: zlib.ads,v 1.26 2004/09/06 06:53:19 vagul Exp $ with Ada.Streams; with Interfaces; package ZLib is ZLib_Error : exception; Status_Error : exception; type Compression_Level is new Integer range -1 .. 9; type Flush_Mode is private; type Compression_Method is private; type Window_Bits_Type is new Integer range 8 .. 15; type Memory_Level_Type is new Integer range 1 .. 9; type Unsigned_32 is new Interfaces.Unsigned_32; type Strategy_Type is private; type Header_Type is (None, Auto, Default, GZip); -- Header type usage have a some limitation for inflate. -- See comment for Inflate_Init. subtype Count is Ada.Streams.Stream_Element_Count; Default_Memory_Level : constant Memory_Level_Type := 8; Default_Window_Bits : constant Window_Bits_Type := 15; ---------------------------------- -- Compression method constants -- ---------------------------------- Deflated : constant Compression_Method; -- Only one method allowed in this ZLib version --------------------------------- -- Compression level constants -- --------------------------------- No_Compression : constant Compression_Level := 0; Best_Speed : constant Compression_Level := 1; Best_Compression : constant Compression_Level := 9; Default_Compression : constant Compression_Level := -1; -------------------------- -- Flush mode constants -- -------------------------- No_Flush : constant Flush_Mode; -- Regular way for compression, no flush Partial_Flush : constant Flush_Mode; -- Will be removed, use Z_SYNC_FLUSH instead Sync_Flush : constant Flush_Mode; -- 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. Block_Flush : constant Flush_Mode; -- Z_BLOCK requests that inflate() stop -- if and when it get to the next deflate block boundary. When decoding the -- zlib or gzip format, this will cause inflate() to return immediately -- after the header and before the first block. When doing a raw inflate, -- inflate() will go ahead and process the first block, and will return -- when it gets to the end of that block, or when it runs out of data. Full_Flush : constant Flush_Mode; -- All output is flushed as with 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 -- Full_Flush too often can seriously degrade the compression. Finish : constant Flush_Mode; -- Just for tell the compressor that input data is complete. ------------------------------------ -- Compression strategy constants -- ------------------------------------ -- RLE stategy could be used only in version 1.2.0 and later. Filtered : constant Strategy_Type; Huffman_Only : constant Strategy_Type; RLE : constant Strategy_Type; Default_Strategy : constant Strategy_Type; Default_Buffer_Size : constant := 4096; type Filter_Type is tagged limited private; -- The filter is for compression and for decompression. -- The usage of the type is depend of its initialization. function Version return String; pragma Inline (Version); -- Return string representation of the ZLib version. procedure Deflate_Init (Filter : in out Filter_Type; Level : in Compression_Level := Default_Compression; Strategy : in Strategy_Type := Default_Strategy; Method : in Compression_Method := Deflated; Window_Bits : in Window_Bits_Type := Default_Window_Bits; Memory_Level : in Memory_Level_Type := Default_Memory_Level; Header : in Header_Type := Default); -- Compressor initialization. -- When Header parameter is Auto or Default, then default zlib header -- would be provided for compressed data. -- When Header is GZip, then gzip header would be set instead of -- default header. -- When Header is None, no header would be set for compressed data. procedure Inflate_Init (Filter : in out Filter_Type; Window_Bits : in Window_Bits_Type := Default_Window_Bits; Header : in Header_Type := Default); -- Decompressor initialization. -- Default header type mean that ZLib default header is expecting in the -- input compressed stream. -- Header type None mean that no header is expecting in the input stream. -- GZip header type mean that GZip header is expecting in the -- input compressed stream. -- Auto header type mean that header type (GZip or Native) would be -- detected automatically in the input stream. -- Note that header types parameter values None, GZip and Auto are -- supported for inflate routine only in ZLib versions 1.2.0.2 and later. -- Deflate_Init is supporting all header types. function Is_Open (Filter : in Filter_Type) return Boolean; pragma Inline (Is_Open); -- Is the filter opened for compression or decompression. procedure Close (Filter : in out Filter_Type; Ignore_Error : in Boolean := False); -- Closing the compression or decompressor. -- If stream is closing before the complete and Ignore_Error is False, -- The exception would be raised. generic with procedure Data_In (Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); with procedure Data_Out (Item : in Ada.Streams.Stream_Element_Array); procedure Generic_Translate (Filter : in out Filter_Type; In_Buffer_Size : in Integer := Default_Buffer_Size; Out_Buffer_Size : in Integer := Default_Buffer_Size); -- Compress/decompress data fetch from Data_In routine and pass the result -- to the Data_Out routine. User should provide Data_In and Data_Out -- for compression/decompression data flow. -- Compression or decompression depend on Filter initialization. function Total_In (Filter : in Filter_Type) return Count; pragma Inline (Total_In); -- Returns total number of input bytes read so far function Total_Out (Filter : in Filter_Type) return Count; pragma Inline (Total_Out); -- Returns total number of bytes output so far function CRC32 (CRC : in Unsigned_32; Data : in Ada.Streams.Stream_Element_Array) return Unsigned_32; pragma Inline (CRC32); -- Compute CRC32, it could be necessary for make gzip format procedure CRC32 (CRC : in out Unsigned_32; Data : in Ada.Streams.Stream_Element_Array); pragma Inline (CRC32); -- Compute CRC32, it could be necessary for make gzip format ------------------------------------------------- -- Below is more complex low level routines. -- ------------------------------------------------- procedure Translate (Filter : in out Filter_Type; In_Data : in Ada.Streams.Stream_Element_Array; In_Last : out Ada.Streams.Stream_Element_Offset; Out_Data : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Flush : in Flush_Mode); -- Compress/decompress the In_Data buffer and place the result into -- Out_Data. In_Last is the index of last element from In_Data accepted by -- the Filter. Out_Last is the last element of the received data from -- Filter. To tell the filter that incoming data are complete put the -- Flush parameter to Finish. function Stream_End (Filter : in Filter_Type) return Boolean; pragma Inline (Stream_End); -- Return the true when the stream is complete. procedure Flush (Filter : in out Filter_Type; Out_Data : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Flush : in Flush_Mode); pragma Inline (Flush); -- Flushing the data from the compressor. generic with procedure Write (Item : in Ada.Streams.Stream_Element_Array); -- User should provide this routine for accept -- compressed/decompressed data. Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size; -- Buffer size for Write user routine. procedure Write (Filter : in out Filter_Type; Item : in Ada.Streams.Stream_Element_Array; Flush : in Flush_Mode := No_Flush); -- Compress/Decompress data from Item to the generic parameter procedure -- Write. Output buffer size could be set in Buffer_Size generic parameter. generic with procedure Read (Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); -- User should provide data for compression/decompression -- thru this routine. Buffer : in out Ada.Streams.Stream_Element_Array; -- Buffer for keep remaining data from the previous -- back read. Rest_First, Rest_Last : in out Ada.Streams.Stream_Element_Offset; -- Rest_First have to be initialized to Buffer'Last + 1 -- Rest_Last have to be initialized to Buffer'Last -- before usage. Allow_Read_Some : in Boolean := False; -- Is it allowed to return Last < Item'Last before end of data. procedure Read (Filter : in out Filter_Type; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; Flush : in Flush_Mode := No_Flush); -- Compress/Decompress data from generic parameter procedure Read to the -- Item. User should provide Buffer and initialized Rest_First, Rest_Last -- indicators. If Allow_Read_Some is True, Read routines could return -- Last < Item'Last only at end of stream. private use Ada.Streams; pragma Assert (Ada.Streams.Stream_Element'Size = 8); pragma Assert (Ada.Streams.Stream_Element'Modulus = 2**8); type Flush_Mode is new Integer range 0 .. 5; type Compression_Method is new Integer range 8 .. 8; type Strategy_Type is new Integer range 0 .. 3; No_Flush : constant Flush_Mode := 0; Partial_Flush : constant Flush_Mode := 1; Sync_Flush : constant Flush_Mode := 2; Full_Flush : constant Flush_Mode := 3; Finish : constant Flush_Mode := 4; Block_Flush : constant Flush_Mode := 5; Filtered : constant Strategy_Type := 1; Huffman_Only : constant Strategy_Type := 2; RLE : constant Strategy_Type := 3; Default_Strategy : constant Strategy_Type := 0; Deflated : constant Compression_Method := 8; type Z_Stream; type Z_Stream_Access is access all Z_Stream; type Filter_Type is tagged limited record Strm : Z_Stream_Access; Compression : Boolean; Stream_End : Boolean; Header : Header_Type; CRC : Unsigned_32; Offset : Stream_Element_Offset; -- Offset for gzip header/footer output. end record; end ZLib; sks-ecc-0.93/zlib/contrib/ada/buffer_demo.adb0000644000175000017500000000720510604550750020017 0ustar nachonacho---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2004 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- -- $Id: buffer_demo.adb,v 1.3 2004/09/06 06:55:35 vagul Exp $ -- This demo program provided by Dr Steve Sangwine -- -- Demonstration of a problem with Zlib-Ada (already fixed) when a buffer -- of exactly the correct size is used for decompressed data, and the last -- few bytes passed in to Zlib are checksum bytes. -- This program compresses a string of text, and then decompresses the -- compressed text into a buffer of the same size as the original text. with Ada.Streams; use Ada.Streams; with Ada.Text_IO; with ZLib; use ZLib; procedure Buffer_Demo is EOL : Character renames ASCII.LF; Text : constant String := "Four score and seven years ago our fathers brought forth," & EOL & "upon this continent, a new nation, conceived in liberty," & EOL & "and dedicated to the proposition that `all men are created equal'."; Source : Stream_Element_Array (1 .. Text'Length); for Source'Address use Text'Address; begin Ada.Text_IO.Put (Text); Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line ("Uncompressed size : " & Positive'Image (Text'Length) & " bytes"); declare Compressed_Data : Stream_Element_Array (1 .. Text'Length); L : Stream_Element_Offset; begin Compress : declare Compressor : Filter_Type; I : Stream_Element_Offset; begin Deflate_Init (Compressor); -- Compress the whole of T at once. Translate (Compressor, Source, I, Compressed_Data, L, Finish); pragma Assert (I = Source'Last); Close (Compressor); Ada.Text_IO.Put_Line ("Compressed size : " & Stream_Element_Offset'Image (L) & " bytes"); end Compress; -- Now we decompress the data, passing short blocks of data to Zlib -- (because this demonstrates the problem - the last block passed will -- contain checksum information and there will be no output, only a -- check inside Zlib that the checksum is correct). Decompress : declare Decompressor : Filter_Type; Uncompressed_Data : Stream_Element_Array (1 .. Text'Length); Block_Size : constant := 4; -- This makes sure that the last block contains -- only Adler checksum data. P : Stream_Element_Offset := Compressed_Data'First - 1; O : Stream_Element_Offset; begin Inflate_Init (Decompressor); loop Translate (Decompressor, Compressed_Data (P + 1 .. Stream_Element_Offset'Min (P + Block_Size, L)), P, Uncompressed_Data (Total_Out (Decompressor) + 1 .. Uncompressed_Data'Last), O, No_Flush); Ada.Text_IO.Put_Line ("Total in : " & Count'Image (Total_In (Decompressor)) & ", out : " & Count'Image (Total_Out (Decompressor))); exit when P = L; end loop; Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line ("Decompressed text matches original text : " & Boolean'Image (Uncompressed_Data = Source)); end Decompress; end; end Buffer_Demo; sks-ecc-0.93/zlib/contrib/ada/zlib.gpr0000600000175000017500000000077710604550750016543 0ustar nachonachoproject Zlib is for Languages use ("Ada"); for Source_Dirs use ("."); for Object_Dir use "."; for Main use ("test.adb", "mtest.adb", "read.adb", "buffer_demo"); package Compiler is for Default_Switches ("ada") use ("-gnatwcfilopru", "-gnatVcdfimorst", "-gnatyabcefhiklmnoprst"); end Compiler; package Linker is for Default_Switches ("ada") use ("-lz"); end Linker; package Builder is for Default_Switches ("ada") use ("-s", "-gnatQ"); end Builder; end Zlib; sks-ecc-0.93/zlib/contrib/ada/zlib-streams.ads0000644000175000017500000001035210604550750020174 0ustar nachonacho---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: zlib-streams.ads,v 1.12 2004/05/31 10:53:40 vagul Exp $ package ZLib.Streams is type Stream_Mode is (In_Stream, Out_Stream, Duplex); type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class; type Stream_Type is new Ada.Streams.Root_Stream_Type with private; procedure Read (Stream : in out Stream_Type; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); procedure Write (Stream : in out Stream_Type; Item : in Ada.Streams.Stream_Element_Array); procedure Flush (Stream : in out Stream_Type; Mode : in Flush_Mode := Sync_Flush); -- Flush the written data to the back stream, -- all data placed to the compressor is flushing to the Back stream. -- Should not be used untill necessary, becouse it is decreasing -- compression. function Read_Total_In (Stream : in Stream_Type) return Count; pragma Inline (Read_Total_In); -- Return total number of bytes read from back stream so far. function Read_Total_Out (Stream : in Stream_Type) return Count; pragma Inline (Read_Total_Out); -- Return total number of bytes read so far. function Write_Total_In (Stream : in Stream_Type) return Count; pragma Inline (Write_Total_In); -- Return total number of bytes written so far. function Write_Total_Out (Stream : in Stream_Type) return Count; pragma Inline (Write_Total_Out); -- Return total number of bytes written to the back stream. procedure Create (Stream : out Stream_Type; Mode : in Stream_Mode; Back : in Stream_Access; Back_Compressed : in Boolean; Level : in Compression_Level := Default_Compression; Strategy : in Strategy_Type := Default_Strategy; Header : in Header_Type := Default; Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size; Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size); -- Create the Comression/Decompression stream. -- If mode is In_Stream then Write operation is disabled. -- If mode is Out_Stream then Read operation is disabled. -- If Back_Compressed is true then -- Data written to the Stream is compressing to the Back stream -- and data read from the Stream is decompressed data from the Back stream. -- If Back_Compressed is false then -- Data written to the Stream is decompressing to the Back stream -- and data read from the Stream is compressed data from the Back stream. -- !!! When the Need_Header is False ZLib-Ada is using undocumented -- ZLib 1.1.4 functionality to do not create/wait for ZLib headers. function Is_Open (Stream : Stream_Type) return Boolean; procedure Close (Stream : in out Stream_Type); private use Ada.Streams; type Buffer_Access is access all Stream_Element_Array; type Stream_Type is new Root_Stream_Type with record Mode : Stream_Mode; Buffer : Buffer_Access; Rest_First : Stream_Element_Offset; Rest_Last : Stream_Element_Offset; -- Buffer for Read operation. -- We need to have this buffer in the record -- becouse not all read data from back stream -- could be processed during the read operation. Buffer_Size : Stream_Element_Offset; -- Buffer size for write operation. -- We do not need to have this buffer -- in the record becouse all data could be -- processed in the write operation. Back : Stream_Access; Reader : Filter_Type; Writer : Filter_Type; end record; end ZLib.Streams; sks-ecc-0.93/zlib/contrib/masmx86/0000755000175000017500000000000010604550750015644 5ustar nachonachosks-ecc-0.93/zlib/contrib/masmx86/readme.txt0000644000175000017500000000112310604550750017637 0ustar nachonacho Summary ------- This directory contains ASM implementations of the functions longest_match() and inflate_fast(). Use instructions ---------------- Copy these files into the zlib source directory, then run the appropriate makefile, as suggested below. Build instructions ------------------ * With Microsoft C and MASM: nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" OBJA="gvmat32c.obj gvmat32.obj inffas32.obj" * With Borland C and TASM: make -f win32/Makefile.bor LOCAL_ZLIB="-DASMV -DASMINF" OBJA="gvmat32c.obj gvmat32.obj inffas32.obj" OBJPA="+gvmat32c.obj+gvmat32.obj+inffas32.obj" sks-ecc-0.93/zlib/contrib/masmx86/gvmat32.obj0000644000175000017500000002400110604550750017620 0ustar nachonachoL‰.B~i.text´¸] 0`.data@0À.debug$S|æb”@B.debug$T€T*@B‹T$UWVSƒì4‹ê‹U|‹]x9ŒwÁêB‹½‰T$0‹Et;Çs‹ø‰\$(‹u8‹Ml‰t$$‰|$ñ‰t$ f‹f‹\3ÿÆf‰T$‰4$‹u,î+Îw3ɉL$,‹U@‰T$ ‹Upf‹l$‹D$L‰T$‹T$$‹ú|$(‹t$ O‰|$ëNƒD$0„Ñf98t%ÿf‹F;ȃºÿL$0uãé¯f;,uÞéã‹|$%ÿf‹F;ȃƒl$0v¬f98„¬%ÿf‹F;ȃmf98„€%ÿf‹F;ȃRf98„T%ÿf‹F;ȃ7f98„(%ÿf‹F;ȃf98„ü%ÿf‹F;ȃf98„Ð%ÿf‹F;ȃæf98„¤%ÿf‹F;ȃËf98„u%ÿf‹F;ȃ°f98„F%ÿf‹F;ȃ•f98„%ÿf‹F;ȃzf98„è%ÿf‹F;ȃ_f98t}%ÿf‹F;ȃHf98tz%ÿf‹F;ȃ1f98ts%ÿf‹F;ȃf98tl%ÿf‹F;ȃf98te%ÿf‹F;ȃìƒl$0‡Yþÿÿéþÿÿf;,…yÿÿÿƒD$0éf;,u€ƒD$0éf;,u‡ƒD$0éõf;,uŽƒD$0éåf;,u•ƒD$0éÕf;,…ÿÿÿƒD$0éÁf;,…ßþÿÿƒD$0é­f;,…°þÿÿƒD$0é™f;,…þÿÿƒD$0 é…f;,…RþÿÿƒD$0 ëtf;,…&þÿÿƒD$0 ëcf;,…úýÿÿƒD$0 ëRf;,…ÎýÿÿƒD$0 ëAf;,…¢ýÿÿƒD$0ë0f;,…výÿÿƒD$0ëf;,…JýÿÿƒD$0ë‹|$$f;,8…ýÿÿ‹ú‹t$ ø‹V3Wt- Òt¾ëQf Òt¾ëEâÿÿÿt¾ë6¾ë/ƒÇƒÆ¹?ó§tƒî‹Wü3 ÒuFf Òu FâÿÿÿuF+t$ ;t$(w‹t$ ‹L$,‹T$$éŒüÿÿ‰t$(‰D$;t$s"‹L$ ‹T$$ÎòN‰t$f‹Yÿ‹t$ ‹L$,é\üÿÿ‹\$‹l$H‹L$(‰]p‹Et;Èw‹ÁƒÄ4[^_]à GVMat32 optimised assembly code written 1996-98 by Gilles Vollant SœX‹È5PœX3ÁtQœœY‹Á5 PœX3Át¸¢[øë÷¸ëðUWVSƒì$‹T$8‹L$<‹Bx‹šŒ;ËB4‹Z||ÁëKÁã ؉$‹‚‹Zt;Ø|‹Ø‰\$‹r8‰t$‹jl|5‰|$ ‹Ç÷؃à‰D$‹B,-+è3í‹Bx‰D$ð‰t$·‰\$·\8ÿ‰\$ ‹z@‹$ë#Ê· O;͆àêˆÔ·D1ÿ;ÃuÝ‹D$·;D$uω$‹t$‹|$ ñ‹D$ºøþÿÿ¼8´0‹23:u‹D23D:uƒÂuéëqƒÂ©ÿÿuƒÂÁè,ƒÒ:‹|$ +Ç=}L‹T$8‹\$;Ët$‹z@‹\$ ‹$éNÿÿÿ‹\$‰D$‰Jp;Ã}-‹t$ð‰t$·\8ÿ‹z@‰\$ ‹$é!ÿÿÿ‹T$8ÇD$‰Jp‹T$8‹\$‹Bt;؋ÃÄ$[^_]à asm686 with masm, optimised assembly code from Brian Raiter, written 1998     %),. 0!2$6'9(<)@+D-F.J0M2R3X5]7`=c>i@kAmBoDsGvHzK}L‚M†NŠPŽQR”S˜T™VX f¥g«i¯j±m¶nºp¼qÂsÆtÈuÍyÑzÓ{Ø~Üá‚å„ç†íŒòŽô‘ø’þž¡4¤O§jª…­ °»³Ö¶ñ¹ ¼#¿:ÂQÅhÈË„̈ÍŠÎЕћҠâ´åÄèÔëäîôñô÷0úDýUfwˆ ™ ª»¿ÃÉËÏ Ñ"Ô#×%Ù(Û)Ý*â+ä-ç.é0î1ð3ö4ø5ý6ÿ89= > ?@BDEFHI!J"L%M'N(P.Q0R1U5X9Y;[?\C]G^LaPcTdXeZf^gbhdifkglkmopsqwr|v€w„xˆy‹zŽ{|’}”‚—„˜…™†š‡›ˆáâãäæë ì í î ï ñóôõö÷øúÿ $%(),- ! " # &*.179<? A!D)E*H+J,M0S1V2X3Z4\5`9c:g;j<n=rBtCvDyE}J€K…L‡M‰N‹SŽT’X”Y˜_›`Ÿa¤b¨c«g®h°²‚¶ƒ¸„¾…Ćʇψщӊ׋یßá‘ä˜è™ìšî›òœ÷þž¯° ± ²³´µ¶·¸!¹&º(»+¼.½0¾3Ã6Ä:Å<ÆAÇCÌGÍKÎMÏOÐSÑVÒZÓ]ÔbÛfÜjÝmÞoßqàuáwâ{ã€äƒå‡æŠçë“ì›ížó¢ô¦õ©ö«÷­ø¯ý²þ³ÿ´µ¶ñ,O:\updasm\contrib\masmx86\gvmat32.obj4  Microsoft (R) Macro Assembler8åå_longest_match_686LastMatchGoodLookaheadLessLimitPositiveLookupLoopLoopEntryLoopCmpsLeaveLoopCmps4LeaveLoopCmpsLenLowerLongerMatchLenMaximumLeaveNowLookaheadRet2>>_cpudetect32exitcpudetectend_cpu_is_386is_old_4869áá_longest_match_7fffnoshrnolookaheadnicematchnodistnormalbeg0add16normalbeg0rcontlabnorollnormalbeg2norollcontloop3jnbexitloopshort1beginloop2do16rcontloop0rcontloop1rcontloop2rcontloop3rcontloop4rcontloop5rcontloop6rcontloop7rcontloop8rcontloop9rcontloop10rcontloop11rcontloop12rcontloop13rcontloop14rcontloop15normalbeg2dc11normalbeg2dc12normalbeg2dc13normalbeg2dc14normalbeg2dc15normalbeg2dc10normalbeg2dc9normalbeg2dc8normalbeg2dc7normalbeg2dc6normalbeg2dc5normalbeg2dc4normalbeg2dc3normalbeg2dc2normalbeg2dc1normalbeg2dc0normalbeg2iseqeq1rr eq1eq11begincomparetrfintrfinvalnewbestlenexitloopminexloInfoAuthor ” ®" ²" Ç# Ë# à$ ä$ ù% ý% & & $' (' 8( <( R) V) k* o* + ƒ+ –, š, ¬- °- À. Ä. ø ü / / )0 -0 C1 G1 y } ˜2 œ2 ©3 ­3 É4 Í4 Û5 ß5 ö6 ú6 7 7 &8 *8 B9 F9 W: [: t; x; Š< Ž< š= ž= °> ´> Æ? Ê? Ü@ à@ òA öA B B C "C 4D 8D JE NE `F dF vG zG H ‘H ¤I ¨I »J ¿J ÒK ÖK éL íL M M N N 4O 8O NP RP hQ lQ ‚R †R œS  S µT ¹T ÎU ÒU çV ëV W W X X 2Y 6Y KZ OZ d[ h[ }\ \ –] š] ¬^ °^ ¼_ À_ Í` Ñ` Üa àa ìb ðb c c d d )e -e ?f Cf Sg Wg fh jh òñž}\.fileþÿgO:\updasm\contrib\masmx86\gvmat32.asm@comp.id ÿÿ.text].data.debug$S|”.debug$TT á¸.bfeŽ.lf»e.efáeá > .bfáe(.lf!e.efeU% åà .bfeª.lfe.efe­8DF\T‹b°mÊLoopCmpsw†!LenLower.”b LeaveNowž«¯¸ÆÕnoshrà2nodistoõ «±Í0Ø:çLído16ôWþbm4xOƒjŽ…™ ¤»¯ÖºñÅ Ñ#Ý:éQõh  ´+Ä:ÔIäXôguƒ0‘DŸU­f»wɈיåªó»iseqÉeq1rräeq1ðeq11ÿþtrfin1trfinval5 Lexitloop|minexlo”œ!_longest_match_7fff_cpudetect32_longest_match_686LastMatchGoodLookaheadLessLimitPositiveLookupLoopLoopEntryLeaveLoopCmps4LeaveLoopCmpsLongerMatchLenMaximumLookaheadRetexitcpudetectend_cpu_is_386is_old_486nolookaheadnicematchnormalbeg0add16normalbeg0rcontlabnorollnormalbeg2norollcontloop3jnbexitloopshort1beginloop2rcontloop0rcontloop1rcontloop2rcontloop3rcontloop4rcontloop5rcontloop6rcontloop7rcontloop8rcontloop9rcontloop10rcontloop11rcontloop12rcontloop13rcontloop14rcontloop15normalbeg2dc11normalbeg2dc12normalbeg2dc13normalbeg2dc14normalbeg2dc15normalbeg2dc10normalbeg2dc9normalbeg2dc8normalbeg2dc7normalbeg2dc6normalbeg2dc5normalbeg2dc4normalbeg2dc3normalbeg2dc2normalbeg2dc1normalbeg2dc0normalbeg2begincomparenewbestlenInfoAuthorsks-ecc-0.93/zlib/contrib/masmx86/gvmat32.asm0000644000175000017500000006505210604550750017641 0ustar nachonacho; gvmat32.asm -- Asm portion of the optimized longest_match for 32 bits x86 ; Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant. ; File written by Gilles Vollant, by modifiying the longest_match ; from Jean-loup Gailly in deflate.c ; ; http://www.zlib.net ; http://www.winimage.com/zLibDll ; http://www.muppetlabs.com/~breadbox/software/assembly.html ; ; For Visual C++ 4.x and higher and ML 6.x and higher ; ml.exe is in directory \MASM611C of Win95 DDK ; ml.exe is also distributed in http://www.masm32.com/masmdl.htm ; and in VC++2003 toolkit at http://msdn.microsoft.com/visualc/vctoolkit2003/ ; ; this file contain two implementation of longest_match ; ; longest_match_7fff : written 1996 by Gilles Vollant optimized for ; first Pentium. Assume s->w_mask == 0x7fff ; longest_match_686 : written by Brian raiter (1998), optimized for Pentium Pro ; ; for using an seembly version of longest_match, you need define ASMV in project ; There is two way in using gvmat32.asm ; ; A) Suggested method ; if you want include both longest_match_7fff and longest_match_686 ; compile the asm file running ; ml /coff /Zi /Flgvmat32.lst /c gvmat32.asm ; and include gvmat32c.c in your project ; if you have an old cpu (386,486 or first Pentium) and s->w_mask==0x7fff, ; longest_match_7fff will be used ; if you have a more modern CPU (Pentium Pro, II and higher) ; longest_match_686 will be used ; on old cpu with s->w_mask!=0x7fff, longest_match_686 will be used, ; but this is not a sitation you'll find often ; ; B) Alternative ; if you are not interresed in old cpu performance and want the smaller ; binaries possible ; ; compile the asm file running ; ml /coff /Zi /c /Flgvmat32.lst /DNOOLDPENTIUMCODE gvmat32.asm ; and do not include gvmat32c.c in your project (ou define also ; NOOLDPENTIUMCODE) ; ; note : as I known, longest_match_686 is very faster than longest_match_7fff ; on pentium Pro/II/III, faster (but less) in P4, but it seem ; longest_match_7fff can be faster (very very litte) on AMD Athlon64/K8 ; ; see below : zlib1222add must be adjuster if you use a zlib version < 1.2.2.2 ;uInt longest_match_7fff(s, cur_match) ; deflate_state *s; ; IPos cur_match; /* current match */ NbStack equ 76 cur_match equ dword ptr[esp+NbStack-0] str_s equ dword ptr[esp+NbStack-4] ; 5 dword on top (ret,ebp,esi,edi,ebx) adrret equ dword ptr[esp+NbStack-8] pushebp equ dword ptr[esp+NbStack-12] pushedi equ dword ptr[esp+NbStack-16] pushesi equ dword ptr[esp+NbStack-20] pushebx equ dword ptr[esp+NbStack-24] chain_length equ dword ptr [esp+NbStack-28] limit equ dword ptr [esp+NbStack-32] best_len equ dword ptr [esp+NbStack-36] window equ dword ptr [esp+NbStack-40] prev equ dword ptr [esp+NbStack-44] scan_start equ word ptr [esp+NbStack-48] wmask equ dword ptr [esp+NbStack-52] match_start_ptr equ dword ptr [esp+NbStack-56] nice_match equ dword ptr [esp+NbStack-60] scan equ dword ptr [esp+NbStack-64] windowlen equ dword ptr [esp+NbStack-68] match_start equ dword ptr [esp+NbStack-72] strend equ dword ptr [esp+NbStack-76] NbStackAdd equ (NbStack-24) .386p name gvmatch .MODEL FLAT ; all the +zlib1222add offsets are due to the addition of fields ; in zlib in the deflate_state structure since the asm code was first written ; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)"). ; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0"). ; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8"). zlib1222add equ 8 ; Note : these value are good with a 8 bytes boundary pack structure dep_chain_length equ 74h+zlib1222add dep_window equ 30h+zlib1222add dep_strstart equ 64h+zlib1222add dep_prev_length equ 70h+zlib1222add dep_nice_match equ 88h+zlib1222add dep_w_size equ 24h+zlib1222add dep_prev equ 38h+zlib1222add dep_w_mask equ 2ch+zlib1222add dep_good_match equ 84h+zlib1222add dep_match_start equ 68h+zlib1222add dep_lookahead equ 6ch+zlib1222add _TEXT segment IFDEF NOUNDERLINE IFDEF NOOLDPENTIUMCODE public longest_match public match_init ELSE public longest_match_7fff public cpudetect32 public longest_match_686 ENDIF ELSE IFDEF NOOLDPENTIUMCODE public _longest_match public _match_init ELSE public _longest_match_7fff public _cpudetect32 public _longest_match_686 ENDIF ENDIF MAX_MATCH equ 258 MIN_MATCH equ 3 MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1) IFNDEF NOOLDPENTIUMCODE IFDEF NOUNDERLINE longest_match_7fff proc near ELSE _longest_match_7fff proc near ENDIF mov edx,[esp+4] push ebp push edi push esi push ebx sub esp,NbStackAdd ; initialize or check the variables used in match.asm. mov ebp,edx ; chain_length = s->max_chain_length ; if (prev_length>=good_match) chain_length >>= 2 mov edx,[ebp+dep_chain_length] mov ebx,[ebp+dep_prev_length] cmp [ebp+dep_good_match],ebx ja noshr shr edx,2 noshr: ; we increment chain_length because in the asm, the --chain_lenght is in the beginning of the loop inc edx mov edi,[ebp+dep_nice_match] mov chain_length,edx mov eax,[ebp+dep_lookahead] cmp eax,edi ; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; jae nolookaheadnicematch mov edi,eax nolookaheadnicematch: ; best_len = s->prev_length mov best_len,ebx ; window = s->window mov esi,[ebp+dep_window] mov ecx,[ebp+dep_strstart] mov window,esi mov nice_match,edi ; scan = window + strstart add esi,ecx mov scan,esi ; dx = *window mov dx,word ptr [esi] ; bx = *(window+best_len-1) mov bx,word ptr [esi+ebx-1] add esi,MAX_MATCH-1 ; scan_start = *scan mov scan_start,dx ; strend = scan + MAX_MATCH-1 mov strend,esi ; bx = scan_end = *(window+best_len-1) ; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? ; s->strstart - (IPos)MAX_DIST(s) : NIL; mov esi,[ebp+dep_w_size] sub esi,MIN_LOOKAHEAD ; here esi = MAX_DIST(s) sub ecx,esi ja nodist xor ecx,ecx nodist: mov limit,ecx ; prev = s->prev mov edx,[ebp+dep_prev] mov prev,edx ; mov edx,dword ptr [ebp+dep_match_start] mov bp,scan_start mov eax,cur_match mov match_start,edx mov edx,window mov edi,edx add edi,best_len mov esi,prev dec edi ; windowlen = window + best_len -1 mov windowlen,edi jmp beginloop2 align 4 ; here, in the loop ; eax = ax = cur_match ; ecx = limit ; bx = scan_end ; bp = scan_start ; edi = windowlen (window + best_len -1) ; esi = prev ;// here; chain_length <=16 normalbeg0add16: add chain_length,16 jz exitloop normalbeg0: cmp word ptr[edi+eax],bx je normalbeg2noroll rcontlabnoroll: ; cur_match = prev[cur_match & wmask] and eax,7fffh mov ax,word ptr[esi+eax*2] ; if cur_match > limit, go to exitloop cmp ecx,eax jnb exitloop ; if --chain_length != 0, go to exitloop dec chain_length jnz normalbeg0 jmp exitloop normalbeg2noroll: ; if (scan_start==*(cur_match+window)) goto normalbeg2 cmp bp,word ptr[edx+eax] jne rcontlabnoroll jmp normalbeg2 contloop3: mov edi,windowlen ; cur_match = prev[cur_match & wmask] and eax,7fffh mov ax,word ptr[esi+eax*2] ; if cur_match > limit, go to exitloop cmp ecx,eax jnbexitloopshort1: jnb exitloop ; if --chain_length != 0, go to exitloop ; begin the main loop beginloop2: sub chain_length,16+1 ; if chain_length <=16, don't use the unrolled loop jna normalbeg0add16 do16: cmp word ptr[edi+eax],bx je normalbeg2dc0 maccn MACRO lab and eax,7fffh mov ax,word ptr[esi+eax*2] cmp ecx,eax jnb exitloop cmp word ptr[edi+eax],bx je lab ENDM rcontloop0: maccn normalbeg2dc1 rcontloop1: maccn normalbeg2dc2 rcontloop2: maccn normalbeg2dc3 rcontloop3: maccn normalbeg2dc4 rcontloop4: maccn normalbeg2dc5 rcontloop5: maccn normalbeg2dc6 rcontloop6: maccn normalbeg2dc7 rcontloop7: maccn normalbeg2dc8 rcontloop8: maccn normalbeg2dc9 rcontloop9: maccn normalbeg2dc10 rcontloop10: maccn short normalbeg2dc11 rcontloop11: maccn short normalbeg2dc12 rcontloop12: maccn short normalbeg2dc13 rcontloop13: maccn short normalbeg2dc14 rcontloop14: maccn short normalbeg2dc15 rcontloop15: and eax,7fffh mov ax,word ptr[esi+eax*2] cmp ecx,eax jnb exitloop sub chain_length,16 ja do16 jmp normalbeg0add16 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; normbeg MACRO rcontlab,valsub ; if we are here, we know that *(match+best_len-1) == scan_end cmp bp,word ptr[edx+eax] ; if (match != scan_start) goto rcontlab jne rcontlab ; calculate the good chain_length, and we'll compare scan and match string add chain_length,16-valsub jmp iseq ENDM normalbeg2dc11: normbeg rcontloop11,11 normalbeg2dc12: normbeg short rcontloop12,12 normalbeg2dc13: normbeg short rcontloop13,13 normalbeg2dc14: normbeg short rcontloop14,14 normalbeg2dc15: normbeg short rcontloop15,15 normalbeg2dc10: normbeg rcontloop10,10 normalbeg2dc9: normbeg rcontloop9,9 normalbeg2dc8: normbeg rcontloop8,8 normalbeg2dc7: normbeg rcontloop7,7 normalbeg2dc6: normbeg rcontloop6,6 normalbeg2dc5: normbeg rcontloop5,5 normalbeg2dc4: normbeg rcontloop4,4 normalbeg2dc3: normbeg rcontloop3,3 normalbeg2dc2: normbeg rcontloop2,2 normalbeg2dc1: normbeg rcontloop1,1 normalbeg2dc0: normbeg rcontloop0,0 ; we go in normalbeg2 because *(ushf*)(match+best_len-1) == scan_end normalbeg2: mov edi,window cmp bp,word ptr[edi+eax] jne contloop3 ; if *(ushf*)match != scan_start, continue iseq: ; if we are here, we know that *(match+best_len-1) == scan_end ; and (match == scan_start) mov edi,edx mov esi,scan ; esi = scan add edi,eax ; edi = window + cur_match = match mov edx,[esi+3] ; compare manually dword at match+3 xor edx,[edi+3] ; and scan +3 jz begincompare ; if equal, go to long compare ; we will determine the unmatch byte and calculate len (in esi) or dl,dl je eq1rr mov esi,3 jmp trfinval eq1rr: or dx,dx je eq1 mov esi,4 jmp trfinval eq1: and edx,0ffffffh jz eq11 mov esi,5 jmp trfinval eq11: mov esi,6 jmp trfinval begincompare: ; here we now scan and match begin same add edi,6 add esi,6 mov ecx,(MAX_MATCH-(2+4))/4 ; scan for at most MAX_MATCH bytes repe cmpsd ; loop until mismatch je trfin ; go to trfin if not unmatch ; we determine the unmatch byte sub esi,4 mov edx,[edi-4] xor edx,[esi] or dl,dl jnz trfin inc esi or dx,dx jnz trfin inc esi and edx,0ffffffh jnz trfin inc esi trfin: sub esi,scan ; esi = len trfinval: ; here we have finised compare, and esi contain len of equal string cmp esi,best_len ; if len > best_len, go newbestlen ja short newbestlen ; now we restore edx, ecx and esi, for the big loop mov esi,prev mov ecx,limit mov edx,window jmp contloop3 newbestlen: mov best_len,esi ; len become best_len mov match_start,eax ; save new position as match_start cmp esi,nice_match ; if best_len >= nice_match, exit jae exitloop mov ecx,scan mov edx,window ; restore edx=window add ecx,esi add esi,edx dec esi mov windowlen,esi ; windowlen = window + best_len-1 mov bx,[ecx-1] ; bx = *(scan+best_len-1) = scan_end ; now we restore ecx and esi, for the big loop : mov esi,prev mov ecx,limit jmp contloop3 exitloop: ; exit : s->match_start=match_start mov ebx,match_start mov ebp,str_s mov ecx,best_len mov dword ptr [ebp+dep_match_start],ebx mov eax,dword ptr [ebp+dep_lookahead] cmp ecx,eax ja minexlo mov eax,ecx minexlo: ; return min(best_len,s->lookahead) ; restore stack and register ebx,esi,edi,ebp add esp,NbStackAdd pop ebx pop esi pop edi pop ebp ret InfoAuthor: ; please don't remove this string ! ; Your are free use gvmat32 in any fre or commercial apps if you don't remove the string in the binary! db 0dh,0ah,"GVMat32 optimised assembly code written 1996-98 by Gilles Vollant",0dh,0ah IFDEF NOUNDERLINE longest_match_7fff endp ELSE _longest_match_7fff endp ENDIF IFDEF NOUNDERLINE cpudetect32 proc near ELSE _cpudetect32 proc near ENDIF push ebx pushfd ; push original EFLAGS pop eax ; get original EFLAGS mov ecx, eax ; save original EFLAGS xor eax, 40000h ; flip AC bit in EFLAGS push eax ; save new EFLAGS value on stack popfd ; replace current EFLAGS value pushfd ; get new EFLAGS pop eax ; store new EFLAGS in EAX xor eax, ecx ; can’t toggle AC bit, processor=80386 jz end_cpu_is_386 ; jump if 80386 processor push ecx popfd ; restore AC bit in EFLAGS first pushfd pushfd pop ecx mov eax, ecx ; get original EFLAGS xor eax, 200000h ; flip ID bit in EFLAGS push eax ; save new EFLAGS value on stack popfd ; replace current EFLAGS value pushfd ; get new EFLAGS pop eax ; store new EFLAGS in EAX popfd ; restore original EFLAGS xor eax, ecx ; can’t toggle ID bit, je is_old_486 ; processor=old mov eax,1 db 0fh,0a2h ;CPUID exitcpudetect: pop ebx ret end_cpu_is_386: mov eax,0300h jmp exitcpudetect is_old_486: mov eax,0400h jmp exitcpudetect IFDEF NOUNDERLINE cpudetect32 endp ELSE _cpudetect32 endp ENDIF ENDIF MAX_MATCH equ 258 MIN_MATCH equ 3 MIN_LOOKAHEAD equ (MAX_MATCH + MIN_MATCH + 1) MAX_MATCH_8_ equ ((MAX_MATCH + 7) AND 0FFF0h) ;;; stack frame offsets chainlenwmask equ esp + 0 ; high word: current chain len ; low word: s->wmask window equ esp + 4 ; local copy of s->window windowbestlen equ esp + 8 ; s->window + bestlen scanstart equ esp + 16 ; first two bytes of string scanend equ esp + 12 ; last two bytes of string scanalign equ esp + 20 ; dword-misalignment of string nicematch equ esp + 24 ; a good enough match size bestlen equ esp + 28 ; size of best match so far scan equ esp + 32 ; ptr to string wanting match LocalVarsSize equ 36 ; saved ebx byte esp + 36 ; saved edi byte esp + 40 ; saved esi byte esp + 44 ; saved ebp byte esp + 48 ; return address byte esp + 52 deflatestate equ esp + 56 ; the function arguments curmatch equ esp + 60 ;;; Offsets for fields in the deflate_state structure. These numbers ;;; are calculated from the definition of deflate_state, with the ;;; assumption that the compiler will dword-align the fields. (Thus, ;;; changing the definition of deflate_state could easily cause this ;;; program to crash horribly, without so much as a warning at ;;; compile time. Sigh.) dsWSize equ 36+zlib1222add dsWMask equ 44+zlib1222add dsWindow equ 48+zlib1222add dsPrev equ 56+zlib1222add dsMatchLen equ 88+zlib1222add dsPrevMatch equ 92+zlib1222add dsStrStart equ 100+zlib1222add dsMatchStart equ 104+zlib1222add dsLookahead equ 108+zlib1222add dsPrevLen equ 112+zlib1222add dsMaxChainLen equ 116+zlib1222add dsGoodMatch equ 132+zlib1222add dsNiceMatch equ 136+zlib1222add ;;; match.asm -- Pentium-Pro-optimized version of longest_match() ;;; Written for zlib 1.1.2 ;;; Copyright (C) 1998 Brian Raiter ;;; You can look at http://www.muppetlabs.com/~breadbox/software/assembly.html ;;; ;;; This is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License. ;GLOBAL _longest_match, _match_init ;SECTION .text ;;; uInt longest_match(deflate_state *deflatestate, IPos curmatch) ;_longest_match: IFDEF NOOLDPENTIUMCODE IFDEF NOUNDERLINE longest_match proc near ELSE _longest_match proc near ENDIF ELSE IFDEF NOUNDERLINE longest_match_686 proc near ELSE _longest_match_686 proc near ENDIF ENDIF ;;; Save registers that the compiler may be using, and adjust esp to ;;; make room for our stack frame. push ebp push edi push esi push ebx sub esp, LocalVarsSize ;;; Retrieve the function arguments. ecx will hold cur_match ;;; throughout the entire function. edx will hold the pointer to the ;;; deflate_state structure during the function's setup (before ;;; entering the main loop. mov edx, [deflatestate] mov ecx, [curmatch] ;;; uInt wmask = s->w_mask; ;;; unsigned chain_length = s->max_chain_length; ;;; if (s->prev_length >= s->good_match) { ;;; chain_length >>= 2; ;;; } mov eax, [edx + dsPrevLen] mov ebx, [edx + dsGoodMatch] cmp eax, ebx mov eax, [edx + dsWMask] mov ebx, [edx + dsMaxChainLen] jl LastMatchGood shr ebx, 2 LastMatchGood: ;;; chainlen is decremented once beforehand so that the function can ;;; use the sign flag instead of the zero flag for the exit test. ;;; It is then shifted into the high word, to make room for the wmask ;;; value, which it will always accompany. dec ebx shl ebx, 16 or ebx, eax mov [chainlenwmask], ebx ;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; mov eax, [edx + dsNiceMatch] mov ebx, [edx + dsLookahead] cmp ebx, eax jl LookaheadLess mov ebx, eax LookaheadLess: mov [nicematch], ebx ;;; register Bytef *scan = s->window + s->strstart; mov esi, [edx + dsWindow] mov [window], esi mov ebp, [edx + dsStrStart] lea edi, [esi + ebp] mov [scan], edi ;;; Determine how many bytes the scan ptr is off from being ;;; dword-aligned. mov eax, edi neg eax and eax, 3 mov [scanalign], eax ;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? ;;; s->strstart - (IPos)MAX_DIST(s) : NIL; mov eax, [edx + dsWSize] sub eax, MIN_LOOKAHEAD sub ebp, eax jg LimitPositive xor ebp, ebp LimitPositive: ;;; int best_len = s->prev_length; mov eax, [edx + dsPrevLen] mov [bestlen], eax ;;; Store the sum of s->window + best_len in esi locally, and in esi. add esi, eax mov [windowbestlen], esi ;;; register ush scan_start = *(ushf*)scan; ;;; register ush scan_end = *(ushf*)(scan+best_len-1); ;;; Posf *prev = s->prev; movzx ebx, word ptr [edi] mov [scanstart], ebx movzx ebx, word ptr [edi + eax - 1] mov [scanend], ebx mov edi, [edx + dsPrev] ;;; Jump into the main loop. mov edx, [chainlenwmask] jmp short LoopEntry align 4 ;;; do { ;;; match = s->window + cur_match; ;;; if (*(ushf*)(match+best_len-1) != scan_end || ;;; *(ushf*)match != scan_start) continue; ;;; [...] ;;; } while ((cur_match = prev[cur_match & wmask]) > limit ;;; && --chain_length != 0); ;;; ;;; Here is the inner loop of the function. The function will spend the ;;; majority of its time in this loop, and majority of that time will ;;; be spent in the first ten instructions. ;;; ;;; Within this loop: ;;; ebx = scanend ;;; ecx = curmatch ;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) ;;; esi = windowbestlen - i.e., (window + bestlen) ;;; edi = prev ;;; ebp = limit LookupLoop: and ecx, edx movzx ecx, word ptr [edi + ecx*2] cmp ecx, ebp jbe LeaveNow sub edx, 00010000h js LeaveNow LoopEntry: movzx eax, word ptr [esi + ecx - 1] cmp eax, ebx jnz LookupLoop mov eax, [window] movzx eax, word ptr [eax + ecx] cmp eax, [scanstart] jnz LookupLoop ;;; Store the current value of chainlen. mov [chainlenwmask], edx ;;; Point edi to the string under scrutiny, and esi to the string we ;;; are hoping to match it up with. In actuality, esi and edi are ;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is ;;; initialized to -(MAX_MATCH_8 - scanalign). mov esi, [window] mov edi, [scan] add esi, ecx mov eax, [scanalign] mov edx, 0fffffef8h; -(MAX_MATCH_8) lea edi, [edi + eax + 0108h] ;MAX_MATCH_8] lea esi, [esi + eax + 0108h] ;MAX_MATCH_8] ;;; Test the strings for equality, 8 bytes at a time. At the end, ;;; adjust edx so that it is offset to the exact byte that mismatched. ;;; ;;; We already know at this point that the first three bytes of the ;;; strings match each other, and they can be safely passed over before ;;; starting the compare loop. So what this code does is skip over 0-3 ;;; bytes, as much as necessary in order to dword-align the edi ;;; pointer. (esi will still be misaligned three times out of four.) ;;; ;;; It should be confessed that this loop usually does not represent ;;; much of the total running time. Replacing it with a more ;;; straightforward "rep cmpsb" would not drastically degrade ;;; performance. LoopCmps: mov eax, [esi + edx] xor eax, [edi + edx] jnz LeaveLoopCmps mov eax, [esi + edx + 4] xor eax, [edi + edx + 4] jnz LeaveLoopCmps4 add edx, 8 jnz LoopCmps jmp short LenMaximum LeaveLoopCmps4: add edx, 4 LeaveLoopCmps: test eax, 0000FFFFh jnz LenLower add edx, 2 shr eax, 16 LenLower: sub al, 1 adc edx, 0 ;;; Calculate the length of the match. If it is longer than MAX_MATCH, ;;; then automatically accept it as the best possible match and leave. lea eax, [edi + edx] mov edi, [scan] sub eax, edi cmp eax, MAX_MATCH jge LenMaximum ;;; If the length of the match is not longer than the best match we ;;; have so far, then forget it and return to the lookup loop. mov edx, [deflatestate] mov ebx, [bestlen] cmp eax, ebx jg LongerMatch mov esi, [windowbestlen] mov edi, [edx + dsPrev] mov ebx, [scanend] mov edx, [chainlenwmask] jmp LookupLoop ;;; s->match_start = cur_match; ;;; best_len = len; ;;; if (len >= nice_match) break; ;;; scan_end = *(ushf*)(scan+best_len-1); LongerMatch: mov ebx, [nicematch] mov [bestlen], eax mov [edx + dsMatchStart], ecx cmp eax, ebx jge LeaveNow mov esi, [window] add esi, eax mov [windowbestlen], esi movzx ebx, word ptr [edi + eax - 1] mov edi, [edx + dsPrev] mov [scanend], ebx mov edx, [chainlenwmask] jmp LookupLoop ;;; Accept the current string, with the maximum possible length. LenMaximum: mov edx, [deflatestate] mov dword ptr [bestlen], MAX_MATCH mov [edx + dsMatchStart], ecx ;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len; ;;; return s->lookahead; LeaveNow: mov edx, [deflatestate] mov ebx, [bestlen] mov eax, [edx + dsLookahead] cmp ebx, eax jg LookaheadRet mov eax, ebx LookaheadRet: ;;; Restore the stack and return from whence we came. add esp, LocalVarsSize pop ebx pop esi pop edi pop ebp ret ; please don't remove this string ! ; Your can freely use gvmat32 in any free or commercial app if you don't remove the string in the binary! db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998",0dh,0ah IFDEF NOOLDPENTIUMCODE IFDEF NOUNDERLINE longest_match endp ELSE _longest_match endp ENDIF IFDEF NOUNDERLINE match_init proc near ret match_init endp ELSE _match_init proc near ret _match_init endp ENDIF ELSE IFDEF NOUNDERLINE longest_match_686 endp ELSE _longest_match_686 endp ENDIF ENDIF _TEXT ends end sks-ecc-0.93/zlib/contrib/masmx86/mkasm.bat0000755000175000017500000000017710604550750017454 0ustar nachonachocl /DASMV /I..\.. /O2 /c gvmat32c.c ml /coff /Zi /c /Flgvmat32.lst gvmat32.asm ml /coff /Zi /c /Flinffas32.lst inffas32.asm sks-ecc-0.93/zlib/contrib/masmx86/inffas32.asm0000644000175000017500000003777210604550750020001 0ustar nachonacho;/* inffas32.asm is a hand tuned assembler version of inffast.c -- fast decoding ; * ; * inffas32.asm is derivated from inffas86.c, with translation of assembly code ; * ; * Copyright (C) 1995-2003 Mark Adler ; * For conditions of distribution and use, see copyright notice in zlib.h ; * ; * Copyright (C) 2003 Chris Anderson ; * Please use the copyright conditions above. ; * ; * Mar-13-2003 -- Most of this is derived from inffast.S which is derived from ; * the gcc -S output of zlib-1.2.0/inffast.c. Zlib-1.2.0 is in beta release at ; * the moment. I have successfully compiled and tested this code with gcc2.96, ; * gcc3.2, icc5.0, msvc6.0. It is very close to the speed of inffast.S ; * compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX ; * enabled. I will attempt to merge the MMX code into this version. Newer ; * versions of this and inffast.S can be found at ; * http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/ ; * ; * 2005 : modification by Gilles Vollant ; */ ; For Visual C++ 4.x and higher and ML 6.x and higher ; ml.exe is in directory \MASM611C of Win95 DDK ; ml.exe is also distributed in http://www.masm32.com/masmdl.htm ; and in VC++2003 toolkit at http://msdn.microsoft.com/visualc/vctoolkit2003/ ; ; ; compile with command line option ; ml /coff /Zi /c /Flinffas32.lst inffas32.asm ; if you define NO_GZIP (see inflate.h), compile with ; ml /coff /Zi /c /Flinffas32.lst /DNO_GUNZIP inffas32.asm ; zlib122sup is 0 fort zlib 1.2.2.1 and lower ; zlib122sup is 8 fort zlib 1.2.2.2 and more (with addition of dmax and head ; in inflate_state in inflate.h) zlib1222sup equ 8 IFDEF GUNZIP INFLATE_MODE_TYPE equ 11 INFLATE_MODE_BAD equ 26 ELSE IFNDEF NO_GUNZIP INFLATE_MODE_TYPE equ 11 INFLATE_MODE_BAD equ 26 ELSE INFLATE_MODE_TYPE equ 3 INFLATE_MODE_BAD equ 17 ENDIF ENDIF ; 75 "inffast.S" ;FILE "inffast.S" ;;;GLOBAL _inflate_fast ;;;SECTION .text .586p .mmx name inflate_fast_x86 .MODEL FLAT _DATA segment inflate_fast_use_mmx: dd 1 _TEXT segment PUBLIC _inflate_fast ALIGN 4 _inflate_fast: jmp inflate_fast_entry ALIGN 4 db 'Fast decoding Code from Chris Anderson' db 0 ALIGN 4 invalid_literal_length_code_msg: db 'invalid literal/length code' db 0 ALIGN 4 invalid_distance_code_msg: db 'invalid distance code' db 0 ALIGN 4 invalid_distance_too_far_msg: db 'invalid distance too far back' db 0 ALIGN 4 inflate_fast_mask: dd 0 dd 1 dd 3 dd 7 dd 15 dd 31 dd 63 dd 127 dd 255 dd 511 dd 1023 dd 2047 dd 4095 dd 8191 dd 16383 dd 32767 dd 65535 dd 131071 dd 262143 dd 524287 dd 1048575 dd 2097151 dd 4194303 dd 8388607 dd 16777215 dd 33554431 dd 67108863 dd 134217727 dd 268435455 dd 536870911 dd 1073741823 dd 2147483647 dd 4294967295 mode_state equ 0 ;/* state->mode */ wsize_state equ (32+zlib1222sup) ;/* state->wsize */ write_state equ (36+4+zlib1222sup) ;/* state->write */ window_state equ (40+4+zlib1222sup) ;/* state->window */ hold_state equ (44+4+zlib1222sup) ;/* state->hold */ bits_state equ (48+4+zlib1222sup) ;/* state->bits */ lencode_state equ (64+4+zlib1222sup) ;/* state->lencode */ distcode_state equ (68+4+zlib1222sup) ;/* state->distcode */ lenbits_state equ (72+4+zlib1222sup) ;/* state->lenbits */ distbits_state equ (76+4+zlib1222sup) ;/* state->distbits */ ;;SECTION .text ; 205 "inffast.S" ;GLOBAL inflate_fast_use_mmx ;SECTION .data ; GLOBAL inflate_fast_use_mmx:object ;.size inflate_fast_use_mmx, 4 ; 226 "inffast.S" ;SECTION .text ALIGN 4 inflate_fast_entry: push edi push esi push ebp push ebx pushfd sub esp,64 cld mov esi, [esp+88] mov edi, [esi+28] mov edx, [esi+4] mov eax, [esi+0] add edx,eax sub edx,11 mov [esp+44],eax mov [esp+20],edx mov ebp, [esp+92] mov ecx, [esi+16] mov ebx, [esi+12] sub ebp,ecx neg ebp add ebp,ebx sub ecx,257 add ecx,ebx mov [esp+60],ebx mov [esp+40],ebp mov [esp+16],ecx ; 285 "inffast.S" mov eax, [edi+lencode_state] mov ecx, [edi+distcode_state] mov [esp+8],eax mov [esp+12],ecx mov eax,1 mov ecx, [edi+lenbits_state] shl eax,cl dec eax mov [esp+0],eax mov eax,1 mov ecx, [edi+distbits_state] shl eax,cl dec eax mov [esp+4],eax mov eax, [edi+wsize_state] mov ecx, [edi+write_state] mov edx, [edi+window_state] mov [esp+52],eax mov [esp+48],ecx mov [esp+56],edx mov ebp, [edi+hold_state] mov ebx, [edi+bits_state] ; 321 "inffast.S" mov esi, [esp+44] mov ecx, [esp+20] cmp ecx,esi ja L_align_long add ecx,11 sub ecx,esi mov eax,12 sub eax,ecx lea edi, [esp+28] rep movsb mov ecx,eax xor eax,eax rep stosb lea esi, [esp+28] mov [esp+20],esi jmp L_is_aligned L_align_long: test esi,3 jz L_is_aligned xor eax,eax mov al, [esi] inc esi mov ecx,ebx add ebx,8 shl eax,cl or ebp,eax jmp L_align_long L_is_aligned: mov edi, [esp+60] ; 366 "inffast.S" L_check_mmx: cmp dword ptr [inflate_fast_use_mmx],2 je L_init_mmx ja L_do_loop push eax push ebx push ecx push edx pushfd mov eax, [esp] xor dword ptr [esp],0200000h popfd pushfd pop edx xor edx,eax jz L_dont_use_mmx xor eax,eax cpuid cmp ebx,0756e6547h jne L_dont_use_mmx cmp ecx,06c65746eh jne L_dont_use_mmx cmp edx,049656e69h jne L_dont_use_mmx mov eax,1 cpuid shr eax,8 and eax,15 cmp eax,6 jne L_dont_use_mmx test edx,0800000h jnz L_use_mmx jmp L_dont_use_mmx L_use_mmx: mov dword ptr [inflate_fast_use_mmx],2 jmp L_check_mmx_pop L_dont_use_mmx: mov dword ptr [inflate_fast_use_mmx],3 L_check_mmx_pop: pop edx pop ecx pop ebx pop eax jmp L_check_mmx ; 426 "inffast.S" ALIGN 4 L_do_loop: ; 437 "inffast.S" cmp bl,15 ja L_get_length_code xor eax,eax lodsw mov cl,bl add bl,16 shl eax,cl or ebp,eax L_get_length_code: mov edx, [esp+0] mov ecx, [esp+8] and edx,ebp mov eax, [ecx+edx*4] L_dolen: mov cl,ah sub bl,ah shr ebp,cl test al,al jnz L_test_for_length_base shr eax,16 stosb L_while_test: cmp [esp+16],edi jbe L_break_loop cmp [esp+20],esi ja L_do_loop jmp L_break_loop L_test_for_length_base: ; 502 "inffast.S" mov edx,eax shr edx,16 mov cl,al test al,16 jz L_test_for_second_level_length and cl,15 jz L_save_len cmp bl,cl jae L_add_bits_to_len mov ch,cl xor eax,eax lodsw mov cl,bl add bl,16 shl eax,cl or ebp,eax mov cl,ch L_add_bits_to_len: mov eax,1 shl eax,cl dec eax sub bl,cl and eax,ebp shr ebp,cl add edx,eax L_save_len: mov [esp+24],edx L_decode_distance: ; 549 "inffast.S" cmp bl,15 ja L_get_distance_code xor eax,eax lodsw mov cl,bl add bl,16 shl eax,cl or ebp,eax L_get_distance_code: mov edx, [esp+4] mov ecx, [esp+12] and edx,ebp mov eax, [ecx+edx*4] L_dodist: mov edx,eax shr edx,16 mov cl,ah sub bl,ah shr ebp,cl ; 584 "inffast.S" mov cl,al test al,16 jz L_test_for_second_level_dist and cl,15 jz L_check_dist_one cmp bl,cl jae L_add_bits_to_dist mov ch,cl xor eax,eax lodsw mov cl,bl add bl,16 shl eax,cl or ebp,eax mov cl,ch L_add_bits_to_dist: mov eax,1 shl eax,cl dec eax sub bl,cl and eax,ebp shr ebp,cl add edx,eax jmp L_check_window L_check_window: ; 625 "inffast.S" mov [esp+44],esi mov eax,edi sub eax, [esp+40] cmp eax,edx jb L_clip_window mov ecx, [esp+24] mov esi,edi sub esi,edx sub ecx,3 mov al, [esi] mov [edi],al mov al, [esi+1] mov dl, [esi+2] add esi,3 mov [edi+1],al mov [edi+2],dl add edi,3 rep movsb mov esi, [esp+44] jmp L_while_test ALIGN 4 L_check_dist_one: cmp edx,1 jne L_check_window cmp [esp+40],edi je L_check_window dec edi mov ecx, [esp+24] mov al, [edi] sub ecx,3 mov [edi+1],al mov [edi+2],al mov [edi+3],al add edi,4 rep stosb jmp L_while_test ALIGN 4 L_test_for_second_level_length: test al,64 jnz L_test_for_end_of_block mov eax,1 shl eax,cl dec eax and eax,ebp add eax,edx mov edx, [esp+8] mov eax, [edx+eax*4] jmp L_dolen ALIGN 4 L_test_for_second_level_dist: test al,64 jnz L_invalid_distance_code mov eax,1 shl eax,cl dec eax and eax,ebp add eax,edx mov edx, [esp+12] mov eax, [edx+eax*4] jmp L_dodist ALIGN 4 L_clip_window: ; 721 "inffast.S" mov ecx,eax mov eax, [esp+52] neg ecx mov esi, [esp+56] cmp eax,edx jb L_invalid_distance_too_far add ecx,edx cmp dword ptr [esp+48],0 jne L_wrap_around_window sub eax,ecx add esi,eax ; 749 "inffast.S" mov eax, [esp+24] cmp eax,ecx jbe L_do_copy1 sub eax,ecx rep movsb mov esi,edi sub esi,edx jmp L_do_copy1 cmp eax,ecx jbe L_do_copy1 sub eax,ecx rep movsb mov esi,edi sub esi,edx jmp L_do_copy1 L_wrap_around_window: ; 793 "inffast.S" mov eax, [esp+48] cmp ecx,eax jbe L_contiguous_in_window add esi, [esp+52] add esi,eax sub esi,ecx sub ecx,eax mov eax, [esp+24] cmp eax,ecx jbe L_do_copy1 sub eax,ecx rep movsb mov esi, [esp+56] mov ecx, [esp+48] cmp eax,ecx jbe L_do_copy1 sub eax,ecx rep movsb mov esi,edi sub esi,edx jmp L_do_copy1 L_contiguous_in_window: ; 836 "inffast.S" add esi,eax sub esi,ecx mov eax, [esp+24] cmp eax,ecx jbe L_do_copy1 sub eax,ecx rep movsb mov esi,edi sub esi,edx L_do_copy1: ; 862 "inffast.S" mov ecx,eax rep movsb mov esi, [esp+44] jmp L_while_test ; 878 "inffast.S" ALIGN 4 L_init_mmx: emms movd mm0,ebp mov ebp,ebx ; 896 "inffast.S" movd mm4,[esp+0] movq mm3,mm4 movd mm5,[esp+4] movq mm2,mm5 pxor mm1,mm1 mov ebx, [esp+8] jmp L_do_loop_mmx ALIGN 4 L_do_loop_mmx: psrlq mm0,mm1 cmp ebp,32 ja L_get_length_code_mmx movd mm6,ebp movd mm7,[esi] add esi,4 psllq mm7,mm6 add ebp,32 por mm0,mm7 L_get_length_code_mmx: pand mm4,mm0 movd eax,mm4 movq mm4,mm3 mov eax, [ebx+eax*4] L_dolen_mmx: movzx ecx,ah movd mm1,ecx sub ebp,ecx test al,al jnz L_test_for_length_base_mmx shr eax,16 stosb L_while_test_mmx: cmp [esp+16],edi jbe L_break_loop cmp [esp+20],esi ja L_do_loop_mmx jmp L_break_loop L_test_for_length_base_mmx: mov edx,eax shr edx,16 test al,16 jz L_test_for_second_level_length_mmx and eax,15 jz L_decode_distance_mmx psrlq mm0,mm1 movd mm1,eax movd ecx,mm0 sub ebp,eax and ecx, [inflate_fast_mask+eax*4] add edx,ecx L_decode_distance_mmx: psrlq mm0,mm1 cmp ebp,32 ja L_get_dist_code_mmx movd mm6,ebp movd mm7,[esi] add esi,4 psllq mm7,mm6 add ebp,32 por mm0,mm7 L_get_dist_code_mmx: mov ebx, [esp+12] pand mm5,mm0 movd eax,mm5 movq mm5,mm2 mov eax, [ebx+eax*4] L_dodist_mmx: movzx ecx,ah mov ebx,eax shr ebx,16 sub ebp,ecx movd mm1,ecx test al,16 jz L_test_for_second_level_dist_mmx and eax,15 jz L_check_dist_one_mmx L_add_bits_to_dist_mmx: psrlq mm0,mm1 movd mm1,eax movd ecx,mm0 sub ebp,eax and ecx, [inflate_fast_mask+eax*4] add ebx,ecx L_check_window_mmx: mov [esp+44],esi mov eax,edi sub eax, [esp+40] cmp eax,ebx jb L_clip_window_mmx mov ecx,edx mov esi,edi sub esi,ebx sub ecx,3 mov al, [esi] mov [edi],al mov al, [esi+1] mov dl, [esi+2] add esi,3 mov [edi+1],al mov [edi+2],dl add edi,3 rep movsb mov esi, [esp+44] mov ebx, [esp+8] jmp L_while_test_mmx ALIGN 4 L_check_dist_one_mmx: cmp ebx,1 jne L_check_window_mmx cmp [esp+40],edi je L_check_window_mmx dec edi mov ecx,edx mov al, [edi] sub ecx,3 mov [edi+1],al mov [edi+2],al mov [edi+3],al add edi,4 rep stosb mov ebx, [esp+8] jmp L_while_test_mmx ALIGN 4 L_test_for_second_level_length_mmx: test al,64 jnz L_test_for_end_of_block and eax,15 psrlq mm0,mm1 movd ecx,mm0 and ecx, [inflate_fast_mask+eax*4] add ecx,edx mov eax, [ebx+ecx*4] jmp L_dolen_mmx ALIGN 4 L_test_for_second_level_dist_mmx: test al,64 jnz L_invalid_distance_code and eax,15 psrlq mm0,mm1 movd ecx,mm0 and ecx, [inflate_fast_mask+eax*4] mov eax, [esp+12] add ecx,ebx mov eax, [eax+ecx*4] jmp L_dodist_mmx ALIGN 4 L_clip_window_mmx: mov ecx,eax mov eax, [esp+52] neg ecx mov esi, [esp+56] cmp eax,ebx jb L_invalid_distance_too_far add ecx,ebx cmp dword ptr [esp+48],0 jne L_wrap_around_window_mmx sub eax,ecx add esi,eax cmp edx,ecx jbe L_do_copy1_mmx sub edx,ecx rep movsb mov esi,edi sub esi,ebx jmp L_do_copy1_mmx cmp edx,ecx jbe L_do_copy1_mmx sub edx,ecx rep movsb mov esi,edi sub esi,ebx jmp L_do_copy1_mmx L_wrap_around_window_mmx: mov eax, [esp+48] cmp ecx,eax jbe L_contiguous_in_window_mmx add esi, [esp+52] add esi,eax sub esi,ecx sub ecx,eax cmp edx,ecx jbe L_do_copy1_mmx sub edx,ecx rep movsb mov esi, [esp+56] mov ecx, [esp+48] cmp edx,ecx jbe L_do_copy1_mmx sub edx,ecx rep movsb mov esi,edi sub esi,ebx jmp L_do_copy1_mmx L_contiguous_in_window_mmx: add esi,eax sub esi,ecx cmp edx,ecx jbe L_do_copy1_mmx sub edx,ecx rep movsb mov esi,edi sub esi,ebx L_do_copy1_mmx: mov ecx,edx rep movsb mov esi, [esp+44] mov ebx, [esp+8] jmp L_while_test_mmx ; 1174 "inffast.S" L_invalid_distance_code: mov ecx, invalid_distance_code_msg mov edx,INFLATE_MODE_BAD jmp L_update_stream_state L_test_for_end_of_block: test al,32 jz L_invalid_literal_length_code mov ecx,0 mov edx,INFLATE_MODE_TYPE jmp L_update_stream_state L_invalid_literal_length_code: mov ecx, invalid_literal_length_code_msg mov edx,INFLATE_MODE_BAD jmp L_update_stream_state L_invalid_distance_too_far: mov esi, [esp+44] mov ecx, invalid_distance_too_far_msg mov edx,INFLATE_MODE_BAD jmp L_update_stream_state L_update_stream_state: mov eax, [esp+88] test ecx,ecx jz L_skip_msg mov [eax+24],ecx L_skip_msg: mov eax, [eax+28] mov [eax+mode_state],edx jmp L_break_loop ALIGN 4 L_break_loop: ; 1243 "inffast.S" cmp dword ptr [inflate_fast_use_mmx],2 jne L_update_next_in mov ebx,ebp L_update_next_in: ; 1266 "inffast.S" mov eax, [esp+88] mov ecx,ebx mov edx, [eax+28] shr ecx,3 sub esi,ecx shl ecx,3 sub ebx,ecx mov [eax+12],edi mov [edx+bits_state],ebx mov ecx,ebx lea ebx, [esp+28] cmp [esp+20],ebx jne L_buf_not_used sub esi,ebx mov ebx, [eax+0] mov [esp+20],ebx add esi,ebx mov ebx, [eax+4] sub ebx,11 add [esp+20],ebx L_buf_not_used: mov [eax+0],esi mov ebx,1 shl ebx,cl dec ebx cmp dword ptr [inflate_fast_use_mmx],2 jne L_update_hold psrlq mm0,mm1 movd ebp,mm0 emms L_update_hold: and ebp,ebx mov [edx+hold_state],ebp mov ebx, [esp+20] cmp ebx,esi jbe L_last_is_smaller sub ebx,esi add ebx,11 mov [eax+4],ebx jmp L_fixup_out L_last_is_smaller: sub esi,ebx neg esi add esi,11 mov [eax+4],esi L_fixup_out: mov ebx, [esp+16] cmp ebx,edi jbe L_end_is_smaller sub ebx,edi add ebx,257 mov [eax+16],ebx jmp L_done L_end_is_smaller: sub edi,ebx neg edi add edi,257 mov [eax+16],edi L_done: add esp,64 popfd pop ebx pop ebp pop esi pop edi ret _TEXT ends end sks-ecc-0.93/zlib/contrib/masmx86/inffas32.obj0000644000175000017500000003505510604550750017763 0ustar nachonachoLvŽBÖ/R.text›´PÈ Q P`.data›®@PÀ.debug$SŸ²Ê%þ@B.debug$T· ¶/@BéIFast decoding Code from Chris Andersoninvalid literal/length codeinvalid distance code‹ÿinvalid distance too far back‹ÿ?ÿÿÿÿÿÿÿ?ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ?ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ?ÿÿÿÿÿÿÿWVUSœƒì@ü‹t$X‹~‹V‹Ðƒê ‰D$,‰T$‹l$\‹N‹^ +é÷Ýëéˉ\$<‰l$(‰L$‹GL‹OP‰D$‰L$ ¸‹OTÓàH‰$¸‹OXÓàH‰D$‹G(‹O0‹W4‰D$4‰L$0‰T$8‹o8‹_<‹t$,‹L$;Îw"ƒÁ +θ +Á|$ó¤‹È3Àóªt$‰t$ë÷Æt3ÀŠF‹ËƒÃÓà èëè‹|$<ƒ=„‰wkPSQRœ‹$4$ œZ3ÐtD3À¢ûGenuu8ùntelu0úineIu(¸¢Áèƒàƒøu÷€uë Çë ÇZY[X뇀ûw 3Àf­ŠË€ÃÓà è‹$‹L$#Õ‹‘ŠÌ*ÜÓí„ÀuÁèª9|$†b9t$wÄéW‹ÐÁêŠÈ¨„ô€át%8ËsŠé3Àf­ŠË€ÃÓà èŠÍ¸ÓàH*Ù#ÅÓíЉT$€ûw 3Àf­ŠË€ÃÓà è‹T$‹L$ #Õ‹‘‹ÐÁêŠÌ*ÜÓíŠÈ¨„²€áte8ËsŠé3Àf­ŠË€ÃÓà èŠÍ¸ÓàH*Ù#ÅÓíÐë‰t$,‹Ç+D$(;‚”‹L$‹÷+òƒéŠˆŠFŠVƒÆˆGˆWƒÇó¤‹t$,éÿÿÿƒúu½9|$(t·O‹L$ŠƒéˆGˆGˆGƒÇóªéèþÿÿ¨@…¸ÓàH#Å‹T$‹‚éºþÿÿ¨@…â¸ÓàH#Å‹T$ ‹‚éÿÿÿ‹È‹D$4÷Ù‹t$8;‚Þʃ|$0u$+Áð‹D$;Áv`+Áó¤‹÷+òëV;ÁvR+Áó¤‹÷+òëH‹D$0;Èv,t$4ð+ñ+È‹D$;Áv.+Áó¤‹t$8‹L$0;Áv+Áó¤‹÷+òëð+ñ‹D$;Áv+Áó¤‹÷+ò‹Èó¤‹t$,éþÿÿ‹ÿwnÅ‹ën$$ãnl$êïÉ‹\$ëÓÁƒý wnõn>ƒÆóþƒÅ ëÇÛà~àÜ‹ƒ¶ÌnÉ+é„ÀuÁèª9|$†9t$wºé‹ÐÁꨄàƒàtÓÁnÈ~Á+è# …ÑÓÁƒý wnõn>ƒÆóþƒÅ ëÇ‹\$ Ûè~èÕ‹ƒ¶Ì‹ØÁë+énɨ„¬ƒàtWÓÁnÈ~Á+è# …Ù‰t$,‹Ç+D$(;©‹Ê‹÷+óƒéŠˆŠFŠVƒÆˆGˆWƒÇó¤‹t$,‹\$é-ÿÿÿIƒûu¸9|$(t²O‹ÊŠƒéˆGˆGˆGƒÇóª‹\$éÿÿÿ‹ÿ¨@…ÞƒàÓÁ~Á# …Ê‹‹éÌþÿÿ‹ÿ¨@…®ƒàÓÁ~Á# …‹D$ Ë‹ˆéÿÿÿ‹ÿ‹È‹D$4÷Ù‹t$8;¢˃|$0u +Áð;ÑvX+Ñó¤‹÷+óëN;ÑvJ+Ñó¤‹÷+óë@‹D$0;Èv(t$4ð+ñ+È;Ñv*+Ñó¤‹t$8‹L$0;Ñv+Ñó¤‹÷+óëð+ñ;Ñv+Ñó¤‹÷+ó‹Êó¤‹t$,‹\$é$þÿÿ¹ºë,¨ t ¹º 빺ë‹t$,¹ºë‹D$X…Ét‰H‹@‰ëƒ=u‹Ý‹D$X‹Ë‹PÁé+ñÁá+Ù‰x ‰Z<‹Ë\$9\$u+ó‹‰\$ó‹Xƒë \$‰0»ÓãKƒ=uÓÁ~Åw#ë‰j8‹\$;Þv +ރà ‰Xë +ó÷ÞƒÆ ‰p‹\$;ßv +ßÉXë +û÷ßljxƒÄ@[]^_Ãà=Iÿ W à  § ÃÓò@W X Y Z [ \]bcklno"q&r*t.u1v4x6y8z:|@}BF€JNƒQ„T†X‡\‰aŠd‹fŒgjor‘t’u“y•|–—‚™†šŠ›Ž‘ž” ˜¡œ¢ž£ ¥£¦¥§ª¨¬©°ª²«´¬¶­¸®¼¯À°Â´ÈµÊ¶Ì·Î¸Ï¹ÑºÔ»Ö¼Ø½ÚÀÞÃåÄëÅíÇîÈïÉðÊñËòÌõÍüÒýÓþÔÿÕÖ×ØÙ ÚÛÜÝÞß$à&á)â,ã/ä1å7æ9ç;éEêGìQîRïSðTñUòX÷[ø]ú_ûaücýfþhÿjmqsvxz|~€ƒ„ ˆ!Ž#’$”%™)›*ž+ -¢.¨/«0­1¯2±4³5µ6·7¹8¼9¾:À;Â>Ç?É@ÊAÌBÎCÐDÒGÖLÙMÛOÝPßQáRäSæTèWìXðYòZõ^÷_ú`üaþbdfg h ijkmnopqr s"t$w)x+y,z.{0|2}4~6‚:ƒ<„@†B‡H‰LŠN‹PSŽUWZ‘]’`“c”f•i–k˜o™twžyŸ} ¢€£„¤†¥‰§Œ¨©’ª•«—­œµž¶¤¸©¹«º¬»®¼°½´¾·¿¼Ç¾ÈÄÊÉËËÌÌÍÎÎÐÏÔÐ×ÑÜÖÞ×âØäÙèÛêÜðÞòß÷àùâûãýåæçéê ë ì íïðòóôõöú!û#ü%þ)ÿ+-/3579 ; ? C E GIKMOQSUY[]_ a!c"e&g'i)m*t.v4y5{78‚9‡:Š;<‘=”A—CšDœFŸG¢H¥I¨J«K®N±O´P·QºT½UÀVÂXÄYÆ[É\ÊaÎbÔdØeÚfßjákämænìoïpñrôs÷túuüvwz| } €‚ƒ„‡#ˆ&‰)Š,‹/24‘7’9“<•>–D—G˜I›LœORžTŸ[ ]£a¤c¥g§i¨oªq«s¬u®x¯z°|±²‚³…´ˆµ‹¶Ž·¹”º˜» ¿£À¥Á©Â«Ä¬Å®Æ°Ç³É¶Ê¹Ë¼Ì¿ÍÁÏÅÐÌÔÎÕÔ×רÚÙÝÚäÛæÜéÝðáòâøäûåþæçè éêëðñò ó$õ&ö,ø.ù3ú5ü7ý9ÿ;=?ACEGI K M O QSUY[]acegik m!o"s#w$y%{'}()*ƒ+…/‡0‰3‹467‘8“9•>—?™AB¡C¦K«L°M²U´V¶X»YÀZÂbÇcÌdÎjÒk×lÜmÞqâräsætévìwîxð}÷~ù‚û†ÿ‡ˆ‰Š ‹ ŒŽ‘’“ •"–$—(˜*™-š0›4ž6 ;¡=¢>¨E©G­J®M°O¶Q·T¼X½Z¾\À^ÁaÂdÃfÅhÆjÇmÈpÏtÐvÑxÓzԀՃօ؇ىÚÛ’â•ã–ä—å˜æ™çšè  inffas32.obj6/Microsoft (R) Macro Assembler Version 6.14.8444 L_test_for_length_base$ L_invalid_distance_too_far L_check_dist_one_mmx L_do_copy1_mmx L_wrap_around_window  L_do_copy1 L_add_bits_to_len  L_do_loop' L_invalid_literal_length_code# invalid_distance_code_msg L_get_length_code_mmx  _inflate_fast  L_init_mmx( L_test_for_second_level_length  L_save_len L_add_bits_to_dist_mmx inflate_fast_mask L_update_next_in L_dodist  L_skip_msg L_get_distance_code" L_wrap_around_window_mmx  L_do_loop_mmx! L_invalid_distance_code& L_test_for_second_level_dist! L_test_for_end_of_block) invalid_literal_length_code_msg*  L_test_for_second_level_dist_mmx L_clip_window_mmx  L_dolen_mmx  L_use_mmx  L_break_loop L_get_length_code L_add_bits_to_dist  L_fixup_out L_get_dist_code_mmx  L_clip_window,››$$$00001) invalid_literal_length_code_msg# invalid_distance_code_msg& invalid_distance_too_far_msg inflate_fast_mask inflate_fast_entry  L_align_long  L_is_aligned  L_check_mmx  L_use_mmx L_dont_use_mmx L_check_mmx_pop  L_do_loop L_get_length_code L_dolen  L_while_test L_test_for_length_base L_add_bits_to_len  L_save_len L_decode_distance L_get_distance_code L_dodist L_add_bits_to_dist L_check_window L_check_dist_one( L_test_for_second_level_length& L_test_for_second_level_dist  L_clip_window L_wrap_around_window L_contiguous_in_window  L_do_copy1  L_init_mmx  L_do_loop_mmx L_get_length_code_mmx  L_dolen_mmx L_while_test_mmx$ L_test_for_length_base_mmx L_decode_distance_mmx L_get_dist_code_mmx  L_dodist_mmx L_add_bits_to_dist_mmx L_check_window_mmx L_check_dist_one_mmx, "L_test_for_second_level_length_mmx*  L_test_for_second_level_dist_mmx L_clip_window_mmx" L_wrap_around_window_mmx$ L_contiguous_in_window_mmx L_do_copy1_mmx! L_invalid_distance_code! L_test_for_end_of_block' L_invalid_literal_length_code$ L_invalid_distance_too_far L_update_stream_state  L_skip_msg  L_break_loop L_update_next_in L_buf_not_used  L_update_hold L_last_is_smaller  L_fixup_out L_end_is_smaller L_done  L_check_mmx L_decode_distance_mmx L_dont_use_mmx  L_is_aligned L_check_window L_contiguous_in_window L_buf_not_used L_update_stream_state L_decode_distance  L_while_test inflate_fast_use_mmx, "L_test_for_second_level_length_mmx L_check_dist_one L_end_is_smaller L_check_window_mmx L_while_test_mmx  L_update_hold$ L_test_for_length_base_mmx  L_dodist_mmx  L_align_long inflate_fast_entry L_dolen L_last_is_smaller L_check_mmx_pop L_done$ L_contiguous_in_window_mmx& invalid_distance_too_far_msgU Y w {  ¡ ½ Á × Û ÷ û   * . ? C h l ! ‘! ® ² Ç" Ë" Ý# á# $ $ % !% ? C \& `& x' |' Œ( ( ¢) ¦) Á* Å* å+ é+ þ, , !- %- I. M. l p —/ ›/ Ã0 Ç0 à1 ä1 ÷2 û2 3 3 $4 (4 A5 E5 _6 c6 v7 z7 •8 ™8 Æ Ê Ü à   , 0 T X q9 u9 : “: §; «; ¿< Ã< Ö2 Ú2 ë= ï= > >  $ 54 94 R? V? e@ i@ }  Ÿ £ ¼$ À$ ÒA ÖA ï) ó) ' ' "5 &5 @B DB ZC ^C v# z#  - ¤- È8 Ì8 á å D D # ' 9" =" O+ S+ h! l! ‰1 1  E ¤E ¼F ÀF âG æG  7  7 " H & H : % > % \ I ` I z  ~  š J ž J È / Ì / ô 0 ø 0  *  * 5 K 9 K [  _  u , y , ˜ . œ . » ¿ ä  è  L  L + ( / ( A 3 E 3 Y & ] & u M y M N “ N ¨ O ¬ O Å 6 É 6 Ü P à P ø Q ü Q  <  < % G ) G F = J = ` ; d ; x B | B ’ D – D ´ M ¸ M Î L Ò L ï A ó A @  @ $  (  D J H J r C v C Ž P ’ P ª I ® I È E Ì E ä N è N ý F F #H 'H ;: ?: S9 W9 q? u? „O ˆO ¡> ¥> ¼Q ÀQ ÎK ÒK ô ø òñ òñ.fileþÿginffas32.asm@comp.idü ÿÿ.text› Q.data.debug$Sþ.debug$T L  ,„ >0 ^ sd $$$00001 ›È.bfeP.lfQe.ef›e8™ §Î   ו æ ûe  X " @® Vt aœ €Ò ‹I ¢û L_dodistõ ³é ¾è ÒU ë” ù¦ ¼ .² Fð g yº …; ð œj ®$ Áp Í áÜ ï Â Ú Þ (G 7Q L_dolenv G„ TÖ f6 ut †Q Ê ®ß É ß/ ì] ÿÌ "… =Þ S4 bO pf ‚… L_done’ “invalid_distance_code_msg_inflate_fastinflate_fast_maskinvalid_literal_length_code_msginflate_fast_use_mmxinvalid_distance_too_far_msgL_test_for_length_baseL_invalid_distance_too_farL_check_dist_one_mmxL_do_copy1_mmxL_wrap_around_windowL_do_copy1L_add_bits_to_lenL_do_loopL_invalid_literal_length_codeL_get_length_code_mmxL_init_mmxL_test_for_second_level_lengthL_save_lenL_add_bits_to_dist_mmxL_update_next_inL_skip_msgL_get_distance_codeL_wrap_around_window_mmxL_do_loop_mmxL_invalid_distance_codeL_test_for_second_level_distL_test_for_end_of_blockL_test_for_second_level_dist_mmxL_clip_window_mmxL_dolen_mmxL_use_mmxL_break_loopL_get_length_codeL_add_bits_to_distL_fixup_outL_get_dist_code_mmxL_clip_windowinflate_fast_entryL_align_longL_is_alignedL_check_mmxL_dont_use_mmxL_check_mmx_popL_while_testL_decode_distanceL_check_windowL_check_dist_oneL_contiguous_in_windowL_while_test_mmxL_test_for_length_base_mmxL_decode_distance_mmxL_dodist_mmxL_check_window_mmxL_test_for_second_level_length_mmxL_contiguous_in_window_mmxL_update_stream_stateL_buf_not_usedL_update_holdL_last_is_smallerL_end_is_smallersks-ecc-0.93/zlib/contrib/masmx86/bld_ml32.bat0000644000175000017500000000013510604550750017731 0ustar nachonachoml /coff /Zi /c /Flgvmat32.lst gvmat32.asm ml /coff /Zi /c /Flinffas32.lst inffas32.asm sks-ecc-0.93/zlib/contrib/masmx86/gvmat32c.c0000644000175000017500000000342710604550750017444 0ustar nachonacho/* gvmat32.c -- C portion of the optimized longest_match for 32 bits x86 * Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant. * File written by Gilles Vollant, by modifiying the longest_match * from Jean-loup Gailly in deflate.c * it prepare all parameters and call the assembly longest_match_gvasm * longest_match execute standard C code is wmask != 0x7fff * (assembly code is faster with a fixed wmask) * * Read comment at beginning of gvmat32.asm for more information */ #if defined(ASMV) && (!defined(NOOLDPENTIUMCODE)) #include "deflate.h" /* if your C compiler don't add underline before function name, define ADD_UNDERLINE_ASMFUNC */ #ifdef ADD_UNDERLINE_ASMFUNC #define longest_match_7fff _longest_match_7fff #define longest_match_686 _longest_match_686 #define cpudetect32 _cpudetect32 #endif unsigned long cpudetect32(); uInt longest_match_c( deflate_state *s, IPos cur_match); /* current match */ uInt longest_match_7fff( deflate_state *s, IPos cur_match); /* current match */ uInt longest_match_686( deflate_state *s, IPos cur_match); /* current match */ static uInt iIsPPro=2; void match_init () { iIsPPro = (((cpudetect32()/0x100)&0xf)>=6) ? 1 : 0; } uInt longest_match( deflate_state *s, IPos cur_match) /* current match */ { if (iIsPPro!=0) return longest_match_686(s,cur_match); if (s->w_mask != 0x7fff) return longest_match_686(s,cur_match); /* now ((s->w_mask == 0x7fff) && (iIsPPro==0)) */ return longest_match_7fff(s,cur_match); } #endif /* defined(ASMV) && (!defined(NOOLDPENTIUMCODE)) */ sks-ecc-0.93/zlib/contrib/untgz/0000755000175000017500000000000010604550750015510 5ustar nachonachosks-ecc-0.93/zlib/contrib/untgz/untgz.c0000644000175000017500000004023610604550750017030 0ustar nachonacho/* * untgz.c -- Display contents and extract files from a gzip'd TAR file * * written by Pedro A. Aranda Gutierrez * adaptation to Unix by Jean-loup Gailly * various fixes by Cosmin Truta */ #include #include #include #include #include #include "zlib.h" #ifdef unix # include #else # include # include #endif #ifdef WIN32 #include # ifndef F_OK # define F_OK 0 # endif # define mkdir(dirname,mode) _mkdir(dirname) # ifdef _MSC_VER # define access(path,mode) _access(path,mode) # define chmod(path,mode) _chmod(path,mode) # define strdup(str) _strdup(str) # endif #else # include #endif /* values used in typeflag field */ #define REGTYPE '0' /* regular file */ #define AREGTYPE '\0' /* regular file */ #define LNKTYPE '1' /* link */ #define SYMTYPE '2' /* reserved */ #define CHRTYPE '3' /* character special */ #define BLKTYPE '4' /* block special */ #define DIRTYPE '5' /* directory */ #define FIFOTYPE '6' /* FIFO special */ #define CONTTYPE '7' /* reserved */ /* GNU tar extensions */ #define GNUTYPE_DUMPDIR 'D' /* file names from dumped directory */ #define GNUTYPE_LONGLINK 'K' /* long link name */ #define GNUTYPE_LONGNAME 'L' /* long file name */ #define GNUTYPE_MULTIVOL 'M' /* continuation of file from another volume */ #define GNUTYPE_NAMES 'N' /* file name that does not fit into main hdr */ #define GNUTYPE_SPARSE 'S' /* sparse file */ #define GNUTYPE_VOLHDR 'V' /* tape/volume header */ /* tar header */ #define BLOCKSIZE 512 #define SHORTNAMESIZE 100 struct tar_header { /* byte offset */ char name[100]; /* 0 */ char mode[8]; /* 100 */ char uid[8]; /* 108 */ char gid[8]; /* 116 */ char size[12]; /* 124 */ char mtime[12]; /* 136 */ char chksum[8]; /* 148 */ char typeflag; /* 156 */ char linkname[100]; /* 157 */ char magic[6]; /* 257 */ char version[2]; /* 263 */ char uname[32]; /* 265 */ char gname[32]; /* 297 */ char devmajor[8]; /* 329 */ char devminor[8]; /* 337 */ char prefix[155]; /* 345 */ /* 500 */ }; union tar_buffer { char buffer[BLOCKSIZE]; struct tar_header header; }; struct attr_item { struct attr_item *next; char *fname; int mode; time_t time; }; enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID }; char *TGZfname OF((const char *)); void TGZnotfound OF((const char *)); int getoct OF((char *, int)); char *strtime OF((time_t *)); int setfiletime OF((char *, time_t)); void push_attr OF((struct attr_item **, char *, int, time_t)); void restore_attr OF((struct attr_item **)); int ExprMatch OF((char *, char *)); int makedir OF((char *)); int matchname OF((int, int, char **, char *)); void error OF((const char *)); int tar OF((gzFile, int, int, int, char **)); void help OF((int)); int main OF((int, char **)); char *prog; const char *TGZsuffix[] = { "\0", ".tar", ".tar.gz", ".taz", ".tgz", NULL }; /* return the file name of the TGZ archive */ /* or NULL if it does not exist */ char *TGZfname (const char *arcname) { static char buffer[1024]; int origlen,i; strcpy(buffer,arcname); origlen = strlen(buffer); for (i=0; TGZsuffix[i]; i++) { strcpy(buffer+origlen,TGZsuffix[i]); if (access(buffer,F_OK) == 0) return buffer; } return NULL; } /* error message for the filename */ void TGZnotfound (const char *arcname) { int i; fprintf(stderr,"%s: Couldn't find ",prog); for (i=0;TGZsuffix[i];i++) fprintf(stderr,(TGZsuffix[i+1]) ? "%s%s, " : "or %s%s\n", arcname, TGZsuffix[i]); exit(1); } /* convert octal digits to int */ /* on error return -1 */ int getoct (char *p,int width) { int result = 0; char c; while (width--) { c = *p++; if (c == 0) break; if (c == ' ') continue; if (c < '0' || c > '7') return -1; result = result * 8 + (c - '0'); } return result; } /* convert time_t to string */ /* use the "YYYY/MM/DD hh:mm:ss" format */ char *strtime (time_t *t) { struct tm *local; static char result[32]; local = localtime(t); sprintf(result,"%4d/%02d/%02d %02d:%02d:%02d", local->tm_year+1900, local->tm_mon+1, local->tm_mday, local->tm_hour, local->tm_min, local->tm_sec); return result; } /* set file time */ int setfiletime (char *fname,time_t ftime) { #ifdef WIN32 static int isWinNT = -1; SYSTEMTIME st; FILETIME locft, modft; struct tm *loctm; HANDLE hFile; int result; loctm = localtime(&ftime); if (loctm == NULL) return -1; st.wYear = (WORD)loctm->tm_year + 1900; st.wMonth = (WORD)loctm->tm_mon + 1; st.wDayOfWeek = (WORD)loctm->tm_wday; st.wDay = (WORD)loctm->tm_mday; st.wHour = (WORD)loctm->tm_hour; st.wMinute = (WORD)loctm->tm_min; st.wSecond = (WORD)loctm->tm_sec; st.wMilliseconds = 0; if (!SystemTimeToFileTime(&st, &locft) || !LocalFileTimeToFileTime(&locft, &modft)) return -1; if (isWinNT < 0) isWinNT = (GetVersion() < 0x80000000) ? 1 : 0; hFile = CreateFile(fname, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, (isWinNT ? FILE_FLAG_BACKUP_SEMANTICS : 0), NULL); if (hFile == INVALID_HANDLE_VALUE) return -1; result = SetFileTime(hFile, NULL, NULL, &modft) ? 0 : -1; CloseHandle(hFile); return result; #else struct utimbuf settime; settime.actime = settime.modtime = ftime; return utime(fname,&settime); #endif } /* push file attributes */ void push_attr(struct attr_item **list,char *fname,int mode,time_t time) { struct attr_item *item; item = (struct attr_item *)malloc(sizeof(struct attr_item)); if (item == NULL) error("Out of memory"); item->fname = strdup(fname); item->mode = mode; item->time = time; item->next = *list; *list = item; } /* restore file attributes */ void restore_attr(struct attr_item **list) { struct attr_item *item, *prev; for (item = *list; item != NULL; ) { setfiletime(item->fname,item->time); chmod(item->fname,item->mode); prev = item; item = item->next; free(prev); } *list = NULL; } /* match regular expression */ #define ISSPECIAL(c) (((c) == '*') || ((c) == '/')) int ExprMatch (char *string,char *expr) { while (1) { if (ISSPECIAL(*expr)) { if (*expr == '/') { if (*string != '\\' && *string != '/') return 0; string ++; expr++; } else if (*expr == '*') { if (*expr ++ == 0) return 1; while (*++string != *expr) if (*string == 0) return 0; } } else { if (*string != *expr) return 0; if (*expr++ == 0) return 1; string++; } } } /* recursive mkdir */ /* abort on ENOENT; ignore other errors like "directory already exists" */ /* return 1 if OK */ /* 0 on error */ int makedir (char *newdir) { char *buffer = strdup(newdir); char *p; int len = strlen(buffer); if (len <= 0) { free(buffer); return 0; } if (buffer[len-1] == '/') { buffer[len-1] = '\0'; } if (mkdir(buffer, 0755) == 0) { free(buffer); return 1; } p = buffer+1; while (1) { char hold; while(*p && *p != '\\' && *p != '/') p++; hold = *p; *p = 0; if ((mkdir(buffer, 0755) == -1) && (errno == ENOENT)) { fprintf(stderr,"%s: Couldn't create directory %s\n",prog,buffer); free(buffer); return 0; } if (hold == 0) break; *p++ = hold; } free(buffer); return 1; } int matchname (int arg,int argc,char **argv,char *fname) { if (arg == argc) /* no arguments given (untgz tgzarchive) */ return 1; while (arg < argc) if (ExprMatch(fname,argv[arg++])) return 1; return 0; /* ignore this for the moment being */ } /* tar file list or extract */ int tar (gzFile in,int action,int arg,int argc,char **argv) { union tar_buffer buffer; int len; int err; int getheader = 1; int remaining = 0; FILE *outfile = NULL; char fname[BLOCKSIZE]; int tarmode; time_t tartime; struct attr_item *attributes = NULL; if (action == TGZ_LIST) printf(" date time size file\n" " ---------- -------- --------- -------------------------------------\n"); while (1) { len = gzread(in, &buffer, BLOCKSIZE); if (len < 0) error(gzerror(in, &err)); /* * Always expect complete blocks to process * the tar information. */ if (len != BLOCKSIZE) { action = TGZ_INVALID; /* force error exit */ remaining = 0; /* force I/O cleanup */ } /* * If we have to get a tar header */ if (getheader >= 1) { /* * if we met the end of the tar * or the end-of-tar block, * we are done */ if (len == 0 || buffer.header.name[0] == 0) break; tarmode = getoct(buffer.header.mode,8); tartime = (time_t)getoct(buffer.header.mtime,12); if (tarmode == -1 || tartime == (time_t)-1) { buffer.header.name[0] = 0; action = TGZ_INVALID; } if (getheader == 1) { strncpy(fname,buffer.header.name,SHORTNAMESIZE); if (fname[SHORTNAMESIZE-1] != 0) fname[SHORTNAMESIZE] = 0; } else { /* * The file name is longer than SHORTNAMESIZE */ if (strncmp(fname,buffer.header.name,SHORTNAMESIZE-1) != 0) error("bad long name"); getheader = 1; } /* * Act according to the type flag */ switch (buffer.header.typeflag) { case DIRTYPE: if (action == TGZ_LIST) printf(" %s %s\n",strtime(&tartime),fname); if (action == TGZ_EXTRACT) { makedir(fname); push_attr(&attributes,fname,tarmode,tartime); } break; case REGTYPE: case AREGTYPE: remaining = getoct(buffer.header.size,12); if (remaining == -1) { action = TGZ_INVALID; break; } if (action == TGZ_LIST) printf(" %s %9d %s\n",strtime(&tartime),remaining,fname); else if (action == TGZ_EXTRACT) { if (matchname(arg,argc,argv,fname)) { outfile = fopen(fname,"wb"); if (outfile == NULL) { /* try creating directory */ char *p = strrchr(fname, '/'); if (p != NULL) { *p = '\0'; makedir(fname); *p = '/'; outfile = fopen(fname,"wb"); } } if (outfile != NULL) printf("Extracting %s\n",fname); else fprintf(stderr, "%s: Couldn't create %s",prog,fname); } else outfile = NULL; } getheader = 0; break; case GNUTYPE_LONGLINK: case GNUTYPE_LONGNAME: remaining = getoct(buffer.header.size,12); if (remaining < 0 || remaining >= BLOCKSIZE) { action = TGZ_INVALID; break; } len = gzread(in, fname, BLOCKSIZE); if (len < 0) error(gzerror(in, &err)); if (fname[BLOCKSIZE-1] != 0 || (int)strlen(fname) > remaining) { action = TGZ_INVALID; break; } getheader = 2; break; default: if (action == TGZ_LIST) printf(" %s <---> %s\n",strtime(&tartime),fname); break; } } else { unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining; if (outfile != NULL) { if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes) { fprintf(stderr, "%s: Error writing %s -- skipping\n",prog,fname); fclose(outfile); outfile = NULL; remove(fname); } } remaining -= bytes; } if (remaining == 0) { getheader = 1; if (outfile != NULL) { fclose(outfile); outfile = NULL; if (action != TGZ_INVALID) push_attr(&attributes,fname,tarmode,tartime); } } /* * Abandon if errors are found */ if (action == TGZ_INVALID) { error("broken archive"); break; } } /* * Restore file modes and time stamps */ restore_attr(&attributes); if (gzclose(in) != Z_OK) error("failed gzclose"); return 0; } /* ============================================================ */ void help(int exitval) { printf("untgz version 0.2.1\n" " using zlib version %s\n\n", zlibVersion()); printf("Usage: untgz file.tgz extract all files\n" " untgz file.tgz fname ... extract selected files\n" " untgz -l file.tgz list archive contents\n" " untgz -h display this help\n"); exit(exitval); } void error(const char *msg) { fprintf(stderr, "%s: %s\n", prog, msg); exit(1); } /* ============================================================ */ #if defined(WIN32) && defined(__GNUC__) int _CRT_glob = 0; /* disable argument globbing in MinGW */ #endif int main(int argc,char **argv) { int action = TGZ_EXTRACT; int arg = 1; char *TGZfile; gzFile *f; prog = strrchr(argv[0],'\\'); if (prog == NULL) { prog = strrchr(argv[0],'/'); if (prog == NULL) { prog = strrchr(argv[0],':'); if (prog == NULL) prog = argv[0]; else prog++; } else prog++; } else prog++; if (argc == 1) help(0); if (strcmp(argv[arg],"-l") == 0) { action = TGZ_LIST; if (argc == ++arg) help(0); } else if (strcmp(argv[arg],"-h") == 0) { help(0); } if ((TGZfile = TGZfname(argv[arg])) == NULL) TGZnotfound(argv[arg]); ++arg; if ((action == TGZ_LIST) && (arg != argc)) help(1); /* * Process the TGZ file */ switch(action) { case TGZ_LIST: case TGZ_EXTRACT: f = gzopen(TGZfile,"rb"); if (f == NULL) { fprintf(stderr,"%s: Couldn't gzopen %s\n",prog,TGZfile); return 1; } exit(tar(f, action, arg, argc, argv)); break; default: error("Unknown option"); exit(1); } return 0; } sks-ecc-0.93/zlib/contrib/untgz/Makefile.msc0000644000175000017500000000043110604550750017727 0ustar nachonachoCC=cl CFLAGS=-MD untgz.exe: untgz.obj ..\..\zlib.lib $(CC) $(CFLAGS) untgz.obj ..\..\zlib.lib untgz.obj: untgz.c ..\..\zlib.h $(CC) $(CFLAGS) -c -I..\.. untgz.c ..\..\zlib.lib: cd ..\.. $(MAKE) -f win32\makefile.msc cd contrib\untgz clean: -del untgz.obj -del untgz.exe sks-ecc-0.93/zlib/contrib/untgz/Makefile0000644000175000017500000000035210604550750017150 0ustar nachonachoCC=cc CFLAGS=-g untgz: untgz.o ../../libz.a $(CC) $(CFLAGS) -o untgz untgz.o -L../.. -lz untgz.o: untgz.c ../../zlib.h $(CC) $(CFLAGS) -c -I../.. untgz.c ../../libz.a: cd ../..; ./configure; make clean: rm -f untgz untgz.o *~ sks-ecc-0.93/zlib/contrib/testzlib/0000755000175000017500000000000010604550750016201 5ustar nachonachosks-ecc-0.93/zlib/contrib/testzlib/testzlib.txt0000644000175000017500000000031510604550750020601 0ustar nachonachoTo build testzLib with Visual Studio 2005: copy to a directory file from : - root of zLib tree - contrib/testzlib - contrib/masmx86 - contrib/masmx64 - contrib/vstudio/vc7 and open testzlib8.slnsks-ecc-0.93/zlib/contrib/testzlib/testzlib.c0000644000175000017500000001672610604550750020221 0ustar nachonacho#include #include #include #include "zlib.h" void MyDoMinus64(LARGE_INTEGER *R,LARGE_INTEGER A,LARGE_INTEGER B) { R->HighPart = A.HighPart - B.HighPart; if (A.LowPart >= B.LowPart) R->LowPart = A.LowPart - B.LowPart; else { R->LowPart = A.LowPart - B.LowPart; R->HighPart --; } } #ifdef _M_X64 // see http://msdn2.microsoft.com/library/twchhe95(en-us,vs.80).aspx for __rdtsc unsigned __int64 __rdtsc(void); void BeginCountRdtsc(LARGE_INTEGER * pbeginTime64) { // printf("rdtsc = %I64x\n",__rdtsc()); pbeginTime64->QuadPart=__rdtsc(); } LARGE_INTEGER GetResRdtsc(LARGE_INTEGER beginTime64,BOOL fComputeTimeQueryPerf) { LARGE_INTEGER LIres; unsigned _int64 res=__rdtsc()-((unsigned _int64)(beginTime64.QuadPart)); LIres.QuadPart=res; // printf("rdtsc = %I64x\n",__rdtsc()); return LIres; } #else #ifdef _M_IX86 void myGetRDTSC32(LARGE_INTEGER * pbeginTime64) { DWORD dwEdx,dwEax; _asm { rdtsc mov dwEax,eax mov dwEdx,edx } pbeginTime64->LowPart=dwEax; pbeginTime64->HighPart=dwEdx; } void BeginCountRdtsc(LARGE_INTEGER * pbeginTime64) { myGetRDTSC32(pbeginTime64); } LARGE_INTEGER GetResRdtsc(LARGE_INTEGER beginTime64,BOOL fComputeTimeQueryPerf) { LARGE_INTEGER LIres,endTime64; myGetRDTSC32(&endTime64); LIres.LowPart=LIres.HighPart=0; MyDoMinus64(&LIres,endTime64,beginTime64); return LIres; } #else void myGetRDTSC32(LARGE_INTEGER * pbeginTime64) { } void BeginCountRdtsc(LARGE_INTEGER * pbeginTime64) { } LARGE_INTEGER GetResRdtsc(LARGE_INTEGER beginTime64,BOOL fComputeTimeQueryPerf) { LARGE_INTEGER lr; lr.QuadPart=0; return lr; } #endif #endif void BeginCountPerfCounter(LARGE_INTEGER * pbeginTime64,BOOL fComputeTimeQueryPerf) { if ((!fComputeTimeQueryPerf) || (!QueryPerformanceCounter(pbeginTime64))) { pbeginTime64->LowPart = GetTickCount(); pbeginTime64->HighPart = 0; } } DWORD GetMsecSincePerfCounter(LARGE_INTEGER beginTime64,BOOL fComputeTimeQueryPerf) { LARGE_INTEGER endTime64,ticksPerSecond,ticks; DWORDLONG ticksShifted,tickSecShifted; DWORD dwLog=16+0; DWORD dwRet; if ((!fComputeTimeQueryPerf) || (!QueryPerformanceCounter(&endTime64))) dwRet = (GetTickCount() - beginTime64.LowPart)*1; else { MyDoMinus64(&ticks,endTime64,beginTime64); QueryPerformanceFrequency(&ticksPerSecond); { ticksShifted = Int64ShrlMod32(*(DWORDLONG*)&ticks,dwLog); tickSecShifted = Int64ShrlMod32(*(DWORDLONG*)&ticksPerSecond,dwLog); } dwRet = (DWORD)((((DWORD)ticksShifted)*1000)/(DWORD)(tickSecShifted)); dwRet *=1; } return dwRet; } int ReadFileMemory(const char* filename,long* plFileSize,void** pFilePtr) { FILE* stream; void* ptr; int retVal=1; stream=fopen(filename, "rb"); if (stream==NULL) return 0; fseek(stream,0,SEEK_END); *plFileSize=ftell(stream); fseek(stream,0,SEEK_SET); ptr=malloc((*plFileSize)+1); if (ptr==NULL) retVal=0; else { if (fread(ptr, 1, *plFileSize,stream) != (*plFileSize)) retVal=0; } fclose(stream); *pFilePtr=ptr; return retVal; } int main(int argc, char *argv[]) { int BlockSizeCompress=0x8000; int BlockSizeUncompress=0x8000; int cprLevel=Z_DEFAULT_COMPRESSION ; long lFileSize; unsigned char* FilePtr; long lBufferSizeCpr; long lBufferSizeUncpr; long lCompressedSize=0; unsigned char* CprPtr; unsigned char* UncprPtr; long lSizeCpr,lSizeUncpr; DWORD dwGetTick,dwMsecQP; LARGE_INTEGER li_qp,li_rdtsc,dwResRdtsc; if (argc<=1) { printf("run TestZlib [BlockSizeCompress] [BlockSizeUncompress] [compres. level]\n"); return 0; } if (ReadFileMemory(argv[1],&lFileSize,&FilePtr)==0) { printf("error reading %s\n",argv[1]); return 1; } else printf("file %s read, %u bytes\n",argv[1],lFileSize); if (argc>=3) BlockSizeCompress=atol(argv[2]); if (argc>=4) BlockSizeUncompress=atol(argv[3]); if (argc>=5) cprLevel=(int)atol(argv[4]); lBufferSizeCpr = lFileSize + (lFileSize/0x10) + 0x200; lBufferSizeUncpr = lBufferSizeCpr; CprPtr=(unsigned char*)malloc(lBufferSizeCpr + BlockSizeCompress); BeginCountPerfCounter(&li_qp,TRUE); dwGetTick=GetTickCount(); BeginCountRdtsc(&li_rdtsc); { z_stream zcpr; int ret=Z_OK; long lOrigToDo = lFileSize; long lOrigDone = 0; int step=0; memset(&zcpr,0,sizeof(z_stream)); deflateInit(&zcpr,cprLevel); zcpr.next_in = FilePtr; zcpr.next_out = CprPtr; do { long all_read_before = zcpr.total_in; zcpr.avail_in = min(lOrigToDo,BlockSizeCompress); zcpr.avail_out = BlockSizeCompress; ret=deflate(&zcpr,(zcpr.avail_in==lOrigToDo) ? Z_FINISH : Z_SYNC_FLUSH); lOrigDone += (zcpr.total_in-all_read_before); lOrigToDo -= (zcpr.total_in-all_read_before); step++; } while (ret==Z_OK); lSizeCpr=zcpr.total_out; deflateEnd(&zcpr); dwGetTick=GetTickCount()-dwGetTick; dwMsecQP=GetMsecSincePerfCounter(li_qp,TRUE); dwResRdtsc=GetResRdtsc(li_rdtsc,TRUE); printf("total compress size = %u, in %u step\n",lSizeCpr,step); printf("time = %u msec = %f sec\n",dwGetTick,dwGetTick/(double)1000.); printf("defcpr time QP = %u msec = %f sec\n",dwMsecQP,dwMsecQP/(double)1000.); printf("defcpr result rdtsc = %I64x\n\n",dwResRdtsc.QuadPart); } CprPtr=(unsigned char*)realloc(CprPtr,lSizeCpr); UncprPtr=(unsigned char*)malloc(lBufferSizeUncpr + BlockSizeUncompress); BeginCountPerfCounter(&li_qp,TRUE); dwGetTick=GetTickCount(); BeginCountRdtsc(&li_rdtsc); { z_stream zcpr; int ret=Z_OK; long lOrigToDo = lSizeCpr; long lOrigDone = 0; int step=0; memset(&zcpr,0,sizeof(z_stream)); inflateInit(&zcpr); zcpr.next_in = CprPtr; zcpr.next_out = UncprPtr; do { long all_read_before = zcpr.total_in; zcpr.avail_in = min(lOrigToDo,BlockSizeUncompress); zcpr.avail_out = BlockSizeUncompress; ret=inflate(&zcpr,Z_SYNC_FLUSH); lOrigDone += (zcpr.total_in-all_read_before); lOrigToDo -= (zcpr.total_in-all_read_before); step++; } while (ret==Z_OK); lSizeUncpr=zcpr.total_out; inflateEnd(&zcpr); dwGetTick=GetTickCount()-dwGetTick; dwMsecQP=GetMsecSincePerfCounter(li_qp,TRUE); dwResRdtsc=GetResRdtsc(li_rdtsc,TRUE); printf("total uncompress size = %u, in %u step\n",lSizeUncpr,step); printf("time = %u msec = %f sec\n",dwGetTick,dwGetTick/(double)1000.); printf("uncpr time QP = %u msec = %f sec\n",dwMsecQP,dwMsecQP/(double)1000.); printf("uncpr result rdtsc = %I64x\n\n",dwResRdtsc.QuadPart); } if (lSizeUncpr==lFileSize) { if (memcmp(FilePtr,UncprPtr,lFileSize)==0) printf("compare ok\n"); } return 0; } sks-ecc-0.93/zlib/contrib/masm686/0000755000175000017500000000000010604550750015542 5ustar nachonachosks-ecc-0.93/zlib/contrib/masm686/match.asm0000644000175000017500000002610010604550750017337 0ustar nachonacho ; match.asm -- Pentium-Pro optimized version of longest_match() ; ; Updated for zlib 1.1.3 and converted to MASM 6.1x ; Copyright (C) 2000 Dan Higdon ; and Chuck Walbourn ; Corrections by Cosmin Truta ; ; This is free software; you can redistribute it and/or modify it ; under the terms of the GNU General Public License. ; Based on match.S ; Written for zlib 1.1.2 ; Copyright (C) 1998 Brian Raiter ; ; Modified by Gilles Vollant (2005) for add gzhead and gzindex .686P .MODEL FLAT ;=========================================================================== ; EQUATES ;=========================================================================== MAX_MATCH EQU 258 MIN_MATCH EQU 3 MIN_LOOKAHEAD EQU (MAX_MATCH + MIN_MATCH + 1) MAX_MATCH_8 EQU ((MAX_MATCH + 7) AND (NOT 7)) ;=========================================================================== ; STRUCTURES ;=========================================================================== ; This STRUCT assumes a 4-byte alignment DEFLATE_STATE STRUCT ds_strm dd ? ds_status dd ? ds_pending_buf dd ? ds_pending_buf_size dd ? ds_pending_out dd ? ds_pending dd ? ds_wrap dd ? ; gzhead and gzindex are added in zlib 1.2.2.2 (see deflate.h) ds_gzhead dd ? ds_gzindex dd ? ds_data_type db ? ds_method db ? db ? ; padding db ? ; padding ds_last_flush dd ? ds_w_size dd ? ; used ds_w_bits dd ? ds_w_mask dd ? ; used ds_window dd ? ; used ds_window_size dd ? ds_prev dd ? ; used ds_head dd ? ds_ins_h dd ? ds_hash_size dd ? ds_hash_bits dd ? ds_hash_mask dd ? ds_hash_shift dd ? ds_block_start dd ? ds_match_length dd ? ; used ds_prev_match dd ? ; used ds_match_available dd ? ds_strstart dd ? ; used ds_match_start dd ? ; used ds_lookahead dd ? ; used ds_prev_length dd ? ; used ds_max_chain_length dd ? ; used ds_max_laxy_match dd ? ds_level dd ? ds_strategy dd ? ds_good_match dd ? ; used ds_nice_match dd ? ; used ; Don't need anymore of the struct for match DEFLATE_STATE ENDS ;=========================================================================== ; CODE ;=========================================================================== _TEXT SEGMENT ;--------------------------------------------------------------------------- ; match_init ;--------------------------------------------------------------------------- ALIGN 4 PUBLIC _match_init _match_init PROC ; no initialization needed ret _match_init ENDP ;--------------------------------------------------------------------------- ; uInt longest_match(deflate_state *deflatestate, IPos curmatch) ;--------------------------------------------------------------------------- ALIGN 4 PUBLIC _longest_match _longest_match PROC ; Since this code uses EBP for a scratch register, the stack frame must ; be manually constructed and referenced relative to the ESP register. ; Stack image ; Variables chainlenwmask = 0 ; high word: current chain len ; low word: s->wmask window = 4 ; local copy of s->window windowbestlen = 8 ; s->window + bestlen scanend = 12 ; last two bytes of string scanstart = 16 ; first two bytes of string scanalign = 20 ; dword-misalignment of string nicematch = 24 ; a good enough match size bestlen = 28 ; size of best match so far scan = 32 ; ptr to string wanting match varsize = 36 ; number of bytes (also offset to last saved register) ; Saved Registers (actually pushed into place) ebx_save = 36 edi_save = 40 esi_save = 44 ebp_save = 48 ; Parameters retaddr = 52 deflatestate = 56 curmatch = 60 ; Save registers that the compiler may be using push ebp push edi push esi push ebx ; Allocate local variable space sub esp,varsize ; Retrieve the function arguments. ecx will hold cur_match ; throughout the entire function. edx will hold the pointer to the ; deflate_state structure during the function's setup (before ; entering the main loop). mov edx, [esp+deflatestate] ASSUME edx:PTR DEFLATE_STATE mov ecx, [esp+curmatch] ; uInt wmask = s->w_mask; ; unsigned chain_length = s->max_chain_length; ; if (s->prev_length >= s->good_match) { ; chain_length >>= 2; ; } mov eax, [edx].ds_prev_length mov ebx, [edx].ds_good_match cmp eax, ebx mov eax, [edx].ds_w_mask mov ebx, [edx].ds_max_chain_length jl SHORT LastMatchGood shr ebx, 2 LastMatchGood: ; chainlen is decremented once beforehand so that the function can ; use the sign flag instead of the zero flag for the exit test. ; It is then shifted into the high word, to make room for the wmask ; value, which it will always accompany. dec ebx shl ebx, 16 or ebx, eax mov [esp+chainlenwmask], ebx ; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; mov eax, [edx].ds_nice_match mov ebx, [edx].ds_lookahead cmp ebx, eax jl SHORT LookaheadLess mov ebx, eax LookaheadLess: mov [esp+nicematch], ebx ;/* register Bytef *scan = s->window + s->strstart; */ mov esi, [edx].ds_window mov [esp+window], esi mov ebp, [edx].ds_strstart lea edi, [esi+ebp] mov [esp+scan],edi ;/* Determine how many bytes the scan ptr is off from being */ ;/* dword-aligned. */ mov eax, edi neg eax and eax, 3 mov [esp+scanalign], eax ;/* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */ ;/* s->strstart - (IPos)MAX_DIST(s) : NIL; */ mov eax, [edx].ds_w_size sub eax, MIN_LOOKAHEAD sub ebp, eax jg SHORT LimitPositive xor ebp, ebp LimitPositive: ;/* int best_len = s->prev_length; */ mov eax, [edx].ds_prev_length mov [esp+bestlen], eax ;/* Store the sum of s->window + best_len in %esi locally, and in %esi. */ add esi, eax mov [esp+windowbestlen], esi ;/* register ush scan_start = *(ushf*)scan; */ ;/* register ush scan_end = *(ushf*)(scan+best_len-1); */ ;/* Posf *prev = s->prev; */ movzx ebx, WORD PTR[edi] mov [esp+scanstart], ebx movzx ebx, WORD PTR[eax+edi-1] mov [esp+scanend], ebx mov edi, [edx].ds_prev ;/* Jump into the main loop. */ mov edx, [esp+chainlenwmask] jmp SHORT LoopEntry ;/* do { ; * match = s->window + cur_match; ; * if (*(ushf*)(match+best_len-1) != scan_end || ; * *(ushf*)match != scan_start) continue; ; * [...] ; * } while ((cur_match = prev[cur_match & wmask]) > limit ; * && --chain_length != 0); ; * ; * Here is the inner loop of the function. The function will spend the ; * majority of its time in this loop, and majority of that time will ; * be spent in the first ten instructions. ; * ; * Within this loop: ; * %ebx = scanend ; * %ecx = curmatch ; * %edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) ; * %esi = windowbestlen - i.e., (window + bestlen) ; * %edi = prev ; * %ebp = limit ; */ ALIGN 4 LookupLoop: and ecx, edx movzx ecx, WORD PTR[edi+ecx*2] cmp ecx, ebp jbe LeaveNow sub edx, 000010000H js LeaveNow LoopEntry: movzx eax, WORD PTR[esi+ecx-1] cmp eax, ebx jnz SHORT LookupLoop mov eax, [esp+window] movzx eax, WORD PTR[eax+ecx] cmp eax, [esp+scanstart] jnz SHORT LookupLoop ;/* Store the current value of chainlen. */ mov [esp+chainlenwmask], edx ;/* Point %edi to the string under scrutiny, and %esi to the string we */ ;/* are hoping to match it up with. In actuality, %esi and %edi are */ ;/* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */ ;/* initialized to -(MAX_MATCH_8 - scanalign). */ mov esi, [esp+window] mov edi, [esp+scan] add esi, ecx mov eax, [esp+scanalign] mov edx, -MAX_MATCH_8 lea edi, [edi+eax+MAX_MATCH_8] lea esi, [esi+eax+MAX_MATCH_8] ;/* Test the strings for equality, 8 bytes at a time. At the end, ; * adjust %edx so that it is offset to the exact byte that mismatched. ; * ; * We already know at this point that the first three bytes of the ; * strings match each other, and they can be safely passed over before ; * starting the compare loop. So what this code does is skip over 0-3 ; * bytes, as much as necessary in order to dword-align the %edi ; * pointer. (%esi will still be misaligned three times out of four.) ; * ; * It should be confessed that this loop usually does not represent ; * much of the total running time. Replacing it with a more ; * straightforward "rep cmpsb" would not drastically degrade ; * performance. ; */ LoopCmps: mov eax, DWORD PTR[esi+edx] xor eax, DWORD PTR[edi+edx] jnz SHORT LeaveLoopCmps mov eax, DWORD PTR[esi+edx+4] xor eax, DWORD PTR[edi+edx+4] jnz SHORT LeaveLoopCmps4 add edx, 8 jnz SHORT LoopCmps jmp LenMaximum ALIGN 4 LeaveLoopCmps4: add edx, 4 LeaveLoopCmps: test eax, 00000FFFFH jnz SHORT LenLower add edx, 2 shr eax, 16 LenLower: sub al, 1 adc edx, 0 ;/* Calculate the length of the match. If it is longer than MAX_MATCH, */ ;/* then automatically accept it as the best possible match and leave. */ lea eax, [edi+edx] mov edi, [esp+scan] sub eax, edi cmp eax, MAX_MATCH jge SHORT LenMaximum ;/* If the length of the match is not longer than the best match we */ ;/* have so far, then forget it and return to the lookup loop. */ mov edx, [esp+deflatestate] mov ebx, [esp+bestlen] cmp eax, ebx jg SHORT LongerMatch mov esi, [esp+windowbestlen] mov edi, [edx].ds_prev mov ebx, [esp+scanend] mov edx, [esp+chainlenwmask] jmp LookupLoop ALIGN 4 ;/* s->match_start = cur_match; */ ;/* best_len = len; */ ;/* if (len >= nice_match) break; */ ;/* scan_end = *(ushf*)(scan+best_len-1); */ LongerMatch: mov ebx, [esp+nicematch] mov [esp+bestlen], eax mov [edx].ds_match_start, ecx cmp eax, ebx jge SHORT LeaveNow mov esi, [esp+window] add esi, eax mov [esp+windowbestlen], esi movzx ebx, WORD PTR[edi+eax-1] mov edi, [edx].ds_prev mov [esp+scanend], ebx mov edx, [esp+chainlenwmask] jmp LookupLoop ALIGN 4 ;/* Accept the current string, with the maximum possible length. */ LenMaximum: mov edx, [esp+deflatestate] mov DWORD PTR[esp+bestlen], MAX_MATCH mov [edx].ds_match_start, ecx ;/* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */ ;/* return s->lookahead; */ LeaveNow: mov edx, [esp+deflatestate] mov ebx, [esp+bestlen] mov eax, [edx].ds_lookahead cmp ebx, eax jg SHORT LookaheadRet mov eax, ebx LookaheadRet: ; Restore the stack and return from whence we came. add esp, varsize pop ebx pop esi pop edi pop ebp ret _longest_match ENDP _TEXT ENDS END sks-ecc-0.93/zlib/contrib/dotzlib/0000755000175000017500000000000010604550750016010 5ustar nachonachosks-ecc-0.93/zlib/contrib/dotzlib/readme.txt0000644000175000017500000000450110604550750020006 0ustar nachonachoThis directory contains a .Net wrapper class library for the ZLib1.dll The wrapper includes support for inflating/deflating memory buffers, .Net streaming wrappers for the gz streams part of zlib, and wrappers for the checksum parts of zlib. See DotZLib/UnitTests.cs for examples. Directory structure: -------------------- LICENSE_1_0.txt - License file. readme.txt - This file. DotZLib.chm - Class library documentation DotZLib.build - NAnt build file DotZLib.sln - Microsoft Visual Studio 2003 solution file DotZLib\*.cs - Source files for the class library Unit tests: ----------- The file DotZLib/UnitTests.cs contains unit tests for use with NUnit 2.1 or higher. To include unit tests in the build, define nunit before building. Build instructions: ------------------- 1. Using Visual Studio.Net 2003: Open DotZLib.sln in VS.Net and build from there. Output file (DotZLib.dll) will be found ./DotZLib/bin/release or ./DotZLib/bin/debug, depending on you are building the release or debug version of the library. Check DotZLib/UnitTests.cs for instructions on how to include unit tests in the build. 2. Using NAnt: Open a command prompt with access to the build environment and run nant in the same directory as the DotZLib.build file. You can define 2 properties on the nant command-line to control the build: debug={true|false} to toggle between release/debug builds (default=true). nunit={true|false} to include or esclude unit tests (default=true). Also the target clean will remove binaries. Output file (DotZLib.dll) will be found in either ./DotZLib/bin/release or ./DotZLib/bin/debug, depending on whether you are building the release or debug version of the library. Examples: nant -D:debug=false -D:nunit=false will build a release mode version of the library without unit tests. nant will build a debug version of the library with unit tests nant clean will remove all previously built files. --------------------------------- Copyright (c) Henrik Ravn 2004 Use, modification and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) sks-ecc-0.93/zlib/contrib/dotzlib/LICENSE_1_0.txt0000644000175000017500000000251710604550750020277 0ustar nachonachoBoost Software License - Version 1.0 - August 17th, 2003 Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.sks-ecc-0.93/zlib/contrib/dotzlib/DotZLib.sln0000644000175000017500000000161310604550750020036 0ustar nachonachoMicrosoft Visual Studio Solution File, Format Version 8.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotZLib", "DotZLib\DotZLib.csproj", "{BB1EE0B1-1808-46CB-B786-949D91117FC5}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Debug.ActiveCfg = Debug|.NET {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Debug.Build.0 = Debug|.NET {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Release.ActiveCfg = Release|.NET {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Release.Build.0 = Release|.NET EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal sks-ecc-0.93/zlib/contrib/dotzlib/DotZLib.build0000644000175000017500000000223210604550750020337 0ustar nachonacho A .Net wrapper library around ZLib1.dll sks-ecc-0.93/zlib/contrib/dotzlib/DotZLib.chm0000644000175000017500000021603010604550750020012 0ustar nachonachoITSF`LÚZ¢ý|ª{О  É"æìý|ª{О  É"æì`xT0Ì0þITSPT ÿÿÿÿ j’].!Ðù É"æìTÿÿÿÿÿÿÿÿÿÿÿÿPMGLAÿÿÿÿ//#IDXHDR˜áy /#ITBITS /#STRINGS™Ësœ/#SYSTEM‚¡,/#TOPICS™y`/#URLSTR™Ÿ!¬R/#URLTBL™’YŒH /#WINDOWS”Ú"L /$FIftiMain–¹i‚¨ /$OBJINST–¤*•?/$WWAssociativeLinks//$WWAssociativeLinks/Property–¤&/$WWKeywordLinks//$WWKeywordLinks/BTree”Ûn°L/$WWKeywordLinks/Data–Œ:–z/$WWKeywordLinks/Map–£4R/$WWKeywordLinks/Property–¤ /Documentation.hhc’¹E§x/Documentation.hhk“á=A/DotZLib.AdlerChecksum.htmlÊBŒ-/DotZLib.AdlerChecksum.Update_overload_3.html‚Õy–U,/DotZLib.AdlerChecksum.Update_overloads.html‚ÆzŽ&/DotZLib.AdlerChecksumConstructor.html‚ƒ‹ '/DotZLib.AdlerChecksumConstructor1.html‚Ž?ˆS'/DotZLib.AdlerChecksumConstructor2.html‚—Šm"/DotZLib.AdlerChecksumMembers.htmlÖX¬G"/DotZLib.AdlerChecksumMethods.html‚¡¤{/DotZLib.ChecksumGenerator.html‚ìNŠL%/DotZLib.ChecksumGenerator.Reset.htmlƒ§Jˆ:1/DotZLib.ChecksumGenerator.Update_overload_1.htmlƒì1/DotZLib.ChecksumGenerator.Update_overload_2.htmlƒßvŒ1/DotZLib.ChecksumGenerator.Update_overload_3.htmlƒÊ•_1/DotZLib.ChecksumGenerator.Update_overload_4.htmlƒ¾l‹+0/DotZLib.ChecksumGenerator.Update_overloads.htmlƒ°Žh%/DotZLib.ChecksumGenerator.Value.htmlƒ‘<ˆV,/DotZLib.ChecksumGeneratorBase._current.html„Ü0ˆd#/DotZLib.ChecksumGeneratorBase.htmlƒù)ŒL)/DotZLib.ChecksumGeneratorBase.Reset.html… ‰B5/DotZLib.ChecksumGeneratorBase.Update_overload_1.html…è<Ž55/DotZLib.ChecksumGeneratorBase.Update_overload_2.html…Û 25/DotZLib.ChecksumGeneratorBase.Update_overload_3.html…ÂA˜I5/DotZLib.ChecksumGeneratorBase.Update_overload_4.html…µ{ŒF4/DotZLib.ChecksumGeneratorBase.Update_overloads.html…¦O,)/DotZLib.ChecksumGeneratorBase.Value.html„ðX‰T./DotZLib.ChecksumGeneratorBaseConstructor.html„¯NŒD//DotZLib.ChecksumGeneratorBaseConstructor1.html„¼‰>//DotZLib.ChecksumGeneratorBaseConstructor2.html„ÅP‹#)/DotZLib.ChecksumGeneratorBaseFields.html„Ðs‹=*/DotZLib.ChecksumGeneratorBaseMembers.html„…u©Y*/DotZLib.ChecksumGeneratorBaseMethods.html„ú,¢a-/DotZLib.ChecksumGeneratorBaseProperties.html„å‹D&/DotZLib.ChecksumGeneratorMembers.html‚÷Žo&/DotZLib.ChecksumGeneratorMethods.htmlƒš8)/DotZLib.ChecksumGeneratorProperties.htmlƒ† ‹3"/DotZLib.Codec.Add_overload_1.html†ÇŽb"/DotZLib.Codec.Add_overload_2.html†»J‹K!/DotZLib.Codec.Add_overloads.html†±!Š)/DotZLib.Codec.Checksum.html†œ'ˆA!/DotZLib.Codec.DataAvailable.html†ètˆ&/DotZLib.Codec.Finish.html†Õwˆ1/DotZLib.Codec.html…öq‰m#/DotZLib.CodecBase._isDisposed.html‡ÉIˆ[&/DotZLib.CodecBase.Add_overload_1.htmlˆ°z&/DotZLib.CodecBase.Add_overload_2.htmlˆ¤3ŒG%/DotZLib.CodecBase.Add_overloads.htmlˆ™`ŠS /DotZLib.CodecBase.Checksum.html‡å\‰4/DotZLib.CodecBase.CleanUp.htmlˆÁ ‰!/DotZLib.CodecBase.copyInput.htmlˆÊJ%/DotZLib.CodecBase.DataAvailable.html‰ša‰#/DotZLib.CodecBase.Dispose.htmlˆ×ZŠ# /DotZLib.CodecBase.Finalize.htmlˆá}ˆ*/DotZLib.CodecBase.Finish.htmlˆê'‰y/DotZLib.CodecBase.html†ñ‹1#/DotZLib.CodecBase.kBufferSize.html‡Ò$ˆA'/DotZLib.CodecBase.OnDataAvailable.htmlˆô ˆo#/DotZLib.CodecBase.resetOutput.htmlˆýˆ]#/DotZLib.CodecBase.setChecksum.html‰…lŠ"/DotZLib.CodecBaseConstructor.html‡´‡a/DotZLib.CodecBaseEvents.html‰}Šd/DotZLib.CodecBaseFields.html‡»uT/DotZLib.CodecBaseMembers.html†üK·I/DotZLib.CodecBaseMethods.html‡ïªP!/DotZLib.CodecBaseProperties.html‡ÚeŠw/DotZLib.CodecEvents.html†Þ(ŠL/DotZLib.CodecMembers.html†€^j/DotZLib.CodecMethods.html†¤hŒ9/DotZLib.CodecProperties.html†‘HŠ_/DotZLib.CompressLevel.html‰¤/DotZLib.CRC32Checksum.html‰³‹s-/DotZLib.CRC32Checksum.Update_overload_3.htmlо3–U,/DotZLib.CRC32Checksum.Update_overloads.htmlН4Ž&/DotZLib.CRC32ChecksumConstructor.html‰ëY‹ '/DotZLib.CRC32ChecksumConstructor1.html‰öyˆS'/DotZLib.CRC32ChecksumConstructor2.html‰ÿLŠm"/DotZLib.CRC32ChecksumMembers.html‰¿¬G"/DotZLib.CRC32ChecksumMethods.htmlŠŠ9¤{"/DotZLib.DataAvailableHandler.htmlŠÕ<%/DotZLib.Deflater.Add_overload_1.html‹éb$/DotZLib.Deflater.Add_overloads.html‹ÞLŠD/DotZLib.Deflater.CleanUp.html‹ørˆ4/DotZLib.Deflater.Finish.htmlŒ&‰&b  ö @ q · ê + fwuVaJx” Ž>fPMGL,ÿÿÿÿ/DotZLib.Deflater.htmlŠâD‹K!/DotZLib.DeflaterConstructor.html‹§‰/DotZLib.DeflaterMembers.htmlŠî¹/DotZLib.DeflaterMethods.html‹°/® /DotZLib.GZipStream.CanRead.htmlž3ˆf /DotZLib.GZipStream.CanSeek.html§ˆ7!/DotZLib.GZipStream.CanWrite.html¯Pˆe /DotZLib.GZipStream.Dispose.htmlŽ“|‰G!/DotZLib.GZipStream.Finalize.htmlŽCˆ./DotZLib.GZipStream.Flush.htmlŽ¥q‰c/DotZLib.GZipStream.htmlŒŠLZ/DotZLib.GZipStream.Length.html¸5Œ6!/DotZLib.GZipStream.Position.htmlÄkŒd/DotZLib.GZipStream.Read.htmlޝT˜7!/DotZLib.GZipStream.ReadByte.htmlŽÈ ‰*/DotZLib.GZipStream.Seek.htmlŽÑ5Ž5"/DotZLib.GZipStream.SetLength.htmlŽßjŒs/DotZLib.GZipStream.Write.htmlŽì]–w"/DotZLib.GZipStream.WriteByte.htmlƒT#/DotZLib.GZipStreamConstructor.htmlŒå{Š`$/DotZLib.GZipStreamConstructor1.htmlŒð[ŽP$/DotZLib.GZipStreamConstructor2.htmlŒÿ+/DotZLib.GZipStreamMembers.htmlŒ˜&ÍU/DotZLib.GZipStreamMethods.htmlÑOÂ-"/DotZLib.GZipStreamProperties.htmlŒ9‘z /DotZLib.html¨9¢ %/DotZLib.Inflater.Add_overload_1.html—`b$/DotZLib.Inflater.Add_overloads.htmlŠD/DotZLib.Inflater.CleanUp.html§Bˆ4/DotZLib.Inflater.Finish.html¯v‰&/DotZLib.Inflater.html’n‹E!/DotZLib.InflaterConstructor.html×9‡F/DotZLib.InflaterMembers.htmlž3¹/DotZLib.InflaterMethods.htmlÞ®/DotZLib.Info.HasDebugInfo.html‘4ˆE/DotZLib.Info.html¹ŠG/DotZLib.Info.SizeOfOffset.html‘˜yˆP /DotZLib.Info.SizeOfPointer.html‘¡IˆP/DotZLib.Info.SizeOfUInt.html‘ªˆJ/DotZLib.Info.SizeOfULong.html‘²cˆN#/DotZLib.Info.UsesAssemblyCode.html‘»1ˆ]/DotZLib.Info.Version.html‘ĈB/DotZLib.InfoConstructor.htmlò‡?/DotZLib.InfoMembers.htmlÃc®;/DotZLib.InfoProperties.htmlù]–W/DotZLib.ZLibException.html‘ÌP8&/DotZLib.ZLibExceptionConstructor.html’” '/DotZLib.ZLibExceptionConstructor1.html’¡$'/DotZLib.ZLibExceptionConstructor2.html’®&‹"/DotZLib.ZLibExceptionMembers.html‘Ú¹| /MSDN.css”š+¿w/privmethod.gif”Œ‡ /protfield.gif“ït‡/protmethod.gif“÷‡ /protproperty.gif”“‡ /pubevent.gif“þ†e/pubmethod.gif“á~†y/pubproperty.gif“èw†} /static.gif”„w‡ ::DataSpace/NameList<(::DataSpace/Storage/MSCompressed/Content£Bƒ³ ,::DataSpace/Storage/MSCompressed/ControlDataj)::DataSpace/Storage/MSCompressed/SpanInfob/::DataSpace/Storage/MSCompressed/Transform/List<&_::DataSpace/Storage/MSCompressed/Transform/{7FC28940-9D31-11D0-9B27-00A0C91E9C7C}/InstanceData/i::DataSpace/Storage/MSCompressed/Transform/{7FC28940-9D31-11D0-9B27-00A0C91E9C7C}/InstanceData/ResetTableotZLib.CodecBase.Add_overload_2.htmlˆ¤3ŒG%/DotZLib.CodecBase.Add_overloads.htmlˆ™`ŠS /DotZLib.CodecBase.Checksum.html‡å\‰4/DotZLib.CodecBase.CleanUp.htmlˆÁ ‰!/DotZLib.CodecBase.copyInput.htmlˆÊJ%/DotZLib.CodecBase.DataAvailable.html‰ša‰#/DotZLib.CodecBase.Dispose.htmlˆ×ZŠ# /DotZLib.CodecBase.Finalize.htmlˆá}ˆ*/DotZLib.CodecBase.Finish.htmlˆê'‰y/DotZLib.CodecBase.html†ñ‹1#/DotZLib.CodecBase.kBufferSize.html‡Ò$ˆA'/DotZLib.CodecBase.OnDataAvailable.htmlˆô ˆo#/DotZLib.CodecBase.resetOutput.htmlˆýˆ]#/DotZLib.CodecBase.setChecksum.html‰…lŠ"/DotZLib.CodecBaseConstructor.html‡´‡a/DotZLib.CodecBaseEvents.html‰}Šd/DotZLib.CodecBaseFields.html‡»uT/DotZLib.CodecBaseMembers.html†üK·I/DotZLib.CodecBaseMethods.html‡ïªP!/DotZLib.CodecBaseProperties.html‡ÚeŠw/DotZLib.CodecEvents.html†Þ(ŠL/DotZLib.CodecMembers.html†€^j/DotZLib.CodecMethods.html†¤hŒ9/DotZLib.CodecProperties.html†‘HŠ_/DotZLib.CompressLevel.html‰¤/DotZLib.CRC32Checksum.html‰³‹s-/DotZLib.CRC32Checksum.Update_overload_3.htmlо3–U,/DotZLib.CRC32Checksum.Update_overloads.htmlН4Ž&/DotZLib.CRC32ChecksumConstructor.html‰ëY‹ '/DotZLib.CRC32ChecksumConstructor1.html‰öyˆS'/DotZLib.CRC32ChecksumConstructor2.html‰ÿLŠm"/DotZLib.CRC32ChecksumMembers.html‰¿¬G"/DotZLib.CRC32ChecksumMethods.htmlŠŠ9¤{"/DotZLib.DataAvailableHandler.htmlŠÕ<%/DotZLib.Deflater.Add_overload_1.html‹éb$/DotZLib.Deflater.Add_overloads.html‹ÞLŠD/DotZLib.Deflater.CleanUp.html‹ørˆ4/DotZLib.Deflater.Finish.htmlŒ&‰&b  ö @ q · Q /Å\ˆÖ'tÀõ0w´BPMGIÝ//DotZLib.Deflater.html Uncompressed MSCompressed{7FC28940-9D31-11D0ûsLZXC (ûsŠÙ€ rz$Î1È64CðHŠVˆ_”vT¿ ¶eLA HHA Version 4.74.8702$ °ËW¢žÄ DotZLib.htmlDocumentationdocumentation MsdnHelp¯c¬  T#SM©"´†ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ3@3U˜ i?Ê eM0’qC²`ÛY©-,1²"4¶oí¶+ûì¶¶’XGûˆò÷0¬#2`EIž%²e²NVB$KK—FøI–,y –'Kƒ((…[óÙ ½Êζsî½—.¹²ûÙ£_Å(lÎtã)\`ÀvÊø„úEᦢô€U AUô¥§n ’ø]K353`o@Û{mÚöµÚš$¬’²Ûº9²·v[{ºlYX’Ó6inýZ¶±ìš4®à4âÆH"|lcBhI!1€‹@@&@$\„#º@ºDÄÅû õØpÉiLâqZK!±A“•–Ž™'KpŒuã¥öI þÒËåÄ„vc¸`w'Í”œF³%,`ˆšÎ³˜Ñ%©–ÕÜòâ3Ä”Z¾geöçdÝ2Æ>Ù ò $º%¬ìT𘙎åfÄ—Yqƒ£ù5ì÷¡|;M‚98VR¼¨ÒÁ:¹¡TõTzxM~®{kUÀI‰upr[ c>'WÀ& s´%5aÀ{Vè 8Ÿ@Ÿà´ŽÙüØ…ÆZµ¢Ð ó ¼ÃOñA6 ¹ ŸH\óü:»Œ˜&@œ×jòÏÔ!Žñ¤KžjaŸû?Í"îpj\âÕ—“UU&Œ¡À¿Á¦MeÌoŸû wß6v›RP'B‰8 îVà» ‰rˆÎ¶[b3Öñ‘oX"B6“ïòFÒÐn›²@ m ð¸BDì t—­=:¤ªå£OQ7E…h5è]_7<@ªJƒŽh¯=³oä#á ±O¶}Èë|éÉ ùm…¶Ê’tÄóÁ®e’U×)²ìwÁX#Ì`ˆÛ¢¤ŠO—¾Ì3ÕrdRÛ¬Ÿñ^8Q//”xl†§KãË%R4§á¶ã„!Ih€©æV"9%­5.K*2­õMo5 >­?{>œéÛaý¿æÂŸfþó`Ïàâ…ëè?ü>`;z('1‡ûÅ÷¶Á‡Źr ÒnÓŵñ\Ý…ÁNo³:%ý¬·Þ¨úaôY)Ÿ`ÕóO”¨É2Ë%U·ÍÇMMo)õHdKç Ó… «ÅZ)àŠ|=IãIdГߙÀ¦Ä@­'ª:! ´íÍ’°Ä¶÷±ÍgðV¢%Ò0]Æ)ó“Ù ­˜™š1ZÓ1Zº;jMR±\û:èDªé¿d’¥O™»NõÚÑxcBëcüëU.Èœl© jâÀÈXA¾ˆøÛéƒÅG&|‚†ýFþ€;)ú%úóo$M¾Ȳ„³šž õì3¥²¢Íp@«º‰Á­å|év€Aõ¬+ðùæP9Ö6@¨°}äÐìu€Õ¯È2X(¶§âÝ=)Åç³Å-]Z R-¬èÖGmò7‚z¥Ùôr¨ý«œøów"&Xí,Ì ˜XêM_´Ö¾˜on^ $““šâÄŸ´Úø°îšæ§õ×m‡¨J»MÇšÒ¶+ªZl6ƪÕo[½^ÞöοÝÛ±·—"‡åÌe1Ñ¥Nn•×X¯ž0GJ½,z…£¥û7t§U`}VžžµSÚ "á§Ç¢Q †æyèÇN/,îD‹X‡/. FârQ›† 4hfD°‹_Nÿæöسd‚åÄŸCjo!EÛ‚0|Núhp´«VáÚ,‘ZpxàY”ZHÆ ‘á›Ó /À[øÊ/‹ 0bXÃ_4|SiÊêFº¥ÅHV'ÏÊMøDœ4#©Þm½ÈƒÚI‰’_çC0Ö)À“å¤ÄPîôÈâå`›rR·°RP.ûLbƒnÿÐ/ºô»m€çŠnê<, 1Ò~n¹›Uµëà7w¨«Œ;½aîýÒî*ò…‚Šb#z¯…E:J P°êE…Âú„FK+²á¶Ó︧햺ž×³‰µn ·åŽz·]ŸCìmF:£Þm—Õܤ°ÍzÒÖ}h§jΔ‰ÆÐH”f,ŒM‘V‹ xK¡d ÖÎ$¶ãÖQÌ€xuÏ2§f”ÑWò—øÆà!xÝÇ^‡ ã=QÍ(‰jq×[‘Ï‚ú¦' yÙ{‘Sö¦ Híë€Ù2ÃH§!QX s$yãpÁ½¡ä„ÎkÁ¿×ä§'®]+”+CZ§8)1]ªqIÞŠUO n%ð€e§ø†IÂK5ŠÈð·ƒgöwoÙñ¯ žË@ði â½ÿ´<;æc4e&Ú>¾†­uõòF'b> £[jôÑͧB:D¦€@)gZM`ß§øÉ¿¶..#º$çú¬&ž|8¾Ì-¬t•äpTvÄI¤ æÿXˆÍi£[ ž5Wì%i¸çŒ0V»ð‹^ßl¡psPû´òdäõ›´ûroL/¡íš¬vZIGY½t/§XHoÈL\œcæ£:ò‹ê´´ÀH{…ðXÏ^àPU¬þO1>§n?—–Ö1éôŽ÷H([fWvržò‹éØL¹¬z¦ê—ý +D]+1ý²/×_)Ú]ÁÒ\ÎÍ—ŽYÒ,Ê—¢ÅòYó\ €‹ ¹ú³„V[4 E­ìE1X[ÁÇmðIPú¨.Ë“ï‹Ú5-Š[®ÔF³ïeØþX¯XBáìúðÕ ÐK×EhÄs̸+ÛÝ:îöeöúUó³r–Žfró#{HK¾AnìßÑFl«`¶g-äŽÁÿµŸ‰=Fxrâ×g7¨&@ü«×[œ:gÄ‘–äb2óT¹2&Q•u”7:Ϭ眊q+ëÂÿ°¹Zµš~ràP––œOýïÇ ò0—$\öXŠæ±H¼"sù½ùã›xÞzo°IÖ,v;Ý¥žæo•å=T'-K]©wvy­©ïÝz)b°GËÐi¹ñ˜V îRÜ:èÕ ¬õ“ØY°Om-YòÊWˆÒxgu!ßÃ]0`¼$Ú±~í‡çÎæ]¶ƒòêÛ ¦öLMWsdßê) Uv_Ñ”õr~7¥ÜwÂM§…©{΋vóªrj‘vâ’6@h’ä]v öÓtÇHçÕáÄ OJ³uÙšðÌÄÞ1Þ°qÞjÓò±˜³áÒ¨÷7`7?ö)$¨HU-È£g÷­Ably_ E7¸^ÆÅgò&9¿òämNf þe`CNÕpåuƒÖxú¨ÄçgàV«ÂÒÂ%Ô7¹|›b¼³¨DÆ9Ëô;Œ3œ¿ÒÍËÝ ÖÁÕ  «ÊÉDü UÄWs.Ÿ,ƒÊ¹ù7Ôñ¨î&ÀQ\RbOeV׌½¥J&ݘ Ü°Ê 6Nr¨À|GJ¦"ðEžTIG¦Kás8=6lÇÂ"ߢv Ý 1î,;šµ•Kf/D®÷~¬ÑfôÛ–ºÔ+䤿:œ5 øH/Õ{}x'±#"- ¼x>¢Cµž]ÈNr¡7Ñ«°D¥¥"šOÏ- Uò·Û=Sªð×à K+´q¾ŸÚEôˆŒ ¡}¸<¯ÀÊPõšŒ ·~Fâ1ªcêßåóS×—vÀeáQl>’AížÏ{Oµ@r©0Ì÷ËHDΑ.ä\æö¡Ç*¸S¿tVÀEæbCø0P|ÄÒp2Æ'{š]æ>Ã)-gª8ñ.Øi/r qT¿Âœ.nòÕD)'fÿÉùÛxc_rú÷{¿2*‰ã±¼g¨á"u·ŒÂa`{þå™i¥`óï-×µJˆ»Óà³2;ïHû ‰þáU;ee¾£µÛýŒkT]K¿$„šŽÝÎ%š™ýþEÑ’ò”ü(ÚÀXì¸[zoizºº,€ñÐ`Ô))ö7²âWÓ²gÊí-÷«õ<ðMNŸÝz¼8©’WÒ/‹€« ”boø™ÓYϤ ~æuò“툵“êÛA ¯•mÊÉM>Ä´ÇnYêëµÏæÅ¨Å-œ:W—ÖÞ÷u— |Aý½—µ±æ%ô 4üt;Wôå÷÷Á¥è>*{ιÜ´¦ Á+ù5Ú>²ó,º„6=ŒBPRØ‹ÛMËÃG-Mûˈ$/˜Z+xá6aë°‘ù  {€ìº/„Ë=ìfUôr¢g„ Ó| w·›Uú¾{‡‹ÉOþ9£µ·bBâ¸_øRãEnpwIšdjÿ]+T1Œ{·½ÍíX%ä3¡kÓTþþôPg6í¡Þè4»Ó:~\ 7بêd7õûýÁ7¬ó¯ä’½A|ÄQ—‹]¤r>=¥²?ÑOã)•œ‰À'¨ÈšÃµ+ T‡Ù4Rü(£ììã WÇYÈ®ÿöÛ@GB¯°C}õ m’ëO† M;^‚xXdûºÍTn–­1Zì8ŒPË_a£ÆéÓ=«2neÁrGÑC’w*Ê f‚ãïÛ"¼\ï(‹«÷ ªãWòõêF˜=ÿŠ2òûŒEžà™;ôNŠŒpâa+ïJÊOÀ˜£‰-Ðß;¶@ɪ¬]G…[v{¦ÙŽï´Yú|.³%uü1ÐA\o!QA³p™ò!hÒØËÕJ×J¢ Ýä]¢tÁø0£Ó°–ÞysJBäcŸH´æ“-q å½óNp‰t ÄH3I5ƒ3®»GïŸ~r“´Î"‚î‹—‰ÈBC)sÌù) "m’ÁˆÉi2û¸ÖnfF 6…:™§‚5b6<áLc#rÎ}7X‚îõÍ_¸1@§….ÜUžèÀ×ãí:dŒ°÷ó Ÿ{ð Ñm7ÄÁ [³Øl·†ðÁTÑïaéÙ›Òfõ@ûýˆ”z Óc¤PPFíØd@{í±%mRM+êû|ôPƒ¥ŒäPºž0áj#TÖ+»•?e­¬Ù؃zÊúXÛ(q[âÀa.{³œóÉiNíæé€*ýWb)`:&ª0õá#6 Ð Ã8“±ƒ© ‰V>ˆŒTÏŠ’½ÄèL*•¶^›u'¨?ÈNQ€n£ œ!A:šbL°gR”ˆ J|Šö΢Q÷d—€¨TÈÓ|ÊèöY|™É[²ùJô®qZošžÁùI`-ÛÙ>§Â“²qD|Ù¶@ôãiÈ¡ž$z™:«£ã‹ÐÕ‰0f^:º[Dlù¶Ô ‰ÚЛ«Œ Q¿É,LÜ€ÈT(LªÂsˆ[…G¹ÎËŽ-ßÍm¿Ø½~{Œ…_®ѼÁÑQ(ãÕÇÐÁÐÿ€šaÿ¿»ž/ÿ"pÆ1XÂt˃‡O*4öI)Șð€HÞ‘àýˆ¸¢Rø>BDÊÝ>z܃®ô*ý¸íÌô©Ax\ÑèZ­PA-ÁØ Þ• ƒ_Aƒ2¬¿åRQ ‡¼ª§È:ó­./8¾‘<ÃY¤ï ?*#áÇÅ5P(6 D”oÚN¥ÓF˶ÖQ8<"¸Û•ÿ"‰å^Œhž…# Gø˜ 4.½„ ˆ7Âñeâ&\Ò‡ƒ aßLà>`€D±µ÷(a ¶Yv芮“š(³}D&6^û×ÿàÅÕÄõ&æØevš/ô™Z²‘èE„¢-<Ÿ¤K£?öþ@7$äÑKš.¼»ŒH>" Û–³v®€ø¨ò%‚fâ–Õ‡À§‰~Ã@èy@CÝÙÞ9`)îÐx@Þ ÞU(p!ËRÅhÌ68ü3@3oeLÚAq²nØÆ¸1YèŽ-~A¶„ƈÛvܶۦî’fGóˆâ×Ö¸¢èH`´š+>À¯ÂrCo€]ë´ÍÂví®¯XÕv®»w‹jmk÷¾­­íݻڭµññ‘—ªÚŽñ·Çª»ÆŠ/<ÒçZmx‰WgnŒ…¾ð±‡@ âû!1£0€¾?ÞûîöÝîÿÝS·ÝŒeY³ßn¶ÕkíÖiT¤”M3-[›tf¨*4L¢”žxž ‚€‚¤Š2 €?€ƒò? ‹œ ¥ÈŸ ²‰ñs)ÛB–5Í›4”†£cv¨7øâ'êÙŽ‘‰×fnjó&äQ3Ê.±YS«ÂŽgf@?A»C=y›†-y£Zzß E­º4ejŠƒ™Ê ²"Ë’ZÊEÉ–½…~ÜóÂtMPåàv@¡el—”½ s›É;îÖ §ý®;\…{˜#Dù ”R¹åébµ¥mº‹Á¿ÚÑ½ŠžïÜCžÓ:,^MÀî¤JðÓ«×öÝ:ºœ—_ë{š M ' mîvZ Z›O£Ú9˜›02{òÊÙ.-ÂÂ@œgT·öê"é¬ýðœïëëJÁÅÿ [ùK9YvŸ«<'…;(×c¹Ô–­cxv˜Ï[ÓOIÁþÖ«:Ã×Kàå–)Þ èí‚ÞŽÀ ¥¢N¯ègt'µ »Šã÷ZîðøvvòXæž3tb¿¸²àh¼TöVÔŠëš%œæè@·¾ h“†8»h>$µ½Ü-Ðïf¶åM`'1±Uèò)“+çf픂vbÃQâ‘!–MÀü_Übc\€sóv“¾÷øú ¾D´27àg~y5/ÆG3vÚ#ÆÈS×Ú»k7¥¥=F£jŒ *Šˆ~¨qþï-#¢½z‰fÛV6ûú;gÂÃAýòÍðáZ±°h+3gé9«èí©3'ÞÙAÏä]¼8F[Â;Kie×®¾­˜Ù… Â¿Ç `ˆ´s Ù1KÐ×M„ÐÀïì?ÁÜÐj!¬@F€‹*±,Žý1Ű =B´E7dÈÅ#Øt÷½2Øã:3='$L_à¿MÇÕãÀãäëη“ýv™Ò;é£j_ úê?¡žQ² Ò·1I.Ü<¯Q"¢WµM:ÿ Óê5O8ê”gj÷3d èk|ÏO^ø Àáçe‘NÚ·éC¬ÌŠUN%‡òl¹¯Ú(ÏSƒ )©¡pùûhÛ‡ìçÿ ÝDÿ€ž}ãVŠj/æqŽÓÒ÷4A£u6FÍ\A‚çÔÄ/mç|c–„w 9/ù^ÍÕäÄŸ®Æ[Ÿ/˳ âñŠ<¡2Yi;lÿ€ò&³Ð"†]Ÿø»±¿ÞãA¢9Ûú¨¶Q°ðÛi1<ãÙ‡®ÑIhÈ2ÔîÒsô¹þ[®‡?1’°;,„§üÔÆî˼ª™ Χïÿ~¶GÎa£ä;Òh‚ÚL$^OÊ»äöûÐç­E³q£"6e÷Ì-'F‰ûÙ=៱gGw˜°[P1Ï›áïæñRøbïÀ¢šG¼ú†‹<ñQ»ó…%s8ÄcŽbÁ‰Kh¶-ð¢é 8H¯ÈëÇm/ômÇ Å‚aXZÜ騖F…¹”À͘K÷c×f$Ôç»V!Eú'¡$ç)8–u½àóR©9Ró0¥|˜‡1YîˆgÀQŒä[C„UÇÃò"zŽ^·a5™bNè#ÑÔWyÑÃ\/^TFä’bV¼Æw5$þ€ö*"ã'c“êˆj>¨?"0=¤Úòa3MP£ÁÃà Ú~EpœÃô ¢,p‚TÒ"'ËP«å )¶Fz©@¾ = oÇ‹P7âGF”‰úFX}{¾üa ‚½$𥾏’ð_ÔˆÚÏY=!x=hWý‰ÀvåG¦žmiIf{ºê5¾¤&,æLYc¯2Ç—YQ‡‹1Š­T‘4fnYOopŽL5“O`Ä}eÊPkñS!&꘦†.e%%\-i2(9sÇö@†ð%óè?¯Ë¬1„Ü$¼“1àÔ+à*“ȲޗÌï$Óø`“ð!lÇæ‚ßsøB5ø²Ë_BôjÙ£8å!ïµÍE½ØÎL1Áá‰Æ"Phõà¾äµÇÆ g4B î“¤û¿Â­‡¼—Œ¸Ó $/yᤖRä®!–«¸ìü7 y6‰.¡×ÜÑBŸ]ö¬ô¹bK¶KKÇùÆ"—¯ðXB|bÐâøžŸÊ ¨Ç˜¯v|‹–Üzçm-*¼e:‰x9÷†lÌtt¢¨~Ì ÊÀeD„ NH:¤hŒÇ­¨–"ÿÇôƒi# ŒògãK¹åÌ‚W»‘£Šã?=JGSîÛûéÜ·ýEß§˜†;ùhŒ©Œ1<áµ¢´€-M“ë dx ­à%cDR5*ûK”/( t@ €êc*ꤰ@ÆúøS„ü.ÀNƒFðnA$u/Þ»E.}3ní/RjQ>öÜ1Ócäâ§ [Uw¬0¿ ƒWðR!O`ÒÕ"Ûp.j¸Ðª§5÷¹œL³8ÅŸP&„¡#»”L ·8L¹ef›}”Úv†„\—r»^…g]ßö-CàÒŠ‘•ˆ '2¯ð}c­òE¡pîtýȰÕA½cÄ%5é¥#ÐAxhÑ ‰H=I#'ß Bܯ& tŒ‡/ëÅgkÂâPzˆAd£ ¬ŒáêT¬43óÞrbzýzB•Eå˜#žåyZðÂûûfi ÞÚ7z·tnÏ=g8~Nñc·b&:‡€õ‹†?‰o¿}Þ¹0ð³MJâoBþRÈðÌ-OÛF?²À¶§ïÁ@8)&·wœ0R4w€„ƒ%’ÏòÕz{ ’‚1—ôéå~kª6ʹﲜ¿·TÊ*/wÇ¿nÅ$ª\S¶W}±Ð&íØD’|Dý‚C´Žè¥4ø7§È¨ú’ úi˜r -ܨ*P± P1†6 ¡}}S,ˆOÿÒÒ‘n¤yå—ë· ‚Ï®" Ì96¨çHùä œ*·‹¾î¨ñK°áVWdwÞÿ/ÅYE;¿LIÝ ‚µ¶›ú’…| òOoòˆ71NQ,^q·xD[s+eiæÝVÙ=é`;Œ³V¦bïaΫ¬µþ€Í |Õ¡è°e»êN{] #(G+ýàW›ÎýwU£‡¼"o&Uù³…÷[ç £×æ3Œqþb\OQ2•µ­ÁœÛ©XÈœ"«ƒ7ÊU‹‡Ñ vž V`ÕHúk`‡a®`)ÕÙøÅ¨[òå€Þ4û7Úóñ6¾BãsEû›Qf5æ0nµÐ'5G±­íGµBÏåžAÖËC';Á:pˆrÚQƒÚÏÀ|R[s,´¢9¨Gf[DüS}GÇCØÚ,çl#Û8ŠRtl bQkdê °Ñ|µ‹z+!B•[ؽ%ª[R‰|* *¿#ï=é,ÂØ ‡<ŠÊâÐF>qJ«ñ¶ñ¯z’S”puµUE®¿Ð¹¢Ëjÿ A —ЍYåÕâG¤Ìˆ "|û®PYU*R0ÞŠø¨7n…mŠ*gÜŠJ‰é ªçû¿U‡Q~=&ï¿€MÎX™Ö_•¡ƒ˜•¾é¬á[†UbP#GM˜'™É´2:­HLqWYìü—Q Ôï1Ò¹Ží¢CzœCk‹Ú«ÑK¶]‰~qÀ'n„tA/ñWäBõók%%­á(Ù–àæ¨FòÁET—˜H`‚æÍª†mïDW`Té0è5_~þ!$tªzÓºBdC& “ .Ÿw¾&°JEbxÚ,Ed<ÄxL« ò¿÷­’áä,ÄwU-egzi `&gäM‚‰ú ®KZr˜·ÚO¦_¸.Îcü}Bù`+9ÎôïÙî5Nþ¯+G8éøÞ Þ£s$Ìž*Kü´ŒU0-@b@4{'"gp^œl¡©åB%ïÍfoˆ—(Pÿ«æ9š3º….?ÆxLjÚ/§÷O"XX«Ç¶vu­©¹+Hó`·ƒ'usèÄ8å« Eòû>Ï«‹Ö—P³˜omlÂTzßFøÍL·ERþ{÷„ c1[°QY¢·2l °ÒxLæÈdhbí‚®šT¾-„T᪄÷8FÃ;ˆ~Á¾H…`‘·-EäÕ&Ôôj}Žne½ ߲ݯ7Ö/ß„‹:?…à×vÝ¡§ùúÛ›«þɺ~lÞoh‘…×®jÃã3Ðæ2l7é œ<å#ßnÛÖ|â‡,oËq£è¯›È}²•)ðO©ÓE«Ñß4`(ØÈàÖxªÔJ ܺ¢`Q8<€*̰ÂÈ üƒù“üšèy‹‡¤˜8ƒ4ì•LÊxMª[$Dì™ÇË1‘Ä 21Nmó#.E,þ“·&RN4ηìBþ-Êgh›5ÿE†‡òÆ„y¤²GÝ<Òw§Ø8ȘÑý!apÄ{HªiÔL6v<8JMHj£æ†w®9b€=.VEq.ÎÛ%jƒô{¿“ó¼&Âܵ ì0`’C¾Æ#7,T :û-#ÞéPÏBûÝ7­a\í䨝ÿ!õ….µ’äGACÎQOR×þت‘Km Efý€¦Q]O¥ EnqÙ9`ÜF¦Zzöj¤œ ò"ë0WQrÙÃðbÚJä$¤Xê¸IŠ|ßHR`yÿg€õ$zÞÜÇ>•‘'ÅÉ+&nZkÒÒ­û8ŒaÁ«akÄËÕL½²^«IÁ%`Á¡œ01¥ûø0}`¤é¸3` m’‚iÃ+$b8 ›iÆD°¥V¶ÙÔ’QçSå¿~†Š`Ç8œTÐ@UzÞ `Lñš-bá/¸3ß´äÑdU‡…)˜’C@Ia”êb%ž’·GL~ˆfB2 /”Úv ÆV/ÙPå´òB¬Êc˜[¢òz§þ¤çU*À(¯¸6°’dŠÎO$:J $À P€vú@3c@3eùÐÿƒ(N° Ö,ÛHG ]±%)È…%4¶„4¶C¶Ý;åÏvº»˜Ùá¼¢øÅõ„ýdæ®hìài„B ðø[¬4$@¶UËÅzv·ù-g7ÞúnΚݻÛo-×rÛ=}.ʲÜññ­'–²¦ß·mÎÆÇ·¼ýk.­â†¯Ï¶ø…“¼[,;Kñ@hfà  {ïí½öîÝî³Ý{¦[‘Í©îzÛë×µ­mÕÍ(CÚÄ]JAÔÛ¼´­KF I Bô§$ˆXE%~€q,~!ó+ˆ€š~³1©yãù‰;PSv†]í;iYíYˆ*Ls˵WÒÅl1sxÙQl.3©éÖxƒ#ß;;¥˜™]¦¢ʺ+l¨vV‡–Sî×ãçc7XÓü ­Dj"ë)ˆ+•Ì‚­ÿ3Â2 d}YÜ›\å2­zo35‡ñº`Ÿ·°zÂYt&ñ%ÇŠòæ¿[ê5|y¸þÂÎÆ¨oh€ûô¿ ¯bœĶAÁ¾,Ï^Òís‰‹¿›IUŠ`Xñk³ª7rf ¾È«­ë|ï4i„±Û}9¼Y‚¶¶£! [ú’E,oxÂ${J£q´çôFb!ÛÕ4'§RÉúøì¥_Ù-{æº#)\Þ ÛrÐ44èXUb*0±Ïe,=¶çe„=“4 /A<çnÞÿÂWêÅä„+µaçÒñàgLð#W2´%zœ Ðë Ìóò¯4îrmÝ?t¦¶:¥ú±"‹n>ÂæïÓ#¹ïuÖÇîK/Ãë•6Þj³Ì=·\$ÆLò owßïuìú¤U™W¼«Ì ¦eɦèÔª¸-.¬:éò£-Ò=Šš”Keï^ÇùºÃ~ú$Ucº¬þ}ÛÄ®½;Ú8ñœžDÍìT ]„Íùüõµþšêaça­ü­ÄBz²Ð`Žõý!iné–HjO¡'SÚhýo¾j õ îGÒïònÕÇe)/ø“5Ø*ÅÆœ‹‹Åüìµ<Ç;¶Ê}lýÐÖ¸jþ) Ðý€l.‚ã>¶ë‡á1‹jµ`†ÚmÙwF.±#ˆÕ@ˆÉDZÞ|3[$tH²H qÊF‚¾Ï:Ô³F}McNAä(GH¨zˆµÐÊLøMü¬ÚɱÞUÔ ÷ÕO€†8§3ÆÍ(%0j#r ‰Äš(,¶±iR~6~–tÕ´àYñ¹‚évj¹í´É³ªš¥ßÖIýL¥Ûü|€÷Q“¤O…ó0µK¼q&0ó8¨özQ*Úž‚€{Û¦ðíµ4Ncùñß¼þþ œ½™ã¸8_–x‰ÆúïíÊk^³6ˆnƒ¡à½Ù™v þ9Q«‰Ñ)'§úÊÑÚê¶ö{wœ¿îÿSñ—Iþíª#àSéå&©'­;Ì»SQP˜êßl7Êkßu*BƒŽÂðŸMBt0™\,ãØ]lÜ«ÝÆ¦‘Æ2»ýÞÀ{ígwå*癢ºÕÂ[E-0³ ­·|T/\‹vÔjçafdEì¬Bl‘'LªAìÆ6#eŽjâ,³} ‚izž=#ÚþU‡à•ª‹àCwÖÅï-ì]¾×lhaòFvÔk˜¡¥®ÌªÒÛÿryq‹GèåfN(ŽJµ‡­­é¯ë’„wµàLQ‰E÷ =‹å„^²T«Þ‘Ø£J¸]~2pŽuJyf¦`A%·B§‹¸Âƒþ¹Ú‹ôïƒlƒÂîc/±÷4½:i/d®?Ò0ò<&~ó í»<—ž»uãÜíÙ›ÉW£ã9GTC‘`jÄÿø½Û“°6Í^¬7€àм%JuÓQÃaCÝ`÷àÔÔ̆Ü×¥öÎÞÆž»}`.2#ùÒÛÆ³7™¯º;oÛéqµðfÿø¿1÷µ¯a+Èw‚Ç«@[ðXQ NIÛ^ÈwhJª"$¾EÕz&ñ[òpú@‹Ü7ÐÛÚ¡$¹h`‚[^<¤€ÕI{‰)‰ïœ!ŽyB_yÐÄk-æ:JŠx„í‡'¹ŸUCµ¹Æ÷)vX6ן˖+ÈT ѳŸ3XTºùÿ}ýxD / ÇQ`/ã?îEï­¯w'Ô—C°iµÈòW[Í‘JÞ ð²ÜÊ·ø‰qi’Ô°Ùå ¶bÑÓÓÁ8q=$8_Bª:Ì‚‚´Àyl”’Kÿ¾Ñ ë¡+þ ÅÂîÉõˆ '‚9A“Èu¦Ù Þà Äê4A†;r_Be °& Ëù<] o§Ú´7¤¶f³¤L­ÃcÆ„Õk8ÓZ†nŸYعŒgÝu¹}A勨¿Â&»\­oÍ~&³î­_³')ùæC±õ÷rSÛ}nSÜ[ÛMv‹i#"DZ6oäqÇmÅ"P3ÿHåÐ;º`‰üd@ü(£Ð]ÏkÕÎkè®úM(ûã CG5ø‚q >9!  1T" çf`ƒ¬P}qõÉÎ.Þ[~z µn’Xj_$ùº'g ñÉeC9û$ÇÁ& )‰d/ËÚ0“ïÎ ¤€Ðó»³íè0P~]&B E•Ïì`>= ¢\Á³ •«)©†m¯ç力¥dô ÷+ŠûtÎgêϹ%TF|жÜÑÂ6lM€Åkh›Œ[Þxß>¢¦$ÂÜÀþº’%uò`¾<’ߊó±|}ƒo—óµA1! ã&;o }\B qîFoTÇŠ dJ_ ÛM%™¦Ç)Y¤hÅ'6("Î6ò”´îEq•:¯!DJÿµ@¢nÀ@Djdr&˜¯\*ˆ-ä-Dû@Òÿ¦i ·7“ aª^efð2΂08øåê 0@0D˜*=¥!9à7BÛɹ·Ù´Æ™´¦%ÏiêY_f8¸†¯i|q2Ó{AŠ&£(!Ä8¢ ñƒcƒî¹=7’Ãáù 5äÒ9»ÃVfÄô°=™a§°…':ü5R40ÔÁûëE‰¢Õq sÂô_†ŒŠµÜåóžÓQ|û^ân'D9ƒáM•`mW’‹Å\Ùd‹æ:žw§ò6½ÌŽH”4ó½_/4 \®ä¹ÀbÛ¡ëÜXý³ªÍ²kKñë¦Ó‘’l/9žÇvCÉö•­¾™<“« ÑB‡¨½ðÁ¨Œ0O#óþ·.MäU䙋9éÂðìfvƒv1ŸÙÓikv|×7óýUë ˆ`ktɦ¡>¬ÜEÍÏÖÔ= QêüæQ ø¹jò2?Rú¬ÿ‹'RïÕû,O›ˆ?v¶ì­<¼ ÕˆõyWý§?ñ}Æi{‚D½tRúd‡ì.ÏñÔ§åDByEŽê<5Ö´H›©Æ£Aõ 17rÛmÍÓõ3ã_tv±2èMR’þžÆZ7ñ<ÕêÒXeõ£P—Wþj)¾ßIp[(==;9Ò&ëkÖöKÔª[$×|qFö¦÷0óŒ/SÎË$"ƒ °:}óÓ$@†Ï<ç®G Ü^W Ò㈥ãeGççÆq¨”°Qî·„ý´ÉJ›¹JöÿÍ„ Ð&DI9_Î2Š}îm´»5?ZÉC(°Ø<þÏ_?AœÏlµm·Êƒðí±¾æa\8vöêöS/DU;nî>!Ú)+sÕ]ÿÎUÙ ²§ä$od%9M® #ùs nV ,º.zØØÑgY5Óï_Ç3äµ¼áL?xêâêIçÕt÷LmÈ¿¨Ñ#ÍWhån—,ÜÀ=T^BO?TƒüA±·ð·Öñ²îã,²âÎ÷t>té‡vUjµ6ФŸVbTÏÓ•øÊ£˜Ø»Ezx£ršOFt¿«¯_¤7U4 ­Ñ&Wbr:ç—ãuŒÃn ÁRê'†')~ÑY8ºJÊ1Ñü±Õ­,~4.^ér×593ò3 †>¤ãQFÓDŽxïäµÿ×™­ž zÚŒ½¦ÿ W…-?Âÿe–·mÀ3`^+Ä ú홯·$¼¾b¬.ù7©³$­v<.®ª”HNò¸¢Þ]Ñè1^J>+-cû!|ü gÍ&Þý[š^š–ä +PWºJòrFà}ð  Œ€ž {þàݑӎî½TºÓ×;ª–uú~öá2+~ (¦(XJV×ÑÝ…¨ã¡Õ e¿°åX¸×q)ôèÔ"·Ab…Ò¡õtËx²›ž~/¼yò/ʪ„P?àì(Ëpaã!KÓ6¶Jaé;7Úš‹î&Û¿¶¨#ôË· ±LL´ñnhìÑÓ. ÙhwW>g0¬¬ëîõo¯éÛ]UÝz¹Y?­±ìi,ãy i*œ«+ÿØ\Ï+Ö’.YTæ u•äuجZOâ™4`•• ›ªêOˆ5« Õ!VT73v!;=ËuNšØMeÃãço ñà.ù†’ÀˆóÈck¾¡!ÀÙí«¹õtëw Äm2ªÜHGi1hàãzØÁ#ã0¨‚~XáB “¬ä {ŸŒÝ •ý°—BteJÍÖ^Üþ»É‚œ8myɺ“ʘ‹ ¥sU eÎ*„°w¡ÑDÆ@hDèÄ‘®S4Wîù³Íjò@ëîæ ½ø‘°àN½t©‚+kúzf÷*U÷;ÛØñ¡PsÕ˜V/*º¹„³Å’Q\!ÿß0¾Lê€9«†YŒš}³¨s($$r]ۡ̈WW<—Z{±á^±MÉ×5Õµ[’«;0b[Óú¿Š¸Õ èêáW€Ñ‚ÄAðåˆÌà¢jHô«kºî£+Ûyþñç.Û’ô÷°µ…Z!MôSÚø¯B|½»#ʼ®PÛȬìy—ºý¿ £yCˆ'"Õœ‹žÄbèï¢Õáªæô.¾¶zë.ød òýÕ×nV·c½„†õ貫h§å´AI%†œS· ~ V+ú»á‚¤fÇ”*§b9ËÚ6WÞë7oe[H” ý{牡û/­È>”Ry~xelïô”ËÆõ©“ÔFÓ%ñ‰¢Go‹ø1¬œœYøüNýD›‡]ƒÓ ¡Æ/Š“Ú­QJù¢@ 3|RâLÐòÇÜÂ_6¯@ZXÄ–N¬ƒPFÀw 7ç ° ð‰¿Õ>¾e£Z,5¦geb3 ¾Dä, ÿàŸõ>V  bIú4dÅØfp£<3EÚh*¡I–†`~>'R(Ýîb{€ÖR±—¾EøL(†Èx  ¥Ï¨ß®¿\ÆÏ½ÄT“l4Ó†Ê>¾ì tkç™c(é&½”õÁÈ‚>!tË黹¾¬±dC®¨y—µdÌtic®oYä©¥Mxº¢¤˜Ü‘TÆåvé=©qçä-Ó&©uJü›±`RKÇ288I-„ò"y¢4%Tb?I)9!@rèèöîÕ ¯ËÈbpBJy‰‡ZaîÒr²¥´dÓe‘Ë›H_M[ÎI‚ ¬ |@À 9°w˜ €öôL%7ƹ}f6QÕªe1¨;Ã*ÔJ´™Ì…¢ûIbš®W«™?­EêÀì¸à¬xÛÊxªÊsõ*ª80 ,¸À Ô*ú(²âµ Q†‡!70ƒÎIþ¾>dŒ~ Ë¥òÍKáL.4èA¸ D­@304U˜ i? ˆ ²^5ä,PǶ¬(–ØÖš{ w·7eÏmÖnÒÊh_Qþâþ„õd®húÀ‡ íÌ,cÂ7ßFÖ€&À°m+;ͳ^Y¤Õ­Üì­Ýµ­Ù²»îÚsÍÙîövËßdÇŒ¯q±vÎeüñ­m³•ñ—ï–V+>ñbËYÁop“ €q)Ī4½Gïù¾w¶÷½ÛÕª­™v%wWµmÛ];U˜gYTÕ¡DM$ÿ[…N!QQ~D¾p8ð9ÀœÃ‡ùŸ ÿ#ý“’i²$±“hÉ ‹G“ î’åE´WS$æ.yTK¥0Ùê§&PV`UÄjc>ÇÍV;ë½È~a³.E[=›ÚN@·Šæ³Ó±p±XØ|¬´ÈûõKÄÖÇŠ ÝjŽM¶È·~û¾ßh{ìk”Íw™[^cˆ>ÎgÙf¯yïûºXEǵ*Õª¬‡ðµ;.ÀØOy^Kmky:¯ÊJ„ø+X¶ã¢ø&‚Õ'ÊãiðúµUãÇ¿/ŸdðÊQ5œÞG†»¶:vKç‰õè®[Ê©¶›é(«aâq0Å92¤ÐÃ[æeN™“–ÊÒúäqܬ—Ä›ÖÇž«ÇOc\õX¥ÙZÚ‰˜ôåvO7j¦dù-ȉrMº} r˜»f¼ÀG_¤<'d¥!1®¹ßZ†#kXDjT§³«vÑÒ'ñ"\9³3< […A‘8ü½uM³÷Ú±#d˜Sò(zª»fjóä âø/˜yŽHRÖÓ[*léÇC²éÛD&R-ïîd€Åƒ¬ÍÊCÕ´¾°yy¥€c´"Êr0§YŒ™›ÐmW½xË5O4Œ:˜¿>üÓ3ø›½½*Ÿ’kZ íˆkõåÓZt-šý„|Zǽ÷jr‡²“=íd!Ô¢+]‰S–ÏÛ•žj?§ð–òaZ‰,úœDm)½ ÝE•©òüÒ)j¶hs˜›PÜÜ1ûxw9óÕAvß¿‘#æ;àeO›û\øF`±3>ìëwG†žZ¸! ë¼!› ?äC¹d.èXîoÍ•ôÚJœÓDº™‰7V)•7¼"ÀV¾.‚Wˆ.JÕ§‘®Ço;¸df’2o²ˆcäíe%\;«Æcʽ;8_bÙ?¾ã"}‚ á[-ý2ÃðBš\ªÜ:×QWT§=/N½XO˵‹X« ø^mö}‡§ßØ=à×/á<fË×Q».¼=žªÄ¹Tù%³ù”Ì]>FüÀ,*]v>5M.R—­¸¡³Jjv­Mu ¥‘À»bKþ“jÙ›eìæ>æ š¹Aº6†ˆ”Úc󶘣õm´uÎ/›ÙQþ¾P”maUÆ»]pïìXõ†¦>p/Ô™øøt¹æð¶}ïeI%F/s-sóñÍ¥ÏÚÃ2Áwãš‹Ÿg3YGõÇ[»µ=2QÏßÓ]°3qY»Þ¥þ°cö;™•d…à¦À¢!]gþÝjMH´U9ú$A¹Ú›üé{‘-Úy½¿£Ü]„iÇ}‰$cö½$ï€dMïЕ¾Ûk%Ig/~n/a!Ñet$=¹)ö ÝùÏÏ’0Ê ô£Ðàû¬ç”ªÝ¨ðþ½FÝ–ÓƒŒïª)¤«³x ÅÊÏ¢›W~*ÖçÑÚ½fž2¸´|±#“ÃDÖüQà˜í9µÈß꩞”(]{ܾ2].UqZêçjþ/¬˜,‚ožÍÏŠzÚ°iŸŽ«Î;ÜmaÃõ`4µxmŸ[j9Óôï4†i`É.íÒ!éTuÃô†ötôÀ b‡$ô2í_Ô‡¡äg» †!w /N f)h„YWM¹›Ô©Vß’O‡¸™°ŠÌŠl‡ôWxßßÂ{Íöþ3Æ ó]…Jú=‘Ú£¶I7F÷^ßgÐ=¼ÁI+p[ƒ-jÆ¿Ýû£C4бë§Ó @<“¿öô Ûúý(jVím‹ÇˆÊ†jÞh4=lZOJ“%ëš! O€¨åø•ìýò ¨ë„ŒC‚ÈëP©oks•4–|ßÚM|6a17Š4¤'M"—Yëò²§½ék‹uÅ! ?sèzËa:'#8l .ÍÄ­›Ò¹†å¡¤îÀäÓ«ãç5·ç’žƒ ¡„*ÎÛZ›Æ¸I„nEÙÿ%1³–kä~ZsxF;qYÊfŽï—?íÑÁnã£!Ž/ ˜íSájóºß÷ÏêaøÍAÏ”PAà¸;¨Þ!çû©:[p…¬v!±¤·DŒeÓI¤Á ’…­·1+Œ —gápcÍ¿ä¹îÔ ˆ¹+™l¤¬qi¥vS¢±ô2@«Þq發_oðyrÆÐ«»$»BÓ’iC]pÓwð™¾2I~}ŒïG‚jÊß=¬(ÞýaeúÏ(µå׃¶À™Îb/4wÍ¿DÑ5Á:SÃƾŽ-q xBCçh Oi:ÝQÂu€Ó“æwN/Z}«ŸÆ]*­¿æ>Lr¶ž>sËÊÑ©n¨§‚éwMX›†‘ ˜}ep]àqT¹s•a]G½¡BbGdØ Ôaí?”b3¡H^×g;¥$¹©©½å,d(¢81Êè JèpnJU©u(•Ä‹ÍÕÑ`~%j ÔâÍù³T½Ä2:é±vX™s|ŠmWÉ~j’õƒ@:4Æ ìО¸\]¨â;æÌ˜ŽÌ¿ó;¬î:<ñ¼àÈÆ>õW6ss±ö1½Ö#±^názÚ`ÂÉwX0Ž4R9Niº5?YíÉáˆ3{vt²6¯'ý¥ÛØœHÔàF#½(!tƒHÈŒa»“ßüx„Y&æ:ŸÔåÐ2‹/sð?ó¡ «›.Þ*Õ Í"6{8¦uZˆ»õøª)Gü‰ƒ½«tï>Ö¹9·×‘Á(¬Ü0f3nÞ¼b˜¸€W «tâŽK¡vûjÍÍG”G4r °¼z¾Î°4ðЉj$‹2Ão1~[«tÃæ:«%“½á1CÈî~UéØÖÂ`¨ï¿¤È’ DWHEÑ0ÑzšÃ¤@£)›õ £öè¥ÉX$D»Í}ÂPH;ÏcñÝãùÔœ¼eB¢<_¤l¬ \×O“Ã{CyßPä\Ýù¯ÑáÀüë£Z‚­ásÓNr „P©`„•·D øÎÛ°p HØ@°z(?`ÈáMíÑ!Ô:ë([_Q€Þ€‰.®JkÜyšM/*Üídí~ö˜ß0Xr AWéؽ D×~(fyH†Ãæ:çVšox‡5!p’3îOn„üÁtAX”ЦNcűà[oë§Š O„ü®¡»êÁ¥x߉9…—üÿ³°KgÓÔ$L9ÔNãÿ×K>Õ˜1O´•µƒ*Jê2–NÖ ë'匒>18öDˆ¿ÁŽñ`?G$½”Ëh`”L¢D€Í4þvP)¿yÚõ KJ â?‚¿…õAÿCÆà;ʘ4@;û €d„à  `ÁCŠ[ ºƒÖ&âŸ%ÑKyýÔcA­ê¤^¾$ĸW˜˜>ßIh´ñ7¸ºÄ2„ÃA:í Áo €ï”–¨m3ä^E¾æ…†}fÜ@‚÷`ܱAIBáÁ\l“”›Ô¡«k^€í¼—í¥­¡—Õô •¥ÓëÕØjéR8$â$yßRŒMV¸ÍWû‰NÙ“ñÒ9ô‰`Oæ ÿ–¹ìFò¿D‹~íw¡&©R`ÞñͧµükGÑ¿]dž Ìu5¦“¼Æ`^5Ø£èE`J#ú–oŤJ=l¶Çž‘ƒù eïÌ`2ǔ‚…§öì]"oí¿•Ÿ½³st¤Ûä2GV-KÊŽ@ŽÉÆžÐVo|Y£  Û¿“j0¬$k=A• ¶-Y*Ìø—tj+6ާˆ,<À¦??UÈ / `ëškÁÐQÇfÿÿ(”ú'3<èÍ1è@¯ŽG£~´ÓXãÅŽý Ø„ ”¯õ)DOÁüëmQåP="ña²ƒ(Ç‚yê: +#T…È|Údƒ ƒ@GQ2³ÅŒ“bZ_傺®u˧KPyÄ\;½êØÜ}g©¯½%àäÏSó?Ï+Q?£YøÚ!©¢9€3”Àÿ'ÿŠD§-ÙHb>|°o]FÞ_Fþ²u3lfÏi’«Ÿ|Õ»qí¡ nЈü,‘Þd´×‘”¶¤Í28£É„ŒÀnGbG˜%h‹aþM #ÃÃgLÎjÕ…å>ø²Øßû`k…3Š~•¬ €IÖáɧ«ƒÑçÀÁÏ–bDñÁ_Ì8‰¨"‹‹¾˜ÍkJÓºaÄ´IãGõ"]‡°WžåÄØ·‰¸)s¶êS˜ ˜9\cÑò‰ÝEðÊdšçþ+iŸÿš)ÏxRâמïMÒT#´‹V¶¾ëŒí’f‡‘b¥„sÈ¡³”=ÔÿHLšÅx>ŠhëBB¤Q¢°\EQÞ ÝŒHëÚWwÜnPuB'+c¶Uê?JÞ&“»Va6ë*7~NÔ„}©QÁþ šÈëf”?–ðñ »ªá¼íÕH{@œ³A¸öD?£ ?à1TÀ¯KɆÖÍ•Ä0¬Žm”R?HŠM9û¢6i‘©*²de»¼>áWÌìÕîÒ"}QE,—œ6œªwHõ1È6ÒºìVöt,HæÐtø*ñaB튙b"·¿UЉ¬¢×€Gµß@+†JJ ýÞI&q©bžð߇ۉž 4á0%üwV XY¤-C2º´ØØäË#=ÐùQw„zëŽßjCúÐ%ø)Ú.ûéá'þÇjÈ!½ýœƒ¯ü1hX‚b”š×| 娠݇ËßÐQ³Ç\Ý/N«Êêhéêu}Þ‚¯˜·@«iÀ¥f¢*É—p7ûAÕ±Zh¹+7Mye¼IcîÙ^óë$zSò™IÛ=ðÉD/ìÊ3ašz"’â(Mùù6ÁÄ •Pjž^h ŸÃKÉ‘Q Ö@;‘¸ iT]¯èYT·AU¾¢ñ©q”´HAœ  `Úx*((Ö44#`5}p»Ûõº¥ãu¼§ÕÒaú؉½›u»ê×Þûlwv»mç­º×TÞÛoûozï{}½½÷j·4°,e0–ØFˆfŠ…1¡AZzå±6 $ÀjUˆ  ˜™°¢Q§&²Ù%Å$EÏHXñI4êÄÚO[JwÝ£M½÷BnmÛînVÜl÷;]6¶Ô¾9FmmzrJÛÚ)~y`×­||´*®V¾NÁEA92¹Ã(Hܲi’@8fÌh ç ùžnïÛî]»™-¶¶]·šî^»Ûíw×®-[Ö·îýwº¶þܤ’JQ2€9’Hb)12Q€B$‡ùáøâAé€=}–L;ÿ% rÈIH…õÏ@,…ú„dŽ úÄ…Ž9 †0zJ¤€*Jadb©9Ÿ†&«KB‡”@)9U¨’+C‰r"lÐ3Fgæ 9Q‡å!´gÑ ¬•Î;õ@)T^ƒ%©F”üŒtc?gÖ½|6 …Øôº …@d úÊ`\•ÚÐÉ¢“<¥RiÑaˆ$Ê{œìëiT„Ìv4)9UÕ*,HY_Ø•¸8~úü'yûB›_&ë%‘’ a‘)ÈŦú¦ND„ñɨ¢‹×.•å4Q`ŽZHÖž×(‰eL':ÌM3Àɪ#¡¬Ó@Æ’KyyÂ¥JHÅòsªtDˆ3Á£¬0†ã>k'JÙE° ‰£ÊR°P§°EÏxDa+»…v#ñTɉˆªÊ!Áéz•… ¬\Uý§Å’LÚsBµñt¶”P³ ²÷²AT ¤PÉSMIxui[A¹–+‹¯Ê‘µuù÷U—žÉQXô•?™aÎOƒÒG'PÑQ„¯ý–v’h§êJ=‚gþù¯ñ"—¦g›Î‰n™•¡žÕbËíõú„¯->#{YC$h CT¨@Åš‘Ä·$ ´¬¬åÎ"µ½8¿´R€¿›³',€Ð…dpO‡2jUgVu„ˆUËkmU z²~ÒúÄvIdŒ ÖV,'èÂÄp F•°:úÛé¿‘¸Zi2_êÔøCŸô|ú5%ð*ÇÄ=FNTºØ*n:%25@L¢|tu¯§³…çŒÒ.Ó3yC¤°ÏÔ4ÆÎêØ—:[ONKšŒ»Z¶a‰Wœ\¨ÔÒYò:§ŒàêAãnucc¨ÐˆµžÓN’,Šc‘¿í$"[W'ø3u|j¼ÚtÏG…z¨^d?në䟑°ÿ®D-¥Q½/»ÖáÔu–¯VjªûÎ\‘Zùzbba£rK3ú?,_v‘:ü"~胣ÅÁýÂÝDw/t";AY’›Û„l~–ßøŸP¢‰ÈRM·…o®×¸Fmâ§ðzLKDêÒû\ÿ~\ʽA9ƒÌÂ$J–%u޶c§¬ǯ¬ŸwNMçô+“£ÒVtû&e‡1à–ÅÝ…qjÏÇ39ô¦)ªNË1½,›ôÖ¡í-OÁa#Bƒ×nÇ?•a6ËsyñõðÉœÏ4•‹‘`•!¢²N—µéËKßD¥H’äOõ&T [RV¤ô\(§áž¨±Í|s`5\ÈÏÚ 6¨é¬rÍŠJņÕäaÖeïcù>ïÑÞÕ¼„Ÿ½~@ ë1ûA 1m¬0.š¾¨T\Æô²j£èjÔu°ððPé=%7þŠìÕf·5=\7;êâV¸4‹“Ó@GzJ–´è3ÝìÂsݬ?9¥È ê]ÅY7PZ±ž¤¡úƒ s%ôüWùޱ æyZ£¸5«’…º’Uxü*<*qS¯¼g‘ipÚ‰Û˜R߬EŸ“Ò@& J³TÕ–•²ŠÕ—Ω¹¡Ôaw:d4êP>-Æý´Ã#綪²ÿÉ×¾…$(+î‚ícÏþ•ÞªýJýÚ¸¹°¹r=àª[ h£t%D´>ª!MD].:`†$E^‹ò­£.Åtø®Ë­eªoì+p–¹Æw%æé/ütMÓ‚×žÈÆ—âé­9bâ •¿/Ï•œ‰â¥h’Á°K~ /ðùù“#Ñ7ÒÔ$~¥OªŸ[Ìýµ®l¸í#¢Ê]®‘n4m2ÒnäÜ’Ÿœƒ/h{÷Š4?à¶&ðª!ü¨6<¢iÐ-:Ùš@i­‚ q'f„€`µc|ÿúhƒt¢¥öo:5WÓÄfKô‰ÖQèTj4f¬¨[( ;à$KýNa! æ Î23Øað‡ ÌκÐ"Tˆ÷ ‹odÏö"D*ಀ†ãœ­«F;Ý‹k¶)VÑbëü6¦â»Rïœ Xq%Ú±Z»Ô5ؾœ.%ÒÎÆ¾18>÷ภ’|™=ÕÛή¶«þÖO·:ëÃ".ã’o(Cc€?MA­+v'ö³‘,ÒKùgõ.Þõý;¼«ÝþâCÊb^ w$íì©€õc9í‰j™QT²ö,­­cÉ#ÙðXß(.³ÆGjáVÏ»œ~eÓ2\yÇtAAÃħ:'bÀáŸÀ·De7ŠçfZÇÅb%^ß°28çó+îs΀É?i]ø@-';§m¹ƒÀ `žÀŽŸŽb®Z0s­ D5Ôo+¬[€Š𔉛ÛÐÿN6RMòŸDüœ:¥Š™6Ü}ð˜}\¥Ká¨Ù:ðJ”ç̵ú:‡Bž"°MÐZ“¢$#Ls“ÛÿÚÒ$gx×"Møu¦–~%ûÍyÞSŸgor1~Q±/¨è[QÑhŸðî•äl{âŠëXí3^]ÁÖ¬ä3H†Å_D«ߎÐ;gš$"taø?ññÌ*këÊ>(q˜Uš³ø8D‘°“„¶:#"·¶ZEûñŸœò´¯†ÝI”l§ôè0¢Å»-1øÀzÓ=/*²cs!0D¹QçD7›w[nèÊí]Fµ¶®¼ ²hùº{Št‡áVhÎ-TöˆÛ^æ.98éô[.Wš„êÿ• ò#:.‡”tÔnµ³Åгr-N»ë!Y–Åï›&ÁdS|ž¢dw:Hª®®ã”So0 1¯«m:)qË|Ì›º1›Ç7û>Qj”!²3…úImørv³Q 7FsÆ»VÛNÊµæØ»@Ó´ãÉÃÂÝèrºÌÒÎÇ[—ÀeΖéDíä% Ä<Œ›™Wÿñ‰ƒ^4³[Úçûâû®gÛô]Ð’Y­œªœò‚RŽpíz×gI…í¨o"«ŠÌÍÞ'MÓJ²†ás÷±°›v!³ÞÛ¼»r›‚fï ñjª@/];­®­‡Xo‘Ô —êLY{²­aö6`*l5ÙþïWº µÔ0'B!°2hKàçÕI&îZuã{eâ˜J!4'Å`±„cÓÇÛ¿`p~¹Í±×”×BgïeÜ©2ÒæÇüð€šØëágøò»QÅ,|R7«ÐH¾ù"qP-ºâtØÜ}OÄc‡C‚C9äC˜ïÈZËøçˆ…0—A¶­úWf¿ìöfQåÛ7eÀ´ ¶oQ¥*—êÕ—úŸ>P}€·ý7^ØÕ‘xßÌçÇbÂå">¨&¢¡ /ʱ·¼ü”õ‡Œøx?¦åo£’²vw 6І!EqýñóP„ÅøcDË­ñÕ¨ë8Ôy™ÑD¬øƒ¿x{yùA쓊šò°ŸÄG0Õ¨€qZ§XùÜ\&ËgJEÀùñãwø+ÓŠ*Ø\9ÓGo"<‘„ÕËÇ‹´MX,´"ø.YɆP´À“:Mß$×|$qº9Šéƒ *Ù€ÅUžM-œ?Ùîò{Ž èšH×÷ª*ç>b&”Û†¦kˆi¬«ä?£”+ŠF´iu¯JWIu]RöYσ;ÍWÎTcºWÑT«q®áÊ_JÅ´g]²Y¢|ÇK‹Z\9m4 kÒuKOí1€hš¡¹œüÊ;ßþ­„]µk«Bæ¿öæ`Á¨^˧߆NEÿœ‚Ê\i9!O’Öè&XV3Q÷¶°"½nNÀIÜE݃{h÷8Ï nóuY¢b°ZOMÄF»”s´;³C¯w`g7Dܲ]M(IIÔ]2ˆp­ðÖžÇ÷ôû<ý?u˜—Ô+‹cB^A±¾Î‡³‘³˜®<´\´Ì~:=#7< ùó JLõgšÞ»ÜnÈnÕñka‡°>LG#U½nH ¸Ÿ‰k¾òtL¤ô¼ra$yg#5×n£K ŸÍ™þŽaÍÍaSÛT%üÕQÏM·_Óœ)}MYáã1ñ¼Òñ³<Û¤…Q„ŽEÝ%;2P{fóÂ;¶6 _¡É®SDÑZÝË:`¢ýæ²'Ù‚»BæE2DÆÿT™äÍoþ—LPÿE¬ÚÓš{¾ I#¨çÍßqKƒuÓ?’¥ø)Ì»eÞõKD¨5­1ÀŒ"ãšèžš›a?‡²o¶}ph6…Ýtq¶Í° Ù€Rqb"6ŸFßvÙS?>àBõM¶ó9)Íõ)«5:ÚµžÎJø“E¶Í6:1þÇümz$uͤñÚ[]“u†¢ä°9ã¶ß0#¹¶¢‹‡åŽtú0Ár¸áxÍ¥ ê9{@wMù%h¢Ö ÝpŸý›œùaÛ³öŠã½CtqŽn‘N1áž!ÃX»ò7Ä~Å;1îˇÜ|މêYx‡(ñú‡šá/ndW)&2Ê‘jlˆ‰U•û@#PëΨ 0ïŽ>;Ï:ÍhïF¿9QYžõv“ŒèdЮÞÿ€Z*×x mzÐŽ5 ôi‚ërá9mÐélè$K‘¹½H‹ôav ‰ñâ³{æ÷du1…ð‘e|ûû…@ úîZÀöýŸ#>j|%Åf<ÔÒËn/G‚W\Eê¹5œ¡ êåÔ:«o鯻e*fMâ#Qg1¸x·?„†Žƒ ¶!:v¼’s[o Ê׳)Œ4 ªžûâIJXó¨ÃþÑ_»tëÌEø ×é1Ý! áÝ^reƒÒ°œxÊÃ,€+á$X ^ú£Èñ“<_«‘ä\KùP¤ÏÏ@㦢ÒSZk¾ÿгiÁC œ/Ñ;Òh—‚+jÖ˜¦oiÆ!”•Ó¤JÙsÀÙ¼Êò _KgN5 ÉBjõ]#!iºÚfÂäCR.Ž 1û‚™%]d¥97dÊÀƒ!žAGEuˆÀUWCôq9¦=O™ é<åŽìÒŽ²Þo<“xÐðÑ¢nAâê‡z>q%P^:¿ÅŠç¾¹Í‚Tm¤f^f­JJÕìbªÛ{Öv˾)¦k­–·®x­Yïk5¼QäÓr¾oㄆɈc£©]HL‰’‡•Ç-&®Îc¬ÒN`;eŒÙzæ¦o™5_÷aÌ“3cž1ŒFŒ˜~SýŒêðLñbõwLÛ3W‹g‚5´èlݤ IÆ«pÓ~Ϥî,cÅÛUé ˜í^¼/?“B:ݧ<ŠñÝ…;–}=É„ŸM÷’õN-¥³€léº ¨¥zpçè*¬¿köwV0èˆô†‡h$m‘B ØÙRÒRóW^ˆöBé†O³mR1Y1}ÀxŒTËÖc§ÚÒo“œ‹%|šg¡)ßR]”J¸ÆKeÌø kú"‘ dFŽ2ö%æ¢ áOæØFgÄ>ndš´‹é};å ØJgæ/Möú5Qæo$Œ?½»ÊŽ&'CLÓm׌¶Öä·mCÂèÌCý!h´Æ"bf»äKYkZ_$ìQ7.’\}Iÿ÷†ÐÙrºÜ¶û  A´Âߥ7¶^Ò´˜Îß1¿¿ÁÂI#†lH4)l¹E©›ýÑu1#‘ÂEž"„„ŒëïZ.ZÈQL¨z&ŠrRŒPG0íu”žª…¢T1êt£˜™RyOÔÙU`ˉ’aD¸ãudxïŠt¸?1|—áq´3\ÿ<,Vtód·0Ðæ/’§ŸŒ=ÿsB(êIf¤e8Ãl  gR@봛Lj>cîØâüqùºÃÜÆÄkZ2ñ¹ï²p¬ù‡ ÿ!OÏ·üäëåÔáó‹Üà@OrÜ”™¿y0áØœœ—ÂðÂ^\'Sü®ßžá¯øÍy!óýcÿeË ùð7 koì7¼÷/d¹|“Çõ{§ýdë¸raÿ‹†¯ýƒ~ôÞïýã—<ú'_û³þñòË~`Õ/ðÖÞЮæ2^½]ÆA']Úúßð%½¯â\30X[>ˆðæ!¯^Ç—ž—ß#½eîÇ¿û~_0ä^îo>yÙwœpü…s®Á–AH¢ßÏ=Š·0æÜ{çcüæ÷§~pãf|0æßœyº¡àg?KÚ”û§?Ù0ÿwÜêÏ_G¸ ”Ûè¸?äÚôø ¿¾‚üpDÌçßk<X0f¼öSRÕ™çƒræï¸`©Öýy•qÀgŠ þ ¬ÿòÂß_°ð‹~ƒ_ýìßCï5ó>Pòïÿ8íWÙïOë1¼oþm–góà'0ÞN\ãMžûÏž×:÷^óŸÖ}þóú(qEfÙYèÉ%î3t9ÛŸrhˆ/œc˜Â|(á'?%ó{yîÁŠÐó3»žÂ ráÏØzpðoøóRø”“8µÞýæáÃ} ÈôkyXè+ÞñØ×<~Úþ­†ùýç3¶ýøÇ«#/áwÜ1=óÍÏ¼Š¦[ûÎô÷S=¦ÿµ°ð3°¾8;‚àÙœ8¶„ þ/< v{#2`4_nïëÚm­ÚÖÕÖ?µ[jkùºÏµ‹–¶w>êÛZVuˆînsÛn{»×ºµ[­Q­DXW‘à%IŒ€„@…„éQžÀú…àCˆdBOI (@JffÀŠ î|’î½jó{÷Ý6@º§“jâÅ ˆ«µd{„U[kknn¤£muoIÖ¹ö}GÙÚk/{«Ö¶ÚÙäêÖÅ‹ÛSmd‹‹›odG/^ÒŽ>x`† ð@€~!¡!Dš+ë={ý÷ºëý~Ö,ÛË–“»Öf»±WJ7²›5 s Ä3ø ~Dü0õшûäá”pî£}ßC¥mŠÍøž·šYâì54Öx08{JZehlh»«$öŠô±Îî¶¼ÍñJZuª‰·upÌÝögó]¶Üí·ŒìpFuÛøâi?øè«jA–,mËî7b>#VUvœ/±’/ÄGÔ6àÁ·À=!Ø#­Î{OLÇY¿‰qˆ¶àêØ#˜Þ¤j¦jáÂñT;,p‡æÿž9¤ÂnùVÕ}¡Ýµ¢à^Â,`íï!{ƪÛêiFñÙL/yQEYÀÚÚ¶LbX‡!û‹‹a›M=å/Y5U³E›Lãì5{»_t§ûsõ1qfÎài÷š\W ¸JÓ5B+î5 |D†o°ÐÎ~UÈç æôù@üÁ£ä…Þ¸Ò#r71ò ~§6ˆ›y6ül?&·¼òø5lHØ¿Î75òløØýH7Áòø5lLØ‹nkäØð°!;’ë‘vÌ7d¤ÍÕID)'#¨œ'Ph§Œ ¿!(AM‹rÆ8… ˆ…!( AQÀ“,’ïÊ™qVIØÈ"öùG‚4GÈCNÒˆ–hŒN!("Ä–ŒN!Q2£DÃQQ~‚šÝ|³bD1봜Ҕ,+ßCF–DM‘ÄEG+Qšé$d©ód â‚"… CM"¦3áµ¼&>My¢Ù12[•%+#¹HVÙ“=?"ŒÈ90¢Ö™3ó³ùäñ& –{ç?Í¢ÏiŒÖ쯹§ûÑ#š8$32‹ÎÛË#—¼páO2¬Ñ8E¸jÁÕ†Û ·Œ¹2ö¦!ðQpy£¼QÞÀox7L­Ù†îüÂSàáÕÆµ®d¥à9Ï<­~?ri¹‰5;®õb˜ê½›P6‹“¦Ûà‘‹vöMß.¢ly9F>Sÿo²ëToA´5´ÝñŒ€;…¾Æ¡½Å.y‚9â…µn7ò¯—¾A÷Ø'yÈÌ?¿;¿1›ñÉ>xÓ',àŽWú3ùÛÃ/Û/»µ™êÖ«ÍŽáîx¼špq¼/Ĩ!z’´yª,Ð…ÝÁÿÎEÌ×˸TN÷Ö0ÚÚ¼)*´—}˜qx7Ç”ÚÝÇøq†•úÛbÒÁpŒËsò–§f'•ñmJ­V`ÊÞÄkøª e«ðÀ?œß¨îZ£·/¼;»ñk]»Í_hús/ƒ^ß‚éf ;¹×ñ{úž•ı—ðýû³*»~õïþ˜Úšâš;éÙÛ µàáö¯nѧò‹†´ßzDó~‡ŒÂÓ£À!†S{ùù†È‘z2ÿ6Ñ ¯‡¡RH‚Ó)¡÷O‹þêÙÄÞL'1hãŸØ¿qÅ‚€¬ë˜lÑé:ŸåU9]|x†DhÚ±ù^ »ä¸ q& ×Än3¶ÕÁ‘ÛìôñÈv¥‰VÑŠ·ˆî´ùëäÁ¥Ÿw9Á‘_ïIDê?@ž»mƱ·µ—Ê|½œ3zY0ê Þ/¡ä{¸U‘ ¡ñÕëê\ì<]ÿ¬Ú™™‘7³(m"ÎÒV¢°jÚºkçz™†XK_ Å›’E¯8Lõ096§am¡1ÄP¬'“Ö;½¢Óˆ…&Ù˜0›9H9YXÛ2þâ5?¿¤F­d,¶2ªw9Ëm5‹ š +W&þçËŒUj¹ëÕ&eB{»0­ŸW.¬oU1 òU‡dÄ^›W£Läã±¢ }ö0èF=±¤ÛÎ Á•ÛpXR‡2L”~_É\Mz“\¬Øß–'vÖœP~!n©L¸]DÆâø4r'83íqlíèå.Ñó­{60YÇèœ@—8?ì#\lÑaj%Ï·ÌØéŸ†˜ ÜW£¨v[Ä^Ç•¤}øõñ…$ñfHÓ®\ö!,˜÷ŒSÎïðìt ¹ÓgS]Ê,x΃/À^ŽÞ|õ¤¬Ö4íÏ[AŒ£³é¤­»uXEœš`§*èé›7)·À÷Cx¥7+Ö­°{ º˜,Ò$B.å~\ê•> #Tð:n‹ùÒ1Hô€—v_¿Ð;­4~fʵ­•M®ÝêÄsǺ Û:ô¹ª×uý<¯&´ž®Ì;Q;(‹Þ4êÐpϡʗۃ®‡zP€—"¬*æ€ô¯Ü¤ /N©/h¨ÈZR2ìÄesÒ:uA Ây§tÔƒ°h|GêèŒó¹œ.ÓÏ}™\;ƒ£‡•ê:|Ûæ€NcNZv‹zZó8¹=I$”îJ†O3‡íD¢¡ÞPoÈdÔfZžû%‹/á´ÒPj ÕÈó€¬öò‰´ÐMÞP`êÍaÔøìBÎr+衉Þ¨0÷×õU>Œ~;;~P?´.«Ó`XÜ€ EBI}¢P‹™òSâ)³ëƒ`¦QgvÞj"âíw“¤G˜®y;ÓV£'tiÐu'óaÓÄaßiñ•9,_tz$¿w°dÔ½YÌÅè—@vPzÒêK¥¤þšLkŠÙÐçã6Kœk‡£ý‘â¥g«fÉëÖÝÝŽ>㽘ûh÷ÏfœØ$Ò-f„X5ö†¥_ j°o¤úKñn+T×ÅrÒ–Cy«uàŸžÈví¹««ž½jݪ]Êei*]ÙbìÝ`뢕?eÒßУ¦Ãƒ—3K°©¸æèC–õñ·ï›ÜGÕ$E’Bl–è"êÞ4:pCD¹½kÉdã‚Z¸÷ô_ž™æ&`‡œ¡òx•ê"Ûj;2’–¶Èé9•™¤™œëðæ£ð’}îYî©Õå¯Õ sƒP„–¸twòf˜šÄ:±{Àƒ}{ãÑAP,ÝŒw˜•Ÿ<è΋zèLwÒž?ŒšÇÚ3g¤kGïBQ\û]Úñ¼ïáÁÏè(ÛßR·ÏDD¡Ä t“‹Hs5¯y|Œý€Í_–éhÁÔ{Ǭeå&˜ø’26ÿÈa¯ò‡-|Hùoï6=KŽþøîs7´íÎú$XÈ5V]AZQáöa³ÕJ˜d…A¥ö‡˜š5(&HÏ+H°o&õæ”͵9´d’îœ!Ó}}Qœ‰ž‚½‹a‚jFUv£¥¯ìpîXE²HÇÞ»‡9\ëì‡õ”ÙSÔ(MÚ;W6Æ›{ˆÉOf‚ö·‰‹ÕMÑ,À¯×çûBåùÅV ƒÖ?O‡-8¡¿êP™Y´ Ý+ùWŸ×–¿d÷x¢)ÁÇàŠ˜.§Å°l«˜ÍêÎüüm×”5Ëɽ¶¬ÊQ{¼UmEôsí¬Kræ8–é¿ÊÈhM¢gݹ>RKü´ mé¡dauJÂáæ‹( "ÖôÊ/d‚‡Sd;¾È웫ö¶e1áa;„… —ðsáÝÞ_×|Š©{÷K¶ PQÚ9¬³Ø%ÎÁîXS„2Hde!ž›b ñ …îÜOeÍ(@µ¹'žjZ¸oWÓWïl5pG†b½Ì'öÑîn¬n±ªë^-ç3äS$ÒFkó> ö­ ™XïC°w¹ºlpˆßWô£ *è}ä¶ö±ß¢žX2øµûî|x)I[Æ$u:1Ö ôÔ⬎¾2îCÝdÃ_' Œ#c:¹ŸsÞZóÐDrxzËqœ†_H÷"ÇŽý›jŒS)A5JÝä` ÚáCƒí•È[S?´VFnx=×õôÙ"]>v¼ä fü׸ÁîÄpz]Š`÷ºi+„££²³£\¿øi(γço粆i.¦{³ß4;Ï+ÁßW¯§ÈBi»rª0tµU’Þî*~¬Lˆ5­¥îXC×ßO,679D5;g¥ˆ 9äÂ÷§Æ‘6­…µ—Øv Ñ)ë+Æ@ Œ£‡é’¬¯¥w¥íøÃêóG{Õ&Eø¯MurOu0 ÊlXjZPiŠýd_gý «mßõΉÄS:Ù¥²eÏ;Cø$˜"œIí’[iíIlil©n9o‚ʈ‰oŒVabŽâãÅ?Èd{„Ü=L–Øu§1fW”­W{ˆùl#.JA.#̧Ã×/ì÷Í£‰irOë* ¬ê˜uÙµøæÑʶðì4:+ÖRR…ÝÌ*xHA̹€1;•Ý«+=Û Â!.>”Çøç¸¾½'–æmõ$ŬxíùaÌÿ0ÅÐÈ"Ì„T ¶ û£O§+ÈPÃG × ¬áhû…0$`Í%ÀųfæqüS¤‹’ÅùQoЭCý@¶ÚˆKŽCžè  3C GFæÀWx€yp÷!˜f[«»'j']F údªÕ‚E?qݹÇáå±e€x°y ¤rýó„½ãǸùaKÉ“-ƒÄ…ÔXBªÙƒeéÓÃ|cÖq¶u;þfìa»a°ü]Q*2_€PqB1.Pš¶êPiç´¨Ýc™ø8ß°çfÀu$VÉ>V0å:s^yZûTËû=—0Yu\cmƒµBñÖˆÛv>ðƒkñ4u¡5íEÚË‘Âå¾<Ù0ʃ#[)ªgTÔ’èÜ…¶«„{ Ôš àÀ.e/9÷؆|Ávõ_µ8!ªY}ÅÑü; \bí‚*Ù0¨µ#Lïœ/{઒ýfÚD•…q µløäÀäKZãa­ƒÌR")øàÅe[’8[=~zaThB»ÒZ¤]à ¿Á0XEÀæJwþ3eW\”–ЕÈ*åo-`#(ª,Þæâ_;ÙÅ>c^úQUý*èéµÇ2X<_´‚&¹c™ŽØ¹¯týòF…47°ÕdYõ6Ä n̪±¿#Áà,mǘ´¢vÌzQHí[œ}p§Ól¼ÂÉ€5j%7àà‘Î4Xu‰ÍÅä„îe™?c…Ç´.èÊz1ÅôS“Þ¤F"ËŽÁ_(?ëãó à ‚âcF”râ!;—·:¤B+Nôà“£PŠ*Эø˜Ar³jìý€–¡{ŽÉpäs+0˜í£m_؆s ï@æ±'v+á*µM¦¦ZƒÐÓóeÖ5€N®0+ à×û¬Ûb  cŽ‚³À;°1¡T Yx™/d¹šPw,Ö¶]PÚÈõ]!€éŽ,€†YëHÆùtÂWÖ„ñDMP#5U¬‡»¶|_Ð‰Çø…¸M :‹ñs Ïüz§«$]_ý ‡áÅe\œ²^Y`–¸~E쯕¤Ñ {EõzŒHNLþßOÌÌ3mvgùÂSã9a£¢†È10œ—Æ£·G~q±Á’.´¤æ‡Y@ÌÍpNöž'Wz ãqÜ¢‚]n¼õ€1ãÄDÛë«ê¿‹X`#Õ˜šíË‚éQx<ñm”C·°¯ X€£¨Q9sA‡ Xa”͵­c¿Ýò ËD…­º}Ø,—ÃÓÐú60Øà-£É[^¹`¶ÕYΘ¤×£ù æÑ”ì>¶vƒ„¤“5XøØc/§É["›m7°îÀîrøp€^I.5ßîõ¸ÂŸÖ|SÚ’öAÃô­àaMΈÛ0`!°_3O»ô9Ÿ±Ý‚G ‚ Qëë‡ó—óÕú)ƒ¿:ù'«jGäTÞøïA£ºj'5 ü5><ÁˆTSWÆ»£Æ€²ýX¯Èé)õýiHk*€äZp'eMù–S¬‹3aø§'I [3 ^†uÁó:Lµ † ~¸2Ïÿž¥ãÚ;_„8jò ôÛànÞóØK“.xþn¡^Ï |¾²ÆƒÉé™óN´_ YoÞò ÁcÐv1Üoâ@oêòF•ÕÐý*ØTL(sFO5ûJø– &kŸP3ÊëRNý@×H¨b–ƒýúQˆ0e>JéDz3–˜Í‹Uð2chäu *ªƒe£mÀ2ÛN äóÌ9F!·f™HæŽ@>­õeÿK$ €XöÙ›yI 7qüým ùýÊ6!Ò7’t}jw .d½¼'pñQ£wô N%*S¨¢7X™–çf ÍŸb;×ïÒG=dpï"™6{C™QâiPTcz‘Š”`Á¦õ)˜•á›LeóÇ mµ ^YìÕ…Áb,×1³#†ç.c;õfÄ{>è ³¥ª€Ù½Òµ4'©[%ðõhóyª<VYöCÉ ‰gŠI5ãV-p~Œ  ÒÞ9ª°o«°î>¦¨O•é7Ü.ñãtæí/»!˜|™¯`Ü_2†HXÌ W'5Ôø1ÓýVòªÇ ÖŸ¶IñgÖ—|Ô:¯^眖,w‚w •4ŒDÓÏgT¸¤¾o1O 炞ž¼Ñ$„Z"•,ÁQCRê°–fÎÍs ©†båªøçBå•~Ö.<êôé¿Hú\Lùÿ4coÈûûŸùÀ 'ÅåÍÀŸ‰û£f@M~4¤ÃEÕDò¶TDÖèÿ"C„+˜B:'Üá‡;ÿp¬Ö]ÝòáŽ;Üp‡î¸ÃwÜáì?ÎÌd·³ÿ3gyÕ}¹á÷šÎéßÿ¯˜ïÕÊßÏŽÍTëAðfFÍdïVwå ²üò¬¹þ×êzÂSÏòQa7Û8›þü2V¿©ùú¹—Ç š•æùÊ´‡M—²ª!Jвb)²!)ÑåBP‘6›¤ulˆ µ¹P( "b-"–-”rn.b3ibª|f›PlJSB§È*ÕÔ„+ÆÿMŒQ …R©„Q55Cã{ÉKŸ5¶X(©Jg)Ÿ†(TÍ…RÆ u6¡ Rf'šP°DATÖ YØ(¥OXAn]"…ß­%¨ ðJ¢•¡„"#,ÜœQ(+?«õˆi_ØáªRSĦ®ëÆ ZT(Ê?­n©¨W©þ/36h=®MpÜ…ôFžÐI&³ކiˆ76š¾reê6ÅÝ0¹Œ%&—!Ä4Fï]¿u™OLf˜À$ŸÙe<1A1±386ñĆ”2à$%þŽ#Ș˜X)# ÒïoQ`˜iÊRÂoÉmà‰³ž&ôvMæ‘»‡ÿ2gõ#Ó{-'ÒØÒv;AI;Që¹½´ÈÚÖ&ùÒ l»›ëKÁ´¿¶ŸN§ðv¤šãoyšà[P'ˆ´Î[¿'È´ÕÜ¿'4Ú¸¡Oi¿¹€Mª=¸óM©iÌ]‚‘šÝÂ'$µºˆOj yM”«W±­ï½W‚Ä‹|TAä´?|ÕÈÜ'ÝjäîM„àÉð<¡›pD¡?ið„cå ¯©Yy¿‚È›7VÂL+BM’(“DI˜”J¢¤$Å%Q(&‰’1)”DII$ŠJ¢QL%bR(‰“’I”D¢˜$JŤQ&%’(<¡›¸DÁ¡ù©/â‰ÞÄSDç“Þç¿„'&…O Ç¿/ü+?¦ûØ}›÷ÞÈ„2’p5wSãXCc MöDônØ=ž›cw6°ØÐŒîòp߆dǸÛMîHÚW+ŸÑJlV±ÐHñ¶V‘>,Jñ[E‰Ã×á®]¬ÙXÒËÕHÉ“!þÞïÞð²^[ˆ¼¤=H"´Ó¼€?^ø¸×ù¯óæË–ðnÂi[›™rDMUìôêõôú»ÅO¼sEïnÑ;ù«ðíÝçå¢Pù*ë|ﺠ)¹)Ç»J }ᾟ0½´û ª¹çÞìRoÖß¾õÈR?WûÏA]§Aú·Þì°¦<¤0ºáŒ…kXÑ<†ƒˆ¡IWqú¡¶êGzêÖ˜Xa.\!C·¨9ŠŽ¼‘¬°6wæŒ8ž¸mVÐC§SÈ‘“»öÁ–XÓEçqb?áW¬X°W¢õ¬Ý{ÎKWqú ½›®?¦k$®ˆ§Ÿ{{bÔc…‘1ZQ`Œn¬À7¨îQW9Ô깩ÜÝÙ£äàSÀ«®×ªpv¬´;ŠËÞõ™¸¬?&ø®T««€€ºÔ??Jj<<]jCSYGM¹»ÜÓ Jë²¾í´;ßöb] 9-çÇoufERF@”Ó ›‘–#ü#m³–a~,?#Àl£5rÞ™Ú`Ýå€BcNñˆXÖÈÚé:3>r0æ¹]-¬ -9í2p‰H³»‡ZLž¾ÎaVâŽL°(­°õˆ–sk5_å'H¨t¶Óí)ûÔ>él`{…î@qmŽ’HQy¨i!ÿÁmó!êr¶ÍLip´0‡(˜¹Ò‰—Ìá¯Zé÷M ‚¬sæŽGödiƒ鬲ZÙ¯†{Ô"‰/s´¤wq(¾]°dø1¹`[P^ #©8Ö†…ϹŸ6.P2æaíà^ز“Ž ã1ld€Å-ª34ó\­°sDÊ~j ©£¸Î*eÏ¢diÙv¶‡ÅÙ…eˆÂï¨ ¡ý«8iI†*ÿúr]ãxv…·MËqÞõ„'þ§m)¿FÉ–vI 7þ<¶iMßw?ÌÛßfì¸åM;ÁÆ—ý΃ÚÐHaƒØå§<¹ŠÑ â„FÐQ#8Ë%%™Õ- –uÍa[š Zd³Ì¥©DÄ¿k*ÄW":à~NÛÝL—&ÀËTRÐó\ƒë $E$ûC_.:&Ä(3!þÃgcEq!1"YÚÂGQP  Ä䉹$ üãTKUõ!K’n.dp±Jyê²èBÖ—aK“R¹^îFV)­ÇËÁl¬f)0Iã•L–%Z™œÉ:Û»ÈágÉe)a¿bLjܤ1¿Ž[°×28._’¡'¡ÄRzYÛ…LÑN• ©ZÎ’æ–Ô)­wpÅ3©:­oœÒ™Õê”D¡¹/Ó¨\”Ã`‹Yçí?žË‹ó‘úNßU6p:t'Ét;и’GÄ5–®±®Xùí€L}é…o“'èµTÿ¦v™ÒS× 83/kmæ›,™ÄšÙ£6tQÔ9Š¸ë®‡›øþ€TÕʺ0Úþ¸®*矼{1vó5NRnã×¢ø3 %1ø-ïl·èñ^¤ùÕXT a¾:*T{d°S †÷Š’÷˜/³¼ÙO©û;Ôé]Á«Ó¶Î×nl-àŸÕFÔÛ ”ºá·Cǯ'R›ºëÝÝ »ƒ$Luòí’μM2䌕<ÁB›öùF`¦åyŠH!¡© BñÎHX[ GA¶ 1¤ ñŠlt@HÌ#Ɇiç8A¡3†îÑtr•¨Kš/ÿ=²Ü°)öX­Â°¿7LJAºp$ðo]–P…°£®ô^ÈUÁ– #Ô~;$b‚"­ãÀÒ¤ÌbbÙi"1’«Ÿ)µÚ3WóOܨ~ ¡*Ò{ùÚ<"ùéB_4I"Ø’˜a\=-uëzÀ~[¯ºGò<ƒ¡ºƒbàé0¥ÒšJgÝãÁÈG˜VWE¢Ìáù>ÐŽ„k•/[z1Ùà²PèÈ'슡¬´c¡×c¿±™—:ƒª’55w—€²+µLª]ŒÒy!úaýâ `ßù>X2/Õ¥xhmÞ¨:Ï\¯Íï‡úQ’4¨ÚKHBz"µ¯èz¼¶Íbk¡‘$ìxPTuŠ‚›´Ma·ï¿Åù“AP˜I 3.•mÚ ÙÍÇæ¼'9­êÐ*á(½Q•jíŽk>C‘Vc» Qì0³pÒÚˆS``­£K:"PáxóªØ6PlUe¤Oß³|"épªü•³d%|t¦bëí"fS‡òqýęڠùÚTá†ùùº_EA‘'p× íXo°I |†sÀØùCž5ŒFyÌd÷2’]ß?¹GY3ÏûïíuûA„’tõë2½=Á·©IZ2)+§g:óÔžVZ‡Z$'¾hðxËûÒ—0<¤t5ök€2:®ƒš8‡õI AÞO0[sd’vÓ|4èxðÈÝm9î-rKùðn/É)膥Wu¾³œü9vàƒÿGð¼D©Ñ-ü†@¸7í•Wj“yÌé‚rñÿäÍçÍŽ’ ‰ôSô´8†2 =sƒ"i¡²íä×"ÑB{ôŠ;“ËÈÀÜ(bÊÓ ž>+G>”¼u%f˜F¨B܈S„&H[•\MžºN¼3è>Iú|úQC#Ѱ5‚ªGºk²¶p~ Ÿœ{®Í+µ õð.Ð^˜MÌ,%#p7VŒQÍh–J|ÁyÁäõ&u„&¸¯îy7ϲ;²ò5=yâ LIœa¦^Ðúû=ds¶…(ëxÊÛ ,w\e}gÈxBQuu´Ö‚¸¸’>»ÿ=Ó!¹‹59ôi5u—„H`:bš#4³àíEõ%_ȹ…=ZäM=„ µ„•õƃÆÊP¦­áD ½+®¦¶Ó»HÜÍc WÇ&V2$¾É—?ŸË@ÛëÇ™ÓuE\Á/O0ºŽý:×¶jç7NïÕì4ªd3²Ú´`½Žœ†žs]Ö Æ¿ýo±^¸\ÊJW,7 VÂÎ:ÏÄÿ'H(Rƒ8~Ï÷PÎdì'”ŽÊ‡W­ëë#ËhfXfçffgØx«™U!û_üÙVeÕ>Š12ŒgNÅ/ãa³®BjÈ£dްߤâ¥ãjšsp¶ÇT9'i†Èؘ¯F˜¨@YêÁz”—°z¤PW=þj$Õ° ¬ø; ¸áæ£6ŒÏ5ÛÓÃö|˜r'z2/”‘ŽñôùBÖ⑲&4§pð¡}¯^::y>’÷á`ÏÛNÉÓÿqãñÍÑ'qyкè0äJèWû΋9¡cÝI‘M¿‡ßÂß´K_ÂÏã3ít2ua…ËÆæ²¥4óó "Ì‹_&¿à° JK¼Üm(Få<C›¥ßë®®2·AM‰˜ÙlƒG Z›ƒ_/pÇ ò¼.àÃξԴ,A¬ÒÃw´-ýœ C=…G˜1RqCåõHÖúü¿IY‰ ÃÉ€V?CqSyH_mª¤ÌmÓ°ôõz¡4ñ“ãŠVjJ:Cœ†u®æñB!dx-¹¬3ÑR#ÄzÍnáØÌ£¼àϲƅ`.†~¶ì';ËezdhãZM1¨ó1í¢(J<ùæ²¹cU÷&Ë¥rá|dsª×÷€î.ìƒ Û3FD܉úç'ÿ¹¢›c‘#w–¶È‚Q‰‰ó°±tܧúá@ôf}GØÌ•ñr¿’~Ä[Õ¨qƈ¶vqƒ›÷¡kp͘\.¿9@æ2äf ˜ªiÁ¨Ÿùßy,¥ìX¿³ÍÏÐö~Æ£D-öÀñ²/¢gkòóév^m´ËÌù¦ge ‚‰‚Š’ã©NA.ÌÁ+SbÈyN [‰ÓØÁœikqÝW(Á •?\?Òî¦$”æD^àÑ#ÍÇh`Üjì waÊ‚FoQÌOº&öyÀÄ[®èç¡:Î×?b§Dªr™%Ì@¾,£œ}\ªÅ«Ö>hN]6ü>l¾oYa<8><8,;\™ã8w9LÓ|œû ·;ɪ£>™[M*º*KsÓÊÊõ.þ²Îc}|[+Ž–g¼AÎ!‰¢×&ÿè òâ˜ÖÁÌÆ‰7Ì H²‹œ%ÌôF#‘¬¿*äMqCüujô¶*ü›×(§W “÷n$X!…`Ü¥­3˜M?5ùGþê­¼tB}Nh±¦ºý5ÛõíN÷U4Ýÿg>ƒo×Sõl¦âœºR–h„ûs ã{cµ¸3ê»› ៭¯|ý}ÿÅêQOý€x<‚ Œß÷ì*ÚQË8x¾Øñú½ëeÚ³ú  ß/÷g6b?ãÔûSÕ¶Ô…²Ã`Àé|’y>…ܤçkuqVmn$_ Ƚî©É›c pdÆÞ&áqRí:`It ²m“Y‚SÚðMr××ü€…Öˆƒ¦Mözžbëõ@4Cb¯—@¶É’ûq·ÄÍÍŠÌJWœyÃPg¨LÛ©QxTâV¦Œy)ÙÙÖv§¬ŒócN1ñT°® ÆF{çør·k†ÿAMÁ׆q1‰Sy”»ïRxKÇœ©ùó?ùà3ïÖ¼æµaPÝŸ3Ï90(£ÄeF+Oe];Ûèô‘aî¼u€!I)Èw•OHx‰ %Vüö"†™Ý}‚÷v;p@c~øÌᣅtÔ’ËäöÁTÅ\(Òô².W8«®µ84à‚Ë|òÐGЏeFIÍZDè­17fJ0ãòÓ.?#!™+Mµ¬š¾{_NH‰•è(LQÿòؤŸŠLM·ã‡EÒÝ ïù¹úÇ?Œ™¶wë§ü¢ÜùÌØ}Õù #ºýÿ—ypô|Ó5£¨z˜,5ýz0B ð`uŠÍUDHošMÈ»¹É1…¤¶²?Ý|8šJ0Û:ÙnAMÚ¦oá "ôzr;U·ÙÙàÆÂÇÚI®yÙ:³­‰[B ·éÓèàªÝø–«SRÞélÞìñ£)I`Vø{ýP­×Úhf„’Á9‚·#WMQHälÊC¬üîŒ,õ½Ú‹®“5ÿ¯Ìy΋c6êÙaÑÐJ²ÀYìé•©æ>JÞM 5~Úë–?×Ùm©QA¬Û;y¨*·´xý•pê—äÔhÝÖæñCÊßû]Ä«« ÖÒ’m¹©Ï­mG©Ç5´s‡ZvÈÞû£†®.U¬HJYðŽNøb_ÓˆÜ!ó/”X¼-/.·-œp–qÛÔ4õYè‚6oÞÒ¥‹&‘xú?=Eššny¹œŠf·Ã!LÙ jp©‡7Rsù( Tè#м\¾õ# xÉÕ Éó‚bÇVešèz7Åð§WÄþ—Ö½«èö}ª"¦Qô ÍG† ¨[ØI¤âUŒ2Ñ ˆµöÌÔß &&é wè ÕpíC3¯ö©& ¬Ê‰a~òþU;L㉎ÉÂb‹€è‘’?<—VL ÝéÀe^ô~¥ú •×'AK •‰-T:TD<ÚEsØ=B¸rxÁ!§å3„#ÑÄeÛjÁ7³¥yiü h%mØ ¯A“2_W¬™О@Ö­°jŒvšSFM°HUœ–—ŸnñÐÄ,Uã<æm—¢ý5 ‹EïŽàbè +J ´Ê[ÌãŠkÃÞR B°Hë˜ÒCTªHإϜ˜0·ƒˆ9ŒµuTúËøÙ&£[+Ûf»'?šJìêÅ{ Ç(Òþä¹éηy”LƒHZ—QuìÔCœaS9—R€ PäºÑo ˆª«Çpt¹]0n¥UOk‰|=r0VdMÏ1ºð3´`œÞ¹—/@P=Í'âÉÞKZð7J+ÿ23>5ä”V*’.ÌÏo'‘Å,záì¨T1‘ ’çñ_‰ jbCjž£<ïZ`å:2ëx»ŠA‹yE¬¸²|OÀ,ª‡Fë¶G‹ÿýó}4®Ÿ±k¥ó›èª¬°°_¸`:ã:CÜytò(‹/Ê:³F3õßÝû33vD×Mˆà¦à>°”ð­Uý?FcN`ú”êpù'i€# Ü í4|¡ï#¯kß{w$Ì,nŽcmß=+ý c?.é0Jßý^÷Ê¿XÄø·Öñz喝'ó|¹KçðÖ†§ýÎ+šGî›Ã²õB×áxÀm©ð“áü—ãæIœ~Èg׸í÷ên¹³‰Ñý~ þü+Ášø’þÃó?õ+F©ö8çæ„_x‘ˉ%=ȱ U,n·Ÿ—èÖsìV™%!WaFôÊKµRbÕo֤Ȍm“Ÿ‘0†Îó¯þâ‘ë¹=å°L¨xiÛ42r/™K“/T¸ë)Î@ô["ŒJ='¯£]ô×%Å¢â‡D•à篱‡=œ%RÏ”ksuõ÷™R;ãbFÝfÙ,ÎÛ…¦ðŽ[¬¿‡g„&üRÏ‘æ­ø päJûú“³²éb†ú£ŒøÝ.¿MÓ+ å‘3W x”šýP7±) AÓAC_’ºY$xç¶Ú® qç¨OT>Ëÿ†ÙØ ¹£%Z¿IoR q‡â—5+,4§”~H2´b0qI*bG —W%î b$: gK”¬{8ÙsFö¿™åŒ'•2ûS39d5ó?Y˜+ û'í-˜(½Ã,dpôÕцý!ò¬¡L™þxݹò8ÏW¤iÕ2’ØÊtµý'-_jŠmó§y‘äí 24wÛ‚ËwDÅŸ¬r+¾¡²ÔWÏYwÐ]ªÙÂÖ±+£Y6[ gô©ÁÜë–‡ås]¿Š:„q­ 0Åu‡=ôËû8OPÜàDvÅ&Âÿ›ÖÔ4í[¿Î0¦ù2ýësAA/—JL][ Ü°l`BØe¯æz€„ÐHcDƒk Ù§y½÷»g0QÆHèéÆÑÁGÁÇŠtrÑÔëöÅÓ€ÛamAÜ ïU&XzBçZjÊ.ëk@€˜‡\…<Æb®ˆÿ+fš¨ýÐO¯9†ÎîSùBÀFøÀz ظ‰Æ  P™ÒÑ`™w"x\£‘ý«ågÌóÂv@Ÿ•h¦WL  ×Nä{T­PóÎjT…µª¤*<…v÷ tšª\ é ]Îa;TžÊ³˜ÀN»´fmõü+_uw7BÑ Å¤ãÉ”«è:;tô­…}áxr虄ƒXñ‹y¹`Å-³ó\©Z®¶í4Á˜~ ÖgL3¶®-Û^äÜÌO¢.Y±í×ßsòP÷ŅЦ=^ûÍ’ì ’åßIÓÔN†ð8¾`ûü'—ÜNJ³M0²_ Ø¤¶ƒYrAÁ‹s'ª&1Ó4úÂ&î„*uõõKÛ¶= ÔIÜL»>“B‚¡ü'“¡Ò¨NBÉbçØ˜lm{ÖcMÌì«ÓiLÈžôÊ$˜ cðŸ²)­mów¸Àå„Ûð“4ò­¾8.‚„Œ=‹¬W°lPIt¤“zËÀÝ'à3vÏ™Â]É@mVðZ<)÷DÏP¸«‹J¦r•„1öÙ³¥ÎÚ¨x}y:_=]h!_ìÞhÿZ…§&¢‰V‹˜ýÃwÚÂwøSu†˜-~Ú’ÇÆBïäMç¢hVîØZ¿˜; >4‹]¹ }6jب®žéÁF×Å´‘¯³‘ÚÛAüfðmè©0ˆn² PÏ q¿{¡v„t"ìmz.Ý~dz“ OÚ^PºÈJ‘çUܦGü%•F²‹SOO¶LF…4bÖÉèæ›'â%%ÑOF+g}òcNó°ûWÊh¶¸"Î0g£lD…sGÑ(vº·‡x'´+øX6ħmq76íY 1O@¤ qº`Ì)O¡-þÆÅg#–4¶×ÏÌ›þë m¯ ç“ùV cë­êýz–ÛµîÐ&õ Ç,€d[Ý´ºýõ…ª÷28©®UÆÖ{‚°a<1µU‚ÖZsw©6‰Iòì6•O«Ðø=’Šàn©±’ž Çe<]\÷SÑ™BÐ%¹£,Õ ®±ß¢?óz&|ãiû¯²SJ_Üû„¼ë\Í¿âñ‚. Žà$g¥ˆÜÞ÷ ³€ß¤˜6ÑŸ$|O9[1ú˜¶/Íjvu¢HúüÊévÍ¢Ý(ŸÙø}/2AO$휇–ìüÔ,‰Mu6¶%ù EÄ=SžÚb Ý[šÜËR¥“72Ñçÿ†÷©H}¬­3“s±B­dž¾ÿ wŒÉ‘ÙÂóÛPEOÔ*)™hÙ@ªïx (ä=€·ã“• ó Ò$(S!g¬<ú\)tCŒ±å;æ |&)îœÓ+ódœûÞ™¿ûQ}élnB%EKþäi ˆ*"›Â>\*âr'ùN¡Ü¯Å’$Aq5 ‘_ôÿ¡ Å›ïûðÌ,¸½€Õ'6©™>ŽþÄrŠ)è©XÕ+í)ž¼Ð$«ojúX>uÆÒðÇ‘7›± IÞË©ÆÏ’²”x-èÆ¡K§R·—™¢|½(ÝðJ£Õ®Ýj©œÊf´xkëí&¶³„/ý¡t4Ò®st¼âÔøõ1q¡u±Š$Ÿÿ½œ&Ùàáp¿ 3èâ¦'-tìË•f.æ—~˜¸IJ Gs/35×¢“éaÉ&lI¾ksYµ…ü=,è]Ê[bæ€iqWÿ¬i(M÷KH1“3nð°9’=´Ù× ô†*«­A¾ü¾mö³ðy1…{7˜„FœøO*i&Žßä)ß®,gŸ;ö¼ì÷¨ìlÆ‘Q.¢»¦u’óíT9¢Ë”̓èum×}ÁÈrÐôÍI¹hL)Cu‚Ÿ~4æ¼yàT½Z•MF"*&Ú“Ó>1s­ åÿÜŠŽ¯÷OU4bL†}êéh­Pê¨è*Êj—TÕ²3æï«U»‘M$%팤ܖ£gtçS6uQ®µZ`Xë?š4ð%ž¤]•§žKÌï’1¯Ëÿzz€´¿TNøÓLg»^@Ü[á–†òuÖÜrWÀASh깿—¢c‘ÏE:¼3ZPÜBþ²ê%Íë Ö–MèÓž®³TÒ¼Þsâ¹3j"?³¥Ø@Õh= [¦F-0XÛ‚íÒš¼;…töLä3ÒQªúꚊh'$)òŒË‘·ÿ6´e±—–c>£9‡Ié¾ZîÌæçÚmU‰ýFœ>5©û±t… ÚÄͤë0¢¦ÈçžkO‹öÞ_ЙTìÒhš}²Ï¡ÿ¤’)7ÐÉæ.…“z-òÕŸñDSìsçÂKGµJàLß(qC¨Åþäºö¦)꘢åØë™ÆÆ0&®UqR þ2ý‹»úd¶m̉ô”²rC¨‘¬š´’*¸ÑGdðÜ)ù)Sh]T [üϾJÙã‘DÍ{ù_ÉÂU›,_µྚ]Š“’•ŠÆ‡_©éq?_»¥}dõ®…n[­·Ž/§ÅLy¼¿<§Æ‹›ÏúüwaŸOWöÝ2MVÛ¤æ“&¦fnit#UòtK‡´°Lõ»ê#Ín-I÷‚‚²ø8#ï~òÙ,F§ $¥·Îäz´ÊŸ”Hák]¢·Oм8iŸÒìÙ&Ãö…«ô4ÅÚ-yˆ½»½›ÆhÔ?ÐúGí•zÚÏg|„KÙÙ‘å‡ÎVŠÑë<âf­†ã×Ójó(t}5Ÿ`_Â$ÈÛdšÔmòÓÎÀÀyh=Q€{h³²«¢‹Ýèœ@Gª’ô“×YÒØèúÊÞ~ÝÄZÿéÿQ%k£^†xÕ®O•:ªÕ11À_æS'¸Þí¯6Û_ëå;Ýó¤ïÏÝãë@dzŒB±Ê¥9}.Ú‘v+­È׿qÔ³‰t_¬jw©ìÐ?íJOÄÒŸµ§í¡+Ïá+lׄ§&\Σ*¼¯¬¿S øƒL—§R¢¼…‘~Ë ×ÒŒ÷a¶Ñ€Ê4ÿ¡¿)œo›æ&yƒã¥_’Óè’ZÂ@í9¨çÅ÷¶Y[µö¦‚*jèÉü6lø—ʦ°áx•€ØéhëKÑËll‹24cãã?VfÒéõ›ÉéHþù&Æ# £NÛ?¡é’'cür*:U›~†æÒnJMR¡FÅ„b«ûù,í†bLôiFÎ)ÝÛU£‘@mÚÓSODfB•?âÃG“'K'’mˆ=%$›ùN§M n.ͺÇ;*Ôyâ©•å(±#5!kÏ—ô•H¹nH­xÞoƒ“<½C¾Ó|œhòÇÑÑÈà»”?›üS׈¾ZRf>¤J”5=ùv?ý*"y|«Aì}€E«k OÞ±fñöôÐY$@ˆ,¤méE·°¶¶Pî3=Z Šb¼­Ç¸Í\EÏRÃë^ =O3&53IDÇØ g%·Ês*Ã~²®€ ;®Ø8“°ÁÞg õ  KŒ .“qfÀ Ë–V°«K…#“zn“Î1ÿ¤§_­? “Äuüc$f»iéÝo3NøyZޝ¦oÐðMÉ’€ÿB9Ì#æv@â`8^Ƭ¨6Òó/7·ÅõîðçXP-ŽÕôÕ£D+é¨q°ÞÂ7Ò6]=o˜Ã zªàØ-6+rö$x¦=XË'¡Äëxx,9²uþ’03Ár-æ`s%C›iKlÄ’{ˆKªãW9Ì£ÊݼP>â+D £w)ó\Ϻ·‹Ö!ÂÁ›Ïû´;0³Qý¥L‚ ÛW>è¸æ]jZVp;N³‡ÐÌÙÜF¡Ë­àtíwÔ‰YV‚gÐý! wˆë¥=!à†½ÖyÚyÀ H(#"'…¸œ7&;Àx[vÆ ö29=êñÖ¶­a;ÈÉú—p49orTñ}n8HÈ`»vØ«šßÚOT÷Îû 5]^½ù×Muï2€ÿ#´ÑÌN—ŽÑù•72}jçÌôzÚ¶:›ðÉÎËV­Âà¾Æ®¢šÍ‚D¡ÉKÊwÑæh3û¿§þ{¸‰'ð9±†¬ˆ ¤hŽ{ðn_‘™¹ i•eû®ª¡ß·p¨åpœnO<µ8 8'Æ3¢û94œY椱KzCgHð.äŸLú€ ^ŒR­cëåÕ_Çó&0ý„ÐØ¾õ¦[89Ÿ,<ÿÄ~ —‚Ô'ý°­ÿÚåAÒ˜µ+´ ÜeI¹0ͨf+„Nㆸ‚¬…A}4ÐãÄ: ¨¡“ôØpÿê¸Ñx' œ&,5ZóÆ+fIèé3•ßx(Y$ŽYÝ[‘¬ ßcFO2ëõØMk§ý½Ü¾ŒlO't™µýÐVtçæ­ƒbͺËÀÒ\M¬ièÜ›ÿÌU“™Ù®z¦µ—lmˆðÖlt;D1[Í^6/k\¿_³Ñz42Þ~Ýs)K?´††v¯û&dÖ>*u­¿\òjø3¦# écdWï¬r,:3q†è¯–úÍ‹®y[¸‘j =1aLµFšF§‰Ðd¾r]›FÛ0'cgZ;á çà!òÙÁÇUAÙPŠ•'J6Cd[#»²a^첩ÑŸ˜ùI÷û2`«~Q4n öÌÕ-œa+7‚ï~xé8›úÍÑ@AF\ºJótC†q”wjpqÁ|ú¬Ç7àè¬Sf¨/B±#Ó{2§gG9ÁÑGÐëñ„14ÇÓJÔß O#T_X¿‡>¾y=x%«jkŒjU í2qt&¯^ˆ…|/ZwÂkþ¤÷ê` ¸Ö]Þ½SÎ]Å™>QI°ñ¹.GQ {Öh‡ãŽoÕÉu5$7¾€ñ¸} [õ:ò¹Ðk“`\Ùt–µk&jò(ŠE œáëV#‰ÊR å)Œp‰[ôY…yj{.ÓµYúc9û5Ù^†Ã¯¾-òž±íawQÙ`ê^ú¬ÿ0lÐú™"€¼Âé1wo™¥hf¢à”‚¸†^ šìcÂË|’•…yÕ%ʹܯAðùêžž(CäS˜´¼VÕ£*3޳FŒËtSD ª(º€;›gŠ/´Ú€|ÚÚÝм¢ôFüW±#v(F¼ëƒ4ÄâD~ݜ۩"™æáU"W„»‘XiÀDýóáúx‰MȪÈO‹ƒ|¢O†z´^V9ð^:dwb³®´ºˆ÷Õ‚LXLfµË‡3çlš„Ö œ Ç¥ßÄh2xb׊œpÌ=¸À™WÎûearPéSÆpör¬|¦©_‰h椇C~ºÀ£ÇšÐÀžÕÆÎu0,©ÃÏÂOk·Ê‡êG÷¹[/÷‰ÄFEUn ¦¥ÎÖ™ó¸~îO2C= ñÉX#Ái5$XâÂTH„•ïN[šµ³`®¶ ¦(gSôå+ŲõúçÙ ¨,Ý ll¾õ¼ñ·X¿Ê­~lÝ'í\$@1¼àã1ºÜ{ð’­˜%n.ce̯èhÞ{”ßõ»·eUNP´è臱ÙTšò{4GfQ–løJx‰bŒ—*Æò ´¯!l]:yÔ®&Š+Òkªð¬ñOÞUUÜáe zýjᅵ’Ë#j©x¶2 kIlý…Iº‚Wt`øfAM|QÐà¦ÍÏmþ„}ƒÂ¢~ÚÞ€—;T¾•;ð¥“lŠ¿]„ºYüë¶} PQœõ’€lðM|©ê²OëÏ=ÃÌK¸ñŽ‹õûí´ˆM-[5ˆ*@æ ¢wv"‰ž¤Í{TBÒè’îSYDl«BJ‰Ñb¬ãu°ã@éÞv|VÂ" —±raî2[VÐ*‚£,ÔÕYBa_U,âmƒ16ir•w»nTÚlˆÉóK%f6l^jêÿ%¤Ûõg}f+ÔÒˆ³>48wÀÏ_Pm 5뛺Sô–«Dås*Q¸Z™[û=žžæ x×g,y5½»äÆv:¿SdBV‘þ›¢’¼o‚q³ OøèŽßüàÈ}Ö”´`R×QŠ(nJ+l`ăÅź{L ’cE¹ßx<Ìoôû{¥‰ ^ò„ !OÈ%8Å?þS¹òÌg&"¥ãð'Òõ^¶h+ñ3èõ©>³\pÀÜuc4ºeD×QßBÀšQz~·<æq‹>æ=—b’ôÖ7­#6s§§è Kdm<ÑiŒª{q¤X뤦Z¢ æ^¦b1² ¦œˆÃE(N G€;Ò{šôÇ—‹fN)‡(Äy388 ‘xlÞõŸ¡`y²ªežÕÍÈnQzÚ-U$rDÉ¢L8rHš)~Ä'õ?{÷ߣë€% c1qI÷Ò•C ].ˆÐ5 *ã÷s/Þ6HÉÐ ½É„€ofÖƒ\Ù«Uš¼f©1ë#=ZÀðOH‹Sú»ÀVYËg‚·Ê·€W¹¼­o|Iü ðvÅw÷'5#ôƒ+”ã±áx^‹gs+ÁqŠíòY%ÝóÊÞ%²À2­2ð™[YÖ mê½aÙzSï3SWÞØëô¦\ Ö‰íÁ’Æ;Á¢gz)'«&wÙ€qÀDô} ¿OòTpŽAFG8XÆNÊeELy©h5EzÄÈCDFü{¹ÿ.ر’Ž—J4 àu -È;wæDè(X¹ g-FCý=M áw¸i»•"Œ/‹®—äß FÃLsÔÒç&{òè™åÔ—„ëø³£ú»CNTì^¯îIïÁ <=M9W!¸ ¹¬¿&#Ž–~ÖÞ´OGZÂU1ì¡awbó‚—ÿ/Ül¹MÖÖÜÔbSØ(v&|ïÑ_ÊI÷Öoµ5‰Ú¾Âö¯"à~¿Ù^œ^H¦¦`„¥\'Ÿ9BèióóÀÒ%Ú}¥9C²ŒF·Ïa>\%ƒÁ"Öp¬Œ¬~JÏÝ^!j}hèÿøÏ~½{˜ÃûÁ_üß:¤4„²•ÖÝ_ 4ÐâûÚ1íJuÚ‹|¹ÿ\ÿQ [šTûQäVÿ uû€Hk›ís]¨(Ñ“2WrÈ%óa3åÁ âÛ:ìUži~CÙbˆWQUP¤õ)bJ”»®÷ß—©‰‚ úØpª¤Ã¢¡,µ+¨Õ(ÉsÄOí@8KŒOˆH*ã[åDk…÷Êež¬3Ó¬û¡Ž—¹ÏB[°+%°ÇÃUÚfΊN‚îÌø¦µ¶Ùç`]@51ø/GÑE²ñ>Ûwr._U#ö¼ÙAö#ùØ òŒõ§mñý5Ì«9cèöPâP,l¾8Gã%,›£jmKa†•wV¸ËIâñfAÄ«à¼8ƒ ‡}d-ç€÷Í—ÓsRÿq£Ò£4°< _vÉkGPž£2N“Ë>m‡s·ž¥àãcð<–¤ÂÄ1/s£º/qTÓéétç€$ë­pØ¥ãйf-ÇÖ4UúÖhÆ¥Kü¼z· ôE“%iþFÿ´šª"ç P-Î*甑åç<HW­ˆáiç¼´­~klZ–äv^y¦óXBupRGì7§‹§d%c¯3>p0ÌóæZëÎÓÊØ>\œÒàÚ=ÕŠjøÎÉ¥°1Ÿ, <ªÖ ›þ×ÎÅcïÅáܤ÷¡Z½!|:ûØ`Ý$²¸6!×Dv1Ú±ä"Ö±ò ¦äIûäF²@Úlã«r]™|U!ŽBE¹WJj–O2€¡*mUl5[-“–Ê~9ƒš"Ðjòè©Ö«‹úÄk8!µ~¯dny÷Ó-2(à)a æáF¸$Ì®žs!˜Òf2Š$ë¶<ÍI²˜•9c‚TÖ4G9 ç„ù ÌåP#/ h _&$¶Èf`ó@ ‘õf/’‘B\/~ŒdoCÝnHŸß(Ž*’ ª)U–,^AØh!L72€n»†¡B þ!f$ºì ݰ{XZxÒ5øý*3uƒ-„ºpsÁœÈ¥ ôê„“äÇ>?¹î([ðw¥‘–ßÉû¹ŠWÔD;öèÙž4ñ,Nþi]¥Ì¥Áhœ†õéÚQà$×<ºù™G¡À¸¦ûªË±ÇIœ‹»LW \DŽ=h°žYñK| ¹ü ŠU¨–©=ÁнÆ+…B[´XÖ2Ðõ¬9ôþE«Ÿ›q™"0ðÐÕ*½<‘V~qm†‚5%!ÂO+hûŠU õpn½<~H5›Ç'ñø› Õ šÉÎ?=—0VÝ·öT„ùhÇWX5˜.ü›†Ç”*G`õ°bŒçÎéÝòý5k¨J¦íBú×¼ £¶›kh/!L¶»‰ï@e•0½§{„SsÚkjæ%·åò%C6­E'ŸÕæÇòóBëÎàý¨ïœ!öEQéþÇæfgĶ$Û½™•† L¤š; ]¶ÃÑñΊá%'£S唋÷°Ó¥“³~lãîØ‚%“tšCL3Mì‡ï(™ä–-œÒ Ý&³Ûo­êC‘Ü/ÃÙúXò¦ÄO§†%´Øm’ žtz]ˆfÂÒÂΙ7õ>m›v÷\O0ÖÔ¡®ýÍN;ø<®'—‘”^Öt£Z®!nЋ–å²&å´`—ïÏÐ#²e‡~†I•iFÍ",ö"bÕZìxµX·,}CÏL2Y«œl+ýÐ' ©ÿÓœ%eðr‹¡(Ñi¹Bç;H C…ÚrúEBㄌبrÞuþ"÷ɨ}²cÞ ÉÁùG@Â^ª"[g‰ÖíÌeÕÔIèÙIöÅ'Ø#$ÛWL÷±ˆbþâ¿ ”t‹|2j­iâÏÝt#”Ûêƒzq°+bwX~9:Ëþ„_k“ºdÓ*DG>åêBsÂA•ÈÄQ Bt3_[²eÿG²â·:ÁÄGRMQM¥¥d z=¸[­GòeéÞÃ4"Ì1>úS(@±'¡r%*Ó/nn¸‡‰ž,!ù- é˜ÿ0Eî±´ßmúsü ™5šÊöV’YòÐ`+h÷É«ióHéˆ׆È9…ȸìQ_Ç ÄóUôÕrÜlèf´B•=>ê~¸Çfõ\ƒ1&«ÄâäâšÝµ¢Yãך!Æ· ¹£Ö½1ϱ»6¥Í Œz!Ã…Ç3Ãô|`(®óh©kŠõùËÑb´-ÚèæÌØ®M~¬°ii›$ŽØìúetöÏkæI1¨Ô:­²,¤rp{[˜š¯¼¶.iË#8£aú ÕÚ#ô/ÞOõ*±£H´eç,yqqgk>w,õ,R§BØä¥#ãwÖÂiÄ_­b;›^—C„| Tb•¼‚¸aï~ïÝÞ.™ch‹ó"]ñr¬Ð­å3E E„tº£A½°0Iä|0&|yûÓïæJí(ض˜<‰Ø-ÚiNMÙb^·[þy„X®!PŸÒ”i}ŒžŠ(\)¼È7§PQ.ëðª üo‚4ÆŽÊ…‡'8 Eð½?x;ëʲA±ü˜^ŸôF¢¦aŠàáœ3›aÄ:Å$p¾à2ÜöѾÃYuAÕ×ï=è¶£Uì,Wùî'÷…»6Þfô¾Ú¶ðHM@–0Gm£®žb´"¶e]Âíc椫¶vliUjæê ¶È²\7}-<™‰ßUâ‹Ç@W=W#òU.]ÊÍéÓȱ¯£i[ܘþú6ÍÓ€úb3ª:ëb²MR@Ï 1Û”)ØÀ è‡Dw%?P¼“TgÒS 3é­Y˺ûºO+èæ837ªæäf5@É®&DñÚÅ}ÅÃ%ùF;÷š^¤”tyªêé\z©šRæ.izÚ—€KºÒ¦k)M·#9ð˜G­À¯o¨?—¼Wç.ZåÀ]ˆtðjŽ++è«>扪gÔž¨ªÊnÀ£ZŽÀ{]æ)êƒ5ó x]B­ùõÒÝ`¯5¿^˜°—Ÿ¡t¡•ÍØŸõ­¡ÏYÀë¸^Lµ¥^þßèoÚÅh¨åð™1d=¦)V#Û‰~iyò-‡ÊƶNñxë†Õ¢rsÇO†± t£,é+ƒóÇ%ä¡í©Ùÿ}jn!LÄNuBM ßu+–ÁÀ–\Xì”*/ïWú•JÍèáÞÉ€s¯ŽùØ/JƒŸŸØË,^Åü®®B°VŽM‰“BŒnO†MEw^ºv0™Ÿ $ñšC•¹|õ7™GLÀ*Q¾³m%Â¾Þø“ÉÕÜË`M„ˆ¯;ü(n棻Ìo~Ýl®¹–Æ”‡EŠÊâó…bÓÒ:Šü\µ‹*3GøëWlê6ÑîÍ÷ýuX€¿vd[(øØïª0uã|Ø÷IGâ Ÿ«ªsþÍëµþc¹G“éKoËÏ^>8¦éž²Ã- }°4•Ýžëœø‰R_&€[ r¿ø›O@'«âļLªEsŠÞbÝ@d׃òêc“ 7V'Ä…l§MÁ—«Î¬¿`ù´BôôMË ²ž•_q¨¾TÛTôÉ[»ãûtíâ@kœ§ñĪk“˜Ý4Z4æ³èR`]?.¸À ¡6z¹]Å‘£Çs?'¬3â<™ÙÐ~w½ê]ø›äñ®&ÿƒÚåob†ç¸^[ Lj޽ì…viu,mAùÿ¾Å«.kO ]Á'|:Ã"À|mÅüOÃ]HÖàÇÄ;ÕÒ€¸/Þ,‚7ûIÏõãuÊQÓE@KáJ‰Ø-E€SC¶›G÷K1.!þ]ç?è.§3Iôôà9šãPÏ-6uW‡‰fphô‡9·º5 “·I¶‹¼ØÏ/5å&œöÌØ½Na‹u-™œ0ÅÆ4…¾'Ä„Æ+]þ”…Ö,zuç 5á»Ün½ía3vU ©ìVÞþ°Ô…It±÷ ÄM*£'ð—Y]’„¶ˆï¡§R¾è†8ey1‚ B“lâÊÒeAr`D}D^œ“†àTðRE hí—ràP† æ>EÛ¦A~p¶¢±·¯3i2pDÏ£b¢ñ%z†b¥ó5F™õŒFx¶æ®œAÁú?± S*ÕÄGïìVŒì°©&Û¥àBrªjJ‚bØ}Uš¼xÄŽõºÞœ®ø—ÍÕØ…±/9ñW?ÿIëÈGÃàéL‘1ÏšsÒ]dU사üÿ ¦¸•g†Oµ²&ôñÇmÛTÀ:í³°ï’ÖûôÛgÛÄÑ^íµ–˜€) oåV]VCÔkþÆòæpjêí|Óo{Tµ&¾ÙO¤÷¯?g“~+WqI¿“j’ŒeØ6zÀ»I¬H\é´/J6Û(|‡—I*† 8Ú*оõ禌É)‘ÎõpÔUÒ6.\ËEí2¢ 5=$-TRrõ–§ É·€'ÙŒ—«|hkFÊWE&MéôÍcZú?j!¯ıQ 4Lÿ¬ÒŠ%¿Æ&]Ûô‹o…å~ª¤~ªýùvó9 ÚÄ?P!cüЄ†ŠzYìÞÖ‹Š¡$˜ª·è^q#.Òí•ä@ÝÔ3è OtIH§ò+Jœ‡¶À"6qø³Sµ´§$¹!i·JvùOzûYt½ÎŽÚŸŠMËŸŸ.’~^¨g“ÜR{{›x´›ÞC-…x*¿3Çöí¸–ÙîÙàŸô-ÙövVClªï¨Þ€s¤\ ·aO>¾­‹‰±;µŠÀÅ4x3è ân«?¾ô®$®ÿ++RóêTöUÆuÖc¸ê¶ŒmÇBøÇ/qsÑËÓÈ´:ãº(ž°–H·cüNë¬sê½]Wð^åù½nœ„£=ôÒ£“bó¿ƒä!±¹>C¼ÌÜŽ.÷ÿF©Þ±Àޤ®ÕÚbï^hJ:m£µám.ñ÷™<™”ÿßüÌo¯ ¬p¨w†ù‰§ôö'‹Ç®}+¶µzã{®éLXw†0õÔBVf¹”þªÙn¿)6ÉÕxB.¨ÁñW£HÉÑ»KÎQœç£FÛ~¤oÀüı¢&¢Cñ´ä;égm Û½×é⿤áIë ²žìý¥F[¾Í3™ªn^¾M‰úgâ䪤B?ÌLߘ4ÊtÍj˜¦ï’&â÷[xÞ¨z/ÿ„·-lÂ"~‘M‹¥Ü_¯Å!ü±ŒJɤs/Ö¿Åßü»»¡ôÎ@êêò}îë½é[çÉ Ô.wKw‚ÌÃwPÎÛ@ç q°t5!pÿoï}f{æÙoøÐ£Rã² A»Ã~&|`L-ý½›½ÛÓóÞÛÛÕ1§wå'“ûÊ;wÑ­ºÔÑIïV¬Ò¹²· ÓE£%!!K[YC34#fPý OÛZ¯nkÐM6M4Ѐ„Dq᩾V¶ Ò: ëu/· ×¶i!±ÒÛ%¤îÚ&ÊŽ¶¶jdR…NTA§2F£¦øJ‰T“øG‚P¦Iö›#4"D×SÅ0ÀEçÆØÇËh›i÷’ä´Þ¼ryËï?¥ÎXÆRà:Þ˜ä(fåòJV 5@L#¹{§bšB/uÁcJ Ù´Ð4YY³ÆR—Îd4œ!7¥äêâá”Îe.! Äw!Š"i•q8ß6gŒð#Çü$ÄXØP¦X«ôþ8e ¾…é%éVÉO?+]Øø%!%…lp!T£æ/1 -˜ö Ýû“±R›B#PÊ$ÊoßáíÞh†/!xÌ›_Xß4ò²Q_ÆÒUÃébÊuGŽün‹åBÓBñŸª‰·€gÿb/Mï ý<ÂIÄtŽZ9O ×KÃKaryºGM: šÌtªÍN°“žÜc&4Å7ÒØ¼:T„•J©4'S¯=‹!ãf¦à¦¢ƒM “‘sïB¬ ÇX *¤T†Ò;5¹¨knLu£l:B%wCWJ6‚5RrÖ´ÏBãõC;”t 1 å zuäÌP#r‰Õæ$‰<¹€2d¡Évõç6.D!yqÑ”tÆ&¡žëpR ²Q‹I¦ÑGš¶ÿÊøRF"FÂBʖ؇2/¾šæPUP¹#­0Å®2‘12óXz²F\•ŠÑ,ná7ÄlÒx}ߞɄð©Þ!0—ä¹'n!ðF¸¥ª|¨ÈST›*I"0l>¡,APÅT‘ì Q‚·$}úÊßÒ…?d’åPSЃaâˆùAl‘Çn\*]²z,\;n¦&¹•è—£&þ ±F– ™œ\¥®o«åfœ7ÕÞåT ½ßá[âùèC¿Ë`”Þ§l»†©sVѰ~ÒŒñ¿ ¸Škë„2÷å.ðtó™XŽ‚ßhÎʘ—Ðó»…þZÁTLÂÇ3#~!ÀW“Tvd¯Š7Q£-¿FáMA”!Mh;9B’RæeM.$#%]yPÎyå¥7xQ… £¾EjJÞ§ˆ’p³B·H‹ê5”¾{”)–¨ 7qÚ׿QôO2U¯§:ô_÷ ŸJ!Üxäašôž„‰èíÉThPÐBáŸí fSÜHv8 ž×ñ½~jŸw**ã2oq Ó¿¢è›”»²qEš9-þþaáéÜ埚¹ S}›ï34)S­ÒwO—TP™£¦…{½øÅS)ɤ9™æd§z¶âMŠhM¤êûGOÑ!|¤Vƒʸü󯿓yÀd}–ãÎr>Ñs41ÒtHæé[_ Ò2þš‡˜©}/‰íbªn݉ÜÊ|ö«ÅKúçÃ"(ÃI³ + !ž¥ú5ºÓTº©gGµ%;“:ÕèYÇb³€ï®ð*ij€ÛÁ"ÃkpÜPÉÌ'`5†Íºñ‹IIÌÛ.ŠÐBZf±õñ–N;œØËG¿3þCœ ð¡\€Ò0G$ô›Ù‹ ·†¢ñŽJOé G^iÌÑçÔIîîIêàˆÞ•$ì#Xǧó>¬»CzÝ?”P¡´xR­’^žÕ 8“óçv¤"&Ù¥}*1 K?%d¢ƒÀ ¥'ÂÛxDl!…û\/ÜøÙÇñNßïžáéQ¹Ãå£Teô_[j~î'à=þ‹¶ÖäUüHFGæíœÎ[‹› ï@ò _®•I³áNÎóÅHŠ,qåÄïiNª¶½U+UòßøPáÈ2š“JdKšªŸ¬?è òÛÚ0#ÃÎüUÒX³O$ƒ!sù ¿KÆû¦,(:[“7~¬ˆ7‹ü ]stÐ ý R>7ÑÇ^}âôaz§G^Tc&‡ÂººX„N]?áMFñ­+ȪãX¡?ñYë²CýNm÷‘õ/J4·Œ¹V~Å¿„þnÞDZ-Ã^e#ôkËäªÂkw•A¶Ø4Ío¥¿Ø¾>`±…L/©hD(^oQÐxv¨b”g?™$s³‚Ì‹‘-'°šBy/ö )}zªdZ(“Æ4¨»`ž:ÿ¦`šƒÃ‚d8!aeï6q· O‚#¹ü åsÍ4%’HºÂ£<×Y$[Œ©ÎŒÂƳRüšº ™q…ÔãW³¿Lµ1…Ç“öÍè’À)‡]²Õgëô¼úvÔùšåøþ€·´o¹ð¯†w}ŽqÈ|¡és6¦ TBËAÅòÁ2–«'µõÍïç•å«UTˆtâ¦éþ‘Ü*ñÓŸLv“M2¸« >UÍñ޵WÕ4 êd±ç7ÈàÇmˤÆö×㑞¬È}íd"lîÖÖ ?j1{°ö7¦¥ÙÍ­!³¯-ô=]±ìY$"ö}í“Ånƒð.ÙäÆòÇdÎv7•3'Wا51:ƒ<aÔÔ/œ¦…g1Æ0Z¼þär8­ÇX¥®‹ Ö½{ØÅÂÝÿ×°‰î6þd¹1„Û°_X¬…ŒÀÓ«›>‡äÄíÑßót7ÅvvéèËÓ{³öf†ó º…Üæ.Ù_p+ÒP—ék®út(ÇÔçpqŒ]6¢Ñ¹ðIö7ö¦_ôæñ°];&@ßAÏ®ZÚ6±ìb<§£g ?*Ÿe$3êpª #4 …‚› ËR¬Â‚‹cßP’9LR© Ιp´Ù&hØÜÿŠ”BÇsöweöÞZŒq.nË~¤x iÂþ¥žT‘Ä ²ÃX)¦NC¾xÆýŸìBZ®¦ æÈ±µie$)‹VÜÜåqn<ŒÐ¨Ñ<’‹lƒ*AljÆ¿Þ3Ë.€`À0 À€¼¬Ô^ˆÑÍ) Pîüg»s5+)Å u²w6e7 ° €`À0 À€0` ùUT/‰xØÍ£PWö‰¬¶ü/GS¦¹Ip À€0` € Köº'|û“' ñ«Wc8\ËݱCƒIlë8à4 [»—ða‡}Áîòƒ ÅÕÎòÈ “ç1„OXæ&]qh•xH‹Yîþ ^ ðOf àÌwÅÌî¥á­W>Ç}™h·ÂíÖÝø‰ô² ¼# ßü ç«€/zPo8,í¤*ä¿\œÀð›’5¾×ñ;3%~š¿±/¢`Ó‚ƒ¥v‹ÏAP`ã¡€á8l>0.ìAÂŒW9 ËKÝ1_æ§&Àùo„ò@¡`ÿ≄ê@VK Uñ§×ö©^À‰žM>mèy)Ù;Vi78õ !ÞVøøÄÀ®½;L¶k^î^bt æ’7 †ÏMü˜Ep4Fœ²øÞ{† Ú^C9ÜE,¥ÍŽòègÇ‹íO&¸œ$|×ò žbŒß6`1ø†pÀŠf€[ÐpØZã¸4U¾ °ï &11V“ÿ eîp7€¶÷á' xNïC°Žnü—~òi;jù2“ã²;@~ÍŸéáˆ'€Þc‚N ®†w`4{mŽkÛÂã[ iþwO­° åõè~w@0Õq|C¢Þƒ¬ëâCñ€hHƒ¹«ü >_ôÁ=Ü (€,ש£ø˜o ÷A=}ð#*¤¹* —Óë| µä㌠߹†÷øŠŽP‡^UÀ¬ãz€©$îÂϤ®â‡ p¸–xHÕð(ð8zp,P¿9°(}Ü`â@¸ô°|3S5øü½1ßzF:/œˆÅ`¸ ðrúñ³àÀAq‚Ô¥…äÅšúŒtœý8½¯ø/Ôôùã¦ìNÚ)ŸK †žKA•ÊjŠA.0³ Xj?]y¦`@À€;õEMx>g4žeþü´øÑ=º]Bí%®™ÝH·ôѹ@±«£ã«©üàM{p‹ZXâ~v Ã|uÙÐé ÷wºÕ¨‡¢â ³çÀìf~öÈpfBñï5‚‡œo(x–Úg(xþ^(š)^dÀƒ{飹=ῪàÞÐéÒÁ ÓÂä#UK×Þ\ €à½WGò«0Õ·%|ÌóÍÜþckîÒb«×n¦²¿úç|UFMLRÅb„¤ü2B*C—Ì5·åmkxfª,*>S ñšç‰uAÖÖï¨j{ûŒ%×)¢ Û–Mõm}$|NB®žíå`„z®Ú$]n¿XÎ-sÀê 'ˆù`dî¿Js&˜bñá³f vôbô&çj•8Ó‚¼ÇïΜ@VíU¯_ÏG§Ì}È«¬Ïo`öLµUü±jVþ>%]}à÷^¤·š‹ÝW@ÁL=ñ,ŸOWÑñ¨É‹s «ùÇàøgK®„?š­ ó¸{+ïG¶C>¦rMøÖPßü·Ý*20´T¯¹¢¿É3ÃÚ™Vá‘©èâàŽ Wø¢Š+ê]ív«YµóhÚ®}æ*H¢í`Ôs°÷[žÀ‘Ø lmŽwt I0•ûÉÆ;mò´Ö˜M.#'¦O{NÃúS!*¸e5/gþp{j) È O,*â½+ç%þ¥B¶ùªôº K¶Øò§dU̦—â@㢵±«o½ù/ b¢Ô*r „ ØøŠE\½­hç’ÁL0“aÊù/»ËMrŸB¨ˆRøg±C_)ˆAðLKæÀib•¾œG£þ²ÈÏͨü°çØmUæå#ÈEÊñK`Rî kö¶MéèÝ­`ÕÈòš2ÿ=½:µbíÕÁäJ°Áä|j‰©°“áæqUjÐúr,ÖBÊ Ú©™„ˆ¬ÕÞòÐt@1ؤNÜôÓHô¹±K3”š¸AdE-Ä®ÝíiÌŒ')ȫع`#÷ÞlMwG¡BSÀ­÷èã¨z{.UzÑÓ†3ZŽ•6LÚal¾©Ë¯±>NŽvêfyµÝ#ÆO°ÅˆÙ£‚µ£»ûŸ½Ãµ!R}ïÓâäJG‚ÃZ° æIþ+î#¼7›¡þk •‹w³42Š_¨ý£U7pË•oYÃîË« é‡ÉÙŽÜË *âàÄÅÛ-qx{š«½"‡åVÓd˜•fCßr²Š Í ŠÖÉŽ‘Yñ¼ƒ”(öÊ©WþÆU? #¨£¡.SçªQåÛhÄèÌ.â=2ÇóW,ÿn9³œ%ÓŽ+ ,röæuÜ0z}•M*N-…œþˆøX&ÇþÁíæÓ¼<,C¡¬Wp½‚½€Öé+ü‚sÕÿ@$mÞ¹ Y‰½'_½iAMM}ʽz{(·¨Ëd×1u¹dЊQÁtïYPãS:±_µ kC¬Ò$ÀŸYß„v‹7e_¿`iÜû|Éçü™jqûÛÎ,ü%LÍ´çµÑ°Á,ÉOê'`?~;²“oFû{¨«Ò­üê—ž”«Ž¯ƒ‹‚NÅ _&7œKBø±ÌMÉ„ï¼ïÀÿêïJ˜Âs ÿò=:m|¶¸Z¦±àáÈ“§&¤S°Z“ô'ÿêÑ Ü–ônZÐL·éj(‹h¹ wm¥C';\ ̦s›kÝb&ä<—àd5ÒI~¢®&y;Å ¿eêö½’ŒÄ¹u¸€G%ÍlþæUoÔXJ„ý“”(­1eYä,´ì† –r„ôÆzc0Rdu¹^vy³Sý’Tjÿ£Ù¥µìÂt¬cæ+Ð?R²ë¥É{ ßÔG{Kø%Д2ÎhÙÔT[ 9+ÁpBxåºÍÌ:iÐ:Þ*ëßš0/þ„^Võˆ·GÚÆÒÙQ¿H[â_ÞKXé^õó=#« €û‰'ün"Sÿ;HTVûú¯Gþ0Þáе9ù€W`•Ií½ÚMXçÿB’nS…ö„h¥oO‡+0½c¹š úoÔvF‰ÂN²nžißèµMø^Ïñž<ÓùùNIÝUÊöWyÝ÷å)”}ò”Ê¿wJ%g…ÿ,Ï¿ Gk’U"I÷MãuâV—bÃdm*ü[ nü¦ ÙG05’¹ íd¶”k­Ì-ßoíH Búre1µ“›ZUØ›™ž2R°J¥ï·þb¿$¤^²´jí¼*Å^‘¦dý ÑYo­T¥† |j'þ ¯•àÓ´µ}a±±š%±©â¬Wó4Z;åΩåOIO”éª1;ÕûÎU3Rñ¬sÄâÑ£ÔÓMvQõŽ÷V„¯”ˆmFFðr¶60Æ$¥T+,ÌøÓ˳ϙ[(NhZ ‡‡+=O%>Õ3ÒIÕX}jHÒí¡ã!Á™…#L$á‘ZE¢Sµ-¿‘(…mPN°;ŽØï„Lj$œª®~/ËÖFõS„’˜¥ÖiR”OšMa“£@ݾÎc‡—ífÌj'ÆŒ)â縆}hÜmaSéä6Fü´f ˆ¿>µLÜ—v÷ßÍäKÿ!Ü<7Qžë'ä3K.þ®’v½ Ø{k2³ewE¯ÜöûÐŒ°?$Ÿ“ŸN@Û5£ºçŸz¬yEä§ZJÊ¢™D;éÚ#;ä_.%DûàÝ=Ρû$ì0 „×{‚ù;ô f=º+ÚsSêŸ'b”½¬¿ú !,Ó-´ñЋøb\b=¼};ªu¿™Öêu!Ý Ç„#÷>ZÃÚAN€Þߢoi/‹^Fú ؽ÷y1.w†-[¯~ƒ„wS„xDÉ —‰üS*zB#»j.jÔ»¥1äËþÌ>ü…K 4Þv„¿tD8–u2¯21V‰­ñGÚ¼{pÛmg6Ú²§nˆöø›/‚GÖ;DÔÿîÜÑ®7"Ïh ׿ä9Ú"®ŒUÛ‰§EM5Ú¢2ég‰PÚoi2Í“¦¶ŽöZD´-r\—÷}‘ÞRï²­Çûžš\Í%*è°·Y¢îþ÷Ÿ““·OõÛ•4a1re³ª=­')›N4Õ¾‰ ڻўý;¹©û¢X›½ÝbìÕi"¾ãvѰÍ&"ÿ‹vw¶H½|›¨ ºj/ödžu5{Ýk¶£ÿÈX³Šföÿd‚²Nhuý˜9 &À͈íw‘ý½\M\j☿ކÎO“êyû¤”@Ä:§k[×B®݇­OøGßFð‰D]|É,ÞWάmºoÚ{qéï$¶io¨fïÆè¢w’‘Ó«DÓP=%~6®„³§÷ø—”iû¿ À€0` üsks-ecc-0.93/zlib/contrib/dotzlib/DotZLib/0000755000175000017500000000000010604550750017317 5ustar nachonachosks-ecc-0.93/zlib/contrib/dotzlib/DotZLib/DotZLib.cs0000644000175000017500000002333010604550750021156 0ustar nachonacho// // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // using System; using System.IO; using System.Runtime.InteropServices; using System.Text; namespace DotZLib { #region Internal types /// /// Defines constants for the various flush types used with zlib /// internal enum FlushTypes { None, Partial, Sync, Full, Finish, Block } #region ZStream structure // internal mapping of the zlib zstream structure for marshalling [StructLayoutAttribute(LayoutKind.Sequential, Pack=4, Size=0, CharSet=CharSet.Ansi)] internal struct ZStream { public IntPtr next_in; public uint avail_in; public uint total_in; public IntPtr next_out; public uint avail_out; public uint total_out; [MarshalAs(UnmanagedType.LPStr)] string msg; uint state; uint zalloc; uint zfree; uint opaque; int data_type; public uint adler; uint reserved; } #endregion #endregion #region Public enums /// /// Defines constants for the available compression levels in zlib /// public enum CompressLevel : int { /// /// The default compression level with a reasonable compromise between compression and speed /// Default = -1, /// /// No compression at all. The data are passed straight through. /// None = 0, /// /// The maximum compression rate available. /// Best = 9, /// /// The fastest available compression level. /// Fastest = 1 } #endregion #region Exception classes /// /// The exception that is thrown when an error occurs on the zlib dll /// public class ZLibException : ApplicationException { /// /// Initializes a new instance of the class with a specified /// error message and error code /// /// The zlib error code that caused the exception /// A message that (hopefully) describes the error public ZLibException(int errorCode, string msg) : base(String.Format("ZLib error {0} {1}", errorCode, msg)) { } /// /// Initializes a new instance of the class with a specified /// error code /// /// The zlib error code that caused the exception public ZLibException(int errorCode) : base(String.Format("ZLib error {0}", errorCode)) { } } #endregion #region Interfaces /// /// Declares methods and properties that enables a running checksum to be calculated /// public interface ChecksumGenerator { /// /// Gets the current value of the checksum /// uint Value { get; } /// /// Clears the current checksum to 0 /// void Reset(); /// /// Updates the current checksum with an array of bytes /// /// The data to update the checksum with void Update(byte[] data); /// /// Updates the current checksum with part of an array of bytes /// /// The data to update the checksum with /// Where in data to start updating /// The number of bytes from data to use /// The sum of offset and count is larger than the length of data /// data is a null reference /// Offset or count is negative. void Update(byte[] data, int offset, int count); /// /// Updates the current checksum with the data from a string /// /// The string to update the checksum with /// The characters in the string are converted by the UTF-8 encoding void Update(string data); /// /// Updates the current checksum with the data from a string, using a specific encoding /// /// The string to update the checksum with /// The encoding to use void Update(string data, Encoding encoding); } /// /// Represents the method that will be called from a codec when new data /// are available. /// /// The byte array containing the processed data /// The index of the first processed byte in data /// The number of processed bytes available /// On return from this method, the data may be overwritten, so grab it while you can. /// You cannot assume that startIndex will be zero. /// public delegate void DataAvailableHandler(byte[] data, int startIndex, int count); /// /// Declares methods and events for implementing compressors/decompressors /// public interface Codec { /// /// Occurs when more processed data are available. /// event DataAvailableHandler DataAvailable; /// /// Adds more data to the codec to be processed. /// /// Byte array containing the data to be added to the codec /// Adding data may, or may not, raise the DataAvailable event void Add(byte[] data); /// /// Adds more data to the codec to be processed. /// /// Byte array containing the data to be added to the codec /// The index of the first byte to add from data /// The number of bytes to add /// Adding data may, or may not, raise the DataAvailable event void Add(byte[] data, int offset, int count); /// /// Finishes up any pending data that needs to be processed and handled. /// void Finish(); /// /// Gets the checksum of the data that has been added so far /// uint Checksum { get; } } #endregion #region Classes /// /// Encapsulates general information about the ZLib library /// public class Info { #region DLL imports [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] private static extern uint zlibCompileFlags(); [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] private static extern string zlibVersion(); #endregion #region Private stuff private uint _flags; // helper function that unpacks a bitsize mask private static int bitSize(uint bits) { switch (bits) { case 0: return 16; case 1: return 32; case 2: return 64; } return -1; } #endregion /// /// Constructs an instance of the Info class. /// public Info() { _flags = zlibCompileFlags(); } /// /// True if the library is compiled with debug info /// public bool HasDebugInfo { get { return 0 != (_flags & 0x100); } } /// /// True if the library is compiled with assembly optimizations /// public bool UsesAssemblyCode { get { return 0 != (_flags & 0x200); } } /// /// Gets the size of the unsigned int that was compiled into Zlib /// public int SizeOfUInt { get { return bitSize(_flags & 3); } } /// /// Gets the size of the unsigned long that was compiled into Zlib /// public int SizeOfULong { get { return bitSize((_flags >> 2) & 3); } } /// /// Gets the size of the pointers that were compiled into Zlib /// public int SizeOfPointer { get { return bitSize((_flags >> 4) & 3); } } /// /// Gets the size of the z_off_t type that was compiled into Zlib /// public int SizeOfOffset { get { return bitSize((_flags >> 6) & 3); } } /// /// Gets the version of ZLib as a string, e.g. "1.2.1" /// public static string Version { get { return zlibVersion(); } } } #endregion } sks-ecc-0.93/zlib/contrib/dotzlib/DotZLib/UnitTests.cs0000644000175000017500000001700310604550750021611 0ustar nachonacho// // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // using System; using System.Collections; using System.IO; // uncomment the define below to include unit tests //#define nunit #if nunit using NUnit.Framework; // Unit tests for the DotZLib class library // ---------------------------------------- // // Use this with NUnit 2 from http://www.nunit.org // namespace DotZLibTests { using DotZLib; // helper methods internal class Utils { public static bool byteArrEqual( byte[] lhs, byte[] rhs ) { if (lhs.Length != rhs.Length) return false; for (int i = lhs.Length-1; i >= 0; --i) if (lhs[i] != rhs[i]) return false; return true; } } [TestFixture] public class CircBufferTests { #region Circular buffer tests [Test] public void SinglePutGet() { CircularBuffer buf = new CircularBuffer(10); Assert.AreEqual( 0, buf.Size ); Assert.AreEqual( -1, buf.Get() ); Assert.IsTrue(buf.Put( 1 )); Assert.AreEqual( 1, buf.Size ); Assert.AreEqual( 1, buf.Get() ); Assert.AreEqual( 0, buf.Size ); Assert.AreEqual( -1, buf.Get() ); } [Test] public void BlockPutGet() { CircularBuffer buf = new CircularBuffer(10); byte[] arr = {1,2,3,4,5,6,7,8,9,10}; Assert.AreEqual( 10, buf.Put(arr,0,10) ); Assert.AreEqual( 10, buf.Size ); Assert.IsFalse( buf.Put(11) ); Assert.AreEqual( 1, buf.Get() ); Assert.IsTrue( buf.Put(11) ); byte[] arr2 = (byte[])arr.Clone(); Assert.AreEqual( 9, buf.Get(arr2,1,9) ); Assert.IsTrue( Utils.byteArrEqual(arr,arr2) ); } #endregion } [TestFixture] public class ChecksumTests { #region CRC32 Tests [Test] public void CRC32_Null() { CRC32Checksum crc32 = new CRC32Checksum(); Assert.AreEqual( 0, crc32.Value ); crc32 = new CRC32Checksum(1); Assert.AreEqual( 1, crc32.Value ); crc32 = new CRC32Checksum(556); Assert.AreEqual( 556, crc32.Value ); } [Test] public void CRC32_Data() { CRC32Checksum crc32 = new CRC32Checksum(); byte[] data = { 1,2,3,4,5,6,7 }; crc32.Update(data); Assert.AreEqual( 0x70e46888, crc32.Value ); crc32 = new CRC32Checksum(); crc32.Update("penguin"); Assert.AreEqual( 0x0e5c1a120, crc32.Value ); crc32 = new CRC32Checksum(1); crc32.Update("penguin"); Assert.AreEqual(0x43b6aa94, crc32.Value); } #endregion #region Adler tests [Test] public void Adler_Null() { AdlerChecksum adler = new AdlerChecksum(); Assert.AreEqual(0, adler.Value); adler = new AdlerChecksum(1); Assert.AreEqual( 1, adler.Value ); adler = new AdlerChecksum(556); Assert.AreEqual( 556, adler.Value ); } [Test] public void Adler_Data() { AdlerChecksum adler = new AdlerChecksum(1); byte[] data = { 1,2,3,4,5,6,7 }; adler.Update(data); Assert.AreEqual( 0x5b001d, adler.Value ); adler = new AdlerChecksum(); adler.Update("penguin"); Assert.AreEqual(0x0bcf02f6, adler.Value ); adler = new AdlerChecksum(1); adler.Update("penguin"); Assert.AreEqual(0x0bd602f7, adler.Value); } #endregion } [TestFixture] public class InfoTests { #region Info tests [Test] public void Info_Version() { Info info = new Info(); Assert.AreEqual("1.2.3", Info.Version); Assert.AreEqual(32, info.SizeOfUInt); Assert.AreEqual(32, info.SizeOfULong); Assert.AreEqual(32, info.SizeOfPointer); Assert.AreEqual(32, info.SizeOfOffset); } #endregion } [TestFixture] public class DeflateInflateTests { #region Deflate tests [Test] public void Deflate_Init() { using (Deflater def = new Deflater(CompressLevel.Default)) { } } private ArrayList compressedData = new ArrayList(); private uint adler1; private ArrayList uncompressedData = new ArrayList(); private uint adler2; public void CDataAvail(byte[] data, int startIndex, int count) { for (int i = 0; i < count; ++i) compressedData.Add(data[i+startIndex]); } [Test] public void Deflate_Compress() { compressedData.Clear(); byte[] testData = new byte[35000]; for (int i = 0; i < testData.Length; ++i) testData[i] = 5; using (Deflater def = new Deflater((CompressLevel)5)) { def.DataAvailable += new DataAvailableHandler(CDataAvail); def.Add(testData); def.Finish(); adler1 = def.Checksum; } } #endregion #region Inflate tests [Test] public void Inflate_Init() { using (Inflater inf = new Inflater()) { } } private void DDataAvail(byte[] data, int startIndex, int count) { for (int i = 0; i < count; ++i) uncompressedData.Add(data[i+startIndex]); } [Test] public void Inflate_Expand() { uncompressedData.Clear(); using (Inflater inf = new Inflater()) { inf.DataAvailable += new DataAvailableHandler(DDataAvail); inf.Add((byte[])compressedData.ToArray(typeof(byte))); inf.Finish(); adler2 = inf.Checksum; } Assert.AreEqual( adler1, adler2 ); } #endregion } [TestFixture] public class GZipStreamTests { #region GZipStream test [Test] public void GZipStream_WriteRead() { using (GZipStream gzOut = new GZipStream("gzstream.gz", CompressLevel.Best)) { BinaryWriter writer = new BinaryWriter(gzOut); writer.Write("hi there"); writer.Write(Math.PI); writer.Write(42); } using (GZipStream gzIn = new GZipStream("gzstream.gz")) { BinaryReader reader = new BinaryReader(gzIn); string s = reader.ReadString(); Assert.AreEqual("hi there",s); double d = reader.ReadDouble(); Assert.AreEqual(Math.PI, d); int i = reader.ReadInt32(); Assert.AreEqual(42,i); } } #endregion } } #endifsks-ecc-0.93/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj0000644000175000017500000001242410604550750022053 0ustar nachonacho sks-ecc-0.93/zlib/contrib/dotzlib/DotZLib/GZipStream.cs0000644000175000017500000002567310604550750021710 0ustar nachonacho// // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // using System; using System.IO; using System.Runtime.InteropServices; namespace DotZLib { /// /// Implements a compressed , in GZip (.gz) format. /// public class GZipStream : Stream, IDisposable { #region Dll Imports [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)] private static extern IntPtr gzopen(string name, string mode); [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] private static extern int gzclose(IntPtr gzFile); [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] private static extern int gzwrite(IntPtr gzFile, int data, int length); [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] private static extern int gzread(IntPtr gzFile, int data, int length); [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] private static extern int gzgetc(IntPtr gzFile); [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] private static extern int gzputc(IntPtr gzFile, int c); #endregion #region Private data private IntPtr _gzFile; private bool _isDisposed = false; private bool _isWriting; #endregion #region Constructors /// /// Creates a new file as a writeable GZipStream /// /// The name of the compressed file to create /// The compression level to use when adding data /// If an error occurred in the internal zlib function public GZipStream(string fileName, CompressLevel level) { _isWriting = true; _gzFile = gzopen(fileName, String.Format("wb{0}", (int)level)); if (_gzFile == IntPtr.Zero) throw new ZLibException(-1, "Could not open " + fileName); } /// /// Opens an existing file as a readable GZipStream /// /// The name of the file to open /// If an error occurred in the internal zlib function public GZipStream(string fileName) { _isWriting = false; _gzFile = gzopen(fileName, "rb"); if (_gzFile == IntPtr.Zero) throw new ZLibException(-1, "Could not open " + fileName); } #endregion #region Access properties /// /// Returns true of this stream can be read from, false otherwise /// public override bool CanRead { get { return !_isWriting; } } /// /// Returns false. /// public override bool CanSeek { get { return false; } } /// /// Returns true if this tsream is writeable, false otherwise /// public override bool CanWrite { get { return _isWriting; } } #endregion #region Destructor & IDispose stuff /// /// Destroys this instance /// ~GZipStream() { cleanUp(false); } /// /// Closes the external file handle /// public void Dispose() { cleanUp(true); } // Does the actual closing of the file handle. private void cleanUp(bool isDisposing) { if (!_isDisposed) { gzclose(_gzFile); _isDisposed = true; } } #endregion #region Basic reading and writing /// /// Attempts to read a number of bytes from the stream. /// /// The destination data buffer /// The index of the first destination byte in buffer /// The number of bytes requested /// The number of bytes read /// If buffer is null /// If count or offset are negative /// If offset + count is > buffer.Length /// If this stream is not readable. /// If this stream has been disposed. public override int Read(byte[] buffer, int offset, int count) { if (!CanRead) throw new NotSupportedException(); if (buffer == null) throw new ArgumentNullException(); if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); if ((offset+count) > buffer.Length) throw new ArgumentException(); if (_isDisposed) throw new ObjectDisposedException("GZipStream"); GCHandle h = GCHandle.Alloc(buffer, GCHandleType.Pinned); int result; try { result = gzread(_gzFile, h.AddrOfPinnedObject().ToInt32() + offset, count); if (result < 0) throw new IOException(); } finally { h.Free(); } return result; } /// /// Attempts to read a single byte from the stream. /// /// The byte that was read, or -1 in case of error or End-Of-File public override int ReadByte() { if (!CanRead) throw new NotSupportedException(); if (_isDisposed) throw new ObjectDisposedException("GZipStream"); return gzgetc(_gzFile); } /// /// Writes a number of bytes to the stream /// /// /// /// /// If buffer is null /// If count or offset are negative /// If offset + count is > buffer.Length /// If this stream is not writeable. /// If this stream has been disposed. public override void Write(byte[] buffer, int offset, int count) { if (!CanWrite) throw new NotSupportedException(); if (buffer == null) throw new ArgumentNullException(); if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); if ((offset+count) > buffer.Length) throw new ArgumentException(); if (_isDisposed) throw new ObjectDisposedException("GZipStream"); GCHandle h = GCHandle.Alloc(buffer, GCHandleType.Pinned); try { int result = gzwrite(_gzFile, h.AddrOfPinnedObject().ToInt32() + offset, count); if (result < 0) throw new IOException(); } finally { h.Free(); } } /// /// Writes a single byte to the stream /// /// The byte to add to the stream. /// If this stream is not writeable. /// If this stream has been disposed. public override void WriteByte(byte value) { if (!CanWrite) throw new NotSupportedException(); if (_isDisposed) throw new ObjectDisposedException("GZipStream"); int result = gzputc(_gzFile, (int)value); if (result < 0) throw new IOException(); } #endregion #region Position & length stuff /// /// Not supported. /// /// /// Always thrown public override void SetLength(long value) { throw new NotSupportedException(); } /// /// Not suppported. /// /// /// /// /// Always thrown public override long Seek(long offset, SeekOrigin origin) { throw new NotSupportedException(); } /// /// Flushes the GZipStream. /// /// In this implementation, this method does nothing. This is because excessive /// flushing may degrade the achievable compression rates. public override void Flush() { // left empty on purpose } /// /// Gets/sets the current position in the GZipStream. Not suppported. /// /// In this implementation this property is not supported /// Always thrown public override long Position { get { throw new NotSupportedException(); } set { throw new NotSupportedException(); } } /// /// Gets the size of the stream. Not suppported. /// /// In this implementation this property is not supported /// Always thrown public override long Length { get { throw new NotSupportedException(); } } #endregion } } sks-ecc-0.93/zlib/contrib/dotzlib/DotZLib/Inflater.cs0000644000175000017500000000724210604550750021417 0ustar nachonacho// // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // using System; using System.Diagnostics; using System.Runtime.InteropServices; namespace DotZLib { /// /// Implements a data decompressor, using the inflate algorithm in the ZLib dll /// public class Inflater : CodecBase { #region Dll imports [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)] private static extern int inflateInit_(ref ZStream sz, string vs, int size); [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] private static extern int inflate(ref ZStream sz, int flush); [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] private static extern int inflateReset(ref ZStream sz); [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] private static extern int inflateEnd(ref ZStream sz); #endregion /// /// Constructs an new instance of the Inflater /// public Inflater() : base() { int retval = inflateInit_(ref _ztream, Info.Version, Marshal.SizeOf(_ztream)); if (retval != 0) throw new ZLibException(retval, "Could not initialize inflater"); resetOutput(); } /// /// Adds more data to the codec to be processed. /// /// Byte array containing the data to be added to the codec /// The index of the first byte to add from data /// The number of bytes to add /// Adding data may, or may not, raise the DataAvailable event public override void Add(byte[] data, int offset, int count) { if (data == null) throw new ArgumentNullException(); if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); if ((offset+count) > data.Length) throw new ArgumentException(); int total = count; int inputIndex = offset; int err = 0; while (err >= 0 && inputIndex < total) { copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize)); err = inflate(ref _ztream, (int)FlushTypes.None); if (err == 0) while (_ztream.avail_out == 0) { OnDataAvailable(); err = inflate(ref _ztream, (int)FlushTypes.None); } inputIndex += (int)_ztream.total_in; } setChecksum( _ztream.adler ); } /// /// Finishes up any pending data that needs to be processed and handled. /// public override void Finish() { int err; do { err = inflate(ref _ztream, (int)FlushTypes.Finish); OnDataAvailable(); } while (err == 0); setChecksum( _ztream.adler ); inflateReset(ref _ztream); resetOutput(); } /// /// Closes the internal zlib inflate stream /// protected override void CleanUp() { inflateEnd(ref _ztream); } } } sks-ecc-0.93/zlib/contrib/dotzlib/DotZLib/CodecBase.cs0000644000175000017500000001430310604550750021457 0ustar nachonacho// // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // using System; using System.Runtime.InteropServices; namespace DotZLib { /// /// Implements the common functionality needed for all s /// public abstract class CodecBase : Codec, IDisposable { #region Data members /// /// Instance of the internal zlib buffer structure that is /// passed to all functions in the zlib dll /// internal ZStream _ztream = new ZStream(); /// /// True if the object instance has been disposed, false otherwise /// protected bool _isDisposed = false; /// /// The size of the internal buffers /// protected const int kBufferSize = 16384; private byte[] _outBuffer = new byte[kBufferSize]; private byte[] _inBuffer = new byte[kBufferSize]; private GCHandle _hInput; private GCHandle _hOutput; private uint _checksum = 0; #endregion /// /// Initializes a new instance of the CodeBase class. /// public CodecBase() { try { _hInput = GCHandle.Alloc(_inBuffer, GCHandleType.Pinned); _hOutput = GCHandle.Alloc(_outBuffer, GCHandleType.Pinned); } catch (Exception) { CleanUp(false); throw; } } #region Codec Members /// /// Occurs when more processed data are available. /// public event DataAvailableHandler DataAvailable; /// /// Fires the event /// protected void OnDataAvailable() { if (_ztream.total_out > 0) { if (DataAvailable != null) DataAvailable( _outBuffer, 0, (int)_ztream.total_out); resetOutput(); } } /// /// Adds more data to the codec to be processed. /// /// Byte array containing the data to be added to the codec /// Adding data may, or may not, raise the DataAvailable event public void Add(byte[] data) { Add(data,0,data.Length); } /// /// Adds more data to the codec to be processed. /// /// Byte array containing the data to be added to the codec /// The index of the first byte to add from data /// The number of bytes to add /// Adding data may, or may not, raise the DataAvailable event /// This must be implemented by a derived class public abstract void Add(byte[] data, int offset, int count); /// /// Finishes up any pending data that needs to be processed and handled. /// /// This must be implemented by a derived class public abstract void Finish(); /// /// Gets the checksum of the data that has been added so far /// public uint Checksum { get { return _checksum; } } #endregion #region Destructor & IDisposable stuff /// /// Destroys this instance /// ~CodecBase() { CleanUp(false); } /// /// Releases any unmanaged resources and calls the method of the derived class /// public void Dispose() { CleanUp(true); } /// /// Performs any codec specific cleanup /// /// This must be implemented by a derived class protected abstract void CleanUp(); // performs the release of the handles and calls the dereived CleanUp() private void CleanUp(bool isDisposing) { if (!_isDisposed) { CleanUp(); if (_hInput.IsAllocated) _hInput.Free(); if (_hOutput.IsAllocated) _hOutput.Free(); _isDisposed = true; } } #endregion #region Helper methods /// /// Copies a number of bytes to the internal codec buffer - ready for proccesing /// /// The byte array that contains the data to copy /// The index of the first byte to copy /// The number of bytes to copy from data protected void copyInput(byte[] data, int startIndex, int count) { Array.Copy(data, startIndex, _inBuffer,0, count); _ztream.next_in = _hInput.AddrOfPinnedObject(); _ztream.total_in = 0; _ztream.avail_in = (uint)count; } /// /// Resets the internal output buffers to a known state - ready for processing /// protected void resetOutput() { _ztream.total_out = 0; _ztream.avail_out = kBufferSize; _ztream.next_out = _hOutput.AddrOfPinnedObject(); } /// /// Updates the running checksum property /// /// The new checksum value protected void setChecksum(uint newSum) { _checksum = newSum; } #endregion } } sks-ecc-0.93/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs0000644000175000017500000001756310604550750022246 0ustar nachonacho// // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // using System; using System.Runtime.InteropServices; using System.Text; namespace DotZLib { #region ChecksumGeneratorBase /// /// Implements the common functionality needed for all s /// /// public abstract class ChecksumGeneratorBase : ChecksumGenerator { /// /// The value of the current checksum /// protected uint _current; /// /// Initializes a new instance of the checksum generator base - the current checksum is /// set to zero /// public ChecksumGeneratorBase() { _current = 0; } /// /// Initializes a new instance of the checksum generator basewith a specified value /// /// The value to set the current checksum to public ChecksumGeneratorBase(uint initialValue) { _current = initialValue; } /// /// Resets the current checksum to zero /// public void Reset() { _current = 0; } /// /// Gets the current checksum value /// public uint Value { get { return _current; } } /// /// Updates the current checksum with part of an array of bytes /// /// The data to update the checksum with /// Where in data to start updating /// The number of bytes from data to use /// The sum of offset and count is larger than the length of data /// data is a null reference /// Offset or count is negative. /// All the other Update methods are implmeneted in terms of this one. /// This is therefore the only method a derived class has to implement public abstract void Update(byte[] data, int offset, int count); /// /// Updates the current checksum with an array of bytes. /// /// The data to update the checksum with public void Update(byte[] data) { Update(data, 0, data.Length); } /// /// Updates the current checksum with the data from a string /// /// The string to update the checksum with /// The characters in the string are converted by the UTF-8 encoding public void Update(string data) { Update(Encoding.UTF8.GetBytes(data)); } /// /// Updates the current checksum with the data from a string, using a specific encoding /// /// The string to update the checksum with /// The encoding to use public void Update(string data, Encoding encoding) { Update(encoding.GetBytes(data)); } } #endregion #region CRC32 /// /// Implements a CRC32 checksum generator /// public sealed class CRC32Checksum : ChecksumGeneratorBase { #region DLL imports [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] private static extern uint crc32(uint crc, int data, uint length); #endregion /// /// Initializes a new instance of the CRC32 checksum generator /// public CRC32Checksum() : base() {} /// /// Initializes a new instance of the CRC32 checksum generator with a specified value /// /// The value to set the current checksum to public CRC32Checksum(uint initialValue) : base(initialValue) {} /// /// Updates the current checksum with part of an array of bytes /// /// The data to update the checksum with /// Where in data to start updating /// The number of bytes from data to use /// The sum of offset and count is larger than the length of data /// data is a null reference /// Offset or count is negative. public override void Update(byte[] data, int offset, int count) { if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); if ((offset+count) > data.Length) throw new ArgumentException(); GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned); try { _current = crc32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count); } finally { hData.Free(); } } } #endregion #region Adler /// /// Implements a checksum generator that computes the Adler checksum on data /// public sealed class AdlerChecksum : ChecksumGeneratorBase { #region DLL imports [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] private static extern uint adler32(uint adler, int data, uint length); #endregion /// /// Initializes a new instance of the Adler checksum generator /// public AdlerChecksum() : base() {} /// /// Initializes a new instance of the Adler checksum generator with a specified value /// /// The value to set the current checksum to public AdlerChecksum(uint initialValue) : base(initialValue) {} /// /// Updates the current checksum with part of an array of bytes /// /// The data to update the checksum with /// Where in data to start updating /// The number of bytes from data to use /// The sum of offset and count is larger than the length of data /// data is a null reference /// Offset or count is negative. public override void Update(byte[] data, int offset, int count) { if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); if ((offset+count) > data.Length) throw new ArgumentException(); GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned); try { _current = adler32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count); } finally { hData.Free(); } } } #endregion }sks-ecc-0.93/zlib/contrib/dotzlib/DotZLib/Deflater.cs0000644000175000017500000000764610604550750021411 0ustar nachonacho// // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // using System; using System.Diagnostics; using System.Runtime.InteropServices; namespace DotZLib { /// /// Implements a data compressor, using the deflate algorithm in the ZLib dll /// public sealed class Deflater : CodecBase { #region Dll imports [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)] private static extern int deflateInit_(ref ZStream sz, int level, string vs, int size); [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] private static extern int deflate(ref ZStream sz, int flush); [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] private static extern int deflateReset(ref ZStream sz); [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] private static extern int deflateEnd(ref ZStream sz); #endregion /// /// Constructs an new instance of the Deflater /// /// The compression level to use for this Deflater public Deflater(CompressLevel level) : base() { int retval = deflateInit_(ref _ztream, (int)level, Info.Version, Marshal.SizeOf(_ztream)); if (retval != 0) throw new ZLibException(retval, "Could not initialize deflater"); resetOutput(); } /// /// Adds more data to the codec to be processed. /// /// Byte array containing the data to be added to the codec /// The index of the first byte to add from data /// The number of bytes to add /// Adding data may, or may not, raise the DataAvailable event public override void Add(byte[] data, int offset, int count) { if (data == null) throw new ArgumentNullException(); if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); if ((offset+count) > data.Length) throw new ArgumentException(); int total = count; int inputIndex = offset; int err = 0; while (err >= 0 && inputIndex < total) { copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize)); while (err >= 0 && _ztream.avail_in > 0) { err = deflate(ref _ztream, (int)FlushTypes.None); if (err == 0) while (_ztream.avail_out == 0) { OnDataAvailable(); err = deflate(ref _ztream, (int)FlushTypes.None); } inputIndex += (int)_ztream.total_in; } } setChecksum( _ztream.adler ); } /// /// Finishes up any pending data that needs to be processed and handled. /// public override void Finish() { int err; do { err = deflate(ref _ztream, (int)FlushTypes.Finish); OnDataAvailable(); } while (err == 0); setChecksum( _ztream.adler ); deflateReset(ref _ztream); resetOutput(); } /// /// Closes the internal zlib deflate stream /// protected override void CleanUp() { deflateEnd(ref _ztream); } } } sks-ecc-0.93/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs0000644000175000017500000000431310604550750022545 0ustar nachonacho// // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // using System; using System.Diagnostics; namespace DotZLib { /// /// This class implements a circular buffer /// internal class CircularBuffer { #region Private data private int _capacity; private int _head; private int _tail; private int _size; private byte[] _buffer; #endregion public CircularBuffer(int capacity) { Debug.Assert( capacity > 0 ); _buffer = new byte[capacity]; _capacity = capacity; _head = 0; _tail = 0; _size = 0; } public int Size { get { return _size; } } public int Put(byte[] source, int offset, int count) { Debug.Assert( count > 0 ); int trueCount = Math.Min(count, _capacity - Size); for (int i = 0; i < trueCount; ++i) _buffer[(_tail+i) % _capacity] = source[offset+i]; _tail += trueCount; _tail %= _capacity; _size += trueCount; return trueCount; } public bool Put(byte b) { if (Size == _capacity) // no room return false; _buffer[_tail++] = b; _tail %= _capacity; ++_size; return true; } public int Get(byte[] destination, int offset, int count) { int trueCount = Math.Min(count,Size); for (int i = 0; i < trueCount; ++i) destination[offset + i] = _buffer[(_head+i) % _capacity]; _head += trueCount; _head %= _capacity; _size -= trueCount; return trueCount; } public int Get() { if (Size == 0) return -1; int result = (int)_buffer[_head++ % _capacity]; --_size; return result; } } } sks-ecc-0.93/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs0000644000175000017500000000471710604550750022252 0ustar nachonachousing System.Reflection; using System.Runtime.CompilerServices; // // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. // [assembly: AssemblyTitle("DotZLib")] [assembly: AssemblyDescription(".Net bindings for ZLib compression dll 1.2.x")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Henrik Ravn")] [assembly: AssemblyProduct("")] [assembly: AssemblyCopyright("(c) 2004 by Henrik Ravn")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.*")] // // In order to sign your assembly you must specify a key to use. Refer to the // Microsoft .NET Framework documentation for more information on assembly signing. // // Use the attributes below to control which key is used for signing. // // Notes: // (*) If no key is specified, the assembly is not signed. // (*) KeyName refers to a key that has been installed in the Crypto Service // Provider (CSP) on your machine. KeyFile refers to a file which contains // a key. // (*) If the KeyFile and the KeyName values are both specified, the // following processing occurs: // (1) If the KeyName can be found in the CSP, that key is used. // (2) If the KeyName does not exist and the KeyFile does exist, the key // in the KeyFile is installed into the CSP and used. // (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. // When specifying the KeyFile, the location of the KeyFile should be // relative to the project output directory which is // %Project Directory%\obj\. For example, if your KeyFile is // located in the project directory, you would specify the AssemblyKeyFile // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework // documentation for more information on this. // [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyFile("")] [assembly: AssemblyKeyName("")] sks-ecc-0.93/zlib/contrib/pascal/0000755000175000017500000000000010604550750015604 5ustar nachonachosks-ecc-0.93/zlib/contrib/pascal/readme.txt0000644000175000017500000000567410604550750017616 0ustar nachonacho This directory contains a Pascal (Delphi, Kylix) interface to the zlib data compression library. Directory listing ================= zlibd32.mak makefile for Borland C++ example.pas usage example of zlib zlibpas.pas the Pascal interface to zlib readme.txt this file Compatibility notes =================== - Although the name "zlib" would have been more normal for the zlibpas unit, this name is already taken by Borland's ZLib unit. This is somehow unfortunate, because that unit is not a genuine interface to the full-fledged zlib functionality, but a suite of class wrappers around zlib streams. Other essential features, such as checksums, are missing. It would have been more appropriate for that unit to have a name like "ZStreams", or something similar. - The C and zlib-supplied types int, uInt, long, uLong, etc. are translated directly into Pascal types of similar sizes (Integer, LongInt, etc.), to avoid namespace pollution. In particular, there is no conversion of unsigned int into a Pascal unsigned integer. The Word type is non-portable and has the same size (16 bits) both in a 16-bit and in a 32-bit environment, unlike Integer. Even if there is a 32-bit Cardinal type, there is no real need for unsigned int in zlib under a 32-bit environment. - Except for the callbacks, the zlib function interfaces are assuming the calling convention normally used in Pascal (__pascal for DOS and Windows16, __fastcall for Windows32). Since the cdecl keyword is used, the old Turbo Pascal does not work with this interface. - The gz* function interfaces are not translated, to avoid interfacing problems with the C runtime library. Besides, gzprintf(gzFile file, const char *format, ...) cannot be translated into Pascal. Legal issues ============ The zlibpas interface is: Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler. Copyright (C) 1998 by Bob Dellaca. Copyright (C) 2003 by Cosmin Truta. The example program is: Copyright (C) 1995-2003 by Jean-loup Gailly. Copyright (C) 1998,1999,2000 by Jacques Nomssi Nzali. Copyright (C) 2003 by Cosmin Truta. This software is provided 'as-is', without any express or implied warranty. In no event will the author 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. sks-ecc-0.93/zlib/contrib/pascal/example.pas0000644000175000017500000003650710604550750017757 0ustar nachonacho(* example.c -- usage example of the zlib compression library * Copyright (C) 1995-2003 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h * * Pascal translation * Copyright (C) 1998 by Jacques Nomssi Nzali. * For conditions of distribution and use, see copyright notice in readme.txt * * Adaptation to the zlibpas interface * Copyright (C) 2003 by Cosmin Truta. * For conditions of distribution and use, see copyright notice in readme.txt *) program example; {$DEFINE TEST_COMPRESS} {DO NOT $DEFINE TEST_GZIO} {$DEFINE TEST_DEFLATE} {$DEFINE TEST_INFLATE} {$DEFINE TEST_FLUSH} {$DEFINE TEST_SYNC} {$DEFINE TEST_DICT} uses SysUtils, zlibpas; const TESTFILE = 'foo.gz'; (* "hello world" would be more standard, but the repeated "hello" * stresses the compression code better, sorry... *) const hello: PChar = 'hello, hello!'; const dictionary: PChar = 'hello'; var dictId: LongInt; (* Adler32 value of the dictionary *) procedure CHECK_ERR(err: Integer; msg: String); begin if err <> Z_OK then begin WriteLn(msg, ' error: ', err); Halt(1); end; end; procedure EXIT_ERR(const msg: String); begin WriteLn('Error: ', msg); Halt(1); end; (* =========================================================================== * Test compress and uncompress *) {$IFDEF TEST_COMPRESS} procedure test_compress(compr: Pointer; comprLen: LongInt; uncompr: Pointer; uncomprLen: LongInt); var err: Integer; len: LongInt; begin len := StrLen(hello)+1; err := compress(compr, comprLen, hello, len); CHECK_ERR(err, 'compress'); StrCopy(PChar(uncompr), 'garbage'); err := uncompress(uncompr, uncomprLen, compr, comprLen); CHECK_ERR(err, 'uncompress'); if StrComp(PChar(uncompr), hello) <> 0 then EXIT_ERR('bad uncompress') else WriteLn('uncompress(): ', PChar(uncompr)); end; {$ENDIF} (* =========================================================================== * Test read/write of .gz files *) {$IFDEF TEST_GZIO} procedure test_gzio(const fname: PChar; (* compressed file name *) uncompr: Pointer; uncomprLen: LongInt); var err: Integer; len: Integer; zfile: gzFile; pos: LongInt; begin len := StrLen(hello)+1; zfile := gzopen(fname, 'wb'); if zfile = NIL then begin WriteLn('gzopen error'); Halt(1); end; gzputc(zfile, 'h'); if gzputs(zfile, 'ello') <> 4 then begin WriteLn('gzputs err: ', gzerror(zfile, err)); Halt(1); end; {$IFDEF GZ_FORMAT_STRING} if gzprintf(zfile, ', %s!', 'hello') <> 8 then begin WriteLn('gzprintf err: ', gzerror(zfile, err)); Halt(1); end; {$ELSE} if gzputs(zfile, ', hello!') <> 8 then begin WriteLn('gzputs err: ', gzerror(zfile, err)); Halt(1); end; {$ENDIF} gzseek(zfile, 1, SEEK_CUR); (* add one zero byte *) gzclose(zfile); zfile := gzopen(fname, 'rb'); if zfile = NIL then begin WriteLn('gzopen error'); Halt(1); end; StrCopy(PChar(uncompr), 'garbage'); if gzread(zfile, uncompr, uncomprLen) <> len then begin WriteLn('gzread err: ', gzerror(zfile, err)); Halt(1); end; if StrComp(PChar(uncompr), hello) <> 0 then begin WriteLn('bad gzread: ', PChar(uncompr)); Halt(1); end else WriteLn('gzread(): ', PChar(uncompr)); pos := gzseek(zfile, -8, SEEK_CUR); if (pos <> 6) or (gztell(zfile) <> pos) then begin WriteLn('gzseek error, pos=', pos, ', gztell=', gztell(zfile)); Halt(1); end; if gzgetc(zfile) <> ' ' then begin WriteLn('gzgetc error'); Halt(1); end; if gzungetc(' ', zfile) <> ' ' then begin WriteLn('gzungetc error'); Halt(1); end; gzgets(zfile, PChar(uncompr), uncomprLen); uncomprLen := StrLen(PChar(uncompr)); if uncomprLen <> 7 then (* " hello!" *) begin WriteLn('gzgets err after gzseek: ', gzerror(zfile, err)); Halt(1); end; if StrComp(PChar(uncompr), hello + 6) <> 0 then begin WriteLn('bad gzgets after gzseek'); Halt(1); end else WriteLn('gzgets() after gzseek: ', PChar(uncompr)); gzclose(zfile); end; {$ENDIF} (* =========================================================================== * Test deflate with small buffers *) {$IFDEF TEST_DEFLATE} procedure test_deflate(compr: Pointer; comprLen: LongInt); var c_stream: z_stream; (* compression stream *) err: Integer; len: LongInt; begin len := StrLen(hello)+1; c_stream.zalloc := NIL; c_stream.zfree := NIL; c_stream.opaque := NIL; err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION); CHECK_ERR(err, 'deflateInit'); c_stream.next_in := hello; c_stream.next_out := compr; while (c_stream.total_in <> len) and (c_stream.total_out < comprLen) do begin c_stream.avail_out := 1; { force small buffers } c_stream.avail_in := 1; err := deflate(c_stream, Z_NO_FLUSH); CHECK_ERR(err, 'deflate'); end; (* Finish the stream, still forcing small buffers: *) while TRUE do begin c_stream.avail_out := 1; err := deflate(c_stream, Z_FINISH); if err = Z_STREAM_END then break; CHECK_ERR(err, 'deflate'); end; err := deflateEnd(c_stream); CHECK_ERR(err, 'deflateEnd'); end; {$ENDIF} (* =========================================================================== * Test inflate with small buffers *) {$IFDEF TEST_INFLATE} procedure test_inflate(compr: Pointer; comprLen : LongInt; uncompr: Pointer; uncomprLen : LongInt); var err: Integer; d_stream: z_stream; (* decompression stream *) begin StrCopy(PChar(uncompr), 'garbage'); d_stream.zalloc := NIL; d_stream.zfree := NIL; d_stream.opaque := NIL; d_stream.next_in := compr; d_stream.avail_in := 0; d_stream.next_out := uncompr; err := inflateInit(d_stream); CHECK_ERR(err, 'inflateInit'); while (d_stream.total_out < uncomprLen) and (d_stream.total_in < comprLen) do begin d_stream.avail_out := 1; (* force small buffers *) d_stream.avail_in := 1; err := inflate(d_stream, Z_NO_FLUSH); if err = Z_STREAM_END then break; CHECK_ERR(err, 'inflate'); end; err := inflateEnd(d_stream); CHECK_ERR(err, 'inflateEnd'); if StrComp(PChar(uncompr), hello) <> 0 then EXIT_ERR('bad inflate') else WriteLn('inflate(): ', PChar(uncompr)); end; {$ENDIF} (* =========================================================================== * Test deflate with large buffers and dynamic change of compression level *) {$IFDEF TEST_DEFLATE} procedure test_large_deflate(compr: Pointer; comprLen: LongInt; uncompr: Pointer; uncomprLen: LongInt); var c_stream: z_stream; (* compression stream *) err: Integer; begin c_stream.zalloc := NIL; c_stream.zfree := NIL; c_stream.opaque := NIL; err := deflateInit(c_stream, Z_BEST_SPEED); CHECK_ERR(err, 'deflateInit'); c_stream.next_out := compr; c_stream.avail_out := Integer(comprLen); (* At this point, uncompr is still mostly zeroes, so it should compress * very well: *) c_stream.next_in := uncompr; c_stream.avail_in := Integer(uncomprLen); err := deflate(c_stream, Z_NO_FLUSH); CHECK_ERR(err, 'deflate'); if c_stream.avail_in <> 0 then EXIT_ERR('deflate not greedy'); (* Feed in already compressed data and switch to no compression: *) deflateParams(c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); c_stream.next_in := compr; c_stream.avail_in := Integer(comprLen div 2); err := deflate(c_stream, Z_NO_FLUSH); CHECK_ERR(err, 'deflate'); (* Switch back to compressing mode: *) deflateParams(c_stream, Z_BEST_COMPRESSION, Z_FILTERED); c_stream.next_in := uncompr; c_stream.avail_in := Integer(uncomprLen); err := deflate(c_stream, Z_NO_FLUSH); CHECK_ERR(err, 'deflate'); err := deflate(c_stream, Z_FINISH); if err <> Z_STREAM_END then EXIT_ERR('deflate should report Z_STREAM_END'); err := deflateEnd(c_stream); CHECK_ERR(err, 'deflateEnd'); end; {$ENDIF} (* =========================================================================== * Test inflate with large buffers *) {$IFDEF TEST_INFLATE} procedure test_large_inflate(compr: Pointer; comprLen: LongInt; uncompr: Pointer; uncomprLen: LongInt); var err: Integer; d_stream: z_stream; (* decompression stream *) begin StrCopy(PChar(uncompr), 'garbage'); d_stream.zalloc := NIL; d_stream.zfree := NIL; d_stream.opaque := NIL; d_stream.next_in := compr; d_stream.avail_in := Integer(comprLen); err := inflateInit(d_stream); CHECK_ERR(err, 'inflateInit'); while TRUE do begin d_stream.next_out := uncompr; (* discard the output *) d_stream.avail_out := Integer(uncomprLen); err := inflate(d_stream, Z_NO_FLUSH); if err = Z_STREAM_END then break; CHECK_ERR(err, 'large inflate'); end; err := inflateEnd(d_stream); CHECK_ERR(err, 'inflateEnd'); if d_stream.total_out <> 2 * uncomprLen + comprLen div 2 then begin WriteLn('bad large inflate: ', d_stream.total_out); Halt(1); end else WriteLn('large_inflate(): OK'); end; {$ENDIF} (* =========================================================================== * Test deflate with full flush *) {$IFDEF TEST_FLUSH} procedure test_flush(compr: Pointer; var comprLen : LongInt); var c_stream: z_stream; (* compression stream *) err: Integer; len: Integer; begin len := StrLen(hello)+1; c_stream.zalloc := NIL; c_stream.zfree := NIL; c_stream.opaque := NIL; err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION); CHECK_ERR(err, 'deflateInit'); c_stream.next_in := hello; c_stream.next_out := compr; c_stream.avail_in := 3; c_stream.avail_out := Integer(comprLen); err := deflate(c_stream, Z_FULL_FLUSH); CHECK_ERR(err, 'deflate'); Inc(PByteArray(compr)^[3]); (* force an error in first compressed block *) c_stream.avail_in := len - 3; err := deflate(c_stream, Z_FINISH); if err <> Z_STREAM_END then CHECK_ERR(err, 'deflate'); err := deflateEnd(c_stream); CHECK_ERR(err, 'deflateEnd'); comprLen := c_stream.total_out; end; {$ENDIF} (* =========================================================================== * Test inflateSync() *) {$IFDEF TEST_SYNC} procedure test_sync(compr: Pointer; comprLen: LongInt; uncompr: Pointer; uncomprLen : LongInt); var err: Integer; d_stream: z_stream; (* decompression stream *) begin StrCopy(PChar(uncompr), 'garbage'); d_stream.zalloc := NIL; d_stream.zfree := NIL; d_stream.opaque := NIL; d_stream.next_in := compr; d_stream.avail_in := 2; (* just read the zlib header *) err := inflateInit(d_stream); CHECK_ERR(err, 'inflateInit'); d_stream.next_out := uncompr; d_stream.avail_out := Integer(uncomprLen); inflate(d_stream, Z_NO_FLUSH); CHECK_ERR(err, 'inflate'); d_stream.avail_in := Integer(comprLen-2); (* read all compressed data *) err := inflateSync(d_stream); (* but skip the damaged part *) CHECK_ERR(err, 'inflateSync'); err := inflate(d_stream, Z_FINISH); if err <> Z_DATA_ERROR then EXIT_ERR('inflate should report DATA_ERROR'); (* Because of incorrect adler32 *) err := inflateEnd(d_stream); CHECK_ERR(err, 'inflateEnd'); WriteLn('after inflateSync(): hel', PChar(uncompr)); end; {$ENDIF} (* =========================================================================== * Test deflate with preset dictionary *) {$IFDEF TEST_DICT} procedure test_dict_deflate(compr: Pointer; comprLen: LongInt); var c_stream: z_stream; (* compression stream *) err: Integer; begin c_stream.zalloc := NIL; c_stream.zfree := NIL; c_stream.opaque := NIL; err := deflateInit(c_stream, Z_BEST_COMPRESSION); CHECK_ERR(err, 'deflateInit'); err := deflateSetDictionary(c_stream, dictionary, StrLen(dictionary)); CHECK_ERR(err, 'deflateSetDictionary'); dictId := c_stream.adler; c_stream.next_out := compr; c_stream.avail_out := Integer(comprLen); c_stream.next_in := hello; c_stream.avail_in := StrLen(hello)+1; err := deflate(c_stream, Z_FINISH); if err <> Z_STREAM_END then EXIT_ERR('deflate should report Z_STREAM_END'); err := deflateEnd(c_stream); CHECK_ERR(err, 'deflateEnd'); end; {$ENDIF} (* =========================================================================== * Test inflate with a preset dictionary *) {$IFDEF TEST_DICT} procedure test_dict_inflate(compr: Pointer; comprLen: LongInt; uncompr: Pointer; uncomprLen: LongInt); var err: Integer; d_stream: z_stream; (* decompression stream *) begin StrCopy(PChar(uncompr), 'garbage'); d_stream.zalloc := NIL; d_stream.zfree := NIL; d_stream.opaque := NIL; d_stream.next_in := compr; d_stream.avail_in := Integer(comprLen); err := inflateInit(d_stream); CHECK_ERR(err, 'inflateInit'); d_stream.next_out := uncompr; d_stream.avail_out := Integer(uncomprLen); while TRUE do begin err := inflate(d_stream, Z_NO_FLUSH); if err = Z_STREAM_END then break; if err = Z_NEED_DICT then begin if d_stream.adler <> dictId then EXIT_ERR('unexpected dictionary'); err := inflateSetDictionary(d_stream, dictionary, StrLen(dictionary)); end; CHECK_ERR(err, 'inflate with dict'); end; err := inflateEnd(d_stream); CHECK_ERR(err, 'inflateEnd'); if StrComp(PChar(uncompr), hello) <> 0 then EXIT_ERR('bad inflate with dict') else WriteLn('inflate with dictionary: ', PChar(uncompr)); end; {$ENDIF} var compr, uncompr: Pointer; comprLen, uncomprLen: LongInt; begin if zlibVersion^ <> ZLIB_VERSION[1] then EXIT_ERR('Incompatible zlib version'); WriteLn('zlib version: ', zlibVersion); WriteLn('zlib compile flags: ', Format('0x%x', [zlibCompileFlags])); comprLen := 10000 * SizeOf(Integer); (* don't overflow on MSDOS *) uncomprLen := comprLen; GetMem(compr, comprLen); GetMem(uncompr, uncomprLen); if (compr = NIL) or (uncompr = NIL) then EXIT_ERR('Out of memory'); (* compr and uncompr are cleared to avoid reading uninitialized * data and to ensure that uncompr compresses well. *) FillChar(compr^, comprLen, 0); FillChar(uncompr^, uncomprLen, 0); {$IFDEF TEST_COMPRESS} WriteLn('** Testing compress'); test_compress(compr, comprLen, uncompr, uncomprLen); {$ENDIF} {$IFDEF TEST_GZIO} WriteLn('** Testing gzio'); if ParamCount >= 1 then test_gzio(ParamStr(1), uncompr, uncomprLen) else test_gzio(TESTFILE, uncompr, uncomprLen); {$ENDIF} {$IFDEF TEST_DEFLATE} WriteLn('** Testing deflate with small buffers'); test_deflate(compr, comprLen); {$ENDIF} {$IFDEF TEST_INFLATE} WriteLn('** Testing inflate with small buffers'); test_inflate(compr, comprLen, uncompr, uncomprLen); {$ENDIF} {$IFDEF TEST_DEFLATE} WriteLn('** Testing deflate with large buffers'); test_large_deflate(compr, comprLen, uncompr, uncomprLen); {$ENDIF} {$IFDEF TEST_INFLATE} WriteLn('** Testing inflate with large buffers'); test_large_inflate(compr, comprLen, uncompr, uncomprLen); {$ENDIF} {$IFDEF TEST_FLUSH} WriteLn('** Testing deflate with full flush'); test_flush(compr, comprLen); {$ENDIF} {$IFDEF TEST_SYNC} WriteLn('** Testing inflateSync'); test_sync(compr, comprLen, uncompr, uncomprLen); {$ENDIF} comprLen := uncomprLen; {$IFDEF TEST_DICT} WriteLn('** Testing deflate and inflate with preset dictionary'); test_dict_deflate(compr, comprLen); test_dict_inflate(compr, comprLen, uncompr, uncomprLen); {$ENDIF} FreeMem(compr, comprLen); FreeMem(uncompr, uncomprLen); end. sks-ecc-0.93/zlib/contrib/pascal/zlibpas.pas0000644000175000017500000001754110604550750017765 0ustar nachonacho(* zlibpas -- Pascal interface to the zlib data compression library * * Copyright (C) 2003 Cosmin Truta. * Derived from original sources by Bob Dellaca. * For conditions of distribution and use, see copyright notice in readme.txt *) unit zlibpas; interface const ZLIB_VERSION = '1.2.3'; type alloc_func = function(opaque: Pointer; items, size: Integer): Pointer; cdecl; free_func = procedure(opaque, address: Pointer); cdecl; in_func = function(opaque: Pointer; var buf: PByte): Integer; cdecl; out_func = function(opaque: Pointer; buf: PByte; size: Integer): Integer; cdecl; z_streamp = ^z_stream; z_stream = packed record next_in: PChar; (* next input byte *) avail_in: Integer; (* number of bytes available at next_in *) total_in: LongInt; (* total nb of input bytes read so far *) next_out: PChar; (* next output byte should be put there *) avail_out: Integer; (* remaining free space at next_out *) total_out: LongInt; (* total nb of bytes output so far *) msg: PChar; (* last error message, NULL if no error *) state: Pointer; (* not visible by applications *) zalloc: alloc_func; (* used to allocate the internal state *) zfree: free_func; (* used to free the internal state *) opaque: Pointer; (* private data object passed to zalloc and zfree *) data_type: Integer; (* best guess about the data type: ascii or binary *) adler: LongInt; (* adler32 value of the uncompressed data *) reserved: LongInt; (* reserved for future use *) end; (* constants *) const Z_NO_FLUSH = 0; Z_PARTIAL_FLUSH = 1; Z_SYNC_FLUSH = 2; Z_FULL_FLUSH = 3; Z_FINISH = 4; Z_OK = 0; Z_STREAM_END = 1; Z_NEED_DICT = 2; Z_ERRNO = -1; Z_STREAM_ERROR = -2; Z_DATA_ERROR = -3; Z_MEM_ERROR = -4; Z_BUF_ERROR = -5; Z_VERSION_ERROR = -6; Z_NO_COMPRESSION = 0; Z_BEST_SPEED = 1; Z_BEST_COMPRESSION = 9; Z_DEFAULT_COMPRESSION = -1; Z_FILTERED = 1; Z_HUFFMAN_ONLY = 2; Z_RLE = 3; Z_DEFAULT_STRATEGY = 0; Z_BINARY = 0; Z_ASCII = 1; Z_UNKNOWN = 2; Z_DEFLATED = 8; (* basic functions *) function zlibVersion: PChar; function deflateInit(var strm: z_stream; level: Integer): Integer; function deflate(var strm: z_stream; flush: Integer): Integer; function deflateEnd(var strm: z_stream): Integer; function inflateInit(var strm: z_stream): Integer; function inflate(var strm: z_stream; flush: Integer): Integer; function inflateEnd(var strm: z_stream): Integer; (* advanced functions *) function deflateInit2(var strm: z_stream; level, method, windowBits, memLevel, strategy: Integer): Integer; function deflateSetDictionary(var strm: z_stream; const dictionary: PChar; dictLength: Integer): Integer; function deflateCopy(var dest, source: z_stream): Integer; function deflateReset(var strm: z_stream): Integer; function deflateParams(var strm: z_stream; level, strategy: Integer): Integer; function deflateBound(var strm: z_stream; sourceLen: LongInt): LongInt; function deflatePrime(var strm: z_stream; bits, value: Integer): Integer; function inflateInit2(var strm: z_stream; windowBits: Integer): Integer; function inflateSetDictionary(var strm: z_stream; const dictionary: PChar; dictLength: Integer): Integer; function inflateSync(var strm: z_stream): Integer; function inflateCopy(var dest, source: z_stream): Integer; function inflateReset(var strm: z_stream): Integer; function inflateBackInit(var strm: z_stream; windowBits: Integer; window: PChar): Integer; function inflateBack(var strm: z_stream; in_fn: in_func; in_desc: Pointer; out_fn: out_func; out_desc: Pointer): Integer; function inflateBackEnd(var strm: z_stream): Integer; function zlibCompileFlags: LongInt; (* utility functions *) function compress(dest: PChar; var destLen: LongInt; const source: PChar; sourceLen: LongInt): Integer; function compress2(dest: PChar; var destLen: LongInt; const source: PChar; sourceLen: LongInt; level: Integer): Integer; function compressBound(sourceLen: LongInt): LongInt; function uncompress(dest: PChar; var destLen: LongInt; const source: PChar; sourceLen: LongInt): Integer; (* checksum functions *) function adler32(adler: LongInt; const buf: PChar; len: Integer): LongInt; function crc32(crc: LongInt; const buf: PChar; len: Integer): LongInt; (* various hacks, don't look :) *) function deflateInit_(var strm: z_stream; level: Integer; const version: PChar; stream_size: Integer): Integer; function inflateInit_(var strm: z_stream; const version: PChar; stream_size: Integer): Integer; function deflateInit2_(var strm: z_stream; level, method, windowBits, memLevel, strategy: Integer; const version: PChar; stream_size: Integer): Integer; function inflateInit2_(var strm: z_stream; windowBits: Integer; const version: PChar; stream_size: Integer): Integer; function inflateBackInit_(var strm: z_stream; windowBits: Integer; window: PChar; const version: PChar; stream_size: Integer): Integer; implementation {$L adler32.obj} {$L compress.obj} {$L crc32.obj} {$L deflate.obj} {$L infback.obj} {$L inffast.obj} {$L inflate.obj} {$L inftrees.obj} {$L trees.obj} {$L uncompr.obj} {$L zutil.obj} function adler32; external; function compress; external; function compress2; external; function compressBound; external; function crc32; external; function deflate; external; function deflateBound; external; function deflateCopy; external; function deflateEnd; external; function deflateInit_; external; function deflateInit2_; external; function deflateParams; external; function deflatePrime; external; function deflateReset; external; function deflateSetDictionary; external; function inflate; external; function inflateBack; external; function inflateBackEnd; external; function inflateBackInit_; external; function inflateCopy; external; function inflateEnd; external; function inflateInit_; external; function inflateInit2_; external; function inflateReset; external; function inflateSetDictionary; external; function inflateSync; external; function uncompress; external; function zlibCompileFlags; external; function zlibVersion; external; function deflateInit(var strm: z_stream; level: Integer): Integer; begin Result := deflateInit_(strm, level, ZLIB_VERSION, sizeof(z_stream)); end; function deflateInit2(var strm: z_stream; level, method, windowBits, memLevel, strategy: Integer): Integer; begin Result := deflateInit2_(strm, level, method, windowBits, memLevel, strategy, ZLIB_VERSION, sizeof(z_stream)); end; function inflateInit(var strm: z_stream): Integer; begin Result := inflateInit_(strm, ZLIB_VERSION, sizeof(z_stream)); end; function inflateInit2(var strm: z_stream; windowBits: Integer): Integer; begin Result := inflateInit2_(strm, windowBits, ZLIB_VERSION, sizeof(z_stream)); end; function inflateBackInit(var strm: z_stream; windowBits: Integer; window: PChar): Integer; begin Result := inflateBackInit_(strm, windowBits, window, ZLIB_VERSION, sizeof(z_stream)); end; function _malloc(Size: Integer): Pointer; cdecl; begin GetMem(Result, Size); end; procedure _free(Block: Pointer); cdecl; begin FreeMem(Block); end; procedure _memset(P: Pointer; B: Byte; count: Integer); cdecl; begin FillChar(P^, count, B); end; procedure _memcpy(dest, source: Pointer; count: Integer); cdecl; begin Move(source^, dest^, count); end; end. sks-ecc-0.93/zlib/contrib/pascal/zlibd32.mak0000644000175000017500000000412510604550750017551 0ustar nachonacho# Makefile for zlib # For use with Delphi and C++ Builder under Win32 # Updated for zlib 1.2.x by Cosmin Truta # ------------ Borland C++ ------------ # This project uses the Delphi (fastcall/register) calling convention: LOC = -DZEXPORT=__fastcall -DZEXPORTVA=__cdecl CC = bcc32 LD = bcc32 AR = tlib # do not use "-pr" in CFLAGS CFLAGS = -a -d -k- -O2 $(LOC) LDFLAGS = # variables ZLIB_LIB = zlib.lib OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj # targets all: $(ZLIB_LIB) example.exe minigzip.exe .c.obj: $(CC) -c $(CFLAGS) $*.c adler32.obj: adler32.c zlib.h zconf.h compress.obj: compress.c zlib.h zconf.h crc32.obj: crc32.c zlib.h zconf.h crc32.h deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h gzio.obj: gzio.c zutil.h zlib.h zconf.h infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inffixed.h inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inffixed.h inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h uncompr.obj: uncompr.c zlib.h zconf.h zutil.obj: zutil.c zutil.h zlib.h zconf.h example.obj: example.c zlib.h zconf.h minigzip.obj: minigzip.c zlib.h zconf.h # For the sake of the old Borland make, # the command line is cut to fit in the MS-DOS 128 byte limit: $(ZLIB_LIB): $(OBJ1) $(OBJ2) -del $(ZLIB_LIB) $(AR) $(ZLIB_LIB) $(OBJP1) $(AR) $(ZLIB_LIB) $(OBJP2) # testing test: example.exe minigzip.exe example echo hello world | minigzip | minigzip -d example.exe: example.obj $(ZLIB_LIB) $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) minigzip.exe: minigzip.obj $(ZLIB_LIB) $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) # cleanup clean: -del *.obj -del *.exe -del *.lib -del *.tds -del zlib.bak -del foo.gz sks-ecc-0.93/zlib/contrib/iostream3/0000755000175000017500000000000010604550750016247 5ustar nachonachosks-ecc-0.93/zlib/contrib/iostream3/zfstream.cc0000644000175000017500000003220710604550750020415 0ustar nachonacho/* * A C++ I/O streams interface to the zlib gz* functions * * by Ludwig Schwardt * original version by Kevin Ruland * * This version is standard-compliant and compatible with gcc 3.x. */ #include "zfstream.h" #include // for strcpy, strcat, strlen (mode strings) #include // for BUFSIZ // Internal buffer sizes (default and "unbuffered" versions) #define BIGBUFSIZE BUFSIZ #define SMALLBUFSIZE 1 /*****************************************************************************/ // Default constructor gzfilebuf::gzfilebuf() : file(NULL), io_mode(std::ios_base::openmode(0)), own_fd(false), buffer(NULL), buffer_size(BIGBUFSIZE), own_buffer(true) { // No buffers to start with this->disable_buffer(); } // Destructor gzfilebuf::~gzfilebuf() { // Sync output buffer and close only if responsible for file // (i.e. attached streams should be left open at this stage) this->sync(); if (own_fd) this->close(); // Make sure internal buffer is deallocated this->disable_buffer(); } // Set compression level and strategy int gzfilebuf::setcompression(int comp_level, int comp_strategy) { return gzsetparams(file, comp_level, comp_strategy); } // Open gzipped file gzfilebuf* gzfilebuf::open(const char *name, std::ios_base::openmode mode) { // Fail if file already open if (this->is_open()) return NULL; // Don't support simultaneous read/write access (yet) if ((mode & std::ios_base::in) && (mode & std::ios_base::out)) return NULL; // Build mode string for gzopen and check it [27.8.1.3.2] char char_mode[6] = "\0\0\0\0\0"; if (!this->open_mode(mode, char_mode)) return NULL; // Attempt to open file if ((file = gzopen(name, char_mode)) == NULL) return NULL; // On success, allocate internal buffer and set flags this->enable_buffer(); io_mode = mode; own_fd = true; return this; } // Attach to gzipped file gzfilebuf* gzfilebuf::attach(int fd, std::ios_base::openmode mode) { // Fail if file already open if (this->is_open()) return NULL; // Don't support simultaneous read/write access (yet) if ((mode & std::ios_base::in) && (mode & std::ios_base::out)) return NULL; // Build mode string for gzdopen and check it [27.8.1.3.2] char char_mode[6] = "\0\0\0\0\0"; if (!this->open_mode(mode, char_mode)) return NULL; // Attempt to attach to file if ((file = gzdopen(fd, char_mode)) == NULL) return NULL; // On success, allocate internal buffer and set flags this->enable_buffer(); io_mode = mode; own_fd = false; return this; } // Close gzipped file gzfilebuf* gzfilebuf::close() { // Fail immediately if no file is open if (!this->is_open()) return NULL; // Assume success gzfilebuf* retval = this; // Attempt to sync and close gzipped file if (this->sync() == -1) retval = NULL; if (gzclose(file) < 0) retval = NULL; // File is now gone anyway (postcondition [27.8.1.3.8]) file = NULL; own_fd = false; // Destroy internal buffer if it exists this->disable_buffer(); return retval; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ // Convert int open mode to mode string bool gzfilebuf::open_mode(std::ios_base::openmode mode, char* c_mode) const { bool testb = mode & std::ios_base::binary; bool testi = mode & std::ios_base::in; bool testo = mode & std::ios_base::out; bool testt = mode & std::ios_base::trunc; bool testa = mode & std::ios_base::app; // Check for valid flag combinations - see [27.8.1.3.2] (Table 92) // Original zfstream hardcoded the compression level to maximum here... // Double the time for less than 1% size improvement seems // excessive though - keeping it at the default level // To change back, just append "9" to the next three mode strings if (!testi && testo && !testt && !testa) strcpy(c_mode, "w"); if (!testi && testo && !testt && testa) strcpy(c_mode, "a"); if (!testi && testo && testt && !testa) strcpy(c_mode, "w"); if (testi && !testo && !testt && !testa) strcpy(c_mode, "r"); // No read/write mode yet // if (testi && testo && !testt && !testa) // strcpy(c_mode, "r+"); // if (testi && testo && testt && !testa) // strcpy(c_mode, "w+"); // Mode string should be empty for invalid combination of flags if (strlen(c_mode) == 0) return false; if (testb) strcat(c_mode, "b"); return true; } // Determine number of characters in internal get buffer std::streamsize gzfilebuf::showmanyc() { // Calls to underflow will fail if file not opened for reading if (!this->is_open() || !(io_mode & std::ios_base::in)) return -1; // Make sure get area is in use if (this->gptr() && (this->gptr() < this->egptr())) return std::streamsize(this->egptr() - this->gptr()); else return 0; } // Fill get area from gzipped file gzfilebuf::int_type gzfilebuf::underflow() { // If something is left in the get area by chance, return it // (this shouldn't normally happen, as underflow is only supposed // to be called when gptr >= egptr, but it serves as error check) if (this->gptr() && (this->gptr() < this->egptr())) return traits_type::to_int_type(*(this->gptr())); // If the file hasn't been opened for reading, produce error if (!this->is_open() || !(io_mode & std::ios_base::in)) return traits_type::eof(); // Attempt to fill internal buffer from gzipped file // (buffer must be guaranteed to exist...) int bytes_read = gzread(file, buffer, buffer_size); // Indicates error or EOF if (bytes_read <= 0) { // Reset get area this->setg(buffer, buffer, buffer); return traits_type::eof(); } // Make all bytes read from file available as get area this->setg(buffer, buffer, buffer + bytes_read); // Return next character in get area return traits_type::to_int_type(*(this->gptr())); } // Write put area to gzipped file gzfilebuf::int_type gzfilebuf::overflow(int_type c) { // Determine whether put area is in use if (this->pbase()) { // Double-check pointer range if (this->pptr() > this->epptr() || this->pptr() < this->pbase()) return traits_type::eof(); // Add extra character to buffer if not EOF if (!traits_type::eq_int_type(c, traits_type::eof())) { *(this->pptr()) = traits_type::to_char_type(c); this->pbump(1); } // Number of characters to write to file int bytes_to_write = this->pptr() - this->pbase(); // Overflow doesn't fail if nothing is to be written if (bytes_to_write > 0) { // If the file hasn't been opened for writing, produce error if (!this->is_open() || !(io_mode & std::ios_base::out)) return traits_type::eof(); // If gzipped file won't accept all bytes written to it, fail if (gzwrite(file, this->pbase(), bytes_to_write) != bytes_to_write) return traits_type::eof(); // Reset next pointer to point to pbase on success this->pbump(-bytes_to_write); } } // Write extra character to file if not EOF else if (!traits_type::eq_int_type(c, traits_type::eof())) { // If the file hasn't been opened for writing, produce error if (!this->is_open() || !(io_mode & std::ios_base::out)) return traits_type::eof(); // Impromptu char buffer (allows "unbuffered" output) char_type last_char = traits_type::to_char_type(c); // If gzipped file won't accept this character, fail if (gzwrite(file, &last_char, 1) != 1) return traits_type::eof(); } // If you got here, you have succeeded (even if c was EOF) // The return value should therefore be non-EOF if (traits_type::eq_int_type(c, traits_type::eof())) return traits_type::not_eof(c); else return c; } // Assign new buffer std::streambuf* gzfilebuf::setbuf(char_type* p, std::streamsize n) { // First make sure stuff is sync'ed, for safety if (this->sync() == -1) return NULL; // If buffering is turned off on purpose via setbuf(0,0), still allocate one... // "Unbuffered" only really refers to put [27.8.1.4.10], while get needs at // least a buffer of size 1 (very inefficient though, therefore make it bigger?) // This follows from [27.5.2.4.3]/12 (gptr needs to point at something, it seems) if (!p || !n) { // Replace existing buffer (if any) with small internal buffer this->disable_buffer(); buffer = NULL; buffer_size = 0; own_buffer = true; this->enable_buffer(); } else { // Replace existing buffer (if any) with external buffer this->disable_buffer(); buffer = p; buffer_size = n; own_buffer = false; this->enable_buffer(); } return this; } // Write put area to gzipped file (i.e. ensures that put area is empty) int gzfilebuf::sync() { return traits_type::eq_int_type(this->overflow(), traits_type::eof()) ? -1 : 0; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ // Allocate internal buffer void gzfilebuf::enable_buffer() { // If internal buffer required, allocate one if (own_buffer && !buffer) { // Check for buffered vs. "unbuffered" if (buffer_size > 0) { // Allocate internal buffer buffer = new char_type[buffer_size]; // Get area starts empty and will be expanded by underflow as need arises this->setg(buffer, buffer, buffer); // Setup entire internal buffer as put area. // The one-past-end pointer actually points to the last element of the buffer, // so that overflow(c) can safely add the extra character c to the sequence. // These pointers remain in place for the duration of the buffer this->setp(buffer, buffer + buffer_size - 1); } else { // Even in "unbuffered" case, (small?) get buffer is still required buffer_size = SMALLBUFSIZE; buffer = new char_type[buffer_size]; this->setg(buffer, buffer, buffer); // "Unbuffered" means no put buffer this->setp(0, 0); } } else { // If buffer already allocated, reset buffer pointers just to make sure no // stale chars are lying around this->setg(buffer, buffer, buffer); this->setp(buffer, buffer + buffer_size - 1); } } // Destroy internal buffer void gzfilebuf::disable_buffer() { // If internal buffer exists, deallocate it if (own_buffer && buffer) { // Preserve unbuffered status by zeroing size if (!this->pbase()) buffer_size = 0; delete[] buffer; buffer = NULL; this->setg(0, 0, 0); this->setp(0, 0); } else { // Reset buffer pointers to initial state if external buffer exists this->setg(buffer, buffer, buffer); if (buffer) this->setp(buffer, buffer + buffer_size - 1); else this->setp(0, 0); } } /*****************************************************************************/ // Default constructor initializes stream buffer gzifstream::gzifstream() : std::istream(NULL), sb() { this->init(&sb); } // Initialize stream buffer and open file gzifstream::gzifstream(const char* name, std::ios_base::openmode mode) : std::istream(NULL), sb() { this->init(&sb); this->open(name, mode); } // Initialize stream buffer and attach to file gzifstream::gzifstream(int fd, std::ios_base::openmode mode) : std::istream(NULL), sb() { this->init(&sb); this->attach(fd, mode); } // Open file and go into fail() state if unsuccessful void gzifstream::open(const char* name, std::ios_base::openmode mode) { if (!sb.open(name, mode | std::ios_base::in)) this->setstate(std::ios_base::failbit); else this->clear(); } // Attach to file and go into fail() state if unsuccessful void gzifstream::attach(int fd, std::ios_base::openmode mode) { if (!sb.attach(fd, mode | std::ios_base::in)) this->setstate(std::ios_base::failbit); else this->clear(); } // Close file void gzifstream::close() { if (!sb.close()) this->setstate(std::ios_base::failbit); } /*****************************************************************************/ // Default constructor initializes stream buffer gzofstream::gzofstream() : std::ostream(NULL), sb() { this->init(&sb); } // Initialize stream buffer and open file gzofstream::gzofstream(const char* name, std::ios_base::openmode mode) : std::ostream(NULL), sb() { this->init(&sb); this->open(name, mode); } // Initialize stream buffer and attach to file gzofstream::gzofstream(int fd, std::ios_base::openmode mode) : std::ostream(NULL), sb() { this->init(&sb); this->attach(fd, mode); } // Open file and go into fail() state if unsuccessful void gzofstream::open(const char* name, std::ios_base::openmode mode) { if (!sb.open(name, mode | std::ios_base::out)) this->setstate(std::ios_base::failbit); else this->clear(); } // Attach to file and go into fail() state if unsuccessful void gzofstream::attach(int fd, std::ios_base::openmode mode) { if (!sb.attach(fd, mode | std::ios_base::out)) this->setstate(std::ios_base::failbit); else this->clear(); } // Close file void gzofstream::close() { if (!sb.close()) this->setstate(std::ios_base::failbit); } sks-ecc-0.93/zlib/contrib/iostream3/README0000644000175000017500000000272210604550750017132 0ustar nachonachoThese classes provide a C++ stream interface to the zlib library. It allows you to do things like: gzofstream outf("blah.gz"); outf << "These go into the gzip file " << 123 << endl; It does this by deriving a specialized stream buffer for gzipped files, which is the way Stroustrup would have done it. :-> The gzifstream and gzofstream classes were originally written by Kevin Ruland and made available in the zlib contrib/iostream directory. The older version still compiles under gcc 2.xx, but not under gcc 3.xx, which sparked the development of this version. The new classes are as standard-compliant as possible, closely following the approach of the standard library's fstream classes. It compiles under gcc versions 3.2 and 3.3, but not under gcc 2.xx. This is mainly due to changes in the standard library naming scheme. The new version of gzifstream/gzofstream/gzfilebuf differs from the previous one in the following respects: - added showmanyc - added setbuf, with support for unbuffered output via setbuf(0,0) - a few bug fixes of stream behavior - gzipped output file opened with default compression level instead of maximum level - setcompressionlevel()/strategy() members replaced by single setcompression() The code is provided "as is", with the permission to use, copy, modify, distribute and sell it for any purpose without fee. Ludwig Schwardt DSP Lab Electrical & Electronic Engineering Department University of Stellenbosch South Africa sks-ecc-0.93/zlib/contrib/iostream3/TODO0000644000175000017500000000075310604550750016744 0ustar nachonachoPossible upgrades to gzfilebuf: - The ability to do putback (e.g. putbackfail) - The ability to seek (zlib supports this, but could be slow/tricky) - Simultaneous read/write access (does it make sense?) - Support for ios_base::ate open mode - Locale support? - Check public interface to see which calls give problems (due to dependence on library internals) - Override operator<<(ostream&, gzfilebuf*) to allow direct copying of stream buffer to stream ( i.e. os << is.rdbuf(); ) sks-ecc-0.93/zlib/contrib/iostream3/zfstream.h0000644000175000017500000002772010604550750020263 0ustar nachonacho/* * A C++ I/O streams interface to the zlib gz* functions * * by Ludwig Schwardt * original version by Kevin Ruland * * This version is standard-compliant and compatible with gcc 3.x. */ #ifndef ZFSTREAM_H #define ZFSTREAM_H #include // not iostream, since we don't need cin/cout #include #include "zlib.h" /*****************************************************************************/ /** * @brief Gzipped file stream buffer class. * * This class implements basic_filebuf for gzipped files. It doesn't yet support * seeking (allowed by zlib but slow/limited), putback and read/write access * (tricky). Otherwise, it attempts to be a drop-in replacement for the standard * file streambuf. */ class gzfilebuf : public std::streambuf { public: // Default constructor. gzfilebuf(); // Destructor. virtual ~gzfilebuf(); /** * @brief Set compression level and strategy on the fly. * @param comp_level Compression level (see zlib.h for allowed values) * @param comp_strategy Compression strategy (see zlib.h for allowed values) * @return Z_OK on success, Z_STREAM_ERROR otherwise. * * Unfortunately, these parameters cannot be modified separately, as the * previous zfstream version assumed. Since the strategy is seldom changed, * it can default and setcompression(level) then becomes like the old * setcompressionlevel(level). */ int setcompression(int comp_level, int comp_strategy = Z_DEFAULT_STRATEGY); /** * @brief Check if file is open. * @return True if file is open. */ bool is_open() const { return (file != NULL); } /** * @brief Open gzipped file. * @param name File name. * @param mode Open mode flags. * @return @c this on success, NULL on failure. */ gzfilebuf* open(const char* name, std::ios_base::openmode mode); /** * @brief Attach to already open gzipped file. * @param fd File descriptor. * @param mode Open mode flags. * @return @c this on success, NULL on failure. */ gzfilebuf* attach(int fd, std::ios_base::openmode mode); /** * @brief Close gzipped file. * @return @c this on success, NULL on failure. */ gzfilebuf* close(); protected: /** * @brief Convert ios open mode int to mode string used by zlib. * @return True if valid mode flag combination. */ bool open_mode(std::ios_base::openmode mode, char* c_mode) const; /** * @brief Number of characters available in stream buffer. * @return Number of characters. * * This indicates number of characters in get area of stream buffer. * These characters can be read without accessing the gzipped file. */ virtual std::streamsize showmanyc(); /** * @brief Fill get area from gzipped file. * @return First character in get area on success, EOF on error. * * This actually reads characters from gzipped file to stream * buffer. Always buffered. */ virtual int_type underflow(); /** * @brief Write put area to gzipped file. * @param c Extra character to add to buffer contents. * @return Non-EOF on success, EOF on error. * * This actually writes characters in stream buffer to * gzipped file. With unbuffered output this is done one * character at a time. */ virtual int_type overflow(int_type c = traits_type::eof()); /** * @brief Installs external stream buffer. * @param p Pointer to char buffer. * @param n Size of external buffer. * @return @c this on success, NULL on failure. * * Call setbuf(0,0) to enable unbuffered output. */ virtual std::streambuf* setbuf(char_type* p, std::streamsize n); /** * @brief Flush stream buffer to file. * @return 0 on success, -1 on error. * * This calls underflow(EOF) to do the job. */ virtual int sync(); // // Some future enhancements // // virtual int_type uflow(); // virtual int_type pbackfail(int_type c = traits_type::eof()); // virtual pos_type // seekoff(off_type off, // std::ios_base::seekdir way, // std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out); // virtual pos_type // seekpos(pos_type sp, // std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out); private: /** * @brief Allocate internal buffer. * * This function is safe to call multiple times. It will ensure * that a proper internal buffer exists if it is required. If the * buffer already exists or is external, the buffer pointers will be * reset to their original state. */ void enable_buffer(); /** * @brief Destroy internal buffer. * * This function is safe to call multiple times. It will ensure * that the internal buffer is deallocated if it exists. In any * case, it will also reset the buffer pointers. */ void disable_buffer(); /** * Underlying file pointer. */ gzFile file; /** * Mode in which file was opened. */ std::ios_base::openmode io_mode; /** * @brief True if this object owns file descriptor. * * This makes the class responsible for closing the file * upon destruction. */ bool own_fd; /** * @brief Stream buffer. * * For simplicity this remains allocated on the free store for the * entire life span of the gzfilebuf object, unless replaced by setbuf. */ char_type* buffer; /** * @brief Stream buffer size. * * Defaults to system default buffer size (typically 8192 bytes). * Modified by setbuf. */ std::streamsize buffer_size; /** * @brief True if this object owns stream buffer. * * This makes the class responsible for deleting the buffer * upon destruction. */ bool own_buffer; }; /*****************************************************************************/ /** * @brief Gzipped file input stream class. * * This class implements ifstream for gzipped files. Seeking and putback * is not supported yet. */ class gzifstream : public std::istream { public: // Default constructor gzifstream(); /** * @brief Construct stream on gzipped file to be opened. * @param name File name. * @param mode Open mode flags (forced to contain ios::in). */ explicit gzifstream(const char* name, std::ios_base::openmode mode = std::ios_base::in); /** * @brief Construct stream on already open gzipped file. * @param fd File descriptor. * @param mode Open mode flags (forced to contain ios::in). */ explicit gzifstream(int fd, std::ios_base::openmode mode = std::ios_base::in); /** * Obtain underlying stream buffer. */ gzfilebuf* rdbuf() const { return const_cast(&sb); } /** * @brief Check if file is open. * @return True if file is open. */ bool is_open() { return sb.is_open(); } /** * @brief Open gzipped file. * @param name File name. * @param mode Open mode flags (forced to contain ios::in). * * Stream will be in state good() if file opens successfully; * otherwise in state fail(). This differs from the behavior of * ifstream, which never sets the state to good() and therefore * won't allow you to reuse the stream for a second file unless * you manually clear() the state. The choice is a matter of * convenience. */ void open(const char* name, std::ios_base::openmode mode = std::ios_base::in); /** * @brief Attach to already open gzipped file. * @param fd File descriptor. * @param mode Open mode flags (forced to contain ios::in). * * Stream will be in state good() if attach succeeded; otherwise * in state fail(). */ void attach(int fd, std::ios_base::openmode mode = std::ios_base::in); /** * @brief Close gzipped file. * * Stream will be in state fail() if close failed. */ void close(); private: /** * Underlying stream buffer. */ gzfilebuf sb; }; /*****************************************************************************/ /** * @brief Gzipped file output stream class. * * This class implements ofstream for gzipped files. Seeking and putback * is not supported yet. */ class gzofstream : public std::ostream { public: // Default constructor gzofstream(); /** * @brief Construct stream on gzipped file to be opened. * @param name File name. * @param mode Open mode flags (forced to contain ios::out). */ explicit gzofstream(const char* name, std::ios_base::openmode mode = std::ios_base::out); /** * @brief Construct stream on already open gzipped file. * @param fd File descriptor. * @param mode Open mode flags (forced to contain ios::out). */ explicit gzofstream(int fd, std::ios_base::openmode mode = std::ios_base::out); /** * Obtain underlying stream buffer. */ gzfilebuf* rdbuf() const { return const_cast(&sb); } /** * @brief Check if file is open. * @return True if file is open. */ bool is_open() { return sb.is_open(); } /** * @brief Open gzipped file. * @param name File name. * @param mode Open mode flags (forced to contain ios::out). * * Stream will be in state good() if file opens successfully; * otherwise in state fail(). This differs from the behavior of * ofstream, which never sets the state to good() and therefore * won't allow you to reuse the stream for a second file unless * you manually clear() the state. The choice is a matter of * convenience. */ void open(const char* name, std::ios_base::openmode mode = std::ios_base::out); /** * @brief Attach to already open gzipped file. * @param fd File descriptor. * @param mode Open mode flags (forced to contain ios::out). * * Stream will be in state good() if attach succeeded; otherwise * in state fail(). */ void attach(int fd, std::ios_base::openmode mode = std::ios_base::out); /** * @brief Close gzipped file. * * Stream will be in state fail() if close failed. */ void close(); private: /** * Underlying stream buffer. */ gzfilebuf sb; }; /*****************************************************************************/ /** * @brief Gzipped file output stream manipulator class. * * This class defines a two-argument manipulator for gzofstream. It is used * as base for the setcompression(int,int) manipulator. */ template class gzomanip2 { public: // Allows insertor to peek at internals template friend gzofstream& operator<<(gzofstream&, const gzomanip2&); // Constructor gzomanip2(gzofstream& (*f)(gzofstream&, T1, T2), T1 v1, T2 v2); private: // Underlying manipulator function gzofstream& (*func)(gzofstream&, T1, T2); // Arguments for manipulator function T1 val1; T2 val2; }; /*****************************************************************************/ // Manipulator function thunks through to stream buffer inline gzofstream& setcompression(gzofstream &gzs, int l, int s = Z_DEFAULT_STRATEGY) { (gzs.rdbuf())->setcompression(l, s); return gzs; } // Manipulator constructor stores arguments template inline gzomanip2::gzomanip2(gzofstream &(*f)(gzofstream &, T1, T2), T1 v1, T2 v2) : func(f), val1(v1), val2(v2) { } // Insertor applies underlying manipulator function to stream template inline gzofstream& operator<<(gzofstream& s, const gzomanip2& m) { return (*m.func)(s, m.val1, m.val2); } // Insert this onto stream to simplify setting of compression level inline gzomanip2 setcompression(int l, int s = Z_DEFAULT_STRATEGY) { return gzomanip2(&setcompression, l, s); } #endif // ZFSTREAM_H sks-ecc-0.93/zlib/contrib/iostream3/test.cc0000644000175000017500000000272210604550750017540 0ustar nachonacho/* * Test program for gzifstream and gzofstream * * by Ludwig Schwardt * original version by Kevin Ruland */ #include "zfstream.h" #include // for cout int main() { gzofstream outf; gzifstream inf; char buf[80]; outf.open("test1.txt.gz"); outf << "The quick brown fox sidestepped the lazy canine\n" << 1.3 << "\nPlan " << 9 << std::endl; outf.close(); std::cout << "Wrote the following message to 'test1.txt.gz' (check with zcat or zless):\n" << "The quick brown fox sidestepped the lazy canine\n" << 1.3 << "\nPlan " << 9 << std::endl; std::cout << "\nReading 'test1.txt.gz' (buffered) produces:\n"; inf.open("test1.txt.gz"); while (inf.getline(buf,80,'\n')) { std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n"; } inf.close(); outf.rdbuf()->pubsetbuf(0,0); outf.open("test2.txt.gz"); outf << setcompression(Z_NO_COMPRESSION) << "The quick brown fox sidestepped the lazy canine\n" << 1.3 << "\nPlan " << 9 << std::endl; outf.close(); std::cout << "\nWrote the same message to 'test2.txt.gz' in uncompressed form"; std::cout << "\nReading 'test2.txt.gz' (unbuffered) produces:\n"; inf.rdbuf()->pubsetbuf(0,0); inf.open("test2.txt.gz"); while (inf.getline(buf,80,'\n')) { std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n"; } inf.close(); return 0; } sks-ecc-0.93/zlib/contrib/infback9/0000755000175000017500000000000010604550750016027 5ustar nachonachosks-ecc-0.93/zlib/contrib/infback9/README0000644000175000017500000000006310604550750016706 0ustar nachonachoSee infback9.h for what this is and how to use it. sks-ecc-0.93/zlib/contrib/infback9/inftree9.h0000644000175000017500000000450610604550750017732 0ustar nachonacho/* inftree9.h -- header to use inftree9.c * Copyright (C) 1995-2003 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ /* Structure for decoding tables. Each entry provides either the information needed to do the operation requested by the code that indexed that table entry, or it provides a pointer to another table that indexes more bits of the code. op indicates whether the entry is a pointer to another table, a literal, a length or distance, an end-of-block, or an invalid code. For a table pointer, the low four bits of op is the number of index bits of that table. For a length or distance, the low four bits of op is the number of extra bits to get after the code. bits is the number of bits in this code or part of the code to drop off of the bit buffer. val is the actual byte to output in the case of a literal, the base length or distance, or the offset from the current table to the next table. Each entry is four bytes. */ typedef struct { unsigned char op; /* operation, extra bits, table bits */ unsigned char bits; /* bits in this part of the code */ unsigned short val; /* offset in table or code value */ } code; /* op values as set by inflate_table(): 00000000 - literal 0000tttt - table link, tttt != 0 is the number of table index bits 100eeeee - length or distance, eeee is the number of extra bits 01100000 - end of block 01000000 - invalid code */ /* Maximum size of dynamic tree. The maximum found in a long but non- exhaustive search was 1444 code structures (852 for length/literals and 592 for distances, the latter actually the result of an exhaustive search). The true maximum is not known, but the value below is more than safe. */ #define ENOUGH 2048 #define MAXD 592 /* Type of code to build for inftable() */ typedef enum { CODES, LENS, DISTS } codetype; extern int inflate_table9 OF((codetype type, unsigned short FAR *lens, unsigned codes, code FAR * FAR *table, unsigned FAR *bits, unsigned short FAR *work)); sks-ecc-0.93/zlib/contrib/infback9/infback9.h0000644000175000017500000000307210604550750017670 0ustar nachonacho/* infback9.h -- header for using inflateBack9 functions * Copyright (C) 2003 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* * This header file and associated patches provide a decoder for PKWare's * undocumented deflate64 compression method (method 9). Use with infback9.c, * inftree9.h, inftree9.c, and inffix9.h. These patches are not supported. * This should be compiled with zlib, since it uses zutil.h and zutil.o. * This code has not yet been tested on 16-bit architectures. See the * comments in zlib.h for inflateBack() usage. These functions are used * identically, except that there is no windowBits parameter, and a 64K * window must be provided. Also if int's are 16 bits, then a zero for * the third parameter of the "out" function actually means 65536UL. * zlib.h must be included before this header file. */ #ifdef __cplusplus extern "C" { #endif ZEXTERN int ZEXPORT inflateBack9 OF((z_stream FAR *strm, in_func in, void FAR *in_desc, out_func out, void FAR *out_desc)); ZEXTERN int ZEXPORT inflateBack9End OF((z_stream FAR *strm)); ZEXTERN int ZEXPORT inflateBack9Init_ OF((z_stream FAR *strm, unsigned char FAR *window, const char *version, int stream_size)); #define inflateBack9Init(strm, window) \ inflateBack9Init_((strm), (window), \ ZLIB_VERSION, sizeof(z_stream)) #ifdef __cplusplus } #endif sks-ecc-0.93/zlib/contrib/infback9/infback9.c0000644000175000017500000005137210604550750017671 0ustar nachonacho/* infback9.c -- inflate deflate64 data using a call-back interface * Copyright (C) 1995-2003 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "zutil.h" #include "infback9.h" #include "inftree9.h" #include "inflate9.h" #define WSIZE 65536UL /* strm provides memory allocation functions in zalloc and zfree, or Z_NULL to use the library memory allocation functions. window is a user-supplied window and output buffer that is 64K bytes. */ int ZEXPORT inflateBack9Init_(strm, window, version, stream_size) z_stream FAR *strm; unsigned char FAR *window; const char *version; int stream_size; { struct inflate_state FAR *state; if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || stream_size != (int)(sizeof(z_stream))) return Z_VERSION_ERROR; if (strm == Z_NULL || window == Z_NULL) return Z_STREAM_ERROR; strm->msg = Z_NULL; /* in case we return an error */ if (strm->zalloc == (alloc_func)0) { strm->zalloc = zcalloc; strm->opaque = (voidpf)0; } if (strm->zfree == (free_func)0) strm->zfree = zcfree; state = (struct inflate_state FAR *)ZALLOC(strm, 1, sizeof(struct inflate_state)); if (state == Z_NULL) return Z_MEM_ERROR; Tracev((stderr, "inflate: allocated\n")); strm->state = (voidpf)state; state->window = window; return Z_OK; } /* Build and output length and distance decoding tables for fixed code decoding. */ #ifdef MAKEFIXED #include void makefixed9(void) { unsigned sym, bits, low, size; code *next, *lenfix, *distfix; struct inflate_state state; code fixed[544]; /* literal/length table */ sym = 0; while (sym < 144) state.lens[sym++] = 8; while (sym < 256) state.lens[sym++] = 9; while (sym < 280) state.lens[sym++] = 7; while (sym < 288) state.lens[sym++] = 8; next = fixed; lenfix = next; bits = 9; inflate_table9(LENS, state.lens, 288, &(next), &(bits), state.work); /* distance table */ sym = 0; while (sym < 32) state.lens[sym++] = 5; distfix = next; bits = 5; inflate_table9(DISTS, state.lens, 32, &(next), &(bits), state.work); /* write tables */ puts(" /* inffix9.h -- table for decoding deflate64 fixed codes"); puts(" * Generated automatically by makefixed9()."); puts(" */"); puts(""); puts(" /* WARNING: this file should *not* be used by applications."); puts(" It is part of the implementation of this library and is"); puts(" subject to change. Applications should only use zlib.h."); puts(" */"); puts(""); size = 1U << 9; printf(" static const code lenfix[%u] = {", size); low = 0; for (;;) { if ((low % 6) == 0) printf("\n "); printf("{%u,%u,%d}", lenfix[low].op, lenfix[low].bits, lenfix[low].val); if (++low == size) break; putchar(','); } puts("\n };"); size = 1U << 5; printf("\n static const code distfix[%u] = {", size); low = 0; for (;;) { if ((low % 5) == 0) printf("\n "); printf("{%u,%u,%d}", distfix[low].op, distfix[low].bits, distfix[low].val); if (++low == size) break; putchar(','); } puts("\n };"); } #endif /* MAKEFIXED */ /* Macros for inflateBack(): */ /* Clear the input bit accumulator */ #define INITBITS() \ do { \ hold = 0; \ bits = 0; \ } while (0) /* Assure that some input is available. If input is requested, but denied, then return a Z_BUF_ERROR from inflateBack(). */ #define PULL() \ do { \ if (have == 0) { \ have = in(in_desc, &next); \ if (have == 0) { \ next = Z_NULL; \ ret = Z_BUF_ERROR; \ goto inf_leave; \ } \ } \ } while (0) /* Get a byte of input into the bit accumulator, or return from inflateBack() with an error if there is no input available. */ #define PULLBYTE() \ do { \ PULL(); \ have--; \ hold += (unsigned long)(*next++) << bits; \ bits += 8; \ } while (0) /* Assure that there are at least n bits in the bit accumulator. If there is not enough available input to do that, then return from inflateBack() with an error. */ #define NEEDBITS(n) \ do { \ while (bits < (unsigned)(n)) \ PULLBYTE(); \ } while (0) /* Return the low n bits of the bit accumulator (n <= 16) */ #define BITS(n) \ ((unsigned)hold & ((1U << (n)) - 1)) /* Remove n bits from the bit accumulator */ #define DROPBITS(n) \ do { \ hold >>= (n); \ bits -= (unsigned)(n); \ } while (0) /* Remove zero to seven bits as needed to go to a byte boundary */ #define BYTEBITS() \ do { \ hold >>= bits & 7; \ bits -= bits & 7; \ } while (0) /* Assure that some output space is available, by writing out the window if it's full. If the write fails, return from inflateBack() with a Z_BUF_ERROR. */ #define ROOM() \ do { \ if (left == 0) { \ put = window; \ left = WSIZE; \ wrap = 1; \ if (out(out_desc, put, (unsigned)left)) { \ ret = Z_BUF_ERROR; \ goto inf_leave; \ } \ } \ } while (0) /* strm provides the memory allocation functions and window buffer on input, and provides information on the unused input on return. For Z_DATA_ERROR returns, strm will also provide an error message. in() and out() are the call-back input and output functions. When inflateBack() needs more input, it calls in(). When inflateBack() has filled the window with output, or when it completes with data in the window, it calls out() to write out the data. The application must not change the provided input until in() is called again or inflateBack() returns. The application must not change the window/output buffer until inflateBack() returns. in() and out() are called with a descriptor parameter provided in the inflateBack() call. This parameter can be a structure that provides the information required to do the read or write, as well as accumulated information on the input and output such as totals and check values. in() should return zero on failure. out() should return non-zero on failure. If either in() or out() fails, than inflateBack() returns a Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it was in() or out() that caused in the error. Otherwise, inflateBack() returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format error, or Z_MEM_ERROR if it could not allocate memory for the state. inflateBack() can also return Z_STREAM_ERROR if the input parameters are not correct, i.e. strm is Z_NULL or the state was not initialized. */ int ZEXPORT inflateBack9(strm, in, in_desc, out, out_desc) z_stream FAR *strm; in_func in; void FAR *in_desc; out_func out; void FAR *out_desc; { struct inflate_state FAR *state; unsigned char FAR *next; /* next input */ unsigned char FAR *put; /* next output */ unsigned have; /* available input */ unsigned long left; /* available output */ inflate_mode mode; /* current inflate mode */ int lastblock; /* true if processing last block */ int wrap; /* true if the window has wrapped */ unsigned long write; /* window write index */ unsigned char FAR *window; /* allocated sliding window, if needed */ unsigned long hold; /* bit buffer */ unsigned bits; /* bits in bit buffer */ unsigned extra; /* extra bits needed */ unsigned long length; /* literal or length of data to copy */ unsigned long offset; /* distance back to copy string from */ unsigned long copy; /* number of stored or match bytes to copy */ unsigned char FAR *from; /* where to copy match bytes from */ code const FAR *lencode; /* starting table for length/literal codes */ code const FAR *distcode; /* starting table for distance codes */ unsigned lenbits; /* index bits for lencode */ unsigned distbits; /* index bits for distcode */ code this; /* current decoding table entry */ code last; /* parent table entry */ unsigned len; /* length to copy for repeats, bits to drop */ int ret; /* return code */ static const unsigned short order[19] = /* permutation of code lengths */ {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; #include "inffix9.h" /* Check that the strm exists and that the state was initialized */ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; /* Reset the state */ strm->msg = Z_NULL; mode = TYPE; lastblock = 0; write = 0; wrap = 0; window = state->window; next = strm->next_in; have = next != Z_NULL ? strm->avail_in : 0; hold = 0; bits = 0; put = window; left = WSIZE; lencode = Z_NULL; distcode = Z_NULL; /* Inflate until end of block marked as last */ for (;;) switch (mode) { case TYPE: /* determine and dispatch block type */ if (lastblock) { BYTEBITS(); mode = DONE; break; } NEEDBITS(3); lastblock = BITS(1); DROPBITS(1); switch (BITS(2)) { case 0: /* stored block */ Tracev((stderr, "inflate: stored block%s\n", lastblock ? " (last)" : "")); mode = STORED; break; case 1: /* fixed block */ lencode = lenfix; lenbits = 9; distcode = distfix; distbits = 5; Tracev((stderr, "inflate: fixed codes block%s\n", lastblock ? " (last)" : "")); mode = LEN; /* decode codes */ break; case 2: /* dynamic block */ Tracev((stderr, "inflate: dynamic codes block%s\n", lastblock ? " (last)" : "")); mode = TABLE; break; case 3: strm->msg = (char *)"invalid block type"; mode = BAD; } DROPBITS(2); break; case STORED: /* get and verify stored block length */ BYTEBITS(); /* go to byte boundary */ NEEDBITS(32); if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { strm->msg = (char *)"invalid stored block lengths"; mode = BAD; break; } length = (unsigned)hold & 0xffff; Tracev((stderr, "inflate: stored length %lu\n", length)); INITBITS(); /* copy stored block from input to output */ while (length != 0) { copy = length; PULL(); ROOM(); if (copy > have) copy = have; if (copy > left) copy = left; zmemcpy(put, next, copy); have -= copy; next += copy; left -= copy; put += copy; length -= copy; } Tracev((stderr, "inflate: stored end\n")); mode = TYPE; break; case TABLE: /* get dynamic table entries descriptor */ NEEDBITS(14); state->nlen = BITS(5) + 257; DROPBITS(5); state->ndist = BITS(5) + 1; DROPBITS(5); state->ncode = BITS(4) + 4; DROPBITS(4); if (state->nlen > 286) { strm->msg = (char *)"too many length symbols"; mode = BAD; break; } Tracev((stderr, "inflate: table sizes ok\n")); /* get code length code lengths (not a typo) */ state->have = 0; while (state->have < state->ncode) { NEEDBITS(3); state->lens[order[state->have++]] = (unsigned short)BITS(3); DROPBITS(3); } while (state->have < 19) state->lens[order[state->have++]] = 0; state->next = state->codes; lencode = (code const FAR *)(state->next); lenbits = 7; ret = inflate_table9(CODES, state->lens, 19, &(state->next), &(lenbits), state->work); if (ret) { strm->msg = (char *)"invalid code lengths set"; mode = BAD; break; } Tracev((stderr, "inflate: code lengths ok\n")); /* get length and distance code code lengths */ state->have = 0; while (state->have < state->nlen + state->ndist) { for (;;) { this = lencode[BITS(lenbits)]; if ((unsigned)(this.bits) <= bits) break; PULLBYTE(); } if (this.val < 16) { NEEDBITS(this.bits); DROPBITS(this.bits); state->lens[state->have++] = this.val; } else { if (this.val == 16) { NEEDBITS(this.bits + 2); DROPBITS(this.bits); if (state->have == 0) { strm->msg = (char *)"invalid bit length repeat"; mode = BAD; break; } len = (unsigned)(state->lens[state->have - 1]); copy = 3 + BITS(2); DROPBITS(2); } else if (this.val == 17) { NEEDBITS(this.bits + 3); DROPBITS(this.bits); len = 0; copy = 3 + BITS(3); DROPBITS(3); } else { NEEDBITS(this.bits + 7); DROPBITS(this.bits); len = 0; copy = 11 + BITS(7); DROPBITS(7); } if (state->have + copy > state->nlen + state->ndist) { strm->msg = (char *)"invalid bit length repeat"; mode = BAD; break; } while (copy--) state->lens[state->have++] = (unsigned short)len; } } /* handle error breaks in while */ if (mode == BAD) break; /* build code tables */ state->next = state->codes; lencode = (code const FAR *)(state->next); lenbits = 9; ret = inflate_table9(LENS, state->lens, state->nlen, &(state->next), &(lenbits), state->work); if (ret) { strm->msg = (char *)"invalid literal/lengths set"; mode = BAD; break; } distcode = (code const FAR *)(state->next); distbits = 6; ret = inflate_table9(DISTS, state->lens + state->nlen, state->ndist, &(state->next), &(distbits), state->work); if (ret) { strm->msg = (char *)"invalid distances set"; mode = BAD; break; } Tracev((stderr, "inflate: codes ok\n")); mode = LEN; case LEN: /* get a literal, length, or end-of-block code */ for (;;) { this = lencode[BITS(lenbits)]; if ((unsigned)(this.bits) <= bits) break; PULLBYTE(); } if (this.op && (this.op & 0xf0) == 0) { last = this; for (;;) { this = lencode[last.val + (BITS(last.bits + last.op) >> last.bits)]; if ((unsigned)(last.bits + this.bits) <= bits) break; PULLBYTE(); } DROPBITS(last.bits); } DROPBITS(this.bits); length = (unsigned)this.val; /* process literal */ if (this.op == 0) { Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? "inflate: literal '%c'\n" : "inflate: literal 0x%02x\n", this.val)); ROOM(); *put++ = (unsigned char)(length); left--; mode = LEN; break; } /* process end of block */ if (this.op & 32) { Tracevv((stderr, "inflate: end of block\n")); mode = TYPE; break; } /* invalid code */ if (this.op & 64) { strm->msg = (char *)"invalid literal/length code"; mode = BAD; break; } /* length code -- get extra bits, if any */ extra = (unsigned)(this.op) & 31; if (extra != 0) { NEEDBITS(extra); length += BITS(extra); DROPBITS(extra); } Tracevv((stderr, "inflate: length %lu\n", length)); /* get distance code */ for (;;) { this = distcode[BITS(distbits)]; if ((unsigned)(this.bits) <= bits) break; PULLBYTE(); } if ((this.op & 0xf0) == 0) { last = this; for (;;) { this = distcode[last.val + (BITS(last.bits + last.op) >> last.bits)]; if ((unsigned)(last.bits + this.bits) <= bits) break; PULLBYTE(); } DROPBITS(last.bits); } DROPBITS(this.bits); if (this.op & 64) { strm->msg = (char *)"invalid distance code"; mode = BAD; break; } offset = (unsigned)this.val; /* get distance extra bits, if any */ extra = (unsigned)(this.op) & 15; if (extra != 0) { NEEDBITS(extra); offset += BITS(extra); DROPBITS(extra); } if (offset > WSIZE - (wrap ? 0: left)) { strm->msg = (char *)"invalid distance too far back"; mode = BAD; break; } Tracevv((stderr, "inflate: distance %lu\n", offset)); /* copy match from window to output */ do { ROOM(); copy = WSIZE - offset; if (copy < left) { from = put + copy; copy = left - copy; } else { from = put - offset; copy = left; } if (copy > length) copy = length; length -= copy; left -= copy; do { *put++ = *from++; } while (--copy); } while (length != 0); break; case DONE: /* inflate stream terminated properly -- write leftover output */ ret = Z_STREAM_END; if (left < WSIZE) { if (out(out_desc, window, (unsigned)(WSIZE - left))) ret = Z_BUF_ERROR; } goto inf_leave; case BAD: ret = Z_DATA_ERROR; goto inf_leave; default: /* can't happen, but makes compilers happy */ ret = Z_STREAM_ERROR; goto inf_leave; } /* Return unused input */ inf_leave: strm->next_in = next; strm->avail_in = have; return ret; } int ZEXPORT inflateBack9End(strm) z_stream FAR *strm; { if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) return Z_STREAM_ERROR; ZFREE(strm, strm->state); strm->state = Z_NULL; Tracev((stderr, "inflate: end\n")); return Z_OK; } sks-ecc-0.93/zlib/contrib/infback9/inflate9.h0000644000175000017500000000370710604550750017722 0ustar nachonacho/* inflate9.h -- internal inflate state definition * Copyright (C) 1995-2003 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ /* Possible inflate modes between inflate() calls */ typedef enum { TYPE, /* i: waiting for type bits, including last-flag bit */ STORED, /* i: waiting for stored size (length and complement) */ TABLE, /* i: waiting for dynamic block table lengths */ LEN, /* i: waiting for length/lit code */ DONE, /* finished check, done -- remain here until reset */ BAD /* got a data error -- remain here until reset */ } inflate_mode; /* State transitions between above modes - (most modes can go to the BAD mode -- not shown for clarity) Read deflate blocks: TYPE -> STORED or TABLE or LEN or DONE STORED -> TYPE TABLE -> LENLENS -> CODELENS -> LEN Read deflate codes: LEN -> LEN or TYPE */ /* state maintained between inflate() calls. Approximately 7K bytes. */ struct inflate_state { /* sliding window */ unsigned char FAR *window; /* allocated sliding window, if needed */ /* dynamic table building */ unsigned ncode; /* number of code length code lengths */ unsigned nlen; /* number of length code lengths */ unsigned ndist; /* number of distance code lengths */ unsigned have; /* number of code lengths in lens[] */ code FAR *next; /* next available space in codes[] */ unsigned short lens[320]; /* temporary storage for code lengths */ unsigned short work[288]; /* work area for code table building */ code codes[ENOUGH]; /* space for code tables */ }; sks-ecc-0.93/zlib/contrib/infback9/inftree9.c0000644000175000017500000003213110604550750017720 0ustar nachonacho/* inftree9.c -- generate Huffman trees for efficient decoding * Copyright (C) 1995-2005 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "zutil.h" #include "inftree9.h" #define MAXBITS 15 const char inflate9_copyright[] = " inflate9 1.2.3 Copyright 1995-2005 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot include such an acknowledgment, I would appreciate that you keep this copyright string in the executable of your product. */ /* Build a set of tables to decode the provided canonical Huffman code. The code lengths are lens[0..codes-1]. The result starts at *table, whose indices are 0..2^bits-1. work is a writable array of at least lens shorts, which is used as a work area. type is the type of code to be generated, CODES, LENS, or DISTS. On return, zero is success, -1 is an invalid code, and +1 means that ENOUGH isn't enough. table on return points to the next available entry's address. bits is the requested root table index bits, and on return it is the actual root table index bits. It will differ if the request is greater than the longest code or if it is less than the shortest code. */ int inflate_table9(type, lens, codes, table, bits, work) codetype type; unsigned short FAR *lens; unsigned codes; code FAR * FAR *table; unsigned FAR *bits; unsigned short FAR *work; { unsigned len; /* a code's length in bits */ unsigned sym; /* index of code symbols */ unsigned min, max; /* minimum and maximum code lengths */ unsigned root; /* number of index bits for root table */ unsigned curr; /* number of index bits for current table */ unsigned drop; /* code bits to drop for sub-table */ int left; /* number of prefix codes available */ unsigned used; /* code entries in table used */ unsigned huff; /* Huffman code */ unsigned incr; /* for incrementing code, index */ unsigned fill; /* index for replicating entries */ unsigned low; /* low bits for current root entry */ unsigned mask; /* mask for low root bits */ code this; /* table entry for duplication */ code FAR *next; /* next available space in table */ const unsigned short FAR *base; /* base value table to use */ const unsigned short FAR *extra; /* extra bits table to use */ int end; /* use base and extra for symbol > end */ unsigned short count[MAXBITS+1]; /* number of codes of each length */ unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ static const unsigned short lbase[31] = { /* Length codes 257..285 base */ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 3, 0, 0}; static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, 133, 133, 133, 133, 144, 201, 196}; static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 32769, 49153}; static const unsigned short dext[32] = { /* Distance codes 0..31 extra */ 128, 128, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 135, 136, 136, 137, 137, 138, 138, 139, 139, 140, 140, 141, 141, 142, 142}; /* Process a set of code lengths to create a canonical Huffman code. The code lengths are lens[0..codes-1]. Each length corresponds to the symbols 0..codes-1. The Huffman code is generated by first sorting the symbols by length from short to long, and retaining the symbol order for codes with equal lengths. Then the code starts with all zero bits for the first code of the shortest length, and the codes are integer increments for the same length, and zeros are appended as the length increases. For the deflate format, these bits are stored backwards from their more natural integer increment ordering, and so when the decoding tables are built in the large loop below, the integer codes are incremented backwards. This routine assumes, but does not check, that all of the entries in lens[] are in the range 0..MAXBITS. The caller must assure this. 1..MAXBITS is interpreted as that code length. zero means that that symbol does not occur in this code. The codes are sorted by computing a count of codes for each length, creating from that a table of starting indices for each length in the sorted table, and then entering the symbols in order in the sorted table. The sorted table is work[], with that space being provided by the caller. The length counts are used for other purposes as well, i.e. finding the minimum and maximum length codes, determining if there are any codes at all, checking for a valid set of lengths, and looking ahead at length counts to determine sub-table sizes when building the decoding tables. */ /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ for (len = 0; len <= MAXBITS; len++) count[len] = 0; for (sym = 0; sym < codes; sym++) count[lens[sym]]++; /* bound code lengths, force root to be within code lengths */ root = *bits; for (max = MAXBITS; max >= 1; max--) if (count[max] != 0) break; if (root > max) root = max; if (max == 0) return -1; /* no codes! */ for (min = 1; min <= MAXBITS; min++) if (count[min] != 0) break; if (root < min) root = min; /* check for an over-subscribed or incomplete set of lengths */ left = 1; for (len = 1; len <= MAXBITS; len++) { left <<= 1; left -= count[len]; if (left < 0) return -1; /* over-subscribed */ } if (left > 0 && (type == CODES || max != 1)) return -1; /* incomplete set */ /* generate offsets into symbol table for each length for sorting */ offs[1] = 0; for (len = 1; len < MAXBITS; len++) offs[len + 1] = offs[len] + count[len]; /* sort symbols by length, by symbol order within each length */ for (sym = 0; sym < codes; sym++) if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; /* Create and fill in decoding tables. In this loop, the table being filled is at next and has curr index bits. The code being used is huff with length len. That code is converted to an index by dropping drop bits off of the bottom. For codes where len is less than drop + curr, those top drop + curr - len bits are incremented through all values to fill the table with replicated entries. root is the number of index bits for the root table. When len exceeds root, sub-tables are created pointed to by the root entry with an index of the low root bits of huff. This is saved in low to check for when a new sub-table should be started. drop is zero when the root table is being filled, and drop is root when sub-tables are being filled. When a new sub-table is needed, it is necessary to look ahead in the code lengths to determine what size sub-table is needed. The length counts are used for this, and so count[] is decremented as codes are entered in the tables. used keeps track of how many table entries have been allocated from the provided *table space. It is checked when a LENS table is being made against the space in *table, ENOUGH, minus the maximum space needed by the worst case distance code, MAXD. This should never happen, but the sufficiency of ENOUGH has not been proven exhaustively, hence the check. This assumes that when type == LENS, bits == 9. sym increments through all symbols, and the loop terminates when all codes of length max, i.e. all codes, have been processed. This routine permits incomplete codes, so another loop after this one fills in the rest of the decoding tables with invalid code markers. */ /* set up for code type */ switch (type) { case CODES: base = extra = work; /* dummy value--not used */ end = 19; break; case LENS: base = lbase; base -= 257; extra = lext; extra -= 257; end = 256; break; default: /* DISTS */ base = dbase; extra = dext; end = -1; } /* initialize state for loop */ huff = 0; /* starting code */ sym = 0; /* starting code symbol */ len = min; /* starting code length */ next = *table; /* current table to fill in */ curr = root; /* current table index bits */ drop = 0; /* current bits to drop from code for index */ low = (unsigned)(-1); /* trigger new sub-table when len > root */ used = 1U << root; /* use root table entries */ mask = used - 1; /* mask for comparing low */ /* check available table space */ if (type == LENS && used >= ENOUGH - MAXD) return 1; /* process all codes and make table entries */ for (;;) { /* create table entry */ this.bits = (unsigned char)(len - drop); if ((int)(work[sym]) < end) { this.op = (unsigned char)0; this.val = work[sym]; } else if ((int)(work[sym]) > end) { this.op = (unsigned char)(extra[work[sym]]); this.val = base[work[sym]]; } else { this.op = (unsigned char)(32 + 64); /* end of block */ this.val = 0; } /* replicate for those indices with low len bits equal to huff */ incr = 1U << (len - drop); fill = 1U << curr; do { fill -= incr; next[(huff >> drop) + fill] = this; } while (fill != 0); /* backwards increment the len-bit code huff */ incr = 1U << (len - 1); while (huff & incr) incr >>= 1; if (incr != 0) { huff &= incr - 1; huff += incr; } else huff = 0; /* go to next symbol, update count, len */ sym++; if (--(count[len]) == 0) { if (len == max) break; len = lens[work[sym]]; } /* create new sub-table if needed */ if (len > root && (huff & mask) != low) { /* if first time, transition to sub-tables */ if (drop == 0) drop = root; /* increment past last table */ next += 1U << curr; /* determine length of next table */ curr = len - drop; left = (int)(1 << curr); while (curr + drop < max) { left -= count[curr + drop]; if (left <= 0) break; curr++; left <<= 1; } /* check for enough space */ used += 1U << curr; if (type == LENS && used >= ENOUGH - MAXD) return 1; /* point entry in root table to sub-table */ low = huff & mask; (*table)[low].op = (unsigned char)curr; (*table)[low].bits = (unsigned char)root; (*table)[low].val = (unsigned short)(next - *table); } } /* Fill in rest of table for incomplete codes. This loop is similar to the loop above in incrementing huff for table indices. It is assumed that len is equal to curr + drop, so there is no loop needed to increment through high index bits. When the current sub-table is filled, the loop drops back to the root table to fill in any remaining entries there. */ this.op = (unsigned char)64; /* invalid code marker */ this.bits = (unsigned char)(len - drop); this.val = (unsigned short)0; while (huff != 0) { /* when done with sub-table, drop back to root table */ if (drop != 0 && (huff & mask) != low) { drop = 0; len = root; next = *table; curr = root; this.bits = (unsigned char)len; } /* put invalid code marker in table */ next[huff >> drop] = this; /* backwards increment the len-bit code huff */ incr = 1U << (len - 1); while (huff & incr) incr >>= 1; if (incr != 0) { huff &= incr - 1; huff += incr; } else huff = 0; } /* set return parameters */ *table += used; *bits = root; return 0; } sks-ecc-0.93/zlib/contrib/infback9/inffix9.h0000644000175000017500000001470710604550750017565 0ustar nachonacho /* inffix9.h -- table for decoding deflate64 fixed codes * Generated automatically by makefixed9(). */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of this library and is subject to change. Applications should only use zlib.h. */ static const code lenfix[512] = { {96,7,0},{0,8,80},{0,8,16},{132,8,115},{130,7,31},{0,8,112}, {0,8,48},{0,9,192},{128,7,10},{0,8,96},{0,8,32},{0,9,160}, {0,8,0},{0,8,128},{0,8,64},{0,9,224},{128,7,6},{0,8,88}, {0,8,24},{0,9,144},{131,7,59},{0,8,120},{0,8,56},{0,9,208}, {129,7,17},{0,8,104},{0,8,40},{0,9,176},{0,8,8},{0,8,136}, {0,8,72},{0,9,240},{128,7,4},{0,8,84},{0,8,20},{133,8,227}, {131,7,43},{0,8,116},{0,8,52},{0,9,200},{129,7,13},{0,8,100}, {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232}, {128,7,8},{0,8,92},{0,8,28},{0,9,152},{132,7,83},{0,8,124}, {0,8,60},{0,9,216},{130,7,23},{0,8,108},{0,8,44},{0,9,184}, {0,8,12},{0,8,140},{0,8,76},{0,9,248},{128,7,3},{0,8,82}, {0,8,18},{133,8,163},{131,7,35},{0,8,114},{0,8,50},{0,9,196}, {129,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},{0,8,130}, {0,8,66},{0,9,228},{128,7,7},{0,8,90},{0,8,26},{0,9,148}, {132,7,67},{0,8,122},{0,8,58},{0,9,212},{130,7,19},{0,8,106}, {0,8,42},{0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244}, {128,7,5},{0,8,86},{0,8,22},{65,8,0},{131,7,51},{0,8,118}, {0,8,54},{0,9,204},{129,7,15},{0,8,102},{0,8,38},{0,9,172}, {0,8,6},{0,8,134},{0,8,70},{0,9,236},{128,7,9},{0,8,94}, {0,8,30},{0,9,156},{132,7,99},{0,8,126},{0,8,62},{0,9,220}, {130,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{133,8,131}, {130,7,31},{0,8,113},{0,8,49},{0,9,194},{128,7,10},{0,8,97}, {0,8,33},{0,9,162},{0,8,1},{0,8,129},{0,8,65},{0,9,226}, {128,7,6},{0,8,89},{0,8,25},{0,9,146},{131,7,59},{0,8,121}, {0,8,57},{0,9,210},{129,7,17},{0,8,105},{0,8,41},{0,9,178}, {0,8,9},{0,8,137},{0,8,73},{0,9,242},{128,7,4},{0,8,85}, {0,8,21},{144,8,3},{131,7,43},{0,8,117},{0,8,53},{0,9,202}, {129,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133}, {0,8,69},{0,9,234},{128,7,8},{0,8,93},{0,8,29},{0,9,154}, {132,7,83},{0,8,125},{0,8,61},{0,9,218},{130,7,23},{0,8,109}, {0,8,45},{0,9,186},{0,8,13},{0,8,141},{0,8,77},{0,9,250}, {128,7,3},{0,8,83},{0,8,19},{133,8,195},{131,7,35},{0,8,115}, {0,8,51},{0,9,198},{129,7,11},{0,8,99},{0,8,35},{0,9,166}, {0,8,3},{0,8,131},{0,8,67},{0,9,230},{128,7,7},{0,8,91}, {0,8,27},{0,9,150},{132,7,67},{0,8,123},{0,8,59},{0,9,214}, {130,7,19},{0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139}, {0,8,75},{0,9,246},{128,7,5},{0,8,87},{0,8,23},{77,8,0}, {131,7,51},{0,8,119},{0,8,55},{0,9,206},{129,7,15},{0,8,103}, {0,8,39},{0,9,174},{0,8,7},{0,8,135},{0,8,71},{0,9,238}, {128,7,9},{0,8,95},{0,8,31},{0,9,158},{132,7,99},{0,8,127}, {0,8,63},{0,9,222},{130,7,27},{0,8,111},{0,8,47},{0,9,190}, {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80}, {0,8,16},{132,8,115},{130,7,31},{0,8,112},{0,8,48},{0,9,193}, {128,7,10},{0,8,96},{0,8,32},{0,9,161},{0,8,0},{0,8,128}, {0,8,64},{0,9,225},{128,7,6},{0,8,88},{0,8,24},{0,9,145}, {131,7,59},{0,8,120},{0,8,56},{0,9,209},{129,7,17},{0,8,104}, {0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},{0,9,241}, {128,7,4},{0,8,84},{0,8,20},{133,8,227},{131,7,43},{0,8,116}, {0,8,52},{0,9,201},{129,7,13},{0,8,100},{0,8,36},{0,9,169}, {0,8,4},{0,8,132},{0,8,68},{0,9,233},{128,7,8},{0,8,92}, {0,8,28},{0,9,153},{132,7,83},{0,8,124},{0,8,60},{0,9,217}, {130,7,23},{0,8,108},{0,8,44},{0,9,185},{0,8,12},{0,8,140}, {0,8,76},{0,9,249},{128,7,3},{0,8,82},{0,8,18},{133,8,163}, {131,7,35},{0,8,114},{0,8,50},{0,9,197},{129,7,11},{0,8,98}, {0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, {128,7,7},{0,8,90},{0,8,26},{0,9,149},{132,7,67},{0,8,122}, {0,8,58},{0,9,213},{130,7,19},{0,8,106},{0,8,42},{0,9,181}, {0,8,10},{0,8,138},{0,8,74},{0,9,245},{128,7,5},{0,8,86}, {0,8,22},{65,8,0},{131,7,51},{0,8,118},{0,8,54},{0,9,205}, {129,7,15},{0,8,102},{0,8,38},{0,9,173},{0,8,6},{0,8,134}, {0,8,70},{0,9,237},{128,7,9},{0,8,94},{0,8,30},{0,9,157}, {132,7,99},{0,8,126},{0,8,62},{0,9,221},{130,7,27},{0,8,110}, {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253}, {96,7,0},{0,8,81},{0,8,17},{133,8,131},{130,7,31},{0,8,113}, {0,8,49},{0,9,195},{128,7,10},{0,8,97},{0,8,33},{0,9,163}, {0,8,1},{0,8,129},{0,8,65},{0,9,227},{128,7,6},{0,8,89}, {0,8,25},{0,9,147},{131,7,59},{0,8,121},{0,8,57},{0,9,211}, {129,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},{0,8,137}, {0,8,73},{0,9,243},{128,7,4},{0,8,85},{0,8,21},{144,8,3}, {131,7,43},{0,8,117},{0,8,53},{0,9,203},{129,7,13},{0,8,101}, {0,8,37},{0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235}, {128,7,8},{0,8,93},{0,8,29},{0,9,155},{132,7,83},{0,8,125}, {0,8,61},{0,9,219},{130,7,23},{0,8,109},{0,8,45},{0,9,187}, {0,8,13},{0,8,141},{0,8,77},{0,9,251},{128,7,3},{0,8,83}, {0,8,19},{133,8,195},{131,7,35},{0,8,115},{0,8,51},{0,9,199}, {129,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, {0,8,67},{0,9,231},{128,7,7},{0,8,91},{0,8,27},{0,9,151}, {132,7,67},{0,8,123},{0,8,59},{0,9,215},{130,7,19},{0,8,107}, {0,8,43},{0,9,183},{0,8,11},{0,8,139},{0,8,75},{0,9,247}, {128,7,5},{0,8,87},{0,8,23},{77,8,0},{131,7,51},{0,8,119}, {0,8,55},{0,9,207},{129,7,15},{0,8,103},{0,8,39},{0,9,175}, {0,8,7},{0,8,135},{0,8,71},{0,9,239},{128,7,9},{0,8,95}, {0,8,31},{0,9,159},{132,7,99},{0,8,127},{0,8,63},{0,9,223}, {130,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143}, {0,8,79},{0,9,255} }; static const code distfix[32] = { {128,5,1},{135,5,257},{131,5,17},{139,5,4097},{129,5,5}, {137,5,1025},{133,5,65},{141,5,16385},{128,5,3},{136,5,513}, {132,5,33},{140,5,8193},{130,5,9},{138,5,2049},{134,5,129}, {142,5,32769},{128,5,2},{135,5,385},{131,5,25},{139,5,6145}, {129,5,7},{137,5,1537},{133,5,97},{141,5,24577},{128,5,4}, {136,5,769},{132,5,49},{140,5,12289},{130,5,13},{138,5,3073}, {134,5,193},{142,5,49153} }; sks-ecc-0.93/zlib/contrib/inflate86/0000755000175000017500000000000010604550750016141 5ustar nachonachosks-ecc-0.93/zlib/contrib/inflate86/inffas86.c0000644000175000017500000011724010604550750017736 0ustar nachonacho/* inffas86.c is a hand tuned assembler version of * * inffast.c -- fast decoding * Copyright (C) 1995-2003 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h * * Copyright (C) 2003 Chris Anderson * Please use the copyright conditions above. * * Dec-29-2003 -- I added AMD64 inflate asm support. This version is also * slightly quicker on x86 systems because, instead of using rep movsb to copy * data, it uses rep movsw, which moves data in 2-byte chunks instead of single * bytes. I've tested the AMD64 code on a Fedora Core 1 + the x86_64 updates * from http://fedora.linux.duke.edu/fc1_x86_64 * which is running on an Athlon 64 3000+ / Gigabyte GA-K8VT800M system with * 1GB ram. The 64-bit version is about 4% faster than the 32-bit version, * when decompressing mozilla-source-1.3.tar.gz. * * Mar-13-2003 -- Most of this is derived from inffast.S which is derived from * the gcc -S output of zlib-1.2.0/inffast.c. Zlib-1.2.0 is in beta release at * the moment. I have successfully compiled and tested this code with gcc2.96, * gcc3.2, icc5.0, msvc6.0. It is very close to the speed of inffast.S * compiled with gcc -DNO_MMX, but inffast.S is still faster on the P3 with MMX * enabled. I will attempt to merge the MMX code into this version. Newer * versions of this and inffast.S can be found at * http://www.eetbeetee.com/zlib/ and http://www.charm.net/~christop/zlib/ */ #include "zutil.h" #include "inftrees.h" #include "inflate.h" #include "inffast.h" /* Mark Adler's comments from inffast.c: */ /* Decode literal, length, and distance codes and write out the resulting literal and match bytes until either not enough input or output is available, an end-of-block is encountered, or a data error is encountered. When large enough input and output buffers are supplied to inflate(), for example, a 16K input buffer and a 64K output buffer, more than 95% of the inflate execution time is spent in this routine. Entry assumptions: state->mode == LEN strm->avail_in >= 6 strm->avail_out >= 258 start >= strm->avail_out state->bits < 8 On return, state->mode is one of: LEN -- ran out of enough output space or enough available input TYPE -- reached end of block code, inflate() to interpret next block BAD -- error in block data Notes: - The maximum input bits used by a length/distance pair is 15 bits for the length code, 5 bits for the length extra, 15 bits for the distance code, and 13 bits for the distance extra. This totals 48 bits, or six bytes. Therefore if strm->avail_in >= 6, then there is enough input to avoid checking for available input while decoding. - The maximum bytes that a single length/distance pair can output is 258 bytes, which is the maximum length that can be coded. inflate_fast() requires strm->avail_out >= 258 for each loop to avoid checking for output space. */ void inflate_fast(strm, start) z_streamp strm; unsigned start; /* inflate()'s starting value for strm->avail_out */ { struct inflate_state FAR *state; struct inffast_ar { /* 64 32 x86 x86_64 */ /* ar offset register */ /* 0 0 */ void *esp; /* esp save */ /* 8 4 */ void *ebp; /* ebp save */ /* 16 8 */ unsigned char FAR *in; /* esi rsi local strm->next_in */ /* 24 12 */ unsigned char FAR *last; /* r9 while in < last */ /* 32 16 */ unsigned char FAR *out; /* edi rdi local strm->next_out */ /* 40 20 */ unsigned char FAR *beg; /* inflate()'s init next_out */ /* 48 24 */ unsigned char FAR *end; /* r10 while out < end */ /* 56 28 */ unsigned char FAR *window;/* size of window, wsize!=0 */ /* 64 32 */ code const FAR *lcode; /* ebp rbp local strm->lencode */ /* 72 36 */ code const FAR *dcode; /* r11 local strm->distcode */ /* 80 40 */ unsigned long hold; /* edx rdx local strm->hold */ /* 88 44 */ unsigned bits; /* ebx rbx local strm->bits */ /* 92 48 */ unsigned wsize; /* window size */ /* 96 52 */ unsigned write; /* window write index */ /*100 56 */ unsigned lmask; /* r12 mask for lcode */ /*104 60 */ unsigned dmask; /* r13 mask for dcode */ /*108 64 */ unsigned len; /* r14 match length */ /*112 68 */ unsigned dist; /* r15 match distance */ /*116 72 */ unsigned status; /* set when state chng*/ } ar; #if defined( __GNUC__ ) && defined( __amd64__ ) && ! defined( __i386 ) #define PAD_AVAIL_IN 6 #define PAD_AVAIL_OUT 258 #else #define PAD_AVAIL_IN 5 #define PAD_AVAIL_OUT 257 #endif /* copy state to local variables */ state = (struct inflate_state FAR *)strm->state; ar.in = strm->next_in; ar.last = ar.in + (strm->avail_in - PAD_AVAIL_IN); ar.out = strm->next_out; ar.beg = ar.out - (start - strm->avail_out); ar.end = ar.out + (strm->avail_out - PAD_AVAIL_OUT); ar.wsize = state->wsize; ar.write = state->write; ar.window = state->window; ar.hold = state->hold; ar.bits = state->bits; ar.lcode = state->lencode; ar.dcode = state->distcode; ar.lmask = (1U << state->lenbits) - 1; ar.dmask = (1U << state->distbits) - 1; /* decode literals and length/distances until end-of-block or not enough input data or output space */ /* align in on 1/2 hold size boundary */ while (((unsigned long)(void *)ar.in & (sizeof(ar.hold) / 2 - 1)) != 0) { ar.hold += (unsigned long)*ar.in++ << ar.bits; ar.bits += 8; } #if defined( __GNUC__ ) && defined( __amd64__ ) && ! defined( __i386 ) __asm__ __volatile__ ( " leaq %0, %%rax\n" " movq %%rbp, 8(%%rax)\n" /* save regs rbp and rsp */ " movq %%rsp, (%%rax)\n" " movq %%rax, %%rsp\n" /* make rsp point to &ar */ " movq 16(%%rsp), %%rsi\n" /* rsi = in */ " movq 32(%%rsp), %%rdi\n" /* rdi = out */ " movq 24(%%rsp), %%r9\n" /* r9 = last */ " movq 48(%%rsp), %%r10\n" /* r10 = end */ " movq 64(%%rsp), %%rbp\n" /* rbp = lcode */ " movq 72(%%rsp), %%r11\n" /* r11 = dcode */ " movq 80(%%rsp), %%rdx\n" /* rdx = hold */ " movl 88(%%rsp), %%ebx\n" /* ebx = bits */ " movl 100(%%rsp), %%r12d\n" /* r12d = lmask */ " movl 104(%%rsp), %%r13d\n" /* r13d = dmask */ /* r14d = len */ /* r15d = dist */ " cld\n" " cmpq %%rdi, %%r10\n" " je .L_one_time\n" /* if only one decode left */ " cmpq %%rsi, %%r9\n" " je .L_one_time\n" " jmp .L_do_loop\n" ".L_one_time:\n" " movq %%r12, %%r8\n" /* r8 = lmask */ " cmpb $32, %%bl\n" " ja .L_get_length_code_one_time\n" " lodsl\n" /* eax = *(uint *)in++ */ " movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ " addb $32, %%bl\n" /* bits += 32 */ " shlq %%cl, %%rax\n" " orq %%rax, %%rdx\n" /* hold |= *((uint *)in)++ << bits */ " jmp .L_get_length_code_one_time\n" ".align 32,0x90\n" ".L_while_test:\n" " cmpq %%rdi, %%r10\n" " jbe .L_break_loop\n" " cmpq %%rsi, %%r9\n" " jbe .L_break_loop\n" ".L_do_loop:\n" " movq %%r12, %%r8\n" /* r8 = lmask */ " cmpb $32, %%bl\n" " ja .L_get_length_code\n" /* if (32 < bits) */ " lodsl\n" /* eax = *(uint *)in++ */ " movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ " addb $32, %%bl\n" /* bits += 32 */ " shlq %%cl, %%rax\n" " orq %%rax, %%rdx\n" /* hold |= *((uint *)in)++ << bits */ ".L_get_length_code:\n" " andq %%rdx, %%r8\n" /* r8 &= hold */ " movl (%%rbp,%%r8,4), %%eax\n" /* eax = lcode[hold & lmask] */ " movb %%ah, %%cl\n" /* cl = this.bits */ " subb %%ah, %%bl\n" /* bits -= this.bits */ " shrq %%cl, %%rdx\n" /* hold >>= this.bits */ " testb %%al, %%al\n" " jnz .L_test_for_length_base\n" /* if (op != 0) 45.7% */ " movq %%r12, %%r8\n" /* r8 = lmask */ " shrl $16, %%eax\n" /* output this.val char */ " stosb\n" ".L_get_length_code_one_time:\n" " andq %%rdx, %%r8\n" /* r8 &= hold */ " movl (%%rbp,%%r8,4), %%eax\n" /* eax = lcode[hold & lmask] */ ".L_dolen:\n" " movb %%ah, %%cl\n" /* cl = this.bits */ " subb %%ah, %%bl\n" /* bits -= this.bits */ " shrq %%cl, %%rdx\n" /* hold >>= this.bits */ " testb %%al, %%al\n" " jnz .L_test_for_length_base\n" /* if (op != 0) 45.7% */ " shrl $16, %%eax\n" /* output this.val char */ " stosb\n" " jmp .L_while_test\n" ".align 32,0x90\n" ".L_test_for_length_base:\n" " movl %%eax, %%r14d\n" /* len = this */ " shrl $16, %%r14d\n" /* len = this.val */ " movb %%al, %%cl\n" " testb $16, %%al\n" " jz .L_test_for_second_level_length\n" /* if ((op & 16) == 0) 8% */ " andb $15, %%cl\n" /* op &= 15 */ " jz .L_decode_distance\n" /* if (!op) */ ".L_add_bits_to_len:\n" " subb %%cl, %%bl\n" " xorl %%eax, %%eax\n" " incl %%eax\n" " shll %%cl, %%eax\n" " decl %%eax\n" " andl %%edx, %%eax\n" /* eax &= hold */ " shrq %%cl, %%rdx\n" " addl %%eax, %%r14d\n" /* len += hold & mask[op] */ ".L_decode_distance:\n" " movq %%r13, %%r8\n" /* r8 = dmask */ " cmpb $32, %%bl\n" " ja .L_get_distance_code\n" /* if (32 < bits) */ " lodsl\n" /* eax = *(uint *)in++ */ " movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ " addb $32, %%bl\n" /* bits += 32 */ " shlq %%cl, %%rax\n" " orq %%rax, %%rdx\n" /* hold |= *((uint *)in)++ << bits */ ".L_get_distance_code:\n" " andq %%rdx, %%r8\n" /* r8 &= hold */ " movl (%%r11,%%r8,4), %%eax\n" /* eax = dcode[hold & dmask] */ ".L_dodist:\n" " movl %%eax, %%r15d\n" /* dist = this */ " shrl $16, %%r15d\n" /* dist = this.val */ " movb %%ah, %%cl\n" " subb %%ah, %%bl\n" /* bits -= this.bits */ " shrq %%cl, %%rdx\n" /* hold >>= this.bits */ " movb %%al, %%cl\n" /* cl = this.op */ " testb $16, %%al\n" /* if ((op & 16) == 0) */ " jz .L_test_for_second_level_dist\n" " andb $15, %%cl\n" /* op &= 15 */ " jz .L_check_dist_one\n" ".L_add_bits_to_dist:\n" " subb %%cl, %%bl\n" " xorl %%eax, %%eax\n" " incl %%eax\n" " shll %%cl, %%eax\n" " decl %%eax\n" /* (1 << op) - 1 */ " andl %%edx, %%eax\n" /* eax &= hold */ " shrq %%cl, %%rdx\n" " addl %%eax, %%r15d\n" /* dist += hold & ((1 << op) - 1) */ ".L_check_window:\n" " movq %%rsi, %%r8\n" /* save in so from can use it's reg */ " movq %%rdi, %%rax\n" " subq 40(%%rsp), %%rax\n" /* nbytes = out - beg */ " cmpl %%r15d, %%eax\n" " jb .L_clip_window\n" /* if (dist > nbytes) 4.2% */ " movl %%r14d, %%ecx\n" /* ecx = len */ " movq %%rdi, %%rsi\n" " subq %%r15, %%rsi\n" /* from = out - dist */ " sarl %%ecx\n" " jnc .L_copy_two\n" /* if len % 2 == 0 */ " rep movsw\n" " movb (%%rsi), %%al\n" " movb %%al, (%%rdi)\n" " incq %%rdi\n" " movq %%r8, %%rsi\n" /* move in back to %rsi, toss from */ " jmp .L_while_test\n" ".L_copy_two:\n" " rep movsw\n" " movq %%r8, %%rsi\n" /* move in back to %rsi, toss from */ " jmp .L_while_test\n" ".align 32,0x90\n" ".L_check_dist_one:\n" " cmpl $1, %%r15d\n" /* if dist 1, is a memset */ " jne .L_check_window\n" " cmpq %%rdi, 40(%%rsp)\n" /* if out == beg, outside window */ " je .L_check_window\n" " movl %%r14d, %%ecx\n" /* ecx = len */ " movb -1(%%rdi), %%al\n" " movb %%al, %%ah\n" " sarl %%ecx\n" " jnc .L_set_two\n" " movb %%al, (%%rdi)\n" " incq %%rdi\n" ".L_set_two:\n" " rep stosw\n" " jmp .L_while_test\n" ".align 32,0x90\n" ".L_test_for_second_level_length:\n" " testb $64, %%al\n" " jnz .L_test_for_end_of_block\n" /* if ((op & 64) != 0) */ " xorl %%eax, %%eax\n" " incl %%eax\n" " shll %%cl, %%eax\n" " decl %%eax\n" " andl %%edx, %%eax\n" /* eax &= hold */ " addl %%r14d, %%eax\n" /* eax += len */ " movl (%%rbp,%%rax,4), %%eax\n" /* eax = lcode[val+(hold&mask[op])]*/ " jmp .L_dolen\n" ".align 32,0x90\n" ".L_test_for_second_level_dist:\n" " testb $64, %%al\n" " jnz .L_invalid_distance_code\n" /* if ((op & 64) != 0) */ " xorl %%eax, %%eax\n" " incl %%eax\n" " shll %%cl, %%eax\n" " decl %%eax\n" " andl %%edx, %%eax\n" /* eax &= hold */ " addl %%r15d, %%eax\n" /* eax += dist */ " movl (%%r11,%%rax,4), %%eax\n" /* eax = dcode[val+(hold&mask[op])]*/ " jmp .L_dodist\n" ".align 32,0x90\n" ".L_clip_window:\n" " movl %%eax, %%ecx\n" /* ecx = nbytes */ " movl 92(%%rsp), %%eax\n" /* eax = wsize, prepare for dist cmp */ " negl %%ecx\n" /* nbytes = -nbytes */ " cmpl %%r15d, %%eax\n" " jb .L_invalid_distance_too_far\n" /* if (dist > wsize) */ " addl %%r15d, %%ecx\n" /* nbytes = dist - nbytes */ " cmpl $0, 96(%%rsp)\n" " jne .L_wrap_around_window\n" /* if (write != 0) */ " movq 56(%%rsp), %%rsi\n" /* from = window */ " subl %%ecx, %%eax\n" /* eax -= nbytes */ " addq %%rax, %%rsi\n" /* from += wsize - nbytes */ " movl %%r14d, %%eax\n" /* eax = len */ " cmpl %%ecx, %%r14d\n" " jbe .L_do_copy\n" /* if (nbytes >= len) */ " subl %%ecx, %%eax\n" /* eax -= nbytes */ " rep movsb\n" " movq %%rdi, %%rsi\n" " subq %%r15, %%rsi\n" /* from = &out[ -dist ] */ " jmp .L_do_copy\n" ".align 32,0x90\n" ".L_wrap_around_window:\n" " movl 96(%%rsp), %%eax\n" /* eax = write */ " cmpl %%eax, %%ecx\n" " jbe .L_contiguous_in_window\n" /* if (write >= nbytes) */ " movl 92(%%rsp), %%esi\n" /* from = wsize */ " addq 56(%%rsp), %%rsi\n" /* from += window */ " addq %%rax, %%rsi\n" /* from += write */ " subq %%rcx, %%rsi\n" /* from -= nbytes */ " subl %%eax, %%ecx\n" /* nbytes -= write */ " movl %%r14d, %%eax\n" /* eax = len */ " cmpl %%ecx, %%eax\n" " jbe .L_do_copy\n" /* if (nbytes >= len) */ " subl %%ecx, %%eax\n" /* len -= nbytes */ " rep movsb\n" " movq 56(%%rsp), %%rsi\n" /* from = window */ " movl 96(%%rsp), %%ecx\n" /* nbytes = write */ " cmpl %%ecx, %%eax\n" " jbe .L_do_copy\n" /* if (nbytes >= len) */ " subl %%ecx, %%eax\n" /* len -= nbytes */ " rep movsb\n" " movq %%rdi, %%rsi\n" " subq %%r15, %%rsi\n" /* from = out - dist */ " jmp .L_do_copy\n" ".align 32,0x90\n" ".L_contiguous_in_window:\n" " movq 56(%%rsp), %%rsi\n" /* rsi = window */ " addq %%rax, %%rsi\n" " subq %%rcx, %%rsi\n" /* from += write - nbytes */ " movl %%r14d, %%eax\n" /* eax = len */ " cmpl %%ecx, %%eax\n" " jbe .L_do_copy\n" /* if (nbytes >= len) */ " subl %%ecx, %%eax\n" /* len -= nbytes */ " rep movsb\n" " movq %%rdi, %%rsi\n" " subq %%r15, %%rsi\n" /* from = out - dist */ " jmp .L_do_copy\n" /* if (nbytes >= len) */ ".align 32,0x90\n" ".L_do_copy:\n" " movl %%eax, %%ecx\n" /* ecx = len */ " rep movsb\n" " movq %%r8, %%rsi\n" /* move in back to %esi, toss from */ " jmp .L_while_test\n" ".L_test_for_end_of_block:\n" " testb $32, %%al\n" " jz .L_invalid_literal_length_code\n" " movl $1, 116(%%rsp)\n" " jmp .L_break_loop_with_status\n" ".L_invalid_literal_length_code:\n" " movl $2, 116(%%rsp)\n" " jmp .L_break_loop_with_status\n" ".L_invalid_distance_code:\n" " movl $3, 116(%%rsp)\n" " jmp .L_break_loop_with_status\n" ".L_invalid_distance_too_far:\n" " movl $4, 116(%%rsp)\n" " jmp .L_break_loop_with_status\n" ".L_break_loop:\n" " movl $0, 116(%%rsp)\n" ".L_break_loop_with_status:\n" /* put in, out, bits, and hold back into ar and pop esp */ " movq %%rsi, 16(%%rsp)\n" /* in */ " movq %%rdi, 32(%%rsp)\n" /* out */ " movl %%ebx, 88(%%rsp)\n" /* bits */ " movq %%rdx, 80(%%rsp)\n" /* hold */ " movq (%%rsp), %%rax\n" /* restore rbp and rsp */ " movq 8(%%rsp), %%rbp\n" " movq %%rax, %%rsp\n" : : "m" (ar) : "memory", "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" ); #elif ( defined( __GNUC__ ) || defined( __ICC ) ) && defined( __i386 ) __asm__ __volatile__ ( " leal %0, %%eax\n" " movl %%esp, (%%eax)\n" /* save esp, ebp */ " movl %%ebp, 4(%%eax)\n" " movl %%eax, %%esp\n" " movl 8(%%esp), %%esi\n" /* esi = in */ " movl 16(%%esp), %%edi\n" /* edi = out */ " movl 40(%%esp), %%edx\n" /* edx = hold */ " movl 44(%%esp), %%ebx\n" /* ebx = bits */ " movl 32(%%esp), %%ebp\n" /* ebp = lcode */ " cld\n" " jmp .L_do_loop\n" ".align 32,0x90\n" ".L_while_test:\n" " cmpl %%edi, 24(%%esp)\n" /* out < end */ " jbe .L_break_loop\n" " cmpl %%esi, 12(%%esp)\n" /* in < last */ " jbe .L_break_loop\n" ".L_do_loop:\n" " cmpb $15, %%bl\n" " ja .L_get_length_code\n" /* if (15 < bits) */ " xorl %%eax, %%eax\n" " lodsw\n" /* al = *(ushort *)in++ */ " movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ " addb $16, %%bl\n" /* bits += 16 */ " shll %%cl, %%eax\n" " orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */ ".L_get_length_code:\n" " movl 56(%%esp), %%eax\n" /* eax = lmask */ " andl %%edx, %%eax\n" /* eax &= hold */ " movl (%%ebp,%%eax,4), %%eax\n" /* eax = lcode[hold & lmask] */ ".L_dolen:\n" " movb %%ah, %%cl\n" /* cl = this.bits */ " subb %%ah, %%bl\n" /* bits -= this.bits */ " shrl %%cl, %%edx\n" /* hold >>= this.bits */ " testb %%al, %%al\n" " jnz .L_test_for_length_base\n" /* if (op != 0) 45.7% */ " shrl $16, %%eax\n" /* output this.val char */ " stosb\n" " jmp .L_while_test\n" ".align 32,0x90\n" ".L_test_for_length_base:\n" " movl %%eax, %%ecx\n" /* len = this */ " shrl $16, %%ecx\n" /* len = this.val */ " movl %%ecx, 64(%%esp)\n" /* save len */ " movb %%al, %%cl\n" " testb $16, %%al\n" " jz .L_test_for_second_level_length\n" /* if ((op & 16) == 0) 8% */ " andb $15, %%cl\n" /* op &= 15 */ " jz .L_decode_distance\n" /* if (!op) */ " cmpb %%cl, %%bl\n" " jae .L_add_bits_to_len\n" /* if (op <= bits) */ " movb %%cl, %%ch\n" /* stash op in ch, freeing cl */ " xorl %%eax, %%eax\n" " lodsw\n" /* al = *(ushort *)in++ */ " movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ " addb $16, %%bl\n" /* bits += 16 */ " shll %%cl, %%eax\n" " orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */ " movb %%ch, %%cl\n" /* move op back to ecx */ ".L_add_bits_to_len:\n" " subb %%cl, %%bl\n" " xorl %%eax, %%eax\n" " incl %%eax\n" " shll %%cl, %%eax\n" " decl %%eax\n" " andl %%edx, %%eax\n" /* eax &= hold */ " shrl %%cl, %%edx\n" " addl %%eax, 64(%%esp)\n" /* len += hold & mask[op] */ ".L_decode_distance:\n" " cmpb $15, %%bl\n" " ja .L_get_distance_code\n" /* if (15 < bits) */ " xorl %%eax, %%eax\n" " lodsw\n" /* al = *(ushort *)in++ */ " movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ " addb $16, %%bl\n" /* bits += 16 */ " shll %%cl, %%eax\n" " orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */ ".L_get_distance_code:\n" " movl 60(%%esp), %%eax\n" /* eax = dmask */ " movl 36(%%esp), %%ecx\n" /* ecx = dcode */ " andl %%edx, %%eax\n" /* eax &= hold */ " movl (%%ecx,%%eax,4), %%eax\n"/* eax = dcode[hold & dmask] */ ".L_dodist:\n" " movl %%eax, %%ebp\n" /* dist = this */ " shrl $16, %%ebp\n" /* dist = this.val */ " movb %%ah, %%cl\n" " subb %%ah, %%bl\n" /* bits -= this.bits */ " shrl %%cl, %%edx\n" /* hold >>= this.bits */ " movb %%al, %%cl\n" /* cl = this.op */ " testb $16, %%al\n" /* if ((op & 16) == 0) */ " jz .L_test_for_second_level_dist\n" " andb $15, %%cl\n" /* op &= 15 */ " jz .L_check_dist_one\n" " cmpb %%cl, %%bl\n" " jae .L_add_bits_to_dist\n" /* if (op <= bits) 97.6% */ " movb %%cl, %%ch\n" /* stash op in ch, freeing cl */ " xorl %%eax, %%eax\n" " lodsw\n" /* al = *(ushort *)in++ */ " movb %%bl, %%cl\n" /* cl = bits, needs it for shifting */ " addb $16, %%bl\n" /* bits += 16 */ " shll %%cl, %%eax\n" " orl %%eax, %%edx\n" /* hold |= *((ushort *)in)++ << bits */ " movb %%ch, %%cl\n" /* move op back to ecx */ ".L_add_bits_to_dist:\n" " subb %%cl, %%bl\n" " xorl %%eax, %%eax\n" " incl %%eax\n" " shll %%cl, %%eax\n" " decl %%eax\n" /* (1 << op) - 1 */ " andl %%edx, %%eax\n" /* eax &= hold */ " shrl %%cl, %%edx\n" " addl %%eax, %%ebp\n" /* dist += hold & ((1 << op) - 1) */ ".L_check_window:\n" " movl %%esi, 8(%%esp)\n" /* save in so from can use it's reg */ " movl %%edi, %%eax\n" " subl 20(%%esp), %%eax\n" /* nbytes = out - beg */ " cmpl %%ebp, %%eax\n" " jb .L_clip_window\n" /* if (dist > nbytes) 4.2% */ " movl 64(%%esp), %%ecx\n" /* ecx = len */ " movl %%edi, %%esi\n" " subl %%ebp, %%esi\n" /* from = out - dist */ " sarl %%ecx\n" " jnc .L_copy_two\n" /* if len % 2 == 0 */ " rep movsw\n" " movb (%%esi), %%al\n" " movb %%al, (%%edi)\n" " incl %%edi\n" " movl 8(%%esp), %%esi\n" /* move in back to %esi, toss from */ " movl 32(%%esp), %%ebp\n" /* ebp = lcode */ " jmp .L_while_test\n" ".L_copy_two:\n" " rep movsw\n" " movl 8(%%esp), %%esi\n" /* move in back to %esi, toss from */ " movl 32(%%esp), %%ebp\n" /* ebp = lcode */ " jmp .L_while_test\n" ".align 32,0x90\n" ".L_check_dist_one:\n" " cmpl $1, %%ebp\n" /* if dist 1, is a memset */ " jne .L_check_window\n" " cmpl %%edi, 20(%%esp)\n" " je .L_check_window\n" /* out == beg, if outside window */ " movl 64(%%esp), %%ecx\n" /* ecx = len */ " movb -1(%%edi), %%al\n" " movb %%al, %%ah\n" " sarl %%ecx\n" " jnc .L_set_two\n" " movb %%al, (%%edi)\n" " incl %%edi\n" ".L_set_two:\n" " rep stosw\n" " movl 32(%%esp), %%ebp\n" /* ebp = lcode */ " jmp .L_while_test\n" ".align 32,0x90\n" ".L_test_for_second_level_length:\n" " testb $64, %%al\n" " jnz .L_test_for_end_of_block\n" /* if ((op & 64) != 0) */ " xorl %%eax, %%eax\n" " incl %%eax\n" " shll %%cl, %%eax\n" " decl %%eax\n" " andl %%edx, %%eax\n" /* eax &= hold */ " addl 64(%%esp), %%eax\n" /* eax += len */ " movl (%%ebp,%%eax,4), %%eax\n" /* eax = lcode[val+(hold&mask[op])]*/ " jmp .L_dolen\n" ".align 32,0x90\n" ".L_test_for_second_level_dist:\n" " testb $64, %%al\n" " jnz .L_invalid_distance_code\n" /* if ((op & 64) != 0) */ " xorl %%eax, %%eax\n" " incl %%eax\n" " shll %%cl, %%eax\n" " decl %%eax\n" " andl %%edx, %%eax\n" /* eax &= hold */ " addl %%ebp, %%eax\n" /* eax += dist */ " movl 36(%%esp), %%ecx\n" /* ecx = dcode */ " movl (%%ecx,%%eax,4), %%eax\n" /* eax = dcode[val+(hold&mask[op])]*/ " jmp .L_dodist\n" ".align 32,0x90\n" ".L_clip_window:\n" " movl %%eax, %%ecx\n" " movl 48(%%esp), %%eax\n" /* eax = wsize */ " negl %%ecx\n" /* nbytes = -nbytes */ " movl 28(%%esp), %%esi\n" /* from = window */ " cmpl %%ebp, %%eax\n" " jb .L_invalid_distance_too_far\n" /* if (dist > wsize) */ " addl %%ebp, %%ecx\n" /* nbytes = dist - nbytes */ " cmpl $0, 52(%%esp)\n" " jne .L_wrap_around_window\n" /* if (write != 0) */ " subl %%ecx, %%eax\n" " addl %%eax, %%esi\n" /* from += wsize - nbytes */ " movl 64(%%esp), %%eax\n" /* eax = len */ " cmpl %%ecx, %%eax\n" " jbe .L_do_copy\n" /* if (nbytes >= len) */ " subl %%ecx, %%eax\n" /* len -= nbytes */ " rep movsb\n" " movl %%edi, %%esi\n" " subl %%ebp, %%esi\n" /* from = out - dist */ " jmp .L_do_copy\n" ".align 32,0x90\n" ".L_wrap_around_window:\n" " movl 52(%%esp), %%eax\n" /* eax = write */ " cmpl %%eax, %%ecx\n" " jbe .L_contiguous_in_window\n" /* if (write >= nbytes) */ " addl 48(%%esp), %%esi\n" /* from += wsize */ " addl %%eax, %%esi\n" /* from += write */ " subl %%ecx, %%esi\n" /* from -= nbytes */ " subl %%eax, %%ecx\n" /* nbytes -= write */ " movl 64(%%esp), %%eax\n" /* eax = len */ " cmpl %%ecx, %%eax\n" " jbe .L_do_copy\n" /* if (nbytes >= len) */ " subl %%ecx, %%eax\n" /* len -= nbytes */ " rep movsb\n" " movl 28(%%esp), %%esi\n" /* from = window */ " movl 52(%%esp), %%ecx\n" /* nbytes = write */ " cmpl %%ecx, %%eax\n" " jbe .L_do_copy\n" /* if (nbytes >= len) */ " subl %%ecx, %%eax\n" /* len -= nbytes */ " rep movsb\n" " movl %%edi, %%esi\n" " subl %%ebp, %%esi\n" /* from = out - dist */ " jmp .L_do_copy\n" ".align 32,0x90\n" ".L_contiguous_in_window:\n" " addl %%eax, %%esi\n" " subl %%ecx, %%esi\n" /* from += write - nbytes */ " movl 64(%%esp), %%eax\n" /* eax = len */ " cmpl %%ecx, %%eax\n" " jbe .L_do_copy\n" /* if (nbytes >= len) */ " subl %%ecx, %%eax\n" /* len -= nbytes */ " rep movsb\n" " movl %%edi, %%esi\n" " subl %%ebp, %%esi\n" /* from = out - dist */ " jmp .L_do_copy\n" /* if (nbytes >= len) */ ".align 32,0x90\n" ".L_do_copy:\n" " movl %%eax, %%ecx\n" " rep movsb\n" " movl 8(%%esp), %%esi\n" /* move in back to %esi, toss from */ " movl 32(%%esp), %%ebp\n" /* ebp = lcode */ " jmp .L_while_test\n" ".L_test_for_end_of_block:\n" " testb $32, %%al\n" " jz .L_invalid_literal_length_code\n" " movl $1, 72(%%esp)\n" " jmp .L_break_loop_with_status\n" ".L_invalid_literal_length_code:\n" " movl $2, 72(%%esp)\n" " jmp .L_break_loop_with_status\n" ".L_invalid_distance_code:\n" " movl $3, 72(%%esp)\n" " jmp .L_break_loop_with_status\n" ".L_invalid_distance_too_far:\n" " movl 8(%%esp), %%esi\n" " movl $4, 72(%%esp)\n" " jmp .L_break_loop_with_status\n" ".L_break_loop:\n" " movl $0, 72(%%esp)\n" ".L_break_loop_with_status:\n" /* put in, out, bits, and hold back into ar and pop esp */ " movl %%esi, 8(%%esp)\n" /* save in */ " movl %%edi, 16(%%esp)\n" /* save out */ " movl %%ebx, 44(%%esp)\n" /* save bits */ " movl %%edx, 40(%%esp)\n" /* save hold */ " movl 4(%%esp), %%ebp\n" /* restore esp, ebp */ " movl (%%esp), %%esp\n" : : "m" (ar) : "memory", "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi" ); #elif defined( _MSC_VER ) && ! defined( _M_AMD64 ) __asm { lea eax, ar mov [eax], esp /* save esp, ebp */ mov [eax+4], ebp mov esp, eax mov esi, [esp+8] /* esi = in */ mov edi, [esp+16] /* edi = out */ mov edx, [esp+40] /* edx = hold */ mov ebx, [esp+44] /* ebx = bits */ mov ebp, [esp+32] /* ebp = lcode */ cld jmp L_do_loop ALIGN 4 L_while_test: cmp [esp+24], edi jbe L_break_loop cmp [esp+12], esi jbe L_break_loop L_do_loop: cmp bl, 15 ja L_get_length_code /* if (15 < bits) */ xor eax, eax lodsw /* al = *(ushort *)in++ */ mov cl, bl /* cl = bits, needs it for shifting */ add bl, 16 /* bits += 16 */ shl eax, cl or edx, eax /* hold |= *((ushort *)in)++ << bits */ L_get_length_code: mov eax, [esp+56] /* eax = lmask */ and eax, edx /* eax &= hold */ mov eax, [ebp+eax*4] /* eax = lcode[hold & lmask] */ L_dolen: mov cl, ah /* cl = this.bits */ sub bl, ah /* bits -= this.bits */ shr edx, cl /* hold >>= this.bits */ test al, al jnz L_test_for_length_base /* if (op != 0) 45.7% */ shr eax, 16 /* output this.val char */ stosb jmp L_while_test ALIGN 4 L_test_for_length_base: mov ecx, eax /* len = this */ shr ecx, 16 /* len = this.val */ mov [esp+64], ecx /* save len */ mov cl, al test al, 16 jz L_test_for_second_level_length /* if ((op & 16) == 0) 8% */ and cl, 15 /* op &= 15 */ jz L_decode_distance /* if (!op) */ cmp bl, cl jae L_add_bits_to_len /* if (op <= bits) */ mov ch, cl /* stash op in ch, freeing cl */ xor eax, eax lodsw /* al = *(ushort *)in++ */ mov cl, bl /* cl = bits, needs it for shifting */ add bl, 16 /* bits += 16 */ shl eax, cl or edx, eax /* hold |= *((ushort *)in)++ << bits */ mov cl, ch /* move op back to ecx */ L_add_bits_to_len: sub bl, cl xor eax, eax inc eax shl eax, cl dec eax and eax, edx /* eax &= hold */ shr edx, cl add [esp+64], eax /* len += hold & mask[op] */ L_decode_distance: cmp bl, 15 ja L_get_distance_code /* if (15 < bits) */ xor eax, eax lodsw /* al = *(ushort *)in++ */ mov cl, bl /* cl = bits, needs it for shifting */ add bl, 16 /* bits += 16 */ shl eax, cl or edx, eax /* hold |= *((ushort *)in)++ << bits */ L_get_distance_code: mov eax, [esp+60] /* eax = dmask */ mov ecx, [esp+36] /* ecx = dcode */ and eax, edx /* eax &= hold */ mov eax, [ecx+eax*4]/* eax = dcode[hold & dmask] */ L_dodist: mov ebp, eax /* dist = this */ shr ebp, 16 /* dist = this.val */ mov cl, ah sub bl, ah /* bits -= this.bits */ shr edx, cl /* hold >>= this.bits */ mov cl, al /* cl = this.op */ test al, 16 /* if ((op & 16) == 0) */ jz L_test_for_second_level_dist and cl, 15 /* op &= 15 */ jz L_check_dist_one cmp bl, cl jae L_add_bits_to_dist /* if (op <= bits) 97.6% */ mov ch, cl /* stash op in ch, freeing cl */ xor eax, eax lodsw /* al = *(ushort *)in++ */ mov cl, bl /* cl = bits, needs it for shifting */ add bl, 16 /* bits += 16 */ shl eax, cl or edx, eax /* hold |= *((ushort *)in)++ << bits */ mov cl, ch /* move op back to ecx */ L_add_bits_to_dist: sub bl, cl xor eax, eax inc eax shl eax, cl dec eax /* (1 << op) - 1 */ and eax, edx /* eax &= hold */ shr edx, cl add ebp, eax /* dist += hold & ((1 << op) - 1) */ L_check_window: mov [esp+8], esi /* save in so from can use it's reg */ mov eax, edi sub eax, [esp+20] /* nbytes = out - beg */ cmp eax, ebp jb L_clip_window /* if (dist > nbytes) 4.2% */ mov ecx, [esp+64] /* ecx = len */ mov esi, edi sub esi, ebp /* from = out - dist */ sar ecx, 1 jnc L_copy_two rep movsw mov al, [esi] mov [edi], al inc edi mov esi, [esp+8] /* move in back to %esi, toss from */ mov ebp, [esp+32] /* ebp = lcode */ jmp L_while_test L_copy_two: rep movsw mov esi, [esp+8] /* move in back to %esi, toss from */ mov ebp, [esp+32] /* ebp = lcode */ jmp L_while_test ALIGN 4 L_check_dist_one: cmp ebp, 1 /* if dist 1, is a memset */ jne L_check_window cmp [esp+20], edi je L_check_window /* out == beg, if outside window */ mov ecx, [esp+64] /* ecx = len */ mov al, [edi-1] mov ah, al sar ecx, 1 jnc L_set_two mov [edi], al /* memset out with from[-1] */ inc edi L_set_two: rep stosw mov ebp, [esp+32] /* ebp = lcode */ jmp L_while_test ALIGN 4 L_test_for_second_level_length: test al, 64 jnz L_test_for_end_of_block /* if ((op & 64) != 0) */ xor eax, eax inc eax shl eax, cl dec eax and eax, edx /* eax &= hold */ add eax, [esp+64] /* eax += len */ mov eax, [ebp+eax*4] /* eax = lcode[val+(hold&mask[op])]*/ jmp L_dolen ALIGN 4 L_test_for_second_level_dist: test al, 64 jnz L_invalid_distance_code /* if ((op & 64) != 0) */ xor eax, eax inc eax shl eax, cl dec eax and eax, edx /* eax &= hold */ add eax, ebp /* eax += dist */ mov ecx, [esp+36] /* ecx = dcode */ mov eax, [ecx+eax*4] /* eax = dcode[val+(hold&mask[op])]*/ jmp L_dodist ALIGN 4 L_clip_window: mov ecx, eax mov eax, [esp+48] /* eax = wsize */ neg ecx /* nbytes = -nbytes */ mov esi, [esp+28] /* from = window */ cmp eax, ebp jb L_invalid_distance_too_far /* if (dist > wsize) */ add ecx, ebp /* nbytes = dist - nbytes */ cmp dword ptr [esp+52], 0 jne L_wrap_around_window /* if (write != 0) */ sub eax, ecx add esi, eax /* from += wsize - nbytes */ mov eax, [esp+64] /* eax = len */ cmp eax, ecx jbe L_do_copy /* if (nbytes >= len) */ sub eax, ecx /* len -= nbytes */ rep movsb mov esi, edi sub esi, ebp /* from = out - dist */ jmp L_do_copy ALIGN 4 L_wrap_around_window: mov eax, [esp+52] /* eax = write */ cmp ecx, eax jbe L_contiguous_in_window /* if (write >= nbytes) */ add esi, [esp+48] /* from += wsize */ add esi, eax /* from += write */ sub esi, ecx /* from -= nbytes */ sub ecx, eax /* nbytes -= write */ mov eax, [esp+64] /* eax = len */ cmp eax, ecx jbe L_do_copy /* if (nbytes >= len) */ sub eax, ecx /* len -= nbytes */ rep movsb mov esi, [esp+28] /* from = window */ mov ecx, [esp+52] /* nbytes = write */ cmp eax, ecx jbe L_do_copy /* if (nbytes >= len) */ sub eax, ecx /* len -= nbytes */ rep movsb mov esi, edi sub esi, ebp /* from = out - dist */ jmp L_do_copy ALIGN 4 L_contiguous_in_window: add esi, eax sub esi, ecx /* from += write - nbytes */ mov eax, [esp+64] /* eax = len */ cmp eax, ecx jbe L_do_copy /* if (nbytes >= len) */ sub eax, ecx /* len -= nbytes */ rep movsb mov esi, edi sub esi, ebp /* from = out - dist */ jmp L_do_copy ALIGN 4 L_do_copy: mov ecx, eax rep movsb mov esi, [esp+8] /* move in back to %esi, toss from */ mov ebp, [esp+32] /* ebp = lcode */ jmp L_while_test L_test_for_end_of_block: test al, 32 jz L_invalid_literal_length_code mov dword ptr [esp+72], 1 jmp L_break_loop_with_status L_invalid_literal_length_code: mov dword ptr [esp+72], 2 jmp L_break_loop_with_status L_invalid_distance_code: mov dword ptr [esp+72], 3 jmp L_break_loop_with_status L_invalid_distance_too_far: mov esi, [esp+4] mov dword ptr [esp+72], 4 jmp L_break_loop_with_status L_break_loop: mov dword ptr [esp+72], 0 L_break_loop_with_status: /* put in, out, bits, and hold back into ar and pop esp */ mov [esp+8], esi /* save in */ mov [esp+16], edi /* save out */ mov [esp+44], ebx /* save bits */ mov [esp+40], edx /* save hold */ mov ebp, [esp+4] /* restore esp, ebp */ mov esp, [esp] } #else #error "x86 architecture not defined" #endif if (ar.status > 1) { if (ar.status == 2) strm->msg = "invalid literal/length code"; else if (ar.status == 3) strm->msg = "invalid distance code"; else strm->msg = "invalid distance too far back"; state->mode = BAD; } else if ( ar.status == 1 ) { state->mode = TYPE; } /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ ar.len = ar.bits >> 3; ar.in -= ar.len; ar.bits -= ar.len << 3; ar.hold &= (1U << ar.bits) - 1; /* update state and return */ strm->next_in = ar.in; strm->next_out = ar.out; strm->avail_in = (unsigned)(ar.in < ar.last ? PAD_AVAIL_IN + (ar.last - ar.in) : PAD_AVAIL_IN - (ar.in - ar.last)); strm->avail_out = (unsigned)(ar.out < ar.end ? PAD_AVAIL_OUT + (ar.end - ar.out) : PAD_AVAIL_OUT - (ar.out - ar.end)); state->hold = ar.hold; state->bits = ar.bits; return; } sks-ecc-0.93/zlib/contrib/inflate86/inffast.S0000644000175000017500000012353210604550750017725 0ustar nachonacho/* * inffast.S is a hand tuned assembler version of: * * inffast.c -- fast decoding * Copyright (C) 1995-2003 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h * * Copyright (C) 2003 Chris Anderson * Please use the copyright conditions above. * * This version (Jan-23-2003) of inflate_fast was coded and tested under * GNU/Linux on a pentium 3, using the gcc-3.2 compiler distribution. On that * machine, I found that gzip style archives decompressed about 20% faster than * the gcc-3.2 -O3 -fomit-frame-pointer compiled version. Your results will * depend on how large of a buffer is used for z_stream.next_in & next_out * (8K-32K worked best for my 256K cpu cache) and how much overhead there is in * stream processing I/O and crc32/addler32. In my case, this routine used * 70% of the cpu time and crc32 used 20%. * * I am confident that this version will work in the general case, but I have * not tested a wide variety of datasets or a wide variety of platforms. * * Jan-24-2003 -- Added -DUSE_MMX define for slightly faster inflating. * It should be a runtime flag instead of compile time flag... * * Jan-26-2003 -- Added runtime check for MMX support with cpuid instruction. * With -DUSE_MMX, only MMX code is compiled. With -DNO_MMX, only non-MMX code * is compiled. Without either option, runtime detection is enabled. Runtime * detection should work on all modern cpus and the recomended algorithm (flip * ID bit on eflags and then use the cpuid instruction) is used in many * multimedia applications. Tested under win2k with gcc-2.95 and gas-2.12 * distributed with cygwin3. Compiling with gcc-2.95 -c inffast.S -o * inffast.obj generates a COFF object which can then be linked with MSVC++ * compiled code. Tested under FreeBSD 4.7 with gcc-2.95. * * Jan-28-2003 -- Tested Athlon XP... MMX mode is slower than no MMX (and * slower than compiler generated code). Adjusted cpuid check to use the MMX * code only for Pentiums < P4 until I have more data on the P4. Speed * improvment is only about 15% on the Athlon when compared with code generated * with MSVC++. Not sure yet, but I think the P4 will also be slower using the * MMX mode because many of it's x86 ALU instructions execute in .5 cycles and * have less latency than MMX ops. Added code to buffer the last 11 bytes of * the input stream since the MMX code grabs bits in chunks of 32, which * differs from the inffast.c algorithm. I don't think there would have been * read overruns where a page boundary was crossed (a segfault), but there * could have been overruns when next_in ends on unaligned memory (unintialized * memory read). * * Mar-13-2003 -- P4 MMX is slightly slower than P4 NO_MMX. I created a C * version of the non-MMX code so that it doesn't depend on zstrm and zstate * structure offsets which are hard coded in this file. This was last tested * with zlib-1.2.0 which is currently in beta testing, newer versions of this * and inffas86.c can be found at http://www.eetbeetee.com/zlib/ and * http://www.charm.net/~christop/zlib/ */ /* * if you have underscore linking problems (_inflate_fast undefined), try * using -DGAS_COFF */ #if ! defined( GAS_COFF ) && ! defined( GAS_ELF ) #if defined( WIN32 ) || defined( __CYGWIN__ ) #define GAS_COFF /* windows object format */ #else #define GAS_ELF #endif #endif /* ! GAS_COFF && ! GAS_ELF */ #if defined( GAS_COFF ) /* coff externals have underscores */ #define inflate_fast _inflate_fast #define inflate_fast_use_mmx _inflate_fast_use_mmx #endif /* GAS_COFF */ .file "inffast.S" .globl inflate_fast .text .align 4,0 .L_invalid_literal_length_code_msg: .string "invalid literal/length code" .align 4,0 .L_invalid_distance_code_msg: .string "invalid distance code" .align 4,0 .L_invalid_distance_too_far_msg: .string "invalid distance too far back" #if ! defined( NO_MMX ) .align 4,0 .L_mask: /* mask[N] = ( 1 << N ) - 1 */ .long 0 .long 1 .long 3 .long 7 .long 15 .long 31 .long 63 .long 127 .long 255 .long 511 .long 1023 .long 2047 .long 4095 .long 8191 .long 16383 .long 32767 .long 65535 .long 131071 .long 262143 .long 524287 .long 1048575 .long 2097151 .long 4194303 .long 8388607 .long 16777215 .long 33554431 .long 67108863 .long 134217727 .long 268435455 .long 536870911 .long 1073741823 .long 2147483647 .long 4294967295 #endif /* NO_MMX */ .text /* * struct z_stream offsets, in zlib.h */ #define next_in_strm 0 /* strm->next_in */ #define avail_in_strm 4 /* strm->avail_in */ #define next_out_strm 12 /* strm->next_out */ #define avail_out_strm 16 /* strm->avail_out */ #define msg_strm 24 /* strm->msg */ #define state_strm 28 /* strm->state */ /* * struct inflate_state offsets, in inflate.h */ #define mode_state 0 /* state->mode */ #define wsize_state 32 /* state->wsize */ #define write_state 40 /* state->write */ #define window_state 44 /* state->window */ #define hold_state 48 /* state->hold */ #define bits_state 52 /* state->bits */ #define lencode_state 68 /* state->lencode */ #define distcode_state 72 /* state->distcode */ #define lenbits_state 76 /* state->lenbits */ #define distbits_state 80 /* state->distbits */ /* * inflate_fast's activation record */ #define local_var_size 64 /* how much local space for vars */ #define strm_sp 88 /* first arg: z_stream * (local_var_size + 24) */ #define start_sp 92 /* second arg: unsigned int (local_var_size + 28) */ /* * offsets for local vars on stack */ #define out 60 /* unsigned char* */ #define window 56 /* unsigned char* */ #define wsize 52 /* unsigned int */ #define write 48 /* unsigned int */ #define in 44 /* unsigned char* */ #define beg 40 /* unsigned char* */ #define buf 28 /* char[ 12 ] */ #define len 24 /* unsigned int */ #define last 20 /* unsigned char* */ #define end 16 /* unsigned char* */ #define dcode 12 /* code* */ #define lcode 8 /* code* */ #define dmask 4 /* unsigned int */ #define lmask 0 /* unsigned int */ /* * typedef enum inflate_mode consts, in inflate.h */ #define INFLATE_MODE_TYPE 11 /* state->mode flags enum-ed in inflate.h */ #define INFLATE_MODE_BAD 26 #if ! defined( USE_MMX ) && ! defined( NO_MMX ) #define RUN_TIME_MMX #define CHECK_MMX 1 #define DO_USE_MMX 2 #define DONT_USE_MMX 3 .globl inflate_fast_use_mmx .data .align 4,0 inflate_fast_use_mmx: /* integer flag for run time control 1=check,2=mmx,3=no */ .long CHECK_MMX #if defined( GAS_ELF ) /* elf info */ .type inflate_fast_use_mmx,@object .size inflate_fast_use_mmx,4 #endif #endif /* RUN_TIME_MMX */ #if defined( GAS_COFF ) /* coff info: scl 2 = extern, type 32 = function */ .def inflate_fast; .scl 2; .type 32; .endef #endif .text .align 32,0x90 inflate_fast: pushl %edi pushl %esi pushl %ebp pushl %ebx pushf /* save eflags (strm_sp, state_sp assumes this is 32 bits) */ subl $local_var_size, %esp cld #define strm_r %esi #define state_r %edi movl strm_sp(%esp), strm_r movl state_strm(strm_r), state_r /* in = strm->next_in; * out = strm->next_out; * last = in + strm->avail_in - 11; * beg = out - (start - strm->avail_out); * end = out + (strm->avail_out - 257); */ movl avail_in_strm(strm_r), %edx movl next_in_strm(strm_r), %eax addl %eax, %edx /* avail_in += next_in */ subl $11, %edx /* avail_in -= 11 */ movl %eax, in(%esp) movl %edx, last(%esp) movl start_sp(%esp), %ebp movl avail_out_strm(strm_r), %ecx movl next_out_strm(strm_r), %ebx subl %ecx, %ebp /* start -= avail_out */ negl %ebp /* start = -start */ addl %ebx, %ebp /* start += next_out */ subl $257, %ecx /* avail_out -= 257 */ addl %ebx, %ecx /* avail_out += out */ movl %ebx, out(%esp) movl %ebp, beg(%esp) movl %ecx, end(%esp) /* wsize = state->wsize; * write = state->write; * window = state->window; * hold = state->hold; * bits = state->bits; * lcode = state->lencode; * dcode = state->distcode; * lmask = ( 1 << state->lenbits ) - 1; * dmask = ( 1 << state->distbits ) - 1; */ movl lencode_state(state_r), %eax movl distcode_state(state_r), %ecx movl %eax, lcode(%esp) movl %ecx, dcode(%esp) movl $1, %eax movl lenbits_state(state_r), %ecx shll %cl, %eax decl %eax movl %eax, lmask(%esp) movl $1, %eax movl distbits_state(state_r), %ecx shll %cl, %eax decl %eax movl %eax, dmask(%esp) movl wsize_state(state_r), %eax movl write_state(state_r), %ecx movl window_state(state_r), %edx movl %eax, wsize(%esp) movl %ecx, write(%esp) movl %edx, window(%esp) movl hold_state(state_r), %ebp movl bits_state(state_r), %ebx #undef strm_r #undef state_r #define in_r %esi #define from_r %esi #define out_r %edi movl in(%esp), in_r movl last(%esp), %ecx cmpl in_r, %ecx ja .L_align_long /* if in < last */ addl $11, %ecx /* ecx = &in[ avail_in ] */ subl in_r, %ecx /* ecx = avail_in */ movl $12, %eax subl %ecx, %eax /* eax = 12 - avail_in */ leal buf(%esp), %edi rep movsb /* memcpy( buf, in, avail_in ) */ movl %eax, %ecx xorl %eax, %eax rep stosb /* memset( &buf[ avail_in ], 0, 12 - avail_in ) */ leal buf(%esp), in_r /* in = buf */ movl in_r, last(%esp) /* last = in, do just one iteration */ jmp .L_is_aligned /* align in_r on long boundary */ .L_align_long: testl $3, in_r jz .L_is_aligned xorl %eax, %eax movb (in_r), %al incl in_r movl %ebx, %ecx addl $8, %ebx shll %cl, %eax orl %eax, %ebp jmp .L_align_long .L_is_aligned: movl out(%esp), out_r #if defined( NO_MMX ) jmp .L_do_loop #endif #if defined( USE_MMX ) jmp .L_init_mmx #endif /*** Runtime MMX check ***/ #if defined( RUN_TIME_MMX ) .L_check_mmx: cmpl $DO_USE_MMX, inflate_fast_use_mmx je .L_init_mmx ja .L_do_loop /* > 2 */ pushl %eax pushl %ebx pushl %ecx pushl %edx pushf movl (%esp), %eax /* copy eflags to eax */ xorl $0x200000, (%esp) /* try toggling ID bit of eflags (bit 21) * to see if cpu supports cpuid... * ID bit method not supported by NexGen but * bios may load a cpuid instruction and * cpuid may be disabled on Cyrix 5-6x86 */ popf pushf popl %edx /* copy new eflags to edx */ xorl %eax, %edx /* test if ID bit is flipped */ jz .L_dont_use_mmx /* not flipped if zero */ xorl %eax, %eax cpuid cmpl $0x756e6547, %ebx /* check for GenuineIntel in ebx,ecx,edx */ jne .L_dont_use_mmx cmpl $0x6c65746e, %ecx jne .L_dont_use_mmx cmpl $0x49656e69, %edx jne .L_dont_use_mmx movl $1, %eax cpuid /* get cpu features */ shrl $8, %eax andl $15, %eax cmpl $6, %eax /* check for Pentium family, is 0xf for P4 */ jne .L_dont_use_mmx testl $0x800000, %edx /* test if MMX feature is set (bit 23) */ jnz .L_use_mmx jmp .L_dont_use_mmx .L_use_mmx: movl $DO_USE_MMX, inflate_fast_use_mmx jmp .L_check_mmx_pop .L_dont_use_mmx: movl $DONT_USE_MMX, inflate_fast_use_mmx .L_check_mmx_pop: popl %edx popl %ecx popl %ebx popl %eax jmp .L_check_mmx #endif /*** Non-MMX code ***/ #if defined ( NO_MMX ) || defined( RUN_TIME_MMX ) #define hold_r %ebp #define bits_r %bl #define bitslong_r %ebx .align 32,0x90 .L_while_test: /* while (in < last && out < end) */ cmpl out_r, end(%esp) jbe .L_break_loop /* if (out >= end) */ cmpl in_r, last(%esp) jbe .L_break_loop .L_do_loop: /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out * * do { * if (bits < 15) { * hold |= *((unsigned short *)in)++ << bits; * bits += 16 * } * this = lcode[hold & lmask] */ cmpb $15, bits_r ja .L_get_length_code /* if (15 < bits) */ xorl %eax, %eax lodsw /* al = *(ushort *)in++ */ movb bits_r, %cl /* cl = bits, needs it for shifting */ addb $16, bits_r /* bits += 16 */ shll %cl, %eax orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */ .L_get_length_code: movl lmask(%esp), %edx /* edx = lmask */ movl lcode(%esp), %ecx /* ecx = lcode */ andl hold_r, %edx /* edx &= hold */ movl (%ecx,%edx,4), %eax /* eax = lcode[hold & lmask] */ .L_dolen: /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out * * dolen: * bits -= this.bits; * hold >>= this.bits */ movb %ah, %cl /* cl = this.bits */ subb %ah, bits_r /* bits -= this.bits */ shrl %cl, hold_r /* hold >>= this.bits */ /* check if op is a literal * if (op == 0) { * PUP(out) = this.val; * } */ testb %al, %al jnz .L_test_for_length_base /* if (op != 0) 45.7% */ shrl $16, %eax /* output this.val char */ stosb jmp .L_while_test .L_test_for_length_base: /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out, %edx = len * * else if (op & 16) { * len = this.val * op &= 15 * if (op) { * if (op > bits) { * hold |= *((unsigned short *)in)++ << bits; * bits += 16 * } * len += hold & mask[op]; * bits -= op; * hold >>= op; * } */ #define len_r %edx movl %eax, len_r /* len = this */ shrl $16, len_r /* len = this.val */ movb %al, %cl testb $16, %al jz .L_test_for_second_level_length /* if ((op & 16) == 0) 8% */ andb $15, %cl /* op &= 15 */ jz .L_save_len /* if (!op) */ cmpb %cl, bits_r jae .L_add_bits_to_len /* if (op <= bits) */ movb %cl, %ch /* stash op in ch, freeing cl */ xorl %eax, %eax lodsw /* al = *(ushort *)in++ */ movb bits_r, %cl /* cl = bits, needs it for shifting */ addb $16, bits_r /* bits += 16 */ shll %cl, %eax orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */ movb %ch, %cl /* move op back to ecx */ .L_add_bits_to_len: movl $1, %eax shll %cl, %eax decl %eax subb %cl, bits_r andl hold_r, %eax /* eax &= hold */ shrl %cl, hold_r addl %eax, len_r /* len += hold & mask[op] */ .L_save_len: movl len_r, len(%esp) /* save len */ #undef len_r .L_decode_distance: /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out, %edx = dist * * if (bits < 15) { * hold |= *((unsigned short *)in)++ << bits; * bits += 16 * } * this = dcode[hold & dmask]; * dodist: * bits -= this.bits; * hold >>= this.bits; * op = this.op; */ cmpb $15, bits_r ja .L_get_distance_code /* if (15 < bits) */ xorl %eax, %eax lodsw /* al = *(ushort *)in++ */ movb bits_r, %cl /* cl = bits, needs it for shifting */ addb $16, bits_r /* bits += 16 */ shll %cl, %eax orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */ .L_get_distance_code: movl dmask(%esp), %edx /* edx = dmask */ movl dcode(%esp), %ecx /* ecx = dcode */ andl hold_r, %edx /* edx &= hold */ movl (%ecx,%edx,4), %eax /* eax = dcode[hold & dmask] */ #define dist_r %edx .L_dodist: movl %eax, dist_r /* dist = this */ shrl $16, dist_r /* dist = this.val */ movb %ah, %cl subb %ah, bits_r /* bits -= this.bits */ shrl %cl, hold_r /* hold >>= this.bits */ /* if (op & 16) { * dist = this.val * op &= 15 * if (op > bits) { * hold |= *((unsigned short *)in)++ << bits; * bits += 16 * } * dist += hold & mask[op]; * bits -= op; * hold >>= op; */ movb %al, %cl /* cl = this.op */ testb $16, %al /* if ((op & 16) == 0) */ jz .L_test_for_second_level_dist andb $15, %cl /* op &= 15 */ jz .L_check_dist_one cmpb %cl, bits_r jae .L_add_bits_to_dist /* if (op <= bits) 97.6% */ movb %cl, %ch /* stash op in ch, freeing cl */ xorl %eax, %eax lodsw /* al = *(ushort *)in++ */ movb bits_r, %cl /* cl = bits, needs it for shifting */ addb $16, bits_r /* bits += 16 */ shll %cl, %eax orl %eax, hold_r /* hold |= *((ushort *)in)++ << bits */ movb %ch, %cl /* move op back to ecx */ .L_add_bits_to_dist: movl $1, %eax shll %cl, %eax decl %eax /* (1 << op) - 1 */ subb %cl, bits_r andl hold_r, %eax /* eax &= hold */ shrl %cl, hold_r addl %eax, dist_r /* dist += hold & ((1 << op) - 1) */ jmp .L_check_window .L_check_window: /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist * %ecx = nbytes * * nbytes = out - beg; * if (dist <= nbytes) { * from = out - dist; * do { * PUP(out) = PUP(from); * } while (--len > 0) { * } */ movl in_r, in(%esp) /* save in so from can use it's reg */ movl out_r, %eax subl beg(%esp), %eax /* nbytes = out - beg */ cmpl dist_r, %eax jb .L_clip_window /* if (dist > nbytes) 4.2% */ movl len(%esp), %ecx movl out_r, from_r subl dist_r, from_r /* from = out - dist */ subl $3, %ecx movb (from_r), %al movb %al, (out_r) movb 1(from_r), %al movb 2(from_r), %dl addl $3, from_r movb %al, 1(out_r) movb %dl, 2(out_r) addl $3, out_r rep movsb movl in(%esp), in_r /* move in back to %esi, toss from */ jmp .L_while_test .align 16,0x90 .L_check_dist_one: cmpl $1, dist_r jne .L_check_window cmpl out_r, beg(%esp) je .L_check_window decl out_r movl len(%esp), %ecx movb (out_r), %al subl $3, %ecx movb %al, 1(out_r) movb %al, 2(out_r) movb %al, 3(out_r) addl $4, out_r rep stosb jmp .L_while_test .align 16,0x90 .L_test_for_second_level_length: /* else if ((op & 64) == 0) { * this = lcode[this.val + (hold & mask[op])]; * } */ testb $64, %al jnz .L_test_for_end_of_block /* if ((op & 64) != 0) */ movl $1, %eax shll %cl, %eax decl %eax andl hold_r, %eax /* eax &= hold */ addl %edx, %eax /* eax += this.val */ movl lcode(%esp), %edx /* edx = lcode */ movl (%edx,%eax,4), %eax /* eax = lcode[val + (hold&mask[op])] */ jmp .L_dolen .align 16,0x90 .L_test_for_second_level_dist: /* else if ((op & 64) == 0) { * this = dcode[this.val + (hold & mask[op])]; * } */ testb $64, %al jnz .L_invalid_distance_code /* if ((op & 64) != 0) */ movl $1, %eax shll %cl, %eax decl %eax andl hold_r, %eax /* eax &= hold */ addl %edx, %eax /* eax += this.val */ movl dcode(%esp), %edx /* edx = dcode */ movl (%edx,%eax,4), %eax /* eax = dcode[val + (hold&mask[op])] */ jmp .L_dodist .align 16,0x90 .L_clip_window: /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist * %ecx = nbytes * * else { * if (dist > wsize) { * invalid distance * } * from = window; * nbytes = dist - nbytes; * if (write == 0) { * from += wsize - nbytes; */ #define nbytes_r %ecx movl %eax, nbytes_r movl wsize(%esp), %eax /* prepare for dist compare */ negl nbytes_r /* nbytes = -nbytes */ movl window(%esp), from_r /* from = window */ cmpl dist_r, %eax jb .L_invalid_distance_too_far /* if (dist > wsize) */ addl dist_r, nbytes_r /* nbytes = dist - nbytes */ cmpl $0, write(%esp) jne .L_wrap_around_window /* if (write != 0) */ subl nbytes_r, %eax addl %eax, from_r /* from += wsize - nbytes */ /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist * %ecx = nbytes, %eax = len * * if (nbytes < len) { * len -= nbytes; * do { * PUP(out) = PUP(from); * } while (--nbytes); * from = out - dist; * } * } */ #define len_r %eax movl len(%esp), len_r cmpl nbytes_r, len_r jbe .L_do_copy1 /* if (nbytes >= len) */ subl nbytes_r, len_r /* len -= nbytes */ rep movsb movl out_r, from_r subl dist_r, from_r /* from = out - dist */ jmp .L_do_copy1 cmpl nbytes_r, len_r jbe .L_do_copy1 /* if (nbytes >= len) */ subl nbytes_r, len_r /* len -= nbytes */ rep movsb movl out_r, from_r subl dist_r, from_r /* from = out - dist */ jmp .L_do_copy1 .L_wrap_around_window: /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist * %ecx = nbytes, %eax = write, %eax = len * * else if (write < nbytes) { * from += wsize + write - nbytes; * nbytes -= write; * if (nbytes < len) { * len -= nbytes; * do { * PUP(out) = PUP(from); * } while (--nbytes); * from = window; * nbytes = write; * if (nbytes < len) { * len -= nbytes; * do { * PUP(out) = PUP(from); * } while(--nbytes); * from = out - dist; * } * } * } */ #define write_r %eax movl write(%esp), write_r cmpl write_r, nbytes_r jbe .L_contiguous_in_window /* if (write >= nbytes) */ addl wsize(%esp), from_r addl write_r, from_r subl nbytes_r, from_r /* from += wsize + write - nbytes */ subl write_r, nbytes_r /* nbytes -= write */ #undef write_r movl len(%esp), len_r cmpl nbytes_r, len_r jbe .L_do_copy1 /* if (nbytes >= len) */ subl nbytes_r, len_r /* len -= nbytes */ rep movsb movl window(%esp), from_r /* from = window */ movl write(%esp), nbytes_r /* nbytes = write */ cmpl nbytes_r, len_r jbe .L_do_copy1 /* if (nbytes >= len) */ subl nbytes_r, len_r /* len -= nbytes */ rep movsb movl out_r, from_r subl dist_r, from_r /* from = out - dist */ jmp .L_do_copy1 .L_contiguous_in_window: /* regs: %esi = from, %ebp = hold, %bl = bits, %edi = out, %edx = dist * %ecx = nbytes, %eax = write, %eax = len * * else { * from += write - nbytes; * if (nbytes < len) { * len -= nbytes; * do { * PUP(out) = PUP(from); * } while (--nbytes); * from = out - dist; * } * } */ #define write_r %eax addl write_r, from_r subl nbytes_r, from_r /* from += write - nbytes */ #undef write_r movl len(%esp), len_r cmpl nbytes_r, len_r jbe .L_do_copy1 /* if (nbytes >= len) */ subl nbytes_r, len_r /* len -= nbytes */ rep movsb movl out_r, from_r subl dist_r, from_r /* from = out - dist */ .L_do_copy1: /* regs: %esi = from, %esi = in, %ebp = hold, %bl = bits, %edi = out * %eax = len * * while (len > 0) { * PUP(out) = PUP(from); * len--; * } * } * } while (in < last && out < end); */ #undef nbytes_r #define in_r %esi movl len_r, %ecx rep movsb movl in(%esp), in_r /* move in back to %esi, toss from */ jmp .L_while_test #undef len_r #undef dist_r #endif /* NO_MMX || RUN_TIME_MMX */ /*** MMX code ***/ #if defined( USE_MMX ) || defined( RUN_TIME_MMX ) .align 32,0x90 .L_init_mmx: emms #undef bits_r #undef bitslong_r #define bitslong_r %ebp #define hold_mm %mm0 movd %ebp, hold_mm movl %ebx, bitslong_r #define used_mm %mm1 #define dmask2_mm %mm2 #define lmask2_mm %mm3 #define lmask_mm %mm4 #define dmask_mm %mm5 #define tmp_mm %mm6 movd lmask(%esp), lmask_mm movq lmask_mm, lmask2_mm movd dmask(%esp), dmask_mm movq dmask_mm, dmask2_mm pxor used_mm, used_mm movl lcode(%esp), %ebx /* ebx = lcode */ jmp .L_do_loop_mmx .align 32,0x90 .L_while_test_mmx: /* while (in < last && out < end) */ cmpl out_r, end(%esp) jbe .L_break_loop /* if (out >= end) */ cmpl in_r, last(%esp) jbe .L_break_loop .L_do_loop_mmx: psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ cmpl $32, bitslong_r ja .L_get_length_code_mmx /* if (32 < bits) */ movd bitslong_r, tmp_mm movd (in_r), %mm7 addl $4, in_r psllq tmp_mm, %mm7 addl $32, bitslong_r por %mm7, hold_mm /* hold_mm |= *((uint *)in)++ << bits */ .L_get_length_code_mmx: pand hold_mm, lmask_mm movd lmask_mm, %eax movq lmask2_mm, lmask_mm movl (%ebx,%eax,4), %eax /* eax = lcode[hold & lmask] */ .L_dolen_mmx: movzbl %ah, %ecx /* ecx = this.bits */ movd %ecx, used_mm subl %ecx, bitslong_r /* bits -= this.bits */ testb %al, %al jnz .L_test_for_length_base_mmx /* if (op != 0) 45.7% */ shrl $16, %eax /* output this.val char */ stosb jmp .L_while_test_mmx .L_test_for_length_base_mmx: #define len_r %edx movl %eax, len_r /* len = this */ shrl $16, len_r /* len = this.val */ testb $16, %al jz .L_test_for_second_level_length_mmx /* if ((op & 16) == 0) 8% */ andl $15, %eax /* op &= 15 */ jz .L_decode_distance_mmx /* if (!op) */ psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ movd %eax, used_mm movd hold_mm, %ecx subl %eax, bitslong_r andl .L_mask(,%eax,4), %ecx addl %ecx, len_r /* len += hold & mask[op] */ .L_decode_distance_mmx: psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ cmpl $32, bitslong_r ja .L_get_dist_code_mmx /* if (32 < bits) */ movd bitslong_r, tmp_mm movd (in_r), %mm7 addl $4, in_r psllq tmp_mm, %mm7 addl $32, bitslong_r por %mm7, hold_mm /* hold_mm |= *((uint *)in)++ << bits */ .L_get_dist_code_mmx: movl dcode(%esp), %ebx /* ebx = dcode */ pand hold_mm, dmask_mm movd dmask_mm, %eax movq dmask2_mm, dmask_mm movl (%ebx,%eax,4), %eax /* eax = dcode[hold & lmask] */ .L_dodist_mmx: #define dist_r %ebx movzbl %ah, %ecx /* ecx = this.bits */ movl %eax, dist_r shrl $16, dist_r /* dist = this.val */ subl %ecx, bitslong_r /* bits -= this.bits */ movd %ecx, used_mm testb $16, %al /* if ((op & 16) == 0) */ jz .L_test_for_second_level_dist_mmx andl $15, %eax /* op &= 15 */ jz .L_check_dist_one_mmx .L_add_bits_to_dist_mmx: psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ movd %eax, used_mm /* save bit length of current op */ movd hold_mm, %ecx /* get the next bits on input stream */ subl %eax, bitslong_r /* bits -= op bits */ andl .L_mask(,%eax,4), %ecx /* ecx = hold & mask[op] */ addl %ecx, dist_r /* dist += hold & mask[op] */ .L_check_window_mmx: movl in_r, in(%esp) /* save in so from can use it's reg */ movl out_r, %eax subl beg(%esp), %eax /* nbytes = out - beg */ cmpl dist_r, %eax jb .L_clip_window_mmx /* if (dist > nbytes) 4.2% */ movl len_r, %ecx movl out_r, from_r subl dist_r, from_r /* from = out - dist */ subl $3, %ecx movb (from_r), %al movb %al, (out_r) movb 1(from_r), %al movb 2(from_r), %dl addl $3, from_r movb %al, 1(out_r) movb %dl, 2(out_r) addl $3, out_r rep movsb movl in(%esp), in_r /* move in back to %esi, toss from */ movl lcode(%esp), %ebx /* move lcode back to %ebx, toss dist */ jmp .L_while_test_mmx .align 16,0x90 .L_check_dist_one_mmx: cmpl $1, dist_r jne .L_check_window_mmx cmpl out_r, beg(%esp) je .L_check_window_mmx decl out_r movl len_r, %ecx movb (out_r), %al subl $3, %ecx movb %al, 1(out_r) movb %al, 2(out_r) movb %al, 3(out_r) addl $4, out_r rep stosb movl lcode(%esp), %ebx /* move lcode back to %ebx, toss dist */ jmp .L_while_test_mmx .align 16,0x90 .L_test_for_second_level_length_mmx: testb $64, %al jnz .L_test_for_end_of_block /* if ((op & 64) != 0) */ andl $15, %eax psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ movd hold_mm, %ecx andl .L_mask(,%eax,4), %ecx addl len_r, %ecx movl (%ebx,%ecx,4), %eax /* eax = lcode[hold & lmask] */ jmp .L_dolen_mmx .align 16,0x90 .L_test_for_second_level_dist_mmx: testb $64, %al jnz .L_invalid_distance_code /* if ((op & 64) != 0) */ andl $15, %eax psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ movd hold_mm, %ecx andl .L_mask(,%eax,4), %ecx movl dcode(%esp), %eax /* ecx = dcode */ addl dist_r, %ecx movl (%eax,%ecx,4), %eax /* eax = lcode[hold & lmask] */ jmp .L_dodist_mmx .align 16,0x90 .L_clip_window_mmx: #define nbytes_r %ecx movl %eax, nbytes_r movl wsize(%esp), %eax /* prepare for dist compare */ negl nbytes_r /* nbytes = -nbytes */ movl window(%esp), from_r /* from = window */ cmpl dist_r, %eax jb .L_invalid_distance_too_far /* if (dist > wsize) */ addl dist_r, nbytes_r /* nbytes = dist - nbytes */ cmpl $0, write(%esp) jne .L_wrap_around_window_mmx /* if (write != 0) */ subl nbytes_r, %eax addl %eax, from_r /* from += wsize - nbytes */ cmpl nbytes_r, len_r jbe .L_do_copy1_mmx /* if (nbytes >= len) */ subl nbytes_r, len_r /* len -= nbytes */ rep movsb movl out_r, from_r subl dist_r, from_r /* from = out - dist */ jmp .L_do_copy1_mmx cmpl nbytes_r, len_r jbe .L_do_copy1_mmx /* if (nbytes >= len) */ subl nbytes_r, len_r /* len -= nbytes */ rep movsb movl out_r, from_r subl dist_r, from_r /* from = out - dist */ jmp .L_do_copy1_mmx .L_wrap_around_window_mmx: #define write_r %eax movl write(%esp), write_r cmpl write_r, nbytes_r jbe .L_contiguous_in_window_mmx /* if (write >= nbytes) */ addl wsize(%esp), from_r addl write_r, from_r subl nbytes_r, from_r /* from += wsize + write - nbytes */ subl write_r, nbytes_r /* nbytes -= write */ #undef write_r cmpl nbytes_r, len_r jbe .L_do_copy1_mmx /* if (nbytes >= len) */ subl nbytes_r, len_r /* len -= nbytes */ rep movsb movl window(%esp), from_r /* from = window */ movl write(%esp), nbytes_r /* nbytes = write */ cmpl nbytes_r, len_r jbe .L_do_copy1_mmx /* if (nbytes >= len) */ subl nbytes_r, len_r /* len -= nbytes */ rep movsb movl out_r, from_r subl dist_r, from_r /* from = out - dist */ jmp .L_do_copy1_mmx .L_contiguous_in_window_mmx: #define write_r %eax addl write_r, from_r subl nbytes_r, from_r /* from += write - nbytes */ #undef write_r cmpl nbytes_r, len_r jbe .L_do_copy1_mmx /* if (nbytes >= len) */ subl nbytes_r, len_r /* len -= nbytes */ rep movsb movl out_r, from_r subl dist_r, from_r /* from = out - dist */ .L_do_copy1_mmx: #undef nbytes_r #define in_r %esi movl len_r, %ecx rep movsb movl in(%esp), in_r /* move in back to %esi, toss from */ movl lcode(%esp), %ebx /* move lcode back to %ebx, toss dist */ jmp .L_while_test_mmx #undef hold_r #undef bitslong_r #endif /* USE_MMX || RUN_TIME_MMX */ /*** USE_MMX, NO_MMX, and RUNTIME_MMX from here on ***/ .L_invalid_distance_code: /* else { * strm->msg = "invalid distance code"; * state->mode = BAD; * } */ movl $.L_invalid_distance_code_msg, %ecx movl $INFLATE_MODE_BAD, %edx jmp .L_update_stream_state .L_test_for_end_of_block: /* else if (op & 32) { * state->mode = TYPE; * break; * } */ testb $32, %al jz .L_invalid_literal_length_code /* if ((op & 32) == 0) */ movl $0, %ecx movl $INFLATE_MODE_TYPE, %edx jmp .L_update_stream_state .L_invalid_literal_length_code: /* else { * strm->msg = "invalid literal/length code"; * state->mode = BAD; * } */ movl $.L_invalid_literal_length_code_msg, %ecx movl $INFLATE_MODE_BAD, %edx jmp .L_update_stream_state .L_invalid_distance_too_far: /* strm->msg = "invalid distance too far back"; * state->mode = BAD; */ movl in(%esp), in_r /* from_r has in's reg, put in back */ movl $.L_invalid_distance_too_far_msg, %ecx movl $INFLATE_MODE_BAD, %edx jmp .L_update_stream_state .L_update_stream_state: /* set strm->msg = %ecx, strm->state->mode = %edx */ movl strm_sp(%esp), %eax testl %ecx, %ecx /* if (msg != NULL) */ jz .L_skip_msg movl %ecx, msg_strm(%eax) /* strm->msg = msg */ .L_skip_msg: movl state_strm(%eax), %eax /* state = strm->state */ movl %edx, mode_state(%eax) /* state->mode = edx (BAD | TYPE) */ jmp .L_break_loop .align 32,0x90 .L_break_loop: /* * Regs: * * bits = %ebp when mmx, and in %ebx when non-mmx * hold = %hold_mm when mmx, and in %ebp when non-mmx * in = %esi * out = %edi */ #if defined( USE_MMX ) || defined( RUN_TIME_MMX ) #if defined( RUN_TIME_MMX ) cmpl $DO_USE_MMX, inflate_fast_use_mmx jne .L_update_next_in #endif /* RUN_TIME_MMX */ movl %ebp, %ebx .L_update_next_in: #endif #define strm_r %eax #define state_r %edx /* len = bits >> 3; * in -= len; * bits -= len << 3; * hold &= (1U << bits) - 1; * state->hold = hold; * state->bits = bits; * strm->next_in = in; * strm->next_out = out; */ movl strm_sp(%esp), strm_r movl %ebx, %ecx movl state_strm(strm_r), state_r shrl $3, %ecx subl %ecx, in_r shll $3, %ecx subl %ecx, %ebx movl out_r, next_out_strm(strm_r) movl %ebx, bits_state(state_r) movl %ebx, %ecx leal buf(%esp), %ebx cmpl %ebx, last(%esp) jne .L_buf_not_used /* if buf != last */ subl %ebx, in_r /* in -= buf */ movl next_in_strm(strm_r), %ebx movl %ebx, last(%esp) /* last = strm->next_in */ addl %ebx, in_r /* in += strm->next_in */ movl avail_in_strm(strm_r), %ebx subl $11, %ebx addl %ebx, last(%esp) /* last = &strm->next_in[ avail_in - 11 ] */ .L_buf_not_used: movl in_r, next_in_strm(strm_r) movl $1, %ebx shll %cl, %ebx decl %ebx #if defined( USE_MMX ) || defined( RUN_TIME_MMX ) #if defined( RUN_TIME_MMX ) cmpl $DO_USE_MMX, inflate_fast_use_mmx jne .L_update_hold #endif /* RUN_TIME_MMX */ psrlq used_mm, hold_mm /* hold_mm >>= last bit length */ movd hold_mm, %ebp emms .L_update_hold: #endif /* USE_MMX || RUN_TIME_MMX */ andl %ebx, %ebp movl %ebp, hold_state(state_r) #define last_r %ebx /* strm->avail_in = in < last ? 11 + (last - in) : 11 - (in - last) */ movl last(%esp), last_r cmpl in_r, last_r jbe .L_last_is_smaller /* if (in >= last) */ subl in_r, last_r /* last -= in */ addl $11, last_r /* last += 11 */ movl last_r, avail_in_strm(strm_r) jmp .L_fixup_out .L_last_is_smaller: subl last_r, in_r /* in -= last */ negl in_r /* in = -in */ addl $11, in_r /* in += 11 */ movl in_r, avail_in_strm(strm_r) #undef last_r #define end_r %ebx .L_fixup_out: /* strm->avail_out = out < end ? 257 + (end - out) : 257 - (out - end)*/ movl end(%esp), end_r cmpl out_r, end_r jbe .L_end_is_smaller /* if (out >= end) */ subl out_r, end_r /* end -= out */ addl $257, end_r /* end += 257 */ movl end_r, avail_out_strm(strm_r) jmp .L_done .L_end_is_smaller: subl end_r, out_r /* out -= end */ negl out_r /* out = -out */ addl $257, out_r /* out += 257 */ movl out_r, avail_out_strm(strm_r) #undef end_r #undef strm_r #undef state_r .L_done: addl $local_var_size, %esp popf popl %ebx popl %ebp popl %esi popl %edi ret #if defined( GAS_ELF ) /* elf info */ .type inflate_fast,@function .size inflate_fast,.-inflate_fast #endif sks-ecc-0.93/zlib/gzio.c0000644000175000017500000007457710604550750014041 0ustar nachonacho/* gzio.c -- IO on .gz files * Copyright (C) 1995-2005 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h * * Compile this file with -DNO_GZCOMPRESS to avoid the compression code. */ /* @(#) $Id$ */ #include #include "zutil.h" #ifdef NO_DEFLATE /* for compatibility with old definition */ # define NO_GZCOMPRESS #endif #ifndef NO_DUMMY_DECL struct internal_state {int dummy;}; /* for buggy compilers */ #endif #ifndef Z_BUFSIZE # ifdef MAXSEG_64K # define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */ # else # define Z_BUFSIZE 16384 # endif #endif #ifndef Z_PRINTF_BUFSIZE # define Z_PRINTF_BUFSIZE 4096 #endif #ifdef __MVS__ # pragma map (fdopen , "\174\174FDOPEN") FILE *fdopen(int, const char *); #endif #ifndef STDC extern voidp malloc OF((uInt size)); extern void free OF((voidpf ptr)); #endif #define ALLOC(size) malloc(size) #define TRYFREE(p) {if (p) free(p);} static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ /* gzip flag byte */ #define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ #define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ #define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ #define ORIG_NAME 0x08 /* bit 3 set: original file name present */ #define COMMENT 0x10 /* bit 4 set: file comment present */ #define RESERVED 0xE0 /* bits 5..7: reserved */ typedef struct gz_stream { z_stream stream; int z_err; /* error code for last stream operation */ int z_eof; /* set if end of input file */ FILE *file; /* .gz file */ Byte *inbuf; /* input buffer */ Byte *outbuf; /* output buffer */ uLong crc; /* crc32 of uncompressed data */ char *msg; /* error message */ char *path; /* path name for debugging only */ int transparent; /* 1 if input file is not a .gz file */ char mode; /* 'w' or 'r' */ z_off_t start; /* start of compressed data in file (header skipped) */ z_off_t in; /* bytes into deflate or inflate */ z_off_t out; /* bytes out of deflate or inflate */ int back; /* one character push-back */ int last; /* true if push-back is last character */ } gz_stream; local gzFile gz_open OF((const char *path, const char *mode, int fd)); local int do_flush OF((gzFile file, int flush)); local int get_byte OF((gz_stream *s)); local void check_header OF((gz_stream *s)); local int destroy OF((gz_stream *s)); local void putLong OF((FILE *file, uLong x)); local uLong getLong OF((gz_stream *s)); /* =========================================================================== Opens a gzip (.gz) file for reading or writing. The mode parameter is as in fopen ("rb" or "wb"). The file is given either by file descriptor or path name (if fd == -1). gz_open 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). */ local gzFile gz_open (path, mode, fd) const char *path; const char *mode; int fd; { int err; int level = Z_DEFAULT_COMPRESSION; /* compression level */ int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */ char *p = (char*)mode; gz_stream *s; char fmode[80]; /* copy of mode, without the compression level */ char *m = fmode; if (!path || !mode) return Z_NULL; s = (gz_stream *)ALLOC(sizeof(gz_stream)); if (!s) return Z_NULL; s->stream.zalloc = (alloc_func)0; s->stream.zfree = (free_func)0; s->stream.opaque = (voidpf)0; s->stream.next_in = s->inbuf = Z_NULL; s->stream.next_out = s->outbuf = Z_NULL; s->stream.avail_in = s->stream.avail_out = 0; s->file = NULL; s->z_err = Z_OK; s->z_eof = 0; s->in = 0; s->out = 0; s->back = EOF; s->crc = crc32(0L, Z_NULL, 0); s->msg = NULL; s->transparent = 0; s->path = (char*)ALLOC(strlen(path)+1); if (s->path == NULL) { return destroy(s), (gzFile)Z_NULL; } strcpy(s->path, path); /* do this early for debugging */ s->mode = '\0'; do { if (*p == 'r') s->mode = 'r'; if (*p == 'w' || *p == 'a') s->mode = 'w'; if (*p >= '0' && *p <= '9') { level = *p - '0'; } else if (*p == 'f') { strategy = Z_FILTERED; } else if (*p == 'h') { strategy = Z_HUFFMAN_ONLY; } else if (*p == 'R') { strategy = Z_RLE; } else { *m++ = *p; /* copy the mode */ } } while (*p++ && m != fmode + sizeof(fmode)); if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL; if (s->mode == 'w') { #ifdef NO_GZCOMPRESS err = Z_STREAM_ERROR; #else err = deflateInit2(&(s->stream), level, Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy); /* windowBits is passed < 0 to suppress zlib header */ s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); #endif if (err != Z_OK || s->outbuf == Z_NULL) { return destroy(s), (gzFile)Z_NULL; } } else { s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); err = inflateInit2(&(s->stream), -MAX_WBITS); /* windowBits is passed < 0 to tell that there is no zlib header. * Note that in this case inflate *requires* an extra "dummy" byte * after the compressed stream in order to complete decompression and * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are * present after the compressed stream. */ if (err != Z_OK || s->inbuf == Z_NULL) { return destroy(s), (gzFile)Z_NULL; } } s->stream.avail_out = Z_BUFSIZE; errno = 0; s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode); if (s->file == NULL) { return destroy(s), (gzFile)Z_NULL; } if (s->mode == 'w') { /* Write a very simple .gz header: */ fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); s->start = 10L; /* We use 10L instead of ftell(s->file) to because ftell causes an * fflush on some systems. This version of the library doesn't use * start anyway in write mode, so this initialization is not * necessary. */ } else { check_header(s); /* skip the .gz header */ s->start = ftell(s->file) - s->stream.avail_in; } return (gzFile)s; } /* =========================================================================== Opens a gzip (.gz) file for reading or writing. */ gzFile ZEXPORT gzopen (path, mode) const char *path; const char *mode; { return gz_open (path, mode, -1); } /* =========================================================================== Associate a gzFile with the file descriptor fd. fd is not dup'ed here to mimic the behavio(u)r of fdopen. */ gzFile ZEXPORT gzdopen (fd, mode) int fd; const char *mode; { char name[46]; /* allow for up to 128-bit integers */ if (fd < 0) return (gzFile)Z_NULL; sprintf(name, "", fd); /* for debugging */ return gz_open (name, mode, fd); } /* =========================================================================== * Update the compression level and strategy */ int ZEXPORT gzsetparams (file, level, strategy) gzFile file; int level; int strategy; { gz_stream *s = (gz_stream*)file; if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; /* Make room to allow flushing */ if (s->stream.avail_out == 0) { s->stream.next_out = s->outbuf; if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { s->z_err = Z_ERRNO; } s->stream.avail_out = Z_BUFSIZE; } return deflateParams (&(s->stream), level, strategy); } /* =========================================================================== Read a byte from a gz_stream; update next_in and avail_in. Return EOF for end of file. IN assertion: the stream s has been sucessfully opened for reading. */ local int get_byte(s) gz_stream *s; { if (s->z_eof) return EOF; if (s->stream.avail_in == 0) { errno = 0; s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file); if (s->stream.avail_in == 0) { s->z_eof = 1; if (ferror(s->file)) s->z_err = Z_ERRNO; return EOF; } s->stream.next_in = s->inbuf; } s->stream.avail_in--; return *(s->stream.next_in)++; } /* =========================================================================== Check the gzip header of a gz_stream opened for reading. Set the stream mode to transparent if the gzip magic header is not present; set s->err to Z_DATA_ERROR if the magic header is present but the rest of the header is incorrect. IN assertion: the stream s has already been created sucessfully; s->stream.avail_in is zero for the first time, but may be non-zero for concatenated .gz files. */ local void check_header(s) gz_stream *s; { int method; /* method byte */ int flags; /* flags byte */ uInt len; int c; /* Assure two bytes in the buffer so we can peek ahead -- handle case where first byte of header is at the end of the buffer after the last gzip segment */ len = s->stream.avail_in; if (len < 2) { if (len) s->inbuf[0] = s->stream.next_in[0]; errno = 0; len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file); if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO; s->stream.avail_in += len; s->stream.next_in = s->inbuf; if (s->stream.avail_in < 2) { s->transparent = s->stream.avail_in; return; } } /* Peek ahead to check the gzip magic header */ if (s->stream.next_in[0] != gz_magic[0] || s->stream.next_in[1] != gz_magic[1]) { s->transparent = 1; return; } s->stream.avail_in -= 2; s->stream.next_in += 2; /* Check the rest of the gzip header */ method = get_byte(s); flags = get_byte(s); if (method != Z_DEFLATED || (flags & RESERVED) != 0) { s->z_err = Z_DATA_ERROR; return; } /* Discard time, xflags and OS code: */ for (len = 0; len < 6; len++) (void)get_byte(s); if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */ len = (uInt)get_byte(s); len += ((uInt)get_byte(s))<<8; /* len is garbage if EOF but the loop below will quit anyway */ while (len-- != 0 && get_byte(s) != EOF) ; } if ((flags & ORIG_NAME) != 0) { /* skip the original file name */ while ((c = get_byte(s)) != 0 && c != EOF) ; } if ((flags & COMMENT) != 0) { /* skip the .gz file comment */ while ((c = get_byte(s)) != 0 && c != EOF) ; } if ((flags & HEAD_CRC) != 0) { /* skip the header crc */ for (len = 0; len < 2; len++) (void)get_byte(s); } s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK; } /* =========================================================================== * Cleanup then free the given gz_stream. Return a zlib error code. Try freeing in the reverse order of allocations. */ local int destroy (s) gz_stream *s; { int err = Z_OK; if (!s) return Z_STREAM_ERROR; TRYFREE(s->msg); if (s->stream.state != NULL) { if (s->mode == 'w') { #ifdef NO_GZCOMPRESS err = Z_STREAM_ERROR; #else err = deflateEnd(&(s->stream)); #endif } else if (s->mode == 'r') { err = inflateEnd(&(s->stream)); } } if (s->file != NULL && fclose(s->file)) { #ifdef ESPIPE if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */ #endif err = Z_ERRNO; } if (s->z_err < 0) err = s->z_err; TRYFREE(s->inbuf); TRYFREE(s->outbuf); TRYFREE(s->path); TRYFREE(s); return err; } /* =========================================================================== Reads the given number of uncompressed bytes from the compressed file. gzread returns the number of bytes actually read (0 for end of file). */ int ZEXPORT gzread (file, buf, len) gzFile file; voidp buf; unsigned len; { gz_stream *s = (gz_stream*)file; Bytef *start = (Bytef*)buf; /* starting point for crc computation */ Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR; if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1; if (s->z_err == Z_STREAM_END) return 0; /* EOF */ next_out = (Byte*)buf; s->stream.next_out = (Bytef*)buf; s->stream.avail_out = len; if (s->stream.avail_out && s->back != EOF) { *next_out++ = s->back; s->stream.next_out++; s->stream.avail_out--; s->back = EOF; s->out++; start++; if (s->last) { s->z_err = Z_STREAM_END; return 1; } } while (s->stream.avail_out != 0) { if (s->transparent) { /* Copy first the lookahead bytes: */ uInt n = s->stream.avail_in; if (n > s->stream.avail_out) n = s->stream.avail_out; if (n > 0) { zmemcpy(s->stream.next_out, s->stream.next_in, n); next_out += n; s->stream.next_out = next_out; s->stream.next_in += n; s->stream.avail_out -= n; s->stream.avail_in -= n; } if (s->stream.avail_out > 0) { s->stream.avail_out -= (uInt)fread(next_out, 1, s->stream.avail_out, s->file); } len -= s->stream.avail_out; s->in += len; s->out += len; if (len == 0) s->z_eof = 1; return (int)len; } if (s->stream.avail_in == 0 && !s->z_eof) { errno = 0; s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file); if (s->stream.avail_in == 0) { s->z_eof = 1; if (ferror(s->file)) { s->z_err = Z_ERRNO; break; } } s->stream.next_in = s->inbuf; } s->in += s->stream.avail_in; s->out += s->stream.avail_out; s->z_err = inflate(&(s->stream), Z_NO_FLUSH); s->in -= s->stream.avail_in; s->out -= s->stream.avail_out; if (s->z_err == Z_STREAM_END) { /* Check CRC and original size */ s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); start = s->stream.next_out; if (getLong(s) != s->crc) { s->z_err = Z_DATA_ERROR; } else { (void)getLong(s); /* The uncompressed length returned by above getlong() may be * different from s->out in case of concatenated .gz files. * Check for such files: */ check_header(s); if (s->z_err == Z_OK) { inflateReset(&(s->stream)); s->crc = crc32(0L, Z_NULL, 0); } } } if (s->z_err != Z_OK || s->z_eof) break; } s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); if (len == s->stream.avail_out && (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO)) return -1; return (int)(len - s->stream.avail_out); } /* =========================================================================== Reads one byte from the compressed file. gzgetc returns this byte or -1 in case of end of file or error. */ int ZEXPORT gzgetc(file) gzFile file; { unsigned char c; return gzread(file, &c, 1) == 1 ? c : -1; } /* =========================================================================== Push one byte back onto the stream. */ int ZEXPORT gzungetc(c, file) int c; gzFile file; { gz_stream *s = (gz_stream*)file; if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF; s->back = c; s->out--; s->last = (s->z_err == Z_STREAM_END); if (s->last) s->z_err = Z_OK; s->z_eof = 0; return c; } /* =========================================================================== 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. The current implementation is not optimized at all. */ char * ZEXPORT gzgets(file, buf, len) gzFile file; char *buf; int len; { char *b = buf; if (buf == Z_NULL || len <= 0) return Z_NULL; while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ; *buf = '\0'; return b == buf && len > 0 ? Z_NULL : b; } #ifndef NO_GZCOMPRESS /* =========================================================================== Writes the given number of uncompressed bytes into the compressed file. gzwrite returns the number of bytes actually written (0 in case of error). */ int ZEXPORT gzwrite (file, buf, len) gzFile file; voidpc buf; unsigned len; { gz_stream *s = (gz_stream*)file; if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; s->stream.next_in = (Bytef*)buf; s->stream.avail_in = len; while (s->stream.avail_in != 0) { if (s->stream.avail_out == 0) { s->stream.next_out = s->outbuf; if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { s->z_err = Z_ERRNO; break; } s->stream.avail_out = Z_BUFSIZE; } s->in += s->stream.avail_in; s->out += s->stream.avail_out; s->z_err = deflate(&(s->stream), Z_NO_FLUSH); s->in -= s->stream.avail_in; s->out -= s->stream.avail_out; if (s->z_err != Z_OK) break; } s->crc = crc32(s->crc, (const Bytef *)buf, len); return (int)(len - s->stream.avail_in); } /* =========================================================================== 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). */ #ifdef STDC #include int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...) { char buf[Z_PRINTF_BUFSIZE]; va_list va; int len; buf[sizeof(buf) - 1] = 0; va_start(va, format); #ifdef NO_vsnprintf # ifdef HAS_vsprintf_void (void)vsprintf(buf, format, va); va_end(va); for (len = 0; len < sizeof(buf); len++) if (buf[len] == 0) break; # else len = vsprintf(buf, format, va); va_end(va); # endif #else # ifdef HAS_vsnprintf_void (void)vsnprintf(buf, sizeof(buf), format, va); va_end(va); len = strlen(buf); # else len = vsnprintf(buf, sizeof(buf), format, va); va_end(va); # endif #endif if (len <= 0 || len >= (int)sizeof(buf) || buf[sizeof(buf) - 1] != 0) return 0; return gzwrite(file, buf, (unsigned)len); } #else /* not ANSI C */ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) gzFile file; const char *format; int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; { char buf[Z_PRINTF_BUFSIZE]; int len; buf[sizeof(buf) - 1] = 0; #ifdef NO_snprintf # ifdef HAS_sprintf_void sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); for (len = 0; len < sizeof(buf); len++) if (buf[len] == 0) break; # else len = sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); # endif #else # ifdef HAS_snprintf_void snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); len = strlen(buf); # else len = snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); # endif #endif if (len <= 0 || len >= sizeof(buf) || buf[sizeof(buf) - 1] != 0) return 0; return gzwrite(file, buf, len); } #endif /* =========================================================================== Writes c, converted to an unsigned char, into the compressed file. gzputc returns the value that was written, or -1 in case of error. */ int ZEXPORT gzputc(file, c) gzFile file; int c; { unsigned char cc = (unsigned char) c; /* required for big endian systems */ return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1; } /* =========================================================================== 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. */ int ZEXPORT gzputs(file, s) gzFile file; const char *s; { return gzwrite(file, (char*)s, (unsigned)strlen(s)); } /* =========================================================================== Flushes all pending output into the compressed file. The parameter flush is as in the deflate() function. */ local int do_flush (file, flush) gzFile file; int flush; { uInt len; int done = 0; gz_stream *s = (gz_stream*)file; if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; s->stream.avail_in = 0; /* should be zero already anyway */ for (;;) { len = Z_BUFSIZE - s->stream.avail_out; if (len != 0) { if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) { s->z_err = Z_ERRNO; return Z_ERRNO; } s->stream.next_out = s->outbuf; s->stream.avail_out = Z_BUFSIZE; } if (done) break; s->out += s->stream.avail_out; s->z_err = deflate(&(s->stream), flush); s->out -= s->stream.avail_out; /* Ignore the second of two consecutive flushes: */ if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK; /* deflate has finished flushing only when it hasn't used up * all the available space in the output buffer: */ done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END); if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break; } return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; } int ZEXPORT gzflush (file, flush) gzFile file; int flush; { gz_stream *s = (gz_stream*)file; int err = do_flush (file, flush); if (err) return err; fflush(s->file); return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; } #endif /* NO_GZCOMPRESS */ /* =========================================================================== Sets the starting position for the next gzread or gzwrite on the given compressed file. The offset represents a number of bytes in the gzseek returns the resulting offset location as measured in bytes from the beginning of the uncompressed stream, or -1 in case of error. SEEK_END is not implemented, returns error. In this version of the library, gzseek can be extremely slow. */ z_off_t ZEXPORT gzseek (file, offset, whence) gzFile file; z_off_t offset; int whence; { gz_stream *s = (gz_stream*)file; if (s == NULL || whence == SEEK_END || s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) { return -1L; } if (s->mode == 'w') { #ifdef NO_GZCOMPRESS return -1L; #else if (whence == SEEK_SET) { offset -= s->in; } if (offset < 0) return -1L; /* At this point, offset is the number of zero bytes to write. */ if (s->inbuf == Z_NULL) { s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */ if (s->inbuf == Z_NULL) return -1L; zmemzero(s->inbuf, Z_BUFSIZE); } while (offset > 0) { uInt size = Z_BUFSIZE; if (offset < Z_BUFSIZE) size = (uInt)offset; size = gzwrite(file, s->inbuf, size); if (size == 0) return -1L; offset -= size; } return s->in; #endif } /* Rest of function is for reading only */ /* compute absolute position */ if (whence == SEEK_CUR) { offset += s->out; } if (offset < 0) return -1L; if (s->transparent) { /* map to fseek */ s->back = EOF; s->stream.avail_in = 0; s->stream.next_in = s->inbuf; if (fseek(s->file, offset, SEEK_SET) < 0) return -1L; s->in = s->out = offset; return offset; } /* For a negative seek, rewind and use positive seek */ if (offset >= s->out) { offset -= s->out; } else if (gzrewind(file) < 0) { return -1L; } /* offset is now the number of bytes to skip. */ if (offset != 0 && s->outbuf == Z_NULL) { s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); if (s->outbuf == Z_NULL) return -1L; } if (offset && s->back != EOF) { s->back = EOF; s->out++; offset--; if (s->last) s->z_err = Z_STREAM_END; } while (offset > 0) { int size = Z_BUFSIZE; if (offset < Z_BUFSIZE) size = (int)offset; size = gzread(file, s->outbuf, (uInt)size); if (size <= 0) return -1L; offset -= size; } return s->out; } /* =========================================================================== Rewinds input file. */ int ZEXPORT gzrewind (file) gzFile file; { gz_stream *s = (gz_stream*)file; if (s == NULL || s->mode != 'r') return -1; s->z_err = Z_OK; s->z_eof = 0; s->back = EOF; s->stream.avail_in = 0; s->stream.next_in = s->inbuf; s->crc = crc32(0L, Z_NULL, 0); if (!s->transparent) (void)inflateReset(&s->stream); s->in = 0; s->out = 0; return fseek(s->file, s->start, SEEK_SET); } /* =========================================================================== 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. */ z_off_t ZEXPORT gztell (file) gzFile file; { return gzseek(file, 0L, SEEK_CUR); } /* =========================================================================== Returns 1 when EOF has previously been detected reading the given input stream, otherwise zero. */ int ZEXPORT gzeof (file) gzFile file; { gz_stream *s = (gz_stream*)file; /* With concatenated compressed files that can have embedded * crc trailers, z_eof is no longer the only/best indicator of EOF * on a gz_stream. Handle end-of-stream error explicitly here. */ if (s == NULL || s->mode != 'r') return 0; if (s->z_eof) return 1; return s->z_err == Z_STREAM_END; } /* =========================================================================== Returns 1 if reading and doing so transparently, otherwise zero. */ int ZEXPORT gzdirect (file) gzFile file; { gz_stream *s = (gz_stream*)file; if (s == NULL || s->mode != 'r') return 0; return s->transparent; } /* =========================================================================== Outputs a long in LSB order to the given file */ local void putLong (file, x) FILE *file; uLong x; { int n; for (n = 0; n < 4; n++) { fputc((int)(x & 0xff), file); x >>= 8; } } /* =========================================================================== Reads a long in LSB order from the given gz_stream. Sets z_err in case of error. */ local uLong getLong (s) gz_stream *s; { uLong x = (uLong)get_byte(s); int c; x += ((uLong)get_byte(s))<<8; x += ((uLong)get_byte(s))<<16; c = get_byte(s); if (c == EOF) s->z_err = Z_DATA_ERROR; x += ((uLong)c)<<24; return x; } /* =========================================================================== Flushes all pending output if necessary, closes the compressed file and deallocates all the (de)compression state. */ int ZEXPORT gzclose (file) gzFile file; { gz_stream *s = (gz_stream*)file; if (s == NULL) return Z_STREAM_ERROR; if (s->mode == 'w') { #ifdef NO_GZCOMPRESS return Z_STREAM_ERROR; #else if (do_flush (file, Z_FINISH) != Z_OK) return destroy((gz_stream*)file); putLong (s->file, s->crc); putLong (s->file, (uLong)(s->in & 0xffffffff)); #endif } return destroy((gz_stream*)file); } #ifdef STDC # define zstrerror(errnum) strerror(errnum) #else # define zstrerror(errnum) "" #endif /* =========================================================================== 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. */ const char * ZEXPORT gzerror (file, errnum) gzFile file; int *errnum; { char *m; gz_stream *s = (gz_stream*)file; if (s == NULL) { *errnum = Z_STREAM_ERROR; return (const char*)ERR_MSG(Z_STREAM_ERROR); } *errnum = s->z_err; if (*errnum == Z_OK) return (const char*)""; m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg); if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err); TRYFREE(s->msg); s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3); if (s->msg == Z_NULL) return (const char*)ERR_MSG(Z_MEM_ERROR); strcpy(s->msg, s->path); strcat(s->msg, ": "); strcat(s->msg, m); return (const char*)s->msg; } /* =========================================================================== Clear the error and end-of-file flags, and do the same for the real file. */ void ZEXPORT gzclearerr (file) gzFile file; { gz_stream *s = (gz_stream*)file; if (s == NULL) return; if (s->z_err != Z_STREAM_END) s->z_err = Z_OK; s->z_eof = 0; clearerr(s->file); } sks-ecc-0.93/zlib/Makefile0000644000175000017500000001005510707473572014354 0ustar nachonacho# Makefile for zlib # Copyright (C) 1995-2005 Jean-loup Gailly. # For conditions of distribution and use, see copyright notice in zlib.h # To compile and test, type: # ./configure; make test # The call of configure is optional if you don't have special requirements # If you wish to build zlib as a shared library, use: ./configure -s # To use the asm code, type: # cp contrib/asm?86/match.S ./match.S # make LOC=-DASMV OBJA=match.o # To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: # make install # To install in $HOME instead of /usr/local, use: # make install prefix=$HOME CC=gcc CFLAGS=-O3 -DUSE_MMAP #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 #CFLAGS=-g -DDEBUG #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ # -Wstrict-prototypes -Wmissing-prototypes LDFLAGS=-L. libz.a LDSHARED=gcc CPP=gcc -E LIBS=libz.a SHAREDLIB=libz.so SHAREDLIBV=libz.so.1.2.3 SHAREDLIBM=libz.so.1 AR=ar rc RANLIB=ranlib TAR=tar SHELL=/bin/sh EXE= prefix =/usr/local exec_prefix =${prefix} libdir =${exec_prefix}/lib includedir =${prefix}/include mandir =${prefix}/share/man man3dir = ${mandir}/man3 OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ zutil.o inflate.o infback.o inftrees.o inffast.o OBJA = # to use the asm code: make OBJA=match.o TEST_OBJS = example.o minigzip.o all: example$(EXE) minigzip$(EXE) check: test test: all @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ echo hello world | ./minigzip | ./minigzip -d || \ echo ' *** minigzip test FAILED ***' ; \ if ./example; then \ echo ' *** zlib test OK ***'; \ else \ echo ' *** zlib test FAILED ***'; \ fi libz.a: $(OBJS) $(OBJA) $(AR) $@ $(OBJS) $(OBJA) -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 match.o: match.S $(CPP) match.S > _match.s $(CC) -c _match.s mv _match.o match.o rm -f _match.s $(SHAREDLIBV): $(OBJS) $(LDSHARED) -o $@ $(OBJS) rm -f $(SHAREDLIB) $(SHAREDLIBM) ln -s $@ $(SHAREDLIB) ln -s $@ $(SHAREDLIBM) example$(EXE): example.o $(LIBS) $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) minigzip$(EXE): minigzip.o $(LIBS) $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) install: $(LIBS) -@if [ ! -d $(exec_prefix) ]; then mkdir -p $(exec_prefix); fi -@if [ ! -d $(includedir) ]; then mkdir -p $(includedir); fi -@if [ ! -d $(libdir) ]; then mkdir -p $(libdir); fi -@if [ ! -d $(man3dir) ]; then mkdir -p $(man3dir); fi cp zlib.h zconf.h $(includedir) chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h cp $(LIBS) $(libdir) cd $(libdir); chmod 755 $(LIBS) -@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1 cd $(libdir); if test -f $(SHAREDLIBV); then \ rm -f $(SHAREDLIB) $(SHAREDLIBM); \ ln -s $(SHAREDLIBV) $(SHAREDLIB); \ ln -s $(SHAREDLIBV) $(SHAREDLIBM); \ (ldconfig || true) >/dev/null 2>&1; \ fi cp zlib.3 $(man3dir) chmod 644 $(man3dir)/zlib.3 # The ranlib in install is needed on NeXTSTEP which checks file times # ldconfig is for Linux uninstall: cd $(includedir); \ cd $(libdir); rm -f libz.a; \ if test -f $(SHAREDLIBV); then \ rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \ fi cd $(man3dir); rm -f zlib.3 mostlyclean: clean clean: rm -f *.o *~ example$(EXE) minigzip$(EXE) \ libz.* foo.gz so_locations \ _match.s maketree contrib/infback9/*.o maintainer-clean: distclean distclean: clean cp -p Makefile.in Makefile cp -p zconf.in.h zconf.h rm -f .DS_Store tags: etags *.[ch] depend: makedepend -- $(CFLAGS) -- *.[ch] # DO NOT DELETE THIS LINE -- make depend depends on it. adler32.o: zlib.h zconf.h compress.o: zlib.h zconf.h crc32.o: crc32.h zlib.h zconf.h deflate.o: deflate.h zutil.h zlib.h zconf.h example.o: zlib.h zconf.h gzio.o: zutil.h zlib.h zconf.h inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inftrees.o: zutil.h zlib.h zconf.h inftrees.h minigzip.o: zlib.h zconf.h trees.o: deflate.h zutil.h zlib.h zconf.h trees.h uncompr.o: zlib.h zconf.h zutil.o: zutil.h zlib.h zconf.h sks-ecc-0.93/zlib/zutil.h0000644000175000017500000001531310604550750014224 0ustar nachonacho/* zutil.h -- internal interface and configuration of the compression library * Copyright (C) 1995-2005 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ /* @(#) $Id$ */ #ifndef ZUTIL_H #define ZUTIL_H #define ZLIB_INTERNAL #include "zlib.h" #ifdef STDC # ifndef _WIN32_WCE # include # endif # include # include #endif #ifdef NO_ERRNO_H # ifdef _WIN32_WCE /* The Microsoft C Run-Time Library for Windows CE doesn't have * errno. We define it as a global variable to simplify porting. * Its value is always 0 and should not be used. We rename it to * avoid conflict with other libraries that use the same workaround. */ # define errno z_errno # endif extern int errno; #else # ifndef _WIN32_WCE # include # endif #endif #ifndef local # define local static #endif /* compile with -Dlocal if your debugger can't find static symbols */ typedef unsigned char uch; typedef uch FAR uchf; typedef unsigned short ush; typedef ush FAR ushf; typedef unsigned long ulg; extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* (size given to avoid silly warnings with Visual C++) */ #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] #define ERR_RETURN(strm,err) \ return (strm->msg = (char*)ERR_MSG(err), (err)) /* To be used only when the state is known to be valid */ /* common constants */ #ifndef DEF_WBITS # define DEF_WBITS MAX_WBITS #endif /* default windowBits for decompression. MAX_WBITS is for compression only */ #if MAX_MEM_LEVEL >= 8 # define DEF_MEM_LEVEL 8 #else # define DEF_MEM_LEVEL MAX_MEM_LEVEL #endif /* default memLevel */ #define STORED_BLOCK 0 #define STATIC_TREES 1 #define DYN_TREES 2 /* The three kinds of block type */ #define MIN_MATCH 3 #define MAX_MATCH 258 /* The minimum and maximum match lengths */ #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ /* target dependencies */ #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) # define OS_CODE 0x00 # if defined(__TURBOC__) || defined(__BORLANDC__) # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) /* Allow compilation with ANSI keywords only enabled */ void _Cdecl farfree( void *block ); void *_Cdecl farmalloc( unsigned long nbytes ); # else # include # endif # else /* MSC or DJGPP */ # include # endif #endif #ifdef AMIGA # define OS_CODE 0x01 #endif #if defined(VAXC) || defined(VMS) # define OS_CODE 0x02 # define F_OPEN(name, mode) \ fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") #endif #if defined(ATARI) || defined(atarist) # define OS_CODE 0x05 #endif #ifdef OS2 # define OS_CODE 0x06 # ifdef M_I86 #include # endif #endif #if defined(MACOS) || defined(TARGET_OS_MAC) # define OS_CODE 0x07 # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os # include /* for fdopen */ # else # ifndef fdopen # define fdopen(fd,mode) NULL /* No fdopen() */ # endif # endif #endif #ifdef TOPS20 # define OS_CODE 0x0a #endif #ifdef WIN32 # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ # define OS_CODE 0x0b # endif #endif #ifdef __50SERIES /* Prime/PRIMOS */ # define OS_CODE 0x0f #endif #if defined(_BEOS_) || defined(RISCOS) # define fdopen(fd,mode) NULL /* No fdopen() */ #endif #if (defined(_MSC_VER) && (_MSC_VER > 600)) # if defined(_WIN32_WCE) # define fdopen(fd,mode) NULL /* No fdopen() */ # ifndef _PTRDIFF_T_DEFINED typedef int ptrdiff_t; # define _PTRDIFF_T_DEFINED # endif # else # define fdopen(fd,type) _fdopen(fd,type) # endif #endif /* common defaults */ #ifndef OS_CODE # define OS_CODE 0x03 /* assume Unix */ #endif #ifndef F_OPEN # define F_OPEN(name, mode) fopen((name), (mode)) #endif /* functions */ #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) # ifndef HAVE_VSNPRINTF # define HAVE_VSNPRINTF # endif #endif #if defined(__CYGWIN__) # ifndef HAVE_VSNPRINTF # define HAVE_VSNPRINTF # endif #endif #ifndef HAVE_VSNPRINTF # ifdef MSDOS /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), but for now we just assume it doesn't. */ # define NO_vsnprintf # endif # ifdef __TURBOC__ # define NO_vsnprintf # endif # ifdef WIN32 /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ # if !defined(vsnprintf) && !defined(NO_vsnprintf) # define vsnprintf _vsnprintf # endif # endif # ifdef __SASC # define NO_vsnprintf # endif #endif #ifdef VMS # define NO_vsnprintf #endif #if defined(pyr) # define NO_MEMCPY #endif #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) /* Use our own functions for small and medium model with MSC <= 5.0. * You may have to use the same strategy for Borland C (untested). * The __SC__ check is for Symantec. */ # define NO_MEMCPY #endif #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) # define HAVE_MEMCPY #endif #ifdef HAVE_MEMCPY # ifdef SMALL_MEDIUM /* MSDOS small or medium model */ # define zmemcpy _fmemcpy # define zmemcmp _fmemcmp # define zmemzero(dest, len) _fmemset(dest, 0, len) # else # define zmemcpy memcpy # define zmemcmp memcmp # define zmemzero(dest, len) memset(dest, 0, len) # endif #else extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); extern void zmemzero OF((Bytef* dest, uInt len)); #endif /* Diagnostic functions */ #ifdef DEBUG # include extern int z_verbose; extern void z_error OF((char *m)); # define Assert(cond,msg) {if(!(cond)) z_error(msg);} # define Trace(x) {if (z_verbose>=0) fprintf x ;} # define Tracev(x) {if (z_verbose>0) fprintf x ;} # define Tracevv(x) {if (z_verbose>1) fprintf x ;} # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} #else # define Assert(cond,msg) # define Trace(x) # define Tracev(x) # define Tracevv(x) # define Tracec(c,x) # define Tracecv(c,x) #endif voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); void zcfree OF((voidpf opaque, voidpf ptr)); #define ZALLOC(strm, items, size) \ (*((strm)->zalloc))((strm)->opaque, (items), (size)) #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} #endif /* ZUTIL_H */ sks-ecc-0.93/zlib/adler32.c0000644000175000017500000001071710604550750014307 0ustar nachonacho/* adler32.c -- compute the Adler-32 checksum of a data stream * Copyright (C) 1995-2004 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #define ZLIB_INTERNAL #include "zlib.h" #define BASE 65521UL /* largest prime smaller than 65536 */ #define NMAX 5552 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); #define DO16(buf) DO8(buf,0); DO8(buf,8); /* use NO_DIVIDE if your processor does not do division in hardware */ #ifdef NO_DIVIDE # define MOD(a) \ do { \ if (a >= (BASE << 16)) a -= (BASE << 16); \ if (a >= (BASE << 15)) a -= (BASE << 15); \ if (a >= (BASE << 14)) a -= (BASE << 14); \ if (a >= (BASE << 13)) a -= (BASE << 13); \ if (a >= (BASE << 12)) a -= (BASE << 12); \ if (a >= (BASE << 11)) a -= (BASE << 11); \ if (a >= (BASE << 10)) a -= (BASE << 10); \ if (a >= (BASE << 9)) a -= (BASE << 9); \ if (a >= (BASE << 8)) a -= (BASE << 8); \ if (a >= (BASE << 7)) a -= (BASE << 7); \ if (a >= (BASE << 6)) a -= (BASE << 6); \ if (a >= (BASE << 5)) a -= (BASE << 5); \ if (a >= (BASE << 4)) a -= (BASE << 4); \ if (a >= (BASE << 3)) a -= (BASE << 3); \ if (a >= (BASE << 2)) a -= (BASE << 2); \ if (a >= (BASE << 1)) a -= (BASE << 1); \ if (a >= BASE) a -= BASE; \ } while (0) # define MOD4(a) \ do { \ if (a >= (BASE << 4)) a -= (BASE << 4); \ if (a >= (BASE << 3)) a -= (BASE << 3); \ if (a >= (BASE << 2)) a -= (BASE << 2); \ if (a >= (BASE << 1)) a -= (BASE << 1); \ if (a >= BASE) a -= BASE; \ } while (0) #else # define MOD(a) a %= BASE # define MOD4(a) a %= BASE #endif /* ========================================================================= */ uLong ZEXPORT adler32(adler, buf, len) uLong adler; const Bytef *buf; uInt len; { unsigned long sum2; unsigned n; /* split Adler-32 into component sums */ sum2 = (adler >> 16) & 0xffff; adler &= 0xffff; /* in case user likes doing a byte at a time, keep it fast */ if (len == 1) { adler += buf[0]; if (adler >= BASE) adler -= BASE; sum2 += adler; if (sum2 >= BASE) sum2 -= BASE; return adler | (sum2 << 16); } /* initial Adler-32 value (deferred check for len == 1 speed) */ if (buf == Z_NULL) return 1L; /* in case short lengths are provided, keep it somewhat fast */ if (len < 16) { while (len--) { adler += *buf++; sum2 += adler; } if (adler >= BASE) adler -= BASE; MOD4(sum2); /* only added so many BASE's */ return adler | (sum2 << 16); } /* do length NMAX blocks -- requires just one modulo operation */ while (len >= NMAX) { len -= NMAX; n = NMAX / 16; /* NMAX is divisible by 16 */ do { DO16(buf); /* 16 sums unrolled */ buf += 16; } while (--n); MOD(adler); MOD(sum2); } /* do remaining bytes (less than NMAX, still just one modulo) */ if (len) { /* avoid modulos if none remaining */ while (len >= 16) { len -= 16; DO16(buf); buf += 16; } while (len--) { adler += *buf++; sum2 += adler; } MOD(adler); MOD(sum2); } /* return recombined sums */ return adler | (sum2 << 16); } /* ========================================================================= */ uLong ZEXPORT adler32_combine(adler1, adler2, len2) uLong adler1; uLong adler2; z_off_t len2; { unsigned long sum1; unsigned long sum2; unsigned rem; /* the derivation of this formula is left as an exercise for the reader */ rem = (unsigned)(len2 % BASE); sum1 = adler1 & 0xffff; sum2 = rem * sum1; MOD(sum2); sum1 += (adler2 & 0xffff) + BASE - 1; sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; if (sum1 > BASE) sum1 -= BASE; if (sum1 > BASE) sum1 -= BASE; if (sum2 > (BASE << 1)) sum2 -= (BASE << 1); if (sum2 > BASE) sum2 -= BASE; return sum1 | (sum2 << 16); } sks-ecc-0.93/zlib/qnx/0000755000175000017500000000000010604550750013507 5ustar nachonachosks-ecc-0.93/zlib/qnx/package.qpg0000600000175000017500000001443310604550750015610 0ustar nachonacho Library Medium 2.0 zlib zlib alain.bonnefoy@icbt.com Public public www.gzip.org/zlib Jean-Loup Gailly,Mark Adler www.gzip.org/zlib zlib@gzip.org A massively spiffy yet delicately unobtrusive compression library. zlib is designed to be a free, general-purpose, legally unencumbered, lossless data compression library for use on virtually any computer hardware and operating system. http://www.gzip.org/zlib 1.2.3 Medium Stable No License Software Development/Libraries and Extensions/C Libraries zlib,compression qnx6 qnx6 None Developer Install Post No Ignore No Optional InstallOver zlib InstallOver zlib-dev sks-ecc-0.93/zlib/minigzip.c0000644000175000017500000001752210604550750014702 0ustar nachonacho/* minigzip.c -- simulate gzip using the zlib compression library * Copyright (C) 1995-2005 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* * minigzip is a minimal implementation of the gzip utility. This is * only an example of using zlib and isn't meant to replace the * full-featured gzip. No attempt is made to deal with file systems * limiting names to 14 or 8+3 characters, etc... Error checking is * very limited. So use minigzip only for testing; use gzip for the * real thing. On MSDOS, use only on file names without extension * or in pipe mode. */ /* @(#) $Id$ */ #include #include "zlib.h" #ifdef STDC # include # include #endif #ifdef USE_MMAP # include # include # include #endif #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) # include # include # define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) #else # define SET_BINARY_MODE(file) #endif #ifdef VMS # define unlink delete # define GZ_SUFFIX "-gz" #endif #ifdef RISCOS # define unlink remove # define GZ_SUFFIX "-gz" # define fileno(file) file->__file #endif #if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os # include /* for fileno */ #endif #ifndef WIN32 /* unlink already in stdio.h for WIN32 */ extern int unlink OF((const char *)); #endif #ifndef GZ_SUFFIX # define GZ_SUFFIX ".gz" #endif #define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1) #define BUFLEN 16384 #define MAX_NAME_LEN 1024 #ifdef MAXSEG_64K # define local static /* Needed for systems with limitation on stack size. */ #else # define local #endif char *prog; void error OF((const char *msg)); void gz_compress OF((FILE *in, gzFile out)); #ifdef USE_MMAP int gz_compress_mmap OF((FILE *in, gzFile out)); #endif void gz_uncompress OF((gzFile in, FILE *out)); void file_compress OF((char *file, char *mode)); void file_uncompress OF((char *file)); int main OF((int argc, char *argv[])); /* =========================================================================== * Display error message and exit */ void error(msg) const char *msg; { fprintf(stderr, "%s: %s\n", prog, msg); exit(1); } /* =========================================================================== * Compress input to output then close both files. */ void gz_compress(in, out) FILE *in; gzFile out; { local char buf[BUFLEN]; int len; int err; #ifdef USE_MMAP /* Try first compressing with mmap. If mmap fails (minigzip used in a * pipe), use the normal fread loop. */ if (gz_compress_mmap(in, out) == Z_OK) return; #endif for (;;) { len = (int)fread(buf, 1, sizeof(buf), in); if (ferror(in)) { perror("fread"); exit(1); } if (len == 0) break; if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); } fclose(in); if (gzclose(out) != Z_OK) error("failed gzclose"); } #ifdef USE_MMAP /* MMAP version, Miguel Albrecht */ /* Try compressing the input file at once using mmap. Return Z_OK if * if success, Z_ERRNO otherwise. */ int gz_compress_mmap(in, out) FILE *in; gzFile out; { int len; int err; int ifd = fileno(in); caddr_t buf; /* mmap'ed buffer for the entire input file */ off_t buf_len; /* length of the input file */ struct stat sb; /* Determine the size of the file, needed for mmap: */ if (fstat(ifd, &sb) < 0) return Z_ERRNO; buf_len = sb.st_size; if (buf_len <= 0) return Z_ERRNO; /* Now do the actual mmap: */ buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0); if (buf == (caddr_t)(-1)) return Z_ERRNO; /* Compress the whole file at once: */ len = gzwrite(out, (char *)buf, (unsigned)buf_len); if (len != (int)buf_len) error(gzerror(out, &err)); munmap(buf, buf_len); fclose(in); if (gzclose(out) != Z_OK) error("failed gzclose"); return Z_OK; } #endif /* USE_MMAP */ /* =========================================================================== * Uncompress input to output then close both files. */ void gz_uncompress(in, out) gzFile in; FILE *out; { local char buf[BUFLEN]; int len; int err; for (;;) { len = gzread(in, buf, sizeof(buf)); if (len < 0) error (gzerror(in, &err)); if (len == 0) break; if ((int)fwrite(buf, 1, (unsigned)len, out) != len) { error("failed fwrite"); } } if (fclose(out)) error("failed fclose"); if (gzclose(in) != Z_OK) error("failed gzclose"); } /* =========================================================================== * Compress the given file: create a corresponding .gz file and remove the * original. */ void file_compress(file, mode) char *file; char *mode; { local char outfile[MAX_NAME_LEN]; FILE *in; gzFile out; strcpy(outfile, file); strcat(outfile, GZ_SUFFIX); in = fopen(file, "rb"); if (in == NULL) { perror(file); exit(1); } out = gzopen(outfile, mode); if (out == NULL) { fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile); exit(1); } gz_compress(in, out); unlink(file); } /* =========================================================================== * Uncompress the given file and remove the original. */ void file_uncompress(file) char *file; { local char buf[MAX_NAME_LEN]; char *infile, *outfile; FILE *out; gzFile in; uInt len = (uInt)strlen(file); strcpy(buf, file); if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) { infile = file; outfile = buf; outfile[len-3] = '\0'; } else { outfile = file; infile = buf; strcat(infile, GZ_SUFFIX); } in = gzopen(infile, "rb"); if (in == NULL) { fprintf(stderr, "%s: can't gzopen %s\n", prog, infile); exit(1); } out = fopen(outfile, "wb"); if (out == NULL) { perror(file); exit(1); } gz_uncompress(in, out); unlink(infile); } /* =========================================================================== * Usage: minigzip [-d] [-f] [-h] [-r] [-1 to -9] [files...] * -d : decompress * -f : compress with Z_FILTERED * -h : compress with Z_HUFFMAN_ONLY * -r : compress with Z_RLE * -1 to -9 : compression level */ int main(argc, argv) int argc; char *argv[]; { int uncompr = 0; gzFile file; char outmode[20]; strcpy(outmode, "wb6 "); prog = argv[0]; argc--, argv++; while (argc > 0) { if (strcmp(*argv, "-d") == 0) uncompr = 1; else if (strcmp(*argv, "-f") == 0) outmode[3] = 'f'; else if (strcmp(*argv, "-h") == 0) outmode[3] = 'h'; else if (strcmp(*argv, "-r") == 0) outmode[3] = 'R'; else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' && (*argv)[2] == 0) outmode[2] = (*argv)[1]; else break; argc--, argv++; } if (outmode[3] == ' ') outmode[3] = 0; if (argc == 0) { SET_BINARY_MODE(stdin); SET_BINARY_MODE(stdout); if (uncompr) { file = gzdopen(fileno(stdin), "rb"); if (file == NULL) error("can't gzdopen stdin"); gz_uncompress(file, stdout); } else { file = gzdopen(fileno(stdout), outmode); if (file == NULL) error("can't gzdopen stdout"); gz_compress(stdin, file); } } else { do { if (uncompr) { file_uncompress(*argv); } else { file_compress(*argv, outmode); } } while (argv++, --argc); } return 0; } sks-ecc-0.93/zlib/algorithm.txt0000644000175000017500000002217010604550750015432 0ustar nachonacho1. Compression algorithm (deflate) The deflation algorithm used by gzip (also zip and zlib) is a variation of LZ77 (Lempel-Ziv 1977, see reference below). It finds duplicated strings in the input data. The second occurrence of a string is replaced by a pointer to the previous string, in the form of a pair (distance, length). Distances are limited to 32K bytes, and lengths are limited to 258 bytes. When a string does not occur anywhere in the previous 32K bytes, it is emitted as a sequence of literal bytes. (In this description, `string' must be taken as an arbitrary sequence of bytes, and is not restricted to printable characters.) Literals or match lengths are compressed with one Huffman tree, and match distances are compressed with another tree. The trees are stored in a compact form at the start of each block. The blocks can have any size (except that the compressed data for one block must fit in available memory). A block is terminated when deflate() determines that it would be useful to start another block with fresh trees. (This is somewhat similar to the behavior of LZW-based _compress_.) Duplicated strings are found using a hash table. All input strings of length 3 are inserted in the hash table. A hash index is computed for the next 3 bytes. If the hash chain for this index is not empty, all strings in the chain are compared with the current input string, and the longest match is selected. The hash chains are searched starting with the most recent strings, to favor small distances and thus take advantage of the Huffman encoding. The hash chains are singly linked. There are no deletions from the hash chains, the algorithm simply discards matches that are too old. To avoid a worst-case situation, very long hash chains are arbitrarily truncated at a certain length, determined by a runtime option (level parameter of deflateInit). So deflate() does not always find the longest possible match but generally finds a match which is long enough. deflate() also defers the selection of matches with a lazy evaluation mechanism. After a match of length N has been found, deflate() searches for a longer match at the next input byte. If a longer match is found, the previous match is truncated to a length of one (thus producing a single literal byte) and the process of lazy evaluation begins again. Otherwise, the original match is kept, and the next match search is attempted only N steps later. The lazy match evaluation is also subject to a runtime parameter. If the current match is long enough, deflate() reduces the search for a longer match, thus speeding up the whole process. If compression ratio is more important than speed, deflate() attempts a complete second search even if the first match is already long enough. The lazy match evaluation is not performed for the fastest compression modes (level parameter 1 to 3). For these fast modes, new strings are inserted in the hash table only when no match was found, or when the match is not too long. This degrades the compression ratio but saves time since there are both fewer insertions and fewer searches. 2. Decompression algorithm (inflate) 2.1 Introduction The key question is how to represent a Huffman code (or any prefix code) so that you can decode fast. The most important characteristic is that shorter codes are much more common than longer codes, so pay attention to decoding the short codes fast, and let the long codes take longer to decode. inflate() sets up a first level table that covers some number of bits of input less than the length of longest code. It gets that many bits from the stream, and looks it up in the table. The table will tell if the next code is that many bits or less and how many, and if it is, it will tell the value, else it will point to the next level table for which inflate() grabs more bits and tries to decode a longer code. How many bits to make the first lookup is a tradeoff between the time it takes to decode and the time it takes to build the table. If building the table took no time (and if you had infinite memory), then there would only be a first level table to cover all the way to the longest code. However, building the table ends up taking a lot longer for more bits since short codes are replicated many times in such a table. What inflate() does is simply to make the number of bits in the first table a variable, and then to set that variable for the maximum speed. For inflate, which has 286 possible codes for the literal/length tree, the size of the first table is nine bits. Also the distance trees have 30 possible values, and the size of the first table is six bits. Note that for each of those cases, the table ended up one bit longer than the ``average'' code length, i.e. the code length of an approximately flat code which would be a little more than eight bits for 286 symbols and a little less than five bits for 30 symbols. 2.2 More details on the inflate table lookup Ok, you want to know what this cleverly obfuscated inflate tree actually looks like. You are correct that it's not a Huffman tree. It is simply a lookup table for the first, let's say, nine bits of a Huffman symbol. The symbol could be as short as one bit or as long as 15 bits. If a particular symbol is shorter than nine bits, then that symbol's translation is duplicated in all those entries that start with that symbol's bits. For example, if the symbol is four bits, then it's duplicated 32 times in a nine-bit table. If a symbol is nine bits long, it appears in the table once. If the symbol is longer than nine bits, then that entry in the table points to another similar table for the remaining bits. Again, there are duplicated entries as needed. The idea is that most of the time the symbol will be short and there will only be one table look up. (That's whole idea behind data compression in the first place.) For the less frequent long symbols, there will be two lookups. If you had a compression method with really long symbols, you could have as many levels of lookups as is efficient. For inflate, two is enough. So a table entry either points to another table (in which case nine bits in the above example are gobbled), or it contains the translation for the symbol and the number of bits to gobble. Then you start again with the next ungobbled bit. You may wonder: why not just have one lookup table for how ever many bits the longest symbol is? The reason is that if you do that, you end up spending more time filling in duplicate symbol entries than you do actually decoding. At least for deflate's output that generates new trees every several 10's of kbytes. You can imagine that filling in a 2^15 entry table for a 15-bit code would take too long if you're only decoding several thousand symbols. At the other extreme, you could make a new table for every bit in the code. In fact, that's essentially a Huffman tree. But then you spend two much time traversing the tree while decoding, even for short symbols. So the number of bits for the first lookup table is a trade of the time to fill out the table vs. the time spent looking at the second level and above of the table. Here is an example, scaled down: The code being decoded, with 10 symbols, from 1 to 6 bits long: A: 0 B: 10 C: 1100 D: 11010 E: 11011 F: 11100 G: 11101 H: 11110 I: 111110 J: 111111 Let's make the first table three bits long (eight entries): 000: A,1 001: A,1 010: A,1 011: A,1 100: B,2 101: B,2 110: -> table X (gobble 3 bits) 111: -> table Y (gobble 3 bits) Each entry is what the bits decode as and how many bits that is, i.e. how many bits to gobble. Or the entry points to another table, with the number of bits to gobble implicit in the size of the table. Table X is two bits long since the longest code starting with 110 is five bits long: 00: C,1 01: C,1 10: D,2 11: E,2 Table Y is three bits long since the longest code starting with 111 is six bits long: 000: F,2 001: F,2 010: G,2 011: G,2 100: H,2 101: H,2 110: I,3 111: J,3 So what we have here are three tables with a total of 20 entries that had to be constructed. That's compared to 64 entries for a single table. Or compared to 16 entries for a Huffman tree (six two entry tables and one four entry table). Assuming that the code ideally represents the probability of the symbols, it takes on the average 1.25 lookups per symbol. That's compared to one lookup for the single table, or 1.66 lookups per symbol for the Huffman tree. There, I think that gives you a picture of what's going on. For inflate, the meaning of a particular symbol is often more than just a letter. It can be a byte (a "literal"), or it can be either a length or a distance which indicates a base value and a number of bits to fetch after the code that is added to the base value. Or it might be the special end-of-block code. The data structures created in inftrees.c try to encode all that information compactly in the tables. Jean-loup Gailly Mark Adler jloup@gzip.org madler@alumni.caltech.edu References: [LZ77] Ziv J., Lempel A., ``A Universal Algorithm for Sequential Data Compression,'' IEEE Transactions on Information Theory, Vol. 23, No. 3, pp. 337-343. ``DEFLATE Compressed Data Format Specification'' available in http://www.ietf.org/rfc/rfc1951.txt sks-ecc-0.93/zlib/inffast.h0000644000175000017500000000062710604550750014511 0ustar nachonacho/* inffast.h -- header to use inffast.c * Copyright (C) 1995-2003 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ void inflate_fast OF((z_streamp strm, unsigned start)); sks-ecc-0.93/zlib/zconf.in.h0000644000175000017500000002251010604550750014576 0ustar nachonacho/* zconf.h -- configuration of the zlib compression library * Copyright (C) 1995-2005 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #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 deflateBound z_deflateBound # define deflatePrime z_deflatePrime # define inflateInit2_ z_inflateInit2_ # define inflateSetDictionary z_inflateSetDictionary # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateCopy z_inflateCopy # define inflateReset z_inflateReset # define inflateBack z_inflateBack # define inflateBackEnd z_inflateBackEnd # define compress z_compress # define compress2 z_compress2 # define compressBound z_compressBound # define uncompress z_uncompress # define adler32 z_adler32 # define crc32 z_crc32 # define get_crc_table z_get_crc_table # define zError z_zError # define alloc_func z_alloc_func # define free_func z_free_func # define in_func z_in_func # define out_func z_out_func # 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(__MSDOS__) && !defined(MSDOS) # define MSDOS #endif #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) # define OS2 #endif #if defined(_WINDOWS) && !defined(WINDOWS) # define WINDOWS #endif #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) # ifndef WIN32 # define WIN32 # endif #endif #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) # ifndef SYS16BIT # define SYS16BIT # endif # endif #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). */ #ifdef SYS16BIT # define MAXSEG_64K #endif #ifdef MSDOS # define UNALIGNED_OK #endif #ifdef __STDC_VERSION__ # ifndef STDC # define STDC # endif # if __STDC_VERSION__ >= 199901L # ifndef STDC99 # define STDC99 # endif # endif #endif #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) # define STDC #endif #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) # define STDC #endif #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) # define STDC #endif #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) # define STDC #endif #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ # define STDC #endif #ifndef STDC # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ # define const /* note: need a more gentle solution here */ # 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 /* 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. */ #ifdef SYS16BIT # if defined(M_I86SM) || defined(M_I86MM) /* MSC small or medium model */ # define SMALL_MEDIUM # ifdef _MSC_VER # define FAR _far # else # define FAR far # endif # endif # if (defined(__SMALL__) || defined(__MEDIUM__)) /* Turbo C small or medium model */ # define SMALL_MEDIUM # ifdef __BORLANDC__ # define FAR _far # else # define FAR far # endif # endif #endif #if defined(WINDOWS) || defined(WIN32) /* If building or using zlib as a DLL, define ZLIB_DLL. * This is not mandatory, but it offers a little performance increase. */ # ifdef ZLIB_DLL # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) # ifdef ZLIB_INTERNAL # define ZEXTERN extern __declspec(dllexport) # else # define ZEXTERN extern __declspec(dllimport) # endif # endif # endif /* ZLIB_DLL */ /* If building or using zlib with the WINAPI/WINAPIV calling convention, * define ZLIB_WINAPI. * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. */ # ifdef ZLIB_WINAPI # ifdef FAR # undef FAR # endif # include /* No need for _export, use ZLIB.DEF instead. */ /* For complete Windows compatibility, use WINAPI, not __stdcall. */ # define ZEXPORT WINAPI # ifdef WIN32 # define ZEXPORTVA WINAPIV # else # define ZEXPORTVA FAR CDECL # endif # endif #endif #if defined (__BEOS__) # ifdef ZLIB_DLL # ifdef ZLIB_INTERNAL # define ZEXPORT __declspec(dllexport) # define ZEXPORTVA __declspec(dllexport) # else # define ZEXPORT __declspec(dllimport) # define ZEXPORTVA __declspec(dllimport) # endif # endif #endif #ifndef ZEXTERN # define ZEXTERN extern #endif #ifndef ZEXPORT # define ZEXPORT #endif #ifndef ZEXPORTVA # define ZEXPORTVA #endif #ifndef FAR # define FAR #endif #if !defined(__MACTYPES__) 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 const *voidpc; typedef void FAR *voidpf; typedef void *voidp; #else typedef Byte const *voidpc; typedef Byte FAR *voidpf; typedef Byte *voidp; #endif #if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ # include /* for off_t */ # include /* for SEEK_* and off_t */ # ifdef VMS # include /* for off_t */ # endif # 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 #if defined(__OS400__) # define NO_vsnprintf #endif #if defined(__MVS__) # define NO_vsnprintf # ifdef FAR # undef FAR # endif #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(deflateBound,"DEBND") # pragma map(inflateInit_,"ININ") # pragma map(inflateInit2_,"ININ2") # pragma map(inflateEnd,"INEND") # pragma map(inflateSync,"INSY") # pragma map(inflateSetDictionary,"INSEDI") # pragma map(compressBound,"CMBND") # pragma map(inflate_table,"INTABL") # pragma map(inflate_fast,"INFA") # pragma map(inflate_copyright,"INCOPY") #endif #endif /* ZCONF_H */ sks-ecc-0.93/zlib/msdos/0000755000175000017500000000000010604550750014026 5ustar nachonachosks-ecc-0.93/zlib/msdos/Makefile.dj20000644000175000017500000000503110604550750016143 0ustar nachonacho# Makefile for zlib. Modified for djgpp v2.0 by F. J. Donahoe, 3/15/96. # Copyright (C) 1995-1998 Jean-loup Gailly. # For conditions of distribution and use, see copyright notice in zlib.h # To compile, or to compile and test, type: # # make -fmakefile.dj2; make test -fmakefile.dj2 # # To install libz.a, zconf.h and zlib.h in the djgpp directories, type: # # make install -fmakefile.dj2 # # after first defining LIBRARY_PATH and INCLUDE_PATH in djgpp.env as # in the sample below if the pattern of the DJGPP distribution is to # be followed. Remember that, while 'es around <=> are ignored in # makefiles, they are *not* in batch files or in djgpp.env. # - - - - - # [make] # INCLUDE_PATH=%\>;INCLUDE_PATH%%\DJDIR%\include # LIBRARY_PATH=%\>;LIBRARY_PATH%%\DJDIR%\lib # BUTT=-m486 # - - - - - # Alternately, these variables may be defined below, overriding the values # in djgpp.env, as # INCLUDE_PATH=c:\usr\include # LIBRARY_PATH=c:\usr\lib CC=gcc #CFLAGS=-MMD -O #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 #CFLAGS=-MMD -g -DDEBUG CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ -Wstrict-prototypes -Wmissing-prototypes # If cp.exe is available, replace "copy /Y" with "cp -fp" . CP=copy /Y # If gnu install.exe is available, replace $(CP) with ginstall. INSTALL=$(CP) # The default value of RM is "rm -f." If "rm.exe" is found, comment out: RM=del LDLIBS=-L. -lz LD=$(CC) -s -o LDSHARED=$(CC) INCL=zlib.h zconf.h LIBS=libz.a AR=ar rcs prefix=/usr/local exec_prefix = $(prefix) OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ zutil.o inflate.o infback.o inftrees.o inffast.o OBJA = # to use the asm code: make OBJA=match.o TEST_OBJS = example.o minigzip.o all: example.exe minigzip.exe check: test test: all ./example echo hello world | .\minigzip | .\minigzip -d %.o : %.c $(CC) $(CFLAGS) -c $< -o $@ libz.a: $(OBJS) $(OBJA) $(AR) $@ $(OBJS) $(OBJA) %.exe : %.o $(LIBS) $(LD) $@ $< $(LDLIBS) # INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env . .PHONY : uninstall clean install: $(INCL) $(LIBS) -@if not exist $(INCLUDE_PATH)\nul mkdir $(INCLUDE_PATH) -@if not exist $(LIBRARY_PATH)\nul mkdir $(LIBRARY_PATH) $(INSTALL) zlib.h $(INCLUDE_PATH) $(INSTALL) zconf.h $(INCLUDE_PATH) $(INSTALL) libz.a $(LIBRARY_PATH) uninstall: $(RM) $(INCLUDE_PATH)\zlib.h $(RM) $(INCLUDE_PATH)\zconf.h $(RM) $(LIBRARY_PATH)\libz.a clean: $(RM) *.d $(RM) *.o $(RM) *.exe $(RM) libz.a $(RM) foo.gz DEPS := $(wildcard *.d) ifneq ($(DEPS),) include $(DEPS) endif sks-ecc-0.93/zlib/msdos/Makefile.msc0000644000175000017500000000525510604550750016256 0ustar nachonacho# Makefile for zlib # Microsoft C 5.1 or later # Last updated: 19-Mar-2003 # To use, do "make makefile.msc" # To compile in small model, set below: MODEL=S # If you wish to reduce the memory requirements (default 256K for big # objects plus a few K), you can add to the LOC macro below: # -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 # See zconf.h for details about the memory requirements. # ------------- Microsoft C 5.1 and later ------------- # Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) # should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added # to the declaration of LOC here: LOC = $(LOCAL_ZLIB) # Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc. CPU_TYP = 0 # Memory model: one of S, M, C, L (small, medium, compact, large) MODEL=L CC=cl CFLAGS=-nologo -A$(MODEL) -G$(CPU_TYP) -W3 -Oait -Gs $(LOC) #-Ox generates bad code with MSC 5.1 LIB_CFLAGS=-Zl $(CFLAGS) LD=link LDFLAGS=/noi/e/st:0x1500/noe/farcall/packcode # "/farcall/packcode" are only useful for `large code' memory models # but should be a "no-op" for small code models. # variables ZLIB_LIB = zlib_$(MODEL).lib OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj # targets all: $(ZLIB_LIB) example.exe minigzip.exe .c.obj: $(CC) -c $(LIB_CFLAGS) $*.c adler32.obj: adler32.c zlib.h zconf.h compress.obj: compress.c zlib.h zconf.h crc32.obj: crc32.c zlib.h zconf.h crc32.h deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h gzio.obj: gzio.c zutil.h zlib.h zconf.h infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inffixed.h inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inffixed.h inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h uncompr.obj: uncompr.c zlib.h zconf.h zutil.obj: zutil.c zutil.h zlib.h zconf.h example.obj: example.c zlib.h zconf.h $(CC) -c $(CFLAGS) $*.c minigzip.obj: minigzip.c zlib.h zconf.h $(CC) -c $(CFLAGS) $*.c # the command line is cut to fit in the MS-DOS 128 byte limit: $(ZLIB_LIB): $(OBJ1) $(OBJ2) if exist $(ZLIB_LIB) del $(ZLIB_LIB) lib $(ZLIB_LIB) $(OBJ1); lib $(ZLIB_LIB) $(OBJ2); example.exe: example.obj $(ZLIB_LIB) $(LD) $(LDFLAGS) example.obj,,,$(ZLIB_LIB); minigzip.exe: minigzip.obj $(ZLIB_LIB) $(LD) $(LDFLAGS) minigzip.obj,,,$(ZLIB_LIB); test: example.exe minigzip.exe example echo hello world | minigzip | minigzip -d clean: -del *.obj -del *.lib -del *.exe -del *.map -del zlib_*.bak -del foo.gz sks-ecc-0.93/zlib/msdos/Makefile.bor0000644000175000017500000000546710604550750016263 0ustar nachonacho# Makefile for zlib # Borland C++ # Last updated: 15-Mar-2003 # To use, do "make -fmakefile.bor" # To compile in small model, set below: MODEL=s # WARNING: the small model is supported but only for small values of # MAX_WBITS and MAX_MEM_LEVEL. For example: # -DMAX_WBITS=11 -DDEF_WBITS=11 -DMAX_MEM_LEVEL=3 # If you wish to reduce the memory requirements (default 256K for big # objects plus a few K), you can add to the LOC macro below: # -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 # See zconf.h for details about the memory requirements. # ------------ Turbo C++, Borland C++ ------------ # Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) # should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added # to the declaration of LOC here: LOC = $(LOCAL_ZLIB) # type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc. CPU_TYP = 0 # memory model: one of s, m, c, l (small, medium, compact, large) MODEL=l # replace bcc with tcc for Turbo C++ 1.0, with bcc32 for the 32 bit version CC=bcc LD=bcc AR=tlib # compiler flags # replace "-O2" by "-O -G -a -d" for Turbo C++ 1.0 CFLAGS=-O2 -Z -m$(MODEL) $(LOC) LDFLAGS=-m$(MODEL) -f- # variables ZLIB_LIB = zlib_$(MODEL).lib OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj # targets all: $(ZLIB_LIB) example.exe minigzip.exe .c.obj: $(CC) -c $(CFLAGS) $*.c adler32.obj: adler32.c zlib.h zconf.h compress.obj: compress.c zlib.h zconf.h crc32.obj: crc32.c zlib.h zconf.h crc32.h deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h gzio.obj: gzio.c zutil.h zlib.h zconf.h infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inffixed.h inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inffixed.h inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h uncompr.obj: uncompr.c zlib.h zconf.h zutil.obj: zutil.c zutil.h zlib.h zconf.h example.obj: example.c zlib.h zconf.h minigzip.obj: minigzip.c zlib.h zconf.h # the command line is cut to fit in the MS-DOS 128 byte limit: $(ZLIB_LIB): $(OBJ1) $(OBJ2) -del $(ZLIB_LIB) $(AR) $(ZLIB_LIB) $(OBJP1) $(AR) $(ZLIB_LIB) $(OBJP2) example.exe: example.obj $(ZLIB_LIB) $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) minigzip.exe: minigzip.obj $(ZLIB_LIB) $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) test: example.exe minigzip.exe example echo hello world | minigzip | minigzip -d clean: -del *.obj -del *.lib -del *.exe -del zlib_*.bak -del foo.gz sks-ecc-0.93/zlib/msdos/Makefile.tc0000644000175000017500000000457610604550750016107 0ustar nachonacho# Makefile for zlib # Turbo C 2.01, Turbo C++ 1.01 # Last updated: 15-Mar-2003 # To use, do "make -fmakefile.tc" # To compile in small model, set below: MODEL=s # WARNING: the small model is supported but only for small values of # MAX_WBITS and MAX_MEM_LEVEL. For example: # -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 # If you wish to reduce the memory requirements (default 256K for big # objects plus a few K), you can add to CFLAGS below: # -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 # See zconf.h for details about the memory requirements. # ------------ Turbo C 2.01, Turbo C++ 1.01 ------------ MODEL=l CC=tcc LD=tcc AR=tlib # CFLAGS=-O2 -G -Z -m$(MODEL) -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 CFLAGS=-O2 -G -Z -m$(MODEL) LDFLAGS=-m$(MODEL) -f- # variables ZLIB_LIB = zlib_$(MODEL).lib OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj # targets all: $(ZLIB_LIB) example.exe minigzip.exe .c.obj: $(CC) -c $(CFLAGS) $*.c adler32.obj: adler32.c zlib.h zconf.h compress.obj: compress.c zlib.h zconf.h crc32.obj: crc32.c zlib.h zconf.h crc32.h deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h gzio.obj: gzio.c zutil.h zlib.h zconf.h infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inffixed.h inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inffixed.h inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h uncompr.obj: uncompr.c zlib.h zconf.h zutil.obj: zutil.c zutil.h zlib.h zconf.h example.obj: example.c zlib.h zconf.h minigzip.obj: minigzip.c zlib.h zconf.h # the command line is cut to fit in the MS-DOS 128 byte limit: $(ZLIB_LIB): $(OBJ1) $(OBJ2) -del $(ZLIB_LIB) $(AR) $(ZLIB_LIB) $(OBJP1) $(AR) $(ZLIB_LIB) $(OBJP2) example.exe: example.obj $(ZLIB_LIB) $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) minigzip.exe: minigzip.obj $(ZLIB_LIB) $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) test: example.exe minigzip.exe example echo hello world | minigzip | minigzip -d clean: -del *.obj -del *.lib -del *.exe -del zlib_*.bak -del foo.gz sks-ecc-0.93/zlib/msdos/Makefile.emx0000644000175000017500000000260410604550750016260 0ustar nachonacho# Makefile for zlib. Modified for emx 0.9c by Chr. Spieler, 6/17/98. # Copyright (C) 1995-1998 Jean-loup Gailly. # For conditions of distribution and use, see copyright notice in zlib.h # To compile, or to compile and test, type: # # make -fmakefile.emx; make test -fmakefile.emx # CC=gcc #CFLAGS=-MMD -O #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 #CFLAGS=-MMD -g -DDEBUG CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ -Wstrict-prototypes -Wmissing-prototypes # If cp.exe is available, replace "copy /Y" with "cp -fp" . CP=copy /Y # If gnu install.exe is available, replace $(CP) with ginstall. INSTALL=$(CP) # The default value of RM is "rm -f." If "rm.exe" is found, comment out: RM=del LDLIBS=-L. -lzlib LD=$(CC) -s -o LDSHARED=$(CC) INCL=zlib.h zconf.h LIBS=zlib.a AR=ar rcs prefix=/usr/local exec_prefix = $(prefix) OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ zutil.o inflate.o infback.o inftrees.o inffast.o TEST_OBJS = example.o minigzip.o all: example.exe minigzip.exe test: all ./example echo hello world | .\minigzip | .\minigzip -d %.o : %.c $(CC) $(CFLAGS) -c $< -o $@ zlib.a: $(OBJS) $(AR) $@ $(OBJS) %.exe : %.o $(LIBS) $(LD) $@ $< $(LDLIBS) .PHONY : clean clean: $(RM) *.d $(RM) *.o $(RM) *.exe $(RM) zlib.a $(RM) foo.gz DEPS := $(wildcard *.d) ifneq ($(DEPS),) include $(DEPS) endif sks-ecc-0.93/zlib/deflate.c0000644000175000017500000017524310604550750014465 0ustar nachonacho/* deflate.c -- compress data using the deflation algorithm * Copyright (C) 1995-2005 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* * ALGORITHM * * The "deflation" process depends on being able to identify portions * of the input text which are identical to earlier input (within a * sliding window trailing behind the input currently being processed). * * The most straightforward technique turns out to be the fastest for * most input files: try all possible matches and select the longest. * The key feature of this algorithm is that insertions into the string * dictionary are very simple and thus fast, and deletions are avoided * completely. Insertions are performed at each input character, whereas * string matches are performed only when the previous match ends. So it * is preferable to spend more time in matches to allow very fast string * insertions and avoid deletions. The matching algorithm for small * strings is inspired from that of Rabin & Karp. A brute force approach * is used to find longer strings when a small match has been found. * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze * (by Leonid Broukhis). * A previous version of this file used a more sophisticated algorithm * (by Fiala and Greene) which is guaranteed to run in linear amortized * time, but has a larger average cost, uses more memory and is patented. * However the F&G algorithm may be faster for some highly redundant * files if the parameter max_chain_length (described below) is too large. * * ACKNOWLEDGEMENTS * * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and * I found it in 'freeze' written by Leonid Broukhis. * Thanks to many people for bug reports and testing. * * REFERENCES * * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". * Available in http://www.ietf.org/rfc/rfc1951.txt * * A description of the Rabin and Karp algorithm is given in the book * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. * * Fiala,E.R., and Greene,D.H. * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 * */ /* @(#) $Id$ */ #include "deflate.h" const char deflate_copyright[] = " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot include such an acknowledgment, I would appreciate that you keep this copyright string in the executable of your product. */ /* =========================================================================== * Function prototypes. */ typedef enum { need_more, /* block not completed, need more input or more output */ block_done, /* block flush performed */ finish_started, /* finish started, need only more output at next deflate */ finish_done /* finish done, accept no more input or output */ } block_state; typedef block_state (*compress_func) OF((deflate_state *s, int flush)); /* Compression function. Returns the block state after the call. */ local void fill_window OF((deflate_state *s)); local block_state deflate_stored OF((deflate_state *s, int flush)); local block_state deflate_fast OF((deflate_state *s, int flush)); #ifndef FASTEST local block_state deflate_slow OF((deflate_state *s, int flush)); #endif local void lm_init OF((deflate_state *s)); local void putShortMSB OF((deflate_state *s, uInt b)); local void flush_pending OF((z_streamp strm)); local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); #ifndef FASTEST #ifdef ASMV void match_init OF((void)); /* asm code initialization */ uInt longest_match OF((deflate_state *s, IPos cur_match)); #else local uInt longest_match OF((deflate_state *s, IPos cur_match)); #endif #endif local uInt longest_match_fast OF((deflate_state *s, IPos cur_match)); #ifdef DEBUG local void check_match OF((deflate_state *s, IPos start, IPos match, int length)); #endif /* =========================================================================== * Local data */ #define NIL 0 /* Tail of hash chains */ #ifndef TOO_FAR # define TOO_FAR 4096 #endif /* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) /* Minimum amount of lookahead, except at the end of the input file. * See deflate.c for comments about the MIN_MATCH+1. */ /* Values for max_lazy_match, good_match and max_chain_length, depending on * the desired pack level (0..9). The values given below have been tuned to * exclude worst case performance for pathological files. Better values may be * found for specific files. */ typedef struct config_s { ush good_length; /* reduce lazy search above this match length */ ush max_lazy; /* do not perform lazy search above this match length */ ush nice_length; /* quit search above this match length */ ush max_chain; compress_func func; } config; #ifdef FASTEST local const config configuration_table[2] = { /* good lazy nice chain */ /* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ /* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */ #else local const config configuration_table[10] = { /* good lazy nice chain */ /* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ /* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */ /* 2 */ {4, 5, 16, 8, deflate_fast}, /* 3 */ {4, 6, 32, 32, deflate_fast}, /* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ /* 5 */ {8, 16, 32, 32, deflate_slow}, /* 6 */ {8, 16, 128, 128, deflate_slow}, /* 7 */ {8, 32, 128, 256, deflate_slow}, /* 8 */ {32, 128, 258, 1024, deflate_slow}, /* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */ #endif /* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 * For deflate_fast() (levels <= 3) good is ignored and lazy has a different * meaning. */ #define EQUAL 0 /* result of memcmp for equal strings */ #ifndef NO_DUMMY_DECL struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ #endif /* =========================================================================== * Update a hash value with the given input byte * IN assertion: all calls to to UPDATE_HASH are made with consecutive * input characters, so that a running hash key can be computed from the * previous key instead of complete recalculation each time. */ #define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) /* =========================================================================== * Insert string str in the dictionary and set match_head to the previous head * of the hash chain (the most recent string with same hash key). Return * the previous length of the hash chain. * If this file is compiled with -DFASTEST, the compression level is forced * to 1, and no hash chains are maintained. * IN assertion: all calls to to INSERT_STRING are made with consecutive * input characters and the first MIN_MATCH bytes of str are valid * (except for the last MIN_MATCH-1 bytes of the input file). */ #ifdef FASTEST #define INSERT_STRING(s, str, match_head) \ (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ match_head = s->head[s->ins_h], \ s->head[s->ins_h] = (Pos)(str)) #else #define INSERT_STRING(s, str, match_head) \ (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ s->head[s->ins_h] = (Pos)(str)) #endif /* =========================================================================== * Initialize the hash table (avoiding 64K overflow for 16 bit systems). * prev[] will be initialized on the fly. */ #define CLEAR_HASH(s) \ s->head[s->hash_size-1] = NIL; \ zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); /* ========================================================================= */ int ZEXPORT deflateInit_(strm, level, version, stream_size) z_streamp strm; int level; const char *version; int stream_size; { return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, version, stream_size); /* To do: ignore strm->next_in if we use it as window */ } /* ========================================================================= */ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, version, stream_size) z_streamp strm; int level; int method; int windowBits; int memLevel; int strategy; const char *version; int stream_size; { deflate_state *s; int wrap = 1; static const char my_version[] = ZLIB_VERSION; ushf *overlay; /* We overlay pending_buf and d_buf+l_buf. This works since the average * output size for (length,distance) codes is <= 24 bits. */ if (version == Z_NULL || version[0] != my_version[0] || stream_size != sizeof(z_stream)) { return Z_VERSION_ERROR; } if (strm == Z_NULL) return Z_STREAM_ERROR; strm->msg = Z_NULL; if (strm->zalloc == (alloc_func)0) { strm->zalloc = zcalloc; strm->opaque = (voidpf)0; } if (strm->zfree == (free_func)0) strm->zfree = zcfree; #ifdef FASTEST if (level != 0) level = 1; #else if (level == Z_DEFAULT_COMPRESSION) level = 6; #endif if (windowBits < 0) { /* suppress zlib wrapper */ wrap = 0; windowBits = -windowBits; } #ifdef GZIP else if (windowBits > 15) { wrap = 2; /* write gzip wrapper instead */ windowBits -= 16; } #endif if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { return Z_STREAM_ERROR; } if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); if (s == Z_NULL) return Z_MEM_ERROR; strm->state = (struct internal_state FAR *)s; s->strm = strm; s->wrap = wrap; s->gzhead = Z_NULL; s->w_bits = windowBits; s->w_size = 1 << s->w_bits; s->w_mask = s->w_size - 1; s->hash_bits = memLevel + 7; s->hash_size = 1 << s->hash_bits; s->hash_mask = s->hash_size - 1; s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); s->pending_buf = (uchf *) overlay; s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || s->pending_buf == Z_NULL) { s->status = FINISH_STATE; strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); deflateEnd (strm); return Z_MEM_ERROR; } s->d_buf = overlay + s->lit_bufsize/sizeof(ush); s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; s->level = level; s->strategy = strategy; s->method = (Byte)method; return deflateReset(strm); } /* ========================================================================= */ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) z_streamp strm; const Bytef *dictionary; uInt dictLength; { deflate_state *s; uInt length = dictLength; uInt n; IPos hash_head = 0; if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || strm->state->wrap == 2 || (strm->state->wrap == 1 && strm->state->status != INIT_STATE)) return Z_STREAM_ERROR; s = strm->state; if (s->wrap) strm->adler = adler32(strm->adler, dictionary, dictLength); if (length < MIN_MATCH) return Z_OK; if (length > MAX_DIST(s)) { length = MAX_DIST(s); dictionary += dictLength - length; /* use the tail of the dictionary */ } zmemcpy(s->window, dictionary, length); s->strstart = length; s->block_start = (long)length; /* Insert all strings in the hash table (except for the last two bytes). * s->lookahead stays null, so s->ins_h will be recomputed at the next * call of fill_window. */ s->ins_h = s->window[0]; UPDATE_HASH(s, s->ins_h, s->window[1]); for (n = 0; n <= length - MIN_MATCH; n++) { INSERT_STRING(s, n, hash_head); } if (hash_head) hash_head = 0; /* to make compiler happy */ return Z_OK; } /* ========================================================================= */ int ZEXPORT deflateReset (strm) z_streamp strm; { deflate_state *s; if (strm == Z_NULL || strm->state == Z_NULL || strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) { return Z_STREAM_ERROR; } strm->total_in = strm->total_out = 0; strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ strm->data_type = Z_UNKNOWN; s = (deflate_state *)strm->state; s->pending = 0; s->pending_out = s->pending_buf; if (s->wrap < 0) { s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ } s->status = s->wrap ? INIT_STATE : BUSY_STATE; strm->adler = #ifdef GZIP s->wrap == 2 ? crc32(0L, Z_NULL, 0) : #endif adler32(0L, Z_NULL, 0); s->last_flush = Z_NO_FLUSH; _tr_init(s); lm_init(s); return Z_OK; } /* ========================================================================= */ int ZEXPORT deflateSetHeader (strm, head) z_streamp strm; gz_headerp head; { if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; if (strm->state->wrap != 2) return Z_STREAM_ERROR; strm->state->gzhead = head; return Z_OK; } /* ========================================================================= */ int ZEXPORT deflatePrime (strm, bits, value) z_streamp strm; int bits; int value; { if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; strm->state->bi_valid = bits; strm->state->bi_buf = (ush)(value & ((1 << bits) - 1)); return Z_OK; } /* ========================================================================= */ int ZEXPORT deflateParams(strm, level, strategy) z_streamp strm; int level; int strategy; { deflate_state *s; compress_func func; int err = Z_OK; if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; s = strm->state; #ifdef FASTEST if (level != 0) level = 1; #else if (level == Z_DEFAULT_COMPRESSION) level = 6; #endif if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { return Z_STREAM_ERROR; } func = configuration_table[s->level].func; if (func != configuration_table[level].func && strm->total_in != 0) { /* Flush the last buffer: */ err = deflate(strm, Z_PARTIAL_FLUSH); } if (s->level != level) { s->level = level; s->max_lazy_match = configuration_table[level].max_lazy; s->good_match = configuration_table[level].good_length; s->nice_match = configuration_table[level].nice_length; s->max_chain_length = configuration_table[level].max_chain; } s->strategy = strategy; return err; } /* ========================================================================= */ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) z_streamp strm; int good_length; int max_lazy; int nice_length; int max_chain; { deflate_state *s; if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; s = strm->state; s->good_match = good_length; s->max_lazy_match = max_lazy; s->nice_match = nice_length; s->max_chain_length = max_chain; return Z_OK; } /* ========================================================================= * For the default windowBits of 15 and memLevel of 8, this function returns * a close to exact, as well as small, upper bound on the compressed size. * They are coded as constants here for a reason--if the #define's are * changed, then this function needs to be changed as well. The return * value for 15 and 8 only works for those exact settings. * * For any setting other than those defaults for windowBits and memLevel, * the value returned is a conservative worst case for the maximum expansion * resulting from using fixed blocks instead of stored blocks, which deflate * can emit on compressed data for some combinations of the parameters. * * This function could be more sophisticated to provide closer upper bounds * for every combination of windowBits and memLevel, as well as wrap. * But even the conservative upper bound of about 14% expansion does not * seem onerous for output buffer allocation. */ uLong ZEXPORT deflateBound(strm, sourceLen) z_streamp strm; uLong sourceLen; { deflate_state *s; uLong destLen; /* conservative upper bound */ destLen = sourceLen + ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11; /* if can't get parameters, return conservative bound */ if (strm == Z_NULL || strm->state == Z_NULL) return destLen; /* if not default parameters, return conservative bound */ s = strm->state; if (s->w_bits != 15 || s->hash_bits != 8 + 7) return destLen; /* default settings: return tight bound for that case */ return compressBound(sourceLen); } /* ========================================================================= * Put a short in the pending buffer. The 16-bit value is put in MSB order. * IN assertion: the stream state is correct and there is enough room in * pending_buf. */ local void putShortMSB (s, b) deflate_state *s; uInt b; { put_byte(s, (Byte)(b >> 8)); put_byte(s, (Byte)(b & 0xff)); } /* ========================================================================= * Flush as much pending output as possible. All deflate() output goes * through this function so some applications may wish to modify it * to avoid allocating a large strm->next_out buffer and copying into it. * (See also read_buf()). */ local void flush_pending(strm) z_streamp strm; { unsigned len = strm->state->pending; if (len > strm->avail_out) len = strm->avail_out; if (len == 0) return; zmemcpy(strm->next_out, strm->state->pending_out, len); strm->next_out += len; strm->state->pending_out += len; strm->total_out += len; strm->avail_out -= len; strm->state->pending -= len; if (strm->state->pending == 0) { strm->state->pending_out = strm->state->pending_buf; } } /* ========================================================================= */ int ZEXPORT deflate (strm, flush) z_streamp strm; int flush; { int old_flush; /* value of flush param for previous deflate call */ deflate_state *s; if (strm == Z_NULL || strm->state == Z_NULL || flush > Z_FINISH || flush < 0) { return Z_STREAM_ERROR; } s = strm->state; if (strm->next_out == Z_NULL || (strm->next_in == Z_NULL && strm->avail_in != 0) || (s->status == FINISH_STATE && flush != Z_FINISH)) { ERR_RETURN(strm, Z_STREAM_ERROR); } if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); s->strm = strm; /* just in case */ old_flush = s->last_flush; s->last_flush = flush; /* Write the header */ if (s->status == INIT_STATE) { #ifdef GZIP if (s->wrap == 2) { strm->adler = crc32(0L, Z_NULL, 0); put_byte(s, 31); put_byte(s, 139); put_byte(s, 8); if (s->gzhead == NULL) { put_byte(s, 0); put_byte(s, 0); put_byte(s, 0); put_byte(s, 0); put_byte(s, 0); put_byte(s, s->level == 9 ? 2 : (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? 4 : 0)); put_byte(s, OS_CODE); s->status = BUSY_STATE; } else { put_byte(s, (s->gzhead->text ? 1 : 0) + (s->gzhead->hcrc ? 2 : 0) + (s->gzhead->extra == Z_NULL ? 0 : 4) + (s->gzhead->name == Z_NULL ? 0 : 8) + (s->gzhead->comment == Z_NULL ? 0 : 16) ); put_byte(s, (Byte)(s->gzhead->time & 0xff)); put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); put_byte(s, s->level == 9 ? 2 : (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? 4 : 0)); put_byte(s, s->gzhead->os & 0xff); if (s->gzhead->extra != NULL) { put_byte(s, s->gzhead->extra_len & 0xff); put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); } if (s->gzhead->hcrc) strm->adler = crc32(strm->adler, s->pending_buf, s->pending); s->gzindex = 0; s->status = EXTRA_STATE; } } else #endif { uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; uInt level_flags; if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) level_flags = 0; else if (s->level < 6) level_flags = 1; else if (s->level == 6) level_flags = 2; else level_flags = 3; header |= (level_flags << 6); if (s->strstart != 0) header |= PRESET_DICT; header += 31 - (header % 31); s->status = BUSY_STATE; putShortMSB(s, header); /* Save the adler32 of the preset dictionary: */ if (s->strstart != 0) { putShortMSB(s, (uInt)(strm->adler >> 16)); putShortMSB(s, (uInt)(strm->adler & 0xffff)); } strm->adler = adler32(0L, Z_NULL, 0); } } #ifdef GZIP if (s->status == EXTRA_STATE) { if (s->gzhead->extra != NULL) { uInt beg = s->pending; /* start of bytes to update crc */ while (s->gzindex < (s->gzhead->extra_len & 0xffff)) { if (s->pending == s->pending_buf_size) { if (s->gzhead->hcrc && s->pending > beg) strm->adler = crc32(strm->adler, s->pending_buf + beg, s->pending - beg); flush_pending(strm); beg = s->pending; if (s->pending == s->pending_buf_size) break; } put_byte(s, s->gzhead->extra[s->gzindex]); s->gzindex++; } if (s->gzhead->hcrc && s->pending > beg) strm->adler = crc32(strm->adler, s->pending_buf + beg, s->pending - beg); if (s->gzindex == s->gzhead->extra_len) { s->gzindex = 0; s->status = NAME_STATE; } } else s->status = NAME_STATE; } if (s->status == NAME_STATE) { if (s->gzhead->name != NULL) { uInt beg = s->pending; /* start of bytes to update crc */ int val; do { if (s->pending == s->pending_buf_size) { if (s->gzhead->hcrc && s->pending > beg) strm->adler = crc32(strm->adler, s->pending_buf + beg, s->pending - beg); flush_pending(strm); beg = s->pending; if (s->pending == s->pending_buf_size) { val = 1; break; } } val = s->gzhead->name[s->gzindex++]; put_byte(s, val); } while (val != 0); if (s->gzhead->hcrc && s->pending > beg) strm->adler = crc32(strm->adler, s->pending_buf + beg, s->pending - beg); if (val == 0) { s->gzindex = 0; s->status = COMMENT_STATE; } } else s->status = COMMENT_STATE; } if (s->status == COMMENT_STATE) { if (s->gzhead->comment != NULL) { uInt beg = s->pending; /* start of bytes to update crc */ int val; do { if (s->pending == s->pending_buf_size) { if (s->gzhead->hcrc && s->pending > beg) strm->adler = crc32(strm->adler, s->pending_buf + beg, s->pending - beg); flush_pending(strm); beg = s->pending; if (s->pending == s->pending_buf_size) { val = 1; break; } } val = s->gzhead->comment[s->gzindex++]; put_byte(s, val); } while (val != 0); if (s->gzhead->hcrc && s->pending > beg) strm->adler = crc32(strm->adler, s->pending_buf + beg, s->pending - beg); if (val == 0) s->status = HCRC_STATE; } else s->status = HCRC_STATE; } if (s->status == HCRC_STATE) { if (s->gzhead->hcrc) { if (s->pending + 2 > s->pending_buf_size) flush_pending(strm); if (s->pending + 2 <= s->pending_buf_size) { put_byte(s, (Byte)(strm->adler & 0xff)); put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); strm->adler = crc32(0L, Z_NULL, 0); s->status = BUSY_STATE; } } else s->status = BUSY_STATE; } #endif /* Flush as much pending output as possible */ if (s->pending != 0) { flush_pending(strm); if (strm->avail_out == 0) { /* Since avail_out is 0, deflate will be called again with * more output space, but possibly with both pending and * avail_in equal to zero. There won't be anything to do, * but this is not an error situation so make sure we * return OK instead of BUF_ERROR at next call of deflate: */ s->last_flush = -1; return Z_OK; } /* Make sure there is something to do and avoid duplicate consecutive * flushes. For repeated and useless calls with Z_FINISH, we keep * returning Z_STREAM_END instead of Z_BUF_ERROR. */ } else if (strm->avail_in == 0 && flush <= old_flush && flush != Z_FINISH) { ERR_RETURN(strm, Z_BUF_ERROR); } /* User must not provide more input after the first FINISH: */ if (s->status == FINISH_STATE && strm->avail_in != 0) { ERR_RETURN(strm, Z_BUF_ERROR); } /* Start a new block or continue the current one. */ if (strm->avail_in != 0 || s->lookahead != 0 || (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { block_state bstate; bstate = (*(configuration_table[s->level].func))(s, flush); if (bstate == finish_started || bstate == finish_done) { s->status = FINISH_STATE; } if (bstate == need_more || bstate == finish_started) { if (strm->avail_out == 0) { s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ } return Z_OK; /* If flush != Z_NO_FLUSH && avail_out == 0, the next call * of deflate should use the same flush parameter to make sure * that the flush is complete. So we don't have to output an * empty block here, this will be done at next call. This also * ensures that for a very small output buffer, we emit at most * one empty block. */ } if (bstate == block_done) { if (flush == Z_PARTIAL_FLUSH) { _tr_align(s); } else { /* FULL_FLUSH or SYNC_FLUSH */ _tr_stored_block(s, (char*)0, 0L, 0); /* For a full flush, this empty block will be recognized * as a special marker by inflate_sync(). */ if (flush == Z_FULL_FLUSH) { CLEAR_HASH(s); /* forget history */ } } flush_pending(strm); if (strm->avail_out == 0) { s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ return Z_OK; } } } Assert(strm->avail_out > 0, "bug2"); if (flush != Z_FINISH) return Z_OK; if (s->wrap <= 0) return Z_STREAM_END; /* Write the trailer */ #ifdef GZIP if (s->wrap == 2) { put_byte(s, (Byte)(strm->adler & 0xff)); put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); put_byte(s, (Byte)(strm->total_in & 0xff)); put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); } else #endif { putShortMSB(s, (uInt)(strm->adler >> 16)); putShortMSB(s, (uInt)(strm->adler & 0xffff)); } flush_pending(strm); /* If avail_out is zero, the application will call deflate again * to flush the rest. */ if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ return s->pending != 0 ? Z_OK : Z_STREAM_END; } /* ========================================================================= */ int ZEXPORT deflateEnd (strm) z_streamp strm; { int status; if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; status = strm->state->status; if (status != INIT_STATE && status != EXTRA_STATE && status != NAME_STATE && status != COMMENT_STATE && status != HCRC_STATE && status != BUSY_STATE && status != FINISH_STATE) { return Z_STREAM_ERROR; } /* Deallocate in reverse order of allocations: */ TRY_FREE(strm, strm->state->pending_buf); TRY_FREE(strm, strm->state->head); TRY_FREE(strm, strm->state->prev); TRY_FREE(strm, strm->state->window); ZFREE(strm, strm->state); strm->state = Z_NULL; return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; } /* ========================================================================= * Copy the source state to the destination state. * To simplify the source, this is not supported for 16-bit MSDOS (which * doesn't have enough memory anyway to duplicate compression states). */ int ZEXPORT deflateCopy (dest, source) z_streamp dest; z_streamp source; { #ifdef MAXSEG_64K return Z_STREAM_ERROR; #else deflate_state *ds; deflate_state *ss; ushf *overlay; if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { return Z_STREAM_ERROR; } ss = source->state; zmemcpy(dest, source, sizeof(z_stream)); ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); if (ds == Z_NULL) return Z_MEM_ERROR; dest->state = (struct internal_state FAR *) ds; zmemcpy(ds, ss, sizeof(deflate_state)); ds->strm = dest; ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); ds->pending_buf = (uchf *) overlay; if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || ds->pending_buf == Z_NULL) { deflateEnd (dest); return Z_MEM_ERROR; } /* following zmemcpy do not work for 16-bit MSDOS */ zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; ds->l_desc.dyn_tree = ds->dyn_ltree; ds->d_desc.dyn_tree = ds->dyn_dtree; ds->bl_desc.dyn_tree = ds->bl_tree; return Z_OK; #endif /* MAXSEG_64K */ } /* =========================================================================== * Read a new buffer from the current input stream, update the adler32 * and total number of bytes read. All deflate() input goes through * this function so some applications may wish to modify it to avoid * allocating a large strm->next_in buffer and copying from it. * (See also flush_pending()). */ local int read_buf(strm, buf, size) z_streamp strm; Bytef *buf; unsigned size; { unsigned len = strm->avail_in; if (len > size) len = size; if (len == 0) return 0; strm->avail_in -= len; if (strm->state->wrap == 1) { strm->adler = adler32(strm->adler, strm->next_in, len); } #ifdef GZIP else if (strm->state->wrap == 2) { strm->adler = crc32(strm->adler, strm->next_in, len); } #endif zmemcpy(buf, strm->next_in, len); strm->next_in += len; strm->total_in += len; return (int)len; } /* =========================================================================== * Initialize the "longest match" routines for a new zlib stream */ local void lm_init (s) deflate_state *s; { s->window_size = (ulg)2L*s->w_size; CLEAR_HASH(s); /* Set the default configuration parameters: */ s->max_lazy_match = configuration_table[s->level].max_lazy; s->good_match = configuration_table[s->level].good_length; s->nice_match = configuration_table[s->level].nice_length; s->max_chain_length = configuration_table[s->level].max_chain; s->strstart = 0; s->block_start = 0L; s->lookahead = 0; s->match_length = s->prev_length = MIN_MATCH-1; s->match_available = 0; s->ins_h = 0; #ifndef FASTEST #ifdef ASMV match_init(); /* initialize the asm code */ #endif #endif } #ifndef FASTEST /* =========================================================================== * Set match_start to the longest match starting at the given string and * return its length. Matches shorter or equal to prev_length are discarded, * in which case the result is equal to prev_length and match_start is * garbage. * IN assertions: cur_match is the head of the hash chain for the current * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 * OUT assertion: the match length is not greater than s->lookahead. */ #ifndef ASMV /* For 80x86 and 680x0, an optimized version will be provided in match.asm or * match.S. The code will be functionally equivalent. */ local uInt longest_match(s, cur_match) deflate_state *s; IPos cur_match; /* current match */ { unsigned chain_length = s->max_chain_length;/* max hash chain length */ register Bytef *scan = s->window + s->strstart; /* current string */ register Bytef *match; /* matched string */ register int len; /* length of current match */ int best_len = s->prev_length; /* best match length so far */ int nice_match = s->nice_match; /* stop if match long enough */ IPos limit = s->strstart > (IPos)MAX_DIST(s) ? s->strstart - (IPos)MAX_DIST(s) : NIL; /* Stop when cur_match becomes <= limit. To simplify the code, * we prevent matches with the string of window index 0. */ Posf *prev = s->prev; uInt wmask = s->w_mask; #ifdef UNALIGNED_OK /* Compare two bytes at a time. Note: this is not always beneficial. * Try with and without -DUNALIGNED_OK to check. */ register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; register ush scan_start = *(ushf*)scan; register ush scan_end = *(ushf*)(scan+best_len-1); #else register Bytef *strend = s->window + s->strstart + MAX_MATCH; register Byte scan_end1 = scan[best_len-1]; register Byte scan_end = scan[best_len]; #endif /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. * It is easy to get rid of this optimization if necessary. */ Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); /* Do not waste too much time if we already have a good match: */ if (s->prev_length >= s->good_match) { chain_length >>= 2; } /* Do not look for matches beyond the end of the input. This is necessary * to make deflate deterministic. */ if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); do { Assert(cur_match < s->strstart, "no future"); match = s->window + cur_match; /* Skip to next match if the match length cannot increase * or if the match length is less than 2. Note that the checks below * for insufficient lookahead only occur occasionally for performance * reasons. Therefore uninitialized memory will be accessed, and * conditional jumps will be made that depend on those values. * However the length of the match is limited to the lookahead, so * the output of deflate is not affected by the uninitialized values. */ #if (defined(UNALIGNED_OK) && MAX_MATCH == 258) /* This code assumes sizeof(unsigned short) == 2. Do not use * UNALIGNED_OK if your compiler uses a different size. */ if (*(ushf*)(match+best_len-1) != scan_end || *(ushf*)match != scan_start) continue; /* It is not necessary to compare scan[2] and match[2] since they are * always equal when the other bytes match, given that the hash keys * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at * strstart+3, +5, ... up to strstart+257. We check for insufficient * lookahead only every 4th comparison; the 128th check will be made * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is * necessary to put more guard bytes at the end of the window, or * to check more often for insufficient lookahead. */ Assert(scan[2] == match[2], "scan[2]?"); scan++, match++; do { } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && *(ushf*)(scan+=2) == *(ushf*)(match+=2) && *(ushf*)(scan+=2) == *(ushf*)(match+=2) && *(ushf*)(scan+=2) == *(ushf*)(match+=2) && scan < strend); /* The funny "do {}" generates better code on most compilers */ /* Here, scan <= window+strstart+257 */ Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); if (*scan == *match) scan++; len = (MAX_MATCH - 1) - (int)(strend-scan); scan = strend - (MAX_MATCH-1); #else /* UNALIGNED_OK */ if (match[best_len] != scan_end || match[best_len-1] != scan_end1 || *match != *scan || *++match != scan[1]) continue; /* The check at best_len-1 can be removed because it will be made * again later. (This heuristic is not always a win.) * It is not necessary to compare scan[2] and match[2] since they * are always equal when the other bytes match, given that * the hash keys are equal and that HASH_BITS >= 8. */ scan += 2, match++; Assert(*scan == *match, "match[2]?"); /* We check for insufficient lookahead only every 8th comparison; * the 256th check will be made at strstart+258. */ do { } while (*++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && scan < strend); Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); len = MAX_MATCH - (int)(strend - scan); scan = strend - MAX_MATCH; #endif /* UNALIGNED_OK */ if (len > best_len) { s->match_start = cur_match; best_len = len; if (len >= nice_match) break; #ifdef UNALIGNED_OK scan_end = *(ushf*)(scan+best_len-1); #else scan_end1 = scan[best_len-1]; scan_end = scan[best_len]; #endif } } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length != 0); if ((uInt)best_len <= s->lookahead) return (uInt)best_len; return s->lookahead; } #endif /* ASMV */ #endif /* FASTEST */ /* --------------------------------------------------------------------------- * Optimized version for level == 1 or strategy == Z_RLE only */ local uInt longest_match_fast(s, cur_match) deflate_state *s; IPos cur_match; /* current match */ { register Bytef *scan = s->window + s->strstart; /* current string */ register Bytef *match; /* matched string */ register int len; /* length of current match */ register Bytef *strend = s->window + s->strstart + MAX_MATCH; /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. * It is easy to get rid of this optimization if necessary. */ Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); Assert(cur_match < s->strstart, "no future"); match = s->window + cur_match; /* Return failure if the match length is less than 2: */ if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; /* The check at best_len-1 can be removed because it will be made * again later. (This heuristic is not always a win.) * It is not necessary to compare scan[2] and match[2] since they * are always equal when the other bytes match, given that * the hash keys are equal and that HASH_BITS >= 8. */ scan += 2, match += 2; Assert(*scan == *match, "match[2]?"); /* We check for insufficient lookahead only every 8th comparison; * the 256th check will be made at strstart+258. */ do { } while (*++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && scan < strend); Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); len = MAX_MATCH - (int)(strend - scan); if (len < MIN_MATCH) return MIN_MATCH - 1; s->match_start = cur_match; return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; } #ifdef DEBUG /* =========================================================================== * Check that the match at match_start is indeed a match. */ local void check_match(s, start, match, length) deflate_state *s; IPos start, match; int length; { /* check that the match is indeed a match */ if (zmemcmp(s->window + match, s->window + start, length) != EQUAL) { fprintf(stderr, " start %u, match %u, length %d\n", start, match, length); do { fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); } while (--length != 0); z_error("invalid match"); } if (z_verbose > 1) { fprintf(stderr,"\\[%d,%d]", start-match, length); do { putc(s->window[start++], stderr); } while (--length != 0); } } #else # define check_match(s, start, match, length) #endif /* DEBUG */ /* =========================================================================== * Fill the window when the lookahead becomes insufficient. * Updates strstart and lookahead. * * IN assertion: lookahead < MIN_LOOKAHEAD * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD * At least one byte has been read, or avail_in == 0; reads are * performed for at least two bytes (required for the zip translate_eol * option -- not supported here). */ local void fill_window(s) deflate_state *s; { register unsigned n, m; register Posf *p; unsigned more; /* Amount of free space at the end of the window. */ uInt wsize = s->w_size; do { more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); /* Deal with !@#$% 64K limit: */ if (sizeof(int) <= 2) { if (more == 0 && s->strstart == 0 && s->lookahead == 0) { more = wsize; } else if (more == (unsigned)(-1)) { /* Very unlikely, but possible on 16 bit machine if * strstart == 0 && lookahead == 1 (input done a byte at time) */ more--; } } /* If the window is almost full and there is insufficient lookahead, * move the upper half to the lower one to make room in the upper half. */ if (s->strstart >= wsize+MAX_DIST(s)) { zmemcpy(s->window, s->window+wsize, (unsigned)wsize); s->match_start -= wsize; s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ s->block_start -= (long) wsize; /* Slide the hash table (could be avoided with 32 bit values at the expense of memory usage). We slide even when level == 0 to keep the hash table consistent if we switch back to level > 0 later. (Using level 0 permanently is not an optimal usage of zlib, so we don't care about this pathological case.) */ /* %%% avoid this when Z_RLE */ n = s->hash_size; p = &s->head[n]; do { m = *--p; *p = (Pos)(m >= wsize ? m-wsize : NIL); } while (--n); n = wsize; #ifndef FASTEST p = &s->prev[n]; do { m = *--p; *p = (Pos)(m >= wsize ? m-wsize : NIL); /* If n is not on any hash chain, prev[n] is garbage but * its value will never be used. */ } while (--n); #endif more += wsize; } if (s->strm->avail_in == 0) return; /* If there was no sliding: * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && * more == window_size - lookahead - strstart * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) * => more >= window_size - 2*WSIZE + 2 * In the BIG_MEM or MMAP case (not yet supported), * window_size == input_size + MIN_LOOKAHEAD && * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. * Otherwise, window_size == 2*WSIZE so more >= 2. * If there was sliding, more >= WSIZE. So in all cases, more >= 2. */ Assert(more >= 2, "more < 2"); n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); s->lookahead += n; /* Initialize the hash value now that we have some input: */ if (s->lookahead >= MIN_MATCH) { s->ins_h = s->window[s->strstart]; UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); #if MIN_MATCH != 3 Call UPDATE_HASH() MIN_MATCH-3 more times #endif } /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, * but this is not important since only literal bytes will be emitted. */ } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); } /* =========================================================================== * Flush the current block, with given end-of-file flag. * IN assertion: strstart is set to the end of the current match. */ #define FLUSH_BLOCK_ONLY(s, eof) { \ _tr_flush_block(s, (s->block_start >= 0L ? \ (charf *)&s->window[(unsigned)s->block_start] : \ (charf *)Z_NULL), \ (ulg)((long)s->strstart - s->block_start), \ (eof)); \ s->block_start = s->strstart; \ flush_pending(s->strm); \ Tracev((stderr,"[FLUSH]")); \ } /* Same but force premature exit if necessary. */ #define FLUSH_BLOCK(s, eof) { \ FLUSH_BLOCK_ONLY(s, eof); \ if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \ } /* =========================================================================== * Copy without compression as much as possible from the input stream, return * the current block state. * This function does not insert new strings in the dictionary since * uncompressible data is probably not useful. This function is used * only for the level=0 compression option. * NOTE: this function should be optimized to avoid extra copying from * window to pending_buf. */ local block_state deflate_stored(s, flush) deflate_state *s; int flush; { /* Stored blocks are limited to 0xffff bytes, pending_buf is limited * to pending_buf_size, and each stored block has a 5 byte header: */ ulg max_block_size = 0xffff; ulg max_start; if (max_block_size > s->pending_buf_size - 5) { max_block_size = s->pending_buf_size - 5; } /* Copy as much as possible from input to output: */ for (;;) { /* Fill the window as much as possible: */ if (s->lookahead <= 1) { Assert(s->strstart < s->w_size+MAX_DIST(s) || s->block_start >= (long)s->w_size, "slide too late"); fill_window(s); if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; if (s->lookahead == 0) break; /* flush the current block */ } Assert(s->block_start >= 0L, "block gone"); s->strstart += s->lookahead; s->lookahead = 0; /* Emit a stored block if pending_buf will be full: */ max_start = s->block_start + max_block_size; if (s->strstart == 0 || (ulg)s->strstart >= max_start) { /* strstart == 0 is possible when wraparound on 16-bit machine */ s->lookahead = (uInt)(s->strstart - max_start); s->strstart = (uInt)max_start; FLUSH_BLOCK(s, 0); } /* Flush if we may have to slide, otherwise block_start may become * negative and the data will be gone: */ if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { FLUSH_BLOCK(s, 0); } } FLUSH_BLOCK(s, flush == Z_FINISH); return flush == Z_FINISH ? finish_done : block_done; } /* =========================================================================== * Compress as much as possible from the input stream, return the current * block state. * This function does not perform lazy evaluation of matches and inserts * new strings in the dictionary only for unmatched strings or for short * matches. It is used only for the fast compression options. */ local block_state deflate_fast(s, flush) deflate_state *s; int flush; { IPos hash_head = NIL; /* head of the hash chain */ int bflush; /* set if current block must be flushed */ for (;;) { /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the next match, plus MIN_MATCH bytes to insert the * string following the next match. */ if (s->lookahead < MIN_LOOKAHEAD) { fill_window(s); if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { return need_more; } if (s->lookahead == 0) break; /* flush the current block */ } /* Insert the string window[strstart .. strstart+2] in the * dictionary, and set hash_head to the head of the hash chain: */ if (s->lookahead >= MIN_MATCH) { INSERT_STRING(s, s->strstart, hash_head); } /* Find the longest match, discarding those <= prev_length. * At this point we have always match_length < MIN_MATCH */ if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { /* To simplify the code, we prevent matches with the string * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ #ifdef FASTEST if ((s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) || (s->strategy == Z_RLE && s->strstart - hash_head == 1)) { s->match_length = longest_match_fast (s, hash_head); } #else if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) { s->match_length = longest_match (s, hash_head); } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) { s->match_length = longest_match_fast (s, hash_head); } #endif /* longest_match() or longest_match_fast() sets match_start */ } if (s->match_length >= MIN_MATCH) { check_match(s, s->strstart, s->match_start, s->match_length); _tr_tally_dist(s, s->strstart - s->match_start, s->match_length - MIN_MATCH, bflush); s->lookahead -= s->match_length; /* Insert new strings in the hash table only if the match length * is not too large. This saves time but degrades compression. */ #ifndef FASTEST if (s->match_length <= s->max_insert_length && s->lookahead >= MIN_MATCH) { s->match_length--; /* string at strstart already in table */ do { s->strstart++; INSERT_STRING(s, s->strstart, hash_head); /* strstart never exceeds WSIZE-MAX_MATCH, so there are * always MIN_MATCH bytes ahead. */ } while (--s->match_length != 0); s->strstart++; } else #endif { s->strstart += s->match_length; s->match_length = 0; s->ins_h = s->window[s->strstart]; UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); #if MIN_MATCH != 3 Call UPDATE_HASH() MIN_MATCH-3 more times #endif /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not * matter since it will be recomputed at next deflate call. */ } } else { /* No match, output a literal byte */ Tracevv((stderr,"%c", s->window[s->strstart])); _tr_tally_lit (s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; } if (bflush) FLUSH_BLOCK(s, 0); } FLUSH_BLOCK(s, flush == Z_FINISH); return flush == Z_FINISH ? finish_done : block_done; } #ifndef FASTEST /* =========================================================================== * Same as above, but achieves better compression. We use a lazy * evaluation for matches: a match is finally adopted only if there is * no better match at the next window position. */ local block_state deflate_slow(s, flush) deflate_state *s; int flush; { IPos hash_head = NIL; /* head of hash chain */ int bflush; /* set if current block must be flushed */ /* Process the input block. */ for (;;) { /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the next match, plus MIN_MATCH bytes to insert the * string following the next match. */ if (s->lookahead < MIN_LOOKAHEAD) { fill_window(s); if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { return need_more; } if (s->lookahead == 0) break; /* flush the current block */ } /* Insert the string window[strstart .. strstart+2] in the * dictionary, and set hash_head to the head of the hash chain: */ if (s->lookahead >= MIN_MATCH) { INSERT_STRING(s, s->strstart, hash_head); } /* Find the longest match, discarding those <= prev_length. */ s->prev_length = s->match_length, s->prev_match = s->match_start; s->match_length = MIN_MATCH-1; if (hash_head != NIL && s->prev_length < s->max_lazy_match && s->strstart - hash_head <= MAX_DIST(s)) { /* To simplify the code, we prevent matches with the string * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) { s->match_length = longest_match (s, hash_head); } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) { s->match_length = longest_match_fast (s, hash_head); } /* longest_match() or longest_match_fast() sets match_start */ if (s->match_length <= 5 && (s->strategy == Z_FILTERED #if TOO_FAR <= 32767 || (s->match_length == MIN_MATCH && s->strstart - s->match_start > TOO_FAR) #endif )) { /* If prev_match is also MIN_MATCH, match_start is garbage * but we will ignore the current match anyway. */ s->match_length = MIN_MATCH-1; } } /* If there was a match at the previous step and the current * match is not better, output the previous match: */ if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; /* Do not insert strings in hash table beyond this. */ check_match(s, s->strstart-1, s->prev_match, s->prev_length); _tr_tally_dist(s, s->strstart -1 - s->prev_match, s->prev_length - MIN_MATCH, bflush); /* Insert in hash table all strings up to the end of the match. * strstart-1 and strstart are already inserted. If there is not * enough lookahead, the last two strings are not inserted in * the hash table. */ s->lookahead -= s->prev_length-1; s->prev_length -= 2; do { if (++s->strstart <= max_insert) { INSERT_STRING(s, s->strstart, hash_head); } } while (--s->prev_length != 0); s->match_available = 0; s->match_length = MIN_MATCH-1; s->strstart++; if (bflush) FLUSH_BLOCK(s, 0); } else if (s->match_available) { /* If there was no match at the previous position, output a * single literal. If there was a match but the current match * is longer, truncate the previous match to a single literal. */ Tracevv((stderr,"%c", s->window[s->strstart-1])); _tr_tally_lit(s, s->window[s->strstart-1], bflush); if (bflush) { FLUSH_BLOCK_ONLY(s, 0); } s->strstart++; s->lookahead--; if (s->strm->avail_out == 0) return need_more; } else { /* There is no previous match to compare with, wait for * the next step to decide. */ s->match_available = 1; s->strstart++; s->lookahead--; } } Assert (flush != Z_NO_FLUSH, "no flush?"); if (s->match_available) { Tracevv((stderr,"%c", s->window[s->strstart-1])); _tr_tally_lit(s, s->window[s->strstart-1], bflush); s->match_available = 0; } FLUSH_BLOCK(s, flush == Z_FINISH); return flush == Z_FINISH ? finish_done : block_done; } #endif /* FASTEST */ #if 0 /* =========================================================================== * For Z_RLE, simply look for runs of bytes, generate matches only of distance * one. Do not maintain a hash table. (It will be regenerated if this run of * deflate switches away from Z_RLE.) */ local block_state deflate_rle(s, flush) deflate_state *s; int flush; { int bflush; /* set if current block must be flushed */ uInt run; /* length of run */ uInt max; /* maximum length of run */ uInt prev; /* byte at distance one to match */ Bytef *scan; /* scan for end of run */ for (;;) { /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the longest encodable run. */ if (s->lookahead < MAX_MATCH) { fill_window(s); if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) { return need_more; } if (s->lookahead == 0) break; /* flush the current block */ } /* See how many times the previous byte repeats */ run = 0; if (s->strstart > 0) { /* if there is a previous byte, that is */ max = s->lookahead < MAX_MATCH ? s->lookahead : MAX_MATCH; scan = s->window + s->strstart - 1; prev = *scan++; do { if (*scan++ != prev) break; } while (++run < max); } /* Emit match if have run of MIN_MATCH or longer, else emit literal */ if (run >= MIN_MATCH) { check_match(s, s->strstart, s->strstart - 1, run); _tr_tally_dist(s, 1, run - MIN_MATCH, bflush); s->lookahead -= run; s->strstart += run; } else { /* No match, output a literal byte */ Tracevv((stderr,"%c", s->window[s->strstart])); _tr_tally_lit (s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; } if (bflush) FLUSH_BLOCK(s, 0); } FLUSH_BLOCK(s, flush == Z_FINISH); return flush == Z_FINISH ? finish_done : block_done; } #endif sks-ecc-0.93/zlib/trees.c0000644000175000017500000012577310604550750014206 0ustar nachonacho/* trees.c -- output deflated data using Huffman coding * Copyright (C) 1995-2005 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ /* * ALGORITHM * * The "deflation" process uses several Huffman trees. The more * common source values are represented by shorter bit sequences. * * Each code tree is stored in a compressed form which is itself * a Huffman encoding of the lengths of all the code strings (in * ascending order by source values). The actual code strings are * reconstructed from the lengths in the inflate process, as described * in the deflate specification. * * REFERENCES * * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc * * Storer, James A. * Data Compression: Methods and Theory, pp. 49-50. * Computer Science Press, 1988. ISBN 0-7167-8156-5. * * Sedgewick, R. * Algorithms, p290. * Addison-Wesley, 1983. ISBN 0-201-06672-6. */ /* @(#) $Id$ */ /* #define GEN_TREES_H */ #include "deflate.h" #ifdef DEBUG # include #endif /* =========================================================================== * Constants */ #define MAX_BL_BITS 7 /* Bit length codes must not exceed MAX_BL_BITS bits */ #define END_BLOCK 256 /* end of block literal code */ #define REP_3_6 16 /* repeat previous bit length 3-6 times (2 bits of repeat count) */ #define REPZ_3_10 17 /* repeat a zero length 3-10 times (3 bits of repeat count) */ #define REPZ_11_138 18 /* repeat a zero length 11-138 times (7 bits of repeat count) */ local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; local const int extra_dbits[D_CODES] /* extra bits for each distance code */ = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; local const uch bl_order[BL_CODES] = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; /* The lengths of the bit length codes are sent in order of decreasing * probability, to avoid transmitting the lengths for unused bit length codes. */ #define Buf_size (8 * 2*sizeof(char)) /* Number of bits used within bi_buf. (bi_buf might be implemented on * more than 16 bits on some systems.) */ /* =========================================================================== * Local data. These are initialized only once. */ #define DIST_CODE_LEN 512 /* see definition of array dist_code below */ #if defined(GEN_TREES_H) || !defined(STDC) /* non ANSI compilers may not accept trees.h */ local ct_data static_ltree[L_CODES+2]; /* The static literal tree. Since the bit lengths are imposed, there is no * need for the L_CODES extra codes used during heap construction. However * The codes 286 and 287 are needed to build a canonical tree (see _tr_init * below). */ local ct_data static_dtree[D_CODES]; /* The static distance tree. (Actually a trivial tree since all codes use * 5 bits.) */ uch _dist_code[DIST_CODE_LEN]; /* Distance codes. The first 256 values correspond to the distances * 3 .. 258, the last 256 values correspond to the top 8 bits of * the 15 bit distances. */ uch _length_code[MAX_MATCH-MIN_MATCH+1]; /* length code for each normalized match length (0 == MIN_MATCH) */ local int base_length[LENGTH_CODES]; /* First normalized length for each code (0 = MIN_MATCH) */ local int base_dist[D_CODES]; /* First normalized distance for each code (0 = distance of 1) */ #else # include "trees.h" #endif /* GEN_TREES_H */ struct static_tree_desc_s { const ct_data *static_tree; /* static tree or NULL */ const intf *extra_bits; /* extra bits for each code or NULL */ int extra_base; /* base index for extra_bits */ int elems; /* max number of elements in the tree */ int max_length; /* max bit length for the codes */ }; local static_tree_desc static_l_desc = {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; local static_tree_desc static_d_desc = {static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; local static_tree_desc static_bl_desc = {(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; /* =========================================================================== * Local (static) routines in this file. */ local void tr_static_init OF((void)); local void init_block OF((deflate_state *s)); local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); local void build_tree OF((deflate_state *s, tree_desc *desc)); local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); local int build_bl_tree OF((deflate_state *s)); local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, int blcodes)); local void compress_block OF((deflate_state *s, ct_data *ltree, ct_data *dtree)); local void set_data_type OF((deflate_state *s)); local unsigned bi_reverse OF((unsigned value, int length)); local void bi_windup OF((deflate_state *s)); local void bi_flush OF((deflate_state *s)); local void copy_block OF((deflate_state *s, charf *buf, unsigned len, int header)); #ifdef GEN_TREES_H local void gen_trees_header OF((void)); #endif #ifndef DEBUG # define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) /* Send a code of the given tree. c and tree must not have side effects */ #else /* DEBUG */ # define send_code(s, c, tree) \ { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ send_bits(s, tree[c].Code, tree[c].Len); } #endif /* =========================================================================== * Output a short LSB first on the stream. * IN assertion: there is enough room in pendingBuf. */ #define put_short(s, w) { \ put_byte(s, (uch)((w) & 0xff)); \ put_byte(s, (uch)((ush)(w) >> 8)); \ } /* =========================================================================== * Send a value on a given number of bits. * IN assertion: length <= 16 and value fits in length bits. */ #ifdef DEBUG local void send_bits OF((deflate_state *s, int value, int length)); local void send_bits(s, value, length) deflate_state *s; int value; /* value to send */ int length; /* number of bits */ { Tracevv((stderr," l %2d v %4x ", length, value)); Assert(length > 0 && length <= 15, "invalid length"); s->bits_sent += (ulg)length; /* If not enough room in bi_buf, use (valid) bits from bi_buf and * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) * unused bits in value. */ if (s->bi_valid > (int)Buf_size - length) { s->bi_buf |= (value << s->bi_valid); put_short(s, s->bi_buf); s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); s->bi_valid += length - Buf_size; } else { s->bi_buf |= value << s->bi_valid; s->bi_valid += length; } } #else /* !DEBUG */ #define send_bits(s, value, length) \ { int len = length;\ if (s->bi_valid > (int)Buf_size - len) {\ int val = value;\ s->bi_buf |= (val << s->bi_valid);\ put_short(s, s->bi_buf);\ s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ s->bi_valid += len - Buf_size;\ } else {\ s->bi_buf |= (value) << s->bi_valid;\ s->bi_valid += len;\ }\ } #endif /* DEBUG */ /* the arguments must not have side effects */ /* =========================================================================== * Initialize the various 'constant' tables. */ local void tr_static_init() { #if defined(GEN_TREES_H) || !defined(STDC) static int static_init_done = 0; int n; /* iterates over tree elements */ int bits; /* bit counter */ int length; /* length value */ int code; /* code value */ int dist; /* distance index */ ush bl_count[MAX_BITS+1]; /* number of codes at each bit length for an optimal tree */ if (static_init_done) return; /* For some embedded targets, global variables are not initialized: */ static_l_desc.static_tree = static_ltree; static_l_desc.extra_bits = extra_lbits; static_d_desc.static_tree = static_dtree; static_d_desc.extra_bits = extra_dbits; static_bl_desc.extra_bits = extra_blbits; /* Initialize the mapping length (0..255) -> length code (0..28) */ length = 0; for (code = 0; code < LENGTH_CODES-1; code++) { base_length[code] = length; for (n = 0; n < (1< dist code (0..29) */ dist = 0; for (code = 0 ; code < 16; code++) { base_dist[code] = dist; for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ for ( ; code < D_CODES; code++) { base_dist[code] = dist << 7; for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { _dist_code[256 + dist++] = (uch)code; } } Assert (dist == 256, "tr_static_init: 256+dist != 512"); /* Construct the codes of the static literal tree */ for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; n = 0; while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; /* Codes 286 and 287 do not exist, but we must include them in the * tree construction to get a canonical Huffman tree (longest code * all ones) */ gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); /* The static distance tree is trivial: */ for (n = 0; n < D_CODES; n++) { static_dtree[n].Len = 5; static_dtree[n].Code = bi_reverse((unsigned)n, 5); } static_init_done = 1; # ifdef GEN_TREES_H gen_trees_header(); # endif #endif /* defined(GEN_TREES_H) || !defined(STDC) */ } /* =========================================================================== * Genererate the file trees.h describing the static trees. */ #ifdef GEN_TREES_H # ifndef DEBUG # include # endif # define SEPARATOR(i, last, width) \ ((i) == (last)? "\n};\n\n" : \ ((i) % (width) == (width)-1 ? ",\n" : ", ")) void gen_trees_header() { FILE *header = fopen("trees.h", "w"); int i; Assert (header != NULL, "Can't open trees.h"); fprintf(header, "/* header created automatically with -DGEN_TREES_H */\n\n"); fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); for (i = 0; i < L_CODES+2; i++) { fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); } fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); for (i = 0; i < D_CODES; i++) { fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); } fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n"); for (i = 0; i < DIST_CODE_LEN; i++) { fprintf(header, "%2u%s", _dist_code[i], SEPARATOR(i, DIST_CODE_LEN-1, 20)); } fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { fprintf(header, "%2u%s", _length_code[i], SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); } fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); for (i = 0; i < LENGTH_CODES; i++) { fprintf(header, "%1u%s", base_length[i], SEPARATOR(i, LENGTH_CODES-1, 20)); } fprintf(header, "local const int base_dist[D_CODES] = {\n"); for (i = 0; i < D_CODES; i++) { fprintf(header, "%5u%s", base_dist[i], SEPARATOR(i, D_CODES-1, 10)); } fclose(header); } #endif /* GEN_TREES_H */ /* =========================================================================== * Initialize the tree data structures for a new zlib stream. */ void _tr_init(s) deflate_state *s; { tr_static_init(); s->l_desc.dyn_tree = s->dyn_ltree; s->l_desc.stat_desc = &static_l_desc; s->d_desc.dyn_tree = s->dyn_dtree; s->d_desc.stat_desc = &static_d_desc; s->bl_desc.dyn_tree = s->bl_tree; s->bl_desc.stat_desc = &static_bl_desc; s->bi_buf = 0; s->bi_valid = 0; s->last_eob_len = 8; /* enough lookahead for inflate */ #ifdef DEBUG s->compressed_len = 0L; s->bits_sent = 0L; #endif /* Initialize the first block of the first file: */ init_block(s); } /* =========================================================================== * Initialize a new block. */ local void init_block(s) deflate_state *s; { int n; /* iterates over tree elements */ /* Initialize the trees. */ for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; s->dyn_ltree[END_BLOCK].Freq = 1; s->opt_len = s->static_len = 0L; s->last_lit = s->matches = 0; } #define SMALLEST 1 /* Index within the heap array of least frequent node in the Huffman tree */ /* =========================================================================== * Remove the smallest element from the heap and recreate the heap with * one less element. Updates heap and heap_len. */ #define pqremove(s, tree, top) \ {\ top = s->heap[SMALLEST]; \ s->heap[SMALLEST] = s->heap[s->heap_len--]; \ pqdownheap(s, tree, SMALLEST); \ } /* =========================================================================== * Compares to subtrees, using the tree depth as tie breaker when * the subtrees have equal frequency. This minimizes the worst case length. */ #define smaller(tree, n, m, depth) \ (tree[n].Freq < tree[m].Freq || \ (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) /* =========================================================================== * Restore the heap property by moving down the tree starting at node k, * exchanging a node with the smallest of its two sons if necessary, stopping * when the heap property is re-established (each father smaller than its * two sons). */ local void pqdownheap(s, tree, k) deflate_state *s; ct_data *tree; /* the tree to restore */ int k; /* node to move down */ { int v = s->heap[k]; int j = k << 1; /* left son of k */ while (j <= s->heap_len) { /* Set j to the smallest of the two sons: */ if (j < s->heap_len && smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { j++; } /* Exit if v is smaller than both sons */ if (smaller(tree, v, s->heap[j], s->depth)) break; /* Exchange v with the smallest son */ s->heap[k] = s->heap[j]; k = j; /* And continue down the tree, setting j to the left son of k */ j <<= 1; } s->heap[k] = v; } /* =========================================================================== * Compute the optimal bit lengths for a tree and update the total bit length * for the current block. * IN assertion: the fields freq and dad are set, heap[heap_max] and * above are the tree nodes sorted by increasing frequency. * OUT assertions: the field len is set to the optimal bit length, the * array bl_count contains the frequencies for each bit length. * The length opt_len is updated; static_len is also updated if stree is * not null. */ local void gen_bitlen(s, desc) deflate_state *s; tree_desc *desc; /* the tree descriptor */ { ct_data *tree = desc->dyn_tree; int max_code = desc->max_code; const ct_data *stree = desc->stat_desc->static_tree; const intf *extra = desc->stat_desc->extra_bits; int base = desc->stat_desc->extra_base; int max_length = desc->stat_desc->max_length; int h; /* heap index */ int n, m; /* iterate over the tree elements */ int bits; /* bit length */ int xbits; /* extra bits */ ush f; /* frequency */ int overflow = 0; /* number of elements with bit length too large */ for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; /* In a first pass, compute the optimal bit lengths (which may * overflow in the case of the bit length tree). */ tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ for (h = s->heap_max+1; h < HEAP_SIZE; h++) { n = s->heap[h]; bits = tree[tree[n].Dad].Len + 1; if (bits > max_length) bits = max_length, overflow++; tree[n].Len = (ush)bits; /* We overwrite tree[n].Dad which is no longer needed */ if (n > max_code) continue; /* not a leaf node */ s->bl_count[bits]++; xbits = 0; if (n >= base) xbits = extra[n-base]; f = tree[n].Freq; s->opt_len += (ulg)f * (bits + xbits); if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); } if (overflow == 0) return; Trace((stderr,"\nbit length overflow\n")); /* This happens for example on obj2 and pic of the Calgary corpus */ /* Find the first bit length which could increase: */ do { bits = max_length-1; while (s->bl_count[bits] == 0) bits--; s->bl_count[bits]--; /* move one leaf down the tree */ s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ s->bl_count[max_length]--; /* The brother of the overflow item also moves one step up, * but this does not affect bl_count[max_length] */ overflow -= 2; } while (overflow > 0); /* Now recompute all bit lengths, scanning in increasing frequency. * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all * lengths instead of fixing only the wrong ones. This idea is taken * from 'ar' written by Haruhiko Okumura.) */ for (bits = max_length; bits != 0; bits--) { n = s->bl_count[bits]; while (n != 0) { m = s->heap[--h]; if (m > max_code) continue; if ((unsigned) tree[m].Len != (unsigned) bits) { Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); s->opt_len += ((long)bits - (long)tree[m].Len) *(long)tree[m].Freq; tree[m].Len = (ush)bits; } n--; } } } /* =========================================================================== * Generate the codes for a given tree and bit counts (which need not be * optimal). * IN assertion: the array bl_count contains the bit length statistics for * the given tree and the field len is set for all tree elements. * OUT assertion: the field code is set for all tree elements of non * zero code length. */ local void gen_codes (tree, max_code, bl_count) ct_data *tree; /* the tree to decorate */ int max_code; /* largest code with non zero frequency */ ushf *bl_count; /* number of codes at each bit length */ { ush next_code[MAX_BITS+1]; /* next code value for each bit length */ ush code = 0; /* running code value */ int bits; /* bit index */ int n; /* code index */ /* The distribution counts are first used to generate the code values * without bit reversal. */ for (bits = 1; bits <= MAX_BITS; bits++) { next_code[bits] = code = (code + bl_count[bits-1]) << 1; } /* Check that the bit counts in bl_count are consistent. The last code * must be all ones. */ Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; const ct_data *stree = desc->stat_desc->static_tree; int elems = desc->stat_desc->elems; int n, m; /* iterate over heap elements */ int max_code = -1; /* largest code with non zero frequency */ int node; /* new node being created */ /* Construct the initial heap, with least frequent element in * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. * heap[0] is not used. */ s->heap_len = 0, s->heap_max = HEAP_SIZE; for (n = 0; n < elems; n++) { if (tree[n].Freq != 0) { s->heap[++(s->heap_len)] = max_code = n; s->depth[n] = 0; } else { tree[n].Len = 0; } } /* The pkzip format requires that at least one distance code exists, * and that at least one bit should be sent even if there is only one * possible code. So to avoid special checks later on we force at least * two codes of non zero frequency. */ while (s->heap_len < 2) { node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); tree[node].Freq = 1; s->depth[node] = 0; s->opt_len--; if (stree) s->static_len -= stree[node].Len; /* node is 0 or 1 so it does not have extra bits */ } desc->max_code = max_code; /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, * establish sub-heaps of increasing lengths: */ for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); /* Construct the Huffman tree by repeatedly combining the least two * frequent nodes. */ node = elems; /* next internal node of the tree */ do { pqremove(s, tree, n); /* n = node of least frequency */ m = s->heap[SMALLEST]; /* m = node of next least frequency */ s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ s->heap[--(s->heap_max)] = m; /* Create a new node father of n and m */ tree[node].Freq = tree[n].Freq + tree[m].Freq; s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ? s->depth[n] : s->depth[m]) + 1); tree[n].Dad = tree[m].Dad = (ush)node; #ifdef DUMP_BL_TREE if (tree == s->bl_tree) { fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); } #endif /* and insert the new node in the heap */ s->heap[SMALLEST] = node++; pqdownheap(s, tree, SMALLEST); } while (s->heap_len >= 2); s->heap[--(s->heap_max)] = s->heap[SMALLEST]; /* At this point, the fields freq and dad are set. We can now * generate the bit lengths. */ gen_bitlen(s, (tree_desc *)desc); /* The field len is now set, we can generate the bit codes */ gen_codes ((ct_data *)tree, max_code, s->bl_count); } /* =========================================================================== * Scan a literal or distance tree to determine the frequencies of the codes * in the bit length tree. */ local void scan_tree (s, tree, max_code) deflate_state *s; ct_data *tree; /* the tree to be scanned */ int max_code; /* and its largest code of non zero frequency */ { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ int nextlen = tree[0].Len; /* length of next code */ int count = 0; /* repeat count of the current code */ int max_count = 7; /* max repeat count */ int min_count = 4; /* min repeat count */ if (nextlen == 0) max_count = 138, min_count = 3; tree[max_code+1].Len = (ush)0xffff; /* guard */ for (n = 0; n <= max_code; n++) { curlen = nextlen; nextlen = tree[n+1].Len; if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { s->bl_tree[curlen].Freq += count; } else if (curlen != 0) { if (curlen != prevlen) s->bl_tree[curlen].Freq++; s->bl_tree[REP_3_6].Freq++; } else if (count <= 10) { s->bl_tree[REPZ_3_10].Freq++; } else { s->bl_tree[REPZ_11_138].Freq++; } count = 0; prevlen = curlen; if (nextlen == 0) { max_count = 138, min_count = 3; } else if (curlen == nextlen) { max_count = 6, min_count = 3; } else { max_count = 7, min_count = 4; } } } /* =========================================================================== * Send a literal or distance tree in compressed form, using the codes in * bl_tree. */ local void send_tree (s, tree, max_code) deflate_state *s; ct_data *tree; /* the tree to be scanned */ int max_code; /* and its largest code of non zero frequency */ { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ int nextlen = tree[0].Len; /* length of next code */ int count = 0; /* repeat count of the current code */ int max_count = 7; /* max repeat count */ int min_count = 4; /* min repeat count */ /* tree[max_code+1].Len = -1; */ /* guard already set */ if (nextlen == 0) max_count = 138, min_count = 3; for (n = 0; n <= max_code; n++) { curlen = nextlen; nextlen = tree[n+1].Len; if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { do { send_code(s, curlen, s->bl_tree); } while (--count != 0); } else if (curlen != 0) { if (curlen != prevlen) { send_code(s, curlen, s->bl_tree); count--; } Assert(count >= 3 && count <= 6, " 3_6?"); send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); } else if (count <= 10) { send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); } else { send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); } count = 0; prevlen = curlen; if (nextlen == 0) { max_count = 138, min_count = 3; } else if (curlen == nextlen) { max_count = 6, min_count = 3; } else { max_count = 7, min_count = 4; } } } /* =========================================================================== * Construct the Huffman tree for the bit lengths and return the index in * bl_order of the last bit length code to send. */ local int build_bl_tree(s) deflate_state *s; { int max_blindex; /* index of last bit length code of non zero freq */ /* Determine the bit length frequencies for literal and distance trees */ scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); /* Build the bit length tree: */ build_tree(s, (tree_desc *)(&(s->bl_desc))); /* opt_len now includes the length of the tree representations, except * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. */ /* Determine the number of bit length codes to send. The pkzip format * requires that at least 4 bit length codes be sent. (appnote.txt says * 3 but the actual value used is 4.) */ for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; } /* Update opt_len to include the bit length tree and counts */ s->opt_len += 3*(max_blindex+1) + 5+5+4; Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", s->opt_len, s->static_len)); return max_blindex; } /* =========================================================================== * Send the header for a block using dynamic Huffman trees: the counts, the * lengths of the bit length codes, the literal tree and the distance tree. * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. */ local void send_all_trees(s, lcodes, dcodes, blcodes) deflate_state *s; int lcodes, dcodes, blcodes; /* number of codes for each tree */ { int rank; /* index in bl_order */ Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, "too many codes"); Tracev((stderr, "\nbl counts: ")); send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ send_bits(s, dcodes-1, 5); send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ for (rank = 0; rank < blcodes; rank++) { Tracev((stderr, "\nbl code %2d ", bl_order[rank])); send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); } Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); } /* =========================================================================== * Send a stored block */ void _tr_stored_block(s, buf, stored_len, eof) deflate_state *s; charf *buf; /* input block */ ulg stored_len; /* length of input block */ int eof; /* true if this is the last block for a file */ { send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ #ifdef DEBUG s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; s->compressed_len += (stored_len + 4) << 3; #endif copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ } /* =========================================================================== * Send one empty static block to give enough lookahead for inflate. * This takes 10 bits, of which 7 may remain in the bit buffer. * The current inflate code requires 9 bits of lookahead. If the * last two codes for the previous block (real code plus EOB) were coded * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode * the last real code. In this case we send two empty static blocks instead * of one. (There are no problems if the previous block is stored or fixed.) * To simplify the code, we assume the worst case of last real code encoded * on one bit only. */ void _tr_align(s) deflate_state *s; { send_bits(s, STATIC_TREES<<1, 3); send_code(s, END_BLOCK, static_ltree); #ifdef DEBUG s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ #endif bi_flush(s); /* Of the 10 bits for the empty block, we have already sent * (10 - bi_valid) bits. The lookahead for the last real code (before * the EOB of the previous block) was thus at least one plus the length * of the EOB plus what we have just sent of the empty static block. */ if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { send_bits(s, STATIC_TREES<<1, 3); send_code(s, END_BLOCK, static_ltree); #ifdef DEBUG s->compressed_len += 10L; #endif bi_flush(s); } s->last_eob_len = 7; } /* =========================================================================== * Determine the best encoding for the current block: dynamic trees, static * trees or store, and output the encoded block to the zip file. */ void _tr_flush_block(s, buf, stored_len, eof) deflate_state *s; charf *buf; /* input block, or NULL if too old */ ulg stored_len; /* length of input block */ int eof; /* true if this is the last block for a file */ { ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ int max_blindex = 0; /* index of last bit length code of non zero freq */ /* Build the Huffman trees unless a stored block is forced */ if (s->level > 0) { /* Check if the file is binary or text */ if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN) set_data_type(s); /* Construct the literal and distance trees */ build_tree(s, (tree_desc *)(&(s->l_desc))); Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, s->static_len)); build_tree(s, (tree_desc *)(&(s->d_desc))); Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, s->static_len)); /* At this point, opt_len and static_len are the total bit lengths of * the compressed block data, excluding the tree representations. */ /* Build the bit length tree for the above two trees, and get the index * in bl_order of the last bit length code to send. */ max_blindex = build_bl_tree(s); /* Determine the best encoding. Compute the block lengths in bytes. */ opt_lenb = (s->opt_len+3+7)>>3; static_lenb = (s->static_len+3+7)>>3; Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, s->last_lit)); if (static_lenb <= opt_lenb) opt_lenb = static_lenb; } else { Assert(buf != (char*)0, "lost buf"); opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ } #ifdef FORCE_STORED if (buf != (char*)0) { /* force stored block */ #else if (stored_len+4 <= opt_lenb && buf != (char*)0) { /* 4: two words for the lengths */ #endif /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. * Otherwise we can't have processed more than WSIZE input bytes since * the last block flush, because compression would have been * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to * transform a block into a stored block. */ _tr_stored_block(s, buf, stored_len, eof); #ifdef FORCE_STATIC } else if (static_lenb >= 0) { /* force static trees */ #else } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { #endif send_bits(s, (STATIC_TREES<<1)+eof, 3); compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); #ifdef DEBUG s->compressed_len += 3 + s->static_len; #endif } else { send_bits(s, (DYN_TREES<<1)+eof, 3); send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, max_blindex+1); compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); #ifdef DEBUG s->compressed_len += 3 + s->opt_len; #endif } Assert (s->compressed_len == s->bits_sent, "bad compressed size"); /* The above check is made mod 2^32, for files larger than 512 MB * and uLong implemented on 32 bits. */ init_block(s); if (eof) { bi_windup(s); #ifdef DEBUG s->compressed_len += 7; /* align on byte boundary */ #endif } Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, s->compressed_len-7*eof)); } /* =========================================================================== * Save the match info and tally the frequency counts. Return true if * the current block must be flushed. */ int _tr_tally (s, dist, lc) deflate_state *s; unsigned dist; /* distance of matched string */ unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ { s->d_buf[s->last_lit] = (ush)dist; s->l_buf[s->last_lit++] = (uch)lc; if (dist == 0) { /* lc is the unmatched char */ s->dyn_ltree[lc].Freq++; } else { s->matches++; /* Here, lc is the match length - MIN_MATCH */ dist--; /* dist = match distance - 1 */ Assert((ush)dist < (ush)MAX_DIST(s) && (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; s->dyn_dtree[d_code(dist)].Freq++; } #ifdef TRUNCATE_BLOCK /* Try to guess if it is profitable to stop the current block here */ if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { /* Compute an upper bound for the compressed length */ ulg out_length = (ulg)s->last_lit*8L; ulg in_length = (ulg)((long)s->strstart - s->block_start); int dcode; for (dcode = 0; dcode < D_CODES; dcode++) { out_length += (ulg)s->dyn_dtree[dcode].Freq * (5L+extra_dbits[dcode]); } out_length >>= 3; Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", s->last_lit, in_length, out_length, 100L - out_length*100L/in_length)); if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; } #endif return (s->last_lit == s->lit_bufsize-1); /* We avoid equality with lit_bufsize because of wraparound at 64K * on 16 bit machines and because stored blocks are restricted to * 64K-1 bytes. */ } /* =========================================================================== * Send the block data compressed using the given Huffman trees */ local void compress_block(s, ltree, dtree) deflate_state *s; ct_data *ltree; /* literal tree */ ct_data *dtree; /* distance tree */ { unsigned dist; /* distance of matched string */ int lc; /* match length or unmatched char (if dist == 0) */ unsigned lx = 0; /* running index in l_buf */ unsigned code; /* the code to send */ int extra; /* number of extra bits to send */ if (s->last_lit != 0) do { dist = s->d_buf[lx]; lc = s->l_buf[lx++]; if (dist == 0) { send_code(s, lc, ltree); /* send a literal byte */ Tracecv(isgraph(lc), (stderr," '%c' ", lc)); } else { /* Here, lc is the match length - MIN_MATCH */ code = _length_code[lc]; send_code(s, code+LITERALS+1, ltree); /* send the length code */ extra = extra_lbits[code]; if (extra != 0) { lc -= base_length[code]; send_bits(s, lc, extra); /* send the extra length bits */ } dist--; /* dist is now the match distance - 1 */ code = d_code(dist); Assert (code < D_CODES, "bad d_code"); send_code(s, code, dtree); /* send the distance code */ extra = extra_dbits[code]; if (extra != 0) { dist -= base_dist[code]; send_bits(s, dist, extra); /* send the extra distance bits */ } } /* literal or match pair ? */ /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, "pendingBuf overflow"); } while (lx < s->last_lit); send_code(s, END_BLOCK, ltree); s->last_eob_len = ltree[END_BLOCK].Len; } /* =========================================================================== * Set the data type to BINARY or TEXT, using a crude approximation: * set it to Z_TEXT if all symbols are either printable characters (33 to 255) * or white spaces (9 to 13, or 32); or set it to Z_BINARY otherwise. * IN assertion: the fields Freq of dyn_ltree are set. */ local void set_data_type(s) deflate_state *s; { int n; for (n = 0; n < 9; n++) if (s->dyn_ltree[n].Freq != 0) break; if (n == 9) for (n = 14; n < 32; n++) if (s->dyn_ltree[n].Freq != 0) break; s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY; } /* =========================================================================== * Reverse the first len bits of a code, using straightforward code (a faster * method would use a table) * IN assertion: 1 <= len <= 15 */ local unsigned bi_reverse(code, len) unsigned code; /* the value to invert */ int len; /* its bit length */ { register unsigned res = 0; do { res |= code & 1; code >>= 1, res <<= 1; } while (--len > 0); return res >> 1; } /* =========================================================================== * Flush the bit buffer, keeping at most 7 bits in it. */ local void bi_flush(s) deflate_state *s; { if (s->bi_valid == 16) { put_short(s, s->bi_buf); s->bi_buf = 0; s->bi_valid = 0; } else if (s->bi_valid >= 8) { put_byte(s, (Byte)s->bi_buf); s->bi_buf >>= 8; s->bi_valid -= 8; } } /* =========================================================================== * Flush the bit buffer and align the output on a byte boundary */ local void bi_windup(s) deflate_state *s; { if (s->bi_valid > 8) { put_short(s, s->bi_buf); } else if (s->bi_valid > 0) { put_byte(s, (Byte)s->bi_buf); } s->bi_buf = 0; s->bi_valid = 0; #ifdef DEBUG s->bits_sent = (s->bits_sent+7) & ~7; #endif } /* =========================================================================== * Copy a stored block, storing first the length and its * one's complement if requested. */ local void copy_block(s, buf, len, header) deflate_state *s; charf *buf; /* the input data */ unsigned len; /* its length */ int header; /* true if block header must be written */ { bi_windup(s); /* align on byte boundary */ s->last_eob_len = 8; /* enough lookahead for inflate */ if (header) { put_short(s, (ush)len); put_short(s, (ush)~len); #ifdef DEBUG s->bits_sent += 2*16; #endif } #ifdef DEBUG s->bits_sent += (ulg)len<<3; #endif while (len--) { put_byte(s, *buf++); } } sks-ecc-0.93/zlib/compress.c0000644000175000017500000000467110604550750014710 0ustar nachonacho/* compress.c -- compress a memory buffer * Copyright (C) 1995-2003 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #define ZLIB_INTERNAL #include "zlib.h" /* =========================================================================== 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. */ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) Bytef *dest; uLongf *destLen; const Bytef *source; uLong sourceLen; int level; { z_stream stream; int err; stream.next_in = (Bytef*)source; stream.avail_in = (uInt)sourceLen; #ifdef MAXSEG_64K /* Check for source > 64K on 16-bit machine: */ if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; #endif stream.next_out = dest; stream.avail_out = (uInt)*destLen; if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; stream.zalloc = (alloc_func)0; stream.zfree = (free_func)0; stream.opaque = (voidpf)0; err = deflateInit(&stream, level); if (err != Z_OK) return err; err = deflate(&stream, Z_FINISH); if (err != Z_STREAM_END) { deflateEnd(&stream); return err == Z_OK ? Z_BUF_ERROR : err; } *destLen = stream.total_out; err = deflateEnd(&stream); return err; } /* =========================================================================== */ int ZEXPORT compress (dest, destLen, source, sourceLen) Bytef *dest; uLongf *destLen; const Bytef *source; uLong sourceLen; { return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); } /* =========================================================================== If the default memLevel or windowBits for deflateInit() is changed, then this function needs to be updated. */ uLong ZEXPORT compressBound (sourceLen) uLong sourceLen; { return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11; } sks-ecc-0.93/zlib/inflate.h0000644000175000017500000001343410604550750014501 0ustar nachonacho/* inflate.h -- internal inflate state definition * Copyright (C) 1995-2004 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ /* define NO_GZIP when compiling if you want to disable gzip header and trailer decoding by inflate(). NO_GZIP would be used to avoid linking in the crc code when it is not needed. For shared libraries, gzip decoding should be left enabled. */ #ifndef NO_GZIP # define GUNZIP #endif /* Possible inflate modes between inflate() calls */ typedef enum { HEAD, /* i: waiting for magic header */ FLAGS, /* i: waiting for method and flags (gzip) */ TIME, /* i: waiting for modification time (gzip) */ OS, /* i: waiting for extra flags and operating system (gzip) */ EXLEN, /* i: waiting for extra length (gzip) */ EXTRA, /* i: waiting for extra bytes (gzip) */ NAME, /* i: waiting for end of file name (gzip) */ COMMENT, /* i: waiting for end of comment (gzip) */ HCRC, /* i: waiting for header crc (gzip) */ DICTID, /* i: waiting for dictionary check value */ DICT, /* waiting for inflateSetDictionary() call */ TYPE, /* i: waiting for type bits, including last-flag bit */ TYPEDO, /* i: same, but skip check to exit inflate on new block */ STORED, /* i: waiting for stored size (length and complement) */ COPY, /* i/o: waiting for input or output to copy stored block */ TABLE, /* i: waiting for dynamic block table lengths */ LENLENS, /* i: waiting for code length code lengths */ CODELENS, /* i: waiting for length/lit and distance code lengths */ LEN, /* i: waiting for length/lit code */ LENEXT, /* i: waiting for length extra bits */ DIST, /* i: waiting for distance code */ DISTEXT, /* i: waiting for distance extra bits */ MATCH, /* o: waiting for output space to copy string */ LIT, /* o: waiting for output space to write literal */ CHECK, /* i: waiting for 32-bit check value */ LENGTH, /* i: waiting for 32-bit length (gzip) */ DONE, /* finished check, done -- remain here until reset */ BAD, /* got a data error -- remain here until reset */ MEM, /* got an inflate() memory error -- remain here until reset */ SYNC /* looking for synchronization bytes to restart inflate() */ } inflate_mode; /* State transitions between above modes - (most modes can go to the BAD or MEM mode -- not shown for clarity) Process header: HEAD -> (gzip) or (zlib) (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME NAME -> COMMENT -> HCRC -> TYPE (zlib) -> DICTID or TYPE DICTID -> DICT -> TYPE Read deflate blocks: TYPE -> STORED or TABLE or LEN or CHECK STORED -> COPY -> TYPE TABLE -> LENLENS -> CODELENS -> LEN Read deflate codes: LEN -> LENEXT or LIT or TYPE LENEXT -> DIST -> DISTEXT -> MATCH -> LEN LIT -> LEN Process trailer: CHECK -> LENGTH -> DONE */ /* state maintained between inflate() calls. Approximately 7K bytes. */ struct inflate_state { inflate_mode mode; /* current inflate mode */ int last; /* true if processing last block */ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ int havedict; /* true if dictionary provided */ int flags; /* gzip header method and flags (0 if zlib) */ unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ unsigned long check; /* protected copy of check value */ unsigned long total; /* protected copy of output count */ gz_headerp head; /* where to save gzip header information */ /* sliding window */ unsigned wbits; /* log base 2 of requested window size */ unsigned wsize; /* window size or zero if not using window */ unsigned whave; /* valid bytes in the window */ unsigned write; /* window write index */ unsigned char FAR *window; /* allocated sliding window, if needed */ /* bit accumulator */ unsigned long hold; /* input bit accumulator */ unsigned bits; /* number of bits in "in" */ /* for string and stored block copying */ unsigned length; /* literal or length of data to copy */ unsigned offset; /* distance back to copy string from */ /* for table and code decoding */ unsigned extra; /* extra bits needed */ /* fixed and dynamic code tables */ code const FAR *lencode; /* starting table for length/literal codes */ code const FAR *distcode; /* starting table for distance codes */ unsigned lenbits; /* index bits for lencode */ unsigned distbits; /* index bits for distcode */ /* dynamic table building */ unsigned ncode; /* number of code length code lengths */ unsigned nlen; /* number of length code lengths */ unsigned ndist; /* number of distance code lengths */ unsigned have; /* number of code lengths in lens[] */ code FAR *next; /* next available space in codes[] */ unsigned short lens[320]; /* temporary storage for code lengths */ unsigned short work[288]; /* work area for code table building */ code codes[ENOUGH]; /* space for code tables */ }; sks-ecc-0.93/zlib/zlib.h0000644000175000017500000020121410604550750014012 0ustar nachonacho/* zlib.h -- interface of the 'zlib' general purpose compression library version 1.2.3, July 18th, 2005 Copyright (C) 1995-2005 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 http://www.ietf.org/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.2.3" #define ZLIB_VERNUM 0x1230 /* 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 compressed data format used by default by the in-memory functions is the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped around a deflate stream, which is itself documented in RFC 1951. The library also supports reading and writing files in gzip (.gz) format with an interface similar to that of stdio using the functions that start with "gz". The gzip format is different from the zlib format. gzip is a gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. This library can optionally read and write gzip streams in memory as well. The zlib format was designed to be compact and fast for use in memory and on communications channels. The gzip format was designed for single- file compression on file systems, has a larger header than zlib to maintain directory information, and uses a different, slower check method than zlib. 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: binary or text */ uLong adler; /* adler32 value of the uncompressed data */ uLong reserved; /* reserved for future use */ } z_stream; typedef z_stream FAR *z_streamp; /* gzip header information passed to and from zlib routines. See RFC 1952 for more details on the meanings of these fields. */ typedef struct gz_header_s { int text; /* true if compressed data believed to be text */ uLong time; /* modification time */ int xflags; /* extra flags (not used when writing a gzip file) */ int os; /* operating system */ Bytef *extra; /* pointer to extra field or Z_NULL if none */ uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ uInt extra_max; /* space at extra (only when reading header) */ Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ uInt name_max; /* space at name (only when reading header) */ Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ uInt comm_max; /* space at comment (only when reading header) */ int hcrc; /* true if there was or will be a header crc */ int done; /* true when done reading gzip header (not used when writing a gzip file) */ } gz_header; typedef gz_header FAR *gz_headerp; /* 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 #define Z_BLOCK 5 /* Allowed flush values; see deflate() and inflate() 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_RLE 3 #define Z_FIXED 4 #define Z_DEFAULT_STRATEGY 0 /* compression strategy; see deflateInit2() below for details */ #define Z_BINARY 0 #define Z_TEXT 1 #define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ #define Z_UNKNOWN 2 /* Possible values of the data_type field (though see inflate()) */ #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. Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to decide how much data to accumualte before producing output, in order to maximize compression. 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 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). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that avail_out is greater than six to avoid repeated flush markers due to avail_out == 0 on return. 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 the value returned by deflateBound (see below). 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 strm->data_type if it can make a good guess about the input data type (Z_BINARY or Z_TEXT). 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). Note that Z_BUF_ERROR is not fatal, and deflate() can be called again with more input and more output space to continue compressing. */ 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 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. The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much output as possible to the output buffer. Z_BLOCK requests that inflate() stop if and when it gets to the next deflate block boundary. When decoding the zlib or gzip format, this will cause inflate() to return immediately after the header and before the first block. When doing a raw inflate, inflate() will go ahead and process the first block, and will return when it gets to the end of that block, or when it runs out of data. The Z_BLOCK option assists in appending to or combining deflate streams. Also to assist in this, on return inflate() will set strm->data_type to the number of unused bits in the last byte taken from strm->next_in, plus 64 if inflate() is currently decoding the last block in the deflate stream, plus 128 if inflate() returned immediately after decoding an end-of-block code or decoding the complete header up to just before the first byte of the deflate stream. The end-of-block will not be indicated until all of the uncompressed data from that block has been written to strm->next_out. The number of unused bits may in general be greater than seven, except when bit 7 of data_type is set, in which case the number of unused bits will be less than eight. 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 approach may be used for the single inflate() call. In this implementation, inflate() always flushes as much output as possible to the output buffer, and always uses the faster approach on the first call. So the only effect of the flush parameter in this implementation is on the return value of inflate(), as noted below, or when it returns early because Z_BLOCK is used. If a preset dictionary is needed after this call (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() will decompress and check either zlib-wrapped or gzip-wrapped deflate data. The header type is detected automatically. Any information contained in the gzip header is not retained, so applications that need that information should instead use raw inflate, see inflateInit2() below, or inflateBack() and perform their own processing of the gzip header and trailer. 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 check value), 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. Note that Z_BUF_ERROR is not fatal, and inflate() can be called again with more input and more output space to continue decompressing. If Z_DATA_ERROR is returned, the application may then call inflateSync() to look for a good compression block if a partial recovery of the data is desired. */ 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. windowBits can also be -8..-15 for raw deflate. In this case, -windowBits determines the window size. deflate() will then generate raw deflate data with no zlib header or trailer, and will not compute an adler32 check value. windowBits can also be greater than 15 for optional gzip encoding. Add 16 to windowBits to write a simple gzip header and trailer around the compressed data instead of a zlib wrapper. The gzip header will have no file name, no extra data, no comment, no modification time (set to zero), no header crc, and the operating system will be set to 255 (unknown). If a gzip stream is being written, strm->adler is a crc32 instead of an adler32. 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), Z_HUFFMAN_ONLY to force Huffman encoding only (no string match), or Z_RLE to limit match distances to one (run-length encoding). 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. Z_RLE is designed to be almost as fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately. Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications. 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. In addition, the current implementation of deflate will use at most the window size minus 262 bytes of the provided dictionary. 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.) If a raw deflate was requested, then the adler32 value is not computed and strm->adler is not set. 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 deflateTune OF((z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain)); /* Fine tune deflate's internal compression parameters. This should only be used by someone who understands the algorithm used by zlib's deflate for searching for the best matching string, and even then only by the most fanatic optimizer trying to squeeze out the last compressed bit for their specific input data. Read the deflate.c source code for the meaning of the max_lazy, good_length, nice_length, and max_chain parameters. deflateTune() can be called after deflateInit() or deflateInit2(), and returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. */ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, uLong sourceLen)); /* deflateBound() returns an upper bound on the compressed size after deflation of sourceLen bytes. It must be called after deflateInit() or deflateInit2(). This would be used to allocate an output buffer for deflation in a single pass, and so would be called before deflate(). */ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, int bits, int value)); /* deflatePrime() inserts bits in the deflate output stream. The intent is that this function is used to start off the deflate output with the bits leftover from a previous deflate stream when appending to it. As such, this function can only be used for raw deflate, and must be used before the first deflate() call after a deflateInit2() or deflateReset(). bits must be less than or equal to 16, and that many of the least significant bits of value will be inserted in the output. deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, gz_headerp head)); /* deflateSetHeader() provides gzip header information for when a gzip stream is requested by deflateInit2(). deflateSetHeader() may be called after deflateInit2() or deflateReset() and before the first call of deflate(). The text, time, os, extra field, name, and comment information in the provided gz_header structure are written to the gzip header (xflag is ignored -- the extra flags are set according to the compression level). The caller must assure that, if not Z_NULL, name and comment are terminated with a zero byte, and that if extra is not Z_NULL, that extra_len bytes are available there. If hcrc is true, a gzip header crc is included. Note that the current versions of the command-line version of gzip (up through version 1.3.x) do not support header crc's, and will report that it is a "multi-part gzip file" and give up. If deflateSetHeader is not used, the default gzip header has text false, the time set to zero, and os set to 255, with no extra, name, or comment fields. The gzip header is returned to the default state by deflateReset(). deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ /* 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. windowBits must be greater than or equal to the windowBits value provided to deflateInit2() while compressing, or it must be equal to 15 if deflateInit2() was not used. 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. windowBits can also be -8..-15 for raw inflate. In this case, -windowBits determines the window size. inflate() will then process raw deflate data, not looking for a zlib or gzip header, not generating a check value, and not looking for any check values for comparison at the end of the stream. This is for use with other formats that use the deflate compressed data format such as zip. Those formats provide their own check values. If a custom format is developed using the raw deflate format for compressed data, it is recommended that a check value such as an adler32 or a crc32 be applied to the uncompressed data as is done in the zlib, gzip, and zip formats. For most applications, the zlib format should be used as is. Note that comments above on the use in deflateInit2() applies to the magnitude of windowBits. windowBits can also be greater than 15 for optional gzip decoding. Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection, or add 16 to decode only the gzip format (the zlib format will return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a crc32 instead of an adler32. 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 null strm). 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 that call returned Z_NEED_DICT. The dictionary chosen by the compressor can be determined from the adler32 value returned by that call of inflate. The compressor and decompressor must use exactly the same dictionary (see deflateSetDictionary). For raw inflate, this function can be called immediately after inflateInit2() or inflateReset() and before any call of inflate() to set the dictionary. The application must insure that the dictionary that was used for compression is provided. 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 inflateCopy 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 randomly accessing a large stream. The first pass through the stream can periodically record the inflate state, allowing restarting inflate at those points when randomly accessing the stream. inflateCopy 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 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). */ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, int bits, int value)); /* This function inserts bits in the inflate input stream. The intent is that this function is used to start inflating at a bit position in the middle of a byte. The provided bits will be used before any bytes are used from next_in. This function should only be used with raw inflate, and should be used before the first inflate() call after inflateInit2() or inflateReset(). bits must be less than or equal to 16, and that many of the least significant bits of value will be inserted in the input. inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, gz_headerp head)); /* inflateGetHeader() requests that gzip header information be stored in the provided gz_header structure. inflateGetHeader() may be called after inflateInit2() or inflateReset(), and before the first call of inflate(). As inflate() processes the gzip stream, head->done is zero until the header is completed, at which time head->done is set to one. If a zlib stream is being decoded, then head->done is set to -1 to indicate that there will be no gzip header information forthcoming. Note that Z_BLOCK can be used to force inflate() to return immediately after header processing is complete and before any actual data is decompressed. The text, time, xflags, and os fields are filled in with the gzip header contents. hcrc is set to true if there is a header CRC. (The header CRC was valid if done is set to one.) If extra is not Z_NULL, then extra_max contains the maximum number of bytes to write to extra. Once done is true, extra_len contains the actual extra field length, and extra contains the extra field, or that field truncated if extra_max is less than extra_len. If name is not Z_NULL, then up to name_max characters are written there, terminated with a zero unless the length is greater than name_max. If comment is not Z_NULL, then up to comm_max characters are written there, terminated with a zero unless the length is greater than comm_max. When any of extra, name, or comment are not Z_NULL and the respective field is not present in the header, then that field is set to Z_NULL to signal its absence. This allows the use of deflateSetHeader() with the returned structure to duplicate the header. However if those fields are set to allocated memory, then the application will need to save those pointers elsewhere so that they can be eventually freed. If inflateGetHeader is not used, then the header information is simply discarded. The header is always checked for validity, including the header CRC if present. inflateReset() will reset the process to discard the header information. The application would need to call inflateGetHeader() again to retrieve the header from the next gzip stream. inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ /* ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, unsigned char FAR *window)); Initialize the internal stream state for decompression using inflateBack() calls. The fields zalloc, zfree and opaque in strm must be initialized before the call. If zalloc and zfree are Z_NULL, then the default library- derived memory allocation routines are used. windowBits is the base two logarithm of the window size, in the range 8..15. window is a caller supplied buffer of that size. Except for special applications where it is assured that deflate was used with small window sizes, windowBits must be 15 and a 32K byte window must be supplied to be able to decompress general deflate streams. See inflateBack() for the usage of these routines. inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of the paramaters are invalid, Z_MEM_ERROR if the internal state could not be allocated, or Z_VERSION_ERROR if the version of the library does not match the version of the header file. */ typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, in_func in, void FAR *in_desc, out_func out, void FAR *out_desc)); /* inflateBack() does a raw inflate with a single call using a call-back interface for input and output. This is more efficient than inflate() for file i/o applications in that it avoids copying between the output and the sliding window by simply making the window itself the output buffer. This function trusts the application to not change the output buffer passed by the output function, at least until inflateBack() returns. inflateBackInit() must be called first to allocate the internal state and to initialize the state with the user-provided window buffer. inflateBack() may then be used multiple times to inflate a complete, raw deflate stream with each call. inflateBackEnd() is then called to free the allocated state. A raw deflate stream is one with no zlib or gzip header or trailer. This routine would normally be used in a utility that reads zip or gzip files and writes out uncompressed files. The utility would decode the header and process the trailer on its own, hence this routine expects only the raw deflate stream to decompress. This is different from the normal behavior of inflate(), which expects either a zlib or gzip header and trailer around the deflate stream. inflateBack() uses two subroutines supplied by the caller that are then called by inflateBack() for input and output. inflateBack() calls those routines until it reads a complete deflate stream and writes out all of the uncompressed data, or until it encounters an error. The function's parameters and return types are defined above in the in_func and out_func typedefs. inflateBack() will call in(in_desc, &buf) which should return the number of bytes of provided input, and a pointer to that input in buf. If there is no input available, in() must return zero--buf is ignored in that case--and inflateBack() will return a buffer error. inflateBack() will call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() should return zero on success, or non-zero on failure. If out() returns non-zero, inflateBack() will return with an error. Neither in() nor out() are permitted to change the contents of the window provided to inflateBackInit(), which is also the buffer that out() uses to write from. The length written by out() will be at most the window size. Any non-zero amount of input may be provided by in(). For convenience, inflateBack() can be provided input on the first call by setting strm->next_in and strm->avail_in. If that input is exhausted, then in() will be called. Therefore strm->next_in must be initialized before calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in must also be initialized, and then if strm->avail_in is not zero, input will initially be taken from strm->next_in[0 .. strm->avail_in - 1]. The in_desc and out_desc parameters of inflateBack() is passed as the first parameter of in() and out() respectively when they are called. These descriptors can be optionally used to pass any information that the caller- supplied in() and out() functions need to do their job. On return, inflateBack() will set strm->next_in and strm->avail_in to pass back any unused input that was provided by the last in() call. The return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR if in() or out() returned an error, Z_DATA_ERROR if there was a format error in the deflate stream (in which case strm->msg is set to indicate the nature of the error), or Z_STREAM_ERROR if the stream was not properly initialized. In the case of Z_BUF_ERROR, an input or output error can be distinguished using strm->next_in which will be Z_NULL only if in() returned an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to out() returning non-zero. (in() will always be called before out(), so strm->next_in is assured to be defined if out() returns non-zero.) Note that inflateBack() cannot return Z_OK. */ ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); /* All memory allocated by inflateBackInit() is freed. inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream state was inconsistent. */ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); /* Return flags indicating compile-time options. Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: 1.0: size of uInt 3.2: size of uLong 5.4: size of voidpf (pointer) 7.6: size of z_off_t Compiler, assembler, and debug options: 8: DEBUG 9: ASMV or ASMINF -- use ASM code 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention 11: 0 (reserved) One-time table building (smaller code, but not thread-safe if true): 12: BUILDFIXED -- build static block decoding tables when needed 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed 14,15: 0 (reserved) Library content (indicates missing functionality): 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking deflate code when not needed) 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect and decode gzip streams (to avoid linking crc code) 18-19: 0 (reserved) Operation variations (changes in library functionality): 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate 21: FASTEST -- deflate algorithm with only one, lowest compression level 22,23: 0 (reserved) The sprintf variant used by gzprintf (zero is best): 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! 26: 0 = returns value, 1 = void -- 1 means inferred string length returned Remainder: 27-31: 0 (reserved) */ /* 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 the value returned by compressBound(sourceLen). 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 the value returned by compressBound(sourceLen). 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 uLong ZEXPORT compressBound OF((uLong sourceLen)); /* compressBound() returns an upper bound on the compressed size after compress() or compress2() on sourceLen bytes. It would be used before a compress() or compress2() call to allocate the destination buffer. */ 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 or incomplete. */ 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", or 'R' for run-length encoding as in "wb1R". (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, voidpc 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). The number of uncompressed bytes written is limited to 4095. The caller should assure that this limit is not exceeded. If it is exceeded, then gzprintf() will return return an error (0) with nothing written. In this case, there may also be a buffer overflow with unpredictable consequences, which is possible only if zlib was compiled with the insecure functions sprintf() or vsprintf() because the secure snprintf() or vsnprintf() functions were not available. */ 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 gzungetc OF((int c, gzFile file)); /* Push one character back onto the stream to be read again later. Only one character of push-back is allowed. gzungetc() returns the character pushed, or -1 on failure. gzungetc() will fail if a character has been pushed but not read yet, or if c is -1. The pushed character will be discarded if the stream is repositioned with gzseek() or gzrewind(). */ 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 gzdirect OF((gzFile file)); /* Returns 1 if file is being read directly without decompression, 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. */ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); /* Clears the error and end-of-file flags for file. This is analogous to the clearerr() function in stdio. This is useful for continuing to read a gzip file that is being written concurrently. */ /* 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 adler32_combine OF((uLong adler1, uLong adler2, z_off_t len2)); /* Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. */ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); /* Update a running CRC-32 with the bytes buf[0..len-1] and return the updated CRC-32. If buf is NULL, this function returns the required initial value for the 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(); */ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); /* Combine two CRC-32 check values into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, CRC-32 check values were calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and len2. */ /* 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)); ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, unsigned char FAR *window, 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)) #define inflateBackInit(strm, windowBits, window) \ inflateBackInit_((strm), (windowBits), (window), \ ZLIB_VERSION, sizeof(z_stream)) #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) struct internal_state {int dummy;}; /* hack for buggy compilers */ #endif ZEXTERN const char * ZEXPORT zError OF((int)); ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); #ifdef __cplusplus } #endif #endif /* ZLIB_H */ sks-ecc-0.93/zlib/inffixed.h0000644000175000017500000001430710604550750014653 0ustar nachonacho /* inffixed.h -- table for decoding fixed codes * Generated automatically by makefixed(). */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ static const code lenfix[512] = { {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, {0,9,255} }; static const code distfix[32] = { {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, {22,5,193},{64,5,0} }; sks-ecc-0.93/zlib/uncompr.c0000644000175000017500000000404710604550750014535 0ustar nachonacho/* uncompr.c -- decompress a memory buffer * Copyright (C) 1995-2003 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #define ZLIB_INTERNAL #include "zlib.h" /* =========================================================================== 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. */ int ZEXPORT uncompress (dest, destLen, source, sourceLen) Bytef *dest; uLongf *destLen; const Bytef *source; uLong sourceLen; { z_stream stream; int err; stream.next_in = (Bytef*)source; stream.avail_in = (uInt)sourceLen; /* Check for source > 64K on 16-bit machine: */ if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; stream.next_out = dest; stream.avail_out = (uInt)*destLen; if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; stream.zalloc = (alloc_func)0; stream.zfree = (free_func)0; err = inflateInit(&stream); if (err != Z_OK) return err; err = inflate(&stream, Z_FINISH); if (err != Z_STREAM_END) { inflateEnd(&stream); if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) return Z_DATA_ERROR; return err; } *destLen = stream.total_out; err = inflateEnd(&stream); return err; } sks-ecc-0.93/zlib/FAQ0000644000175000017500000003535010604550750013241 0ustar nachonacho Frequently Asked Questions about zlib If your question is not there, please check the zlib home page http://www.zlib.org which may have more recent information. The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html 1. Is zlib Y2K-compliant? Yes. zlib doesn't handle dates. 2. Where can I get a Windows DLL version? The zlib sources can be compiled without change to produce a DLL. See the file win32/DLL_FAQ.txt in the zlib distribution. Pointers to the precompiled DLL are found in the zlib web site at http://www.zlib.org. 3. Where can I get a Visual Basic interface to zlib? See * http://www.dogma.net/markn/articles/zlibtool/zlibtool.htm * contrib/visual-basic.txt in the zlib distribution * win32/DLL_FAQ.txt in the zlib distribution 4. compress() returns Z_BUF_ERROR. Make sure that before the call of compress, the length of the compressed buffer is equal to the total size of the compressed buffer and not zero. For Visual Basic, check that this parameter is passed by reference ("as any"), not by value ("as long"). 5. deflate() or inflate() returns Z_BUF_ERROR. Before making the call, make sure that avail_in and avail_out are not zero. When setting the parameter flush equal to Z_FINISH, also make sure that avail_out is big enough to allow processing all pending input. Note that a Z_BUF_ERROR is not fatal--another call to deflate() or inflate() can be made with more input or output space. A Z_BUF_ERROR may in fact be unavoidable depending on how the functions are used, since it is not possible to tell whether or not there is more output pending when strm.avail_out returns with zero. 6. Where's the zlib documentation (man pages, etc.)? It's in zlib.h for the moment, and Francis S. Lin has converted it to a web page zlib.html. Volunteers to transform this to Unix-style man pages, please contact us (zlib@gzip.org). Examples of zlib usage are in the files example.c and minigzip.c. 7. Why don't you use GNU autoconf or libtool or ...? Because we would like to keep zlib as a very small and simple package. zlib is rather portable and doesn't need much configuration. 8. I found a bug in zlib. Most of the time, such problems are due to an incorrect usage of zlib. Please try to reproduce the problem with a small program and send the corresponding source to us at zlib@gzip.org . Do not send multi-megabyte data files without prior agreement. 9. Why do I get "undefined reference to gzputc"? If "make test" produces something like example.o(.text+0x154): undefined reference to `gzputc' check that you don't have old files libz.* in /usr/lib, /usr/local/lib or /usr/X11R6/lib. Remove any old versions, then do "make install". 10. I need a Delphi interface to zlib. See the contrib/delphi directory in the zlib distribution. 11. Can zlib handle .zip archives? Not by itself, no. See the directory contrib/minizip in the zlib distribution. 12. Can zlib handle .Z files? No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt the code of uncompress on your own. 13. How can I make a Unix shared library? make clean ./configure -s make 14. How do I install a shared zlib library on Unix? After the above, then: make install However, many flavors of Unix come with a shared zlib already installed. Before going to the trouble of compiling a shared version of zlib and trying to install it, you may want to check if it's already there! If you can #include , it's there. The -lz option will probably link to it. 15. I have a question about OttoPDF. We are not the authors of OttoPDF. The real author is on the OttoPDF web site: Joel Hainley, jhainley@myndkryme.com. 16. Can zlib decode Flate data in an Adobe PDF file? Yes. See http://www.fastio.com/ (ClibPDF), or http://www.pdflib.com/ . To modify PDF forms, see http://sourceforge.net/projects/acroformtool/ . 17. Why am I getting this "register_frame_info not found" error on Solaris? After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib generates an error such as: ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so: symbol __register_frame_info: referenced symbol not found The symbol __register_frame_info is not part of zlib, it is generated by the C compiler (cc or gcc). You must recompile applications using zlib which have this problem. This problem is specific to Solaris. See http://www.sunfreeware.com for Solaris versions of zlib and applications using zlib. 18. Why does gzip give an error on a file I make with compress/deflate? The compress and deflate functions produce data in the zlib format, which is different and incompatible with the gzip format. The gz* functions in zlib on the other hand use the gzip format. Both the zlib and gzip formats use the same compressed data format internally, but have different headers and trailers around the compressed data. 19. Ok, so why are there two different formats? The gzip format was designed to retain the directory information about a single file, such as the name and last modification date. The zlib format on the other hand was designed for in-memory and communication channel applications, and has a much more compact header and trailer and uses a faster integrity check than gzip. 20. Well that's nice, but how do I make a gzip file in memory? You can request that deflate write the gzip format instead of the zlib format using deflateInit2(). You can also request that inflate decode the gzip format using inflateInit2(). Read zlib.h for more details. 21. Is zlib thread-safe? Yes. However any library routines that zlib uses and any application- provided memory allocation routines must also be thread-safe. zlib's gz* functions use stdio library routines, and most of zlib's functions use the library memory allocation routines by default. zlib's Init functions allow for the application to provide custom memory allocation routines. Of course, you should only operate on any given zlib or gzip stream from a single thread at a time. 22. Can I use zlib in my commercial application? Yes. Please read the license in zlib.h. 23. Is zlib under the GNU license? No. Please read the license in zlib.h. 24. The license says that altered source versions must be "plainly marked". So what exactly do I need to do to meet that requirement? You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In particular, the final version number needs to be changed to "f", and an identification string should be appended to ZLIB_VERSION. Version numbers x.x.x.f are reserved for modifications to zlib by others than the zlib maintainers. For example, if the version of the base zlib you are altering is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also update the version strings in deflate.c and inftrees.c. For altered source distributions, you should also note the origin and nature of the changes in zlib.h, as well as in ChangeLog and README, along with the dates of the alterations. The origin should include at least your name (or your company's name), and an email address to contact for help or issues with the library. Note that distributing a compiled zlib library along with zlib.h and zconf.h is also a source distribution, and so you should change ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes in zlib.h as you would for a full source distribution. 25. Will zlib work on a big-endian or little-endian architecture, and can I exchange compressed data between them? Yes and yes. 26. Will zlib work on a 64-bit machine? It should. It has been tested on 64-bit machines, and has no dependence on any data types being limited to 32-bits in length. If you have any difficulties, please provide a complete problem report to zlib@gzip.org 27. Will zlib decompress data from the PKWare Data Compression Library? No. The PKWare DCL uses a completely different compressed data format than does PKZIP and zlib. However, you can look in zlib's contrib/blast directory for a possible solution to your problem. 28. Can I access data randomly in a compressed stream? No, not without some preparation. If when compressing you periodically use Z_FULL_FLUSH, carefully write all the pending data at those points, and keep an index of those locations, then you can start decompression at those points. You have to be careful to not use Z_FULL_FLUSH too often, since it can significantly degrade compression. 29. Does zlib work on MVS, OS/390, CICS, etc.? We don't know for sure. We have heard occasional reports of success on these systems. If you do use it on one of these, please provide us with a report, instructions, and patches that we can reference when we get these questions. Thanks. 30. Is there some simpler, easier to read version of inflate I can look at to understand the deflate format? First off, you should read RFC 1951. Second, yes. Look in zlib's contrib/puff directory. 31. Does zlib infringe on any patents? As far as we know, no. In fact, that was originally the whole point behind zlib. Look here for some more information: http://www.gzip.org/#faq11 32. Can zlib work with greater than 4 GB of data? Yes. inflate() and deflate() will process any amount of data correctly. Each call of inflate() or deflate() is limited to input and output chunks of the maximum value that can be stored in the compiler's "unsigned int" type, but there is no limit to the number of chunks. Note however that the strm.total_in and strm_total_out counters may be limited to 4 GB. These counters are provided as a convenience and are not used internally by inflate() or deflate(). The application can easily set up its own counters updated after each call of inflate() or deflate() to count beyond 4 GB. compress() and uncompress() may be limited to 4 GB, since they operate in a single call. gzseek() and gztell() may be limited to 4 GB depending on how zlib is compiled. See the zlibCompileFlags() function in zlib.h. The word "may" appears several times above since there is a 4 GB limit only if the compiler's "long" type is 32 bits. If the compiler's "long" type is 64 bits, then the limit is 16 exabytes. 33. Does zlib have any security vulnerabilities? The only one that we are aware of is potentially in gzprintf(). If zlib is compiled to use sprintf() or vsprintf(), then there is no protection against a buffer overflow of a 4K string space, other than the caller of gzprintf() assuring that the output will not exceed 4K. On the other hand, if zlib is compiled to use snprintf() or vsnprintf(), which should normally be the case, then there is no vulnerability. The ./configure script will display warnings if an insecure variation of sprintf() will be used by gzprintf(). Also the zlibCompileFlags() function will return information on what variant of sprintf() is used by gzprintf(). If you don't have snprintf() or vsnprintf() and would like one, you can find a portable implementation here: http://www.ijs.si/software/snprintf/ Note that you should be using the most recent version of zlib. Versions 1.1.3 and before were subject to a double-free vulnerability. 34. Is there a Java version of zlib? Probably what you want is to use zlib in Java. zlib is already included as part of the Java SDK in the java.util.zip package. If you really want a version of zlib written in the Java language, look on the zlib home page for links: http://www.zlib.org/ 35. I get this or that compiler or source-code scanner warning when I crank it up to maximally-pedantic. Can't you guys write proper code? Many years ago, we gave up attempting to avoid warnings on every compiler in the universe. It just got to be a waste of time, and some compilers were downright silly. So now, we simply make sure that the code always works. 36. Valgrind (or some similar memory access checker) says that deflate is performing a conditional jump that depends on an uninitialized value. Isn't that a bug? No. That is intentional for performance reasons, and the output of deflate is not affected. This only started showing up recently since zlib 1.2.x uses malloc() by default for allocations, whereas earlier versions used calloc(), which zeros out the allocated memory. 37. Will zlib read the (insert any ancient or arcane format here) compressed data format? Probably not. Look in the comp.compression FAQ for pointers to various formats and associated software. 38. How can I encrypt/decrypt zip files with zlib? zlib doesn't support encryption. The original PKZIP encryption is very weak and can be broken with freely available programs. To get strong encryption, use GnuPG, http://www.gnupg.org/ , which already includes zlib compression. For PKZIP compatible "encryption", look at http://www.info-zip.org/ 39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings? "gzip" is the gzip format, and "deflate" is the zlib format. They should probably have called the second one "zlib" instead to avoid confusion with the raw deflate compressed data format. While the HTTP 1.1 RFC 2616 correctly points to the zlib specification in RFC 1950 for the "deflate" transfer encoding, there have been reports of servers and browsers that incorrectly produce or expect raw deflate data per the deflate specficiation in RFC 1951, most notably Microsoft. So even though the "deflate" transfer encoding using the zlib format would be the more efficient approach (and in fact exactly what the zlib format was designed for), using the "gzip" transfer encoding is probably more reliable due to an unfortunate choice of name on the part of the HTTP 1.1 authors. Bottom line: use the gzip format for HTTP 1.1 encoding. 40. Does zlib support the new "Deflate64" format introduced by PKWare? No. PKWare has apparently decided to keep that format proprietary, since they have not documented it as they have previous compression formats. In any case, the compression improvements are so modest compared to other more modern approaches, that it's not worth the effort to implement. 41. Can you please sign these lengthy legal documents and fax them back to us so that we can use your software in our product? No. Go away. Shoo. sks-ecc-0.93/zlib/make_vms.com0000600000175000017500000003166210604550750015203 0ustar nachonacho$! make libz under VMS written by $! Martin P.J. Zinser $! $! $ on error then goto err_exit $! $! $! Just some general constants... $! $ true = 1 $ false = 0 $ tmpnam = "temp_" + f$getjpi("","pid") $ SAY = "WRITE SYS$OUTPUT" $! $! Setup variables holding "config" information $! $ Make = "" $ name = "Zlib" $ version = "?.?.?" $ v_string = "ZLIB_VERSION" $ v_file = "zlib.h" $ ccopt = "" $ lopts = "" $ linkonly = false $ optfile = name + ".opt" $ its_decc = false $ its_vaxc = false $ its_gnuc = false $ axp = f$getsyi("HW_MODEL").ge.1024 $ s_case = false $! Check for MMK/MMS $! $ If F$Search ("Sys$System:MMS.EXE") .nes. "" Then Make = "MMS" $ If F$Type (MMK) .eqs. "STRING" Then Make = "MMK" $! $! $ gosub find_version $! $ gosub check_opts $! $! Look for the compiler used $! $ gosub check_compiler $ if its_decc $ then $ ccopt = "/prefix=all" + ccopt $ if f$trnlnm("SYS") .eqs. "" $ then $ if axp $ then $ define sys sys$library: $ else $ ccopt = "/decc" + ccopt $ define sys decc$library_include: $ endif $ endif $ endif $ if its_vaxc .or. its_gnuc $ then $ if f$trnlnm("SYS").eqs."" then define sys sys$library: $ endif $! $! Build the thing plain or with mms $! $ write sys$output "Compiling Zlib sources ..." $ if make.eqs."" $ then $ dele example.obj;*,minigzip.obj;* $ CALL MAKE adler32.OBJ "CC ''CCOPT' adler32" - adler32.c zlib.h zconf.h $ CALL MAKE compress.OBJ "CC ''CCOPT' compress" - compress.c zlib.h zconf.h $ CALL MAKE crc32.OBJ "CC ''CCOPT' crc32" - crc32.c zlib.h zconf.h $ CALL MAKE deflate.OBJ "CC ''CCOPT' deflate" - deflate.c deflate.h zutil.h zlib.h zconf.h $ CALL MAKE gzio.OBJ "CC ''CCOPT' gzio" - gzio.c zutil.h zlib.h zconf.h $ CALL MAKE infback.OBJ "CC ''CCOPT' infback" - infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h $ CALL MAKE inffast.OBJ "CC ''CCOPT' inffast" - inffast.c zutil.h zlib.h zconf.h inffast.h $ CALL MAKE inflate.OBJ "CC ''CCOPT' inflate" - inflate.c zutil.h zlib.h zconf.h infblock.h $ CALL MAKE inftrees.OBJ "CC ''CCOPT' inftrees" - inftrees.c zutil.h zlib.h zconf.h inftrees.h $ CALL MAKE trees.OBJ "CC ''CCOPT' trees" - trees.c deflate.h zutil.h zlib.h zconf.h $ CALL MAKE uncompr.OBJ "CC ''CCOPT' uncompr" - uncompr.c zlib.h zconf.h $ CALL MAKE zutil.OBJ "CC ''CCOPT' zutil" - zutil.c zutil.h zlib.h zconf.h $ write sys$output "Building Zlib ..." $ CALL MAKE libz.OLB "lib/crea libz.olb *.obj" *.OBJ $ write sys$output "Building example..." $ CALL MAKE example.OBJ "CC ''CCOPT' example" - example.c zlib.h zconf.h $ call make example.exe "LINK example,libz.olb/lib" example.obj libz.olb $ if f$search("x11vms:xvmsutils.olb") .nes. "" $ then $ write sys$output "Building minigzip..." $ CALL MAKE minigzip.OBJ "CC ''CCOPT' minigzip" - minigzip.c zlib.h zconf.h $ call make minigzip.exe - "LINK minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib" - minigzip.obj libz.olb $ endif $ else $ gosub crea_mms $ SAY "Make ''name' ''version' with ''Make' " $ 'make' $ endif $! $! Alpha gets a shareable image $! $ If axp $ Then $ gosub crea_olist $ write sys$output "Creating libzshr.exe" $ call anal_obj_axp modules.opt _link.opt $ if s_case $ then $ open/append optf modules.opt $ write optf "case_sensitive=YES" $ close optf $ endif $ LINK_'lopts'/SHARE=libzshr.exe modules.opt/opt,_link.opt/opt $ endif $ write sys$output "Zlib build completed" $ exit $CC_ERR: $ write sys$output "C compiler required to build ''name'" $ goto err_exit $ERR_EXIT: $ set message/facil/ident/sever/text $ write sys$output "Exiting..." $ exit 2 $! $! $MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES $ V = 'F$Verify(0) $! P1 = What we are trying to make $! P2 = Command to make it $! P3 - P8 What it depends on $ $ If F$Search(P1) .Eqs. "" Then Goto Makeit $ Time = F$CvTime(F$File(P1,"RDT")) $arg=3 $Loop: $ Argument = P'arg $ If Argument .Eqs. "" Then Goto Exit $ El=0 $Loop2: $ File = F$Element(El," ",Argument) $ If File .Eqs. " " Then Goto Endl $ AFile = "" $Loop3: $ OFile = AFile $ AFile = F$Search(File) $ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl $ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit $ Goto Loop3 $NextEL: $ El = El + 1 $ Goto Loop2 $EndL: $ arg=arg+1 $ If arg .Le. 8 Then Goto Loop $ Goto Exit $ $Makeit: $ VV=F$VERIFY(0) $ write sys$output P2 $ 'P2 $ VV='F$Verify(VV) $Exit: $ If V Then Set Verify $ENDSUBROUTINE $!------------------------------------------------------------------------------ $! $! Check command line options and set symbols accordingly $! $ CHECK_OPTS: $ i = 1 $ OPT_LOOP: $ if i .lt. 9 $ then $ cparm = f$edit(p'i',"upcase") $ if cparm .eqs. "DEBUG" $ then $ ccopt = ccopt + "/noopt/deb" $ lopts = lopts + "/deb" $ endif $ if f$locate("CCOPT=",cparm) .lt. f$length(cparm) $ then $ start = f$locate("=",cparm) + 1 $ len = f$length(cparm) - start $ ccopt = ccopt + f$extract(start,len,cparm) $ if f$locate("AS_IS",f$edit(ccopt,"UPCASE")) .lt. f$length(ccopt) - then s_case = true $ endif $ if cparm .eqs. "LINK" then linkonly = true $ if f$locate("LOPTS=",cparm) .lt. f$length(cparm) $ then $ start = f$locate("=",cparm) + 1 $ len = f$length(cparm) - start $ lopts = lopts + f$extract(start,len,cparm) $ endif $ if f$locate("CC=",cparm) .lt. f$length(cparm) $ then $ start = f$locate("=",cparm) + 1 $ len = f$length(cparm) - start $ cc_com = f$extract(start,len,cparm) if (cc_com .nes. "DECC") .and. - (cc_com .nes. "VAXC") .and. - (cc_com .nes. "GNUC") $ then $ write sys$output "Unsupported compiler choice ''cc_com' ignored" $ write sys$output "Use DECC, VAXC, or GNUC instead" $ else $ if cc_com .eqs. "DECC" then its_decc = true $ if cc_com .eqs. "VAXC" then its_vaxc = true $ if cc_com .eqs. "GNUC" then its_gnuc = true $ endif $ endif $ if f$locate("MAKE=",cparm) .lt. f$length(cparm) $ then $ start = f$locate("=",cparm) + 1 $ len = f$length(cparm) - start $ mmks = f$extract(start,len,cparm) $ if (mmks .eqs. "MMK") .or. (mmks .eqs. "MMS") $ then $ make = mmks $ else $ write sys$output "Unsupported make choice ''mmks' ignored" $ write sys$output "Use MMK or MMS instead" $ endif $ endif $ i = i + 1 $ goto opt_loop $ endif $ return $!------------------------------------------------------------------------------ $! $! Look for the compiler used $! $CHECK_COMPILER: $ if (.not. (its_decc .or. its_vaxc .or. its_gnuc)) $ then $ its_decc = (f$search("SYS$SYSTEM:DECC$COMPILER.EXE") .nes. "") $ its_vaxc = .not. its_decc .and. (F$Search("SYS$System:VAXC.Exe") .nes. "") $ its_gnuc = .not. (its_decc .or. its_vaxc) .and. (f$trnlnm("gnu_cc") .nes. "") $ endif $! $! Exit if no compiler available $! $ if (.not. (its_decc .or. its_vaxc .or. its_gnuc)) $ then goto CC_ERR $ else $ if its_decc then write sys$output "CC compiler check ... Compaq C" $ if its_vaxc then write sys$output "CC compiler check ... VAX C" $ if its_gnuc then write sys$output "CC compiler check ... GNU C" $ endif $ return $!------------------------------------------------------------------------------ $! $! If MMS/MMK are available dump out the descrip.mms if required $! $CREA_MMS: $ write sys$output "Creating descrip.mms..." $ create descrip.mms $ open/append out descrip.mms $ copy sys$input: out $ deck # descrip.mms: MMS description file for building zlib on VMS # written by Martin P.J. Zinser # OBJS = adler32.obj, compress.obj, crc32.obj, gzio.obj, uncompr.obj, infback.obj\ deflate.obj, trees.obj, zutil.obj, inflate.obj, \ inftrees.obj, inffast.obj $ eod $ write out "CFLAGS=", ccopt $ write out "LOPTS=", lopts $ copy sys$input: out $ deck all : example.exe minigzip.exe libz.olb @ write sys$output " Example applications available" libz.olb : libz.olb($(OBJS)) @ write sys$output " libz available" example.exe : example.obj libz.olb link $(LOPTS) example,libz.olb/lib minigzip.exe : minigzip.obj libz.olb link $(LOPTS) minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib clean : delete *.obj;*,libz.olb;*,*.opt;*,*.exe;* # Other dependencies. adler32.obj : adler32.c zutil.h zlib.h zconf.h compress.obj : compress.c zlib.h zconf.h crc32.obj : crc32.c zutil.h zlib.h zconf.h deflate.obj : deflate.c deflate.h zutil.h zlib.h zconf.h example.obj : example.c zlib.h zconf.h gzio.obj : gzio.c zutil.h zlib.h zconf.h inffast.obj : inffast.c zutil.h zlib.h zconf.h inftrees.h inffast.h inflate.obj : inflate.c zutil.h zlib.h zconf.h inftrees.obj : inftrees.c zutil.h zlib.h zconf.h inftrees.h minigzip.obj : minigzip.c zlib.h zconf.h trees.obj : trees.c deflate.h zutil.h zlib.h zconf.h uncompr.obj : uncompr.c zlib.h zconf.h zutil.obj : zutil.c zutil.h zlib.h zconf.h infback.obj : infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h $ eod $ close out $ return $!------------------------------------------------------------------------------ $! $! Read list of core library sources from makefile.in and create options $! needed to build shareable image $! $CREA_OLIST: $ open/read min makefile.in $ open/write mod modules.opt $ src_check = "OBJS =" $MRLOOP: $ read/end=mrdone min rec $ if (f$extract(0,6,rec) .nes. src_check) then goto mrloop $ rec = rec - src_check $ gosub extra_filnam $ if (f$element(1,"\",rec) .eqs. "\") then goto mrdone $MRSLOOP: $ read/end=mrdone min rec $ gosub extra_filnam $ if (f$element(1,"\",rec) .nes. "\") then goto mrsloop $MRDONE: $ close min $ close mod $ return $!------------------------------------------------------------------------------ $! $! Take record extracted in crea_olist and split it into single filenames $! $EXTRA_FILNAM: $ myrec = f$edit(rec - "\", "trim,compress") $ i = 0 $FELOOP: $ srcfil = f$element(i," ", myrec) $ if (srcfil .nes. " ") $ then $ write mod f$parse(srcfil,,,"NAME"), ".obj" $ i = i + 1 $ goto feloop $ endif $ return $!------------------------------------------------------------------------------ $! $! Find current Zlib version number $! $FIND_VERSION: $ open/read h_in 'v_file' $hloop: $ read/end=hdone h_in rec $ rec = f$edit(rec,"TRIM") $ if (f$extract(0,1,rec) .nes. "#") then goto hloop $ rec = f$edit(rec - "#", "TRIM") $ if f$element(0," ",rec) .nes. "define" then goto hloop $ if f$element(1," ",rec) .eqs. v_string $ then $ version = 'f$element(2," ",rec)' $ goto hdone $ endif $ goto hloop $hdone: $ close h_in $ return $!------------------------------------------------------------------------------ $! $! Analyze Object files for OpenVMS AXP to extract Procedure and Data $! information to build a symbol vector for a shareable image $! All the "brains" of this logic was suggested by Hartmut Becker $! (Hartmut.Becker@compaq.com). All the bugs were introduced by me $! (zinser@decus.de), so if you do have problem reports please do not $! bother Hartmut/HP, but get in touch with me $! $ ANAL_OBJ_AXP: Subroutine $ V = 'F$Verify(0) $ SAY := "WRITE_ SYS$OUTPUT" $ $ IF F$SEARCH("''P1'") .EQS. "" $ THEN $ SAY "ANAL_OBJ_AXP-E-NOSUCHFILE: Error, inputfile ''p1' not available" $ goto exit_aa $ ENDIF $ IF "''P2'" .EQS. "" $ THEN $ SAY "ANAL_OBJ_AXP: Error, no output file provided" $ goto exit_aa $ ENDIF $ $ open/read in 'p1 $ create a.tmp $ open/append atmp a.tmp $ loop: $ read/end=end_loop in line $ f= f$search(line) $ if f .eqs. "" $ then $ write sys$output "ANAL_OBJ_AXP-w-nosuchfile, ''line'" $ goto loop $ endif $ define/user sys$output nl: $ define/user sys$error nl: $ anal/obj/gsd 'f /out=x.tmp $ open/read xtmp x.tmp $ XLOOP: $ read/end=end_xloop xtmp xline $ xline = f$edit(xline,"compress") $ write atmp xline $ goto xloop $ END_XLOOP: $ close xtmp $ goto loop $ end_loop: $ close in $ close atmp $ if f$search("a.tmp") .eqs. "" - then $ exit $ ! all global definitions $ search a.tmp "symbol:","EGSY$V_DEF 1","EGSY$V_NORM 1"/out=b.tmp $ ! all procedures $ search b.tmp "EGSY$V_NORM 1"/wind=(0,1) /out=c.tmp $ search c.tmp "symbol:"/out=d.tmp $ define/user sys$output nl: $ edito/edt/command=sys$input d.tmp sub/symbol: "/symbol_vector=(/whole sub/"/=PROCEDURE)/whole exit $ ! all data $ search b.tmp "EGSY$V_DEF 1"/wind=(0,1) /out=e.tmp $ search e.tmp "symbol:"/out=f.tmp $ define/user sys$output nl: $ edito/edt/command=sys$input f.tmp sub/symbol: "/symbol_vector=(/whole sub/"/=DATA)/whole exit $ sort/nodupl d.tmp,f.tmp 'p2' $ delete a.tmp;*,b.tmp;*,c.tmp;*,d.tmp;*,e.tmp;*,f.tmp;* $ if f$search("x.tmp") .nes. "" - then $ delete x.tmp;* $! $ EXIT_AA: $ if V then set verify $ endsubroutine $!------------------------------------------------------------------------------ sks-ecc-0.93/zlib/inftrees.c0000644000175000017500000003267410604550750014700 0ustar nachonacho/* inftrees.c -- generate Huffman trees for efficient decoding * Copyright (C) 1995-2005 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "zutil.h" #include "inftrees.h" #define MAXBITS 15 const char inflate_copyright[] = " inflate 1.2.3 Copyright 1995-2005 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot include such an acknowledgment, I would appreciate that you keep this copyright string in the executable of your product. */ /* Build a set of tables to decode the provided canonical Huffman code. The code lengths are lens[0..codes-1]. The result starts at *table, whose indices are 0..2^bits-1. work is a writable array of at least lens shorts, which is used as a work area. type is the type of code to be generated, CODES, LENS, or DISTS. On return, zero is success, -1 is an invalid code, and +1 means that ENOUGH isn't enough. table on return points to the next available entry's address. bits is the requested root table index bits, and on return it is the actual root table index bits. It will differ if the request is greater than the longest code or if it is less than the shortest code. */ int inflate_table(type, lens, codes, table, bits, work) codetype type; unsigned short FAR *lens; unsigned codes; code FAR * FAR *table; unsigned FAR *bits; unsigned short FAR *work; { unsigned len; /* a code's length in bits */ unsigned sym; /* index of code symbols */ unsigned min, max; /* minimum and maximum code lengths */ unsigned root; /* number of index bits for root table */ unsigned curr; /* number of index bits for current table */ unsigned drop; /* code bits to drop for sub-table */ int left; /* number of prefix codes available */ unsigned used; /* code entries in table used */ unsigned huff; /* Huffman code */ unsigned incr; /* for incrementing code, index */ unsigned fill; /* index for replicating entries */ unsigned low; /* low bits for current root entry */ unsigned mask; /* mask for low root bits */ code this; /* table entry for duplication */ code FAR *next; /* next available space in table */ const unsigned short FAR *base; /* base value table to use */ const unsigned short FAR *extra; /* extra bits table to use */ int end; /* use base and extra for symbol > end */ unsigned short count[MAXBITS+1]; /* number of codes of each length */ unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ static const unsigned short lbase[31] = { /* Length codes 257..285 base */ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196}; static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0}; static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64}; /* Process a set of code lengths to create a canonical Huffman code. The code lengths are lens[0..codes-1]. Each length corresponds to the symbols 0..codes-1. The Huffman code is generated by first sorting the symbols by length from short to long, and retaining the symbol order for codes with equal lengths. Then the code starts with all zero bits for the first code of the shortest length, and the codes are integer increments for the same length, and zeros are appended as the length increases. For the deflate format, these bits are stored backwards from their more natural integer increment ordering, and so when the decoding tables are built in the large loop below, the integer codes are incremented backwards. This routine assumes, but does not check, that all of the entries in lens[] are in the range 0..MAXBITS. The caller must assure this. 1..MAXBITS is interpreted as that code length. zero means that that symbol does not occur in this code. The codes are sorted by computing a count of codes for each length, creating from that a table of starting indices for each length in the sorted table, and then entering the symbols in order in the sorted table. The sorted table is work[], with that space being provided by the caller. The length counts are used for other purposes as well, i.e. finding the minimum and maximum length codes, determining if there are any codes at all, checking for a valid set of lengths, and looking ahead at length counts to determine sub-table sizes when building the decoding tables. */ /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ for (len = 0; len <= MAXBITS; len++) count[len] = 0; for (sym = 0; sym < codes; sym++) count[lens[sym]]++; /* bound code lengths, force root to be within code lengths */ root = *bits; for (max = MAXBITS; max >= 1; max--) if (count[max] != 0) break; if (root > max) root = max; if (max == 0) { /* no symbols to code at all */ this.op = (unsigned char)64; /* invalid code marker */ this.bits = (unsigned char)1; this.val = (unsigned short)0; *(*table)++ = this; /* make a table to force an error */ *(*table)++ = this; *bits = 1; return 0; /* no symbols, but wait for decoding to report error */ } for (min = 1; min <= MAXBITS; min++) if (count[min] != 0) break; if (root < min) root = min; /* check for an over-subscribed or incomplete set of lengths */ left = 1; for (len = 1; len <= MAXBITS; len++) { left <<= 1; left -= count[len]; if (left < 0) return -1; /* over-subscribed */ } if (left > 0 && (type == CODES || max != 1)) return -1; /* incomplete set */ /* generate offsets into symbol table for each length for sorting */ offs[1] = 0; for (len = 1; len < MAXBITS; len++) offs[len + 1] = offs[len] + count[len]; /* sort symbols by length, by symbol order within each length */ for (sym = 0; sym < codes; sym++) if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; /* Create and fill in decoding tables. In this loop, the table being filled is at next and has curr index bits. The code being used is huff with length len. That code is converted to an index by dropping drop bits off of the bottom. For codes where len is less than drop + curr, those top drop + curr - len bits are incremented through all values to fill the table with replicated entries. root is the number of index bits for the root table. When len exceeds root, sub-tables are created pointed to by the root entry with an index of the low root bits of huff. This is saved in low to check for when a new sub-table should be started. drop is zero when the root table is being filled, and drop is root when sub-tables are being filled. When a new sub-table is needed, it is necessary to look ahead in the code lengths to determine what size sub-table is needed. The length counts are used for this, and so count[] is decremented as codes are entered in the tables. used keeps track of how many table entries have been allocated from the provided *table space. It is checked when a LENS table is being made against the space in *table, ENOUGH, minus the maximum space needed by the worst case distance code, MAXD. This should never happen, but the sufficiency of ENOUGH has not been proven exhaustively, hence the check. This assumes that when type == LENS, bits == 9. sym increments through all symbols, and the loop terminates when all codes of length max, i.e. all codes, have been processed. This routine permits incomplete codes, so another loop after this one fills in the rest of the decoding tables with invalid code markers. */ /* set up for code type */ switch (type) { case CODES: base = extra = work; /* dummy value--not used */ end = 19; break; case LENS: base = lbase; base -= 257; extra = lext; extra -= 257; end = 256; break; default: /* DISTS */ base = dbase; extra = dext; end = -1; } /* initialize state for loop */ huff = 0; /* starting code */ sym = 0; /* starting code symbol */ len = min; /* starting code length */ next = *table; /* current table to fill in */ curr = root; /* current table index bits */ drop = 0; /* current bits to drop from code for index */ low = (unsigned)(-1); /* trigger new sub-table when len > root */ used = 1U << root; /* use root table entries */ mask = used - 1; /* mask for comparing low */ /* check available table space */ if (type == LENS && used >= ENOUGH - MAXD) return 1; /* process all codes and make table entries */ for (;;) { /* create table entry */ this.bits = (unsigned char)(len - drop); if ((int)(work[sym]) < end) { this.op = (unsigned char)0; this.val = work[sym]; } else if ((int)(work[sym]) > end) { this.op = (unsigned char)(extra[work[sym]]); this.val = base[work[sym]]; } else { this.op = (unsigned char)(32 + 64); /* end of block */ this.val = 0; } /* replicate for those indices with low len bits equal to huff */ incr = 1U << (len - drop); fill = 1U << curr; min = fill; /* save offset to next table */ do { fill -= incr; next[(huff >> drop) + fill] = this; } while (fill != 0); /* backwards increment the len-bit code huff */ incr = 1U << (len - 1); while (huff & incr) incr >>= 1; if (incr != 0) { huff &= incr - 1; huff += incr; } else huff = 0; /* go to next symbol, update count, len */ sym++; if (--(count[len]) == 0) { if (len == max) break; len = lens[work[sym]]; } /* create new sub-table if needed */ if (len > root && (huff & mask) != low) { /* if first time, transition to sub-tables */ if (drop == 0) drop = root; /* increment past last table */ next += min; /* here min is 1 << curr */ /* determine length of next table */ curr = len - drop; left = (int)(1 << curr); while (curr + drop < max) { left -= count[curr + drop]; if (left <= 0) break; curr++; left <<= 1; } /* check for enough space */ used += 1U << curr; if (type == LENS && used >= ENOUGH - MAXD) return 1; /* point entry in root table to sub-table */ low = huff & mask; (*table)[low].op = (unsigned char)curr; (*table)[low].bits = (unsigned char)root; (*table)[low].val = (unsigned short)(next - *table); } } /* Fill in rest of table for incomplete codes. This loop is similar to the loop above in incrementing huff for table indices. It is assumed that len is equal to curr + drop, so there is no loop needed to increment through high index bits. When the current sub-table is filled, the loop drops back to the root table to fill in any remaining entries there. */ this.op = (unsigned char)64; /* invalid code marker */ this.bits = (unsigned char)(len - drop); this.val = (unsigned short)0; while (huff != 0) { /* when done with sub-table, drop back to root table */ if (drop != 0 && (huff & mask) != low) { drop = 0; len = root; next = *table; this.bits = (unsigned char)len; } /* put invalid code marker in table */ next[huff >> drop] = this; /* backwards increment the len-bit code huff */ incr = 1U << (len - 1); while (huff & incr) incr >>= 1; if (incr != 0) { huff &= incr - 1; huff += incr; } else huff = 0; } /* set return parameters */ *table += used; *bits = root; return 0; } sks-ecc-0.93/zlib/projects/0000755000175000017500000000000010604550750014532 5ustar nachonachosks-ecc-0.93/zlib/projects/README.projects0000644000175000017500000000337210604550750017247 0ustar nachonachoThis directory contains project files for building zlib under various Integrated Development Environments (IDE). If you wish to submit a new project to this directory, you should comply to the following requirements. Otherwise (e.g. if you wish to integrate a custom piece of code that changes the zlib interface or its behavior), please consider submitting the project to the contrib directory. Requirements ============ - The project must build zlib using the source files from the official zlib source distribution, exclusively. - If the project produces redistributable builds (e.g. shared objects or DLL files), these builds must be compatible to those produced by makefiles, if such makefiles exist in the zlib distribution. In particular, if the project produces a DLL build for the Win32 platform, this build must comply to the officially-ammended Win32 DLL Application Binary Interface (ABI), described in win32/DLL_FAQ.txt. - The project may provide additional build targets, which depend on 3rd-party (unofficially-supported) software, present in the contrib directory. For example, it is possible to provide an "ASM build", besides the officially-supported build, and have ASM source files among its dependencies. - If there are significant differences between the project files created by different versions of an IDE (e.g. Visual C++ 6.0 vs. 7.0), the name of the project directory should contain the version number of the IDE for which the project is intended (e.g. "visualc6" for Visual C++ 6.0, or "visualc7" for Visual C++ 7.0 and 7.1). Current projects ================ visualc6/ by Simon-Pierre Cadieux and Cosmin Truta Project for Microsoft Visual C++ 6.0 sks-ecc-0.93/zlib/projects/visualc6/0000755000175000017500000000000010604550750016266 5ustar nachonachosks-ecc-0.93/zlib/projects/visualc6/example.dsp0000644000175000017500000002477610604550750020451 0ustar nachonacho# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=example - Win32 LIB 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 "example.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 "example.mak" CFG="example - Win32 LIB Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "example - Win32 DLL Release" (based on "Win32 (x86) Console Application") !MESSAGE "example - Win32 DLL Debug" (based on "Win32 (x86) Console Application") !MESSAGE "example - Win32 DLL ASM Release" (based on "Win32 (x86) Console Application") !MESSAGE "example - Win32 DLL ASM Debug" (based on "Win32 (x86) Console Application") !MESSAGE "example - Win32 LIB Release" (based on "Win32 (x86) Console Application") !MESSAGE "example - Win32 LIB Debug" (based on "Win32 (x86) Console Application") !MESSAGE "example - Win32 LIB ASM Release" (based on "Win32 (x86) Console Application") !MESSAGE "example - Win32 LIB ASM 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)" == "example - Win32 DLL Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "example___Win32_DLL_Release" # PROP BASE Intermediate_Dir "example___Win32_DLL_Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Win32_DLL_Release" # PROP Intermediate_Dir "Win32_DLL_Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT CPP /YX # 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 /nologo /subsystem:console /machine:I386 # ADD LINK32 /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "example - Win32 DLL Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "example___Win32_DLL_Debug" # PROP BASE Intermediate_Dir "example___Win32_DLL_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Win32_DLL_Debug" # PROP Intermediate_Dir "Win32_DLL_Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT CPP /YX # 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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 DLL ASM Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "example___Win32_DLL_ASM_Release" # PROP BASE Intermediate_Dir "example___Win32_DLL_ASM_Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Win32_DLL_ASM_Release" # PROP Intermediate_Dir "Win32_DLL_ASM_Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT CPP /YX # 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 /nologo /subsystem:console /machine:I386 # ADD LINK32 /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "example - Win32 DLL ASM Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "example___Win32_DLL_ASM_Debug" # PROP BASE Intermediate_Dir "example___Win32_DLL_ASM_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Win32_DLL_ASM_Debug" # PROP Intermediate_Dir "Win32_DLL_ASM_Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT CPP /YX # 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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 LIB Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "example___Win32_LIB_Release" # PROP BASE Intermediate_Dir "example___Win32_LIB_Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Win32_LIB_Release" # PROP Intermediate_Dir "Win32_LIB_Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT CPP /YX # 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 /nologo /subsystem:console /machine:I386 # ADD LINK32 /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "example - Win32 LIB Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "example___Win32_LIB_Debug" # PROP BASE Intermediate_Dir "example___Win32_LIB_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Win32_LIB_Debug" # PROP Intermediate_Dir "Win32_LIB_Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT CPP /YX # 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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ELSEIF "$(CFG)" == "example - Win32 LIB ASM Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "example___Win32_LIB_ASM_Release" # PROP BASE Intermediate_Dir "example___Win32_LIB_ASM_Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Win32_LIB_ASM_Release" # PROP Intermediate_Dir "Win32_LIB_ASM_Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT CPP /YX # 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 /nologo /subsystem:console /machine:I386 # ADD LINK32 /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "example - Win32 LIB ASM Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "example___Win32_LIB_ASM_Debug" # PROP BASE Intermediate_Dir "example___Win32_LIB_ASM_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Win32_LIB_ASM_Debug" # PROP Intermediate_Dir "Win32_LIB_ASM_Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT CPP /YX # 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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "example - Win32 DLL Release" # Name "example - Win32 DLL Debug" # Name "example - Win32 DLL ASM Release" # Name "example - Win32 DLL ASM Debug" # Name "example - Win32 LIB Release" # Name "example - Win32 LIB Debug" # Name "example - Win32 LIB ASM Release" # Name "example - Win32 LIB ASM Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\..\example.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\..\zconf.h # End Source File # Begin Source File SOURCE=..\..\zlib.h # End Source File # End Group # End Target # End Project sks-ecc-0.93/zlib/projects/visualc6/zlib.dsp0000644000175000017500000004172010604550750017742 0ustar nachonacho# Microsoft Developer Studio Project File - Name="zlib" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 # TARGTYPE "Win32 (x86) Static Library" 0x0104 CFG=zlib - Win32 LIB 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 "zlib.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 "zlib.mak" CFG="zlib - Win32 LIB Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "zlib - Win32 DLL Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "zlib - Win32 DLL Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "zlib - Win32 DLL ASM Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "zlib - Win32 DLL ASM Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "zlib - Win32 LIB Release" (based on "Win32 (x86) Static Library") !MESSAGE "zlib - Win32 LIB Debug" (based on "Win32 (x86) Static Library") !MESSAGE "zlib - Win32 LIB ASM Release" (based on "Win32 (x86) Static Library") !MESSAGE "zlib - Win32 LIB ASM Debug" (based on "Win32 (x86) Static Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" !IF "$(CFG)" == "zlib - Win32 DLL Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "zlib___Win32_DLL_Release" # PROP BASE Intermediate_Dir "zlib___Win32_DLL_Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Win32_DLL_Release" # PROP Intermediate_Dir "Win32_DLL_Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" CPP=cl.exe # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX /Yc /Yu # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT CPP /YX /Yc /Yu MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 RSC=rc.exe # 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 /nologo /dll /machine:I386 # ADD LINK32 /nologo /dll /machine:I386 /out:"Win32_DLL_Release\zlib1.dll" !ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "zlib___Win32_DLL_Debug" # PROP BASE Intermediate_Dir "zlib___Win32_DLL_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Win32_DLL_Debug" # PROP Intermediate_Dir "Win32_DLL_Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" CPP=cl.exe # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX /Yc /Yu # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT CPP /YX /Yc /Yu MTL=midl.exe # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 RSC=rc.exe # 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 /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 /nologo /dll /debug /machine:I386 /out:"Win32_DLL_Debug\zlib1d.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "zlib___Win32_DLL_ASM_Release" # PROP BASE Intermediate_Dir "zlib___Win32_DLL_ASM_Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Win32_DLL_ASM_Release" # PROP Intermediate_Dir "Win32_DLL_ASM_Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" CPP=cl.exe # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX /Yc /Yu # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "ASMV" /D "ASMINF" /FD /c # SUBTRACT CPP /YX /Yc /Yu MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 RSC=rc.exe # 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 /nologo /dll /machine:I386 # ADD LINK32 /nologo /dll /machine:I386 /out:"Win32_DLL_ASM_Release\zlib1.dll" !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "zlib___Win32_DLL_ASM_Debug" # PROP BASE Intermediate_Dir "zlib___Win32_DLL_ASM_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Win32_DLL_ASM_Debug" # PROP Intermediate_Dir "Win32_DLL_ASM_Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" CPP=cl.exe # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX /Yc /Yu # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "ASMV" /D "ASMINF" /FD /GZ /c # SUBTRACT CPP /YX /Yc /Yu MTL=midl.exe # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 RSC=rc.exe # 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 /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 /nologo /dll /debug /machine:I386 /out:"Win32_DLL_ASM_Debug\zlib1d.dll" /pdbtype:sept !ELSEIF "$(CFG)" == "zlib - Win32 LIB Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "zlib___Win32_LIB_Release" # PROP BASE Intermediate_Dir "zlib___Win32_LIB_Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Win32_LIB_Release" # PROP Intermediate_Dir "Win32_LIB_Release" # PROP Target_Dir "" CPP=cl.exe # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX /Yc /Yu # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT CPP /YX /Yc /Yu RSC=rc.exe # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "zlib___Win32_LIB_Debug" # PROP BASE Intermediate_Dir "zlib___Win32_LIB_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Win32_LIB_Debug" # PROP Intermediate_Dir "Win32_LIB_Debug" # PROP Target_Dir "" CPP=cl.exe # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX /Yc /Yu # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT CPP /YX /Yc /Yu RSC=rc.exe # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"Win32_LIB_Debug\zlibd.lib" !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "zlib___Win32_LIB_ASM_Release" # PROP BASE Intermediate_Dir "zlib___Win32_LIB_ASM_Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Win32_LIB_ASM_Release" # PROP Intermediate_Dir "Win32_LIB_ASM_Release" # PROP Target_Dir "" CPP=cl.exe # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX /Yc /Yu # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "ASMV" /D "ASMINF" /FD /c # SUBTRACT CPP /YX /Yc /Yu RSC=rc.exe # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "zlib___Win32_LIB_ASM_Debug" # PROP BASE Intermediate_Dir "zlib___Win32_LIB_ASM_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Win32_LIB_ASM_Debug" # PROP Intermediate_Dir "Win32_LIB_ASM_Debug" # PROP Target_Dir "" CPP=cl.exe # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX /Yc /Yu # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "ASMV" /D "ASMINF" /FD /GZ /c # SUBTRACT CPP /YX /Yc /Yu RSC=rc.exe # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"Win32_LIB_ASM_Debug\zlibd.lib" !ENDIF # Begin Target # Name "zlib - Win32 DLL Release" # Name "zlib - Win32 DLL Debug" # Name "zlib - Win32 DLL ASM Release" # Name "zlib - Win32 DLL ASM Debug" # Name "zlib - Win32 LIB Release" # Name "zlib - Win32 LIB Debug" # Name "zlib - Win32 LIB ASM Release" # Name "zlib - Win32 LIB ASM Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\..\adler32.c # End Source File # Begin Source File SOURCE=..\..\compress.c # End Source File # Begin Source File SOURCE=..\..\crc32.c # End Source File # Begin Source File SOURCE=..\..\deflate.c # End Source File # Begin Source File SOURCE=..\..\gzio.c # End Source File # Begin Source File SOURCE=..\..\infback.c # End Source File # Begin Source File SOURCE=..\..\inffast.c # End Source File # Begin Source File SOURCE=..\..\inflate.c # End Source File # Begin Source File SOURCE=..\..\inftrees.c # End Source File # Begin Source File SOURCE=..\..\trees.c # End Source File # Begin Source File SOURCE=..\..\uncompr.c # End Source File # Begin Source File SOURCE=..\..\win32\zlib.def !IF "$(CFG)" == "zlib - Win32 DLL Release" !ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug" !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release" !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug" !ELSEIF "$(CFG)" == "zlib - Win32 LIB Release" # PROP Exclude_From_Build 1 !ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug" # PROP Exclude_From_Build 1 !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release" # PROP Exclude_From_Build 1 !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug" # PROP Exclude_From_Build 1 !ENDIF # End Source File # Begin Source File SOURCE=..\..\zutil.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\..\crc32.h # End Source File # Begin Source File SOURCE=..\..\deflate.h # End Source File # Begin Source File SOURCE=..\..\inffast.h # End Source File # Begin Source File SOURCE=..\..\inffixed.h # End Source File # Begin Source File SOURCE=..\..\inflate.h # End Source File # Begin Source File SOURCE=..\..\inftrees.h # End Source File # Begin Source File SOURCE=..\..\trees.h # End Source File # Begin Source File SOURCE=..\..\zconf.h # End Source File # Begin Source File SOURCE=..\..\zlib.h # End Source File # Begin Source File SOURCE=..\..\zutil.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=..\..\win32\zlib1.rc # End Source File # End Group # Begin Group "Assembler Files (Unsupported)" # PROP Default_Filter "asm;obj;c;cpp;cxx;h;hpp;hxx" # Begin Source File SOURCE=..\..\contrib\masmx86\gvmat32.asm !IF "$(CFG)" == "zlib - Win32 DLL Release" # PROP Exclude_From_Build 1 !ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug" # PROP Exclude_From_Build 1 !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release" # Begin Custom Build - Assembling... IntDir=.\Win32_DLL_ASM_Release InputPath=..\..\contrib\masmx86\gvmat32.asm InputName=gvmat32 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" ml.exe /nologo /c /coff /Cx /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug" # Begin Custom Build - Assembling... IntDir=.\Win32_DLL_ASM_Debug InputPath=..\..\contrib\masmx86\gvmat32.asm InputName=gvmat32 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" ml.exe /nologo /c /coff /Cx /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "zlib - Win32 LIB Release" # PROP Exclude_From_Build 1 !ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug" # PROP Exclude_From_Build 1 !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release" # Begin Custom Build - Assembling... IntDir=.\Win32_LIB_ASM_Release InputPath=..\..\contrib\masmx86\gvmat32.asm InputName=gvmat32 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" ml.exe /nologo /c /coff /Cx /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug" # Begin Custom Build - Assembling... IntDir=.\Win32_LIB_ASM_Debug InputPath=..\..\contrib\masmx86\gvmat32.asm InputName=gvmat32 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" ml.exe /nologo /c /coff /Cx /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" # End Custom Build !ENDIF # End Source File # Begin Source File SOURCE=..\..\contrib\masmx86\gvmat32c.c !IF "$(CFG)" == "zlib - Win32 DLL Release" # PROP Exclude_From_Build 1 # ADD CPP /I "..\.." !ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug" # PROP Exclude_From_Build 1 # ADD CPP /I "..\.." !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release" # ADD CPP /I "..\.." !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug" # ADD CPP /I "..\.." !ELSEIF "$(CFG)" == "zlib - Win32 LIB Release" # PROP Exclude_From_Build 1 # ADD CPP /I "..\.." !ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug" # PROP Exclude_From_Build 1 # ADD CPP /I "..\.." !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release" # ADD CPP /I "..\.." !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug" # ADD CPP /I "..\.." !ENDIF # End Source File # Begin Source File SOURCE=..\..\contrib\masmx86\inffas32.asm !IF "$(CFG)" == "zlib - Win32 DLL Release" # PROP Exclude_From_Build 1 !ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug" # PROP Exclude_From_Build 1 !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release" # Begin Custom Build - Assembling... IntDir=.\Win32_DLL_ASM_Release InputPath=..\..\contrib\masmx86\inffas32.asm InputName=inffas32 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" ml.exe /nologo /c /coff /Cx /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug" # Begin Custom Build - Assembling... IntDir=.\Win32_DLL_ASM_Debug InputPath=..\..\contrib\masmx86\inffas32.asm InputName=inffas32 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" ml.exe /nologo /c /coff /Cx /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "zlib - Win32 LIB Release" # PROP Exclude_From_Build 1 !ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug" # PROP Exclude_From_Build 1 !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release" # Begin Custom Build - Assembling... IntDir=.\Win32_LIB_ASM_Release InputPath=..\..\contrib\masmx86\inffas32.asm InputName=inffas32 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" ml.exe /nologo /c /coff /Cx /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" # End Custom Build !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug" # Begin Custom Build - Assembling... IntDir=.\Win32_LIB_ASM_Debug InputPath=..\..\contrib\masmx86\inffas32.asm InputName=inffas32 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" ml.exe /nologo /c /coff /Cx /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" # End Custom Build !ENDIF # End Source File # End Group # Begin Source File SOURCE=.\README.txt # End Source File # End Target # End Project sks-ecc-0.93/zlib/projects/visualc6/README.txt0000644000175000017500000000471010604550750017766 0ustar nachonachoMicrosoft Developer Studio Project Files, Format Version 6.00 for zlib. Copyright (C) 2000-2004 Simon-Pierre Cadieux. Copyright (C) 2004 Cosmin Truta. For conditions of distribution and use, see copyright notice in zlib.h. This project builds the zlib binaries as follows: * Win32_DLL_Release\zlib1.dll DLL build * Win32_DLL_Debug\zlib1d.dll DLL build (debug version) * Win32_DLL_ASM_Release\zlib1.dll DLL build using ASM code * Win32_DLL_ASM_Debug\zlib1d.dll DLL build using ASM code (debug version) * Win32_LIB_Release\zlib.lib static build * Win32_LIB_Debug\zlibd.lib static build (debug version) * Win32_LIB_ASM_Release\zlib.lib static build using ASM code * Win32_LIB_ASM_Debug\zlibd.lib static build using ASM code (debug version) For more information regarding the DLL builds, please see the DLL FAQ in ..\..\win32\DLL_FAQ.txt. To build and test: 1) On the main menu, select "File | Open Workspace". Open "zlib.dsw". 2) Select "Build | Set Active Configuration". Choose the configuration you wish to build. 3) Select "Build | Clean". 4) Select "Build | Build ... (F7)". Ignore warning messages about not being able to find certain include files (e.g. alloc.h). 5) If you built one of the sample programs (example or minigzip), select "Build | Execute ... (Ctrl+F5)". To use: 1) Select "Project | Settings (Alt+F7)". Make note of the configuration names used in your project. Usually, these names are "Win32 Release" and "Win32 Debug". 2) In the Workspace window, select the "FileView" tab. Right-click on the root item "Workspace '...'". Select "Insert Project into Workspace". Switch on the checkbox "Dependency of:", and select the name of your project. Open "zlib.dsp". 3) Select "Build | Configurations". For each configuration of your project: 3.1) Choose the zlib configuration you wish to use. 3.2) Click on "Add". 3.3) Set the new zlib configuration name to the name used by the configuration from the current iteration. 4) Select "Build | Set Active Configuration". Choose the configuration you wish to build. 5) Select "Build | Build ... (F7)". 6) If you built an executable program, select "Build | Execute ... (Ctrl+F5)". Note: To build the ASM-enabled code, you need Microsoft Assembler (ML.EXE). You can get it by downloading and installing the latest Processor Pack for Visual C++ 6.0. sks-ecc-0.93/zlib/projects/visualc6/zlib.dsw0000644000175000017500000000207110604550750017745 0ustar nachonachoMicrosoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "example"=.\example.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ Begin Project Dependency Project_Dep_Name zlib End Project Dependency }}} ############################################################################### Project: "minigzip"=.\minigzip.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ Begin Project Dependency Project_Dep_Name zlib End Project Dependency }}} ############################################################################### Project: "zlib"=.\zlib.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### sks-ecc-0.93/zlib/projects/visualc6/minigzip.dsp0000644000175000017500000002505410604550750020632 0ustar nachonacho# Microsoft Developer Studio Project File - Name="minigzip" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=minigzip - Win32 LIB 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 "minigzip.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 "minigzip.mak" CFG="minigzip - Win32 LIB Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "minigzip - Win32 DLL Release" (based on "Win32 (x86) Console Application") !MESSAGE "minigzip - Win32 DLL Debug" (based on "Win32 (x86) Console Application") !MESSAGE "minigzip - Win32 DLL ASM Release" (based on "Win32 (x86) Console Application") !MESSAGE "minigzip - Win32 DLL ASM Debug" (based on "Win32 (x86) Console Application") !MESSAGE "minigzip - Win32 LIB Release" (based on "Win32 (x86) Console Application") !MESSAGE "minigzip - Win32 LIB Debug" (based on "Win32 (x86) Console Application") !MESSAGE "minigzip - Win32 LIB ASM Release" (based on "Win32 (x86) Console Application") !MESSAGE "minigzip - Win32 LIB ASM 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)" == "minigzip - Win32 DLL Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "minigzip___Win32_DLL_Release" # PROP BASE Intermediate_Dir "minigzip___Win32_DLL_Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Win32_DLL_Release" # PROP Intermediate_Dir "Win32_DLL_Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT CPP /YX # 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 /nologo /subsystem:console /machine:I386 # ADD LINK32 /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "minigzip - Win32 DLL Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "minigzip___Win32_DLL_Debug" # PROP BASE Intermediate_Dir "minigzip___Win32_DLL_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Win32_DLL_Debug" # PROP Intermediate_Dir "Win32_DLL_Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT CPP /YX # 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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ELSEIF "$(CFG)" == "minigzip - Win32 DLL ASM Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "minigzip___Win32_DLL_ASM_Release" # PROP BASE Intermediate_Dir "minigzip___Win32_DLL_ASM_Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Win32_DLL_ASM_Release" # PROP Intermediate_Dir "Win32_DLL_ASM_Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT CPP /YX # 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 /nologo /subsystem:console /machine:I386 # ADD LINK32 /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "minigzip - Win32 DLL ASM Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "minigzip___Win32_DLL_ASM_Debug" # PROP BASE Intermediate_Dir "minigzip___Win32_DLL_ASM_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Win32_DLL_ASM_Debug" # PROP Intermediate_Dir "Win32_DLL_ASM_Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT CPP /YX # 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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ELSEIF "$(CFG)" == "minigzip - Win32 LIB Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "minigzip___Win32_LIB_Release" # PROP BASE Intermediate_Dir "minigzip___Win32_LIB_Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Win32_LIB_Release" # PROP Intermediate_Dir "Win32_LIB_Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT CPP /YX # 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 /nologo /subsystem:console /machine:I386 # ADD LINK32 /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "minigzip - Win32 LIB Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "minigzip___Win32_LIB_Debug" # PROP BASE Intermediate_Dir "minigzip___Win32_LIB_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Win32_LIB_Debug" # PROP Intermediate_Dir "Win32_LIB_Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT CPP /YX # 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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ELSEIF "$(CFG)" == "minigzip - Win32 LIB ASM Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "minigzip___Win32_LIB_ASM_Release" # PROP BASE Intermediate_Dir "minigzip___Win32_LIB_ASM_Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Win32_LIB_ASM_Release" # PROP Intermediate_Dir "Win32_LIB_ASM_Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT BASE CPP /YX # ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /FD /c # SUBTRACT CPP /YX # 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 /nologo /subsystem:console /machine:I386 # ADD LINK32 /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "minigzip - Win32 LIB ASM Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "minigzip___Win32_LIB_ASM_Debug" # PROP BASE Intermediate_Dir "minigzip___Win32_LIB_ASM_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Win32_LIB_ASM_Debug" # PROP Intermediate_Dir "Win32_LIB_ASM_Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT BASE CPP /YX # ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c # SUBTRACT CPP /YX # 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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "minigzip - Win32 DLL Release" # Name "minigzip - Win32 DLL Debug" # Name "minigzip - Win32 DLL ASM Release" # Name "minigzip - Win32 DLL ASM Debug" # Name "minigzip - Win32 LIB Release" # Name "minigzip - Win32 LIB Debug" # Name "minigzip - Win32 LIB ASM Release" # Name "minigzip - Win32 LIB ASM Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\..\minigzip.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\..\zconf.h # End Source File # Begin Source File SOURCE=..\..\zlib.h # End Source File # End Group # End Target # End Project sks-ecc-0.93/zlib/deflate.h0000644000175000017500000002752210604550750014466 0ustar nachonacho/* deflate.h -- internal compression state * Copyright (C) 1995-2004 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ /* @(#) $Id$ */ #ifndef DEFLATE_H #define DEFLATE_H #include "zutil.h" /* define NO_GZIP when compiling if you want to disable gzip header and trailer creation by deflate(). NO_GZIP would be used to avoid linking in the crc code when it is not needed. For shared libraries, gzip encoding should be left enabled. */ #ifndef NO_GZIP # define GZIP #endif /* =========================================================================== * Internal compression state. */ #define LENGTH_CODES 29 /* number of length codes, not counting the special END_BLOCK code */ #define LITERALS 256 /* number of literal bytes 0..255 */ #define L_CODES (LITERALS+1+LENGTH_CODES) /* number of Literal or Length codes, including the END_BLOCK code */ #define D_CODES 30 /* number of distance codes */ #define BL_CODES 19 /* number of codes used to transfer the bit lengths */ #define HEAP_SIZE (2*L_CODES+1) /* maximum heap size */ #define MAX_BITS 15 /* All codes must not exceed MAX_BITS bits */ #define INIT_STATE 42 #define EXTRA_STATE 69 #define NAME_STATE 73 #define COMMENT_STATE 91 #define HCRC_STATE 103 #define BUSY_STATE 113 #define FINISH_STATE 666 /* Stream status */ /* Data structure describing a single value and its code string. */ typedef struct ct_data_s { union { ush freq; /* frequency count */ ush code; /* bit string */ } fc; union { ush dad; /* father node in Huffman tree */ ush len; /* length of bit string */ } dl; } FAR ct_data; #define Freq fc.freq #define Code fc.code #define Dad dl.dad #define Len dl.len typedef struct static_tree_desc_s static_tree_desc; typedef struct tree_desc_s { ct_data *dyn_tree; /* the dynamic tree */ int max_code; /* largest code with non zero frequency */ static_tree_desc *stat_desc; /* the corresponding static tree */ } FAR tree_desc; typedef ush Pos; typedef Pos FAR Posf; typedef unsigned IPos; /* A Pos is an index in the character window. We use short instead of int to * save space in the various tables. IPos is used only for parameter passing. */ typedef struct internal_state { z_streamp strm; /* pointer back to this zlib stream */ int status; /* as the name implies */ Bytef *pending_buf; /* output still pending */ ulg pending_buf_size; /* size of pending_buf */ Bytef *pending_out; /* next pending byte to output to the stream */ uInt pending; /* nb of bytes in the pending buffer */ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ gz_headerp gzhead; /* gzip header information to write */ uInt gzindex; /* where in extra, name, or comment */ Byte method; /* STORED (for zip only) or DEFLATED */ int last_flush; /* value of flush param for previous deflate call */ /* used by deflate.c: */ uInt w_size; /* LZ77 window size (32K by default) */ uInt w_bits; /* log2(w_size) (8..16) */ uInt w_mask; /* w_size - 1 */ Bytef *window; /* Sliding window. Input bytes are read into the second half of the window, * and move to the first half later to keep a dictionary of at least wSize * bytes. With this organization, matches are limited to a distance of * wSize-MAX_MATCH bytes, but this ensures that IO is always * performed with a length multiple of the block size. Also, it limits * the window size to 64K, which is quite useful on MSDOS. * To do: use the user input buffer as sliding window. */ ulg window_size; /* Actual size of window: 2*wSize, except when the user input buffer * is directly used as sliding window. */ Posf *prev; /* Link to older string with same hash index. To limit the size of this * array to 64K, this link is maintained only for the last 32K strings. * An index in this array is thus a window index modulo 32K. */ Posf *head; /* Heads of the hash chains or NIL. */ uInt ins_h; /* hash index of string to be inserted */ uInt hash_size; /* number of elements in hash table */ uInt hash_bits; /* log2(hash_size) */ uInt hash_mask; /* hash_size-1 */ uInt hash_shift; /* Number of bits by which ins_h must be shifted at each input * step. It must be such that after MIN_MATCH steps, the oldest * byte no longer takes part in the hash key, that is: * hash_shift * MIN_MATCH >= hash_bits */ long block_start; /* Window position at the beginning of the current output block. Gets * negative when the window is moved backwards. */ uInt match_length; /* length of best match */ IPos prev_match; /* previous match */ int match_available; /* set if previous match exists */ uInt strstart; /* start of string to insert */ uInt match_start; /* start of matching string */ uInt lookahead; /* number of valid bytes ahead in window */ uInt prev_length; /* Length of the best match at previous step. Matches not greater than this * are discarded. This is used in the lazy match evaluation. */ uInt max_chain_length; /* To speed up deflation, hash chains are never searched beyond this * length. A higher limit improves compression ratio but degrades the * speed. */ uInt max_lazy_match; /* Attempt to find a better match only when the current match is strictly * smaller than this value. This mechanism is used only for compression * levels >= 4. */ # define max_insert_length max_lazy_match /* Insert new strings in the hash table only if the match length is not * greater than this length. This saves time but degrades compression. * max_insert_length is used only for compression levels <= 3. */ int level; /* compression level (1..9) */ int strategy; /* favor or force Huffman coding*/ uInt good_match; /* Use a faster search when the previous match is longer than this */ int nice_match; /* Stop searching when current match exceeds this */ /* used by trees.c: */ /* Didn't use ct_data typedef below to supress compiler warning */ struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ struct tree_desc_s l_desc; /* desc. for literal tree */ struct tree_desc_s d_desc; /* desc. for distance tree */ struct tree_desc_s bl_desc; /* desc. for bit length tree */ ush bl_count[MAX_BITS+1]; /* number of codes at each bit length for an optimal tree */ int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ int heap_len; /* number of elements in the heap */ int heap_max; /* element of largest frequency */ /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. * The same heap array is used to build all trees. */ uch depth[2*L_CODES+1]; /* Depth of each subtree used as tie breaker for trees of equal frequency */ uchf *l_buf; /* buffer for literals or lengths */ uInt lit_bufsize; /* Size of match buffer for literals/lengths. There are 4 reasons for * limiting lit_bufsize to 64K: * - frequencies can be kept in 16 bit counters * - if compression is not successful for the first block, all input * data is still in the window so we can still emit a stored block even * when input comes from standard input. (This can also be done for * all blocks if lit_bufsize is not greater than 32K.) * - if compression is not successful for a file smaller than 64K, we can * even emit a stored file instead of a stored block (saving 5 bytes). * This is applicable only for zip (not gzip or zlib). * - creating new Huffman trees less frequently may not provide fast * adaptation to changes in the input data statistics. (Take for * example a binary file with poorly compressible code followed by * a highly compressible string table.) Smaller buffer sizes give * fast adaptation but have of course the overhead of transmitting * trees more frequently. * - I can't count above 4 */ uInt last_lit; /* running index in l_buf */ ushf *d_buf; /* Buffer for distances. To simplify the code, d_buf and l_buf have * the same number of elements. To use different lengths, an extra flag * array would be necessary. */ ulg opt_len; /* bit length of current block with optimal trees */ ulg static_len; /* bit length of current block with static trees */ uInt matches; /* number of string matches in current block */ int last_eob_len; /* bit length of EOB code for last block */ #ifdef DEBUG ulg compressed_len; /* total bit length of compressed file mod 2^32 */ ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ #endif ush bi_buf; /* Output buffer. bits are inserted starting at the bottom (least * significant bits). */ int bi_valid; /* Number of valid bits in bi_buf. All bits above the last valid bit * are always zero. */ } FAR deflate_state; /* Output a byte on the stream. * IN assertion: there is enough room in pending_buf. */ #define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) /* Minimum amount of lookahead, except at the end of the input file. * See deflate.c for comments about the MIN_MATCH+1. */ #define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) /* In order to simplify the code, particularly on 16 bit machines, match * distances are limited to MAX_DIST instead of WSIZE. */ /* in trees.c */ void _tr_init OF((deflate_state *s)); int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, int eof)); void _tr_align OF((deflate_state *s)); void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, int eof)); #define d_code(dist) \ ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) /* Mapping from a distance to a distance code. dist is the distance - 1 and * must not have side effects. _dist_code[256] and _dist_code[257] are never * used. */ #ifndef DEBUG /* Inline versions of _tr_tally for speed: */ #if defined(GEN_TREES_H) || !defined(STDC) extern uch _length_code[]; extern uch _dist_code[]; #else extern const uch _length_code[]; extern const uch _dist_code[]; #endif # define _tr_tally_lit(s, c, flush) \ { uch cc = (c); \ s->d_buf[s->last_lit] = 0; \ s->l_buf[s->last_lit++] = cc; \ s->dyn_ltree[cc].Freq++; \ flush = (s->last_lit == s->lit_bufsize-1); \ } # define _tr_tally_dist(s, distance, length, flush) \ { uch len = (length); \ ush dist = (distance); \ s->d_buf[s->last_lit] = dist; \ s->l_buf[s->last_lit++] = len; \ dist--; \ s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ s->dyn_dtree[d_code(dist)].Freq++; \ flush = (s->last_lit == s->lit_bufsize-1); \ } #else # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) # define _tr_tally_dist(s, distance, length, flush) \ flush = _tr_tally(s, distance, length) #endif #endif /* DEFLATE_H */ sks-ecc-0.93/zlib/inffast.c0000644000175000017500000003043010604550750014477 0ustar nachonacho/* inffast.c -- fast decoding * Copyright (C) 1995-2004 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "zutil.h" #include "inftrees.h" #include "inflate.h" #include "inffast.h" #ifndef ASMINF /* Allow machine dependent optimization for post-increment or pre-increment. Based on testing to date, Pre-increment preferred for: - PowerPC G3 (Adler) - MIPS R5000 (Randers-Pehrson) Post-increment preferred for: - none No measurable difference: - Pentium III (Anderson) - M68060 (Nikl) */ #ifdef POSTINC # define OFF 0 # define PUP(a) *(a)++ #else # define OFF 1 # define PUP(a) *++(a) #endif /* Decode literal, length, and distance codes and write out the resulting literal and match bytes until either not enough input or output is available, an end-of-block is encountered, or a data error is encountered. When large enough input and output buffers are supplied to inflate(), for example, a 16K input buffer and a 64K output buffer, more than 95% of the inflate execution time is spent in this routine. Entry assumptions: state->mode == LEN strm->avail_in >= 6 strm->avail_out >= 258 start >= strm->avail_out state->bits < 8 On return, state->mode is one of: LEN -- ran out of enough output space or enough available input TYPE -- reached end of block code, inflate() to interpret next block BAD -- error in block data Notes: - The maximum input bits used by a length/distance pair is 15 bits for the length code, 5 bits for the length extra, 15 bits for the distance code, and 13 bits for the distance extra. This totals 48 bits, or six bytes. Therefore if strm->avail_in >= 6, then there is enough input to avoid checking for available input while decoding. - The maximum bytes that a single length/distance pair can output is 258 bytes, which is the maximum length that can be coded. inflate_fast() requires strm->avail_out >= 258 for each loop to avoid checking for output space. */ void inflate_fast(strm, start) z_streamp strm; unsigned start; /* inflate()'s starting value for strm->avail_out */ { struct inflate_state FAR *state; unsigned char FAR *in; /* local strm->next_in */ unsigned char FAR *last; /* while in < last, enough input available */ unsigned char FAR *out; /* local strm->next_out */ unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ unsigned char FAR *end; /* while out < end, enough space available */ #ifdef INFLATE_STRICT unsigned dmax; /* maximum distance from zlib header */ #endif unsigned wsize; /* window size or zero if not using window */ unsigned whave; /* valid bytes in the window */ unsigned write; /* window write index */ unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ unsigned long hold; /* local strm->hold */ unsigned bits; /* local strm->bits */ code const FAR *lcode; /* local strm->lencode */ code const FAR *dcode; /* local strm->distcode */ unsigned lmask; /* mask for first level of length codes */ unsigned dmask; /* mask for first level of distance codes */ code this; /* retrieved table entry */ unsigned op; /* code bits, operation, extra bits, or */ /* window position, window bytes to copy */ unsigned len; /* match length, unused bytes */ unsigned dist; /* match distance */ unsigned char FAR *from; /* where to copy match from */ /* copy state to local variables */ state = (struct inflate_state FAR *)strm->state; in = strm->next_in - OFF; last = in + (strm->avail_in - 5); out = strm->next_out - OFF; beg = out - (start - strm->avail_out); end = out + (strm->avail_out - 257); #ifdef INFLATE_STRICT dmax = state->dmax; #endif wsize = state->wsize; whave = state->whave; write = state->write; window = state->window; hold = state->hold; bits = state->bits; lcode = state->lencode; dcode = state->distcode; lmask = (1U << state->lenbits) - 1; dmask = (1U << state->distbits) - 1; /* decode literals and length/distances until end-of-block or not enough input data or output space */ do { if (bits < 15) { hold += (unsigned long)(PUP(in)) << bits; bits += 8; hold += (unsigned long)(PUP(in)) << bits; bits += 8; } this = lcode[hold & lmask]; dolen: op = (unsigned)(this.bits); hold >>= op; bits -= op; op = (unsigned)(this.op); if (op == 0) { /* literal */ Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? "inflate: literal '%c'\n" : "inflate: literal 0x%02x\n", this.val)); PUP(out) = (unsigned char)(this.val); } else if (op & 16) { /* length base */ len = (unsigned)(this.val); op &= 15; /* number of extra bits */ if (op) { if (bits < op) { hold += (unsigned long)(PUP(in)) << bits; bits += 8; } len += (unsigned)hold & ((1U << op) - 1); hold >>= op; bits -= op; } Tracevv((stderr, "inflate: length %u\n", len)); if (bits < 15) { hold += (unsigned long)(PUP(in)) << bits; bits += 8; hold += (unsigned long)(PUP(in)) << bits; bits += 8; } this = dcode[hold & dmask]; dodist: op = (unsigned)(this.bits); hold >>= op; bits -= op; op = (unsigned)(this.op); if (op & 16) { /* distance base */ dist = (unsigned)(this.val); op &= 15; /* number of extra bits */ if (bits < op) { hold += (unsigned long)(PUP(in)) << bits; bits += 8; if (bits < op) { hold += (unsigned long)(PUP(in)) << bits; bits += 8; } } dist += (unsigned)hold & ((1U << op) - 1); #ifdef INFLATE_STRICT if (dist > dmax) { strm->msg = (char *)"invalid distance too far back"; state->mode = BAD; break; } #endif hold >>= op; bits -= op; Tracevv((stderr, "inflate: distance %u\n", dist)); op = (unsigned)(out - beg); /* max distance in output */ if (dist > op) { /* see if copy from window */ op = dist - op; /* distance back in window */ if (op > whave) { strm->msg = (char *)"invalid distance too far back"; state->mode = BAD; break; } from = window - OFF; if (write == 0) { /* very common case */ from += wsize - op; if (op < len) { /* some from window */ len -= op; do { PUP(out) = PUP(from); } while (--op); from = out - dist; /* rest from output */ } } else if (write < op) { /* wrap around window */ from += wsize + write - op; op -= write; if (op < len) { /* some from end of window */ len -= op; do { PUP(out) = PUP(from); } while (--op); from = window - OFF; if (write < len) { /* some from start of window */ op = write; len -= op; do { PUP(out) = PUP(from); } while (--op); from = out - dist; /* rest from output */ } } } else { /* contiguous in window */ from += write - op; if (op < len) { /* some from window */ len -= op; do { PUP(out) = PUP(from); } while (--op); from = out - dist; /* rest from output */ } } while (len > 2) { PUP(out) = PUP(from); PUP(out) = PUP(from); PUP(out) = PUP(from); len -= 3; } if (len) { PUP(out) = PUP(from); if (len > 1) PUP(out) = PUP(from); } } else { from = out - dist; /* copy direct from output */ do { /* minimum length is three */ PUP(out) = PUP(from); PUP(out) = PUP(from); PUP(out) = PUP(from); len -= 3; } while (len > 2); if (len) { PUP(out) = PUP(from); if (len > 1) PUP(out) = PUP(from); } } } else if ((op & 64) == 0) { /* 2nd level distance code */ this = dcode[this.val + (hold & ((1U << op) - 1))]; goto dodist; } else { strm->msg = (char *)"invalid distance code"; state->mode = BAD; break; } } else if ((op & 64) == 0) { /* 2nd level length code */ this = lcode[this.val + (hold & ((1U << op) - 1))]; goto dolen; } else if (op & 32) { /* end-of-block */ Tracevv((stderr, "inflate: end of block\n")); state->mode = TYPE; break; } else { strm->msg = (char *)"invalid literal/length code"; state->mode = BAD; break; } } while (in < last && out < end); /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ len = bits >> 3; in -= len; bits -= len << 3; hold &= (1U << bits) - 1; /* update state and return */ strm->next_in = in + OFF; strm->next_out = out + OFF; strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); strm->avail_out = (unsigned)(out < end ? 257 + (end - out) : 257 - (out - end)); state->hold = hold; state->bits = bits; return; } /* inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): - Using bit fields for code structure - Different op definition to avoid & for extra bits (do & for table bits) - Three separate decoding do-loops for direct, window, and write == 0 - Special case for distance > 1 copies to do overlapped load and store copy - Explicit branch predictions (based on measured branch probabilities) - Deferring match copy and interspersed it with decoding subsequent codes - Swapping literal/length else - Swapping window/direct else - Larger unrolled copy loops (three is about right) - Moving len -= 3 statement into middle of loop */ #endif /* !ASMINF */ sks-ecc-0.93/zlib/Makefile.in0000644000175000017500000001004510604550750014746 0ustar nachonacho# Makefile for zlib # Copyright (C) 1995-2005 Jean-loup Gailly. # For conditions of distribution and use, see copyright notice in zlib.h # To compile and test, type: # ./configure; make test # The call of configure is optional if you don't have special requirements # If you wish to build zlib as a shared library, use: ./configure -s # To use the asm code, type: # cp contrib/asm?86/match.S ./match.S # make LOC=-DASMV OBJA=match.o # To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: # make install # To install in $HOME instead of /usr/local, use: # make install prefix=$HOME CC=cc CFLAGS=-O #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 #CFLAGS=-g -DDEBUG #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ # -Wstrict-prototypes -Wmissing-prototypes LDFLAGS=libz.a LDSHARED=$(CC) CPP=$(CC) -E LIBS=libz.a SHAREDLIB=libz.so SHAREDLIBV=libz.so.1.2.3 SHAREDLIBM=libz.so.1 AR=ar rc RANLIB=ranlib TAR=tar SHELL=/bin/sh EXE= prefix = /usr/local exec_prefix = ${prefix} libdir = ${exec_prefix}/lib includedir = ${prefix}/include mandir = ${prefix}/share/man man3dir = ${mandir}/man3 OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ zutil.o inflate.o infback.o inftrees.o inffast.o OBJA = # to use the asm code: make OBJA=match.o TEST_OBJS = example.o minigzip.o all: example$(EXE) minigzip$(EXE) check: test test: all @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ echo hello world | ./minigzip | ./minigzip -d || \ echo ' *** minigzip test FAILED ***' ; \ if ./example; then \ echo ' *** zlib test OK ***'; \ else \ echo ' *** zlib test FAILED ***'; \ fi libz.a: $(OBJS) $(OBJA) $(AR) $@ $(OBJS) $(OBJA) -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 match.o: match.S $(CPP) match.S > _match.s $(CC) -c _match.s mv _match.o match.o rm -f _match.s $(SHAREDLIBV): $(OBJS) $(LDSHARED) -o $@ $(OBJS) rm -f $(SHAREDLIB) $(SHAREDLIBM) ln -s $@ $(SHAREDLIB) ln -s $@ $(SHAREDLIBM) example$(EXE): example.o $(LIBS) $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) minigzip$(EXE): minigzip.o $(LIBS) $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) install: $(LIBS) -@if [ ! -d $(exec_prefix) ]; then mkdir -p $(exec_prefix); fi -@if [ ! -d $(includedir) ]; then mkdir -p $(includedir); fi -@if [ ! -d $(libdir) ]; then mkdir -p $(libdir); fi -@if [ ! -d $(man3dir) ]; then mkdir -p $(man3dir); fi cp zlib.h zconf.h $(includedir) chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h cp $(LIBS) $(libdir) cd $(libdir); chmod 755 $(LIBS) -@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1 cd $(libdir); if test -f $(SHAREDLIBV); then \ rm -f $(SHAREDLIB) $(SHAREDLIBM); \ ln -s $(SHAREDLIBV) $(SHAREDLIB); \ ln -s $(SHAREDLIBV) $(SHAREDLIBM); \ (ldconfig || true) >/dev/null 2>&1; \ fi cp zlib.3 $(man3dir) chmod 644 $(man3dir)/zlib.3 # The ranlib in install is needed on NeXTSTEP which checks file times # ldconfig is for Linux uninstall: cd $(includedir); \ cd $(libdir); rm -f libz.a; \ if test -f $(SHAREDLIBV); then \ rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \ fi cd $(man3dir); rm -f zlib.3 mostlyclean: clean clean: rm -f *.o *~ example$(EXE) minigzip$(EXE) \ libz.* foo.gz so_locations \ _match.s maketree contrib/infback9/*.o maintainer-clean: distclean distclean: clean cp -p Makefile.in Makefile cp -p zconf.in.h zconf.h rm -f .DS_Store tags: etags *.[ch] depend: makedepend -- $(CFLAGS) -- *.[ch] # DO NOT DELETE THIS LINE -- make depend depends on it. adler32.o: zlib.h zconf.h compress.o: zlib.h zconf.h crc32.o: crc32.h zlib.h zconf.h deflate.o: deflate.h zutil.h zlib.h zconf.h example.o: zlib.h zconf.h gzio.o: zutil.h zlib.h zconf.h inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inftrees.o: zutil.h zlib.h zconf.h inftrees.h minigzip.o: zlib.h zconf.h trees.o: deflate.h zutil.h zlib.h zconf.h trees.h uncompr.o: zlib.h zconf.h zutil.o: zutil.h zlib.h zconf.h sks-ecc-0.93/zlib/win32/0000755000175000017500000000000010604550750013643 5ustar nachonachosks-ecc-0.93/zlib/win32/Makefile.crossgcc0000644000175000017500000000673110604550750017117 0ustar nachonacho# Makefile for zlib, derived from Makefile.dj2. # Modified for mingw32 by C. Spieler, 6/16/98. # Updated for zlib 1.2.x by Christian Spieler and Cosmin Truta, Mar-2003. # Last updated: 1-Aug-2003. # Tested under Cygwin and MinGW. # Copyright (C) 1995-2003 Jean-loup Gailly. # For conditions of distribution and use, see copyright notice in zlib.h # To compile, or to compile and test, type: # # make -fmakefile.gcc; make test testdll -fmakefile.gcc # # To use the asm code, type: # cp contrib/asm?86/match.S ./match.S # make LOC=-DASMV OBJA=match.o -fmakefile.gcc # # To install libz.a, zconf.h and zlib.h in the system directories, type: # # make install -fmakefile.gcc # Note: # If the platform is *not* MinGW (e.g. it is Cygwin or UWIN), # the DLL name should be changed from "zlib1.dll". STATICLIB = libz.a SHAREDLIB = zlib1.dll IMPLIB = libzdll.a #LOC = -DASMV #LOC = -DDEBUG -g CC = i586-mingw32msvc-cc CFLAGS = $(LOC) -O3 -Wall AS = $(CC) ASFLAGS = $(LOC) -Wall LD = $(CC) LDFLAGS = $(LOC) -s AR = ar ARFLAGS = rcs RC = windres RCFLAGS = --define GCC_WINDRES CP = cp -fp # If GNU install is available, replace $(CP) with install. INSTALL = $(CP) RM = rm -f prefix = /usr/local exec_prefix = $(prefix) OBJS = adler32.o compress.o crc32.o deflate.o gzio.o infback.o \ inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o OBJA = all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) example minigzip example_d minigzip_d test: example minigzip ./example echo hello world | ./minigzip | ./minigzip -d testdll: example_d minigzip_d ./example_d echo hello world | ./minigzip_d | ./minigzip_d -d .c.o: $(CC) $(CFLAGS) -c -o $@ $< .S.o: $(AS) $(ASFLAGS) -c -o $@ $< $(STATICLIB): $(OBJS) $(OBJA) $(AR) $(ARFLAGS) $@ $(OBJS) $(OBJA) $(IMPLIB): $(SHAREDLIB) $(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlibrc.o dllwrap --driver-name $(CC) --def win32/zlib.def \ --implib $(IMPLIB) -o $@ $(OBJS) $(OBJA) zlibrc.o strip $@ example: example.o $(STATICLIB) $(LD) $(LDFLAGS) -o $@ example.o $(STATICLIB) minigzip: minigzip.o $(STATICLIB) $(LD) $(LDFLAGS) -o $@ minigzip.o $(STATICLIB) example_d: example.o $(IMPLIB) $(LD) $(LDFLAGS) -o $@ example.o $(IMPLIB) minigzip_d: minigzip.o $(IMPLIB) $(LD) $(LDFLAGS) -o $@ minigzip.o $(IMPLIB) zlibrc.o: win32/zlib1.rc $(RC) $(RCFLAGS) -o $@ win32/zlib1.rc # INCLUDE_PATH and LIBRARY_PATH must be set. .PHONY: install uninstall clean install: zlib.h zconf.h $(LIB) -@if not exist $(INCLUDE_PATH)/nul mkdir $(INCLUDE_PATH) -@if not exist $(LIBRARY_PATH)/nul mkdir $(LIBRARY_PATH) -$(INSTALL) zlib.h $(INCLUDE_PATH) -$(INSTALL) zconf.h $(INCLUDE_PATH) -$(INSTALL) $(STATICLIB) $(LIBRARY_PATH) -$(INSTALL) $(IMPLIB) $(LIBRARY_PATH) uninstall: -$(RM) $(INCLUDE_PATH)/zlib.h -$(RM) $(INCLUDE_PATH)/zconf.h -$(RM) $(LIBRARY_PATH)/$(STATICLIB) -$(RM) $(LIBRARY_PATH)/$(IMPLIB) clean: -$(RM) $(STATICLIB) -$(RM) $(SHAREDLIB) -$(RM) $(IMPLIB) -$(RM) *.o -$(RM) *.exe -$(RM) foo.gz adler32.o: zlib.h zconf.h compress.o: zlib.h zconf.h crc32.o: crc32.h zlib.h zconf.h deflate.o: deflate.h zutil.h zlib.h zconf.h example.o: zlib.h zconf.h gzio.o: zutil.h zlib.h zconf.h inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inftrees.o: zutil.h zlib.h zconf.h inftrees.h minigzip.o: zlib.h zconf.h trees.o: deflate.h zutil.h zlib.h zconf.h trees.h uncompr.o: zlib.h zconf.h zutil.o: zutil.h zlib.h zconf.h sks-ecc-0.93/zlib/win32/Makefile.crossgcc~0000644000175000017500000000671110604550750017313 0ustar nachonacho# Makefile for zlib, derived from Makefile.dj2. # Modified for mingw32 by C. Spieler, 6/16/98. # Updated for zlib 1.2.x by Christian Spieler and Cosmin Truta, Mar-2003. # Last updated: 1-Aug-2003. # Tested under Cygwin and MinGW. # Copyright (C) 1995-2003 Jean-loup Gailly. # For conditions of distribution and use, see copyright notice in zlib.h # To compile, or to compile and test, type: # # make -fmakefile.gcc; make test testdll -fmakefile.gcc # # To use the asm code, type: # cp contrib/asm?86/match.S ./match.S # make LOC=-DASMV OBJA=match.o -fmakefile.gcc # # To install libz.a, zconf.h and zlib.h in the system directories, type: # # make install -fmakefile.gcc # Note: # If the platform is *not* MinGW (e.g. it is Cygwin or UWIN), # the DLL name should be changed from "zlib1.dll". STATICLIB = libz.a SHAREDLIB = zlib1.dll IMPLIB = libzdll.a #LOC = -DASMV #LOC = -DDEBUG -g CC = gcc CFLAGS = $(LOC) -O3 -Wall AS = $(CC) ASFLAGS = $(LOC) -Wall LD = $(CC) LDFLAGS = $(LOC) -s AR = ar ARFLAGS = rcs RC = windres RCFLAGS = --define GCC_WINDRES CP = cp -fp # If GNU install is available, replace $(CP) with install. INSTALL = $(CP) RM = rm -f prefix = /usr/local exec_prefix = $(prefix) OBJS = adler32.o compress.o crc32.o deflate.o gzio.o infback.o \ inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o OBJA = all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) example minigzip example_d minigzip_d test: example minigzip ./example echo hello world | ./minigzip | ./minigzip -d testdll: example_d minigzip_d ./example_d echo hello world | ./minigzip_d | ./minigzip_d -d .c.o: $(CC) $(CFLAGS) -c -o $@ $< .S.o: $(AS) $(ASFLAGS) -c -o $@ $< $(STATICLIB): $(OBJS) $(OBJA) $(AR) $(ARFLAGS) $@ $(OBJS) $(OBJA) $(IMPLIB): $(SHAREDLIB) $(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlibrc.o dllwrap --driver-name $(CC) --def win32/zlib.def \ --implib $(IMPLIB) -o $@ $(OBJS) $(OBJA) zlibrc.o strip $@ example: example.o $(STATICLIB) $(LD) $(LDFLAGS) -o $@ example.o $(STATICLIB) minigzip: minigzip.o $(STATICLIB) $(LD) $(LDFLAGS) -o $@ minigzip.o $(STATICLIB) example_d: example.o $(IMPLIB) $(LD) $(LDFLAGS) -o $@ example.o $(IMPLIB) minigzip_d: minigzip.o $(IMPLIB) $(LD) $(LDFLAGS) -o $@ minigzip.o $(IMPLIB) zlibrc.o: win32/zlib1.rc $(RC) $(RCFLAGS) -o $@ win32/zlib1.rc # INCLUDE_PATH and LIBRARY_PATH must be set. .PHONY: install uninstall clean install: zlib.h zconf.h $(LIB) -@if not exist $(INCLUDE_PATH)/nul mkdir $(INCLUDE_PATH) -@if not exist $(LIBRARY_PATH)/nul mkdir $(LIBRARY_PATH) -$(INSTALL) zlib.h $(INCLUDE_PATH) -$(INSTALL) zconf.h $(INCLUDE_PATH) -$(INSTALL) $(STATICLIB) $(LIBRARY_PATH) -$(INSTALL) $(IMPLIB) $(LIBRARY_PATH) uninstall: -$(RM) $(INCLUDE_PATH)/zlib.h -$(RM) $(INCLUDE_PATH)/zconf.h -$(RM) $(LIBRARY_PATH)/$(STATICLIB) -$(RM) $(LIBRARY_PATH)/$(IMPLIB) clean: -$(RM) $(STATICLIB) -$(RM) $(SHAREDLIB) -$(RM) $(IMPLIB) -$(RM) *.o -$(RM) *.exe -$(RM) foo.gz adler32.o: zlib.h zconf.h compress.o: zlib.h zconf.h crc32.o: crc32.h zlib.h zconf.h deflate.o: deflate.h zutil.h zlib.h zconf.h example.o: zlib.h zconf.h gzio.o: zutil.h zlib.h zconf.h inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inftrees.o: zutil.h zlib.h zconf.h inftrees.h minigzip.o: zlib.h zconf.h trees.o: deflate.h zutil.h zlib.h zconf.h trees.h uncompr.o: zlib.h zconf.h zutil.o: zutil.h zlib.h zconf.h sks-ecc-0.93/zlib/win32/Makefile.msc0000644000175000017500000000533510604550750016072 0ustar nachonacho# Makefile for zlib -- Microsoft (Visual) C # # Authors: # Cosmin Truta, 11-Mar-2003 # Christian Spieler, 19-Mar-2003 # # Last updated: # Cosmin Truta, 27-Aug-2003 # # Usage: # nmake -f win32/Makefile.msc (standard build) # nmake -f win32/Makefile.msc LOC=-DFOO (nonstandard build) # nmake -f win32/Makefile.msc LOC=-DASMV OBJA=match.obj (use ASM code) # optional build flags LOC = # variables STATICLIB = zlib.lib SHAREDLIB = zlib1.dll IMPLIB = zdll.lib CC = cl AS = ml LD = link AR = lib RC = rc CFLAGS = -nologo -MD -O2 $(LOC) ASFLAGS = -coff LDFLAGS = -nologo -release ARFLAGS = -nologo RCFLAGS = /dWIN32 /r OBJS = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj \ inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj OBJA = # targets all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \ example.exe minigzip.exe example_d.exe minigzip_d.exe $(STATICLIB): $(OBJS) $(OBJA) $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(OBJA) $(IMPLIB): $(SHAREDLIB) $(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlib1.res $(LD) $(LDFLAGS) -def:win32/zlib.def -dll -implib:$(IMPLIB) \ -out:$@ $(OBJS) $(OBJA) zlib1.res example.exe: example.obj $(STATICLIB) $(LD) $(LDFLAGS) example.obj $(STATICLIB) minigzip.exe: minigzip.obj $(STATICLIB) $(LD) $(LDFLAGS) minigzip.obj $(STATICLIB) example_d.exe: example.obj $(IMPLIB) $(LD) $(LDFLAGS) -out:$@ example.obj $(IMPLIB) minigzip_d.exe: minigzip.obj $(IMPLIB) $(LD) $(LDFLAGS) -out:$@ minigzip.obj $(IMPLIB) .c.obj: $(CC) -c $(CFLAGS) $< .asm.obj: $(AS) -c $(ASFLAGS) $< adler32.obj: adler32.c zlib.h zconf.h compress.obj: compress.c zlib.h zconf.h crc32.obj: crc32.c zlib.h zconf.h crc32.h deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h gzio.obj: gzio.c zutil.h zlib.h zconf.h infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inffixed.h inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inffixed.h inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h uncompr.obj: uncompr.c zlib.h zconf.h zutil.obj: zutil.c zutil.h zlib.h zconf.h example.obj: example.c zlib.h zconf.h minigzip.obj: minigzip.c zlib.h zconf.h zlib1.res: win32/zlib1.rc $(RC) $(RCFLAGS) /fo$@ win32/zlib1.rc # testing test: example.exe minigzip.exe example echo hello world | minigzip | minigzip -d testdll: example_d.exe minigzip_d.exe example_d echo hello world | minigzip_d | minigzip_d -d # cleanup clean: -del $(STATICLIB) -del $(SHAREDLIB) -del $(IMPLIB) -del *.obj -del *.res -del *.exp -del *.exe -del foo.gz sks-ecc-0.93/zlib/win32/zlib1.rc0000644000175000017500000000200010604550750015202 0ustar nachonacho#include #ifdef GCC_WINDRES VS_VERSION_INFO VERSIONINFO #else VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE #endif FILEVERSION 1,2,2,0 PRODUCTVERSION 1,2,2,0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK #ifdef _DEBUG FILEFLAGS 1 #else FILEFLAGS 0 #endif FILEOS VOS_DOS_WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE 0 // not used BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904E4" //language ID = U.S. English, char set = Windows, Multilingual BEGIN VALUE "FileDescription", "zlib data compression library\0" VALUE "FileVersion", "1.2.3\0" VALUE "InternalName", "zlib1.dll\0" VALUE "LegalCopyright", "(C) 1995-2004 Jean-loup Gailly & Mark Adler\0" VALUE "OriginalFilename", "zlib1.dll\0" VALUE "ProductName", "zlib\0" VALUE "ProductVersion", "1.2.3\0" VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x0409, 1252 END END sks-ecc-0.93/zlib/win32/DLL_FAQ.txt0000644000175000017500000004301010604550750015504 0ustar nachonacho Frequently Asked Questions about ZLIB1.DLL This document describes the design, the rationale, and the usage of the official DLL build of zlib, named ZLIB1.DLL. If you have general questions about zlib, you should see the file "FAQ" found in the zlib distribution, or at the following location: http://www.gzip.org/zlib/zlib_faq.html 1. What is ZLIB1.DLL, and how can I get it? - ZLIB1.DLL is the official build of zlib as a DLL. (Please remark the character '1' in the name.) Pointers to a precompiled ZLIB1.DLL can be found in the zlib web site at: http://www.zlib.org/ Applications that link to ZLIB1.DLL can rely on the following specification: * The exported symbols are exclusively defined in the source files "zlib.h" and "zlib.def", found in an official zlib source distribution. * The symbols are exported by name, not by ordinal. * The exported names are undecorated. * The calling convention of functions is "C" (CDECL). * The ZLIB1.DLL binary is linked to MSVCRT.DLL. The archive in which ZLIB1.DLL is bundled contains compiled test programs that must run with a valid build of ZLIB1.DLL. It is recommended to download the prebuilt DLL from the zlib web site, instead of building it yourself, to avoid potential incompatibilities that could be introduced by your compiler and build settings. If you do build the DLL yourself, please make sure that it complies with all the above requirements, and it runs with the precompiled test programs, bundled with the original ZLIB1.DLL distribution. If, for any reason, you need to build an incompatible DLL, please use a different file name. 2. Why did you change the name of the DLL to ZLIB1.DLL? What happened to the old ZLIB.DLL? - The old ZLIB.DLL, built from zlib-1.1.4 or earlier, required compilation settings that were incompatible to those used by a static build. The DLL settings were supposed to be enabled by defining the macro ZLIB_DLL, before including "zlib.h". Incorrect handling of this macro was silently accepted at build time, resulting in two major problems: * ZLIB_DLL was missing from the old makefile. When building the DLL, not all people added it to the build options. In consequence, incompatible incarnations of ZLIB.DLL started to circulate around the net. * When switching from using the static library to using the DLL, applications had to define the ZLIB_DLL macro and to recompile all the sources that contained calls to zlib functions. Failure to do so resulted in creating binaries that were unable to run with the official ZLIB.DLL build. The only possible solution that we could foresee was to make a binary-incompatible change in the DLL interface, in order to remove the dependency on the ZLIB_DLL macro, and to release the new DLL under a different name. We chose the name ZLIB1.DLL, where '1' indicates the major zlib version number. We hope that we will not have to break the binary compatibility again, at least not as long as the zlib-1.x series will last. There is still a ZLIB_DLL macro, that can trigger a more efficient build and use of the DLL, but compatibility no longer dependents on it. 3. Can I build ZLIB.DLL from the new zlib sources, and replace an old ZLIB.DLL, that was built from zlib-1.1.4 or earlier? - In principle, you can do it by assigning calling convention keywords to the macros ZEXPORT and ZEXPORTVA. In practice, it depends on what you mean by "an old ZLIB.DLL", because the old DLL exists in several mutually-incompatible versions. You have to find out first what kind of calling convention is being used in your particular ZLIB.DLL build, and to use the same one in the new build. If you don't know what this is all about, you might be better off if you would just leave the old DLL intact. 4. Can I compile my application using the new zlib interface, and link it to an old ZLIB.DLL, that was built from zlib-1.1.4 or earlier? - The official answer is "no"; the real answer depends again on what kind of ZLIB.DLL you have. Even if you are lucky, this course of action is unreliable. If you rebuild your application and you intend to use a newer version of zlib (post- 1.1.4), it is strongly recommended to link it to the new ZLIB1.DLL. 5. Why are the zlib symbols exported by name, and not by ordinal? - Although exporting symbols by ordinal is a little faster, it is risky. Any single glitch in the maintenance or use of the DEF file that contains the ordinals can result in incompatible builds and frustrating crashes. Simply put, the benefits of exporting symbols by ordinal do not justify the risks. Technically, it should be possible to maintain ordinals in the DEF file, and still export the symbols by name. Ordinals exist in every DLL, and even if the dynamic linking performed at the DLL startup is searching for names, ordinals serve as hints, for a faster name lookup. However, if the DEF file contains ordinals, the Microsoft linker automatically builds an implib that will cause the executables linked to it to use those ordinals, and not the names. It is interesting to notice that the GNU linker for Win32 does not suffer from this problem. It is possible to avoid the DEF file if the exported symbols are accompanied by a "__declspec(dllexport)" attribute in the source files. You can do this in zlib by predefining the ZLIB_DLL macro. 6. I see that the ZLIB1.DLL functions use the "C" (CDECL) calling convention. Why not use the STDCALL convention? STDCALL is the standard convention in Win32, and I need it in my Visual Basic project! (For readability, we use CDECL to refer to the convention triggered by the "__cdecl" keyword, STDCALL to refer to the convention triggered by "__stdcall", and FASTCALL to refer to the convention triggered by "__fastcall".) - Most of the native Windows API functions (without varargs) use indeed the WINAPI convention (which translates to STDCALL in Win32), but the standard C functions use CDECL. If a user application is intrinsically tied to the Windows API (e.g. it calls native Windows API functions such as CreateFile()), sometimes it makes sense to decorate its own functions with WINAPI. But if ANSI C or POSIX portability is a goal (e.g. it calls standard C functions such as fopen()), it is not a sound decision to request the inclusion of , or to use non-ANSI constructs, for the sole purpose to make the user functions STDCALL-able. The functionality offered by zlib is not in the category of "Windows functionality", but is more like "C functionality". Technically, STDCALL is not bad; in fact, it is slightly faster than CDECL, and it works with variable-argument functions, just like CDECL. It is unfortunate that, in spite of using STDCALL in the Windows API, it is not the default convention used by the C compilers that run under Windows. The roots of the problem reside deep inside the unsafety of the K&R-style function prototypes, where the argument types are not specified; but that is another story for another day. The remaining fact is that CDECL is the default convention. Even if an explicit convention is hard-coded into the function prototypes inside C headers, problems may appear. The necessity to expose the convention in users' callbacks is one of these problems. The calling convention issues are also important when using zlib in other programming languages. Some of them, like Ada (GNAT) and Fortran (GNU G77), have C bindings implemented initially on Unix, and relying on the C calling convention. On the other hand, the pre- .NET versions of Microsoft Visual Basic require STDCALL, while Borland Delphi prefers, although it does not require, FASTCALL. In fairness to all possible uses of zlib outside the C programming language, we choose the default "C" convention. Anyone interested in different bindings or conventions is encouraged to maintain specialized projects. The "contrib/" directory from the zlib distribution already holds a couple of foreign bindings, such as Ada, C++, and Delphi. 7. I need a DLL for my Visual Basic project. What can I do? - Define the ZLIB_WINAPI macro before including "zlib.h", when building both the DLL and the user application (except that you don't need to define anything when using the DLL in Visual Basic). The ZLIB_WINAPI macro will switch on the WINAPI (STDCALL) convention. The name of this DLL must be different than the official ZLIB1.DLL. Gilles Vollant has contributed a build named ZLIBWAPI.DLL, with the ZLIB_WINAPI macro turned on, and with the minizip functionality built in. For more information, please read the notes inside "contrib/vstudio/readme.txt", found in the zlib distribution. 8. I need to use zlib in my Microsoft .NET project. What can I do? - Henrik Ravn has contributed a .NET wrapper around zlib. Look into contrib/dotzlib/, inside the zlib distribution. 9. If my application uses ZLIB1.DLL, should I link it to MSVCRT.DLL? Why? - It is not required, but it is recommended to link your application to MSVCRT.DLL, if it uses ZLIB1.DLL. The executables (.EXE, .DLL, etc.) that are involved in the same process and are using the C run-time library (i.e. they are calling standard C functions), must link to the same library. There are several libraries in the Win32 system: CRTDLL.DLL, MSVCRT.DLL, the static C libraries, etc. Since ZLIB1.DLL is linked to MSVCRT.DLL, the executables that depend on it should also be linked to MSVCRT.DLL. 10. Why are you saying that ZLIB1.DLL and my application should be linked to the same C run-time (CRT) library? I linked my application and my DLLs to different C libraries (e.g. my application to a static library, and my DLLs to MSVCRT.DLL), and everything works fine. - If a user library invokes only pure Win32 API (accessible via and the related headers), its DLL build will work in any context. But if this library invokes standard C API, things get more complicated. There is a single Win32 library in a Win32 system. Every function in this library resides in a single DLL module, that is safe to call from anywhere. On the other hand, there are multiple versions of the C library, and each of them has its own separate internal state. Standalone executables and user DLLs that call standard C functions must link to a C run-time (CRT) library, be it static or shared (DLL). Intermixing occurs when an executable (not necessarily standalone) and a DLL are linked to different CRTs, and both are running in the same process. Intermixing multiple CRTs is possible, as long as their internal states are kept intact. The Microsoft Knowledge Base articles KB94248 "HOWTO: Use the C Run-Time" and KB140584 "HOWTO: Link with the Correct C Run-Time (CRT) Library" mention the potential problems raised by intermixing. If intermixing works for you, it's because your application and DLLs are avoiding the corruption of each of the CRTs' internal states, maybe by careful design, or maybe by fortune. Also note that linking ZLIB1.DLL to non-Microsoft CRTs, such as those provided by Borland, raises similar problems. 11. Why are you linking ZLIB1.DLL to MSVCRT.DLL? - MSVCRT.DLL exists on every Windows 95 with a new service pack installed, or with Microsoft Internet Explorer 4 or later, and on all other Windows 4.x or later (Windows 98, Windows NT 4, or later). It is freely distributable; if not present in the system, it can be downloaded from Microsoft or from other software provider for free. The fact that MSVCRT.DLL does not exist on a virgin Windows 95 is not so problematic. Windows 95 is scarcely found nowadays, Microsoft ended its support a long time ago, and many recent applications from various vendors, including Microsoft, do not even run on it. Furthermore, no serious user should run Windows 95 without a proper update installed. 12. Why are you not linking ZLIB1.DLL to <> ? - We considered and abandoned the following alternatives: * Linking ZLIB1.DLL to a static C library (LIBC.LIB, or LIBCMT.LIB) is not a good option. People are using the DLL mainly to save disk space. If you are linking your program to a static C library, you may as well consider linking zlib in statically, too. * Linking ZLIB1.DLL to CRTDLL.DLL looks appealing, because CRTDLL.DLL is present on every Win32 installation. Unfortunately, it has a series of problems: it does not work properly with Microsoft's C++ libraries, it does not provide support for 64-bit file offsets, (and so on...), and Microsoft discontinued its support a long time ago. * Linking ZLIB1.DLL to MSVCR70.DLL or MSVCR71.DLL, supplied with the Microsoft .NET platform, and Visual C++ 7.0/7.1, raises problems related to the status of ZLIB1.DLL as a system component. According to the Microsoft Knowledge Base article KB326922 "INFO: Redistribution of the Shared C Runtime Component in Visual C++ .NET", MSVCR70.DLL and MSVCR71.DLL are not supposed to function as system DLLs, because they may clash with MSVCRT.DLL. Instead, the application's installer is supposed to put these DLLs (if needed) in the application's private directory. If ZLIB1.DLL depends on a non-system runtime, it cannot function as a redistributable system component. * Linking ZLIB1.DLL to non-Microsoft runtimes, such as Borland's, or Cygwin's, raises problems related to the reliable presence of these runtimes on Win32 systems. It's easier to let the DLL build of zlib up to the people who distribute these runtimes, and who may proceed as explained in the answer to Question 14. 13. If ZLIB1.DLL cannot be linked to MSVCR70.DLL or MSVCR71.DLL, how can I build/use ZLIB1.DLL in Microsoft Visual C++ 7.0 (Visual Studio .NET) or newer? - Due to the problems explained in the Microsoft Knowledge Base article KB326922 (see the previous answer), the C runtime that comes with the VC7 environment is no longer considered a system component. That is, it should not be assumed that this runtime exists, or may be installed in a system directory. Since ZLIB1.DLL is supposed to be a system component, it may not depend on a non-system component. In order to link ZLIB1.DLL and your application to MSVCRT.DLL in VC7, you need the library of Visual C++ 6.0 or older. If you don't have this library at hand, it's probably best not to use ZLIB1.DLL. We are hoping that, in the future, Microsoft will provide a way to build applications linked to a proper system runtime, from the Visual C++ environment. Until then, you have a couple of alternatives, such as linking zlib in statically. If your application requires dynamic linking, you may proceed as explained in the answer to Question 14. 14. I need to link my own DLL build to a CRT different than MSVCRT.DLL. What can I do? - Feel free to rebuild the DLL from the zlib sources, and link it the way you want. You should, however, clearly state that your build is unofficial. You should give it a different file name, and/or install it in a private directory that can be accessed by your application only, and is not visible to the others (e.g. it's not in the SYSTEM or the SYSTEM32 directory, and it's not in the PATH). Otherwise, your build may clash with applications that link to the official build. For example, in Cygwin, zlib is linked to the Cygwin runtime CYGWIN1.DLL, and it is distributed under the name CYGZ.DLL. 15. May I include additional pieces of code that I find useful, link them in ZLIB1.DLL, and export them? - No. A legitimate build of ZLIB1.DLL must not include code that does not originate from the official zlib source code. But you can make your own private DLL build, under a different file name, as suggested in the previous answer. For example, zlib is a part of the VCL library, distributed with Borland Delphi and C++ Builder. The DLL build of VCL is a redistributable file, named VCLxx.DLL. 16. May I remove some functionality out of ZLIB1.DLL, by enabling macros like NO_GZCOMPRESS or NO_GZIP at compile time? - No. A legitimate build of ZLIB1.DLL must provide the complete zlib functionality, as implemented in the official zlib source code. But you can make your own private DLL build, under a different file name, as suggested in the previous answer. 17. I made my own ZLIB1.DLL build. Can I test it for compliance? - We prefer that you download the official DLL from the zlib web site. If you need something peculiar from this DLL, you can send your suggestion to the zlib mailing list. However, in case you do rebuild the DLL yourself, you can run it with the test programs found in the DLL distribution. Running these test programs is not a guarantee of compliance, but a failure can imply a detected problem. ** This document is written and maintained by Cosmin Truta sks-ecc-0.93/zlib/win32/VisualC.txt0000644000175000017500000000016510604550750015754 0ustar nachonacho To build zlib using the Microsoft Visual C++ environment, use the appropriate project from the projects/ directory. sks-ecc-0.93/zlib/win32/Makefile.gcc0000644000175000017500000000671110604550750016043 0ustar nachonacho# Makefile for zlib, derived from Makefile.dj2. # Modified for mingw32 by C. Spieler, 6/16/98. # Updated for zlib 1.2.x by Christian Spieler and Cosmin Truta, Mar-2003. # Last updated: 1-Aug-2003. # Tested under Cygwin and MinGW. # Copyright (C) 1995-2003 Jean-loup Gailly. # For conditions of distribution and use, see copyright notice in zlib.h # To compile, or to compile and test, type: # # make -fmakefile.gcc; make test testdll -fmakefile.gcc # # To use the asm code, type: # cp contrib/asm?86/match.S ./match.S # make LOC=-DASMV OBJA=match.o -fmakefile.gcc # # To install libz.a, zconf.h and zlib.h in the system directories, type: # # make install -fmakefile.gcc # Note: # If the platform is *not* MinGW (e.g. it is Cygwin or UWIN), # the DLL name should be changed from "zlib1.dll". STATICLIB = libz.a SHAREDLIB = zlib1.dll IMPLIB = libzdll.a #LOC = -DASMV #LOC = -DDEBUG -g CC = gcc CFLAGS = $(LOC) -O3 -Wall AS = $(CC) ASFLAGS = $(LOC) -Wall LD = $(CC) LDFLAGS = $(LOC) -s AR = ar ARFLAGS = rcs RC = windres RCFLAGS = --define GCC_WINDRES CP = cp -fp # If GNU install is available, replace $(CP) with install. INSTALL = $(CP) RM = rm -f prefix = /usr/local exec_prefix = $(prefix) OBJS = adler32.o compress.o crc32.o deflate.o gzio.o infback.o \ inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o OBJA = all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) example minigzip example_d minigzip_d test: example minigzip ./example echo hello world | ./minigzip | ./minigzip -d testdll: example_d minigzip_d ./example_d echo hello world | ./minigzip_d | ./minigzip_d -d .c.o: $(CC) $(CFLAGS) -c -o $@ $< .S.o: $(AS) $(ASFLAGS) -c -o $@ $< $(STATICLIB): $(OBJS) $(OBJA) $(AR) $(ARFLAGS) $@ $(OBJS) $(OBJA) $(IMPLIB): $(SHAREDLIB) $(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlibrc.o dllwrap --driver-name $(CC) --def win32/zlib.def \ --implib $(IMPLIB) -o $@ $(OBJS) $(OBJA) zlibrc.o strip $@ example: example.o $(STATICLIB) $(LD) $(LDFLAGS) -o $@ example.o $(STATICLIB) minigzip: minigzip.o $(STATICLIB) $(LD) $(LDFLAGS) -o $@ minigzip.o $(STATICLIB) example_d: example.o $(IMPLIB) $(LD) $(LDFLAGS) -o $@ example.o $(IMPLIB) minigzip_d: minigzip.o $(IMPLIB) $(LD) $(LDFLAGS) -o $@ minigzip.o $(IMPLIB) zlibrc.o: win32/zlib1.rc $(RC) $(RCFLAGS) -o $@ win32/zlib1.rc # INCLUDE_PATH and LIBRARY_PATH must be set. .PHONY: install uninstall clean install: zlib.h zconf.h $(LIB) -@if not exist $(INCLUDE_PATH)/nul mkdir $(INCLUDE_PATH) -@if not exist $(LIBRARY_PATH)/nul mkdir $(LIBRARY_PATH) -$(INSTALL) zlib.h $(INCLUDE_PATH) -$(INSTALL) zconf.h $(INCLUDE_PATH) -$(INSTALL) $(STATICLIB) $(LIBRARY_PATH) -$(INSTALL) $(IMPLIB) $(LIBRARY_PATH) uninstall: -$(RM) $(INCLUDE_PATH)/zlib.h -$(RM) $(INCLUDE_PATH)/zconf.h -$(RM) $(LIBRARY_PATH)/$(STATICLIB) -$(RM) $(LIBRARY_PATH)/$(IMPLIB) clean: -$(RM) $(STATICLIB) -$(RM) $(SHAREDLIB) -$(RM) $(IMPLIB) -$(RM) *.o -$(RM) *.exe -$(RM) foo.gz adler32.o: zlib.h zconf.h compress.o: zlib.h zconf.h crc32.o: crc32.h zlib.h zconf.h deflate.o: deflate.h zutil.h zlib.h zconf.h example.o: zlib.h zconf.h gzio.o: zutil.h zlib.h zconf.h inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inftrees.o: zutil.h zlib.h zconf.h inftrees.h minigzip.o: zlib.h zconf.h trees.o: deflate.h zutil.h zlib.h zconf.h trees.h uncompr.o: zlib.h zconf.h zutil.o: zutil.h zlib.h zconf.h sks-ecc-0.93/zlib/win32/Makefile.bor0000644000175000017500000000461010604550750016065 0ustar nachonacho# Makefile for zlib # Borland C++ for Win32 # # Updated for zlib 1.2.x by Cosmin Truta, 11-Mar-2003 # Last updated: 28-Aug-2003 # # Usage: # make -f win32/Makefile.bor # make -f win32/Makefile.bor LOCAL_ZLIB=-DASMV OBJA=match.obj OBJPA=+match.obj # ------------ Borland C++ ------------ # Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) # should be added to the environment via "set LOCAL_ZLIB=-DFOO" or # added to the declaration of LOC here: LOC = $(LOCAL_ZLIB) CC = bcc32 AS = bcc32 LD = bcc32 AR = tlib CFLAGS = -a -d -k- -O2 $(LOC) ASFLAGS = $(LOC) LDFLAGS = $(LOC) # variables ZLIB_LIB = zlib.lib OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj #OBJA = OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj #OBJPA= # targets all: $(ZLIB_LIB) example.exe minigzip.exe .c.obj: $(CC) -c $(CFLAGS) $< .asm.obj: $(AS) -c $(ASFLAGS) $< adler32.obj: adler32.c zlib.h zconf.h compress.obj: compress.c zlib.h zconf.h crc32.obj: crc32.c zlib.h zconf.h crc32.h deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h gzio.obj: gzio.c zutil.h zlib.h zconf.h infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inffixed.h inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ inffast.h inffixed.h inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h uncompr.obj: uncompr.c zlib.h zconf.h zutil.obj: zutil.c zutil.h zlib.h zconf.h example.obj: example.c zlib.h zconf.h minigzip.obj: minigzip.c zlib.h zconf.h # For the sake of the old Borland make, # the command line is cut to fit in the MS-DOS 128 byte limit: $(ZLIB_LIB): $(OBJ1) $(OBJ2) $(OBJA) -del $(ZLIB_LIB) $(AR) $(ZLIB_LIB) $(OBJP1) $(AR) $(ZLIB_LIB) $(OBJP2) $(AR) $(ZLIB_LIB) $(OBJPA) # testing test: example.exe minigzip.exe example echo hello world | minigzip | minigzip -d example.exe: example.obj $(ZLIB_LIB) $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) minigzip.exe: minigzip.obj $(ZLIB_LIB) $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) # cleanup clean: -del *.obj -del *.lib -del *.exe -del *.tds -del zlib.bak -del foo.gz sks-ecc-0.93/zlib/win32/zlib.def0000644000175000017500000000163110604550750015264 0ustar nachonachoLIBRARY ; zlib data compression library EXPORTS ; basic functions zlibVersion deflate deflateEnd inflate inflateEnd ; advanced functions deflateSetDictionary deflateCopy deflateReset deflateParams deflateBound deflatePrime inflateSetDictionary inflateSync inflateCopy inflateReset inflateBack inflateBackEnd zlibCompileFlags ; utility functions compress compress2 compressBound uncompress gzopen gzdopen gzsetparams gzread gzwrite gzprintf gzputs gzgets gzputc gzgetc gzungetc gzflush gzseek gzrewind gztell gzeof gzclose gzerror gzclearerr ; checksum functions adler32 crc32 ; various hacks, don't look :) deflateInit_ deflateInit2_ inflateInit_ inflateInit2_ inflateBackInit_ inflateSyncPoint get_crc_table zError sks-ecc-0.93/zlib/win32/Makefile.emx0000644000175000017500000000261510604550750016077 0ustar nachonacho# Makefile for zlib. Modified for emx/rsxnt by Chr. Spieler, 6/16/98. # Copyright (C) 1995-1998 Jean-loup Gailly. # For conditions of distribution and use, see copyright notice in zlib.h # To compile, or to compile and test, type: # # make -fmakefile.emx; make test -fmakefile.emx # CC=gcc -Zwin32 #CFLAGS=-MMD -O #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 #CFLAGS=-MMD -g -DDEBUG CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ -Wstrict-prototypes -Wmissing-prototypes # If cp.exe is available, replace "copy /Y" with "cp -fp" . CP=copy /Y # If gnu install.exe is available, replace $(CP) with ginstall. INSTALL=$(CP) # The default value of RM is "rm -f." If "rm.exe" is found, comment out: RM=del LDLIBS=-L. -lzlib LD=$(CC) -s -o LDSHARED=$(CC) INCL=zlib.h zconf.h LIBS=zlib.a AR=ar rcs prefix=/usr/local exec_prefix = $(prefix) OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ zutil.o inflate.o infback.o inftrees.o inffast.o TEST_OBJS = example.o minigzip.o all: example.exe minigzip.exe test: all ./example echo hello world | .\minigzip | .\minigzip -d %.o : %.c $(CC) $(CFLAGS) -c $< -o $@ zlib.a: $(OBJS) $(AR) $@ $(OBJS) %.exe : %.o $(LIBS) $(LD) $@ $< $(LDLIBS) .PHONY : clean clean: $(RM) *.d $(RM) *.o $(RM) *.exe $(RM) zlib.a $(RM) foo.gz DEPS := $(wildcard *.d) ifneq ($(DEPS),) include $(DEPS) endif sks-ecc-0.93/zlib/example.c0000644000175000017500000004001610604550750014501 0ustar nachonacho/* example.c -- usage example of the zlib compression library * Copyright (C) 1995-2004 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #include #include "zlib.h" #ifdef STDC # include # include #endif #if defined(VMS) || defined(RISCOS) # define TESTFILE "foo-gz" #else # define TESTFILE "foo.gz" #endif #define CHECK_ERR(err, msg) { \ if (err != Z_OK) { \ fprintf(stderr, "%s error: %d\n", msg, err); \ exit(1); \ } \ } const char hello[] = "hello, hello!"; /* "hello world" would be more standard, but the repeated "hello" * stresses the compression code better, sorry... */ const char dictionary[] = "hello"; uLong dictId; /* Adler32 value of the dictionary */ void test_compress OF((Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)); void test_gzio OF((const char *fname, Byte *uncompr, uLong uncomprLen)); void test_deflate OF((Byte *compr, uLong comprLen)); void test_inflate OF((Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)); void test_large_deflate OF((Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)); void test_large_inflate OF((Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)); void test_flush OF((Byte *compr, uLong *comprLen)); void test_sync OF((Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)); void test_dict_deflate OF((Byte *compr, uLong comprLen)); void test_dict_inflate OF((Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)); int main OF((int argc, char *argv[])); /* =========================================================================== * Test compress() and uncompress() */ void test_compress(compr, comprLen, uncompr, uncomprLen) Byte *compr, *uncompr; uLong comprLen, uncomprLen; { int err; uLong len = (uLong)strlen(hello)+1; err = compress(compr, &comprLen, (const Bytef*)hello, len); CHECK_ERR(err, "compress"); strcpy((char*)uncompr, "garbage"); err = uncompress(uncompr, &uncomprLen, compr, comprLen); CHECK_ERR(err, "uncompress"); if (strcmp((char*)uncompr, hello)) { fprintf(stderr, "bad uncompress\n"); exit(1); } else { printf("uncompress(): %s\n", (char *)uncompr); } } /* =========================================================================== * Test read/write of .gz files */ void test_gzio(fname, uncompr, uncomprLen) const char *fname; /* compressed file name */ Byte *uncompr; uLong uncomprLen; { #ifdef NO_GZCOMPRESS fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); #else int err; int len = (int)strlen(hello)+1; gzFile file; z_off_t pos; file = gzopen(fname, "wb"); if (file == NULL) { fprintf(stderr, "gzopen error\n"); exit(1); } gzputc(file, 'h'); if (gzputs(file, "ello") != 4) { fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err)); exit(1); } if (gzprintf(file, ", %s!", "hello") != 8) { fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err)); exit(1); } gzseek(file, 1L, SEEK_CUR); /* add one zero byte */ gzclose(file); file = gzopen(fname, "rb"); if (file == NULL) { fprintf(stderr, "gzopen error\n"); exit(1); } strcpy((char*)uncompr, "garbage"); if (gzread(file, uncompr, (unsigned)uncomprLen) != len) { fprintf(stderr, "gzread err: %s\n", gzerror(file, &err)); exit(1); } if (strcmp((char*)uncompr, hello)) { fprintf(stderr, "bad gzread: %s\n", (char*)uncompr); exit(1); } else { printf("gzread(): %s\n", (char*)uncompr); } pos = gzseek(file, -8L, SEEK_CUR); if (pos != 6 || gztell(file) != pos) { fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", (long)pos, (long)gztell(file)); exit(1); } if (gzgetc(file) != ' ') { fprintf(stderr, "gzgetc error\n"); exit(1); } if (gzungetc(' ', file) != ' ') { fprintf(stderr, "gzungetc error\n"); exit(1); } gzgets(file, (char*)uncompr, (int)uncomprLen); if (strlen((char*)uncompr) != 7) { /* " hello!" */ fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err)); exit(1); } if (strcmp((char*)uncompr, hello + 6)) { fprintf(stderr, "bad gzgets after gzseek\n"); exit(1); } else { printf("gzgets() after gzseek: %s\n", (char*)uncompr); } gzclose(file); #endif } /* =========================================================================== * Test deflate() with small buffers */ void test_deflate(compr, comprLen) Byte *compr; uLong comprLen; { z_stream c_stream; /* compression stream */ int err; uLong len = (uLong)strlen(hello)+1; c_stream.zalloc = (alloc_func)0; c_stream.zfree = (free_func)0; c_stream.opaque = (voidpf)0; err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); CHECK_ERR(err, "deflateInit"); c_stream.next_in = (Bytef*)hello; c_stream.next_out = compr; while (c_stream.total_in != len && c_stream.total_out < comprLen) { c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ err = deflate(&c_stream, Z_NO_FLUSH); CHECK_ERR(err, "deflate"); } /* Finish the stream, still forcing small buffers: */ for (;;) { c_stream.avail_out = 1; err = deflate(&c_stream, Z_FINISH); if (err == Z_STREAM_END) break; CHECK_ERR(err, "deflate"); } err = deflateEnd(&c_stream); CHECK_ERR(err, "deflateEnd"); } /* =========================================================================== * Test inflate() with small buffers */ void test_inflate(compr, comprLen, uncompr, uncomprLen) Byte *compr, *uncompr; uLong comprLen, uncomprLen; { int err; z_stream d_stream; /* decompression stream */ strcpy((char*)uncompr, "garbage"); d_stream.zalloc = (alloc_func)0; d_stream.zfree = (free_func)0; d_stream.opaque = (voidpf)0; d_stream.next_in = compr; d_stream.avail_in = 0; d_stream.next_out = uncompr; err = inflateInit(&d_stream); CHECK_ERR(err, "inflateInit"); while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) { d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */ err = inflate(&d_stream, Z_NO_FLUSH); if (err == Z_STREAM_END) break; CHECK_ERR(err, "inflate"); } err = inflateEnd(&d_stream); CHECK_ERR(err, "inflateEnd"); if (strcmp((char*)uncompr, hello)) { fprintf(stderr, "bad inflate\n"); exit(1); } else { printf("inflate(): %s\n", (char *)uncompr); } } /* =========================================================================== * Test deflate() with large buffers and dynamic change of compression level */ void test_large_deflate(compr, comprLen, uncompr, uncomprLen) Byte *compr, *uncompr; uLong comprLen, uncomprLen; { z_stream c_stream; /* compression stream */ int err; c_stream.zalloc = (alloc_func)0; c_stream.zfree = (free_func)0; c_stream.opaque = (voidpf)0; err = deflateInit(&c_stream, Z_BEST_SPEED); CHECK_ERR(err, "deflateInit"); c_stream.next_out = compr; c_stream.avail_out = (uInt)comprLen; /* At this point, uncompr is still mostly zeroes, so it should compress * very well: */ c_stream.next_in = uncompr; c_stream.avail_in = (uInt)uncomprLen; err = deflate(&c_stream, Z_NO_FLUSH); CHECK_ERR(err, "deflate"); if (c_stream.avail_in != 0) { fprintf(stderr, "deflate not greedy\n"); exit(1); } /* Feed in already compressed data and switch to no compression: */ deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); c_stream.next_in = compr; c_stream.avail_in = (uInt)comprLen/2; err = deflate(&c_stream, Z_NO_FLUSH); CHECK_ERR(err, "deflate"); /* Switch back to compressing mode: */ deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED); c_stream.next_in = uncompr; c_stream.avail_in = (uInt)uncomprLen; err = deflate(&c_stream, Z_NO_FLUSH); CHECK_ERR(err, "deflate"); err = deflate(&c_stream, Z_FINISH); if (err != Z_STREAM_END) { fprintf(stderr, "deflate should report Z_STREAM_END\n"); exit(1); } err = deflateEnd(&c_stream); CHECK_ERR(err, "deflateEnd"); } /* =========================================================================== * Test inflate() with large buffers */ void test_large_inflate(compr, comprLen, uncompr, uncomprLen) Byte *compr, *uncompr; uLong comprLen, uncomprLen; { int err; z_stream d_stream; /* decompression stream */ strcpy((char*)uncompr, "garbage"); d_stream.zalloc = (alloc_func)0; d_stream.zfree = (free_func)0; d_stream.opaque = (voidpf)0; d_stream.next_in = compr; d_stream.avail_in = (uInt)comprLen; err = inflateInit(&d_stream); CHECK_ERR(err, "inflateInit"); for (;;) { d_stream.next_out = uncompr; /* discard the output */ d_stream.avail_out = (uInt)uncomprLen; err = inflate(&d_stream, Z_NO_FLUSH); if (err == Z_STREAM_END) break; CHECK_ERR(err, "large inflate"); } err = inflateEnd(&d_stream); CHECK_ERR(err, "inflateEnd"); if (d_stream.total_out != 2*uncomprLen + comprLen/2) { fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out); exit(1); } else { printf("large_inflate(): OK\n"); } } /* =========================================================================== * Test deflate() with full flush */ void test_flush(compr, comprLen) Byte *compr; uLong *comprLen; { z_stream c_stream; /* compression stream */ int err; uInt len = (uInt)strlen(hello)+1; c_stream.zalloc = (alloc_func)0; c_stream.zfree = (free_func)0; c_stream.opaque = (voidpf)0; err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); CHECK_ERR(err, "deflateInit"); c_stream.next_in = (Bytef*)hello; c_stream.next_out = compr; c_stream.avail_in = 3; c_stream.avail_out = (uInt)*comprLen; err = deflate(&c_stream, Z_FULL_FLUSH); CHECK_ERR(err, "deflate"); compr[3]++; /* force an error in first compressed block */ c_stream.avail_in = len - 3; err = deflate(&c_stream, Z_FINISH); if (err != Z_STREAM_END) { CHECK_ERR(err, "deflate"); } err = deflateEnd(&c_stream); CHECK_ERR(err, "deflateEnd"); *comprLen = c_stream.total_out; } /* =========================================================================== * Test inflateSync() */ void test_sync(compr, comprLen, uncompr, uncomprLen) Byte *compr, *uncompr; uLong comprLen, uncomprLen; { int err; z_stream d_stream; /* decompression stream */ strcpy((char*)uncompr, "garbage"); d_stream.zalloc = (alloc_func)0; d_stream.zfree = (free_func)0; d_stream.opaque = (voidpf)0; d_stream.next_in = compr; d_stream.avail_in = 2; /* just read the zlib header */ err = inflateInit(&d_stream); CHECK_ERR(err, "inflateInit"); d_stream.next_out = uncompr; d_stream.avail_out = (uInt)uncomprLen; inflate(&d_stream, Z_NO_FLUSH); CHECK_ERR(err, "inflate"); d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */ err = inflateSync(&d_stream); /* but skip the damaged part */ CHECK_ERR(err, "inflateSync"); err = inflate(&d_stream, Z_FINISH); if (err != Z_DATA_ERROR) { fprintf(stderr, "inflate should report DATA_ERROR\n"); /* Because of incorrect adler32 */ exit(1); } err = inflateEnd(&d_stream); CHECK_ERR(err, "inflateEnd"); printf("after inflateSync(): hel%s\n", (char *)uncompr); } /* =========================================================================== * Test deflate() with preset dictionary */ void test_dict_deflate(compr, comprLen) Byte *compr; uLong comprLen; { z_stream c_stream; /* compression stream */ int err; c_stream.zalloc = (alloc_func)0; c_stream.zfree = (free_func)0; c_stream.opaque = (voidpf)0; err = deflateInit(&c_stream, Z_BEST_COMPRESSION); CHECK_ERR(err, "deflateInit"); err = deflateSetDictionary(&c_stream, (const Bytef*)dictionary, sizeof(dictionary)); CHECK_ERR(err, "deflateSetDictionary"); dictId = c_stream.adler; c_stream.next_out = compr; c_stream.avail_out = (uInt)comprLen; c_stream.next_in = (Bytef*)hello; c_stream.avail_in = (uInt)strlen(hello)+1; err = deflate(&c_stream, Z_FINISH); if (err != Z_STREAM_END) { fprintf(stderr, "deflate should report Z_STREAM_END\n"); exit(1); } err = deflateEnd(&c_stream); CHECK_ERR(err, "deflateEnd"); } /* =========================================================================== * Test inflate() with a preset dictionary */ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) Byte *compr, *uncompr; uLong comprLen, uncomprLen; { int err; z_stream d_stream; /* decompression stream */ strcpy((char*)uncompr, "garbage"); d_stream.zalloc = (alloc_func)0; d_stream.zfree = (free_func)0; d_stream.opaque = (voidpf)0; d_stream.next_in = compr; d_stream.avail_in = (uInt)comprLen; err = inflateInit(&d_stream); CHECK_ERR(err, "inflateInit"); d_stream.next_out = uncompr; d_stream.avail_out = (uInt)uncomprLen; for (;;) { err = inflate(&d_stream, Z_NO_FLUSH); if (err == Z_STREAM_END) break; if (err == Z_NEED_DICT) { if (d_stream.adler != dictId) { fprintf(stderr, "unexpected dictionary"); exit(1); } err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary, sizeof(dictionary)); } CHECK_ERR(err, "inflate with dict"); } err = inflateEnd(&d_stream); CHECK_ERR(err, "inflateEnd"); if (strcmp((char*)uncompr, hello)) { fprintf(stderr, "bad inflate with dict\n"); exit(1); } else { printf("inflate with dictionary: %s\n", (char *)uncompr); } } /* =========================================================================== * Usage: example [output.gz [input.gz]] */ int main(argc, argv) int argc; char *argv[]; { Byte *compr, *uncompr; uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ uLong uncomprLen = comprLen; static const char* myVersion = ZLIB_VERSION; if (zlibVersion()[0] != myVersion[0]) { fprintf(stderr, "incompatible zlib version\n"); exit(1); } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) { fprintf(stderr, "warning: different zlib version\n"); } printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n", ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags()); compr = (Byte*)calloc((uInt)comprLen, 1); uncompr = (Byte*)calloc((uInt)uncomprLen, 1); /* compr and uncompr are cleared to avoid reading uninitialized * data and to ensure that uncompr compresses well. */ if (compr == Z_NULL || uncompr == Z_NULL) { printf("out of memory\n"); exit(1); } test_compress(compr, comprLen, uncompr, uncomprLen); test_gzio((argc > 1 ? argv[1] : TESTFILE), uncompr, uncomprLen); test_deflate(compr, comprLen); test_inflate(compr, comprLen, uncompr, uncomprLen); test_large_deflate(compr, comprLen, uncompr, uncomprLen); test_large_inflate(compr, comprLen, uncompr, uncomprLen); test_flush(compr, &comprLen); test_sync(compr, comprLen, uncompr, uncomprLen); comprLen = uncomprLen; test_dict_deflate(compr, comprLen); test_dict_inflate(compr, comprLen, uncompr, uncomprLen); free(compr); free(uncompr); return 0; } sks-ecc-0.93/zlib/inflate.c0000644000175000017500000013752110604550750014500 0ustar nachonacho/* inflate.c -- zlib decompression * Copyright (C) 1995-2005 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* * Change history: * * 1.2.beta0 24 Nov 2002 * - First version -- complete rewrite of inflate to simplify code, avoid * creation of window when not needed, minimize use of window when it is * needed, make inffast.c even faster, implement gzip decoding, and to * improve code readability and style over the previous zlib inflate code * * 1.2.beta1 25 Nov 2002 * - Use pointers for available input and output checking in inffast.c * - Remove input and output counters in inffast.c * - Change inffast.c entry and loop from avail_in >= 7 to >= 6 * - Remove unnecessary second byte pull from length extra in inffast.c * - Unroll direct copy to three copies per loop in inffast.c * * 1.2.beta2 4 Dec 2002 * - Change external routine names to reduce potential conflicts * - Correct filename to inffixed.h for fixed tables in inflate.c * - Make hbuf[] unsigned char to match parameter type in inflate.c * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset) * to avoid negation problem on Alphas (64 bit) in inflate.c * * 1.2.beta3 22 Dec 2002 * - Add comments on state->bits assertion in inffast.c * - Add comments on op field in inftrees.h * - Fix bug in reuse of allocated window after inflateReset() * - Remove bit fields--back to byte structure for speed * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths * - Change post-increments to pre-increments in inflate_fast(), PPC biased? * - Add compile time option, POSTINC, to use post-increments instead (Intel?) * - Make MATCH copy in inflate() much faster for when inflate_fast() not used * - Use local copies of stream next and avail values, as well as local bit * buffer and bit count in inflate()--for speed when inflate_fast() not used * * 1.2.beta4 1 Jan 2003 * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings * - Move a comment on output buffer sizes from inffast.c to inflate.c * - Add comments in inffast.c to introduce the inflate_fast() routine * - Rearrange window copies in inflate_fast() for speed and simplification * - Unroll last copy for window match in inflate_fast() * - Use local copies of window variables in inflate_fast() for speed * - Pull out common write == 0 case for speed in inflate_fast() * - Make op and len in inflate_fast() unsigned for consistency * - Add FAR to lcode and dcode declarations in inflate_fast() * - Simplified bad distance check in inflate_fast() * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new * source file infback.c to provide a call-back interface to inflate for * programs like gzip and unzip -- uses window as output buffer to avoid * window copying * * 1.2.beta5 1 Jan 2003 * - Improved inflateBack() interface to allow the caller to provide initial * input in strm. * - Fixed stored blocks bug in inflateBack() * * 1.2.beta6 4 Jan 2003 * - Added comments in inffast.c on effectiveness of POSTINC * - Typecasting all around to reduce compiler warnings * - Changed loops from while (1) or do {} while (1) to for (;;), again to * make compilers happy * - Changed type of window in inflateBackInit() to unsigned char * * * 1.2.beta7 27 Jan 2003 * - Changed many types to unsigned or unsigned short to avoid warnings * - Added inflateCopy() function * * 1.2.0 9 Mar 2003 * - Changed inflateBack() interface to provide separate opaque descriptors * for the in() and out() functions * - Changed inflateBack() argument and in_func typedef to swap the length * and buffer address return values for the input function * - Check next_in and next_out for Z_NULL on entry to inflate() * * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. */ #include "zutil.h" #include "inftrees.h" #include "inflate.h" #include "inffast.h" #ifdef MAKEFIXED # ifndef BUILDFIXED # define BUILDFIXED # endif #endif /* function prototypes */ local void fixedtables OF((struct inflate_state FAR *state)); local int updatewindow OF((z_streamp strm, unsigned out)); #ifdef BUILDFIXED void makefixed OF((void)); #endif local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf, unsigned len)); int ZEXPORT inflateReset(strm) z_streamp strm; { struct inflate_state FAR *state; if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; strm->total_in = strm->total_out = state->total = 0; strm->msg = Z_NULL; strm->adler = 1; /* to support ill-conceived Java test suite */ state->mode = HEAD; state->last = 0; state->havedict = 0; state->dmax = 32768U; state->head = Z_NULL; state->wsize = 0; state->whave = 0; state->write = 0; state->hold = 0; state->bits = 0; state->lencode = state->distcode = state->next = state->codes; Tracev((stderr, "inflate: reset\n")); return Z_OK; } int ZEXPORT inflatePrime(strm, bits, value) z_streamp strm; int bits; int value; { struct inflate_state FAR *state; if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR; value &= (1L << bits) - 1; state->hold += value << state->bits; state->bits += bits; return Z_OK; } int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) z_streamp strm; int windowBits; const char *version; int stream_size; { struct inflate_state FAR *state; if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || stream_size != (int)(sizeof(z_stream))) return Z_VERSION_ERROR; if (strm == Z_NULL) return Z_STREAM_ERROR; strm->msg = Z_NULL; /* in case we return an error */ if (strm->zalloc == (alloc_func)0) { strm->zalloc = zcalloc; strm->opaque = (voidpf)0; } if (strm->zfree == (free_func)0) strm->zfree = zcfree; state = (struct inflate_state FAR *) ZALLOC(strm, 1, sizeof(struct inflate_state)); if (state == Z_NULL) return Z_MEM_ERROR; Tracev((stderr, "inflate: allocated\n")); strm->state = (struct internal_state FAR *)state; if (windowBits < 0) { state->wrap = 0; windowBits = -windowBits; } else { state->wrap = (windowBits >> 4) + 1; #ifdef GUNZIP if (windowBits < 48) windowBits &= 15; #endif } if (windowBits < 8 || windowBits > 15) { ZFREE(strm, state); strm->state = Z_NULL; return Z_STREAM_ERROR; } state->wbits = (unsigned)windowBits; state->window = Z_NULL; return inflateReset(strm); } int ZEXPORT inflateInit_(strm, version, stream_size) z_streamp strm; const char *version; int stream_size; { return inflateInit2_(strm, DEF_WBITS, version, stream_size); } /* Return state with length and distance decoding tables and index sizes set to fixed code decoding. Normally this returns fixed tables from inffixed.h. If BUILDFIXED is defined, then instead this routine builds the tables the first time it's called, and returns those tables the first time and thereafter. This reduces the size of the code by about 2K bytes, in exchange for a little execution time. However, BUILDFIXED should not be used for threaded applications, since the rewriting of the tables and virgin may not be thread-safe. */ local void fixedtables(state) struct inflate_state FAR *state; { #ifdef BUILDFIXED static int virgin = 1; static code *lenfix, *distfix; static code fixed[544]; /* build fixed huffman tables if first call (may not be thread safe) */ if (virgin) { unsigned sym, bits; static code *next; /* literal/length table */ sym = 0; while (sym < 144) state->lens[sym++] = 8; while (sym < 256) state->lens[sym++] = 9; while (sym < 280) state->lens[sym++] = 7; while (sym < 288) state->lens[sym++] = 8; next = fixed; lenfix = next; bits = 9; inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); /* distance table */ sym = 0; while (sym < 32) state->lens[sym++] = 5; distfix = next; bits = 5; inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); /* do this just once */ virgin = 0; } #else /* !BUILDFIXED */ # include "inffixed.h" #endif /* BUILDFIXED */ state->lencode = lenfix; state->lenbits = 9; state->distcode = distfix; state->distbits = 5; } #ifdef MAKEFIXED #include /* Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also defines BUILDFIXED, so the tables are built on the fly. makefixed() writes those tables to stdout, which would be piped to inffixed.h. A small program can simply call makefixed to do this: void makefixed(void); int main(void) { makefixed(); return 0; } Then that can be linked with zlib built with MAKEFIXED defined and run: a.out > inffixed.h */ void makefixed() { unsigned low, size; struct inflate_state state; fixedtables(&state); puts(" /* inffixed.h -- table for decoding fixed codes"); puts(" * Generated automatically by makefixed()."); puts(" */"); puts(""); puts(" /* WARNING: this file should *not* be used by applications."); puts(" It is part of the implementation of this library and is"); puts(" subject to change. Applications should only use zlib.h."); puts(" */"); puts(""); size = 1U << 9; printf(" static const code lenfix[%u] = {", size); low = 0; for (;;) { if ((low % 7) == 0) printf("\n "); printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits, state.lencode[low].val); if (++low == size) break; putchar(','); } puts("\n };"); size = 1U << 5; printf("\n static const code distfix[%u] = {", size); low = 0; for (;;) { if ((low % 6) == 0) printf("\n "); printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, state.distcode[low].val); if (++low == size) break; putchar(','); } puts("\n };"); } #endif /* MAKEFIXED */ /* Update the window with the last wsize (normally 32K) bytes written before returning. If window does not exist yet, create it. This is only called when a window is already in use, or when output has been written during this inflate call, but the end of the deflate stream has not been reached yet. It is also called to create a window for dictionary data when a dictionary is loaded. Providing output buffers larger than 32K to inflate() should provide a speed advantage, since only the last 32K of output is copied to the sliding window upon return from inflate(), and since all distances after the first 32K of output will fall in the output data, making match copies simpler and faster. The advantage may be dependent on the size of the processor's data caches. */ local int updatewindow(strm, out) z_streamp strm; unsigned out; { struct inflate_state FAR *state; unsigned copy, dist; state = (struct inflate_state FAR *)strm->state; /* if it hasn't been done already, allocate space for the window */ if (state->window == Z_NULL) { state->window = (unsigned char FAR *) ZALLOC(strm, 1U << state->wbits, sizeof(unsigned char)); if (state->window == Z_NULL) return 1; } /* if window not in use yet, initialize */ if (state->wsize == 0) { state->wsize = 1U << state->wbits; state->write = 0; state->whave = 0; } /* copy state->wsize or less output bytes into the circular window */ copy = out - strm->avail_out; if (copy >= state->wsize) { zmemcpy(state->window, strm->next_out - state->wsize, state->wsize); state->write = 0; state->whave = state->wsize; } else { dist = state->wsize - state->write; if (dist > copy) dist = copy; zmemcpy(state->window + state->write, strm->next_out - copy, dist); copy -= dist; if (copy) { zmemcpy(state->window, strm->next_out - copy, copy); state->write = copy; state->whave = state->wsize; } else { state->write += dist; if (state->write == state->wsize) state->write = 0; if (state->whave < state->wsize) state->whave += dist; } } return 0; } /* Macros for inflate(): */ /* check function to use adler32() for zlib or crc32() for gzip */ #ifdef GUNZIP # define UPDATE(check, buf, len) \ (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) #else # define UPDATE(check, buf, len) adler32(check, buf, len) #endif /* check macros for header crc */ #ifdef GUNZIP # define CRC2(check, word) \ do { \ hbuf[0] = (unsigned char)(word); \ hbuf[1] = (unsigned char)((word) >> 8); \ check = crc32(check, hbuf, 2); \ } while (0) # define CRC4(check, word) \ do { \ hbuf[0] = (unsigned char)(word); \ hbuf[1] = (unsigned char)((word) >> 8); \ hbuf[2] = (unsigned char)((word) >> 16); \ hbuf[3] = (unsigned char)((word) >> 24); \ check = crc32(check, hbuf, 4); \ } while (0) #endif /* Load registers with state in inflate() for speed */ #define LOAD() \ do { \ put = strm->next_out; \ left = strm->avail_out; \ next = strm->next_in; \ have = strm->avail_in; \ hold = state->hold; \ bits = state->bits; \ } while (0) /* Restore state from registers in inflate() */ #define RESTORE() \ do { \ strm->next_out = put; \ strm->avail_out = left; \ strm->next_in = next; \ strm->avail_in = have; \ state->hold = hold; \ state->bits = bits; \ } while (0) /* Clear the input bit accumulator */ #define INITBITS() \ do { \ hold = 0; \ bits = 0; \ } while (0) /* Get a byte of input into the bit accumulator, or return from inflate() if there is no input available. */ #define PULLBYTE() \ do { \ if (have == 0) goto inf_leave; \ have--; \ hold += (unsigned long)(*next++) << bits; \ bits += 8; \ } while (0) /* Assure that there are at least n bits in the bit accumulator. If there is not enough available input to do that, then return from inflate(). */ #define NEEDBITS(n) \ do { \ while (bits < (unsigned)(n)) \ PULLBYTE(); \ } while (0) /* Return the low n bits of the bit accumulator (n < 16) */ #define BITS(n) \ ((unsigned)hold & ((1U << (n)) - 1)) /* Remove n bits from the bit accumulator */ #define DROPBITS(n) \ do { \ hold >>= (n); \ bits -= (unsigned)(n); \ } while (0) /* Remove zero to seven bits as needed to go to a byte boundary */ #define BYTEBITS() \ do { \ hold >>= bits & 7; \ bits -= bits & 7; \ } while (0) /* Reverse the bytes in a 32-bit value */ #define REVERSE(q) \ ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) /* inflate() uses a state machine to process as much input data and generate as much output data as possible before returning. The state machine is structured roughly as follows: for (;;) switch (state) { ... case STATEn: if (not enough input data or output space to make progress) return; ... make progress ... state = STATEm; break; ... } so when inflate() is called again, the same case is attempted again, and if the appropriate resources are provided, the machine proceeds to the next state. The NEEDBITS() macro is usually the way the state evaluates whether it can proceed or should return. NEEDBITS() does the return if the requested bits are not available. The typical use of the BITS macros is: NEEDBITS(n); ... do something with BITS(n) ... DROPBITS(n); where NEEDBITS(n) either returns from inflate() if there isn't enough input left to load n bits into the accumulator, or it continues. BITS(n) gives the low n bits in the accumulator. When done, DROPBITS(n) drops the low n bits off the accumulator. INITBITS() clears the accumulator and sets the number of available bits to zero. BYTEBITS() discards just enough bits to put the accumulator on a byte boundary. After BYTEBITS() and a NEEDBITS(8), then BITS(8) would return the next byte in the stream. NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return if there is no input available. The decoding of variable length codes uses PULLBYTE() directly in order to pull just enough bytes to decode the next code, and no more. Some states loop until they get enough input, making sure that enough state information is maintained to continue the loop where it left off if NEEDBITS() returns in the loop. For example, want, need, and keep would all have to actually be part of the saved state in case NEEDBITS() returns: case STATEw: while (want < need) { NEEDBITS(n); keep[want++] = BITS(n); DROPBITS(n); } state = STATEx; case STATEx: As shown above, if the next state is also the next case, then the break is omitted. A state may also return if there is not enough output space available to complete that state. Those states are copying stored data, writing a literal byte, and copying a matching string. When returning, a "goto inf_leave" is used to update the total counters, update the check value, and determine whether any progress has been made during that inflate() call in order to return the proper return code. Progress is defined as a change in either strm->avail_in or strm->avail_out. When there is a window, goto inf_leave will update the window with the last output written. If a goto inf_leave occurs in the middle of decompression and there is no window currently, goto inf_leave will create one and copy output to the window for the next call of inflate(). In this implementation, the flush parameter of inflate() only affects the return code (per zlib.h). inflate() always writes as much as possible to strm->next_out, given the space available and the provided input--the effect documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers the allocation of and copying into a sliding window until necessary, which provides the effect documented in zlib.h for Z_FINISH when the entire input stream available. So the only thing the flush parameter actually does is: when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it will return Z_BUF_ERROR if it has not reached the end of the stream. */ int ZEXPORT inflate(strm, flush) z_streamp strm; int flush; { struct inflate_state FAR *state; unsigned char FAR *next; /* next input */ unsigned char FAR *put; /* next output */ unsigned have, left; /* available input and output */ unsigned long hold; /* bit buffer */ unsigned bits; /* bits in bit buffer */ unsigned in, out; /* save starting available input and output */ unsigned copy; /* number of stored or match bytes to copy */ unsigned char FAR *from; /* where to copy match bytes from */ code this; /* current decoding table entry */ code last; /* parent table entry */ unsigned len; /* length to copy for repeats, bits to drop */ int ret; /* return code */ #ifdef GUNZIP unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ #endif static const unsigned short order[19] = /* permutation of code lengths */ {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL || (strm->next_in == Z_NULL && strm->avail_in != 0)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ LOAD(); in = have; out = left; ret = Z_OK; for (;;) switch (state->mode) { case HEAD: if (state->wrap == 0) { state->mode = TYPEDO; break; } NEEDBITS(16); #ifdef GUNZIP if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ state->check = crc32(0L, Z_NULL, 0); CRC2(state->check, hold); INITBITS(); state->mode = FLAGS; break; } state->flags = 0; /* expect zlib header */ if (state->head != Z_NULL) state->head->done = -1; if (!(state->wrap & 1) || /* check if zlib header allowed */ #else if ( #endif ((BITS(8) << 8) + (hold >> 8)) % 31) { strm->msg = (char *)"incorrect header check"; state->mode = BAD; break; } if (BITS(4) != Z_DEFLATED) { strm->msg = (char *)"unknown compression method"; state->mode = BAD; break; } DROPBITS(4); len = BITS(4) + 8; if (len > state->wbits) { strm->msg = (char *)"invalid window size"; state->mode = BAD; break; } state->dmax = 1U << len; Tracev((stderr, "inflate: zlib header ok\n")); strm->adler = state->check = adler32(0L, Z_NULL, 0); state->mode = hold & 0x200 ? DICTID : TYPE; INITBITS(); break; #ifdef GUNZIP case FLAGS: NEEDBITS(16); state->flags = (int)(hold); if ((state->flags & 0xff) != Z_DEFLATED) { strm->msg = (char *)"unknown compression method"; state->mode = BAD; break; } if (state->flags & 0xe000) { strm->msg = (char *)"unknown header flags set"; state->mode = BAD; break; } if (state->head != Z_NULL) state->head->text = (int)((hold >> 8) & 1); if (state->flags & 0x0200) CRC2(state->check, hold); INITBITS(); state->mode = TIME; case TIME: NEEDBITS(32); if (state->head != Z_NULL) state->head->time = hold; if (state->flags & 0x0200) CRC4(state->check, hold); INITBITS(); state->mode = OS; case OS: NEEDBITS(16); if (state->head != Z_NULL) { state->head->xflags = (int)(hold & 0xff); state->head->os = (int)(hold >> 8); } if (state->flags & 0x0200) CRC2(state->check, hold); INITBITS(); state->mode = EXLEN; case EXLEN: if (state->flags & 0x0400) { NEEDBITS(16); state->length = (unsigned)(hold); if (state->head != Z_NULL) state->head->extra_len = (unsigned)hold; if (state->flags & 0x0200) CRC2(state->check, hold); INITBITS(); } else if (state->head != Z_NULL) state->head->extra = Z_NULL; state->mode = EXTRA; case EXTRA: if (state->flags & 0x0400) { copy = state->length; if (copy > have) copy = have; if (copy) { if (state->head != Z_NULL && state->head->extra != Z_NULL) { len = state->head->extra_len - state->length; zmemcpy(state->head->extra + len, next, len + copy > state->head->extra_max ? state->head->extra_max - len : copy); } if (state->flags & 0x0200) state->check = crc32(state->check, next, copy); have -= copy; next += copy; state->length -= copy; } if (state->length) goto inf_leave; } state->length = 0; state->mode = NAME; case NAME: if (state->flags & 0x0800) { if (have == 0) goto inf_leave; copy = 0; do { len = (unsigned)(next[copy++]); if (state->head != Z_NULL && state->head->name != Z_NULL && state->length < state->head->name_max) state->head->name[state->length++] = len; } while (len && copy < have); if (state->flags & 0x0200) state->check = crc32(state->check, next, copy); have -= copy; next += copy; if (len) goto inf_leave; } else if (state->head != Z_NULL) state->head->name = Z_NULL; state->length = 0; state->mode = COMMENT; case COMMENT: if (state->flags & 0x1000) { if (have == 0) goto inf_leave; copy = 0; do { len = (unsigned)(next[copy++]); if (state->head != Z_NULL && state->head->comment != Z_NULL && state->length < state->head->comm_max) state->head->comment[state->length++] = len; } while (len && copy < have); if (state->flags & 0x0200) state->check = crc32(state->check, next, copy); have -= copy; next += copy; if (len) goto inf_leave; } else if (state->head != Z_NULL) state->head->comment = Z_NULL; state->mode = HCRC; case HCRC: if (state->flags & 0x0200) { NEEDBITS(16); if (hold != (state->check & 0xffff)) { strm->msg = (char *)"header crc mismatch"; state->mode = BAD; break; } INITBITS(); } if (state->head != Z_NULL) { state->head->hcrc = (int)((state->flags >> 9) & 1); state->head->done = 1; } strm->adler = state->check = crc32(0L, Z_NULL, 0); state->mode = TYPE; break; #endif case DICTID: NEEDBITS(32); strm->adler = state->check = REVERSE(hold); INITBITS(); state->mode = DICT; case DICT: if (state->havedict == 0) { RESTORE(); return Z_NEED_DICT; } strm->adler = state->check = adler32(0L, Z_NULL, 0); state->mode = TYPE; case TYPE: if (flush == Z_BLOCK) goto inf_leave; case TYPEDO: if (state->last) { BYTEBITS(); state->mode = CHECK; break; } NEEDBITS(3); state->last = BITS(1); DROPBITS(1); switch (BITS(2)) { case 0: /* stored block */ Tracev((stderr, "inflate: stored block%s\n", state->last ? " (last)" : "")); state->mode = STORED; break; case 1: /* fixed block */ fixedtables(state); Tracev((stderr, "inflate: fixed codes block%s\n", state->last ? " (last)" : "")); state->mode = LEN; /* decode codes */ break; case 2: /* dynamic block */ Tracev((stderr, "inflate: dynamic codes block%s\n", state->last ? " (last)" : "")); state->mode = TABLE; break; case 3: strm->msg = (char *)"invalid block type"; state->mode = BAD; } DROPBITS(2); break; case STORED: BYTEBITS(); /* go to byte boundary */ NEEDBITS(32); if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { strm->msg = (char *)"invalid stored block lengths"; state->mode = BAD; break; } state->length = (unsigned)hold & 0xffff; Tracev((stderr, "inflate: stored length %u\n", state->length)); INITBITS(); state->mode = COPY; case COPY: copy = state->length; if (copy) { if (copy > have) copy = have; if (copy > left) copy = left; if (copy == 0) goto inf_leave; zmemcpy(put, next, copy); have -= copy; next += copy; left -= copy; put += copy; state->length -= copy; break; } Tracev((stderr, "inflate: stored end\n")); state->mode = TYPE; break; case TABLE: NEEDBITS(14); state->nlen = BITS(5) + 257; DROPBITS(5); state->ndist = BITS(5) + 1; DROPBITS(5); state->ncode = BITS(4) + 4; DROPBITS(4); #ifndef PKZIP_BUG_WORKAROUND if (state->nlen > 286 || state->ndist > 30) { strm->msg = (char *)"too many length or distance symbols"; state->mode = BAD; break; } #endif Tracev((stderr, "inflate: table sizes ok\n")); state->have = 0; state->mode = LENLENS; case LENLENS: while (state->have < state->ncode) { NEEDBITS(3); state->lens[order[state->have++]] = (unsigned short)BITS(3); DROPBITS(3); } while (state->have < 19) state->lens[order[state->have++]] = 0; state->next = state->codes; state->lencode = (code const FAR *)(state->next); state->lenbits = 7; ret = inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); if (ret) { strm->msg = (char *)"invalid code lengths set"; state->mode = BAD; break; } Tracev((stderr, "inflate: code lengths ok\n")); state->have = 0; state->mode = CODELENS; case CODELENS: while (state->have < state->nlen + state->ndist) { for (;;) { this = state->lencode[BITS(state->lenbits)]; if ((unsigned)(this.bits) <= bits) break; PULLBYTE(); } if (this.val < 16) { NEEDBITS(this.bits); DROPBITS(this.bits); state->lens[state->have++] = this.val; } else { if (this.val == 16) { NEEDBITS(this.bits + 2); DROPBITS(this.bits); if (state->have == 0) { strm->msg = (char *)"invalid bit length repeat"; state->mode = BAD; break; } len = state->lens[state->have - 1]; copy = 3 + BITS(2); DROPBITS(2); } else if (this.val == 17) { NEEDBITS(this.bits + 3); DROPBITS(this.bits); len = 0; copy = 3 + BITS(3); DROPBITS(3); } else { NEEDBITS(this.bits + 7); DROPBITS(this.bits); len = 0; copy = 11 + BITS(7); DROPBITS(7); } if (state->have + copy > state->nlen + state->ndist) { strm->msg = (char *)"invalid bit length repeat"; state->mode = BAD; break; } while (copy--) state->lens[state->have++] = (unsigned short)len; } } /* handle error breaks in while */ if (state->mode == BAD) break; /* build code tables */ state->next = state->codes; state->lencode = (code const FAR *)(state->next); state->lenbits = 9; ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); if (ret) { strm->msg = (char *)"invalid literal/lengths set"; state->mode = BAD; break; } state->distcode = (code const FAR *)(state->next); state->distbits = 6; ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, &(state->next), &(state->distbits), state->work); if (ret) { strm->msg = (char *)"invalid distances set"; state->mode = BAD; break; } Tracev((stderr, "inflate: codes ok\n")); state->mode = LEN; case LEN: if (have >= 6 && left >= 258) { RESTORE(); inflate_fast(strm, out); LOAD(); break; } for (;;) { this = state->lencode[BITS(state->lenbits)]; if ((unsigned)(this.bits) <= bits) break; PULLBYTE(); } if (this.op && (this.op & 0xf0) == 0) { last = this; for (;;) { this = state->lencode[last.val + (BITS(last.bits + last.op) >> last.bits)]; if ((unsigned)(last.bits + this.bits) <= bits) break; PULLBYTE(); } DROPBITS(last.bits); } DROPBITS(this.bits); state->length = (unsigned)this.val; if ((int)(this.op) == 0) { Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? "inflate: literal '%c'\n" : "inflate: literal 0x%02x\n", this.val)); state->mode = LIT; break; } if (this.op & 32) { Tracevv((stderr, "inflate: end of block\n")); state->mode = TYPE; break; } if (this.op & 64) { strm->msg = (char *)"invalid literal/length code"; state->mode = BAD; break; } state->extra = (unsigned)(this.op) & 15; state->mode = LENEXT; case LENEXT: if (state->extra) { NEEDBITS(state->extra); state->length += BITS(state->extra); DROPBITS(state->extra); } Tracevv((stderr, "inflate: length %u\n", state->length)); state->mode = DIST; case DIST: for (;;) { this = state->distcode[BITS(state->distbits)]; if ((unsigned)(this.bits) <= bits) break; PULLBYTE(); } if ((this.op & 0xf0) == 0) { last = this; for (;;) { this = state->distcode[last.val + (BITS(last.bits + last.op) >> last.bits)]; if ((unsigned)(last.bits + this.bits) <= bits) break; PULLBYTE(); } DROPBITS(last.bits); } DROPBITS(this.bits); if (this.op & 64) { strm->msg = (char *)"invalid distance code"; state->mode = BAD; break; } state->offset = (unsigned)this.val; state->extra = (unsigned)(this.op) & 15; state->mode = DISTEXT; case DISTEXT: if (state->extra) { NEEDBITS(state->extra); state->offset += BITS(state->extra); DROPBITS(state->extra); } #ifdef INFLATE_STRICT if (state->offset > state->dmax) { strm->msg = (char *)"invalid distance too far back"; state->mode = BAD; break; } #endif if (state->offset > state->whave + out - left) { strm->msg = (char *)"invalid distance too far back"; state->mode = BAD; break; } Tracevv((stderr, "inflate: distance %u\n", state->offset)); state->mode = MATCH; case MATCH: if (left == 0) goto inf_leave; copy = out - left; if (state->offset > copy) { /* copy from window */ copy = state->offset - copy; if (copy > state->write) { copy -= state->write; from = state->window + (state->wsize - copy); } else from = state->window + (state->write - copy); if (copy > state->length) copy = state->length; } else { /* copy from output */ from = put - state->offset; copy = state->length; } if (copy > left) copy = left; left -= copy; state->length -= copy; do { *put++ = *from++; } while (--copy); if (state->length == 0) state->mode = LEN; break; case LIT: if (left == 0) goto inf_leave; *put++ = (unsigned char)(state->length); left--; state->mode = LEN; break; case CHECK: if (state->wrap) { NEEDBITS(32); out -= left; strm->total_out += out; state->total += out; if (out) strm->adler = state->check = UPDATE(state->check, put - out, out); out = left; if (( #ifdef GUNZIP state->flags ? hold : #endif REVERSE(hold)) != state->check) { strm->msg = (char *)"incorrect data check"; state->mode = BAD; break; } INITBITS(); Tracev((stderr, "inflate: check matches trailer\n")); } #ifdef GUNZIP state->mode = LENGTH; case LENGTH: if (state->wrap && state->flags) { NEEDBITS(32); if (hold != (state->total & 0xffffffffUL)) { strm->msg = (char *)"incorrect length check"; state->mode = BAD; break; } INITBITS(); Tracev((stderr, "inflate: length matches trailer\n")); } #endif state->mode = DONE; case DONE: ret = Z_STREAM_END; goto inf_leave; case BAD: ret = Z_DATA_ERROR; goto inf_leave; case MEM: return Z_MEM_ERROR; case SYNC: default: return Z_STREAM_ERROR; } /* Return from inflate(), updating the total counts and the check value. If there was no progress during the inflate() call, return a buffer error. Call updatewindow() to create and/or update the window state. Note: a memory error from inflate() is non-recoverable. */ inf_leave: RESTORE(); if (state->wsize || (state->mode < CHECK && out != strm->avail_out)) if (updatewindow(strm, out)) { state->mode = MEM; return Z_MEM_ERROR; } in -= strm->avail_in; out -= strm->avail_out; strm->total_in += in; strm->total_out += out; state->total += out; if (state->wrap && out) strm->adler = state->check = UPDATE(state->check, strm->next_out - out, out); strm->data_type = state->bits + (state->last ? 64 : 0) + (state->mode == TYPE ? 128 : 0); if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) ret = Z_BUF_ERROR; return ret; } int ZEXPORT inflateEnd(strm) z_streamp strm; { struct inflate_state FAR *state; if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (state->window != Z_NULL) ZFREE(strm, state->window); ZFREE(strm, strm->state); strm->state = Z_NULL; Tracev((stderr, "inflate: end\n")); return Z_OK; } int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) z_streamp strm; const Bytef *dictionary; uInt dictLength; { struct inflate_state FAR *state; unsigned long id; /* check state */ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (state->wrap != 0 && state->mode != DICT) return Z_STREAM_ERROR; /* check for correct dictionary id */ if (state->mode == DICT) { id = adler32(0L, Z_NULL, 0); id = adler32(id, dictionary, dictLength); if (id != state->check) return Z_DATA_ERROR; } /* copy dictionary to window */ if (updatewindow(strm, strm->avail_out)) { state->mode = MEM; return Z_MEM_ERROR; } if (dictLength > state->wsize) { zmemcpy(state->window, dictionary + dictLength - state->wsize, state->wsize); state->whave = state->wsize; } else { zmemcpy(state->window + state->wsize - dictLength, dictionary, dictLength); state->whave = dictLength; } state->havedict = 1; Tracev((stderr, "inflate: dictionary set\n")); return Z_OK; } int ZEXPORT inflateGetHeader(strm, head) z_streamp strm; gz_headerp head; { struct inflate_state FAR *state; /* check state */ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; /* save header structure */ state->head = head; head->done = 0; return Z_OK; } /* Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found or when out of input. When called, *have is the number of pattern bytes found in order so far, in 0..3. On return *have is updated to the new state. If on return *have equals four, then the pattern was found and the return value is how many bytes were read including the last byte of the pattern. If *have is less than four, then the pattern has not been found yet and the return value is len. In the latter case, syncsearch() can be called again with more data and the *have state. *have is initialized to zero for the first call. */ local unsigned syncsearch(have, buf, len) unsigned FAR *have; unsigned char FAR *buf; unsigned len; { unsigned got; unsigned next; got = *have; next = 0; while (next < len && got < 4) { if ((int)(buf[next]) == (got < 2 ? 0 : 0xff)) got++; else if (buf[next]) got = 0; else got = 4 - got; next++; } *have = got; return next; } int ZEXPORT inflateSync(strm) z_streamp strm; { unsigned len; /* number of bytes to look at or looked at */ unsigned long in, out; /* temporary to save total_in and total_out */ unsigned char buf[4]; /* to restore bit buffer to byte string */ struct inflate_state FAR *state; /* check parameters */ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; /* if first time, start search in bit buffer */ if (state->mode != SYNC) { state->mode = SYNC; state->hold <<= state->bits & 7; state->bits -= state->bits & 7; len = 0; while (state->bits >= 8) { buf[len++] = (unsigned char)(state->hold); state->hold >>= 8; state->bits -= 8; } state->have = 0; syncsearch(&(state->have), buf, len); } /* search available input */ len = syncsearch(&(state->have), strm->next_in, strm->avail_in); strm->avail_in -= len; strm->next_in += len; strm->total_in += len; /* return no joy or set up to restart inflate() on a new block */ if (state->have != 4) return Z_DATA_ERROR; in = strm->total_in; out = strm->total_out; inflateReset(strm); strm->total_in = in; strm->total_out = out; state->mode = TYPE; return Z_OK; } /* Returns true if inflate is currently at the end of a block generated by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored block. When decompressing, PPP checks that at the end of input packet, inflate is waiting for these length bytes. */ int ZEXPORT inflateSyncPoint(strm) z_streamp strm; { struct inflate_state FAR *state; if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; return state->mode == STORED && state->bits == 0; } int ZEXPORT inflateCopy(dest, source) z_streamp dest; z_streamp source; { struct inflate_state FAR *state; struct inflate_state FAR *copy; unsigned char FAR *window; unsigned wsize; /* check input */ if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || source->zalloc == (alloc_func)0 || source->zfree == (free_func)0) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)source->state; /* allocate space */ copy = (struct inflate_state FAR *) ZALLOC(source, 1, sizeof(struct inflate_state)); if (copy == Z_NULL) return Z_MEM_ERROR; window = Z_NULL; if (state->window != Z_NULL) { window = (unsigned char FAR *) ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); if (window == Z_NULL) { ZFREE(source, copy); return Z_MEM_ERROR; } } /* copy state */ zmemcpy(dest, source, sizeof(z_stream)); zmemcpy(copy, state, sizeof(struct inflate_state)); if (state->lencode >= state->codes && state->lencode <= state->codes + ENOUGH - 1) { copy->lencode = copy->codes + (state->lencode - state->codes); copy->distcode = copy->codes + (state->distcode - state->codes); } copy->next = copy->codes + (state->next - state->codes); if (window != Z_NULL) { wsize = 1U << state->wbits; zmemcpy(window, state->window, wsize); } copy->window = window; dest->state = (struct internal_state FAR *)copy; return Z_OK; } sks-ecc-0.93/zlib/zconf.h0000644000175000017500000002251010707473572014203 0ustar nachonacho/* zconf.h -- configuration of the zlib compression library * Copyright (C) 1995-2005 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #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 deflateBound z_deflateBound # define deflatePrime z_deflatePrime # define inflateInit2_ z_inflateInit2_ # define inflateSetDictionary z_inflateSetDictionary # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateCopy z_inflateCopy # define inflateReset z_inflateReset # define inflateBack z_inflateBack # define inflateBackEnd z_inflateBackEnd # define compress z_compress # define compress2 z_compress2 # define compressBound z_compressBound # define uncompress z_uncompress # define adler32 z_adler32 # define crc32 z_crc32 # define get_crc_table z_get_crc_table # define zError z_zError # define alloc_func z_alloc_func # define free_func z_free_func # define in_func z_in_func # define out_func z_out_func # 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(__MSDOS__) && !defined(MSDOS) # define MSDOS #endif #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) # define OS2 #endif #if defined(_WINDOWS) && !defined(WINDOWS) # define WINDOWS #endif #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) # ifndef WIN32 # define WIN32 # endif #endif #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) # ifndef SYS16BIT # define SYS16BIT # endif # endif #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). */ #ifdef SYS16BIT # define MAXSEG_64K #endif #ifdef MSDOS # define UNALIGNED_OK #endif #ifdef __STDC_VERSION__ # ifndef STDC # define STDC # endif # if __STDC_VERSION__ >= 199901L # ifndef STDC99 # define STDC99 # endif # endif #endif #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) # define STDC #endif #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) # define STDC #endif #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) # define STDC #endif #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) # define STDC #endif #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ # define STDC #endif #ifndef STDC # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ # define const /* note: need a more gentle solution here */ # 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 /* 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. */ #ifdef SYS16BIT # if defined(M_I86SM) || defined(M_I86MM) /* MSC small or medium model */ # define SMALL_MEDIUM # ifdef _MSC_VER # define FAR _far # else # define FAR far # endif # endif # if (defined(__SMALL__) || defined(__MEDIUM__)) /* Turbo C small or medium model */ # define SMALL_MEDIUM # ifdef __BORLANDC__ # define FAR _far # else # define FAR far # endif # endif #endif #if defined(WINDOWS) || defined(WIN32) /* If building or using zlib as a DLL, define ZLIB_DLL. * This is not mandatory, but it offers a little performance increase. */ # ifdef ZLIB_DLL # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) # ifdef ZLIB_INTERNAL # define ZEXTERN extern __declspec(dllexport) # else # define ZEXTERN extern __declspec(dllimport) # endif # endif # endif /* ZLIB_DLL */ /* If building or using zlib with the WINAPI/WINAPIV calling convention, * define ZLIB_WINAPI. * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. */ # ifdef ZLIB_WINAPI # ifdef FAR # undef FAR # endif # include /* No need for _export, use ZLIB.DEF instead. */ /* For complete Windows compatibility, use WINAPI, not __stdcall. */ # define ZEXPORT WINAPI # ifdef WIN32 # define ZEXPORTVA WINAPIV # else # define ZEXPORTVA FAR CDECL # endif # endif #endif #if defined (__BEOS__) # ifdef ZLIB_DLL # ifdef ZLIB_INTERNAL # define ZEXPORT __declspec(dllexport) # define ZEXPORTVA __declspec(dllexport) # else # define ZEXPORT __declspec(dllimport) # define ZEXPORTVA __declspec(dllimport) # endif # endif #endif #ifndef ZEXTERN # define ZEXTERN extern #endif #ifndef ZEXPORT # define ZEXPORT #endif #ifndef ZEXPORTVA # define ZEXPORTVA #endif #ifndef FAR # define FAR #endif #if !defined(__MACTYPES__) 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 const *voidpc; typedef void FAR *voidpf; typedef void *voidp; #else typedef Byte const *voidpc; typedef Byte FAR *voidpf; typedef Byte *voidp; #endif #if 1 /* HAVE_UNISTD_H -- this line is updated by ./configure */ # include /* for off_t */ # include /* for SEEK_* and off_t */ # ifdef VMS # include /* for off_t */ # endif # 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 #if defined(__OS400__) # define NO_vsnprintf #endif #if defined(__MVS__) # define NO_vsnprintf # ifdef FAR # undef FAR # endif #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(deflateBound,"DEBND") # pragma map(inflateInit_,"ININ") # pragma map(inflateInit2_,"ININ2") # pragma map(inflateEnd,"INEND") # pragma map(inflateSync,"INSY") # pragma map(inflateSetDictionary,"INSEDI") # pragma map(compressBound,"CMBND") # pragma map(inflate_table,"INTABL") # pragma map(inflate_fast,"INFA") # pragma map(inflate_copyright,"INCOPY") #endif #endif /* ZCONF_H */ sks-ecc-0.93/zlib/INDEX0000644000175000017500000000244610604550750013501 0ustar nachonachoChangeLog history of changes FAQ Frequently Asked Questions about zlib INDEX this file Makefile makefile for Unix (generated by configure) Makefile.in makefile for Unix (template for configure) README guess what algorithm.txt description of the (de)compression algorithm configure configure script for Unix zconf.in.h template for zconf.h (used by configure) amiga/ makefiles for Amiga SAS C as400/ makefiles for IBM AS/400 msdos/ makefiles for MSDOS old/ makefiles for various architectures and zlib documentation files that have not yet been updated for zlib 1.2.x projects/ projects for various Integrated Development Environments qnx/ makefiles for QNX win32/ makefiles for Windows zlib public header files (must be kept): zconf.h zlib.h private source files used to build the zlib library: adler32.c compress.c crc32.c crc32.h deflate.c deflate.h gzio.c infback.c inffast.c inffast.h inffixed.h inflate.c inflate.h inftrees.c inftrees.h trees.c trees.h uncompr.c zutil.c zutil.h source files for sample programs: example.c minigzip.c unsupported contribution by third parties See contrib/README.contrib sks-ecc-0.93/zlib/infback.c0000644000175000017500000005322410604550750014450 0ustar nachonacho/* infback.c -- inflate using a call-back interface * Copyright (C) 1995-2005 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* This code is largely copied from inflate.c. Normally either infback.o or inflate.o would be linked into an application--not both. The interface with inffast.c is retained so that optimized assembler-coded versions of inflate_fast() can be used with either inflate.c or infback.c. */ #include "zutil.h" #include "inftrees.h" #include "inflate.h" #include "inffast.h" /* function prototypes */ local void fixedtables OF((struct inflate_state FAR *state)); /* strm provides memory allocation functions in zalloc and zfree, or Z_NULL to use the library memory allocation functions. windowBits is in the range 8..15, and window is a user-supplied window and output buffer that is 2**windowBits bytes. */ int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) z_streamp strm; int windowBits; unsigned char FAR *window; const char *version; int stream_size; { struct inflate_state FAR *state; if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || stream_size != (int)(sizeof(z_stream))) return Z_VERSION_ERROR; if (strm == Z_NULL || window == Z_NULL || windowBits < 8 || windowBits > 15) return Z_STREAM_ERROR; strm->msg = Z_NULL; /* in case we return an error */ if (strm->zalloc == (alloc_func)0) { strm->zalloc = zcalloc; strm->opaque = (voidpf)0; } if (strm->zfree == (free_func)0) strm->zfree = zcfree; state = (struct inflate_state FAR *)ZALLOC(strm, 1, sizeof(struct inflate_state)); if (state == Z_NULL) return Z_MEM_ERROR; Tracev((stderr, "inflate: allocated\n")); strm->state = (struct internal_state FAR *)state; state->dmax = 32768U; state->wbits = windowBits; state->wsize = 1U << windowBits; state->window = window; state->write = 0; state->whave = 0; return Z_OK; } /* Return state with length and distance decoding tables and index sizes set to fixed code decoding. Normally this returns fixed tables from inffixed.h. If BUILDFIXED is defined, then instead this routine builds the tables the first time it's called, and returns those tables the first time and thereafter. This reduces the size of the code by about 2K bytes, in exchange for a little execution time. However, BUILDFIXED should not be used for threaded applications, since the rewriting of the tables and virgin may not be thread-safe. */ local void fixedtables(state) struct inflate_state FAR *state; { #ifdef BUILDFIXED static int virgin = 1; static code *lenfix, *distfix; static code fixed[544]; /* build fixed huffman tables if first call (may not be thread safe) */ if (virgin) { unsigned sym, bits; static code *next; /* literal/length table */ sym = 0; while (sym < 144) state->lens[sym++] = 8; while (sym < 256) state->lens[sym++] = 9; while (sym < 280) state->lens[sym++] = 7; while (sym < 288) state->lens[sym++] = 8; next = fixed; lenfix = next; bits = 9; inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); /* distance table */ sym = 0; while (sym < 32) state->lens[sym++] = 5; distfix = next; bits = 5; inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); /* do this just once */ virgin = 0; } #else /* !BUILDFIXED */ # include "inffixed.h" #endif /* BUILDFIXED */ state->lencode = lenfix; state->lenbits = 9; state->distcode = distfix; state->distbits = 5; } /* Macros for inflateBack(): */ /* Load returned state from inflate_fast() */ #define LOAD() \ do { \ put = strm->next_out; \ left = strm->avail_out; \ next = strm->next_in; \ have = strm->avail_in; \ hold = state->hold; \ bits = state->bits; \ } while (0) /* Set state from registers for inflate_fast() */ #define RESTORE() \ do { \ strm->next_out = put; \ strm->avail_out = left; \ strm->next_in = next; \ strm->avail_in = have; \ state->hold = hold; \ state->bits = bits; \ } while (0) /* Clear the input bit accumulator */ #define INITBITS() \ do { \ hold = 0; \ bits = 0; \ } while (0) /* Assure that some input is available. If input is requested, but denied, then return a Z_BUF_ERROR from inflateBack(). */ #define PULL() \ do { \ if (have == 0) { \ have = in(in_desc, &next); \ if (have == 0) { \ next = Z_NULL; \ ret = Z_BUF_ERROR; \ goto inf_leave; \ } \ } \ } while (0) /* Get a byte of input into the bit accumulator, or return from inflateBack() with an error if there is no input available. */ #define PULLBYTE() \ do { \ PULL(); \ have--; \ hold += (unsigned long)(*next++) << bits; \ bits += 8; \ } while (0) /* Assure that there are at least n bits in the bit accumulator. If there is not enough available input to do that, then return from inflateBack() with an error. */ #define NEEDBITS(n) \ do { \ while (bits < (unsigned)(n)) \ PULLBYTE(); \ } while (0) /* Return the low n bits of the bit accumulator (n < 16) */ #define BITS(n) \ ((unsigned)hold & ((1U << (n)) - 1)) /* Remove n bits from the bit accumulator */ #define DROPBITS(n) \ do { \ hold >>= (n); \ bits -= (unsigned)(n); \ } while (0) /* Remove zero to seven bits as needed to go to a byte boundary */ #define BYTEBITS() \ do { \ hold >>= bits & 7; \ bits -= bits & 7; \ } while (0) /* Assure that some output space is available, by writing out the window if it's full. If the write fails, return from inflateBack() with a Z_BUF_ERROR. */ #define ROOM() \ do { \ if (left == 0) { \ put = state->window; \ left = state->wsize; \ state->whave = left; \ if (out(out_desc, put, left)) { \ ret = Z_BUF_ERROR; \ goto inf_leave; \ } \ } \ } while (0) /* strm provides the memory allocation functions and window buffer on input, and provides information on the unused input on return. For Z_DATA_ERROR returns, strm will also provide an error message. in() and out() are the call-back input and output functions. When inflateBack() needs more input, it calls in(). When inflateBack() has filled the window with output, or when it completes with data in the window, it calls out() to write out the data. The application must not change the provided input until in() is called again or inflateBack() returns. The application must not change the window/output buffer until inflateBack() returns. in() and out() are called with a descriptor parameter provided in the inflateBack() call. This parameter can be a structure that provides the information required to do the read or write, as well as accumulated information on the input and output such as totals and check values. in() should return zero on failure. out() should return non-zero on failure. If either in() or out() fails, than inflateBack() returns a Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it was in() or out() that caused in the error. Otherwise, inflateBack() returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format error, or Z_MEM_ERROR if it could not allocate memory for the state. inflateBack() can also return Z_STREAM_ERROR if the input parameters are not correct, i.e. strm is Z_NULL or the state was not initialized. */ int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) z_streamp strm; in_func in; void FAR *in_desc; out_func out; void FAR *out_desc; { struct inflate_state FAR *state; unsigned char FAR *next; /* next input */ unsigned char FAR *put; /* next output */ unsigned have, left; /* available input and output */ unsigned long hold; /* bit buffer */ unsigned bits; /* bits in bit buffer */ unsigned copy; /* number of stored or match bytes to copy */ unsigned char FAR *from; /* where to copy match bytes from */ code this; /* current decoding table entry */ code last; /* parent table entry */ unsigned len; /* length to copy for repeats, bits to drop */ int ret; /* return code */ static const unsigned short order[19] = /* permutation of code lengths */ {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; /* Check that the strm exists and that the state was initialized */ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; /* Reset the state */ strm->msg = Z_NULL; state->mode = TYPE; state->last = 0; state->whave = 0; next = strm->next_in; have = next != Z_NULL ? strm->avail_in : 0; hold = 0; bits = 0; put = state->window; left = state->wsize; /* Inflate until end of block marked as last */ for (;;) switch (state->mode) { case TYPE: /* determine and dispatch block type */ if (state->last) { BYTEBITS(); state->mode = DONE; break; } NEEDBITS(3); state->last = BITS(1); DROPBITS(1); switch (BITS(2)) { case 0: /* stored block */ Tracev((stderr, "inflate: stored block%s\n", state->last ? " (last)" : "")); state->mode = STORED; break; case 1: /* fixed block */ fixedtables(state); Tracev((stderr, "inflate: fixed codes block%s\n", state->last ? " (last)" : "")); state->mode = LEN; /* decode codes */ break; case 2: /* dynamic block */ Tracev((stderr, "inflate: dynamic codes block%s\n", state->last ? " (last)" : "")); state->mode = TABLE; break; case 3: strm->msg = (char *)"invalid block type"; state->mode = BAD; } DROPBITS(2); break; case STORED: /* get and verify stored block length */ BYTEBITS(); /* go to byte boundary */ NEEDBITS(32); if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { strm->msg = (char *)"invalid stored block lengths"; state->mode = BAD; break; } state->length = (unsigned)hold & 0xffff; Tracev((stderr, "inflate: stored length %u\n", state->length)); INITBITS(); /* copy stored block from input to output */ while (state->length != 0) { copy = state->length; PULL(); ROOM(); if (copy > have) copy = have; if (copy > left) copy = left; zmemcpy(put, next, copy); have -= copy; next += copy; left -= copy; put += copy; state->length -= copy; } Tracev((stderr, "inflate: stored end\n")); state->mode = TYPE; break; case TABLE: /* get dynamic table entries descriptor */ NEEDBITS(14); state->nlen = BITS(5) + 257; DROPBITS(5); state->ndist = BITS(5) + 1; DROPBITS(5); state->ncode = BITS(4) + 4; DROPBITS(4); #ifndef PKZIP_BUG_WORKAROUND if (state->nlen > 286 || state->ndist > 30) { strm->msg = (char *)"too many length or distance symbols"; state->mode = BAD; break; } #endif Tracev((stderr, "inflate: table sizes ok\n")); /* get code length code lengths (not a typo) */ state->have = 0; while (state->have < state->ncode) { NEEDBITS(3); state->lens[order[state->have++]] = (unsigned short)BITS(3); DROPBITS(3); } while (state->have < 19) state->lens[order[state->have++]] = 0; state->next = state->codes; state->lencode = (code const FAR *)(state->next); state->lenbits = 7; ret = inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); if (ret) { strm->msg = (char *)"invalid code lengths set"; state->mode = BAD; break; } Tracev((stderr, "inflate: code lengths ok\n")); /* get length and distance code code lengths */ state->have = 0; while (state->have < state->nlen + state->ndist) { for (;;) { this = state->lencode[BITS(state->lenbits)]; if ((unsigned)(this.bits) <= bits) break; PULLBYTE(); } if (this.val < 16) { NEEDBITS(this.bits); DROPBITS(this.bits); state->lens[state->have++] = this.val; } else { if (this.val == 16) { NEEDBITS(this.bits + 2); DROPBITS(this.bits); if (state->have == 0) { strm->msg = (char *)"invalid bit length repeat"; state->mode = BAD; break; } len = (unsigned)(state->lens[state->have - 1]); copy = 3 + BITS(2); DROPBITS(2); } else if (this.val == 17) { NEEDBITS(this.bits + 3); DROPBITS(this.bits); len = 0; copy = 3 + BITS(3); DROPBITS(3); } else { NEEDBITS(this.bits + 7); DROPBITS(this.bits); len = 0; copy = 11 + BITS(7); DROPBITS(7); } if (state->have + copy > state->nlen + state->ndist) { strm->msg = (char *)"invalid bit length repeat"; state->mode = BAD; break; } while (copy--) state->lens[state->have++] = (unsigned short)len; } } /* handle error breaks in while */ if (state->mode == BAD) break; /* build code tables */ state->next = state->codes; state->lencode = (code const FAR *)(state->next); state->lenbits = 9; ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); if (ret) { strm->msg = (char *)"invalid literal/lengths set"; state->mode = BAD; break; } state->distcode = (code const FAR *)(state->next); state->distbits = 6; ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, &(state->next), &(state->distbits), state->work); if (ret) { strm->msg = (char *)"invalid distances set"; state->mode = BAD; break; } Tracev((stderr, "inflate: codes ok\n")); state->mode = LEN; case LEN: /* use inflate_fast() if we have enough input and output */ if (have >= 6 && left >= 258) { RESTORE(); if (state->whave < state->wsize) state->whave = state->wsize - left; inflate_fast(strm, state->wsize); LOAD(); break; } /* get a literal, length, or end-of-block code */ for (;;) { this = state->lencode[BITS(state->lenbits)]; if ((unsigned)(this.bits) <= bits) break; PULLBYTE(); } if (this.op && (this.op & 0xf0) == 0) { last = this; for (;;) { this = state->lencode[last.val + (BITS(last.bits + last.op) >> last.bits)]; if ((unsigned)(last.bits + this.bits) <= bits) break; PULLBYTE(); } DROPBITS(last.bits); } DROPBITS(this.bits); state->length = (unsigned)this.val; /* process literal */ if (this.op == 0) { Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ? "inflate: literal '%c'\n" : "inflate: literal 0x%02x\n", this.val)); ROOM(); *put++ = (unsigned char)(state->length); left--; state->mode = LEN; break; } /* process end of block */ if (this.op & 32) { Tracevv((stderr, "inflate: end of block\n")); state->mode = TYPE; break; } /* invalid code */ if (this.op & 64) { strm->msg = (char *)"invalid literal/length code"; state->mode = BAD; break; } /* length code -- get extra bits, if any */ state->extra = (unsigned)(this.op) & 15; if (state->extra != 0) { NEEDBITS(state->extra); state->length += BITS(state->extra); DROPBITS(state->extra); } Tracevv((stderr, "inflate: length %u\n", state->length)); /* get distance code */ for (;;) { this = state->distcode[BITS(state->distbits)]; if ((unsigned)(this.bits) <= bits) break; PULLBYTE(); } if ((this.op & 0xf0) == 0) { last = this; for (;;) { this = state->distcode[last.val + (BITS(last.bits + last.op) >> last.bits)]; if ((unsigned)(last.bits + this.bits) <= bits) break; PULLBYTE(); } DROPBITS(last.bits); } DROPBITS(this.bits); if (this.op & 64) { strm->msg = (char *)"invalid distance code"; state->mode = BAD; break; } state->offset = (unsigned)this.val; /* get distance extra bits, if any */ state->extra = (unsigned)(this.op) & 15; if (state->extra != 0) { NEEDBITS(state->extra); state->offset += BITS(state->extra); DROPBITS(state->extra); } if (state->offset > state->wsize - (state->whave < state->wsize ? left : 0)) { strm->msg = (char *)"invalid distance too far back"; state->mode = BAD; break; } Tracevv((stderr, "inflate: distance %u\n", state->offset)); /* copy match from window to output */ do { ROOM(); copy = state->wsize - state->offset; if (copy < left) { from = put + copy; copy = left - copy; } else { from = put - state->offset; copy = left; } if (copy > state->length) copy = state->length; state->length -= copy; left -= copy; do { *put++ = *from++; } while (--copy); } while (state->length != 0); break; case DONE: /* inflate stream terminated properly -- write leftover output */ ret = Z_STREAM_END; if (left < state->wsize) { if (out(out_desc, state->window, state->wsize - left)) ret = Z_BUF_ERROR; } goto inf_leave; case BAD: ret = Z_DATA_ERROR; goto inf_leave; default: /* can't happen, but makes compilers happy */ ret = Z_STREAM_ERROR; goto inf_leave; } /* Return unused input */ inf_leave: strm->next_in = next; strm->avail_in = have; return ret; } int ZEXPORT inflateBackEnd(strm) z_streamp strm; { if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) return Z_STREAM_ERROR; ZFREE(strm, strm->state); strm->state = Z_NULL; Tracev((stderr, "inflate: end\n")); return Z_OK; }