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 #include "scram/scram.h"
00038 #include "saml20/saml20.h"
00039
00040 #include "login/login.h"
00041 #include "ntlm/x-ntlm.h"
00042 #include "kerberos_v5/kerberos_v5.h"
00043
00050 const char *GSASL_VALID_MECHANISM_CHARACTERS =
00051 "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
00052
00053 static int
00054 register_builtin_mechs (Gsasl * ctx)
00055 {
00056 int rc = GSASL_OK;
00057
00058 #ifdef USE_ANONYMOUS
00059 rc = gsasl_register (ctx, &gsasl_anonymous_mechanism);
00060 if (rc != GSASL_OK)
00061 return rc;
00062 #endif
00063
00064 #ifdef USE_EXTERNAL
00065 rc = gsasl_register (ctx, &gsasl_external_mechanism);
00066 if (rc != GSASL_OK)
00067 return rc;
00068 #endif
00069
00070 #ifdef USE_LOGIN
00071 rc = gsasl_register (ctx, &gsasl_login_mechanism);
00072 if (rc != GSASL_OK)
00073 return rc;
00074 #endif
00075
00076 #ifdef USE_PLAIN
00077 rc = gsasl_register (ctx, &gsasl_plain_mechanism);
00078 if (rc != GSASL_OK)
00079 return rc;
00080 #endif
00081
00082 #ifdef USE_SECURID
00083 rc = gsasl_register (ctx, &gsasl_securid_mechanism);
00084 if (rc != GSASL_OK)
00085 return rc;
00086 #endif
00087
00088 #ifdef USE_NTLM
00089 rc = gsasl_register (ctx, &gsasl_ntlm_mechanism);
00090 if (rc != GSASL_OK)
00091 return rc;
00092 #endif
00093
00094 #ifdef USE_DIGEST_MD5
00095 rc = gsasl_register (ctx, &gsasl_digest_md5_mechanism);
00096 if (rc != GSASL_OK)
00097 return rc;
00098 #endif
00099
00100 #ifdef USE_CRAM_MD5
00101 rc = gsasl_register (ctx, &gsasl_cram_md5_mechanism);
00102 if (rc != GSASL_OK)
00103 return rc;
00104 #endif
00105
00106 #ifdef USE_SCRAM_SHA1
00107 rc = gsasl_register (ctx, &gsasl_scram_sha1_mechanism);
00108 if (rc != GSASL_OK)
00109 return rc;
00110 #endif
00111
00112 #ifdef USE_SAML20
00113 rc = gsasl_register (ctx, &gsasl_saml20_mechanism);
00114 if (rc != GSASL_OK)
00115 return rc;
00116 #endif
00117
00118 #ifdef USE_GSSAPI
00119 rc = gsasl_register (ctx, &gsasl_gssapi_mechanism);
00120 if (rc != GSASL_OK)
00121 return rc;
00122 #endif
00123
00124 #ifdef USE_GS2
00125 rc = gsasl_register (ctx, &gsasl_gs2_krb5_mechanism);
00126 if (rc != GSASL_OK)
00127 return rc;
00128 #endif
00129
00130 return GSASL_OK;
00131 }
00132
00145 int
00146 gsasl_init (Gsasl ** ctx)
00147 {
00148 int rc;
00149
00150 if (gc_init () != GC_OK)
00151 return GSASL_CRYPTO_ERROR;
00152
00153 *ctx = (Gsasl *) calloc (1, sizeof (**ctx));
00154 if (*ctx == NULL)
00155 return GSASL_MALLOC_ERROR;
00156
00157 rc = register_builtin_mechs (*ctx);
00158 if (rc != GSASL_OK)
00159 {
00160 gsasl_done (*ctx);
00161 return rc;
00162 }
00163
00164 return GSASL_OK;
00165 }