summaryrefslogtreecommitdiffstats
path: root/ssl/kssl.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssl/kssl.c')
-rw-r--r--ssl/kssl.c3863
1 files changed, 1947 insertions, 1916 deletions
diff --git a/ssl/kssl.c b/ssl/kssl.c
index 6f100eede5..c223a5660c 100644
--- a/ssl/kssl.c
+++ b/ssl/kssl.c
@@ -1,5 +1,7 @@
/* ssl/kssl.c -*- mode: C; c-file-style: "eay" -*- */
-/* Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project 2000.
+/*
+ * Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project
+ * 2000.
*/
/* ====================================================================
* Copyright (c) 2000 The OpenSSL Project. All rights reserved.
@@ -9,7 +11,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -55,23 +57,22 @@
*
*/
-
/*-
* ssl/kssl.c -- Routines to support (& debug) Kerberos5 auth for openssl
*
- * 19990701 VRS Started.
- * 200011?? Jeffrey Altman, Richard Levitte
- * Generalized for Heimdal, Newer MIT, & Win32.
- * Integrated into main OpenSSL 0.9.7 snapshots.
- * 20010413 Simon Wilkinson, VRS
- * Real RFC2712 KerberosWrapper replaces AP_REQ.
+ * 19990701 VRS Started.
+ * 200011?? Jeffrey Altman, Richard Levitte
+ * Generalized for Heimdal, Newer MIT, & Win32.
+ * Integrated into main OpenSSL 0.9.7 snapshots.
+ * 20010413 Simon Wilkinson, VRS
+ * Real RFC2712 KerberosWrapper replaces AP_REQ.
*/
#include <openssl/opensslconf.h>
#include <string.h>
-#define KRB5_PRIVATE 1
+#define KRB5_PRIVATE 1
#include <openssl/ssl.h>
#include <openssl/evp.h>
@@ -81,19 +82,19 @@
#ifndef OPENSSL_NO_KRB5
-#ifndef ENOMEM
-#define ENOMEM KRB5KRB_ERR_GENERIC
-#endif
+# ifndef ENOMEM
+# define ENOMEM KRB5KRB_ERR_GENERIC
+# endif
-/*
+/*
* When OpenSSL is built on Windows, we do not want to require that
* the Kerberos DLLs be available in order for the OpenSSL DLLs to
* work. Therefore, all Kerberos routines are loaded at run time
* and we do not link to a .LIB file.
*/
-#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
-/*
+# if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
+/*
* The purpose of the following pre-processor statements is to provide
* compatibility with different releases of MIT Kerberos for Windows.
* All versions up to 1.2 used macros. But macros do not allow for
@@ -102,2128 +103,2158 @@
* an OpenSSL DLL built on Windows to work whether or not the macro
* or function form of the routines are utilized.
*/
-#ifdef krb5_cc_get_principal
-#define NO_DEF_KRB5_CCACHE
-#undef krb5_cc_get_principal
-#endif
-#define krb5_cc_get_principal kssl_krb5_cc_get_principal
-
-#define krb5_free_data_contents kssl_krb5_free_data_contents
-#define krb5_free_context kssl_krb5_free_context
-#define krb5_auth_con_free kssl_krb5_auth_con_free
-#define krb5_free_principal kssl_krb5_free_principal
-#define krb5_mk_req_extended kssl_krb5_mk_req_extended
-#define krb5_get_credentials kssl_krb5_get_credentials
-#define krb5_cc_default kssl_krb5_cc_default
-#define krb5_sname_to_principal kssl_krb5_sname_to_principal
-#define krb5_init_context kssl_krb5_init_context
-#define krb5_free_ticket kssl_krb5_free_ticket
-#define krb5_rd_req kssl_krb5_rd_req
-#define krb5_kt_default kssl_krb5_kt_default
-#define krb5_kt_resolve kssl_krb5_kt_resolve
+# ifdef krb5_cc_get_principal
+# define NO_DEF_KRB5_CCACHE
+# undef krb5_cc_get_principal
+# endif
+# define krb5_cc_get_principal kssl_krb5_cc_get_principal
+
+# define krb5_free_data_contents kssl_krb5_free_data_contents
+# define krb5_free_context kssl_krb5_free_context
+# define krb5_auth_con_free kssl_krb5_auth_con_free
+# define krb5_free_principal kssl_krb5_free_principal
+# define krb5_mk_req_extended kssl_krb5_mk_req_extended
+# define krb5_get_credentials kssl_krb5_get_credentials
+# define krb5_cc_default kssl_krb5_cc_default
+# define krb5_sname_to_principal kssl_krb5_sname_to_principal
+# define krb5_init_context kssl_krb5_init_context
+# define krb5_free_ticket kssl_krb5_free_ticket
+# define krb5_rd_req kssl_krb5_rd_req
+# define krb5_kt_default kssl_krb5_kt_default
+# define krb5_kt_resolve kssl_krb5_kt_resolve
/* macros in mit 1.2.2 and earlier; functions in mit 1.2.3 and greater */
-#ifndef krb5_kt_close
-#define krb5_kt_close kssl_krb5_kt_close
-#endif /* krb5_kt_close */
-#ifndef krb5_kt_get_entry
-#define krb5_kt_get_entry kssl_krb5_kt_get_entry
-#endif /* krb5_kt_get_entry */
-#define krb5_auth_con_init kssl_krb5_auth_con_init
-
-#define krb5_principal_compare kssl_krb5_principal_compare
-#define krb5_decrypt_tkt_part kssl_krb5_decrypt_tkt_part
-#define krb5_timeofday kssl_krb5_timeofday
-#define krb5_rc_default kssl_krb5_rc_default
-
-#ifdef krb5_rc_initialize
-#undef krb5_rc_initialize
-#endif
-#define krb5_rc_initialize kssl_krb5_rc_initialize
-
-#ifdef krb5_rc_get_lifespan
-#undef krb5_rc_get_lifespan
-#endif
-#define krb5_rc_get_lifespan kssl_krb5_rc_get_lifespan
-
-#ifdef krb5_rc_destroy
-#undef krb5_rc_destroy
-#endif
-#define krb5_rc_destroy kssl_krb5_rc_destroy
-
-#define valid_cksumtype kssl_valid_cksumtype
-#define krb5_checksum_size kssl_krb5_checksum_size
-#define krb5_kt_free_entry kssl_krb5_kt_free_entry
-#define krb5_auth_con_setrcache kssl_krb5_auth_con_setrcache
-#define krb5_auth_con_getrcache kssl_krb5_auth_con_getrcache
-#define krb5_get_server_rcache kssl_krb5_get_server_rcache
+# ifndef krb5_kt_close
+# define krb5_kt_close kssl_krb5_kt_close
+# endif /* krb5_kt_close */
+# ifndef krb5_kt_get_entry
+# define krb5_kt_get_entry kssl_krb5_kt_get_entry
+# endif /* krb5_kt_get_entry */
+# define krb5_auth_con_init kssl_krb5_auth_con_init
+
+# define krb5_principal_compare kssl_krb5_principal_compare
+# define krb5_decrypt_tkt_part kssl_krb5_decrypt_tkt_part
+# define krb5_timeofday kssl_krb5_timeofday
+# define krb5_rc_default kssl_krb5_rc_default
+
+# ifdef krb5_rc_initialize
+# undef krb5_rc_initialize
+# endif
+# define krb5_rc_initialize kssl_krb5_rc_initialize
+
+# ifdef krb5_rc_get_lifespan
+# undef krb5_rc_get_lifespan
+# endif
+# define krb5_rc_get_lifespan kssl_krb5_rc_get_lifespan
+
+# ifdef krb5_rc_destroy
+# undef krb5_rc_destroy
+# endif
+# define krb5_rc_destroy kssl_krb5_rc_destroy
+
+# define valid_cksumtype kssl_valid_cksumtype
+# define krb5_checksum_size kssl_krb5_checksum_size
+# define krb5_kt_free_entry kssl_krb5_kt_free_entry
+# define krb5_auth_con_setrcache kssl_krb5_auth_con_setrcache
+# define krb5_auth_con_getrcache kssl_krb5_auth_con_getrcache
+# define krb5_get_server_rcache kssl_krb5_get_server_rcache
/* Prototypes for built in stubs */
void kssl_krb5_free_data_contents(krb5_context, krb5_data *);
-void kssl_krb5_free_principal(krb5_context, krb5_principal );
+void kssl_krb5_free_principal(krb5_context, krb5_principal);
krb5_error_code kssl_krb5_kt_resolve(krb5_context,
- krb5_const char *,
- krb5_keytab *);
-krb5_error_code kssl_krb5_kt_default(krb5_context,
- krb5_keytab *);
+ krb5_const char *, krb5_keytab *);
+krb5_error_code kssl_krb5_kt_default(krb5_context, krb5_keytab *);
krb5_error_code kssl_krb5_free_ticket(krb5_context, krb5_ticket *);
-krb5_error_code kssl_krb5_rd_req(krb5_context, krb5_auth_context *,
+krb5_error_code kssl_krb5_rd_req(krb5_context, krb5_auth_context *,
krb5_const krb5_data *,
- krb5_const_principal, krb5_keytab,
- krb5_flags *,krb5_ticket **);
+ krb5_const_principal, krb5_keytab,
+ krb5_flags *, krb5_ticket **);
krb5_boolean kssl_krb5_principal_compare(krb5_context, krb5_const_principal,
krb5_const_principal);
krb5_error_code kssl_krb5_mk_req_extended(krb5_context,
- krb5_auth_context *,
+ krb5_auth_context *,
krb5_const krb5_flags,
- krb5_data *,
- krb5_creds *,
- krb5_data * );
+ krb5_data *,
+ krb5_creds *, krb5_data *);
krb5_error_code kssl_krb5_init_context(krb5_context *);
void kssl_krb5_free_context(krb5_context);
-krb5_error_code kssl_krb5_cc_default(krb5_context,krb5_ccache *);
+krb5_error_code kssl_krb5_cc_default(krb5_context, krb5_ccache *);
krb5_error_code kssl_krb5_sname_to_principal(krb5_context,
- krb5_const char *,
- krb5_const char *,
- krb5_int32,
- krb5_principal *);
+ krb5_const char *,
+ krb5_const char *,
+ krb5_int32, krb5_principal *);
krb5_error_code kssl_krb5_get_credentials(krb5_context,
krb5_const krb5_flags,
krb5_ccache,
- krb5_creds *,
- krb5_creds * *);
-krb5_error_code kssl_krb5_auth_con_init(krb5_context,
- krb5_auth_context *);
-krb5_error_code kssl_krb5_cc_get_principal(krb5_context context,
+ krb5_creds *, krb5_creds * *);
+krb5_error_code kssl_krb5_auth_con_init(krb5_context, krb5_auth_context *);
+krb5_error_code kssl_krb5_cc_get_principal(krb5_context context,
krb5_ccache cache,
krb5_principal *principal);
-krb5_error_code kssl_krb5_auth_con_free(krb5_context,krb5_auth_context);
-size_t kssl_krb5_checksum_size(krb5_context context,krb5_cksumtype ctype);
+krb5_error_code kssl_krb5_auth_con_free(krb5_context, krb5_auth_context);
+size_t kssl_krb5_checksum_size(krb5_context context, krb5_cksumtype ctype);
krb5_boolean kssl_valid_cksumtype(krb5_cksumtype ctype);
-krb5_error_code krb5_kt_free_entry(krb5_context,krb5_keytab_entry FAR * );
-krb5_error_code kssl_krb5_auth_con_setrcache(krb5_context,
- krb5_auth_context,
- krb5_rcache);
-krb5_error_code kssl_krb5_get_server_rcache(krb5_context,
+krb5_error_code krb5_kt_free_entry(krb5_context, krb5_keytab_entry FAR *);
+krb5_error_code kssl_krb5_auth_con_setrcache(krb5_context,
+ krb5_auth_context, krb5_rcache);
+krb5_error_code kssl_krb5_get_server_rcache(krb5_context,
krb5_const krb5_data *,
krb5_rcache *);
-krb5_error_code kssl_krb5_auth_con_getrcache(krb5_context,
+krb5_error_code kssl_krb5_auth_con_getrcache(krb5_context,
krb5_auth_context,
krb5_rcache *);
/* Function pointers (almost all Kerberos functions are _stdcall) */
-static void (_stdcall *p_krb5_free_data_contents)(krb5_context, krb5_data *)
- =NULL;
-static void (_stdcall *p_krb5_free_principal)(krb5_context, krb5_principal )
- =NULL;
+static void (_stdcall *p_krb5_free_data_contents) (krb5_context, krb5_data *)
+ = NULL;
+static void (_stdcall *p_krb5_free_principal) (krb5_context, krb5_principal)
+ = NULL;
static krb5_error_code(_stdcall *p_krb5_kt_resolve)
- (krb5_context, krb5_const char *, krb5_keytab *)=NULL;
-static krb5_error_code (_stdcall *p_krb5_kt_default)(krb5_context,
- krb5_keytab *)=NULL;
-static krb5_error_code (_stdcall *p_krb5_free_ticket)(krb5_context,
- krb5_ticket *)=NULL;
-static krb5_error_code (_stdcall *p_krb5_rd_req)(krb5_context,
- krb5_auth_context *,
+ (krb5_context, krb5_const char *, krb5_keytab *) = NULL;
+static krb5_error_code(_stdcall *p_krb5_kt_default) (krb5_context,
+ krb5_keytab *) = NULL;
+static krb5_error_code(_stdcall *p_krb5_free_ticket) (krb5_context,
+ krb5_ticket *) = NULL;
+static krb5_error_code(_stdcall *p_krb5_rd_req) (krb5_context,
+ krb5_auth_context *,
krb5_const krb5_data *,
- krb5_const_principal,
+ krb5_const_principal,
krb5_keytab, krb5_flags *,
- krb5_ticket **)=NULL;
-static krb5_error_code (_stdcall *p_krb5_mk_req_extended)
- (krb5_context, krb5_auth_context *,
- krb5_const krb5_flags, krb5_data *, krb5_creds *,
- krb5_data * )=NULL;
-static krb5_error_code (_stdcall *p_krb5_init_context)(krb5_context *)=NULL;
-static void (_stdcall *p_krb5_free_context)(krb5_context)=NULL;
-static krb5_error_code (_stdcall *p_krb5_cc_default)(krb5_context,
- krb5_ccache *)=NULL;
-static krb5_error_code (_stdcall *p_krb5_sname_to_principal)
- (krb5_context, krb5_const char *, krb5_const char *,
- krb5_int32, krb5_principal *)=NULL;
-static krb5_error_code (_stdcall *p_krb5_get_credentials)
- (krb5_context, krb5_const krb5_flags, krb5_ccache,
- krb5_creds *, krb5_creds **)=NULL;
-static krb5_error_code (_stdcall *p_krb5_auth_con_init)
- (krb5_context, krb5_auth_context *)=NULL;
-static krb5_error_code (_stdcall *p_krb5_cc_get_principal)
- (krb5_context context, krb5_ccache cache,
- krb5_principal *principal)=NULL;
-static krb5_error_code (_stdcall *p_krb5_auth_con_free)
- (krb5_context, krb5_auth_context)=NULL;
-static krb5_error_code (_stdcall *p_krb5_decrypt_tkt_part)
- (krb5_context, krb5_const krb5_keyblock *,
- krb5_ticket *)=NULL;
-static krb5_error_code (_stdcall *p_krb5_timeofday)
- (krb5_context context, krb5_int32 *timeret)=NULL;
-static krb5_error_code (_stdcall *p_krb5_rc_default)
- (krb5_context context, krb5_rcache *rc)=NULL;
-static krb5_error_code (_stdcall *p_krb5_rc_initialize)
- (krb5_context context, krb5_rcache rc,
- krb5_deltat lifespan)=NULL;
-static krb5_error_code (_stdcall *p_krb5_rc_get_lifespan)
- (krb5_context context, krb5_rcache rc,
- krb5_deltat *lifespan)=NULL;
-static krb5_error_code (_stdcall *p_krb5_rc_destroy)
- (krb5_context context, krb5_rcache rc)=NULL;
-static krb5_boolean (_stdcall *p_krb5_principal_compare)
- (krb5_context, krb5_const_principal, krb5_const_principal)=NULL;
-static size_t (_stdcall *p_krb5_checksum_size)(krb5_context context,krb5_cksumtype ctype)=NULL;
-static krb5_boolean (_stdcall *p_valid_cksumtype)(krb5_cksumtype ctype)=NULL;
-static krb5_error_code (_stdcall *p_krb5_kt_free_entry)
- (krb5_context,krb5_keytab_entry * )=NULL;
-static krb5_error_code (_stdcall * p_krb5_auth_con_setrcache)(krb5_context,
- krb5_auth_context,
- krb5_rcache)=NULL;
-static krb5_error_code (_stdcall * p_krb5_get_server_rcache)(krb5_context,
- krb5_const krb5_data *,
- krb5_rcache *)=NULL;
-static krb5_error_code (* p_krb5_auth_con_getrcache)(krb5_context,
- krb5_auth_context,
- krb5_rcache *)=NULL;
-static krb5_error_code (_stdcall * p_krb5_kt_close)(krb5_context context,
- krb5_keytab keytab)=NULL;
-static krb5_error_code (_stdcall * p_krb5_kt_get_entry)(krb5_context context,
- krb5_keytab keytab,
- krb5_const_principal principal, krb5_kvno vno,
- krb5_enctype enctype, krb5_keytab_entry *entry)=NULL;
+ krb5_ticket **) = NULL;
+static krb5_error_code(_stdcall *p_krb5_mk_req_extended)
+ (krb5_context, krb5_auth_context *,
+ krb5_const krb5_flags, krb5_data *, krb5_creds *, krb5_data *) = NULL;
+static krb5_error_code(_stdcall *p_krb5_init_context) (krb5_context *) = NULL;
+static void (_stdcall *p_krb5_free_context) (krb5_context) = NULL;
+static krb5_error_code(_stdcall *p_krb5_cc_default) (krb5_context,
+ krb5_ccache *) = NULL;
+static krb5_error_code(_stdcall *p_krb5_sname_to_principal)
+ (krb5_context, krb5_const char *, krb5_const char *,
+ krb5_int32, krb5_principal *) = NULL;
+static krb5_error_code(_stdcall *p_krb5_get_credentials)
+ (krb5_context, krb5_const krb5_flags, krb5_ccache,
+ krb5_creds *, krb5_creds **) = NULL;
+static krb5_error_code(_stdcall *p_krb5_auth_con_init)
+ (krb5_context, krb5_auth_context *) = NULL;
+static krb5_error_code(_stdcall *p_krb5_cc_get_principal)
+ (krb5_context context, krb5_ccache cache, krb5_principal *principal) = NULL;
+static krb5_error_code(_stdcall *p_krb5_auth_con_free)
+ (krb5_context, krb5_auth_context) = NULL;
+static krb5_error_code(_stdcall *p_krb5_decrypt_tkt_part)
+ (krb5_context, krb5_const krb5_keyblock *, krb5_ticket *) = NULL;
+static krb5_error_code(_stdcall *p_krb5_timeofday)
+ (krb5_context context, krb5_int32 *timeret) = NULL;
+static krb5_error_code(_stdcall *p_krb5_rc_default)
+ (krb5_context context, krb5_rcache *rc) = NULL;
+static krb5_error_code(_stdcall *p_krb5_rc_initialize)
+ (krb5_context context, krb5_rcache rc, krb5_deltat lifespan) = NULL;
+static krb5_error_code(_stdcall *p_krb5_rc_get_lifespan)
+ (krb5_context context, krb5_rcache rc, krb5_deltat *lifespan) = NULL;
+static krb5_error_code(_stdcall *p_krb5_rc_destroy)
+ (krb5_context context, krb5_rcache rc) = NULL;
+static krb5_boolean(_stdcall *p_krb5_principal_compare)
+ (krb5_context, krb5_const_principal, krb5_const_principal) = NULL;
+static size_t (_stdcall *p_krb5_checksum_size) (krb5_context context,
+ krb5_cksumtype ctype) = NULL;
+static krb5_boolean(_stdcall *p_valid_cksumtype) (krb5_cksumtype ctype) =
+ NULL;
+static krb5_error_code(_stdcall *p_krb5_kt_free_entry)
+ (krb5_context, krb5_keytab_entry *) = NULL;
+static krb5_error_code(_stdcall *p_krb5_auth_con_setrcache) (krb5_context,
+ krb5_auth_context,
+ krb5_rcache) =
+ NULL;
+static krb5_error_code(_stdcall *p_krb5_get_server_rcache) (krb5_context,
+ krb5_const
+ krb5_data *,
+ krb5_rcache *) =
+ NULL;
+static krb5_error_code(*p_krb5_auth_con_getrcache) (krb5_context,
+ krb5_auth_context,
+ krb5_rcache *) = NULL;
+static krb5_error_code(_stdcall *p_krb5_kt_close) (krb5_context context,
+ krb5_keytab keytab) = NULL;
+static krb5_error_code(_stdcall *p_krb5_kt_get_entry) (krb5_context context,
+ krb5_keytab keytab,
+ krb5_const_principal
+ principal,
+ krb5_kvno vno,
+ krb5_enctype enctype,
+ krb5_keytab_entry
+ *entry) = NULL;
static int krb5_loaded = 0; /* only attempt to initialize func ptrs once */
/* Function to Load the Kerberos 5 DLL and initialize function pointers */
-void
-load_krb5_dll(void)
- {
- HANDLE hKRB5_32;
-
- krb5_loaded++;
- hKRB5_32 = LoadLibrary(TEXT("KRB5_32"));
- if (!hKRB5_32)
- return;
-
- (FARPROC) p_krb5_free_data_contents =
- GetProcAddress( hKRB5_32, "krb5_free_data_contents" );
- (FARPROC) p_krb5_free_context =
- GetProcAddress( hKRB5_32, "krb5_free_context" );
- (FARPROC) p_krb5_auth_con_free =
- GetProcAddress( hKRB5_32, "krb5_auth_con_free" );
- (FARPROC) p_krb5_free_principal =
- GetProcAddress( hKRB5_32, "krb5_free_principal" );
- (FARPROC) p_krb5_mk_req_extended =
- GetProcAddress( hKRB5_32, "krb5_mk_req_extended" );
- (FARPROC) p_krb5_get_credentials =
- GetProcAddress( hKRB5_32, "krb5_get_credentials" );
- (FARPROC) p_krb5_cc_get_principal =
- GetProcAddress( hKRB5_32, "krb5_cc_get_principal" );
- (FARPROC) p_krb5_cc_default =
- GetProcAddress( hKRB5_32, "krb5_cc_default" );
- (FARPROC) p_krb5_sname_to_principal =
- GetProcAddress( hKRB5_32, "krb5_sname_to_principal" );
- (FARPROC) p_krb5_init_context =
- GetProcAddress( hKRB5_32, "krb5_init_context" );
- (FARPROC) p_krb5_free_ticket =
- GetProcAddress( hKRB5_32, "krb5_free_ticket" );
- (FARPROC) p_krb5_rd_req =
- GetProcAddress( hKRB5_32, "krb5_rd_req" );
- (FARPROC) p_krb5_principal_compare =
- GetProcAddress( hKRB5_32, "krb5_principal_compare" );
- (FARPROC) p_krb5_decrypt_tkt_part =
- GetProcAddress( hKRB5_32, "krb5_decrypt_tkt_part" );
- (FARPROC) p_krb5_timeofday =
- GetProcAddress( hKRB5_32, "krb5_timeofday" );
- (FARPROC) p_krb5_rc_default =
- GetProcAddress( hKRB5_32, "krb5_rc_default" );
- (FARPROC) p_krb5_rc_initialize =
- GetProcAddress( hKRB5_32, "krb5_rc_initialize" );
- (FARPROC) p_krb5_rc_get_lifespan =
- GetProcAddress( hKRB5_32, "krb5_rc_get_lifespan" );
- (FARPROC) p_krb5_rc_destroy =
- GetProcAddress( hKRB5_32, "krb5_rc_destroy" );
- (FARPROC) p_krb5_kt_default =
- GetProcAddress( hKRB5_32, "krb5_kt_default" );
- (FARPROC) p_krb5_kt_resolve =
- GetProcAddress( hKRB5_32, "krb5_kt_resolve" );
- (FARPROC) p_krb5_auth_con_init =
- GetProcAddress( hKRB5_32, "krb5_auth_con_init" );
- (FARPROC) p_valid_cksumtype =
- GetProcAddress( hKRB5_32, "valid_cksumtype" );
- (FARPROC) p_krb5_checksum_size =
- GetProcAddress( hKRB5_32, "krb5_checksum_size" );
- (FARPROC) p_krb5_kt_free_entry =
- GetProcAddress( hKRB5_32, "krb5_kt_free_entry" );
- (FARPROC) p_krb5_auth_con_setrcache =
- GetProcAddress( hKRB5_32, "krb5_auth_con_setrcache" );
- (FARPROC) p_krb5_get_server_rcache =
- GetProcAddress( hKRB5_32, "krb5_get_server_rcache" );
- (FARPROC) p_krb5_auth_con_getrcache =
- GetProcAddress( hKRB5_32, "krb5_auth_con_getrcache" );
- (FARPROC) p_krb5_kt_close =
- GetProcAddress( hKRB5_32, "krb5_kt_close" );
- (FARPROC) p_krb5_kt_get_entry =
- GetProcAddress( hKRB5_32, "krb5_kt_get_entry" );
- }
+void load_krb5_dll(void)
+{
+ HANDLE hKRB5_32;
+
+ krb5_loaded++;
+ hKRB5_32 = LoadLibrary(TEXT("KRB5_32"));
+ if (!hKRB5_32)
+ return;
+
+ (FARPROC) p_krb5_free_data_contents =
+ GetProcAddress(hKRB5_32, "krb5_free_data_contents");
+ (FARPROC) p_krb5_free_context =
+ GetProcAddress(hKRB5_32, "krb5_free_context");
+ (FARPROC) p_krb5_auth_con_free =
+ GetProcAddress(hKRB5_32, "krb5_auth_con_free");
+ (FARPROC) p_krb5_free_principal =
+ GetProcAddress(hKRB5_32, "krb5_free_principal");
+ (FARPROC) p_krb5_mk_req_extended =
+ GetProcAddress(hKRB5_32, "krb5_mk_req_extended");
+ (FARPROC) p_krb5_get_credentials =
+ GetProcAddress(hKRB5_32, "krb5_get_credentials");
+ (FARPROC) p_krb5_cc_get_principal =
+ GetProcAddress(hKRB5_32, "krb5_cc_get_principal");
+ (FARPROC) p_krb5_cc_default = GetProcAddress(hKRB5_32, "krb5_cc_default");
+ (FARPROC) p_krb5_sname_to_principal =
+ GetProcAddress(hKRB5_32, "krb5_sname_to_principal");
+ (FARPROC) p_krb5_init_context =
+ GetProcAddress(hKRB5_32, "krb5_init_context");
+ (FARPROC) p_krb5_free_ticket =
+ GetProcAddress(hKRB5_32, "krb5_free_ticket");
+ (FARPROC) p_krb5_rd_req = GetProcAddress(hKRB5_32, "krb5_rd_req");
+ (FARPROC) p_krb5_principal_compare =
+ GetProcAddress(hKRB5_32, "krb5_principal_compare");
+ (FARPROC) p_krb5_decrypt_tkt_part =
+ GetProcAddress(hKRB5_32, "krb5_decrypt_tkt_part");
+ (FARPROC) p_krb5_timeofday = GetProcAddress(hKRB5_32, "krb5_timeofday");
+ (FARPROC) p_krb5_rc_default = GetProcAddress(hKRB5_32, "krb5_rc_default");
+ (FARPROC) p_krb5_rc_initialize =
+ GetProcAddress(hKRB5_32, "krb5_rc_initialize");
+ (FARPROC) p_krb5_rc_get_lifespan =
+ GetProcAddress(hKRB5_32, "krb5_rc_get_lifespan");
+ (FARPROC) p_krb5_rc_destroy = GetProcAddress(hKRB5_32, "krb5_rc_destroy");
+ (FARPROC) p_krb5_kt_default = GetProcAddress(hKRB5_32, "krb5_kt_default");
+ (FARPROC) p_krb5_kt_resolve = GetProcAddress(hKRB5_32, "krb5_kt_resolve");
+ (FARPROC) p_krb5_auth_con_init =
+ GetProcAddress(hKRB5_32, "krb5_auth_con_init");
+ (FARPROC) p_valid_cksumtype = GetProcAddress(hKRB5_32, "valid_cksumtype");
+ (FARPROC) p_krb5_checksum_size =
+ GetProcAddress(hKRB5_32, "krb5_checksum_size");
+ (FARPROC) p_krb5_kt_free_entry =
+ GetProcAddress(hKRB5_32, "krb5_kt_free_entry");
+ (FARPROC) p_krb5_auth_con_setrcache =
+ GetProcAddress(hKRB5_32, "krb5_auth_con_setrcache");
+ (FARPROC) p_krb5_get_server_rcache =
+ GetProcAddress(hKRB5_32, "krb5_get_server_rcache");
+ (FARPROC) p_krb5_auth_con_getrcache =
+ GetProcAddress(hKRB5_32, "krb5_auth_con_getrcache");
+ (FARPROC) p_krb5_kt_close = GetProcAddress(hKRB5_32, "krb5_kt_close");
+ (FARPROC) p_krb5_kt_get_entry =
+ GetProcAddress(hKRB5_32, "krb5_kt_get_entry");
+}
/* Stubs for each function to be dynamicly loaded */
-void
-kssl_krb5_free_data_contents(krb5_context CO, krb5_data * data)
- {
- if (!krb5_loaded)
- load_krb5_dll();
+void kssl_krb5_free_data_contents(krb5_context CO, krb5_data *data)
+{
+ if (!krb5_loaded)
+ load_krb5_dll();
- if ( p_krb5_free_data_contents )
- p_krb5_free_data_contents(CO,data);
- }
+ if (p_krb5_free_data_contents)
+ p_krb5_free_data_contents(CO, data);
+}
krb5_error_code
-kssl_krb5_mk_req_extended (krb5_context CO,
- krb5_auth_context * pACO,
+kssl_krb5_mk_req_extended(krb5_context CO,
+ krb5_auth_context *pACO,
krb5_const krb5_flags F,
- krb5_data * pD1,
- krb5_creds * pC,
- krb5_data * pD2)
- {
- if (!krb5_loaded)
- load_krb5_dll();
-
- if ( p_krb5_mk_req_extended )
- return(p_krb5_mk_req_extended(CO,pACO,F,pD1,pC,pD2));
- else
- return KRB5KRB_ERR_GENERIC;
- }
+ krb5_data *pD1, krb5_creds *pC, krb5_data *pD2)
+{
+ if (!krb5_loaded)
+ load_krb5_dll();
+
+ if (p_krb5_mk_req_extended)
+ return (p_krb5_mk_req_extended(CO, pACO, F, pD1, pC, pD2));
+ else
+ return KRB5KRB_ERR_GENERIC;
+}
+
krb5_error_code
-kssl_krb5_auth_con_init(krb5_context CO,
- krb5_auth_context * pACO)
- {
- if (!krb5_loaded)
- load_krb5_dll();
-
- if ( p_krb5_auth_con_init )
- return(p_krb5_auth_con_init(CO,pACO));
- else
- return KRB5KRB_ERR_GENERIC;
- }
+kssl_krb5_auth_con_init(krb5_context CO, krb5_auth_context *pACO)
+{
+ if (!krb5_loaded)
+ load_krb5_dll();
+
+ if (p_krb5_auth_con_init)
+ return (p_krb5_auth_con_init(CO, pACO));
+ else
+ return KRB5KRB_ERR_GENERIC;
+}
+
krb5_error_code
-kssl_krb5_auth_con_free (krb5_context CO,
- krb5_auth_context ACO)
- {
- if (!krb5_loaded)
- load_krb5_dll();
-
- if ( p_krb5_auth_con_free )
- return(p_krb5_auth_con_free(CO,ACO));
- else
- return KRB5KRB_ERR_GENERIC;
- }
+kssl_krb5_auth_con_free(krb5_context CO, krb5_auth_context ACO)
+{
+ if (!krb5_loaded)
+ load_krb5_dll();
+
+ if (p_krb5_auth_con_free)
+ return (p_krb5_auth_con_free(CO, ACO));
+ else
+ return KRB5KRB_ERR_GENERIC;
+}
+
krb5_error_code
kssl_krb5_get_credentials(krb5_context CO,
- krb5_const krb5_flags F,
- krb5_ccache CC,
- krb5_creds * pCR,
- krb5_creds ** ppCR)
- {
- if (!krb5_loaded)
- load_krb5_dll();
-
- if ( p_krb5_get_credentials )
- return(p_krb5_get_credentials(CO,F,CC,pCR,ppCR));
- else
- return KRB5KRB_ERR_GENERIC;
- }
+ krb5_const krb5_flags F,
+ krb5_ccache CC, krb5_creds *pCR, krb5_creds **ppCR)
+{
+ if (!krb5_loaded)
+ load_krb5_dll();
+
+ if (p_krb5_get_credentials)
+ return (p_krb5_get_credentials(CO, F, CC, pCR, ppCR));
+ else
+ return KRB5KRB_ERR_GENERIC;
+}
+
krb5_error_code
kssl_krb5_sname_to_principal(krb5_context CO,
- krb5_const char * pC1,
- krb5_const char * pC2,
- krb5_int32 I,
- krb5_principal * pPR)
- {
- if (!krb5_loaded)
- load_krb5_dll();
-
- if ( p_krb5_sname_to_principal )
- return(p_krb5_sname_to_principal(CO,pC1,pC2,I,pPR));
- else
- return KRB5KRB_ERR_GENERIC;
- }
+ krb5_const char *pC1,
+ krb5_const char *pC2,
+ krb5_int32 I, krb5_principal *pPR)
+{
+ if (!krb5_loaded)
+ load_krb5_dll();
-krb5_error_code
-kssl_krb5_cc_default(krb5_context CO,
- krb5_ccache * pCC)
- {
- if (!krb5_loaded)
- load_krb5_dll();
-
- if ( p_krb5_cc_default )
- return(p_krb5_cc_default(CO,pCC));
- else
- return KRB5KRB_ERR_GENERIC;
- }
+ if (p_krb5_sname_to_principal)
+ return (p_krb5_sname_to_principal(CO, pC1, pC2, I, pPR));
+ else
+ return KRB5KRB_ERR_GENERIC;
+}
-krb5_error_code
-kssl_krb5_init_context(krb5_context * pCO)
- {
- if (!krb5_loaded)
- load_krb5_dll();
-
- if ( p_krb5_init_context )
- return(p_krb5_init_context(pCO));
- else
- return KRB5KRB_ERR_GENERIC;
- }
-
-void
-kssl_krb5_free_context(krb5_context CO)
- {
- if (!krb5_loaded)
- load_krb5_dll();
-
- if ( p_krb5_free_context )
- p_krb5_free_context(CO);
- }
-
-void
-kssl_krb5_free_principal(krb5_context c, krb5_principal p)
- {
- if (!krb5_loaded)
- load_krb5_dll();
-
- if ( p_krb5_free_principal )
- p_krb5_free_principal(c,p);
- }
+krb5_error_code kssl_krb5_cc_default(krb5_context CO, krb5_ccache *pCC)
+{
+ if (!krb5_loaded)
+ load_krb5_dll();
-krb5_error_code
-kssl_krb5_kt_resolve(krb5_context con,
- krb5_const char * sz,
- krb5_keytab * kt)
- {
- if (!krb5_loaded)
- load_krb5_dll();
-
- if ( p_krb5_kt_resolve )
- return(p_krb5_kt_resolve(con,sz,kt));
- else
- return KRB5KRB_ERR_GENERIC;
- }
+ if (p_krb5_cc_default)
+ return (p_krb5_cc_default(CO, pCC));
+ else
+ return KRB5KRB_ERR_GENERIC;
+}
-krb5_error_code
-kssl_krb5_kt_default(krb5_context con,
- krb5_keytab * kt)
- {
- if (!krb5_loaded)
- load_krb5_dll();
-
- if ( p_krb5_kt_default )
- return(p_krb5_kt_default(con,kt));
- else
- return KRB5KRB_ERR_GENERIC;
- }
+krb5_error_code kssl_krb5_init_context(krb5_context *pCO)
+{
+ if (!krb5_loaded)
+ load_krb5_dll();
+
+ if (p_krb5_init_context)
+ return (p_krb5_init_context(pCO));
+ else
+ return KRB5KRB_ERR_GENERIC;
+}
+
+void kssl_krb5_free_context(krb5_context CO)
+{
+ if (!krb5_loaded)
+ load_krb5_dll();
+
+ if (p_krb5_free_context)
+ p_krb5_free_context(CO);
+}
+
+void kssl_krb5_free_principal(krb5_context c, krb5_principal p)
+{
+ if (!krb5_loaded)
+ load_krb5_dll();
+
+ if (p_krb5_free_principal)
+ p_krb5_free_principal(c, p);
+}
krb5_error_code
-kssl_krb5_free_ticket(krb5_context con,
- krb5_ticket * kt)
- {
- if (!krb5_loaded)
- load_krb5_dll();
-
- if ( p_krb5_free_ticket )
- return(p_krb5_free_ticket(con,kt));
- else
- return KRB5KRB_ERR_GENERIC;
- }
+kssl_krb5_kt_resolve(krb5_context con, krb5_const char *sz, krb5_keytab *kt)
+{
+ if (!krb5_loaded)
+ load_krb5_dll();
+
+ if (p_krb5_kt_resolve)
+ return (p_krb5_kt_resolve(con, sz, kt));
+ else
+ return KRB5KRB_ERR_GENERIC;
+}
+
+krb5_error_code kssl_krb5_kt_default(krb5_context con, krb5_keytab *kt)
+{
+ if (!krb5_loaded)
+ load_krb5_dll();
+
+ if (p_krb5_kt_default)
+ return (p_krb5_kt_default(con, kt));
+ else
+ return KRB5KRB_ERR_GENERIC;
+}
+
+krb5_error_code kssl_krb5_free_ticket(krb5_context con, krb5_ticket *kt)
+{
+ if (!krb5_loaded)
+ load_krb5_dll();
+
+ if (p_krb5_free_ticket)
+ return (p_krb5_free_ticket(con, kt));
+ else
+ return KRB5KRB_ERR_GENERIC;
+}
krb5_error_code
-kssl_krb5_rd_req(krb5_context con, krb5_auth_context * pacon,
- krb5_const krb5_data * data,
- krb5_const_principal princ, krb5_keytab keytab,
- krb5_flags * flags, krb5_ticket ** pptkt)
- {
- if (!krb5_loaded)
- load_krb5_dll();
-
- if ( p_krb5_rd_req )
- return(p_krb5_rd_req(con,pacon,data,princ,keytab,flags,pptkt));
- else
- return KRB5KRB_ERR_GENERIC;
- }
+kssl_krb5_rd_req(krb5_context con, krb5_auth_context *pacon,
+ krb5_const krb5_data *data,
+ krb5_const_principal princ, krb5_keytab keytab,
+ krb5_flags *flags, krb5_ticket **pptkt)
+{
+ if (!krb5_loaded)
+ load_krb5_dll();
+
+ if (p_krb5_rd_req)
+ return (p_krb5_rd_req(con, pacon, data, princ, keytab, flags, pptkt));
+ else
+ return KRB5KRB_ERR_GENERIC;
+}
krb5_boolean
krb5_principal_compare(krb5_context con, krb5_const_principal princ1,
- krb5_const_principal princ2)
- {
- if (!krb5_loaded)
- load_krb5_dll();
+ krb5_const_principal princ2)
+{
+ if (!krb5_loaded)
+ load_krb5_dll();
- if ( p_krb5_principal_compare )
- return(p_krb5_principal_compare(con,princ1,princ2));
- else
- return KRB5KRB_ERR_GENERIC;
- }
+ if (p_krb5_principal_compare)
+ return (p_krb5_principal_compare(con, princ1, princ2));
+ else
+ return KRB5KRB_ERR_GENERIC;
+}
krb5_error_code
krb5_decrypt_tkt_part(krb5_context con, krb5_const krb5_keyblock *keys,
- krb5_ticket *ticket)
- {
- if (!krb5_loaded)
- load_krb5_dll();
+ krb5_ticket *ticket)
+{
+ if (!krb5_loaded)
+ load_krb5_dll();
- if ( p_krb5_decrypt_tkt_part )
- return(p_krb5_decrypt_tkt_part(con,keys,ticket));
- else
- return KRB5KRB_ERR_GENERIC;
- }
+ if (p_krb5_decrypt_tkt_part)
+ return (p_krb5_decrypt_tkt_part(con, keys, ticket));
+ else
+ return KRB5KRB_ERR_GENERIC;
+}
-krb5_error_code
-krb5_timeofday(krb5_context con, krb5_int32 *timeret)
- {
- if (!krb5_loaded)
- load_krb5_dll();
+krb5_error_code krb5_timeofday(krb5_context con, krb5_int32 *timeret)
+{
+ if (!krb5_loaded)
+ load_krb5_dll();
- if ( p_krb5_timeofday )
- return(p_krb5_timeofday(con,timeret));
- else
- return KRB5KRB_ERR_GENERIC;
- }
+ if (p_krb5_timeofday)
+ return (p_krb5_timeofday(con, timeret));
+ else
+ return KRB5KRB_ERR_GENERIC;
+}
-krb5_error_code
-krb5_rc_default(krb5_context con, krb5_rcache *rc)
- {
- if (!krb5_loaded)
- load_krb5_dll();
+krb5_erro