Added the files and changes needed to create a dll out of libcrypto
authorKeith Vetter <keithv@fusion.com>
Fri, 3 Mar 1995 02:20:21 +0000 (02:20 +0000)
committerKeith Vetter <keithv@fusion.com>
Fri, 3 Mar 1995 02:20:21 +0000 (02:20 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5068 dc483132-0cff-0310-8789-dd5450dbe970

20 files changed:
src/lib/crypto/ChangeLog
src/lib/crypto/Makefile.in
src/lib/crypto/crc32/ChangeLog
src/lib/crypto/crc32/Makefile.in
src/lib/crypto/crc32/crc.c
src/lib/crypto/crc32/crctest.c
src/lib/crypto/des/ChangeLog
src/lib/crypto/des/Makefile.in
src/lib/crypto/des/f_cbc.c
src/lib/crypto/des/f_tables.h
src/lib/crypto/des/string2key.c
src/lib/crypto/libcrypt.def [new file with mode: 0644]
src/lib/crypto/md4/ChangeLog
src/lib/crypto/md4/Makefile.in
src/lib/crypto/md5/ChangeLog
src/lib/crypto/md5/Makefile.in
src/lib/crypto/os/ChangeLog
src/lib/crypto/os/Makefile.in
src/lib/crypto/os/rnd_confoun.c
src/lib/crypto/win_glue.c [new file with mode: 0644]

index 0c17f78c5957f7c16e0b41e2a0c55c6cb91e1a96..73b1a29258225719e8a480aeedd0ef384433dd92 100644 (file)
@@ -1,3 +1,8 @@
+Thu Mar 2 17:43:25 1995 Keith Vetter (keithv@fusion.com)
+
+       * Makefile.in: added rules to make a DLL from a lib.
+        * win_glue.c, librcrypto.def: needed for making a DLL.
+
 Tue Feb 28 00:15:06 1995  John Gilmore  (gnu at toad.com)
 
        * cryptoconf.c, des_md5.c:  Avoid <krb5/...> includes.
index 66b19507e8196384d6ba41454ff93600e520da81..fc632bde36939afd4f223eecd6a7a8f969a8142b 100644 (file)
@@ -3,7 +3,7 @@ CFLAGS = $(CCOPTS) $(DEFS) -I$(srcdir)/crc32 -I$(srcdir)/des -I$(srcdir)/md4 \
 LDFLAGS = -g
 
 ##DOSBUILDTOP = ..\..
-##DOSLIBNAME=libcrypto.$(LIBEXT)
+##DOSLIBNAME=crypto.lib
 ##DOS!include $(BUILDTOP)\config\windows.in
 
 TST=if test -n "`cat DONE`" ; then
@@ -22,7 +22,18 @@ all:: all-$(WHAT)
 
 all-unix::
 
-all-windows:: $(OBJS)
+all-windows:: $(OBJS) win_glue.obj
+
+win_glue.obj:: win_glue.c
+       $(CC) $(CFLAGS) /c $*.c
+
+libcrypto.lib:: libcrypto.dll
+       implib /nologo $@ $(@R).dll
+       
+libcrypto.dll:: $(LIBNAME)
+       link /co /noe /nologo win_glue,libcrypto.dll,nul,\
+               crypto.lib winsock ldllcew libw,libcrypto.def
+       rc /p /k $@
 
 libcrypto.a: des/DONE md4/DONE md5/DONE crc32/DONE os/DONE $(OBJS)
        (cd des; $(TST) $(ARADD) ../$@ `cat DONE` ; fi)
@@ -38,10 +49,13 @@ install:: libcrypto.a
        $(RANLIB) $(DESTDIR)$(KRB5_LIBDIR)/libcrypto.a
 
 clean:: clean-$(WHAT)
-       $(RM) libcrypto.$(LIBEXT) libcrypto.bak
+       $(RM) libcrypto.$(LIBEXT) libcrypto.dll libcrypto.bak 
 
 clean-unix::
 
+clean-windows::
+       $(RM) crypto.lib crypto.bak
+
 check:: check-$(WHAT)
 
 check-unix::
@@ -100,3 +114,6 @@ check-windows::
        @echo Making check in ..\os
        -$(MAKE) -$(MFLAGS) check
        cd ..
+
+all-windows:: libcrypto.lib
+
index cefe0da6479c748fd239aea1f0c67d181bc07fa5..949a7c66e2a7bb26f0018030daab75754f55616b 100644 (file)
@@ -1,3 +1,9 @@
+Thu Mar 2 17:48:08 1995 Keith Vetter (keithv@fusion.com)
+
+       * Makefile.in: changed LIBNAME for the PC
+        * crc.c, crctest.c: added cast on the assignment of bits of
+           a long into characters.
+
 Mon Feb 20 15:37:10 1995 Keith Vetter (keithv@fusion.com)
 
        * crc.c: changed API to INTERFACE
index b8a750c5c99db74aa2182abf1e8e5705d452774f..c4e7230bbf3139f544da80c88715eb0901eca857 100644 (file)
@@ -1,7 +1,7 @@
 CFLAGS = $(CCOPTS) $(DEFS)
 
 ##DOSBUILDTOP = ..\..\..
-##DOSLIBNAME=..\libcrypto.$(LIBEXT)
+##DOSLIBNAME=..\crypto.lib
 ##DOS!include $(BUILDTOP)\config\windows.in
 
 OBJS=  crc.$(OBJEXT)
index 652846b29358fb55fb07c3883c2137e1a8cb5120..6ee533a407b3cde2b980fe1acdf0295cc5377793 100644 (file)
@@ -161,8 +161,8 @@ krb5_checksum FAR *outcksum;
     int i;
 
     data = (u_char *)in;
-    for (i=0; i<in_length;i++) {
-       idx = (data[i] ^ c);
+    for (i=0; i < (int) in_length;i++) {
+       idx = (int) (data[i] ^ c);
        idx &= 0xff;
        c >>= 8;
        c ^= crc_table[idx];
@@ -170,10 +170,10 @@ krb5_checksum FAR *outcksum;
     /* c now holds the result */
     outcksum->checksum_type = CKSUMTYPE_CRC32;
     outcksum->length = 4;
-    outcksum->contents[0] = c & 0xff;
-    outcksum->contents[1] = (c >> 8) & 0xff;
-    outcksum->contents[2] = (c >> 16) & 0xff;
-    outcksum->contents[3] = (c >> 24) & 0xff;
+    outcksum->contents[0] = (krb5_octet) (c & 0xff);
+    outcksum->contents[1] = (krb5_octet) ((c >> 8) & 0xff);
+    outcksum->contents[2] = (krb5_octet) ((c >> 16) & 0xff);
+    outcksum->contents[3] = (krb5_octet) ((c >> 24) & 0xff);
     return 0;
 }
 
index 7a70a8b82fabc8fe3f98a5a8402df345e61099c9..58388227e8bb40675cd6a3a75f211fc2b6b23295 100644 (file)
@@ -61,20 +61,20 @@ main()
                    expected_crc);
            exit(1);
        }
