Moved krb5, gss, and crypto library initialization/cleanup code into new dedicated...
authorMiro Jurisic <meeroh@mit.edu>
Sat, 22 Jan 2000 04:04:36 +0000 (04:04 +0000)
committerMiro Jurisic <meeroh@mit.edu>
Sat, 22 Jan 2000 04:04:36 +0000 (04:04 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11960 dc483132-0cff-0310-8789-dd5450dbe970

15 files changed:
src/lib/crypto/ChangeLog
src/lib/crypto/Makefile.in
src/lib/crypto/crypto_libinit.c [new file with mode: 0644]
src/lib/crypto/crypto_libinit.h [new file with mode: 0644]
src/lib/crypto/prng.c
src/lib/gssapi/ChangeLog
src/lib/gssapi/Makefile.in
src/lib/gssapi/gss_libinit.c [new file with mode: 0644]
src/lib/gssapi/gss_libinit.h [new file with mode: 0644]
src/lib/krb5/ChangeLog
src/lib/krb5/Makefile.in
src/lib/krb5/krb5_libinit.c [new file with mode: 0644]
src/lib/krb5/krb5_libinit.h [new file with mode: 0644]
src/mac/GSS.CFM.c
src/mac/K5.CFM.c

index 0c4236842c4809e60fdbcf9bc0b786b8d1b943f0..957a0ec312be8382b93aaff81d36a599428f326a 100644 (file)
@@ -1,3 +1,9 @@
+Fri Jan 21 22:47:00 2000  Miro Jurisic  <meeroh@mit.edu>
+
+       * Makefile.in: added crypto_libinit.[co]
+       * crypto_libinit.[ch]: new files, contain library initialization
+               and cleanup code
+
 2000-01-21  Ken Raeburn  <raeburn@mit.edu>
 
        * cksumtypes.c (krb5_cksumtypes_list, krb5_cksumtypes_length): Now
index d86325bf824c79fb3f7ddb799d865f39e4c70a2d..71bddf5c4bb695582c3d1787d1491b79de698649 100644 (file)
@@ -26,6 +26,7 @@ STLIBOBJS=\
        cksumtype_to_string.o   \
        cksumtypes.o            \
        coll_proof_cksum.o      \
+       crypto_libinit.o        \
        decrypt.o               \
        encrypt.o               \
        encrypt_length.o        \
@@ -53,6 +54,7 @@ OBJS=\
        $(OUTPRE)cksumtype_to_string.$(OBJEXT)  \
        $(OUTPRE)cksumtypes.$(OBJEXT)           \
        $(OUTPRE)coll_proof_cksum.$(OBJEXT)     \
+       $(OUTPRE)crypto_libinit.$(OBJEXT)       \
        $(OUTPRE)decrypt.$(OBJEXT)              \
        $(OUTPRE)encrypt.$(OBJEXT)              \
        $(OUTPRE)encrypt_length.$(OBJEXT)       \
@@ -80,6 +82,7 @@ SRCS=\
        $(subdir)/cksumtype_to_string.c \
        $(subdir)/cksumtypes.c          \
        $(subdir)/coll_proof_cksum.c    \
+       $(subdir)/crypto_libinit.c      \
        $(subdir)/decrypt.c             \
        $(subdir)/encrypt.c             \
        $(subdir)/encrypt_length.c      \
diff --git a/src/lib/crypto/crypto_libinit.c b/src/lib/crypto/crypto_libinit.c
new file mode 100644 (file)
index 0000000..5ae277e
--- /dev/null
@@ -0,0 +1,30 @@
+#include <assert.h>
+
+static int             initialized = false;
+
+/*
+ * Initialize the crypto library.
+ */
+
+int cryptoint_initialize_library (void)
+{
+       
+       if (!initialized) {
+               initialized = true;
+       }
+       
+       return 0;
+}
+
+/*
+ * Clean up the crypto library state
+ */
+
+void cryptoint_cleanup_library (void)
+{
+       assert (initialized);
+       
+       prng_cleanup ();
+       
+       initialized = false;
+}
\ No newline at end of file
diff --git a/src/lib/crypto/crypto_libinit.h b/src/lib/crypto/crypto_libinit.h
new file mode 100644 (file)
index 0000000..3586a63
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef KRB5_LIBINIT_H
+#define KRB5_LIBINIT_H
+
+int cryptoint_initialize_library (void);
+void cryptoint_cleanup_library (void);
+
+#endif /* KRB5_LIBINIT_H */
index c0f106f0a59b13e84a7464cb1fb9ae8af6c85ff8..6d401a9bf06220d6ac2f9f703094082480951796 100644 (file)
@@ -153,3 +153,9 @@ krb5_c_random_make_octets(krb5_context context, krb5_data *data)
 
     return(0);
 }
