From eb1934623fc475cbcff71777245e7544fd6405c2 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Sat, 2 Jul 2005 04:36:07 +0000 Subject: rename string_to_key.c to arcfour_s2k.c git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17291 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/crypto/arcfour/ChangeLog | 5 +++ src/lib/crypto/arcfour/Makefile.in | 10 ++--- src/lib/crypto/arcfour/arcfour_s2k.c | 70 ++++++++++++++++++++++++++++++++++ src/lib/crypto/arcfour/string_to_key.c | 70 ---------------------------------- 4 files changed, 80 insertions(+), 75 deletions(-) create mode 100644 src/lib/crypto/arcfour/arcfour_s2k.c delete mode 100644 src/lib/crypto/arcfour/string_to_key.c (limited to 'src') diff --git a/src/lib/crypto/arcfour/ChangeLog b/src/lib/crypto/arcfour/ChangeLog index 7f5d638e5..8f6d3d53d 100644 --- a/src/lib/crypto/arcfour/ChangeLog +++ b/src/lib/crypto/arcfour/ChangeLog @@ -1,3 +1,8 @@ +2005-07-02 Ken Raeburn + + * arcfour_s2k.c: Renamed from string_to_key.c. + * Makefile.in (STLIBOBJS, OBJS, SRCS): Updated accordingly. + 2004-09-21 Sam Hartman * string_to_key.c (krb5int_arcfour_string_to_key): Free the copy diff --git a/src/lib/crypto/arcfour/Makefile.in b/src/lib/crypto/arcfour/Makefile.in index 0ebbd4af4..bd435c341 100644 --- a/src/lib/crypto/arcfour/Makefile.in +++ b/src/lib/crypto/arcfour/Makefile.in @@ -15,15 +15,15 @@ RUN_SETUP = @KRB5_RUN_ENV@ KRB5_CONFIG=$(SRCTOP)/config-files/krb5.conf STLIBOBJS=\ arcfour.o \ - string_to_key.o + arcfour_s2k.o OBJS=\ $(OUTPRE)arcfour.$(OBJEXT) \ - $(OUTPRE)string_to_key.$(OBJEXT) + $(OUTPRE)arcfour_s2k.$(OBJEXT) SRCS=\ $(srcdir)/arcfour.c \ - $(srcdir)/string_to_key.c + $(srcdir)/arcfour_s2k.c ##DOS##LIBOBJS = $(OBJS) @@ -50,8 +50,8 @@ arcfour.so arcfour.po $(OUTPRE)arcfour.$(OBJEXT): arcfour.c \ $(SRCTOP)/include/port-sockets.h $(BUILDTOP)/include/krb5/autoconf.h \ $(SRCTOP)/include/socket-utils.h $(SRCTOP)/include/krb5/kdb.h \ arcfour-int.h arcfour.h -string_to_key.so string_to_key.po $(OUTPRE)string_to_key.$(OBJEXT): \ - string_to_key.c $(SRCTOP)/include/k5-int.h $(BUILDTOP)/include/krb5/osconf.h \ +arcfour_s2k.so arcfour_s2k.po $(OUTPRE)arcfour_s2k.$(OBJEXT): \ + arcfour_s2k.c $(SRCTOP)/include/k5-int.h $(BUILDTOP)/include/krb5/osconf.h \ $(BUILDTOP)/include/krb5/autoconf.h $(SRCTOP)/include/k5-platform.h \ $(BUILDTOP)/include/krb5/autoconf.h $(SRCTOP)/include/k5-thread.h \ $(BUILDTOP)/include/krb5.h $(COM_ERR_DEPS) $(BUILDTOP)/include/profile.h \ diff --git a/src/lib/crypto/arcfour/arcfour_s2k.c b/src/lib/crypto/arcfour/arcfour_s2k.c new file mode 100644 index 000000000..57a64b3e9 --- /dev/null +++ b/src/lib/crypto/arcfour/arcfour_s2k.c @@ -0,0 +1,70 @@ +#include "k5-int.h" +#include "rsa-md4.h" +#include "arcfour-int.h" + +static void asctouni(unsigned char *unicode, unsigned char *ascii, size_t len) +{ + int counter; + for (counter=0;counterlength != 16) + return (KRB5_BAD_MSIZE); + + /* We ignore salt per the Microsoft spec*/ + + /* compute the space needed for the new string. + Since the password must be stored in unicode, we need to increase + that number by 2x. + + This should be re-evauated in the future, it makes the assumption that + thes user's password is in ascii. + */ + slen = ((string->length)>128)?128:string->length; + len=(slen)*2; + + copystr = malloc(len); + if (copystr == NULL) + return ENOMEM; + + /* make the string. start by creating the unicode version of the password*/ + asctouni(copystr, string->data, slen ); + + /* the actual MD4 hash of the data */ + krb5_MD4Init(&md4_context); + krb5_MD4Update(&md4_context, (unsigned char *)copystr, len); + krb5_MD4Final(&md4_context); + memcpy(key->contents, md4_context.digest, 16); + +#if 0 + /* test the string_to_key function */ + printf("Hash="); + { + int counter; + for(counter=0;counter<16;counter++) + printf("%02x", md4_context.digest[counter]); + printf("\n"); + } +#endif /* 0 */ + + /* Zero out the data behind us */ + memset (copystr, 0, len); + memset(&md4_context, 0, sizeof(md4_context)); + free(copystr); + return 0; +} diff --git a/src/lib/crypto/arcfour/string_to_key.c b/src/lib/crypto/arcfour/string_to_key.c deleted file mode 100644 index 57a64b3e9..000000000 --- a/src/lib/crypto/arcfour/string_to_key.c +++ /dev/null @@ -1,70 +0,0 @@ -#include "k5-int.h" -#include "rsa-md4.h" -#include "arcfour-int.h" - -static void asctouni(unsigned char *unicode, unsigned char *ascii, size_t len) -{ - int counter; - for (counter=0;counterlength != 16) - return (KRB5_BAD_MSIZE); - - /* We ignore salt per the Microsoft spec*/ - - /* compute the space needed for the new string. - Since the password must be stored in unicode, we need to increase - that number by 2x. - - This should be re-evauated in the future, it makes the assumption that - thes user's password is in ascii. - */ - slen = ((string->length)>128)?128:string->length; - len=(slen)*2; - - copystr = malloc(len); - if (copystr == NULL) - return ENOMEM; - - /* make the string. start by creating the unicode version of the password*/ - asctouni(copystr, string->data, slen ); - - /* the actual MD4 hash of the data */ - krb5_MD4Init(&md4_context); - krb5_MD4Update(&md4_context, (unsigned char *)copystr, len); - krb5_MD4Final(&md4_context); - memcpy(key->contents, md4_context.digest, 16); - -#if 0 - /* test the string_to_key function */ - printf("Hash="); - { - int counter; - for(counter=0;counter<16;counter++) - printf("%02x", md4_context.digest[counter]); - printf("\n"); - } -#endif /* 0 */ - - /* Zero out the data behind us */ - memset (copystr, 0, len); - memset(&md4_context, 0, sizeof(md4_context)); - free(copystr); - return 0; -} -- cgit