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 "anonymous/anonymous.h"
00033 #include "plain/plain.h"
00034 #include "securid/securid.h"
00035 #include "digest-md5/digest-md5.h"
00036
00037 #include "login/login.h"
00038 #include "ntlm/x-ntlm.h"
00039 #include "kerberos_v5/kerberos_v5.h"
00040
00047 const char *GSASL_VALID_MECHANISM_CHARACTERS =
00048 "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
00049
00050 static int
00051 register_builtin_mechs (Gsasl * ctx)
00052 {
00053 int rc = GSASL_OK;
00054
00055 #ifdef USE_ANONYMOUS
00056 rc = gsasl_register (ctx, &gsasl_anonymous_mechanism);
00057 if (rc != GSASL_OK)
00058 return rc;
00059 #endif
00060
00061 #ifdef USE_EXTERNAL
00062 rc = gsasl_register (ctx, &gsasl_external_mechanism);
00063 if (rc != GSASL_OK)
00064 return rc;
00065 #endif
00066
00067 #ifdef USE_LOGIN
00068 rc = gsasl_register (ctx, &gsasl_login_mechanism);
00069 if (rc != GSASL_OK)
00070 return rc;
00071 #endif
00072
00073 #ifdef USE_PLAIN
00074 rc = gsasl_register (ctx, &gsasl_plain_mechanism);
00075 if (rc != GSASL_OK)
00076 return rc;
00077 #endif
00078
00079 #ifdef USE_SECURID
00080 rc = gsasl_register (ctx, &gsasl_securid_mechanism);
00081 if (rc != GSASL_OK)
00082 return rc;
00083 #endif
00084
00085 #ifdef USE_NTLM
00086 rc = gsasl_register (ctx, &gsasl_ntlm_mechanism);
00087 if (rc != GSASL_OK)
00088 return rc;
00089 #endif
00090
00091 #ifdef USE_DIGEST_MD5
00092 rc = gsasl_register (ctx, &gsasl_digest_md5_mechanism);
00093 if (rc != GSASL_OK)
00094 return rc;
00095 #endif
00096
00097 #ifdef USE_CRAM_MD5
00098 rc = gsasl_register (ctx, &gsasl_cram_md5_mechanism);
00099 if (rc != GSASL_OK)
00100 return rc;
00101 #endif
00102
00103 #ifdef USE_GSSAPI
00104 rc = gsasl_register (ctx, &gsasl_gssapi_mechanism);
00105 if (rc != GSASL_OK)
00106 return rc;
00107 #endif
00108
00109 return GSASL_OK;
00110 }
00111
00123 int
00124 gsasl_init (Gsasl ** ctx)
00125 {
00126 int rc;
00127
00128 if (gc_init () != GC_OK)
00129 return GSASL_CRYPTO_ERROR;
00130
00131 *ctx = (Gsasl *) calloc (1, sizeof (**ctx));
00132 if (*ctx == NULL)
00133 return GSASL_MALLOC_ERROR;
00134
00135 rc = register_builtin_mechs (*ctx);
00136 if (rc != GSASL_OK)
00137 {
00138 gsasl_done (*ctx);
00139 return rc;
00140 }
00141
00142 return GSASL_OK;
00143 }