diff options
| author | Greg Hudson <ghudson@mit.edu> | 2011-03-02 05:29:29 +0000 |
|---|---|---|
| committer | Greg Hudson <ghudson@mit.edu> | 2011-03-02 05:29:29 +0000 |
| commit | ce6d249fdf1dd7dda5b202836ed387500324ae2a (patch) | |
| tree | b0550b898743ddfdff76ac6647fca7a12d6db284 /src/lib/crypto/crypto_tests | |
| parent | e2d6d9ce23b878334d70a0f9c697064873619b75 (diff) | |
Consolidate almost all lib/crypto/krb headers into a single
crypto_int.h. In that header, define and document responsibilities
for crypto modules, some of which are satisfied through a
module-specific crypto_mod.h. In the OpenSSL and NSS modules, remove
many of the headers and sources providing functionality which isn't
needed by lib/crypto/krb any more (direct interfaces to MD4, MD5, and
SHA-1 hashing, as well as DES weak key testing). Change most
Makefile.ins to only include headers from lib/crypto/krb and
lib/crypto/$(CRYPTO_IMPL), instead of from many different directories.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24677 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/crypto/crypto_tests')
| -rw-r--r-- | src/lib/crypto/crypto_tests/Makefile.in | 12 | ||||
| -rw-r--r-- | src/lib/crypto/crypto_tests/aes-test.c | 2 | ||||
| -rw-r--r-- | src/lib/crypto/crypto_tests/deps | 91 | ||||
| -rw-r--r-- | src/lib/crypto/crypto_tests/t_cmac.c | 4 | ||||
| -rw-r--r-- | src/lib/crypto/crypto_tests/t_crc.c | 3 | ||||
| -rw-r--r-- | src/lib/crypto/crypto_tests/t_cts.c | 2 | ||||
| -rw-r--r-- | src/lib/crypto/crypto_tests/t_derive.c | 4 | ||||
| -rw-r--r-- | src/lib/crypto/crypto_tests/t_encrypt.c | 3 | ||||
| -rw-r--r-- | src/lib/crypto/crypto_tests/t_hmac.c | 2 | ||||
| -rw-r--r-- | src/lib/crypto/crypto_tests/t_mddriver.c | 159 | ||||
| -rw-r--r-- | src/lib/crypto/crypto_tests/t_nfold.c | 2 | ||||
| -rw-r--r-- | src/lib/crypto/crypto_tests/vectors.c | 2 |
12 files changed, 110 insertions, 176 deletions
diff --git a/src/lib/crypto/crypto_tests/Makefile.in b/src/lib/crypto/crypto_tests/Makefile.in index 81f9b5e0a..e137083ec 100644 --- a/src/lib/crypto/crypto_tests/Makefile.in +++ b/src/lib/crypto/crypto_tests/Makefile.in @@ -1,16 +1,6 @@ mydir=lib$(S)crypto$(S)crypto_tests BUILDTOP=$(REL)..$(S)..$(S).. -LOCALINCLUDES = -I$(srcdir)/../krb -I$(srcdir)/../$(CRYPTO_IMPL)/enc_provider \ - -I$(srcdir)/../$(CRYPTO_IMPL)/hash_provider \ - -I$(srcdir)/../krb/keyhash_provider -I$(srcdir)/../krb/dk \ - -I$(srcdir)/../$(CRYPTO_IMPL) -I$(srcdir)/../krb/prng \ - -I$(srcdir)/../krb/prng/$(PRNG_ALG) -I$(srcdir)/../krb/crc32 \ - -I$(srcdir)/../krb/old -I$(srcdir)/../krb/raw \ - -I$(srcdir)/../$(CRYPTO_IMPL)/aes -I$(srcdir)/../$(CRYPTO_IMPL)/des \ - -I$(srcdir)/../$(CRYPTO_IMPL)/arcfour \ - -I$(srcdir)/../$(CRYPTO_IMPL)/sha1 \ - -I$(srcdir)/../$(CRYPTO_IMPL)/md5 -I$(srcdir)/../$(CRYPTO_IMPL)/md4 \ - -I$(srcdir)/../$(CRYPTO_IMPL)/camellia +LOCALINCLUDES = -I$(srcdir)/../krb -I$(srcdir)/../$(CRYPTO_IMPL) RUN_SETUP = @KRB5_RUN_ENV@ PROG_LIBPATH=-L$(TOPLIBD) PROG_RPATH=$(KRB5_LIBDIR) diff --git a/src/lib/crypto/crypto_tests/aes-test.c b/src/lib/crypto/crypto_tests/aes-test.c index 4c0618a47..b86b5ab8c 100644 --- a/src/lib/crypto/crypto_tests/aes-test.c +++ b/src/lib/crypto/crypto_tests/aes-test.c @@ -30,7 +30,7 @@ */ #include <stdio.h> -#include "k5-int.h" +#include "crypto_int.h" static char key[32]; static char plain[16], cipher[16], zero[16]; diff --git a/src/lib/crypto/crypto_tests/deps b/src/lib/crypto/crypto_tests/deps index 7849b8afe..01aa2dc0f 100644 --- a/src/lib/crypto/crypto_tests/deps +++ b/src/lib/crypto/crypto_tests/deps @@ -3,18 +3,22 @@ # $(OUTPRE)t_nfold.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \ - $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(top_srcdir)/include/k5-buf.h \ - $(top_srcdir)/include/k5-err.h $(top_srcdir)/include/k5-gmt_mktime.h \ - $(top_srcdir)/include/k5-int-pkinit.h $(top_srcdir)/include/k5-int.h \ - $(top_srcdir)/include/k5-platform.h $(top_srcdir)/include/k5-plugin.h \ - $(top_srcdir)/include/k5-thread.h $(top_srcdir)/include/k5-trace.h \ - $(top_srcdir)/include/krb5.h $(top_srcdir)/include/krb5/authdata_plugin.h \ - $(top_srcdir)/include/krb5/plugin.h $(top_srcdir)/include/krb5/preauth_plugin.h \ - $(top_srcdir)/include/port-sockets.h $(top_srcdir)/include/socket-utils.h \ - t_nfold.c + $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../builtin/aes/aes.h \ + $(srcdir)/../builtin/aes/uitypes.h $(srcdir)/../builtin/crypto_mod.h \ + $(srcdir)/../builtin/sha2/sha2.h $(srcdir)/../krb/crypto_int.h \ + $(top_srcdir)/include/k5-buf.h $(top_srcdir)/include/k5-err.h \ + $(top_srcdir)/include/k5-gmt_mktime.h $(top_srcdir)/include/k5-int-pkinit.h \ + $(top_srcdir)/include/k5-int.h $(top_srcdir)/include/k5-platform.h \ + $(top_srcdir)/include/k5-plugin.h $(top_srcdir)/include/k5-thread.h \ + $(top_srcdir)/include/k5-trace.h $(top_srcdir)/include/krb5.h \ + $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \ + $(top_srcdir)/include/krb5/preauth_plugin.h $(top_srcdir)/include/port-sockets.h \ + $(top_srcdir)/include/socket-utils.h t_nfold.c $(OUTPRE)t_encrypt.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \ - $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../krb/etypes.h \ + $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../builtin/aes/aes.h \ + $(srcdir)/../builtin/aes/uitypes.h $(srcdir)/../builtin/crypto_mod.h \ + $(srcdir)/../builtin/sha2/sha2.h $(srcdir)/../krb/crypto_int.h \ $(top_srcdir)/include/k5-buf.h $(top_srcdir)/include/k5-err.h \ $(top_srcdir)/include/k5-gmt_mktime.h $(top_srcdir)/include/k5-int-pkinit.h \ $(top_srcdir)/include/k5-int.h $(top_srcdir)/include/k5-platform.h \ @@ -58,8 +62,9 @@ $(OUTPRE)t_prng.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ t_prng.c $(OUTPRE)t_cmac.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \ - $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../krb/cksumtypes.h \ - $(srcdir)/../krb/etypes.h $(srcdir)/../openssl/enc_provider/enc_provider.h \ + $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../builtin/aes/aes.h \ + $(srcdir)/../builtin/aes/uitypes.h $(srcdir)/../builtin/crypto_mod.h \ + $(srcdir)/../builtin/sha2/sha2.h $(srcdir)/../krb/crypto_int.h \ $(top_srcdir)/include/k5-buf.h $(top_srcdir)/include/k5-err.h \ $(top_srcdir)/include/k5-gmt_mktime.h $(top_srcdir)/include/k5-int-pkinit.h \ $(top_srcdir)/include/k5-int.h $(top_srcdir)/include/k5-platform.h \ @@ -70,7 +75,9 @@ $(OUTPRE)t_cmac.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(top_srcdir)/include/socket-utils.h t_cmac.c $(OUTPRE)t_hmac.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \ - $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../openssl/hash_provider/hash_provider.h \ + $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../builtin/aes/aes.h \ + $(srcdir)/../builtin/aes/uitypes.h $(srcdir)/../builtin/crypto_mod.h \ + $(srcdir)/../builtin/sha2/sha2.h $(srcdir)/../krb/crypto_int.h \ $(top_srcdir)/include/k5-buf.h $(top_srcdir)/include/k5-err.h \ $(top_srcdir)/include/k5-gmt_mktime.h $(top_srcdir)/include/k5-int-pkinit.h \ $(top_srcdir)/include/k5-int.h $(top_srcdir)/include/k5-platform.h \ @@ -92,7 +99,9 @@ $(OUTPRE)t_pkcs5.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ t_pkcs5.c $(OUTPRE)t_cts.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \ - $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../openssl/hash_provider/hash_provider.h \ + $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../builtin/aes/aes.h \ + $(srcdir)/../builtin/aes/uitypes.h $(srcdir)/../builtin/crypto_mod.h \ + $(srcdir)/../builtin/sha2/sha2.h $(srcdir)/../krb/crypto_int.h \ $(top_srcdir)/include/k5-buf.h $(top_srcdir)/include/k5-err.h \ $(top_srcdir)/include/k5-gmt_mktime.h $(top_srcdir)/include/k5-int-pkinit.h \ $(top_srcdir)/include/k5-int.h $(top_srcdir)/include/k5-platform.h \ @@ -103,7 +112,9 @@ $(OUTPRE)t_cts.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(top_srcdir)/include/socket-utils.h t_cts.c $(OUTPRE)vectors.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \ - $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../openssl/hash_provider/hash_provider.h \ + $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../builtin/aes/aes.h \ + $(srcdir)/../builtin/aes/uitypes.h $(srcdir)/../builtin/crypto_mod.h \ + $(srcdir)/../builtin/sha2/sha2.h $(srcdir)/../krb/crypto_int.h \ $(top_srcdir)/include/k5-buf.h $(top_srcdir)/include/k5-err.h \ $(top_srcdir)/include/k5-gmt_mktime.h $(top_srcdir)/include/k5-int-pkinit.h \ $(top_srcdir)/include/k5-int.h $(top_srcdir)/include/k5-platform.h \ @@ -114,15 +125,17 @@ $(OUTPRE)vectors.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(top_srcdir)/include/socket-utils.h vectors.c $(OUTPRE)aes-test.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \ - $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(top_srcdir)/include/k5-buf.h \ - $(top_srcdir)/include/k5-err.h $(top_srcdir)/include/k5-gmt_mktime.h \ - $(top_srcdir)/include/k5-int-pkinit.h $(top_srcdir)/include/k5-int.h \ - $(top_srcdir)/include/k5-platform.h $(top_srcdir)/include/k5-plugin.h \ - $(top_srcdir)/include/k5-thread.h $(top_srcdir)/include/k5-trace.h \ - $(top_srcdir)/include/krb5.h $(top_srcdir)/include/krb5/authdata_plugin.h \ - $(top_srcdir)/include/krb5/plugin.h $(top_srcdir)/include/krb5/preauth_plugin.h \ - $(top_srcdir)/include/port-sockets.h $(top_srcdir)/include/socket-utils.h \ - aes-test.c + $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../builtin/aes/aes.h \ + $(srcdir)/../builtin/aes/uitypes.h $(srcdir)/../builtin/crypto_mod.h \ + $(srcdir)/../builtin/sha2/sha2.h $(srcdir)/../krb/crypto_int.h \ + $(top_srcdir)/include/k5-buf.h $(top_srcdir)/include/k5-err.h \ + $(top_srcdir)/include/k5-gmt_mktime.h $(top_srcdir)/include/k5-int-pkinit.h \ + $(top_srcdir)/include/k5-int.h $(top_srcdir)/include/k5-platform.h \ + $(top_srcdir)/include/k5-plugin.h $(top_srcdir)/include/k5-thread.h \ + $(top_srcdir)/include/k5-trace.h $(top_srcdir)/include/krb5.h \ + $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \ + $(top_srcdir)/include/krb5/preauth_plugin.h $(top_srcdir)/include/port-sockets.h \ + $(top_srcdir)/include/socket-utils.h aes-test.c $(OUTPRE)camellia-test.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \ $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(top_srcdir)/include/k5-buf.h \ @@ -158,7 +171,9 @@ $(OUTPRE)t_cksums.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ t_cksums.c $(OUTPRE)t_crc.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \ - $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../krb/crc32/crc-32.h \ + $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../builtin/aes/aes.h \ + $(srcdir)/../builtin/aes/uitypes.h $(srcdir)/../builtin/crypto_mod.h \ + $(srcdir)/../builtin/sha2/sha2.h $(srcdir)/../krb/crypto_int.h \ $(top_srcdir)/include/k5-buf.h $(top_srcdir)/include/k5-err.h \ $(top_srcdir)/include/k5-gmt_mktime.h $(top_srcdir)/include/k5-int-pkinit.h \ $(top_srcdir)/include/k5-int.h $(top_srcdir)/include/k5-platform.h \ @@ -169,7 +184,9 @@ $(OUTPRE)t_crc.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(top_srcdir)/include/socket-utils.h t_crc.c $(OUTPRE)t_mddriver.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \ - $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../openssl/md5/rsa-md5.h \ + $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../builtin/aes/aes.h \ + $(srcdir)/../builtin/aes/uitypes.h $(srcdir)/../builtin/crypto_mod.h \ + $(srcdir)/../builtin/sha2/sha2.h $(srcdir)/../krb/crypto_int.h \ $(top_srcdir)/include/k5-buf.h $(top_srcdir)/include/k5-err.h \ $(top_srcdir)/include/k5-gmt_mktime.h $(top_srcdir)/include/k5-int-pkinit.h \ $(top_srcdir)/include/k5-int.h $(top_srcdir)/include/k5-platform.h \ @@ -213,17 +230,17 @@ $(OUTPRE)t_str2key.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ t_str2key.c $(OUTPRE)t_derive.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \ - $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../krb/cksumtypes.h \ - $(srcdir)/../krb/dk/dk.h $(srcdir)/../krb/etypes.h \ - $(srcdir)/../openssl/enc_provider/enc_provider.h $(top_srcdir)/include/k5-buf.h \ - $(top_srcdir)/include/k5-err.h $(top_srcdir)/include/k5-gmt_mktime.h \ - $(top_srcdir)/include/k5-int-pkinit.h $(top_srcdir)/include/k5-int.h \ - $(top_srcdir)/include/k5-platform.h $(top_srcdir)/include/k5-plugin.h \ - $(top_srcdir)/include/k5-thread.h $(top_srcdir)/include/k5-trace.h \ - $(top_srcdir)/include/krb5.h $(top_srcdir)/include/krb5/authdata_plugin.h \ - $(top_srcdir)/include/krb5/plugin.h $(top_srcdir)/include/krb5/preauth_plugin.h \ - $(top_srcdir)/include/port-sockets.h $(top_srcdir)/include/socket-utils.h \ - t_derive.c + $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../builtin/aes/aes.h \ + $(srcdir)/../builtin/aes/uitypes.h $(srcdir)/../builtin/crypto_mod.h \ + $(srcdir)/../builtin/sha2/sha2.h $(srcdir)/../krb/crypto_int.h \ + $(top_srcdir)/include/k5-buf.h $(top_srcdir)/include/k5-err.h \ + $(top_srcdir)/include/k5-gmt_mktime.h $(top_srcdir)/include/k5-int-pkinit.h \ + $(top_srcdir)/include/k5-int.h $(top_srcdir)/include/k5-platform.h \ + $(top_srcdir)/include/k5-plugin.h $(top_srcdir)/include/k5-thread.h \ + $(top_srcdir)/include/k5-trace.h $(top_srcdir)/include/krb5.h \ + $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \ + $(top_srcdir)/include/krb5/preauth_plugin.h $(top_srcdir)/include/port-sockets.h \ + $(top_srcdir)/include/socket-utils.h t_derive.c $(OUTPRE)t_fork.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \ $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(top_srcdir)/include/k5-buf.h \ diff --git a/src/lib/crypto/crypto_tests/t_cmac.c b/src/lib/crypto/crypto_tests/t_cmac.c index 47afd53f3..c140f24f5 100644 --- a/src/lib/crypto/crypto_tests/t_cmac.c +++ b/src/lib/crypto/crypto_tests/t_cmac.c @@ -38,9 +38,7 @@ * krb5int_cmac_checksum. */ -#include "k5-int.h" -#include "enc_provider.h" -#include "cksumtypes.h" +#include "crypto_int.h" #ifdef CAMELLIA diff --git a/src/lib/crypto/crypto_tests/t_crc.c b/src/lib/crypto/crypto_tests/t_crc.c index 99b2b5ee7..d8b0ea74f 100644 --- a/src/lib/crypto/crypto_tests/t_crc.c +++ b/src/lib/crypto/crypto_tests/t_crc.c @@ -31,8 +31,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "k5-int.h" -#include "crc-32.h" +#include "crypto_int.h" #define HEX 1 #define STR 2 diff --git a/src/lib/crypto/crypto_tests/t_cts.c b/src/lib/crypto/crypto_tests/t_cts.c index da697bde1..90155f780 100644 --- a/src/lib/crypto/crypto_tests/t_cts.c +++ b/src/lib/crypto/crypto_tests/t_cts.c @@ -37,7 +37,7 @@ #include <stdio.h> #include <string.h> #include <ctype.h> -#include "hash_provider.h" +#include "crypto_int.h" #define ASIZE(ARRAY) (sizeof(ARRAY)/sizeof(ARRAY[0])) diff --git a/src/lib/crypto/crypto_tests/t_derive.c b/src/lib/crypto/crypto_tests/t_derive.c index 49b0bb5fa..f221ebff5 100644 --- a/src/lib/crypto/crypto_tests/t_derive.c +++ b/src/lib/crypto/crypto_tests/t_derive.c @@ -29,9 +29,7 @@ * With the -v flag, results for all tests are displayed. */ -#include "k5-int.h" -#include "../krb/dk/dk.h" -#include "enc_provider/enc_provider.h" +#include "crypto_int.h" struct test { krb5_enctype enctype; diff --git a/src/lib/crypto/crypto_tests/t_encrypt.c b/src/lib/crypto/crypto_tests/t_encrypt.c index 5008ab015..db75e22a8 100644 --- a/src/lib/crypto/crypto_tests/t_encrypt.c +++ b/src/lib/crypto/crypto_tests/t_encrypt.c @@ -31,8 +31,7 @@ * Some black-box tests of crypto systems. Make sure that we can decrypt things we encrypt, etc. */ -#include "k5-int.h" -#include "etypes.h" +#include "crypto_int.h" #include <stdio.h> /* What enctypes should we test?*/ diff --git a/src/lib/crypto/crypto_tests/t_hmac.c b/src/lib/crypto/crypto_tests/t_hmac.c index 1056ff62f..ec49d615d 100644 --- a/src/lib/crypto/crypto_tests/t_hmac.c +++ b/src/lib/crypto/crypto_tests/t_hmac.c @@ -34,7 +34,7 @@ #include <string.h> #include <ctype.h> -#include "hash_provider.h" +#include "crypto_int.h" #define ASIZE(ARRAY) (sizeof(ARRAY)/sizeof(ARRAY[0])) diff --git a/src/lib/crypto/crypto_tests/t_mddriver.c b/src/lib/crypto/crypto_tests/t_mddriver.c index b3af381f6..68435139c 100644 --- a/src/lib/crypto/crypto_tests/t_mddriver.c +++ b/src/lib/crypto/crypto_tests/t_mddriver.c @@ -21,28 +21,17 @@ #define MD 5 #endif -#include "k5-int.h" - -#if MD == 2 -#include "md2.h" -#endif -#if MD == 4 -#include "rsa-md4.h" -#endif -#if MD == 5 -#include "rsa-md5.h" -#endif +#include "crypto_int.h" /* Length of test block, number of test blocks. */ #define TEST_BLOCK_LEN 1000 #define TEST_BLOCK_COUNT 1000 +static void MDHash (char *, size_t, size_t, unsigned char *); static void MDString (char *); static void MDTimeTrial (void); static void MDTestSuite (void); -static void MDFile (char *); -static void MDFilter (void); static void MDPrint (unsigned char [16]); struct md_test_entry { @@ -50,18 +39,8 @@ struct md_test_entry { unsigned char digest[16]; }; -#if MD == 2 -#define MD_CTX krb5_MD2_CTX -#define MDInit krb5_MD2Init -#define MDUpdate krb5_MD2Update -#define MDFinal krb5_MD2Final -#endif - #if MD == 4 -#define MD_CTX krb5_MD4_CTX -#define MDInit krb5int_MD4Init -#define MDUpdate krb5int_MD4Update -#define MDFinal krb5int_MD4Final +#define MDProvider krb5int_hash_md4 #define HAVE_TEST_SUITE /* Test suite from RFC 1320 */ @@ -94,10 +73,7 @@ struct md_test_entry md_test_suite[] = { #endif #if MD == 5 -#define MD_CTX krb5_MD5_CTX -#define MDInit krb5int_MD5Init -#define MDUpdate krb5int_MD5Update -#define MDFinal krb5int_MD5Final +#define MDProvider krb5int_hash_md5 #define HAVE_TEST_SUITE /* Test suite from RFC 1321 */ @@ -135,8 +111,6 @@ struct md_test_entry md_test_suite[] = { -sstring - digests string -t - runs time trial -x - runs test script - filename - digests file - (none) - digests standard input */ int main (argc, argv) int argc; @@ -144,36 +118,47 @@ int main (argc, argv) { int i; - if (argc > 1) - for (i = 1; i < argc; i++) - if (argv[i][0] == '-' && argv[i][1] == 's') - MDString (argv[i] + 2); - else if (strcmp (argv[i], "-t") == 0) - MDTimeTrial (); - else if (strcmp (argv[i], "-x") == 0) - MDTestSuite (); - else - MDFile (argv[i]); - else - MDFilter (); - + for (i = 1; i < argc; i++) { + if (argv[i][0] == '-' && argv[i][1] == 's') + MDString (argv[i] + 2); + else if (strcmp (argv[i], "-t") == 0) + MDTimeTrial (); + else if (strcmp (argv[i], "-x") == 0) + MDTestSuite (); + } return (0); } +static void MDHash (bytes, len, count, out) + char *bytes; + size_t len, count; + unsigned char *out; +{ + krb5_crypto_iov *iov; + krb5_data outdata = make_data (out, MDProvider.hashsize); + size_t i; + + iov = malloc (count * sizeof(*iov)); + if (iov == NULL) + abort (); + for (i = 0; i < count; i++) { + iov[i].flags = KRB5_CRYPTO_TYPE_DATA; + iov[i].data = make_data (bytes, len); + } + MDProvider.hash(iov, count, &outdata); + free(iov); +} + /* Digests a string and prints the result. */ static void MDString (string) char *string; { - MD_CTX context; - unsigned int len = strlen (string); - - MDInit (&context); - MDUpdate (&context, (unsigned char *) string, len); - MDFinal (&context); + unsigned char digest[16]; + MDHash (string, strlen(string), 1, digest); printf ("MD%d (\"%s\") = ", MD, string); - MDPrint (context.digest); + MDPrint (digest); printf ("\n"); } @@ -182,9 +167,8 @@ static void MDString (string) */ static void MDTimeTrial () { - MD_CTX context; time_t endTime, startTime; - unsigned char block[TEST_BLOCK_LEN]; + unsigned char block[TEST_BLOCK_LEN], digest[16]; unsigned int i; printf("MD%d time trial. Digesting %d %d-byte blocks ...", MD, @@ -198,17 +182,14 @@ static void MDTimeTrial () time (&startTime); /* Digest blocks */ - MDInit (&context); - for (i = 0; i < TEST_BLOCK_COUNT; i++) - MDUpdate (&context, block, TEST_BLOCK_LEN); - MDFinal (&context); + MDHash ((char *)block, TEST_BLOCK_LEN, TEST_BLOCK_COUNT, digest); /* Stop timer */ time (&endTime); printf (" done\n"); printf ("Digest = "); - MDPrint (context.digest); + MDPrint (digest); printf ("\nTime = %ld seconds\n", (long)(endTime-startTime)); printf ("Speed = %ld bytes/second\n", @@ -220,29 +201,24 @@ static void MDTimeTrial () static void MDTestSuite () { #ifdef HAVE_TEST_SUITE - MD_CTX context; struct md_test_entry *entry; int i, num_tests = 0, num_failed = 0; + unsigned char digest[16]; printf ("MD%d test suite:\n\n", MD); for (entry = md_test_suite; entry->string; entry++) { unsigned int len = strlen (entry->string); - MDInit (&context); - MDUpdate (&context, (unsigned char *) entry->string, len); - MDFinal (&context); + MDHash (entry->string, len, 1, digest); printf ("MD%d (\"%s\") = ", MD, entry->string); - MDPrint (context.digest); + MDPrint (digest); printf ("\n"); - for (i=0; i < 16; i++) { - if (context.digest[i] != entry->digest[i]) { - printf("\tIncorrect MD%d digest! Should have been:\n\t\t ", - MD); - MDPrint(entry->digest); - printf("\n"); - num_failed++; - } + if (memcmp(digest, entry->digest, 16) != 0) { + printf("\tIncorrect MD%d digest! Should have been:\n\t\t ", MD); + MDPrint(entry->digest); + printf("\n"); + num_failed++; } num_tests++; } @@ -269,49 +245,6 @@ static void MDTestSuite () #endif } -/* Digests a file and prints the result. */ - -static void MDFile (filename) - char *filename; -{ - FILE *file; - MD_CTX context; - int len; - unsigned char buffer[1024]; - - if ((file = fopen (filename, "rb")) == NULL) - printf ("%s can't be opened\n", filename); - else { - MDInit (&context); - while ((len = fread (buffer, 1, 1024, file)) != 0) - MDUpdate (&context, buffer, len); - MDFinal (&context); - - fclose (file); - - printf ("MD%d (%s) = ", MD, filename); - MDPrint (context.digest); - printf ("\n"); - } -} - -/* Digests the standard input and prints the result. - */ -static void MDFilter () -{ - MD_CTX context; - int len; - unsigned char buffer[16]; - - MDInit (&context); - while ((len = fread (buffer, 1, 16, stdin)) != 0) - MDUpdate (&context, buffer, len); - MDFinal (&context); - - MDPrint (context.digest); - printf ("\n"); -} - /* Prints a message digest in hexadecimal. */ static void MDPrint (digest) diff --git a/src/lib/crypto/crypto_tests/t_nfold.c b/src/lib/crypto/crypto_tests/t_nfold.c index 25361338f..6a8e7f725 100644 --- a/src/lib/crypto/crypto_tests/t_nfold.c +++ b/src/lib/crypto/crypto_tests/t_nfold.c @@ -35,7 +35,7 @@ #include <string.h> #include <assert.h> -#include "k5-int.h" +#include "crypto_int.h" #define ASIZE(ARRAY) (sizeof(ARRAY)/sizeof(ARRAY[0])) diff --git a/src/lib/crypto/crypto_tests/vectors.c b/src/lib/crypto/crypto_tests/vectors.c index f984a1788..8e9728765 100644 --- a/src/lib/crypto/crypto_tests/vectors.c +++ b/src/lib/crypto/crypto_tests/vectors.c @@ -37,7 +37,7 @@ #include <stdio.h> #include <string.h> #include <ctype.h> -#include "hash_provider.h" +#include "crypto_int.h" #define ASIZE(ARRAY) (sizeof(ARRAY)/sizeof(ARRAY[0])) |