+
+void prng_cleanup (void)
+{
+       free (random_state);
+       inited = 0;
+}
\ No newline at end of file
index 8f794fa718f13729391bc4317f8ce1497bad06e1..64f7f5765be5d823fd5ce7377f012462300f1ae1 100644 (file)
@@ -1,3 +1,9 @@
+Fri Jan 21 22:47:00 2000  Miro Jurisic  <meeroh@mit.edu>
+
+       * Makefile.in: added gss_libinit.[co]
+       * gss_libinit.[ch]: new files, contain library initialization
+               and cleanup code
+
 Tue May 18 19:52:56 1999  Danilo Almeida  <dalmeida@mit.edu>
 
        * Makefile.in: Remove - from recursive Win32 make invocation.
index 992615d5531f424f458a8ef98aec5aaef1982d8c..5198aec4bc19517b58ab8d4fad0282c41b35c782 100644 (file)
@@ -12,6 +12,12 @@ LOCAL_SUBDIRS= generic krb5
 
 MAC_SUBDIRS = generic krb5
 
+OBJS=\
+       $(OUTPRE)gss_libinit.$(OBJEXT)
+
+SRCS=\
+       $(subdir)/gss_libinit.c
+
 LIB=gssapi_krb5
 LIBMAJOR=2
 LIBMINOR=1
diff --git a/src/lib/gssapi/gss_libinit.c b/src/lib/gssapi/gss_libinit.c
new file mode 100644 (file)
index 0000000..ac91b0f
--- /dev/null
@@ -0,0 +1,43 @@
+#include <assert.h>
+
+#include "gssapi_err_generic.h"
+#include "gssapi_err_krb5.h"
+
+#include "gss_libinit.h"
+
+static int             initialized = false;
+
+/*
+ * Initialize the GSSAPI library.
+ */
+
+OM_uint32 gssint_initialize_library (void)
+{
+       
+       if (!initialized) {
+           add_error_table(&et_k5g_error_table);
+           add_error_table(&et_ggss_error_table);
+
+               initialized = true;
+       }
+       
+       return 0;
+}
+
+/*
+ * Clean up the Kerberos v5 lirbary state
+ */
+
+void gssint_cleanup_library (void)
+{
+       OM_uint32 maj_stat, min_stat;
+
+       assert (initialized);
+       
+       maj_stat = kg_release_defcred (&min_stat);
+       
+    remove_error_table(&et_k5g_error_table);
+    remove_error_table(&et_ggss_error_table);
+       
+       initialized = false;
+}
\ No newline at end of file
diff --git a/src/lib/gssapi/gss_libinit.h b/src/lib/gssapi/gss_libinit.h
new file mode 100644 (file)
index 0000000..ba89ff3
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef KRB5_LIBINIT_H
+#define KRB5_LIBINIT_H
+
+#include "gssapi.h"
+
+OM_uint32 gssint_initialize_library (void);
+void gssint_cleanup_library (void);
+
+#endif /* KRB5_LIBINIT_H */
index b11d3091e1d7990f552b39da1d66d961e532b18d..5cb84642ba9f5a3ce048c6bf384ac3b71a40ea25 100644 (file)
@@ -1,3 +1,9 @@
+Fri Jan 21 22:47:00 2000  Miro Jurisic  <meeroh@mit.edu>
+
+       * Makefile.in: added krb5_libinit.[co]
+       * krb5_libinit.[ch]: new files, contain library initialization
+               and cleanup code
+
 1999-12-01  Ken Raeburn  <raeburn@mit.edu>
 
        * Makefile.in (LIBMINOR): Update to 2.
index 4235d7272f0652aa9f055d25b891e513e4caf64f..b03b623dfd14a101658d83e5e24dd971987bd1d4 100644 (file)
@@ -45,6 +45,12 @@ STOBJLISTS= \
        posix/OBJS.ST \
        $(BUILDTOP)/util/profile/OBJS.ST
 
+OBJS=\
+       $(OUTPRE)krb5_libinit.$(OBJEXT)
+
+SRCS=\
+       $(subdir)/krb5_libinit.c
+
 RELDIR=krb5
 SHLIB_EXPDEPS = \
        $(TOPLIBD)/libk5crypto$(SHLIBEXT) \