-       outbytes[0] = expect & 0xff;
-       outbytes[1] = (expect >> 8) & 0xff;
-       outbytes[2] = (expect >> 16) & 0xff;
-       outbytes[3] = (expect >> 24) & 0xff;
+       outbytes[0] = (unsigned char) (expect & 0xff);
+       outbytes[1] = (unsigned char) ((expect >> 8) & 0xff);
+       outbytes[2] = (unsigned char) ((expect >> 16) & 0xff);
+       outbytes[3] = (unsigned char) ((expect >> 24) & 0xff);
 
        if (sscanf(input, "%lx",  &expect) != 1) {
            fprintf(stderr, "bad expectation '%s', not hex\n",
                    expected_crc);
            exit(1);
        }
-       inbytes[0] = expect & 0xff;
-       inbytes[1] = (expect >> 8) & 0xff;
-       inbytes[2] = (expect >> 16) & 0xff;
-       inbytes[3] = (expect >> 24) & 0xff;
+       inbytes[0] = (unsigned char) (expect & 0xff);
+       inbytes[1] = (unsigned char) ((expect >> 8) & 0xff);
+       inbytes[2] = (unsigned char) ((expect >> 16) & 0xff);
+       inbytes[3] = (unsigned char) ((expect >> 24) & 0xff);
 
        (*crc32_cksumtable_entry.sum_func)((krb5_pointer)inbytes,
                                           in_length, 0, 0, &outck);
