Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Feature/rm cincludes #37

Closed
wants to merge 6 commits into from

3 participants

@sjaeckel
Owner

We had several suggestions how to remove the included c-files, I propose this solution...

@sjaeckel sjaeckel referenced this pull request
Open

release needed - soon #36

@sjaeckel sjaeckel added this to the v1.18.0 milestone
@karel-m

Makefiles need to update the following part:

#ciphers come in two flavours... enc+dec and enc
src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c src/ciphers/aes/aes_tab.h
    $(CC) $(CFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o

#These are the rules to make certain object files.
src/ciphers/aes/aes_tab.o: src/ciphers/aes/aes_tab.c src/ciphers/aes/aes_tab.h
src/ciphers/twofish/twofish_tab.o: src/ciphers/twofish/twofish_tab.c src/ciphers/twofish/twofish_tab.h
src/ciphers/safer/safer_tab.o: src/ciphers/safer/safer_tab.c src/ciphers/safer/safer_tab.h
src/hashes/whirl/whirltab.o: src/hashes/whirl/whirltab.c src/hashes/whirl/whirltab.h
src/prngs/sober128tab.o: src/prngs/sober128tab.c src/prngs/sober128tab.h
src/pk/dh/dh_static.o: src/pk/dh/dh_static.c src/pk/dh/dh_static.h
@karel-m

I'am not sure if it is necessary to use:
#define __DECL_<name>_TAB_H__ extern

As all the tables are only for internal use and we are not about to expose them from outside the library I guess that it can be always extern

Or perhaps having just one globally defined:
#define __DECL_INTERNAL_TAB_H__ extern
instead on many __DECL_<name>_TAB_H__

But of course it is only cosmetics

@sjaeckel
Owner

mh, regarding #37 (comment) wouldn't it be enought to add the .h files to the HEADERS part of the makefiles?

@karel-m

Putting ..._tab.h files into HEADERS is enough.

However $(HEADERS) is also used for install target and I guess we do not want to install ..._tab.h files

src/ciphers/aes/aes_tab.c
@@ -27,7 +27,15 @@
@file aes_tab.c
AES tables
*/
-static const ulong32 TE0[256] = {
+
+#include "tomcrypt.h"
+
+#ifdef LTC_RIJNDAEL
+
+#define __DECL_AES_TAB_H__
+#include "aes_tab.h"
+
+const ulong32 TE0[256] = {
@rofl0r
rofl0r added a note

why was static removed ? is the table used from several TUs ? if so it may make sense to put it into a separate compilation unit. if not, this only adds bloat (object size).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@rofl0r

since you asked for comments:
i'm personally not too happy with this. why is the change needed ? the only advantage i can see is for a simple buildsystem where you can basically just compile *.c and then link it together. however the current buildsystem seems far from simple anyway...
so from my POV, this is a pretty invasive change for no real gain (that i can see).

@karel-m

@rofl0r for example src/ciphers/aes/aes_tab.c is used in src/ciphers/aes/aes.c + src/mac/pelican/pelican.c (I have not checked others)

As for the building "by just compiling *.c" in fact it works quite fine (after eliminating .c includes) - I use exactly this approach in my perl bindings

@sjaeckel
Owner

The more I looked at the old patch the less I liked it...
I decided to stay with the old approach for the tabs, but harden it a bit by protecting them, so you could theoretically also "just compile *.c" I think.
for sha2 and dh I decided to remove the inclusion of the c files.

@sjaeckel sjaeckel closed this
@sjaeckel sjaeckel deleted the feature/rmCincludes branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
4 genlist.sh
@@ -1,8 +1,8 @@
#!/bin/bash
# aes_tab.o is a pseudo object as it's made from aes.o and MPI is optional
-export a=`echo -n "src/ciphers/aes/aes_enc.o " ; find . -type f | sort | grep "[.]/src" | grep "[.]c" | grep -v "sha224" | grep -v "sha384" | grep -v "aes_tab" | grep -v "twofish_tab" | grep -v "whirltab" | grep -v "dh_sys" | grep -v "ecc_sys" | grep -v "mpi[.]c" | grep -v "sober128tab" | sed -e 'sE\./EE' | sed -e 's/\.c/\.o/' | xargs`
+export a=`echo -n "src/ciphers/aes/aes_enc.o " ; find ./src -type f -name "*.c" -not -name "*tab.c" | sort | sed -e 'sE\./EE' | sed -e 's/\.c/\.o/' | xargs`
perl ./parsenames.pl OBJECTS "$a"
-export a=`find . -type f | grep [.]/src | grep [.]h | sed -e 'se\./ee' | xargs`
+export a=`find src/headers -type f -name "*.h" | xargs`
perl ./parsenames.pl HEADERS "$a"
# $Source: /cvs/libtom/libtomcrypt/genlist.sh,v $
View
30 makefile
@@ -116,8 +116,8 @@ endif
OBJECTS=src/ciphers/aes/aes_enc.o src/ciphers/aes/aes.o src/ciphers/anubis.o src/ciphers/blowfish.o \
src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \
src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \
-src/ciphers/rc6.o src/ciphers/safer/safer.o src/ciphers/safer/safer_tab.o src/ciphers/safer/saferp.o \
-src/ciphers/skipjack.o src/ciphers/twofish/twofish.o src/ciphers/xtea.o src/encauth/ccm/ccm_memory.o \
+src/ciphers/rc6.o src/ciphers/safer/safer.o src/ciphers/safer/saferp.o src/ciphers/skipjack.o \
+src/ciphers/twofish/twofish.o src/ciphers/xtea.o src/encauth/ccm/ccm_memory.o \
src/encauth/ccm/ccm_memory_ex.o src/encauth/ccm/ccm_test.o src/encauth/eax/eax_addheader.o \
src/encauth/eax/eax_decrypt.o src/encauth/eax/eax_decrypt_verify_memory.o src/encauth/eax/eax_done.o \
src/encauth/eax/eax_encrypt.o src/encauth/eax/eax_encrypt_authenticate_memory.o \
@@ -138,15 +138,16 @@ src/encauth/ocb3/ocb3_int_ntz.o src/encauth/ocb3/ocb3_int_xor_blocks.o src/encau
src/hashes/chc/chc.o src/hashes/helper/hash_file.o src/hashes/helper/hash_filehandle.o \
src/hashes/helper/hash_memory.o src/hashes/helper/hash_memory_multi.o src/hashes/md2.o src/hashes/md4.o \
src/hashes/md5.o src/hashes/rmd128.o src/hashes/rmd160.o src/hashes/rmd256.o src/hashes/rmd320.o \
-src/hashes/sha1.o src/hashes/sha2/sha256.o src/hashes/sha2/sha512.o src/hashes/tiger.o \
-src/hashes/whirl/whirl.o src/mac/f9/f9_done.o src/mac/f9/f9_file.o src/mac/f9/f9_init.o \
-src/mac/f9/f9_memory.o src/mac/f9/f9_memory_multi.o src/mac/f9/f9_process.o src/mac/f9/f9_test.o \
-src/mac/hmac/hmac_done.o src/mac/hmac/hmac_file.o src/mac/hmac/hmac_init.o src/mac/hmac/hmac_memory.o \
-src/mac/hmac/hmac_memory_multi.o src/mac/hmac/hmac_process.o src/mac/hmac/hmac_test.o \
-src/mac/omac/omac_done.o src/mac/omac/omac_file.o src/mac/omac/omac_init.o src/mac/omac/omac_memory.o \
-src/mac/omac/omac_memory_multi.o src/mac/omac/omac_process.o src/mac/omac/omac_test.o \
-src/mac/pelican/pelican.o src/mac/pelican/pelican_memory.o src/mac/pelican/pelican_test.o \
-src/mac/pmac/pmac_done.o src/mac/pmac/pmac_file.o src/mac/pmac/pmac_init.o src/mac/pmac/pmac_memory.o \
+src/hashes/sha1.o src/hashes/sha2/sha224.o src/hashes/sha2/sha256.o src/hashes/sha2/sha384.o \
+src/hashes/sha2/sha512.o src/hashes/tiger.o src/hashes/whirl/whirl.o src/mac/f9/f9_done.o \
+src/mac/f9/f9_file.o src/mac/f9/f9_init.o src/mac/f9/f9_memory.o src/mac/f9/f9_memory_multi.o \
+src/mac/f9/f9_process.o src/mac/f9/f9_test.o src/mac/hmac/hmac_done.o src/mac/hmac/hmac_file.o \
+src/mac/hmac/hmac_init.o src/mac/hmac/hmac_memory.o src/mac/hmac/hmac_memory_multi.o \
+src/mac/hmac/hmac_process.o src/mac/hmac/hmac_test.o src/mac/omac/omac_done.o src/mac/omac/omac_file.o \
+src/mac/omac/omac_init.o src/mac/omac/omac_memory.o src/mac/omac/omac_memory_multi.o \
+src/mac/omac/omac_process.o src/mac/omac/omac_test.o src/mac/pelican/pelican.o \
+src/mac/pelican/pelican_memory.o src/mac/pelican/pelican_test.o src/mac/pmac/pmac_done.o \
+src/mac/pmac/pmac_file.o src/mac/pmac/pmac_init.o src/mac/pmac/pmac_memory.o \
src/mac/pmac/pmac_memory_multi.o src/mac/pmac/pmac_ntz.o src/mac/pmac/pmac_process.o \
src/mac/pmac/pmac_shift_xor.o src/mac/pmac/pmac_test.o src/mac/xcbc/xcbc_done.o \
src/mac/xcbc/xcbc_file.o src/mac/xcbc/xcbc_init.o src/mac/xcbc/xcbc_memory.o \
@@ -215,9 +216,10 @@ src/pk/asn1/der/teletex_string/der_length_teletex_string.o \
src/pk/asn1/der/utctime/der_decode_utctime.o src/pk/asn1/der/utctime/der_encode_utctime.o \
src/pk/asn1/der/utctime/der_length_utctime.o src/pk/asn1/der/utf8/der_decode_utf8_string.o \
src/pk/asn1/der/utf8/der_encode_utf8_string.o src/pk/asn1/der/utf8/der_length_utf8_string.o \
-src/pk/dh/dh.o src/pk/dsa/dsa_decrypt_key.o src/pk/dsa/dsa_encrypt_key.o src/pk/dsa/dsa_export.o \
-src/pk/dsa/dsa_free.o src/pk/dsa/dsa_import.o src/pk/dsa/dsa_make_key.o src/pk/dsa/dsa_shared_secret.o \
-src/pk/dsa/dsa_sign_hash.o src/pk/dsa/dsa_verify_hash.o src/pk/dsa/dsa_verify_key.o src/pk/ecc/ecc.o \
+src/pk/dh/dh.o src/pk/dh/dh_static.o src/pk/dh/dh_sys.o src/pk/dsa/dsa_decrypt_key.o \
+src/pk/dsa/dsa_encrypt_key.o src/pk/dsa/dsa_export.o src/pk/dsa/dsa_free.o src/pk/dsa/dsa_import.o \
+src/pk/dsa/dsa_make_key.o src/pk/dsa/dsa_shared_secret.o src/pk/dsa/dsa_sign_hash.o \
+src/pk/dsa/dsa_verify_hash.o src/pk/dsa/dsa_verify_key.o src/pk/ecc/ecc.o \
src/pk/ecc/ecc_ansi_x963_export.o src/pk/ecc/ecc_ansi_x963_import.o src/pk/ecc/ecc_decrypt_key.o \
src/pk/ecc/ecc_encrypt_key.o src/pk/ecc/ecc_export.o src/pk/ecc/ecc_free.o src/pk/ecc/ecc_get_size.o \
src/pk/ecc/ecc_import.o src/pk/ecc/ecc_make_key.o src/pk/ecc/ecc_shared_secret.o \
View
30 makefile.icc
@@ -97,8 +97,8 @@ endif
OBJECTS=src/ciphers/aes/aes_enc.o src/ciphers/aes/aes.o src/ciphers/anubis.o src/ciphers/blowfish.o \
src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \
src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \
-src/ciphers/rc6.o src/ciphers/safer/safer.o src/ciphers/safer/safer_tab.o src/ciphers/safer/saferp.o \
-src/ciphers/skipjack.o src/ciphers/twofish/twofish.o src/ciphers/xtea.o src/encauth/ccm/ccm_memory.o \
+src/ciphers/rc6.o src/ciphers/safer/safer.o src/ciphers/safer/saferp.o src/ciphers/skipjack.o \
+src/ciphers/twofish/twofish.o src/ciphers/xtea.o src/encauth/ccm/ccm_memory.o \
src/encauth/ccm/ccm_memory_ex.o src/encauth/ccm/ccm_test.o src/encauth/eax/eax_addheader.o \
src/encauth/eax/eax_decrypt.o src/encauth/eax/eax_decrypt_verify_memory.o src/encauth/eax/eax_done.o \
src/encauth/eax/eax_encrypt.o src/encauth/eax/eax_encrypt_authenticate_memory.o \
@@ -119,15 +119,16 @@ src/encauth/ocb3/ocb3_int_ntz.o src/encauth/ocb3/ocb3_int_xor_blocks.o src/encau
src/hashes/chc/chc.o src/hashes/helper/hash_file.o src/hashes/helper/hash_filehandle.o \
src/hashes/helper/hash_memory.o src/hashes/helper/hash_memory_multi.o src/hashes/md2.o src/hashes/md4.o \
src/hashes/md5.o src/hashes/rmd128.o src/hashes/rmd160.o src/hashes/rmd256.o src/hashes/rmd320.o \
-src/hashes/sha1.o src/hashes/sha2/sha256.o src/hashes/sha2/sha512.o src/hashes/tiger.o \
-src/hashes/whirl/whirl.o src/mac/f9/f9_done.o src/mac/f9/f9_file.o src/mac/f9/f9_init.o \
-src/mac/f9/f9_memory.o src/mac/f9/f9_memory_multi.o src/mac/f9/f9_process.o src/mac/f9/f9_test.o \
-src/mac/hmac/hmac_done.o src/mac/hmac/hmac_file.o src/mac/hmac/hmac_init.o src/mac/hmac/hmac_memory.o \
-src/mac/hmac/hmac_memory_multi.o src/mac/hmac/hmac_process.o src/mac/hmac/hmac_test.o \
-src/mac/omac/omac_done.o src/mac/omac/omac_file.o src/mac/omac/omac_init.o src/mac/omac/omac_memory.o \
-src/mac/omac/omac_memory_multi.o src/mac/omac/omac_process.o src/mac/omac/omac_test.o \
-src/mac/pelican/pelican.o src/mac/pelican/pelican_memory.o src/mac/pelican/pelican_test.o \
-src/mac/pmac/pmac_done.o src/mac/pmac/pmac_file.o src/mac/pmac/pmac_init.o src/mac/pmac/pmac_memory.o \
+src/hashes/sha1.o src/hashes/sha2/sha224.o src/hashes/sha2/sha256.o src/hashes/sha2/sha384.o \
+src/hashes/sha2/sha512.o src/hashes/tiger.o src/hashes/whirl/whirl.o src/mac/f9/f9_done.o \
+src/mac/f9/f9_file.o src/mac/f9/f9_init.o src/mac/f9/f9_memory.o src/mac/f9/f9_memory_multi.o \
+src/mac/f9/f9_process.o src/mac/f9/f9_test.o src/mac/hmac/hmac_done.o src/mac/hmac/hmac_file.o \
+src/mac/hmac/hmac_init.o src/mac/hmac/hmac_memory.o src/mac/hmac/hmac_memory_multi.o \
+src/mac/hmac/hmac_process.o src/mac/hmac/hmac_test.o src/mac/omac/omac_done.o src/mac/omac/omac_file.o \
+src/mac/omac/omac_init.o src/mac/omac/omac_memory.o src/mac/omac/omac_memory_multi.o \
+src/mac/omac/omac_process.o src/mac/omac/omac_test.o src/mac/pelican/pelican.o \
+src/mac/pelican/pelican_memory.o src/mac/pelican/pelican_test.o src/mac/pmac/pmac_done.o \
+src/mac/pmac/pmac_file.o src/mac/pmac/pmac_init.o src/mac/pmac/pmac_memory.o \
src/mac/pmac/pmac_memory_multi.o src/mac/pmac/pmac_ntz.o src/mac/pmac/pmac_process.o \
src/mac/pmac/pmac_shift_xor.o src/mac/pmac/pmac_test.o src/mac/xcbc/xcbc_done.o \
src/mac/xcbc/xcbc_file.o src/mac/xcbc/xcbc_init.o src/mac/xcbc/xcbc_memory.o \
@@ -196,9 +197,10 @@ src/pk/asn1/der/teletex_string/der_length_teletex_string.o \
src/pk/asn1/der/utctime/der_decode_utctime.o src/pk/asn1/der/utctime/der_encode_utctime.o \
src/pk/asn1/der/utctime/der_length_utctime.o src/pk/asn1/der/utf8/der_decode_utf8_string.o \
src/pk/asn1/der/utf8/der_encode_utf8_string.o src/pk/asn1/der/utf8/der_length_utf8_string.o \
-src/pk/dh/dh.o src/pk/dsa/dsa_decrypt_key.o src/pk/dsa/dsa_encrypt_key.o src/pk/dsa/dsa_export.o \
-src/pk/dsa/dsa_free.o src/pk/dsa/dsa_import.o src/pk/dsa/dsa_make_key.o src/pk/dsa/dsa_shared_secret.o \
-src/pk/dsa/dsa_sign_hash.o src/pk/dsa/dsa_verify_hash.o src/pk/dsa/dsa_verify_key.o src/pk/ecc/ecc.o \
+src/pk/dh/dh.o src/pk/dh/dh_static.o src/pk/dh/dh_sys.o src/pk/dsa/dsa_decrypt_key.o \
+src/pk/dsa/dsa_encrypt_key.o src/pk/dsa/dsa_export.o src/pk/dsa/dsa_free.o src/pk/dsa/dsa_import.o \
+src/pk/dsa/dsa_make_key.o src/pk/dsa/dsa_shared_secret.o src/pk/dsa/dsa_sign_hash.o \
+src/pk/dsa/dsa_verify_hash.o src/pk/dsa/dsa_verify_key.o src/pk/ecc/ecc.o \
src/pk/ecc/ecc_ansi_x963_export.o src/pk/ecc/ecc_ansi_x963_import.o src/pk/ecc/ecc_decrypt_key.o \
src/pk/ecc/ecc_encrypt_key.o src/pk/ecc/ecc_export.o src/pk/ecc/ecc_free.o src/pk/ecc/ecc_get_size.o \
src/pk/ecc/ecc_import.o src/pk/ecc/ecc_make_key.o src/pk/ecc/ecc_shared_secret.o \
View
30 makefile.msvc
@@ -7,8 +7,8 @@ CFLAGS = /Isrc/headers/ /Itestprof/ /Ox /DWIN32 /DLTC_SOURCE /W3 /Fo$@ $(CF)
OBJECTS=src/ciphers/aes/aes_enc.obj src/ciphers/aes/aes.obj src/ciphers/anubis.obj src/ciphers/blowfish.obj \
src/ciphers/camellia.obj src/ciphers/cast5.obj src/ciphers/des.obj src/ciphers/kasumi.obj src/ciphers/khazad.obj \
src/ciphers/kseed.obj src/ciphers/multi2.obj src/ciphers/noekeon.obj src/ciphers/rc2.obj src/ciphers/rc5.obj \
-src/ciphers/rc6.obj src/ciphers/safer/safer.obj src/ciphers/safer/safer_tab.obj src/ciphers/safer/saferp.obj \
-src/ciphers/skipjack.obj src/ciphers/twofish/twofish.obj src/ciphers/xtea.obj src/encauth/ccm/ccm_memory.obj \
+src/ciphers/rc6.obj src/ciphers/safer/safer.obj src/ciphers/safer/saferp.obj src/ciphers/skipjack.obj \
+src/ciphers/twofish/twofish.obj src/ciphers/xtea.obj src/encauth/ccm/ccm_memory.obj \
src/encauth/ccm/ccm_memory_ex.obj src/encauth/ccm/ccm_test.obj src/encauth/eax/eax_addheader.obj \
src/encauth/eax/eax_decrypt.obj src/encauth/eax/eax_decrypt_verify_memory.obj src/encauth/eax/eax_done.obj \
src/encauth/eax/eax_encrypt.obj src/encauth/eax/eax_encrypt_authenticate_memory.obj \
@@ -29,15 +29,16 @@ src/encauth/ocb3/ocb3_int_ntz.obj src/encauth/ocb3/ocb3_int_xor_blocks.obj src/e
src/hashes/chc/chc.obj src/hashes/helper/hash_file.obj src/hashes/helper/hash_filehandle.obj \
src/hashes/helper/hash_memory.obj src/hashes/helper/hash_memory_multi.obj src/hashes/md2.obj src/hashes/md4.obj \
src/hashes/md5.obj src/hashes/rmd128.obj src/hashes/rmd160.obj src/hashes/rmd256.obj src/hashes/rmd320.obj \
-src/hashes/sha1.obj src/hashes/sha2/sha256.obj src/hashes/sha2/sha512.obj src/hashes/tiger.obj \
-src/hashes/whirl/whirl.obj src/mac/f9/f9_done.obj src/mac/f9/f9_file.obj src/mac/f9/f9_init.obj \
-src/mac/f9/f9_memory.obj src/mac/f9/f9_memory_multi.obj src/mac/f9/f9_process.obj src/mac/f9/f9_test.obj \
-src/mac/hmac/hmac_done.obj src/mac/hmac/hmac_file.obj src/mac/hmac/hmac_init.obj src/mac/hmac/hmac_memory.obj \
-src/mac/hmac/hmac_memory_multi.obj src/mac/hmac/hmac_process.obj src/mac/hmac/hmac_test.obj \
-src/mac/omac/omac_done.obj src/mac/omac/omac_file.obj src/mac/omac/omac_init.obj src/mac/omac/omac_memory.obj \
-src/mac/omac/omac_memory_multi.obj src/mac/omac/omac_process.obj src/mac/omac/omac_test.obj \
-src/mac/pelican/pelican.obj src/mac/pelican/pelican_memory.obj src/mac/pelican/pelican_test.obj \
-src/mac/pmac/pmac_done.obj src/mac/pmac/pmac_file.obj src/mac/pmac/pmac_init.obj src/mac/pmac/pmac_memory.obj \
+src/hashes/sha1.obj src/hashes/sha2/sha224.obj src/hashes/sha2/sha256.obj src/hashes/sha2/sha384.obj \
+src/hashes/sha2/sha512.obj src/hashes/tiger.obj src/hashes/whirl/whirl.obj src/mac/f9/f9_done.obj \
+src/mac/f9/f9_file.obj src/mac/f9/f9_init.obj src/mac/f9/f9_memory.obj src/mac/f9/f9_memory_multi.obj \
+src/mac/f9/f9_process.obj src/mac/f9/f9_test.obj src/mac/hmac/hmac_done.obj src/mac/hmac/hmac_file.obj \
+src/mac/hmac/hmac_init.obj src/mac/hmac/hmac_memory.obj src/mac/hmac/hmac_memory_multi.obj \
+src/mac/hmac/hmac_process.obj src/mac/hmac/hmac_test.obj src/mac/omac/omac_done.obj src/mac/omac/omac_file.obj \
+src/mac/omac/omac_init.obj src/mac/omac/omac_memory.obj src/mac/omac/omac_memory_multi.obj \
+src/mac/omac/omac_process.obj src/mac/omac/omac_test.obj src/mac/pelican/pelican.obj \
+src/mac/pelican/pelican_memory.obj src/mac/pelican/pelican_test.obj src/mac/pmac/pmac_done.obj \
+src/mac/pmac/pmac_file.obj src/mac/pmac/pmac_init.obj src/mac/pmac/pmac_memory.obj \
src/mac/pmac/pmac_memory_multi.obj src/mac/pmac/pmac_ntz.obj src/mac/pmac/pmac_process.obj \
src/mac/pmac/pmac_shift_xor.obj src/mac/pmac/pmac_test.obj src/mac/xcbc/xcbc_done.obj \
src/mac/xcbc/xcbc_file.obj src/mac/xcbc/xcbc_init.obj src/mac/xcbc/xcbc_memory.obj \
@@ -106,9 +107,10 @@ src/pk/asn1/der/teletex_string/der_length_teletex_string.obj \
src/pk/asn1/der/utctime/der_decode_utctime.obj src/pk/asn1/der/utctime/der_encode_utctime.obj \
src/pk/asn1/der/utctime/der_length_utctime.obj src/pk/asn1/der/utf8/der_decode_utf8_string.obj \
src/pk/asn1/der/utf8/der_encode_utf8_string.obj src/pk/asn1/der/utf8/der_length_utf8_string.obj \
-src/pk/dh/dh.obj src/pk/dsa/dsa_decrypt_key.obj src/pk/dsa/dsa_encrypt_key.obj src/pk/dsa/dsa_export.obj \
-src/pk/dsa/dsa_free.obj src/pk/dsa/dsa_import.obj src/pk/dsa/dsa_make_key.obj src/pk/dsa/dsa_shared_secret.obj \
-src/pk/dsa/dsa_sign_hash.obj src/pk/dsa/dsa_verify_hash.obj src/pk/dsa/dsa_verify_key.obj src/pk/ecc/ecc.obj \
+src/pk/dh/dh.obj src/pk/dh/dh_static.obj src/pk/dh/dh_sys.obj src/pk/dsa/dsa_decrypt_key.obj \
+src/pk/dsa/dsa_encrypt_key.obj src/pk/dsa/dsa_export.obj src/pk/dsa/dsa_free.obj src/pk/dsa/dsa_import.obj \
+src/pk/dsa/dsa_make_key.obj src/pk/dsa/dsa_shared_secret.obj src/pk/dsa/dsa_sign_hash.obj \
+src/pk/dsa/dsa_verify_hash.obj src/pk/dsa/dsa_verify_key.obj src/pk/ecc/ecc.obj \
src/pk/ecc/ecc_ansi_x963_export.obj src/pk/ecc/ecc_ansi_x963_import.obj src/pk/ecc/ecc_decrypt_key.obj \
src/pk/ecc/ecc_encrypt_key.obj src/pk/ecc/ecc_export.obj src/pk/ecc/ecc_free.obj src/pk/ecc/ecc_get_size.obj \
src/pk/ecc/ecc_import.obj src/pk/ecc/ecc_make_key.obj src/pk/ecc/ecc_shared_secret.obj \
View
30 makefile.shared
@@ -102,8 +102,8 @@ endif
OBJECTS=src/ciphers/aes/aes_enc.o src/ciphers/aes/aes.o src/ciphers/anubis.o src/ciphers/blowfish.o \
src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \
src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \
-src/ciphers/rc6.o src/ciphers/safer/safer.o src/ciphers/safer/safer_tab.o src/ciphers/safer/saferp.o \
-src/ciphers/skipjack.o src/ciphers/twofish/twofish.o src/ciphers/xtea.o src/encauth/ccm/ccm_memory.o \
+src/ciphers/rc6.o src/ciphers/safer/safer.o src/ciphers/safer/saferp.o src/ciphers/skipjack.o \
+src/ciphers/twofish/twofish.o src/ciphers/xtea.o src/encauth/ccm/ccm_memory.o \
src/encauth/ccm/ccm_memory_ex.o src/encauth/ccm/ccm_test.o src/encauth/eax/eax_addheader.o \
src/encauth/eax/eax_decrypt.o src/encauth/eax/eax_decrypt_verify_memory.o src/encauth/eax/eax_done.o \
src/encauth/eax/eax_encrypt.o src/encauth/eax/eax_encrypt_authenticate_memory.o \
@@ -124,15 +124,16 @@ src/encauth/ocb3/ocb3_int_ntz.o src/encauth/ocb3/ocb3_int_xor_blocks.o src/encau
src/hashes/chc/chc.o src/hashes/helper/hash_file.o src/hashes/helper/hash_filehandle.o \
src/hashes/helper/hash_memory.o src/hashes/helper/hash_memory_multi.o src/hashes/md2.o src/hashes/md4.o \
src/hashes/md5.o src/hashes/rmd128.o src/hashes/rmd160.o src/hashes/rmd256.o src/hashes/rmd320.o \
-src/hashes/sha1.o src/hashes/sha2/sha256.o src/hashes/sha2/sha512.o src/hashes/tiger.o \
-src/hashes/whirl/whirl.o src/mac/f9/f9_done.o src/mac/f9/f9_file.o src/mac/f9/f9_init.o \
-src/mac/f9/f9_memory.o src/mac/f9/f9_memory_multi.o src/mac/f9/f9_process.o src/mac/f9/f9_test.o \
-src/mac/hmac/hmac_done.o src/mac/hmac/hmac_file.o src/mac/hmac/hmac_init.o src/mac/hmac/hmac_memory.o \
-src/mac/hmac/hmac_memory_multi.o src/mac/hmac/hmac_process.o src/mac/hmac/hmac_test.o \
-src/mac/omac/omac_done.o src/mac/omac/omac_file.o src/mac/omac/omac_init.o src/mac/omac/omac_memory.o \
-src/mac/omac/omac_memory_multi.o src/mac/omac/omac_process.o src/mac/omac/omac_test.o \
-src/mac/pelican/pelican.o src/mac/pelican/pelican_memory.o src/mac/pelican/pelican_test.o \
-src/mac/pmac/pmac_done.o src/mac/pmac/pmac_file.o src/mac/pmac/pmac_init.o src/mac/pmac/pmac_memory.o \
+src/hashes/sha1.o src/hashes/sha2/sha224.o src/hashes/sha2/sha256.o src/hashes/sha2/sha384.o \
+src/hashes/sha2/sha512.o src/hashes/tiger.o src/hashes/whirl/whirl.o src/mac/f9/f9_done.o \
+src/mac/f9/f9_file.o src/mac/f9/f9_init.o src/mac/f9/f9_memory.o src/mac/f9/f9_memory_multi.o \
+src/mac/f9/f9_process.o src/mac/f9/f9_test.o src/mac/hmac/hmac_done.o src/mac/hmac/hmac_file.o \
+src/mac/hmac/hmac_init.o src/mac/hmac/hmac_memory.o src/mac/hmac/hmac_memory_multi.o \
+src/mac/hmac/hmac_process.o src/mac/hmac/hmac_test.o src/mac/omac/omac_done.o src/mac/omac/omac_file.o \
+src/mac/omac/omac_init.o src/mac/omac/omac_memory.o src/mac/omac/omac_memory_multi.o \
+src/mac/omac/omac_process.o src/mac/omac/omac_test.o src/mac/pelican/pelican.o \
+src/mac/pelican/pelican_memory.o src/mac/pelican/pelican_test.o src/mac/pmac/pmac_done.o \
+src/mac/pmac/pmac_file.o src/mac/pmac/pmac_init.o src/mac/pmac/pmac_memory.o \
src/mac/pmac/pmac_memory_multi.o src/mac/pmac/pmac_ntz.o src/mac/pmac/pmac_process.o \
src/mac/pmac/pmac_shift_xor.o src/mac/pmac/pmac_test.o src/mac/xcbc/xcbc_done.o \
src/mac/xcbc/xcbc_file.o src/mac/xcbc/xcbc_init.o src/mac/xcbc/xcbc_memory.o \
@@ -201,9 +202,10 @@ src/pk/asn1/der/teletex_string/der_length_teletex_string.o \
src/pk/asn1/der/utctime/der_decode_utctime.o src/pk/asn1/der/utctime/der_encode_utctime.o \
src/pk/asn1/der/utctime/der_length_utctime.o src/pk/asn1/der/utf8/der_decode_utf8_string.o \
src/pk/asn1/der/utf8/der_encode_utf8_string.o src/pk/asn1/der/utf8/der_length_utf8_string.o \
-src/pk/dh/dh.o src/pk/dsa/dsa_decrypt_key.o src/pk/dsa/dsa_encrypt_key.o src/pk/dsa/dsa_export.o \
-src/pk/dsa/dsa_free.o src/pk/dsa/dsa_import.o src/pk/dsa/dsa_make_key.o src/pk/dsa/dsa_shared_secret.o \
-src/pk/dsa/dsa_sign_hash.o src/pk/dsa/dsa_verify_hash.o src/pk/dsa/dsa_verify_key.o src/pk/ecc/ecc.o \
+src/pk/dh/dh.o src/pk/dh/dh_static.o src/pk/dh/dh_sys.o src/pk/dsa/dsa_decrypt_key.o \
+src/pk/dsa/dsa_encrypt_key.o src/pk/dsa/dsa_export.o src/pk/dsa/dsa_free.o src/pk/dsa/dsa_import.o \
+src/pk/dsa/dsa_make_key.o src/pk/dsa/dsa_shared_secret.o src/pk/dsa/dsa_sign_hash.o \
+src/pk/dsa/dsa_verify_hash.o src/pk/dsa/dsa_verify_key.o src/pk/ecc/ecc.o \
src/pk/ecc/ecc_ansi_x963_export.o src/pk/ecc/ecc_ansi_x963_import.o src/pk/ecc/ecc_decrypt_key.o \
src/pk/ecc/ecc_encrypt_key.o src/pk/ecc/ecc_export.o src/pk/ecc/ecc_free.o src/pk/ecc/ecc_get_size.o \
src/pk/ecc/ecc_import.o src/pk/ecc/ecc_make_key.o src/pk/ecc/ecc_shared_secret.o \
View
30 makefile.unix
@@ -43,8 +43,8 @@ GROUP=wheel
OBJECTS=src/ciphers/aes/aes_enc.o src/ciphers/aes/aes.o src/ciphers/anubis.o src/ciphers/blowfish.o \
src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \
src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \
-src/ciphers/rc6.o src/ciphers/safer/safer.o src/ciphers/safer/safer_tab.o src/ciphers/safer/saferp.o \
-src/ciphers/skipjack.o src/ciphers/twofish/twofish.o src/ciphers/xtea.o src/encauth/ccm/ccm_memory.o \
+src/ciphers/rc6.o src/ciphers/safer/safer.o src/ciphers/safer/saferp.o src/ciphers/skipjack.o \
+src/ciphers/twofish/twofish.o src/ciphers/xtea.o src/encauth/ccm/ccm_memory.o \
src/encauth/ccm/ccm_memory_ex.o src/encauth/ccm/ccm_test.o src/encauth/eax/eax_addheader.o \
src/encauth/eax/eax_decrypt.o src/encauth/eax/eax_decrypt_verify_memory.o src/encauth/eax/eax_done.o \
src/encauth/eax/eax_encrypt.o src/encauth/eax/eax_encrypt_authenticate_memory.o \
@@ -65,15 +65,16 @@ src/encauth/ocb3/ocb3_int_ntz.o src/encauth/ocb3/ocb3_int_xor_blocks.o src/encau
src/hashes/chc/chc.o src/hashes/helper/hash_file.o src/hashes/helper/hash_filehandle.o \
src/hashes/helper/hash_memory.o src/hashes/helper/hash_memory_multi.o src/hashes/md2.o src/hashes/md4.o \
src/hashes/md5.o src/hashes/rmd128.o src/hashes/rmd160.o src/hashes/rmd256.o src/hashes/rmd320.o \
-src/hashes/sha1.o src/hashes/sha2/sha256.o src/hashes/sha2/sha512.o src/hashes/tiger.o \
-src/hashes/whirl/whirl.o src/mac/f9/f9_done.o src/mac/f9/f9_file.o src/mac/f9/f9_init.o \
-src/mac/f9/f9_memory.o src/mac/f9/f9_memory_multi.o src/mac/f9/f9_process.o src/mac/f9/f9_test.o \
-src/mac/hmac/hmac_done.o src/mac/hmac/hmac_file.o src/mac/hmac/hmac_init.o src/mac/hmac/hmac_memory.o \
-src/mac/hmac/hmac_memory_multi.o src/mac/hmac/hmac_process.o src/mac/hmac/hmac_test.o \
-src/mac/omac/omac_done.o src/mac/omac/omac_file.o src/mac/omac/omac_init.o src/mac/omac/omac_memory.o \
-src/mac/omac/omac_memory_multi.o src/mac/omac/omac_process.o src/mac/omac/omac_test.o \
-src/mac/pelican/pelican.o src/mac/pelican/pelican_memory.o src/mac/pelican/pelican_test.o \
-src/mac/pmac/pmac_done.o src/mac/pmac/pmac_file.o src/mac/pmac/pmac_init.o src/mac/pmac/pmac_memory.o \
+src/hashes/sha1.o src/hashes/sha2/sha224.o src/hashes/sha2/sha256.o src/hashes/sha2/sha384.o \
+src/hashes/sha2/sha512.o src/hashes/tiger.o src/hashes/whirl/whirl.o src/mac/f9/f9_done.o \
+src/mac/f9/f9_file.o src/mac/f9/f9_init.o src/mac/f9/f9_memory.o src/mac/f9/f9_memory_multi.o \
+src/mac/f9/f9_process.o src/mac/f9/f9_test.o src/mac/hmac/hmac_done.o src/mac/hmac/hmac_file.o \
+src/mac/hmac/hmac_init.o src/mac/hmac/hmac_memory.o src/mac/hmac/hmac_memory_multi.o \
+src/mac/hmac/hmac_process.o src/mac/hmac/hmac_test.o src/mac/omac/omac_done.o src/mac/omac/omac_file.o \
+src/mac/omac/omac_init.o src/mac/omac/omac_memory.o src/mac/omac/omac_memory_multi.o \
+src/mac/omac/omac_process.o src/mac/omac/omac_test.o src/mac/pelican/pelican.o \
+src/mac/pelican/pelican_memory.o src/mac/pelican/pelican_test.o src/mac/pmac/pmac_done.o \
+src/mac/pmac/pmac_file.o src/mac/pmac/pmac_init.o src/mac/pmac/pmac_memory.o \
src/mac/pmac/pmac_memory_multi.o src/mac/pmac/pmac_ntz.o src/mac/pmac/pmac_process.o \
src/mac/pmac/pmac_shift_xor.o src/mac/pmac/pmac_test.o src/mac/xcbc/xcbc_done.o \
src/mac/xcbc/xcbc_file.o src/mac/xcbc/xcbc_init.o src/mac/xcbc/xcbc_memory.o \
@@ -142,9 +143,10 @@ src/pk/asn1/der/teletex_string/der_length_teletex_string.o \
src/pk/asn1/der/utctime/der_decode_utctime.o src/pk/asn1/der/utctime/der_encode_utctime.o \
src/pk/asn1/der/utctime/der_length_utctime.o src/pk/asn1/der/utf8/der_decode_utf8_string.o \
src/pk/asn1/der/utf8/der_encode_utf8_string.o src/pk/asn1/der/utf8/der_length_utf8_string.o \
-src/pk/dh/dh.o src/pk/dsa/dsa_decrypt_key.o src/pk/dsa/dsa_encrypt_key.o src/pk/dsa/dsa_export.o \
-src/pk/dsa/dsa_free.o src/pk/dsa/dsa_import.o src/pk/dsa/dsa_make_key.o src/pk/dsa/dsa_shared_secret.o \
-src/pk/dsa/dsa_sign_hash.o src/pk/dsa/dsa_verify_hash.o src/pk/dsa/dsa_verify_key.o src/pk/ecc/ecc.o \
+src/pk/dh/dh.o src/pk/dh/dh_static.o src/pk/dh/dh_sys.o src/pk/dsa/dsa_decrypt_key.o \
+src/pk/dsa/dsa_encrypt_key.o src/pk/dsa/dsa_export.o src/pk/dsa/dsa_free.o src/pk/dsa/dsa_import.o \
+src/pk/dsa/dsa_make_key.o src/pk/dsa/dsa_shared_secret.o src/pk/dsa/dsa_sign_hash.o \
+src/pk/dsa/dsa_verify_hash.o src/pk/dsa/dsa_verify_key.o src/pk/ecc/ecc.o \
src/pk/ecc/ecc_ansi_x963_export.o src/pk/ecc/ecc_ansi_x963_import.o src/pk/ecc/ecc_decrypt_key.o \
src/pk/ecc/ecc_encrypt_key.o src/pk/ecc/ecc_export.o src/pk/ecc/ecc_free.o src/pk/ecc/ecc_get_size.o \
src/pk/ecc/ecc_import.o src/pk/ecc/ecc_make_key.o src/pk/ecc/ecc_shared_secret.o \
View
1  src/ciphers/aes/aes.c
@@ -88,6 +88,7 @@ const struct ltc_cipher_descriptor aes_enc_desc =
#endif
+#define __LTC_AES_TAB_C__
#include "aes_tab.c"
static ulong32 setup_mix(ulong32 temp)
View
4 src/ciphers/aes/aes_tab.c
@@ -23,6 +23,8 @@ Td3[x] = Si[x].[09, 0d, 0b, 0e];
Td4[x] = Si[x].[01, 01, 01, 01];
*/
+#ifdef __LTC_AES_TAB_C__
+
/**
@file aes_tab.c
AES tables
@@ -1023,6 +1025,8 @@ static const ulong32 rcon[] = {
0x1B000000UL, 0x36000000UL, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
};
+#endif /* __LTC_AES_TAB_C__ */
+
/* $Source$ */
/* $Revision$ */
/* $Date$ */
View
4 src/ciphers/safer/safer.c
@@ -32,6 +32,9 @@
#ifdef LTC_SAFER
+#define __LTC_SAFER_TAB_C__
+#include "safer_tab.c"
+
const struct ltc_cipher_descriptor
safer_k64_desc = {
"safer-k64",
@@ -95,7 +98,6 @@ const struct ltc_cipher_descriptor
#define IPHT(x, y) { x -= y; y -= x; }
/******************* Types ****************************************************/
-extern const unsigned char safer_ebox[], safer_lbox[];
#ifdef LTC_CLEAN_STACK
static void _Safer_Expand_Userkey(const unsigned char *userkey_1,
View
10 src/ciphers/safer/safer_tab.c
@@ -14,13 +14,11 @@
Tables for LTC_SAFER block ciphers
*/
-#include "tomcrypt.h"
-
-#if defined(LTC_SAFERP) || defined(LTC_SAFER)
+#ifdef __LTC_SAFER_TAB_C__
/* This is the box defined by ebox[x] = 45^x mod 257.
* Its assumed that the value "256" corresponds to zero. */
-const unsigned char safer_ebox[256] = {
+static const unsigned char safer_ebox[256] = {
1, 45, 226, 147, 190, 69, 21, 174, 120, 3, 135, 164, 184, 56, 207, 63,
8, 103, 9, 148, 235, 38, 168, 107, 189, 24, 52, 27, 187, 191, 114, 247,
64, 53, 72, 156, 81, 47, 59, 85, 227, 192, 159, 216, 211, 243, 141, 177,
@@ -40,7 +38,7 @@ const unsigned char safer_ebox[256] = {
};
/* This is the inverse of ebox or the base 45 logarithm */
-const unsigned char safer_lbox[256] = {
+static const unsigned char safer_lbox[256] = {
128, 0, 176, 9, 96, 239, 185, 253, 16, 18, 159, 228, 105, 186, 173, 248,
192, 56, 194, 101, 79, 6, 148, 252, 25, 222, 106, 27, 93, 78, 168, 130,
112, 237, 232, 236, 114, 179, 21, 195, 255, 171, 182, 71, 68, 1, 172, 37,
@@ -59,7 +57,7 @@ const unsigned char safer_lbox[256] = {
184, 64, 120, 45, 58, 233, 100, 31, 146, 144, 125, 57, 111, 224, 137, 48
};
-#endif
+#endif /* __LTC_SAFER_TAB_C__ */
View
5 src/ciphers/safer/saferp.c
@@ -17,6 +17,9 @@
#ifdef LTC_SAFERP
+#define __LTC_SAFER_TAB_C__
+#include "safer_tab.c"
+
const struct ltc_cipher_descriptor saferp_desc =
{
"safer+",
@@ -42,8 +45,6 @@ const struct ltc_cipher_descriptor saferp_desc =
* array of 16 bytes b[0..15] which is the block of data
*/
-extern const unsigned char safer_ebox[], safer_lbox[];
-
#define ROUND(b, i) \
b[0] = (safer_ebox[(b[0] ^ skey->saferp.K[i][0]) & 255] + skey->saferp.K[i+1][0]) & 255; \
b[1] = safer_lbox[(b[1] + skey->saferp.K[i][1]) & 255] ^ skey->saferp.K[i+1][1]; \
View
1  src/ciphers/twofish/twofish.c
@@ -62,6 +62,7 @@ static const unsigned char qord[4][5] = {
#ifdef LTC_TWOFISH_TABLES
+#define __LTC_TWOFISH_TAB_C__
#include "twofish_tab.c"
#define sbox(i, x) ((ulong32)SBOX[i][(x)&255])
View
2  src/ciphers/twofish/twofish_tab.c
@@ -14,6 +14,7 @@
Twofish tables, Tom St Denis
*/
#ifdef LTC_TWOFISH_TABLES
+#ifdef __LTC_TWOFISH_TAB_C__
/* pre generated 8x8 tables from the four 4x4s */
static const unsigned char SBOX[2][256] = {
@@ -489,6 +490,7 @@ static const ulong32 rs_tab7[256] = {
#endif /* LTC_TWOFISH_ALL_TABLES */
+#endif /* __LTC_TWOFISH_TAB_C__ */
#endif
/* $Source$ */
View
6 src/hashes/sha2/sha224.c
@@ -13,6 +13,10 @@
LTC_SHA-224 new NIST standard based off of LTC_SHA-256 truncated to 224 bits (Tom St Denis)
*/
+#include "tomcrypt.h"
+
+#if defined(LTC_SHA224) && defined(LTC_SHA256)
+
const struct ltc_hash_descriptor sha224_desc =
{
"sha224",
@@ -119,6 +123,8 @@ int sha224_test(void)
#endif
}
+#endif /* defined(LTC_SHA224) && defined(LTC_SHA256) */
+
/* $Source$ */
/* $Revision$ */
View
4 src/hashes/sha2/sha256.c
@@ -327,10 +327,6 @@ int sha256_test(void)
#endif
}
-#ifdef LTC_SHA224
-#include "sha224.c"
-#endif
-
#endif
View
9 src/hashes/sha2/sha384.c
@@ -13,6 +13,10 @@
LTC_SHA384 hash included in sha512.c, Tom St Denis
*/
+#include "tomcrypt.h"
+
+#if defined(LTC_SHA384) && defined(LTC_SHA512)
+
const struct ltc_hash_descriptor sha384_desc =
{
"sha384",
@@ -125,10 +129,7 @@ int sha384_test(void)
#endif
}
-
-
-
-
+#endif /* defined(LTC_SHA384) && defined(LTC_SHA512) */
/* $Source$ */
/* $Revision$ */
View
4 src/hashes/sha2/sha512.c
@@ -305,10 +305,6 @@ int sha512_test(void)
#endif
}
-#ifdef LTC_SHA384
- #include "sha384.c"
-#endif
-
#endif
View
1  src/hashes/whirl/whirl.c
@@ -37,6 +37,7 @@ const struct ltc_hash_descriptor whirlpool_desc =
};
/* the sboxes */
+#define __LTC_WHIRLTAB_C__
#include "whirltab.c"
/* get a_{i,j} */
View
4 src/hashes/whirl/whirltab.c
@@ -2,6 +2,9 @@
@file whirltab.c
LTC_WHIRLPOOL tables, Tom St Denis
*/
+
+#ifdef __LTC_WHIRLTAB_C__
+
static const ulong64 sbox0[] = {
CONST64(0x18186018c07830d8), CONST64(0x23238c2305af4626), CONST64(0xc6c63fc67ef991b8), CONST64(0xe8e887e8136fcdfb),
CONST64(0x878726874ca113cb), CONST64(0xb8b8dab8a9626d11), CONST64(0x0101040108050209), CONST64(0x4f4f214f426e9e0d),
@@ -577,6 +580,7 @@ CONST64(0xca2dbf07ad5a8333),
CONST64(0x6302aa71c81949d9),
};
+#endif /* __LTC_WHIRLTAB_C__ */
/* $Source$ */
/* $Revision$ */
View
1  src/mac/pelican/pelican.c
@@ -17,6 +17,7 @@
#ifdef LTC_PELICAN
+#define __LTC_AES_TAB_C__
#define ENCRYPT_ONLY
#define PELI_TAB
#include "../../ciphers/aes/aes_tab.c"
View
233 src/pk/dh/dh.c
@@ -17,231 +17,8 @@
#ifdef LTC_MDH
- /* size of a packet header in bytes */
- #define PACKET_SIZE 4
-
- /* Section tags */
- #define PACKET_SECT_DH 1
-
- /* 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
-
-#define OUTPUT_BIGNUM(num, out, y, z) \
-{ \
- if ((y + 4) > *outlen) { return CRYPT_BUFFER_OVERFLOW; } \
- z = (unsigned long)mp_unsigned_bin_size(num); \
- STORE32L(z, out+y); \
- y += 4; \
- if ((y + z) > *outlen) { return CRYPT_BUFFER_OVERFLOW; } \
- if ((err = mp_to_unsigned_bin(num, out+y)) != CRYPT_OK) { return err; } \
- y += z; \
-}
-
-#define INPUT_BIGNUM(num, in, x, y, inlen) \
-{ \
- /* load value */ \
- if ((y + 4) > inlen) { \
- err = CRYPT_INVALID_PACKET; \
- goto error; \
- } \
- LOAD32L(x, in+y); \
- y += 4; \
- \
- /* sanity check... */ \
- if ((x+y) > inlen) { \
- err = CRYPT_INVALID_PACKET; \
- goto error; \
- } \
- \
- /* load it */ \
- if ((err = mp_read_unsigned_bin(num, (unsigned char *)in+y, (int)x)) != CRYPT_OK) {\
- goto error; \
- } \
- y += x; \
-}
-
-static void packet_store_header(unsigned char *dst, int section, int subsection)
-{
- LTC_ARGCHK(dst != NULL);
-
- /* store version number */
- dst[0] = (unsigned char)(CRYPT&255);
- dst[1] = (unsigned char)((CRYPT>>8)&255);
-
- /* store section and subsection */
- dst[2] = (unsigned char)(section & 255);
- dst[3] = (unsigned char)(subsection & 255);
-
-}
-
-static int packet_valid_header(unsigned char *src, int section, int subsection)
-{
- unsigned long ver;
-
- LTC_ARGCHK(src != NULL);
-
- /* check version */
- ver = ((unsigned long)src[0]) | ((unsigned long)src[1] << 8U);
- if (CRYPT < ver) {
- return CRYPT_INVALID_PACKET;
- }
- /* check section and subsection */
- if (section != (int)src[2] || subsection != (int)src[3]) {
- return CRYPT_INVALID_PACKET;
- }
-
- return CRYPT_OK;
-}
-
-
-/* max export size we'll encounter (smaller than this but lets round up a bit) */
-#define DH_BUF_SIZE 1200
-
-/* This holds the key settings. ***MUST*** be organized by size from smallest to largest. */
-static const struct {
- int size;
- char *name, *base, *prime;
-} sets[] = {
-#ifdef DH768
-{
- 96,
- "DH-768",
- "4",
- "F///////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "//////m3wvV"
-},
-#endif
-#ifdef DH1024
-{
- 128,
- "DH-1024",
- "4",
- "F///////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////m3C47"
-},
-#endif
-#ifdef DH1280
-{
- 160,
- "DH-1280",
- "4",
- "F///////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "//////////////////////////////m4kSN"
-},
-#endif
-#ifdef DH1536
-{
- 192,
- "DH-1536",
- "4",
- "F///////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////m5uqd"
-},
-#endif
-#ifdef DH1792
-{
- 224,
- "DH-1792",
- "4",
- "F///////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "//////////////////////////////////////////////////////mT/sd"
-},
-#endif
-#ifdef DH2048
-{
- 256,
- "DH-2048",
- "4",
- "3///////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "/////////////////////////////////////////m8MPh"
-},
-#endif
-#ifdef DH2560
-{
- 320,
- "DH-2560",
- "4",
- "3///////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "/////mKFpF"
-},
-#endif
-#ifdef DH3072
-{
- 384,
- "DH-3072",
- "4",
- "3///////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "/////////////////////////////m32nN"
-},
-#endif
-#ifdef DH4096
-{
- 512,
- "DH-4096",
- "4",
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "////////////////////////////////////////////////////////////"
- "/////////////////////m8pOF"
-},
-#endif
-{
- 0,
- NULL,
- NULL,
- NULL
-}
-};
-
-static int is_valid_idx(int n)
-{
- int x;
-
- for (x = 0; sets[x].size; x++);
- if ((n < 0) || (n >= x)) {
- return 0;
- }
- return 1;
-}
+#include "dh_static.h"
/**
Test the DH sub-system (can take a while)
@@ -318,7 +95,7 @@ void dh_sizes(int *low, int *high)
int dh_get_size(dh_key *key)
{
LTC_ARGCHK(key != NULL);
- if (is_valid_idx(key->idx) == 1) {
+ if (dh_is_valid_idx(key->idx) == 1) {
return sets[key->idx].size;
} else {
return INT_MAX; /* large value that would cause dh_make_key() to fail */
@@ -523,7 +300,7 @@ int dh_import(const unsigned char *in, unsigned long inlen, dh_key *key)
}
/* is the key idx valid? */
- if (is_valid_idx(key->idx) != 1) {
+ if (dh_is_valid_idx(key->idx) != 1) {
err = CRYPT_PK_TYPE_MISMATCH;
goto error;
}
@@ -601,6 +378,4 @@ int dh_shared_secret(dh_key *private_key, dh_key *public_key,
return err;
}
-#include "dh_sys.c"
-
-#endif
+#endif /* LTC_MDH */
View
163 src/pk/dh/dh_static.c
@@ -0,0 +1,163 @@
+/* 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@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file dh_static.c
+ DH crypto, Tom St Denis
+*/
+
+#ifdef LTC_MDH
+
+#define __DECL_DH_STATIC_H__
+#include "dh_static.h"
+
+/* This holds the key settings. ***MUST*** be organized by size from smallest to largest. */
+const dh_set sets[] = {
+#ifdef DH768
+{
+ 96,
+ "DH-768",
+ "4",
+ "F///////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "//////m3wvV"
+},
+#endif
+#ifdef DH1024
+{
+ 128,
+ "DH-1024",
+ "4",
+ "F///////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////m3C47"
+},
+#endif
+#ifdef DH1280
+{
+ 160,
+ "DH-1280",
+ "4",
+ "F///////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "//////////////////////////////m4kSN"
+},
+#endif
+#ifdef DH1536
+{
+ 192,
+ "DH-1536",
+ "4",
+ "F///////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////m5uqd"
+},
+#endif
+#ifdef DH1792
+{
+ 224,
+ "DH-1792",
+ "4",
+ "F///////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "//////////////////////////////////////////////////////mT/sd"
+},
+#endif
+#ifdef DH2048
+{
+ 256,
+ "DH-2048",
+ "4",
+ "3///////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "/////////////////////////////////////////m8MPh"
+},
+#endif
+#ifdef DH2560
+{
+ 320,
+ "DH-2560",
+ "4",
+ "3///////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "/////mKFpF"
+},
+#endif
+#ifdef DH3072
+{
+ 384,
+ "DH-3072",
+ "4",
+ "3///////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "/////////////////////////////m32nN"
+},
+#endif
+#ifdef DH4096
+{
+ 512,
+ "DH-4096",
+ "4",
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "////////////////////////////////////////////////////////////"
+ "/////////////////////m8pOF"
+},
+#endif
+{
+ 0,
+ NULL,
+ NULL,
+ NULL
+}
+};
+
+int dh_is_valid_idx(int n)
+{
+ int x;
+
+ for (x = 0; sets[x].size; x++);
+ if ((n < 0) || (n >= x)) {
+ return 0;
+ }
+ return 1;
+}
+
+
+#endif /* LTC_MDH */
View
125 src/pk/dh/dh_static.h
@@ -0,0 +1,125 @@
+#ifndef __DH_STATIC_H__
+#define __DH_STATIC_H__
+#ifndef __DECL_DH_STATIC_H__
+#define __DECL_DH_STATIC_H__ extern
+#endif
+
+/* 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@gmail.com, http://libtomcrypt.org
+ */
+#include "tomcrypt.h"
+
+/**
+ @file dh_static.h
+ DH crypto, Tom St Denis
+*/
+
+#ifdef LTC_MDH
+
+/* size of a packet header in bytes */
+#define PACKET_SIZE 4
+
+/* Section tags */
+#define PACKET_SECT_DH 1
+
+/* 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
+
+#define OUTPUT_BIGNUM(num, out, y, z) \
+{ \
+ if ((y + 4) > *outlen) { return CRYPT_BUFFER_OVERFLOW; } \
+ z = (unsigned long)mp_unsigned_bin_size(num); \
+ STORE32L(z, out+y); \
+ y += 4; \
+ if ((y + z) > *outlen) { return CRYPT_BUFFER_OVERFLOW; } \
+ if ((err = mp_to_unsigned_bin(num, out+y)) != CRYPT_OK) { return err; } \
+ y += z; \
+}
+
+#define INPUT_BIGNUM(num, in, x, y, inlen) \
+{ \
+ /* load value */ \
+ if ((y + 4) > inlen) { \
+ err = CRYPT_INVALID_PACKET; \
+ goto error; \
+ } \
+ LOAD32L(x, in+y); \
+ y += 4; \
+ \
+ /* sanity check... */ \
+ if ((x+y) > inlen) { \
+ err = CRYPT_INVALID_PACKET; \
+ goto error; \
+ } \
+ \
+ /* load it */ \
+ if ((err = mp_read_unsigned_bin(num, (unsigned char *)in+y, (int)x)) != CRYPT_OK) {\
+ goto error; \
+ } \
+ y += x; \
+}
+
+static inline void packet_store_header (unsigned char *dst, int section, int subsection)
+{
+ LTC_ARGCHK(dst != NULL);
+
+ /* store version number */
+ dst[0] = (unsigned char)(CRYPT&255);
+ dst[1] = (unsigned char)((CRYPT>>8)&255);
+
+ /* store section and subsection */
+ dst[2] = (unsigned char)(section & 255);
+ dst[3] = (unsigned char)(subsection & 255);
+
+}
+
+static inline int packet_valid_header (unsigned char *src, int section, int subsection)
+{
+ unsigned long ver;
+
+ LTC_ARGCHK(src != NULL);
+
+ /* check version */
+ ver = ((unsigned long)src[0]) | ((unsigned long)src[1] << 8U);
+ if (CRYPT < ver) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ /* check section and subsection */
+ if (section != (int)src[2] || subsection != (int)src[3]) {
+ return CRYPT_INVALID_PACKET;
+ }
+
+ return CRYPT_OK;
+}
+
+#ifndef DH_BUF_SIZE
+/* max export size we'll encounter (smaller than this but lets round up a bit) */
+#define DH_BUF_SIZE 1200
+#endif /* DH_BUF_SIZE */
+
+typedef struct {
+ int size;
+ char *name, *base, *prime;
+} dh_set;
+
+/* This holds the key settings. ***MUST*** be organized by size from smallest to largest. */
+__DECL_DH_STATIC_H__ const dh_set sets[];
+
+
+int dh_is_valid_idx(int n);
+
+
+#endif /* __DH_STATIC_H__ */
+
+#endif /* LTC_MDH */
View
20 src/pk/dh/dh_sys.c
@@ -9,11 +9,17 @@
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
*/
+#include "tomcrypt.h"
+
+#ifdef LTC_MDH
/**
@file dh_sys.c
DH Crypto, Tom St Denis
*/
+#include "dh_static.h"
+
+
/**
Encrypt a short symmetric key with a public DH key
@param in The symmetric key to encrypt
@@ -33,7 +39,7 @@ int dh_encrypt_key(const unsigned char *in, unsigned long inlen,
{
unsigned char *pub_expt, *dh_shared, *skey;
dh_key pubkey;
- unsigned long x, y, z, hashsize, pubkeysize;
+ unsigned long x, y, z, pubkeysize;
int err;
LTC_ARGCHK(in != NULL);
@@ -89,9 +95,6 @@ int dh_encrypt_key(const unsigned char *in, unsigned long inlen,
goto LBL_ERR;
}
- /* make random key */
- hashsize = hash_descriptor[hash].hashsize;
-
x = DH_BUF_SIZE;
if ((err = dh_shared_secret(&pubkey, key, dh_shared, &x)) != CRYPT_OK) {
dh_free(&pubkey);
@@ -158,7 +161,7 @@ int dh_decrypt_key(const unsigned char *in, unsigned long inlen,
dh_key *key)
{
unsigned char *shared_secret, *skey;
- unsigned long x, y, z, hashsize, keysize;
+ unsigned long x, y, z, keysize;
int hash, err;
dh_key pubkey;
@@ -206,9 +209,6 @@ int dh_decrypt_key(const unsigned char *in, unsigned long inlen,
goto LBL_ERR;
}
- /* common values */
- hashsize = hash_descriptor[hash].hashsize;
-
/* get public key */
LOAD32L(x, in+y);
@@ -329,7 +329,7 @@ int dh_sign_hash(const unsigned char *in, unsigned long inlen,
}
/* is the IDX valid ? */
- if (is_valid_idx(key->idx) != 1) {
+ if (dh_is_valid_idx(key->idx) != 1) {
return CRYPT_PK_INVALID_TYPE;
}
@@ -488,3 +488,5 @@ int dh_verify_hash(const unsigned char *sig, unsigned long siglen,
mp_clear_multi(tmp, m, g, p, b, a, NULL);
return err;
}
+
+#endif /* LTC_MDH */
View
1  src/prngs/sober128.c
@@ -18,6 +18,7 @@
#ifdef LTC_SOBER128
+#define __LTC_SOBER128TAB_C__
#include "sober128tab.c"
const struct ltc_prng_descriptor sober128_desc =
View
5 src/prngs/sober128tab.c
@@ -2,6 +2,9 @@
@file sober128tab.c
SOBER-128 Tables
*/
+
+#ifdef __LTC_SOBER128TAB_C__
+
/* $ID$ */
/* @(#)TuringMultab.h 1.3 (QUALCOMM) 02/09/03 */
/* Multiplication table for Turing using 0xD02B4367 */
@@ -157,6 +160,8 @@ static const ulong32 Sbox[256] = {
0xf9e6053f, 0xa4b0d300, 0xd499cbcc, 0xb95e3d40,
};
+#endif /* __LTC_SOBER128TAB_C__ */
+
/* $Source$ */
/* $Revision$ */
/* $Date$ */
Something went wrong with that request. Please try again.