summaryrefslogtreecommitdiffstats
path: root/src/lib/crypto
diff options
context:
space:
mode:
authorMiro Jurisic <meeroh@mit.edu>2000-01-22 04:04:36 +0000
committerMiro Jurisic <meeroh@mit.edu>2000-01-22 04:04:36 +0000
commit3954dd2c1f9919e2ac09f86f022063119b5dd8d3 (patch)
tree4918d63eb6cb7427d398d6cac70bfa325ad29025 /src/lib/crypto
parent41ff7485d2775407c85fb2b90b26c3170b2ad4b5 (diff)
downloadkrb5-3954dd2c1f9919e2ac09f86f022063119b5dd8d3.tar.gz
krb5-3954dd2c1f9919e2ac09f86f022063119b5dd8d3.tar.xz
krb5-3954dd2c1f9919e2ac09f86f022063119b5dd8d3.zip
Moved krb5, gss, and crypto library initialization/cleanup code into new dedicated functions; added code to release global state allocated in prng.c
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11960 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/crypto')
-rw-r--r--src/lib/crypto/ChangeLog6
-rw-r--r--src/lib/crypto/Makefile.in3
-rw-r--r--src/lib/crypto/crypto_libinit.c30
-rw-r--r--src/lib/crypto/crypto_libinit.h7
-rw-r--r--src/lib/crypto/prng.c6
5 files changed, 52 insertions, 0 deletions
diff --git a/src/lib/crypto/ChangeLog b/src/lib/crypto/ChangeLog
index 0c4236842c..957a0ec312 100644
--- a/src/lib/crypto/ChangeLog
+++ b/src/lib/crypto/ChangeLog
@@ -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
diff --git a/src/lib/crypto/Makefile.in b/src/lib/crypto/Makefile.in
index d86325bf82..71bddf5c4b 100644
--- a/src/lib/crypto/Makefile.in
+++ b/src/lib/crypto/Makefile.in
@@ -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
index 0000000000..5ae277e9e8
--- /dev/null
+++ b/src/lib/crypto/crypto_libinit.c
@@ -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
index 0000000000..3586a63aa9
--- /dev/null
+++ b/src/lib/crypto/crypto_libinit.h
@@ -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 */
diff --git a/src/lib/crypto/prng.c b/src/lib/crypto/prng.c
index c0f106f0a5..6d401a9bf0 100644
--- a/src/lib/crypto/prng.c
+++ b/src/lib/crypto/prng.c
@@ -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