index 57c8eaab0a913e9c36ff1891fee985ccabaeb131..049ac76882f14a78ab09a07e19dc0b86b2e3988b 100644 (file)
@@ -1,3 +1,10 @@
+Thu Mar 2 17:50:39 1995 Keith Vetter (keithv@fusion.com)
+
+       * Makefile.in: changed LIBNAME for the PC.
+        * f_tables.h. f_cbc.c: added cast on the assignment of bits of
+           a long into characters.
+        * string2k.c: promoted an int into a long.
+
 Thu Mar  2 18:09:28 1995  Theodore Y. Ts'o  <tytso@dcl>
 
        * Makefile.in (ISODELIB): Remove reference to $(ISODELIB).
index 9425744b3fb59747b35a9f1e664c488629129197..94be80b3db5471deb58192829a6ccdc98ba6295c 100644 (file)
@@ -2,7 +2,7 @@ CFLAGS = $(CCOPTS) $(DEFS)
 LDFLAGS = -g
 
 ##DOSBUILDTOP = ..\..\..
-##DOSLIBNAME=..\libcrypto.$(LIBEXT)
+##DOSLIBNAME=..\crypto.lib
 ##DOS!include $(BUILDTOP)\config\windows.in
 
 COMERRLIB=$(BUILDTOP)/util/et/libcom_err.$(LIBEXT)
index bac00b2d44f3750368e4f2aa4ed7527b2b156dfb..f2f78daf73d065d4dc69be88551fc868566bb4a3 100644 (file)
@@ -189,21 +189,21 @@ mit_des_cbc_encrypt(in, out, length, schedule, ivec, encrypt)
                                op += (int) length;
                                switch(length) {
                                case 8:
-                                       *(--op) = right & 0xff;
+                                       *(--op) = (unsigned char) (right & 0xff);
                                case 7:
-                                       *(--op) = (right >> 8) & 0xff;
+                                       *(--op) = (unsigned char) ((right >> 8) & 0xff);
                                case 6:
-                                       *(--op) = (right >> 16) & 0xff;
+                                       *(--op) = (unsigned char) ((right >> 16) & 0xff);
                                case 5:
-                                       *(--op) = (right >> 24) & 0xff;
+                                       *(--op) = (unsigned char) ((right >> 24) & 0xff);
                                case 4:
-                                       *(--op) = left & 0xff;
+                                       *(--op) = (unsigned char) (left & 0xff);
                                case 3:
-                                       *(--op) = (left >> 8) & 0xff;
+                                       *(--op) = (unsigned char) ((left >> 8) & 0xff);
                                case 2:
-                                       *(--op) = (left >> 16) & 0xff;
+                                       *(--op) = (unsigned char) ((left >> 16) & 0xff);
                                case 1:
-                                       *(--op) = (left >> 24) & 0xff;
+                                       *(--op) = (unsigned char) ((left >> 24) & 0xff);
                                        break;
                                }
                                break;          /* we're done */
index a9c63dcc12f1a1d8cb6e1b95dc815985ea320d6b..29e1860566e33cd54579cb8c600b986515809a24 100644 (file)
@@ -221,9 +221,9 @@ extern const unsigned KRB_INT32 des_SP_table[8][64];
        (lr) |= (unsigned KRB_INT32)(*(ip)++)
 
 #define        PUT_HALF_BLOCK(lr, op) \
