From 4117e231ca8a46489a8b1efa3bb478775f14d541 Mon Sep 17 00:00:00 2001 From: Sam Hartman Date: Fri, 9 Nov 2001 21:11:38 +0000 Subject: Compiles now git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13974 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/crypto/yarrow/ChangeLog | 2 ++ src/lib/crypto/yarrow/Makefile.in | 36 ++++++++++++++++++++++++++++++++++++ src/lib/crypto/yarrow/yarrow.c | 17 ++++++++++------- src/lib/crypto/yarrow/yarrow.h | 1 + src/lib/crypto/yarrow/ycipher.c | 11 +++++------ src/lib/crypto/yarrow/ycipher.h | 4 ++-- src/lib/crypto/yarrow/yhash.h | 12 ++++++------ src/lib/crypto/yarrow/ylock.h | 4 ++-- 8 files changed, 64 insertions(+), 23 deletions(-) create mode 100644 src/lib/crypto/yarrow/Makefile.in (limited to 'src/lib/crypto') diff --git a/src/lib/crypto/yarrow/ChangeLog b/src/lib/crypto/yarrow/ChangeLog index 6a0e5c4..fad87f1 100644 --- a/src/lib/crypto/yarrow/ChangeLog +++ b/src/lib/crypto/yarrow/ChangeLog @@ -1,5 +1,7 @@ 2001-11-09 Sam Hartman + * Makefile.in: New file + * yhash.h : Use krb5 shaa1 * yarrow.c (Yarrow_Reseed): For all calls to cipher_init, use TRY diff --git a/src/lib/crypto/yarrow/Makefile.in b/src/lib/crypto/yarrow/Makefile.in new file mode 100644 index 0000000..49f8e9e --- /dev/null +++ b/src/lib/crypto/yarrow/Makefile.in @@ -0,0 +1,36 @@ +thisconfigdir=./.. +myfulldir=lib/crypto/yarrow +mydir=yarrow +BUILDTOP=$(REL)$(U)$(S)$(U)$(S)$(U) +LOCALINCLUDES = -I$(srcdir)/.. -I$(srcdir)/../sha1 -I$(srcdir)/../enc_provider + +##DOS##BUILDTOP = ..\..\.. +##DOS##PREFIXDIR=yarrow +##DOS##OBJFILE=..\$(OUTPRE)yarrow.lst +##WIN16##LIBNAME=..\crypto.lib + +PROG_LIBPATH=-L$(TOPLIBD) +PROG_RPATH=$(KRB5_LIBDIR) + +RUN_SETUP = @KRB5_RUN_ENV@ KRB5_CONFIG=$(SRCTOP)/config-files/krb5.conf + +STLIBOBJS=\ + yarrow.o \ + ycipher.o +OBJS=\ + $(OUTPRE)yarrow.$(OBJEXT) \ + $(OUTP)ycipher.$(OBJEXT) + +SRCS=\ + $(srcdir)/yarrow.c \ + $(srcdir)/ycipher.c + +##DOS##LIBOBJS = $(OBJS) + +all-unix:: all-libobjs + +includes:: depend + +depend:: $(SRCS) + +clean-unix:: clean-libobjs diff --git a/src/lib/crypto/yarrow/yarrow.c b/src/lib/crypto/yarrow/yarrow.c index 7d9e6bd..066a9c5 100644 --- a/src/lib/crypto/yarrow/yarrow.c +++ b/src/lib/crypto/yarrow/yarrow.c @@ -18,6 +18,8 @@ * See the accompanying LICENSE file for more information. */ +#include "k5-int.h" + #include #include #if !defined(WIN32) @@ -175,7 +177,7 @@ int Yarrow_Init(Yarrow_CTX* y, const char *filename) mem_zero(y->K, sizeof(y->K)); - TRY (Krb5int_Yarrow_Cipher_Init(&y->cipher, y->K)); + TRY (krb5int_yarrow_cipher_init(&y->cipher, y->K)); y->out_left = 0; y->out_count = 0; y->gate_count = 0; @@ -402,7 +404,7 @@ static int Yarrow_Output_Block( Yarrow_CTX* y, void* out ) /* R <- E_k(C) */ - TRY ( krb5int_yarrow_cipher_encrypt_block ( &y->cipher, y->C, out )) + TRY ( krb5int_yarrow_cipher_encrypt_block ( &y->cipher, y->C, out )); #if defined(YARROW_DEBUG) printf("===\n"); @@ -526,7 +528,7 @@ int Yarrow_Gate(Yarrow_CTX* y) /* need to resetup the key schedule as the key has changed */ - TRY (Krb5int_Yarrow_Cipher_Init(&y->cipher, y->K)); + TRY (krb5int_yarrow_cipher_init(&y->cipher, y->K)); CATCH: TRACE( printf( "]," ); ); @@ -619,6 +621,7 @@ int Yarrow_Reseed(Yarrow_CTX* y, int pool) /* feed hash of slow pool into the fast pool */ + HASH_Final(slow_pool, digest); /* Each pool contains the running hash of all inputs fed into it @@ -637,7 +640,7 @@ int Yarrow_Reseed(Yarrow_CTX* y, int pool) /* step 1. v_0 <- hash of all inputs into fast pool */ - HASH_Final(fast_pool, v_0); + HASH_Final(fast_pool, &v_0); HASH_Init(fast_pool); /* reinitialize fast pool */ /* v_i <- v_0 */ @@ -657,7 +660,7 @@ int Yarrow_Reseed(Yarrow_CTX* y, int pool) HASH_Update(&hash, &big_endian_int32, sizeof(krb5_ui_4)); big_endian_int32 = make_big_endian32(i & 0xFFFFFFFF); /* LS word */ HASH_Update(&hash, &big_endian_int32, sizeof(krb5_ui_4)); - HASH_Final(&hash, v_i); + HASH_Final(&hash, &v_i); } /* step3. K = h'(h(v_Pt|K)) */ @@ -678,7 +681,7 @@ int Yarrow_Reseed(Yarrow_CTX* y, int pool) /* need to resetup the key schedule as the key has changed */ - TRY(Krb5int_Yarrow_Cipher_Init(&y->cipher, y->K)); + TRY(krb5int_yarrow_cipher_init(&y->cipher, y->K)); #if defined(YARROW_DEBUG) hex_print(stdout, "new K", y->K, sizeof(y->K)); @@ -689,7 +692,7 @@ int Yarrow_Reseed(Yarrow_CTX* y, int pool) #if defined(YARROW_DEBUG) hex_print(stdout, "old C", y->C, sizeof(y->C)); #endif - TRY (krb5int_yarrow_cipher_encrypt_block (&y->cipher, zero_block, y->C)) + TRY (krb5int_yarrow_cipher_encrypt_block (&y->cipher, zero_block, y->C)); #if defined(YARROW_DEBUG) hex_print(stdout, "new C", y->C, sizeof(y->C)); #endif diff --git a/src/lib/crypto/yarrow/yarrow.h b/src/lib/crypto/yarrow/yarrow.h index b8b8884..77b6f07 100644 --- a/src/lib/crypto/yarrow/yarrow.h +++ b/src/lib/crypto/yarrow/yarrow.h @@ -7,6 +7,7 @@ #define YARROW_DETECT_FORK #include #endif +#define YARROW_NO_MATHLIB #include "ytypes.h" #include "yhash.h" diff --git a/src/lib/crypto/yarrow/ycipher.c b/src/lib/crypto/yarrow/ycipher.c index d354bae..b2c7a96 100644 --- a/src/lib/crypto/yarrow/ycipher.c +++ b/src/lib/crypto/yarrow/ycipher.c @@ -35,7 +35,7 @@ int krb5int_yarrow_cipher_init (CIPHER_CTX *ctx, - const char * key) + unsigned const char * key) { size_t keybytes, keylength; const struct krb5_enc_provider *enc = &yarrow_enc_provider; @@ -60,18 +60,17 @@ int krb5int_yarrow_cipher_init } int krb5int_yarrow_cipher_encrypt_block -(CIPHER_CTX *ctx, const char *in, - char *out) +(CIPHER_CTX *ctx, const unsigned char *in, + unsigned char *out) { krb5_error_code ret; - krb5_data ind; - krb5_enc_data outd; + krb5_data ind, outd; const struct krb5_enc_provider *enc = &yarrow_enc_provider; ind.data = (char *) in; ind.length = CIPHER_BLOCK_SIZE; outd.data = out; outd.length = CIPHER_BLOCK_SIZE; - ret = enc->encrypt (ctx->key, 0, ind, outd); + ret = enc->encrypt (&ctx->key, 0, &ind, &outd); if (ret) return YARROW_FAIL; return YARROW_OK; diff --git a/src/lib/crypto/yarrow/ycipher.h b/src/lib/crypto/yarrow/ycipher.h index 87ae85a..a78cf16 100644 --- a/src/lib/crypto/yarrow/ycipher.h +++ b/src/lib/crypto/yarrow/ycipher.h @@ -29,9 +29,9 @@ typedef struct #endif -int krb5int_yarrow_cipher_init (CIPHER_CTX *ctx, const char *key); +int krb5int_yarrow_cipher_init (CIPHER_CTX *ctx, unsigned const char *key); int krb5int_yarrow_cipher_encrypt_block -(CIPHER_CTX *ctx, const char *in, char *out); +(CIPHER_CTX *ctx, const unsigned char *in, unsigned char *out); #if !defined( YARROW_NO_MATHLIB ) #define POW_CIPHER_KEY_SIZE pow(2.0, CIPHER_KEY_SIZE * 8 / 3.0) diff --git a/src/lib/crypto/yarrow/yhash.h b/src/lib/crypto/yarrow/yhash.h index 579432f..98c4403 100644 --- a/src/lib/crypto/yarrow/yhash.h +++ b/src/lib/crypto/yarrow/yhash.h @@ -12,12 +12,12 @@ #define HASH_CTX SHS_INFO -#define HASH_Init(x) shsinit(x) -#define HASH_Update(x, buf, sz) shsupdate(x, (void*)buf, sz) -#define HASH_Final(x, digest) do { \ - shsfinal(x); \ - memcpy(digest, (void *) x.digest, SHS_DIGESTSIZE); \ - } while(0;) +#define HASH_Init(x) shsInit(x) +#define HASH_Update(x, buf, sz) shsUpdate(x, (const void*)buf, sz) +#define HASH_Final(x, tdigest) do { \ + shsFinal(x); \ + memcpy((tdigest), (void *) (x)->digest, SHS_DIGESTSIZE); \ + } while(0) #define HASH_DIGEST_SIZE SHS_DIGESTSIZE diff --git a/src/lib/crypto/yarrow/ylock.h b/src/lib/crypto/yarrow/ylock.h index 3e52605..21d3911 100644 --- a/src/lib/crypto/yarrow/ylock.h +++ b/src/lib/crypto/yarrow/ylock.h @@ -12,7 +12,7 @@ */ -int LOCK( void ) { return (YARROW_OK); } -int UNLOCK( void ) { return (YARROW_OK); } +static int LOCK( void ) { return (YARROW_OK); } +static int UNLOCK( void ) { return (YARROW_OK); } #endif /* YLOCK_H */ -- cgit v1.1