gsasl.h

Go to the documentation of this file.
00001 /* gsasl.h --- Header file for GNU SASL Library.
00002  * Copyright (C) 2002, 2003, 2004, 2005, 2006  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 #ifndef GSASL_H
00024 # define GSASL_H
00025 
00026 # include <stdio.h>             /* FILE */
00027 # include <stddef.h>            /* size_t */
00028 # include <unistd.h>            /* ssize_t */
00029 
00030 # ifdef __cplusplus
00031 extern "C"
00032 {
00033 # endif
00034 
00042 # define GSASL_VERSION "0.2.15"
00043 
00044   /* RFC 2222: SASL mechanisms are named by strings, from 1 to 20
00045    * characters in length, consisting of upper-case letters, digits,
00046    * hyphens, and/or underscores.  SASL mechanism names must be
00047    * registered with the IANA.
00048    */
00049   enum
00050   {
00051     GSASL_MIN_MECHANISM_SIZE = 1,
00052     GSASL_MAX_MECHANISM_SIZE = 20
00053   };
00054   extern const char *GSASL_VALID_MECHANISM_CHARACTERS;
00055 
00056   /* Error codes */
00057   typedef enum
00058   {
00059     GSASL_OK = 0,
00060     GSASL_NEEDS_MORE = 1,
00061     GSASL_UNKNOWN_MECHANISM = 2,
00062     GSASL_MECHANISM_CALLED_TOO_MANY_TIMES = 3,
00063     GSASL_MALLOC_ERROR = 7,
00064     GSASL_BASE64_ERROR = 8,
00065     GSASL_CRYPTO_ERROR = 9,
00066     GSASL_SASLPREP_ERROR = 29,
00067     GSASL_MECHANISM_PARSE_ERROR = 30,
00068     GSASL_AUTHENTICATION_ERROR = 31,
00069     GSASL_INTEGRITY_ERROR = 33,
00070     GSASL_NO_CLIENT_CODE = 35,
00071     GSASL_NO_SERVER_CODE = 36,
00072     GSASL_NO_CALLBACK = 51,
00073     GSASL_NO_ANONYMOUS_TOKEN = 52,
00074     GSASL_NO_AUTHID = 53,
00075     GSASL_NO_AUTHZID = 54,
00076     GSASL_NO_PASSWORD = 55,
00077     GSASL_NO_PASSCODE = 56,
00078     GSASL_NO_PIN = 57,
00079     GSASL_NO_SERVICE = 58,
00080     GSASL_NO_HOSTNAME = 59,
00081     /* Mechanism specific errors. */
00082     GSASL_GSSAPI_RELEASE_BUFFER_ERROR = 37,
00083     GSASL_GSSAPI_IMPORT_NAME_ERROR = 38,
00084     GSASL_GSSAPI_INIT_SEC_CONTEXT_ERROR = 39,
00085     GSASL_GSSAPI_ACCEPT_SEC_CONTEXT_ERROR = 40,
00086     GSASL_GSSAPI_UNWRAP_ERROR = 41,
00087     GSASL_GSSAPI_WRAP_ERROR = 42,
00088     GSASL_GSSAPI_ACQUIRE_CRED_ERROR = 43,
00089     GSASL_GSSAPI_DISPLAY_NAME_ERROR = 44,
00090     GSASL_GSSAPI_UNSUPPORTED_PROTECTION_ERROR = 45,
00091     GSASL_KERBEROS_V5_INIT_ERROR = 46,
00092     GSASL_KERBEROS_V5_INTERNAL_ERROR = 47,
00093     GSASL_SHISHI_ERROR = GSASL_KERBEROS_V5_INTERNAL_ERROR,
00094     GSASL_SECURID_SERVER_NEED_ADDITIONAL_PASSCODE = 48,
00095     GSASL_SECURID_SERVER_NEED_NEW_PIN = 49
00096   } Gsasl_rc;
00097 
00098   /* Quality of Protection types, used by DIGEST-MD5 */
00099   typedef enum
00100   {
00101     GSASL_QOP_AUTH = 1,
00102     GSASL_QOP_AUTH_INT = 2,
00103     GSASL_QOP_AUTH_CONF = 4
00104   } Gsasl_qop;
00105 
00106   /* Cipher types, used by DIGEST-MD5 */
00107   typedef enum
00108   {
00109     GSASL_CIPHER_DES = 1,
00110     GSASL_CIPHER_3DES = 2,
00111     GSASL_CIPHER_RC4 = 4,
00112     GSASL_CIPHER_RC4_40 = 8,
00113     GSASL_CIPHER_RC4_56 = 16,
00114     GSASL_CIPHER_AES = 32
00115   } Gsasl_cipher;
00116 
00117   /* SASLprep flags, see gsasl_saslprep(). */
00118   typedef enum
00119   {
00120     GSASL_ALLOW_UNASSIGNED = 1
00121   } Gsasl_saslprep_flags;
00122 
00123   /* Library handles */
00124   typedef struct Gsasl Gsasl;
00125   typedef struct Gsasl_session Gsasl_session;
00126 
00127   /* Callback/property types. */
00128   typedef enum
00129   {
00130     /* Information properties, e.g., username. */
00131     GSASL_AUTHID = 1,
00132     GSASL_AUTHZID = 2,
00133     GSASL_PASSWORD = 3,
00134     GSASL_ANONYMOUS_TOKEN = 4,
00135     GSASL_SERVICE = 5,
00136     GSASL_HOSTNAME = 6,
00137     GSASL_GSSAPI_DISPLAY_NAME = 7,
00138     GSASL_PASSCODE = 8,
00139     GSASL_SUGGESTED_PIN = 9,
00140     GSASL_PIN = 10,
00141     GSASL_REALM = 11,
00142     /* Server validation callback properties. */
00143     GSASL_VALIDATE_SIMPLE = 500,
00144     GSASL_VALIDATE_EXTERNAL = 501,
00145     GSASL_VALIDATE_ANONYMOUS = 502,
00146     GSASL_VALIDATE_GSSAPI = 503,
00147     GSASL_VALIDATE_SECURID = 504
00148   } Gsasl_property;
00149 
00174   typedef int (*Gsasl_callback_function) (Gsasl * ctx, Gsasl_session * sctx,
00175                                           Gsasl_property prop);
00176 
00177   /* Library entry and exit points: version.c, init.c, done.c */
00178   extern int gsasl_init (Gsasl ** ctx);
00179   extern void gsasl_done (Gsasl * ctx);
00180   extern const char *gsasl_check_version (const char *req_version);
00181 
00182   /* Callback handling: callback.c */
00183   extern void gsasl_callback_set (Gsasl * ctx, Gsasl_callback_function cb);
00184   extern int gsasl_callback (Gsasl * ctx, Gsasl_session * sctx,
00185                              Gsasl_property prop);
00186 
00187   extern void gsasl_callback_hook_set (Gsasl * ctx, void *hook);
00188   extern void *gsasl_callback_hook_get (Gsasl * ctx);
00189 
00190   extern void gsasl_session_hook_set (Gsasl_session * sctx, void *hook);
00191   extern void *gsasl_session_hook_get (Gsasl_session * sctx);
00192 
00193   /* Property handling: property.c */
00194   extern void gsasl_property_set (Gsasl_session * sctx, Gsasl_property prop,
00195                                   const char *data);
00196   extern void gsasl_property_set_raw (Gsasl_session * sctx,
00197                                       Gsasl_property prop, const char *data,
00198                                       size_t len);
00199   extern const char *gsasl_property_get (Gsasl_session * sctx,
00200                                          Gsasl_property prop);
00201   extern const char *gsasl_property_fast (Gsasl_session * sctx,
00202                                           Gsasl_property prop);
00203 
00204   /* Mechanism handling: listmech.c, supportp.c, suggest.c */
00205   extern int gsasl_client_mechlist (Gsasl * ctx, char **out);
00206   extern int gsasl_client_support_p (Gsasl * ctx, const char *name);
00207   extern const char *gsasl_client_suggest_mechanism (Gsasl * ctx,
00208                                                      const char *mechlist);
00209 
00210   extern int gsasl_server_mechlist (Gsasl * ctx, char **out);
00211   extern int gsasl_server_support_p (Gsasl * ctx, const char *name);
00212 
00213   /* Authentication functions: xstart.c, xstep.c, xfinish.c */
00214   extern int gsasl_client_start (Gsasl * ctx, const char *mech,
00215                                  Gsasl_session ** sctx);
00216   extern int gsasl_server_start (Gsasl * ctx, const char *mech,
00217                                  Gsasl_session ** sctx);
00218   extern int gsasl_step (Gsasl_session * sctx,
00219                          const char *input, size_t input_len,
00220                          char **output, size_t * output_len);
00221   extern int gsasl_step64 (Gsasl_session * sctx,
00222                            const char *b64input, char **b64output);
00223   extern void gsasl_finish (Gsasl_session * sctx);
00224 
00225   /* Session functions: xcode.c */
00226   extern int gsasl_encode (Gsasl_session * sctx,
00227                            const char *input, size_t input_len,
00228                            char **output, size_t * output_len);
00229   extern int gsasl_decode (Gsasl_session * sctx,
00230                            const char *input, size_t input_len,
00231                            char **output, size_t * output_len);
00232 
00233   /* Error handling: error.c */
00234   extern const char *gsasl_strerror (int err);
00235 
00236   /* Internationalized string processing: stringprep.c */
00237   extern int gsasl_saslprep (const char *in, Gsasl_saslprep_flags flags,
00238                              char **out, int *stringpreprc);
00239 
00240   /* Utilities: base64.c, md5pwd.c, crypto.c */
00241   extern int gsasl_simple_getpass (const char *filename,
00242                                    const char *username,
00243                                    char **key);
00244   extern int gsasl_base64_to (const char *in, size_t inlen,
00245                               char **out, size_t * outlen);
00246   extern int gsasl_base64_from (const char *in, size_t inlen,
00247                                 char **out, size_t * outlen);
00248   extern int gsasl_nonce (char *data, size_t datalen);
00249   extern int gsasl_random (char *data, size_t datalen);
00250   extern int gsasl_md5 (const char *in, size_t inlen, char *out[16]);
00251   extern int gsasl_hmac_md5 (const char *key, size_t keylen,
00252                              const char *in, size_t inlen, char *outhash[16]);
00253 
00254   /* Get the mechanism API. */
00255 # include <gsasl-mech.h>
00256 
00257 #ifndef GSASL_NO_OBSOLETE
00258   /* For compatibility with earlier versions. */
00259 # include <gsasl-compat.h>
00260 #endif
00261 
00262 # ifdef __cplusplus
00263 }
00264 # endif
00265 
00266 #endif                          /* GSASL_H */

Generated on Tue Aug 22 12:06:06 2006 for gsasl by  doxygen 1.4.7