-       *(op)++ = ((lr) >> 24) & 0xff; \
-       *(op)++ = ((lr) >> 16) & 0xff; \
-       *(op)++ = ((lr) >> 8) & 0xff; \
-       *(op)++ = (lr) & 0xff
+       *(op)++ = (unsigned char) (((lr) >> 24) & 0xff); \
+       *(op)++ = (unsigned char) (((lr) >> 16) & 0xff); \
+       *(op)++ = (unsigned char) (((lr) >> 8) & 0xff); \
+       *(op)++ = (unsigned char) ((lr) & 0xff)
 
 #endif /* __DES_TABLES_H__ */
index 4369f1de92c0a4df79e3fbf827ea046689d0afdb..b9dd7115d22b0ab9156091794862064029fa4a04 100644 (file)
@@ -51,7 +51,8 @@ const krb5_data FAR * salt;
     register char *str, *copystr;
     register krb5_octet *key;
 
-    register unsigned temp,i;
+    register unsigned temp;
+    register long i;        
     register int j;
     register long length;
     unsigned char *k_p;
diff --git a/src/lib/crypto/libcrypt.def b/src/lib/crypto/libcrypt.def
new file mode 100644 (file)
index 0000000..ef3c85a
--- /dev/null
@@ -0,0 +1,52 @@
+;-----------------------------
+;   CRYPTO.DEF - module definition file
+;-----------------------------
+
+LIBRARY   CRYPTO
+DESCRIPTION 'DLL for Kerberos cryptography support'
+EXETYPE   WINDOWS
+CODE      PRELOAD MOVEABLE DISCARDABLE
+DATA      PRELOAD MOVEABLE SINGLE
+HEAPSIZE  8192
+
+EXPORTS
+       WEP @1 RESIDENTNAME
+       LIBMAIN                                 @2
+       CRC32_SUM_FUNC                          @3 
+       KRB5_RANDOM_CONFOUNDER                  @4 
+       MAKE_KEY_SCHED                          @5 
+       MD4_CRYPTO_SUM_FUNC                     @6 
+       MD4_SUM_FUNC                            @7 
+       MD4FINAL                                @8 
+       MD4INIT                                 @9 
+       MD4UPDATE                               @10 
+       MD5_CRYPTO_SUM_FUNC                     @11 
+       MD5_SUM_FUNC                            @12 
+       MD5FINAL                                @13 
+       MD5INIT                                 @14 
+       MD5UPDATE                               @15 
+       MIT_DES_CBC_CHECKSUM                    @16 
+       MIT_DES_CBC_CKSUM                       @17 
+       MIT_DES_CBC_ENCRYPT                     @18 
+       MIT_DES_CHECK_KEY_PARITY                @19 
+       MIT_DES_CRC_DECRYPT_FUNC                @20 
+       MIT_DES_CRC_ENCRYPT_FUNC                @21 
+       MIT_DES_ECB_ENCRYPT                     @22 
+       MIT_DES_FINISH_KEY                      @23 
+       MIT_DES_FINISH_RANDOM_KEY               @24 
+       MIT_DES_FIXUP_KEY_PARITY                @25 
+       MIT_DES_GENERATE_RANDOM_BLOCK           @26 
+       MIT_DES_INIT_RANDOM_KEY                 @27 
+       MIT_DES_INIT_RANDOM_NUMBER_GENERATOR    @28 
+       MIT_DES_IS_WEAK_KEY                     @29 
+       MIT_DES_KEY_SCHED                       @30 
+       MIT_DES_MD5_DECRYPT_FUNC                @31 
+       MIT_DES_MD5_ENCRYPT_FUNC                @32 
+       MIT_DES_NEW_RANDOM_KEY                  @33 
+       MIT_DES_PROCESS_KEY                     @34 
+       MIT_DES_RANDOM_KEY                      @35 
+       MIT_DES_SET_RANDOM_GENERATOR_SEED       @36 
+       MIT_DES_SET_SEQUENCE_NUMBER             @37 
+       MIT_DES_STRING_TO_KEY                   @38 
+       MIT_RAW_DES_DECRYPT_FUNC                @39 
+       MIT_RAW_DES_ENCRYPT_FUNC                @40 
index 907c5c34aaa608f1adb3a36f39b483087b9093cc..dca4ef84f79150fb2345e0d99f4f7a132e7fc770 100644 (file)
@@ -1,3 +1,7 @@
+Thu Mar 2 17:53:35 1995 Keith Vetter (keithv@fusion.com)
+
+       * Makefile.in: changed LIBNAME for the PC
+
 Tue Feb 28 00:19:06 1995  John Gilmore  (gnu at toad.com)
 
        * rsa-md4.h:  Avoid <krb5/...> includes.