diff --git a/src/lib/krb5/krb5_libinit.c b/src/lib/krb5/krb5_libinit.c
new file mode 100644 (file)
index 0000000..584aa57
--- /dev/null
@@ -0,0 +1,46 @@
+#include <assert.h>
+
+#include "krb5.h"
+#include "krb5_err.h"
+#include "kv5m_err.h"
+#include "asn1_err.h"
+#include "kdb5_err.h"
+
+static int             initialized = false;
+
+/*
+ * Initialize the Kerberos v5 library.
+ */
+
+krb5_error_code krb5int_initialize_library (void)
+{
+       
+       if (!initialized) {
+           add_error_table(&et_krb5_error_table);
+           add_error_table(&et_kv5m_error_table);
+           add_error_table(&et_kdb5_error_table);
+           add_error_table(&et_asn1_error_table);
+
+               initialized = true;
+       }
+       
+       return 0;
+}
+
+/*
+ * Clean up the Kerberos v5 lirbary state
+ */
+
+void krb5int_cleanup_library (void)
+{
+       assert (initialized);
+       
+       krb5_stdcc_shutdown();
+       
+    remove_error_table(&et_krb5_error_table);
+    remove_error_table(&et_kv5m_error_table);
+    remove_error_table(&et_kdb5_error_table);
+    remove_error_table(&et_asn1_error_table);
+       
+       initialized = false;
+}
\ No newline at end of file
diff --git a/src/lib/krb5/krb5_libinit.h b/src/lib/krb5/krb5_libinit.h
new file mode 100644 (file)
index 0000000..11d7248
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef KRB5_LIBINIT_H
+#define KRB5_LIBINIT_H
+
+#include "krb5.h"
+
+krb5_error_code krb5int_initialize_library (void);
+void krb5int_cleanup_library (void);
+
+#endif /* KRB5_LIBINIT_H */
index a7c7c64eceffff73174f16cd1c078bff91d37966..985ccd24043a89a8266798ad592c11451980f48c 100644 (file)
  
 #include <CodeFragments.h>
  
-#include "gssapi_err_generic.h"
-#include "gssapi_err_krb5.h"
-
-#include "gssapi.h"
+#include "gss_libinit.h"
 
 OSErr __initializeGSS(CFragInitBlockPtr ibp);
 void __terminateGSS(void);
@@ -36,8 +33,7 @@ OSErr __initializeGSS(CFragInitBlockPtr ibp)
        
        /* Initialize the error tables */
        if (err == noErr) {
-           add_error_table(&et_k5g_error_table);
-           add_error_table(&et_ggss_error_table);
+               err = gssint_initialize_library ();
        }
        
        return err;
@@ -45,13 +41,7 @@ OSErr __initializeGSS(CFragInitBlockPtr ibp)
 
 void __terminateGSS(void)
 {
-
-       OM_uint32 maj_stat, min_stat;
-
-       maj_stat = kg_release_defcred (&min_stat);
-       
-    remove_error_table(&et_k5g_error_table);
-    remove_error_table(&et_ggss_error_table);
+       gssint_cleanup_library ();
 
        __terminate();
 }
index 57d1fbb26b4b3eb211c278a572648b4882a918c9..efb918cfc083a63c6c5ec80ba63b3a3a3aab05a1 100644 (file)
  
 #include <CodeFragments.h>
 
-#include "krb5_err.h"
-#include "kv5m_err.h"
-#include "asn1_err.h"
-#include "kdb5_err.h"
-#include "profile.h"
-#include "adm_err.h"
+#include "krb5_libinit.h"
+#include "crypto_libinit.h"
 
 
 OSErr __initializeK5(CFragInitBlockPtr ibp);
@@ -34,17 +30,14 @@ OSErr __initializeK5(CFragInitBlockPtr ibp)
 {
        OSErr   err = noErr;
        
-       /* Do normal init of the shared library */
        err = __initialize();
        
-       /* Initialize the error tables */
        if (err == noErr) {
-           add_error_table(&et_krb5_error_table);
-           add_error_table(&et_kv5m_error_table);
-           add_error_table(&et_kdb5_error_table);
-           add_error_table(&et_asn1_error_table);
-//         add_error_table(&et_prof_error_table);
-           add_error_table(&et_kadm_error_table);
+               err = krb5int_initialize_library ();
+       }
+       
+       if (err == noErr) {
+               err = cryptoint_initialize_library ();
        }
        
        return err;
@@ -53,14 +46,8 @@ OSErr __initializeK5(CFragInitBlockPtr ibp)
 void __terminateK5(void)
 {
 
-       krb5_stdcc_shutdown();
-       
-    remove_error_table(&et_krb5_error_table);
-    remove_error_table(&et_kv5m_error_table);
-    remove_error_table(&et_kdb5_error_table);
-    remove_error_table(&et_asn1_error_table);
-//    remove_error_table(&et_prof_error_table);
-    remove_error_table(&et_kadm_error_table);
+       cryptoint_cleanup_library ();
+       krb5int_cleanup_library ();
 
        __terminate();
 }