init.c

Go to the documentation of this file.
00001 /* init.c --- Entry point for libgsasl.
00002  * Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008  Simon Josefsson
00003  *
00004  * This file is part of GNU SASL Library.
00005  *
00006  * GNU SASL Library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public License
00008  * as published by the Free Software Foundation; either version 2.1 of
00009  * the License, or (at your option) any later version.
00010  *
00011  * GNU SASL Library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License License along with GNU SASL Library; if not, write to the
00018  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "internal.h"
00024 
00025 /* Get gc_init. */
00026 #include <gc.h>
00027 
00028 /* Get mechanism headers. */
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 /* USE_ANONYMOUS */
00061 
00062 #ifdef USE_EXTERNAL
00063   rc = gsasl_register (ctx, &gsasl_external_mechanism);
00064   if (rc != GSASL_OK)
00065     return rc;
00066 #endif /* USE_EXTERNAL */
00067 
00068 #ifdef USE_LOGIN
00069   rc = gsasl_register (ctx, &gsasl_login_mechanism);
00070   if (rc != GSASL_OK)
00071     return rc;
00072 #endif /* USE_LOGIN */
00073 
00074 #ifdef USE_PLAIN
00075   rc = gsasl_register (ctx, &gsasl_plain_mechanism);
00076   if (rc != GSASL_OK)
00077     return rc;
00078 #endif /* USE_PLAIN */
00079 
00080 #ifdef USE_SECURID
00081   rc = gsasl_register (ctx, &gsasl_securid_mechanism);
00082   if (rc != GSASL_OK)
00083     return rc;
00084 #endif /* USE_SECURID */
00085 
00086 #ifdef USE_NTLM
00087   rc = gsasl_register (ctx, &gsasl_ntlm_mechanism);
00088   if (rc != GSASL_OK)
00089     return rc;
00090 #endif /* USE_NTLM */
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 /* USE_DIGEST_MD5 */
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 /* USE_CRAM_MD5 */
00103 
00104 #ifdef USE_GSSAPI
00105   rc = gsasl_register (ctx, &gsasl_gssapi_mechanism);
00106   if (rc != GSASL_OK)
00107     return rc;
00108 #endif /* USE_GSSAPI */
00109 
00110 #ifdef USE_GS2
00111   rc = gsasl_register (ctx, &gsasl_gs2_krb5_mechanism);
00112   if (rc != GSASL_OK)
00113     return rc;
00114 #endif /* USE_GSSAPI */
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 }

Generated on Tue Oct 21 18:28:19 2008 for gsasl by  doxygen 1.5.6