index af6b730bc7fcae72324c46d67332ae5d84856bd3..6dbe1066b5604df1a9125f69ebae7da3dadaf4b9 100644 (file)
@@ -3,7 +3,7 @@ CFLAGS = $(CCOPTS) $(DEFS) -I$(srcdir)/../des -I$(srcdir)
 LDFLAGS = -g
 
 ##DOSBUILDTOP = ..\..\..
-##DOSLIBNAME=..\libcrypto.$(LIBEXT)
+##DOSLIBNAME=..\crypto.lib
 ##DOS!include $(BUILDTOP)\config\windows.in
 
 OBJS=  md4.$(OBJEXT) md4glue.$(OBJEXT) md4crypto.$(OBJEXT)
index 35c518e56be2edc996febeb6da934b089566863a..3c93d568964599e921c50845b6674fe42b55df74 100644 (file)
@@ -1,3 +1,7 @@
+Thu Mar 2 17:54:26 1995 Keith Vetter (keithv@fusion.com)
+
+       * Makefile.in: changed LIBNAME for the PC
+
 Tue Feb 28 00:20:15 1995  John Gilmore  (gnu at toad.com)
 
        * md5.c, md5crypto.c, md5glue.c, t_mddriver.c:  Avoid <krb5/...>
index 259d1fbcde07f7393a23393f7237d22571b6d0cf..09a4637b929ecd6067703a474254aa578a5bee63 100644 (file)
@@ -2,7 +2,7 @@ CFLAGS = $(CCOPTS) $(DEFS) -I$(srcdir)/../des
 LDFLAGS = -g
 
 ##DOSBUILDTOP = ..\..\..
-##DOSLIBNAME=..\libcrypto.$(LIBEXT)
+##DOSLIBNAME=..\crypto.lib
 ##DOS!include $(BUILDTOP)\config\windows.in
 
 OBJS=  md5.$(OBJEXT) md5glue.$(OBJEXT) md5crypto.$(OBJEXT)
index a2e96b464ea67643d2c1dc6e1f50b99a1483e7a5..9848d4be60227ddaf580d995be2c30aa1eac624b 100644 (file)
@@ -1,3 +1,9 @@
+Thu Mar 2 17:56:48 1995 Keith Vetter (keithv@fusion.com)
+
+       * Makefile.in: changed LIBNAME for the PC, and  brought in ustime
+           and localaddr from the krb/os directory.
+        * rnd_conf.c: added cast to the seed assignment.
+
 Mon Feb 20 16:25:36 1995 Keith Vetter (keithv@fusion.com)
 
        * Makfile.in: made to work for the PC
index 60e9af9856a25b5c7bead87ddf293a4ea3930312..7bf4dd8e851d08c4786b346b2dc4b0b6353098ef 100644 (file)
@@ -2,7 +2,7 @@ CFLAGS = $(CCOPTS) $(DEFS)
 LDFLAGS = -g
 
 ##DOSBUILDTOP = ..\..\..
