init.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "internal.h"
00024
00025
00026 #include <gc.h>
00027
00028
00029 #include "cram-md5/cram-md5.h"
00030 #include "external/external.h"
00031 #include "gssapi/x-gssapi.h"
00032 #include "gs2/gs2.h"
00033 #include "anonymous/anonymous.h"
00034 #include "plain/plain.h"
00035 #include "securid/securid.h"
00036 #include "digest-md5/digest-md5.h"
00037
00038 #include "login/login.h"
00039 #include "ntlm/x-ntlm.h"
00040 #include "kerberos_v5/kerberos_v5.h"
00041
00048 const char *GSASL_VALID_MECHANISM_CHARACTERS =
00049 "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
00050
00051 static int
00052 register_builtin_mechs (Gsasl * ctx)
00053 {
00054 int rc = GSASL_OK;
00055
00056 #ifdef USE_ANONYMOUS
00057 rc = gsasl_register (ctx, &gsasl_anonymous_mechanism);
00058 if (rc != GSASL_OK)
00059 return rc;
00060 #endif
00061
00062 #ifdef USE_EXTERNAL
00063 rc = gsasl_register (ctx, &gsasl_external_mechanism);
00064 if (rc != GSASL_OK)
00065 return rc;
00066 #endif
00067
00068 #ifdef USE_LOGIN
00069 rc = gsasl_register (ctx, &gsasl_login_mechanism);
00070 if (rc != GSASL_OK)
00071 return rc;
00072 #endif
00073
00074 #ifdef USE_PLAIN
00075 rc = gsasl_register (ctx, &gsasl_plain_mechanism);
00076 if (rc != GSASL_OK)
00077 return rc;
00078 #endif
00079
00080 #ifdef USE_SECURID
00081 rc = gsasl_register (ctx, &gsasl_securid_mechanism);
00082 if (rc != GSASL_OK)
00083 return rc;
00084 #endif
00085
00086 #ifdef USE_NTLM
00087 rc = gsasl_register (ctx, &gsasl_ntlm_mechanism);
00088 if (rc != GSASL_OK)
00089 return rc;
00090 #endif
00091
00092 #ifdef USE_DIGEST_MD5
00093 rc = gsasl_register (ctx, &gsasl_digest_md5_mechanism);
00094 if (rc != GSASL_OK)
00095 return rc;
00096 #endif
00097
00098 #ifdef USE_CRAM_MD5
00099 rc = gsasl_register (ctx, &gsasl_cram_md5_mechanism);
00100 if (rc != GSASL_OK)
00101 return rc;
00102 #endif
00103
00104 #ifdef USE_GSSAPI
00105 rc = gsasl_register (ctx, &gsasl_gssapi_mechanism);
00106 if (rc != GSASL_OK)
00107 return rc;
00108 #endif
00109
00110 #ifdef USE_GS2
00111 rc = gsasl_register (ctx, &gsasl_gs2_krb5_mechanism);
00112 if (rc != GSASL_OK)
00113 return rc;
00114 #endif
00115
00116 return GSASL_OK;
00117 }
00118
00131 int
00132 gsasl_init (Gsasl ** ctx)
00133 {
00134 int rc;
00135
00136 if (gc_init () != GC_OK)
00137 return GSASL_CRYPTO_ERROR;
00138
00139 *ctx = (Gsasl *) calloc (1, sizeof (**ctx));
00140 if (*ctx == NULL)
00141 return GSASL_MALLOC_ERROR;
00142
00143 rc = register_builtin_mechs (*ctx);
00144 if (rc != GSASL_OK)
00145 {
00146 gsasl_done (*ctx);
00147 return rc;
00148 }
00149
00150 return GSASL_OK;
00151 }