-##DOSLIBNAME=..\libcrypto.$(LIBEXT)
+##DOSLIBNAME=..\crypto.lib
 ##DOS!include $(BUILDTOP)\config\windows.in
 
 LIBOBJS = @LIBOBJS@
@@ -15,16 +15,16 @@ all:: all-$(WHAT)
 
 all-unix:: $(OBJS)
 
-all-windows: rnd_confoun.obj
+all-windows: rnd_confoun.obj localaddr.obj ustime.obj
 
-localaddr.c: ../../krb5/os/localaddr.c
-       -$(LN) $(srcdir)/../../krb5/os/localaddr.c $@
+localaddr.c: ..$(S)..$(S)krb5$(S)os$(S)localaddr.c
+       -$(LN) $(srcdir)$(S)..$(S)..$(S)krb5$(S)os$(S)localaddr.c $@
 
-ustime.c: ../../krb5/os/ustime.c
-       -$(LN) $(srcdir)/../../krb5/os/ustime.c $@
+ustime.c: ..$(S)..$(S)krb5$(S)os$(S)ustime.c
+       -$(LN) $(srcdir)$(S)..$(S)..$(S)krb5$(S)os$(S)ustime.c $@
 
-memmove.c: ../../krb5/posix/memmove.c
-       -$(LN) $(srcdir)/../../krb5/posix/memmove.c $@
+memmove.c: ..$(S)..$(S)krb5$(S)posix$(S)memmove.c
+       -$(LN) $(srcdir)$(S)..$(S)..$(S)krb5$(S)posix$(S)memmove.c $@
 
 clean::
        $(RM) ustime.c localaddr.c memmove.c
index bed3b17ee0234a3b7b35bf0faec16fb55b4186ce..7021ec7d5190d529fccd319f123d04b23ce654f0 100644 (file)
@@ -72,7 +72,7 @@ krb5_pointer fillin;
     if (!seeded) {
        /* time() defined in 4.12.2.4, but returns a time_t, which is an
           "arithmetic type" (4.12.1) */
-       rval = time(0);
+       rval = (RAND_TYPE) time(0);
        SRAND(rval);
 #ifdef HAVE_GETPID
        rval = RAND();
diff --git a/src/lib/crypto/win_glue.c b/src/lib/crypto/win_glue.c
new file mode 100644 (file)
index 0000000..0680f80
--- /dev/null
@@ -0,0 +1,53 @@
+#define NEED_SOCKETS
+#include <k5-int.h>
+
+/* 
+ * WinSock support.
+ *
+ * Do the WinSock initialization call, keeping all the hair here.
+ *
+ * This routine is called by SOCKET_INITIALIZE in include/c-windows.h.
+ * The code is pretty much copied from winsock.txt from winsock-1.1,
+ * available from:
+ * ftp://sunsite.unc.edu/pub/micro/pc-stuff/ms-windows/winsock/winsock-1.1
+ */
+int
+win_socket_initialize()
+{
+    WORD wVersionRequested;
+    WSADATA wsaData;
+    int err;
+
+    wVersionRequested = 0x0101;                /* We need version 1.1 */
+
+    err = WSAStartup (wVersionRequested, &wsaData);
+    if (err != 0) 
+       return err;             /* Library couldn't initialize */
+
+    if (wVersionRequested != wsaData.wVersion) {
+       /* DLL couldn't support our version of the spec */
+       WSACleanup ();
+       return -104;            /* FIXME -- better error? */
+    }
+
+    return 0;
+}
+
+BOOL CALLBACK
+LibMain(hInst, wDataSeg, cbHeap, CmdLine)
+       HINSTANCE hInst;
+       WORD wDataSeg;
+       WORD cbHeap;
+       LPSTR CmdLine;
+{
+        win_socket_initialize ();
+       return 1;
+}
+
+
+int CALLBACK __export
+WEP(nParam)
+       int nParam;
+{
+       return 1;
+}