#include <stdio.h>#include <stddef.h>#include <unistd.h>#include <gsasl-mech.h>#include <gsasl-compat.h>Go to the source code of this file.
| #define GSASL_VERSION "0.2.29" |
GSASL_VERSION
String defined via CPP denoting the header file version number. Used together with stringprep_check_version() to verify header file and run-time library consistency.
Definition at line 56 of file gsasl.h.
Referenced by gsasl_check_version().
| typedef int(* Gsasl_callback_function)(Gsasl *ctx, Gsasl_session *sctx, Gsasl_property prop) |
Gsasl_callback_function:
| ctx | libgsasl handle. | |
| sctx | session handle, may be NULL. | |
| prop | enumerated value of Gsasl_property type. |
It is called by the SASL library when it need some information from the application. Depending on the value of , it should either set some property (e.g., username or password) using gsasl_property_set(), or it should extract some properties (e.g., authentication and authorization identities) using gsasl_property_fast() and use them to make a policy decision, perhaps returning GSASL_AUTHENTICATION_ERROR or GSASL_OK depending on whether the policy permitted the operation.
Return value: Any valid return code, the interpretation of which depend on the value.
Since: 0.2.0
| typedef struct Gsasl_session Gsasl_session |
| anonymous enum |
| enum Gsasl_cipher |
| enum Gsasl_property |
| enum Gsasl_qop |
| enum Gsasl_rc |
| enum Gsasl_saslprep_flags |
| GSASL_API int gsasl_base64_from | ( | const char * | in, | |
| size_t | inlen, | |||
| char ** | out, | |||
| size_t * | outlen | |||
| ) |
gsasl_base64_from:
| in | input byte array | |
| inlen | size of input byte array | |
| out | pointer to newly allocated output byte array | |
| outlen | pointer to size of newly allocated output byte array |
Return value: Returns GSASL_OK on success, GSASL_BASE64_ERROR if input was invalid, and GSASL_MALLOC_ERROR on memory allocation errors.
Since: 0.2.2
Definition at line 74 of file base64.c.
References GSASL_BASE64_ERROR, GSASL_MALLOC_ERROR, and GSASL_OK.
Referenced by gsasl_base64_decode(), and gsasl_step64().
| GSASL_API int gsasl_base64_to | ( | const char * | in, | |
| size_t | inlen, | |||
| char ** | out, | |||
| size_t * | outlen | |||
| ) |
gsasl_base64_to:
| in | input byte array | |
| inlen | size of input byte array | |
| out | pointer to newly allocated output byte array | |
| outlen | pointer to size of newly allocated output byte array |
Return value: Returns GSASL_OK on success, or GSASL_MALLOC_ERROR if input was too large or memory allocation fail.
Since: 0.2.2
Definition at line 44 of file base64.c.
References GSASL_MALLOC_ERROR, and GSASL_OK.
Referenced by _gsasl_digest_md5_client_start(), _gsasl_digest_md5_server_start(), gsasl_base64_encode(), and gsasl_step64().
| GSASL_API int gsasl_callback | ( | Gsasl * | ctx, | |
| Gsasl_session * | sctx, | |||
| Gsasl_property | prop | |||
| ) |
gsasl_callback:
| ctx | handle received from gsasl_init(), may be NULL to derive it from . | |
| sctx | session handle. | |
| prop | enumerated value of Gsasl_property type. |
Note that if no callback has been set by the application, but the obsolete callback interface has been used, this function will translate the old callback interface into the new. This interface should be sufficient to invoke all callbacks, both new and old.
Return value: Returns whatever the application callback return, or GSASL_NO_CALLBACK if no application was known.
Since: 0.2.0
Definition at line 81 of file callback.c.
References _gsasl_obsolete_callback(), Gsasl::cb, Gsasl_session::ctx, and GSASL_NO_CALLBACK.
Referenced by _gsasl_anonymous_server_step(), _gsasl_digest_md5_client_step(), _gsasl_external_server_step(), _gsasl_gs2_server_step(), _gsasl_gssapi_server_step(), _gsasl_login_server_step(), _gsasl_plain_server_step(), _gsasl_securid_server_step(), and gsasl_property_get().
| GSASL_API void* gsasl_callback_hook_get | ( | Gsasl * | ctx | ) |
gsasl_callback_hook_get:
| ctx | libgsasl handle. |
The application data is set using gsasl_callback_hook_set(). This is normally used by the application to maintain a global state between the main program and callbacks.
Return value: Returns the application specific data, or NULL.
Since: 0.2.0
Definition at line 134 of file callback.c.
References Gsasl::application_hook.
| GSASL_API void gsasl_callback_hook_set | ( | Gsasl * | ctx, | |
| void * | hook | |||
| ) |
gsasl_callback_hook_set:
| ctx | libgsasl handle. | |
| hook | opaque pointer to application specific data. |
The application data can be later (for instance, inside a callback) be retrieved by calling gsasl_callback_hook_get(). This is normally used by the application to maintain a global state between the main program and callbacks.
Since: 0.2.0
Definition at line 114 of file callback.c.
References Gsasl::application_hook.
| GSASL_API void gsasl_callback_set | ( | Gsasl * | ctx, | |
| Gsasl_callback_function | cb | |||
| ) |
gsasl_callback_set:
| ctx | handle received from gsasl_init(). | |
| cb | pointer to function implemented by application. |
Since: 0.2.0
Definition at line 44 of file callback.c.
References Gsasl::cb.
| GSASL_API const char* gsasl_check_version | ( | const char * | req_version | ) |
gsasl_check_version:
| req_version | version string to compare with, or NULL. |
See GSASL_VERSION for a suitable string.
Return value: Check that the the version of the library is at minimum the one given as a string in and return the actual version string of the library; return NULL if the condition is not met. If NULL is passed to this function no check is done and only the version string is returned.
Definition at line 42 of file version.c.
References GSASL_VERSION.
| GSASL_API int gsasl_client_mechlist | ( | Gsasl * | ctx, | |
| char ** | out | |||
| ) |
gsasl_client_mechlist:
| ctx | libgsasl handle. | |
| out | newly allocated output character array. |
Return value: Returns GSASL_OK if successful, or error code.
Definition at line 74 of file listmech.c.
References Gsasl::client_mechs, and Gsasl::n_client_mechs.
Referenced by gsasl_client_listmech().
| GSASL_API int gsasl_client_start | ( | Gsasl * | ctx, | |
| const char * | mech, | |||
| Gsasl_session ** | sctx | |||
| ) |
gsasl_client_start:
| ctx | libgsasl handle. | |
| mech | name of SASL mechanism. | |
| sctx | pointer to client handle. |
Return value: Returns GSASL_OK if successful, or error code.
Definition at line 119 of file xstart.c.
References Gsasl::client_mechs, and Gsasl::n_client_mechs.
Referenced by gsasl_client_suggest_mechanism().
| GSASL_API const char* gsasl_client_suggest_mechanism | ( | Gsasl * | ctx, | |
| const char * | mechlist | |||
| ) |
gsasl_client_suggest_mechanism:
| ctx | libgsasl handle. | |
| mechlist | input character array with SASL mechanism names, separated by invalid characters (e.g. SPC). |
Return value: Returns name of "best" SASL mechanism supported by the libgsasl client which is present in the input string.
Definition at line 37 of file suggest.c.
References Gsasl::client_mechs, gsasl_client_start(), gsasl_finish(), GSASL_OK, GSASL_VALID_MECHANISM_CHARACTERS, i, j, Gsasl::n_client_mechs, and Gsasl_mechanism::name.
| GSASL_API int gsasl_client_support_p | ( | Gsasl * | ctx, | |
| const char * | name | |||
| ) |
gsasl_client_support_p:
| ctx | libgsasl handle. | |
| name | name of SASL mechanism. |
Return value: Returns 1 if the libgsasl client supports the named mechanism, otherwise 0.
Definition at line 49 of file supportp.c.
References Gsasl::client_mechs, and Gsasl::n_client_mechs.
| GSASL_API int gsasl_decode | ( | Gsasl_session * | sctx, | |
| const char * | input, | |||
| size_t | input_len, | |||
| char ** | output, | |||
| size_t * | output_len | |||
| ) |
gsasl_decode:
| sctx | libgsasl session handle. | |
| input | input byte array. | |
| input_len | size of input byte array. | |
| output | newly allocated output byte array. | |
| output_len | size of output byte array. |
The buffer is allocated by this function, and it is the responsibility of caller to deallocate it by calling free().
Return value: Returns GSASL_OK if encoding was successful, otherwise an error code.
Definition at line 96 of file xcode.c.
References Gsasl_mechanism::client, Gsasl_session::clientp, Gsasl_mechanism_functions::decode, Gsasl_session::mech, and Gsasl_mechanism::server.
Referenced by gsasl_decode_inline().
| GSASL_API void gsasl_done | ( | Gsasl * | ctx | ) |
gsasl_done:
| ctx | libgsasl handle. |
Definition at line 33 of file done.c.
References Gsasl_mechanism::client, Gsasl::client_mechs, Gsasl_mechanism_functions::done, i, Gsasl::n_client_mechs, Gsasl::n_server_mechs, Gsasl_mechanism::server, and Gsasl::server_mechs.
Referenced by gsasl_init().
| GSASL_API int gsasl_encode | ( | Gsasl_session * | sctx, | |
| const char * | input, | |||
| size_t | input_len, | |||
| char ** | output, | |||
| size_t * | output_len | |||
| ) |
gsasl_encode:
| sctx | libgsasl session handle. | |
| input | input byte array. | |
| input_len | size of input byte array. | |
| output | newly allocated output byte array. | |
| output_len | size of output byte array. |
The buffer is allocated by this function, and it is the responsibility of caller to deallocate it by calling free().
Return value: Returns GSASL_OK if encoding was successful, otherwise an error code.
Definition at line 64 of file xcode.c.
References Gsasl_mechanism::client, Gsasl_session::clientp, Gsasl_mechanism_functions::encode, Gsasl_session::mech, and Gsasl_mechanism::server.
Referenced by gsasl_encode_inline().
| GSASL_API void gsasl_finish | ( | Gsasl_session * | sctx | ) |
gsasl_finish:
| sctx | libgsasl session handle. |
Definition at line 35 of file xfinish.c.
References Gsasl_session::anonymous_token, Gsasl_session::authid, Gsasl_session::authzid, Gsasl_mechanism::client, Gsasl_session::clientp, Gsasl_session::digest_md5_hashed_password, Gsasl_mechanism_functions::finish, free_if_nonnull, Gsasl_session::gssapi_display_name, Gsasl_session::hostname, Gsasl_session::mech, Gsasl_session::mech_data, Gsasl_session::passcode, Gsasl_session::password, Gsasl_session::pin, Gsasl_session::realm, Gsasl_mechanism::server, Gsasl_session::service, and Gsasl_session::suggestedpin.
Referenced by gsasl_client_finish(), gsasl_client_suggest_mechanism(), and gsasl_server_finish().
| GSASL_API void gsasl_free | ( | void * | ptr | ) |
gsasl_free:
| ptr | memory pointer |
This is useful on Windows where libgsasl is linked to one CRT and the application is linked to another CRT. Then malloc/free will not use the same heap. This happens if you build libgsasl using mingw32 and the application with Visual Studio.
Since: 0.2.19
Definition at line 41 of file src/free.c.
| GSASL_API int gsasl_hmac_md5 | ( | const char * | key, | |
| size_t | keylen, | |||
| const char * | in, | |||
| size_t | inlen, | |||
| char * | outhash[16] | |||
| ) |
gsasl_hmac_md5:
| key | input character array with key to use. | |
| keylen | length of input character array with key to use. | |
| in | input character array of data to hash. | |
| inlen | length of input character array of data to hash. | |
| outhash | newly allocated character array with keyed hash of data. |
Return value: Returns GSASL_OK iff successful.
Definition at line 92 of file crypto.c.
References GSASL_MALLOC_ERROR.
| GSASL_API int gsasl_init | ( | Gsasl ** | ctx | ) |
gsasl_init:
| ctx | pointer to libgsasl handle. |
Return value: GSASL_OK iff successful, otherwise GSASL_MALLOC_ERROR.
Definition at line 132 of file init.c.
References GSASL_CRYPTO_ERROR, gsasl_done(), GSASL_MALLOC_ERROR, GSASL_OK, and rc.
| GSASL_API int gsasl_md5 | ( | const char * | in, | |
| size_t | inlen, | |||
| char * | out[16] | |||
| ) |
gsasl_md5:
| in | input character array of data to hash. | |
| inlen | length of input character array of data to hash. | |
| out | newly allocated character array with hash of data. |
Return value: Returns GSASL_OK iff successful.
Definition at line 70 of file crypto.c.
References GSASL_MALLOC_ERROR.
Referenced by _gsasl_digest_md5_client_step(), and _gsasl_digest_md5_server_step().
| GSASL_API const char* gsasl_mechanism_name | ( | Gsasl_session * | sctx | ) |
gsasl_mechanism_name:
| sctx | libgsasl session handle. |
Return value: Returns a zero terminated character array with the name of the SASL mechanism, or NULL if not known.
Since: 0.2.28
Definition at line 38 of file mechname.c.
References Gsasl_session::mech, and Gsasl_mechanism::name.
| GSASL_API int gsasl_nonce | ( | char * | data, | |
| size_t | datalen | |||
| ) |
gsasl_nonce:
| data | output array to be filled with unpredictable random data. | |
| datalen | size of output array. |
Return value: Returns GSASL_OK iff successful.
Definition at line 37 of file crypto.c.
Referenced by _gsasl_digest_md5_client_start(), _gsasl_digest_md5_server_start(), and gsasl_randomize().
| GSASL_API const char* gsasl_property_fast | ( | Gsasl_session * | sctx, | |
| Gsasl_property | prop | |||
| ) |
gsasl_property_fast:
| sctx | session handle. | |
| prop | enumerated value of Gsasl_property type, indicating the type of data in . |
The pointer is to live data, and must not be deallocated or modified in any way.
This function will not invoke the application callback.
Return value: Return property value, if known, or NULL if no value known.
Since: 0.2.0
Definition at line 174 of file property.c.
Referenced by _gsasl_digest_md5_client_step(), _gsasl_obsolete_property_map(), and gsasl_property_get().
| GSASL_API const char* gsasl_property_get | ( | Gsasl_session * | sctx, | |
| Gsasl_property | prop | |||
| ) |
gsasl_property_get:
| sctx | session handle. | |
| prop | enumerated value of Gsasl_property type, indicating the type of data in . |
The pointer is to live data, and must not be deallocated or modified in any way.
This function will invoke the application callback, using gsasl_callback(), when a property value is not known.
If no value is known, and no callback is specified or if the callback fail to return data, and if any obsolete callback functions has been set by the application, this function will try to call these obsolete callbacks, and store the returned data as the corresponding property. This behaviour of this function will be removed when the obsolete callback interfaces are removed.
Return value: Return data for property, or NULL if no value known.
Since: 0.2.0
Definition at line 217 of file property.c.
References _gsasl_obsolete_property_map(), gsasl_callback(), and gsasl_property_fast().
Referenced by _gsasl_anonymous_client_step(), _gsasl_cram_md5_client_step(), _gsasl_cram_md5_server_step(), _gsasl_digest_md5_client_step(), _gsasl_digest_md5_server_step(), _gsasl_external_client_step(), _gsasl_gs2_client_step(), _gsasl_gs2_server_start(), _gsasl_gssapi_client_step(), _gsasl_gssapi_server_start(), _gsasl_login_client_step(), _gsasl_login_server_step(), _gsasl_ntlm_client_step(), _gsasl_plain_client_step(), _gsasl_plain_server_step(), _gsasl_securid_client_step(), and _gsasl_securid_server_step().
| GSASL_API void gsasl_property_set | ( | Gsasl_session * | sctx, | |
| Gsasl_property | prop, | |||
| const char * | data | |||
| ) |
gsasl_property_set:
| sctx | session handle. | |
| prop | enumerated value of Gsasl_property type, indicating the type of data in . | |
| data | zero terminated character string to store. |
You can immediately deallocate after calling this function, without affecting the data stored in the session handle.
Since: 0.2.0
Definition at line 105 of file property.c.
References gsasl_property_set_raw().
Referenced by _gsasl_cram_md5_server_step(), _gsasl_digest_md5_client_step(), _gsasl_digest_md5_server_step(), _gsasl_external_server_step(), _gsasl_login_server_step(), _gsasl_obsolete_callback(), _gsasl_obsolete_property_map(), _gsasl_plain_server_step(), and _gsasl_securid_server_step().
| GSASL_API void gsasl_property_set_raw | ( | Gsasl_session * | sctx, | |
| Gsasl_property | prop, | |||
| const char * | data, | |||
| size_t | len | |||
| ) |
gsasl_property_set_raw:
| sctx | session handle. | |
| prop | enumerated value of Gsasl_property type, indicating the type of data in . | |
| data | character string to store. | |
| len | length of character string to store. |
You can immediately deallocate after calling this function, without affecting the data stored in the session handle.
Except for the length indicator, this function is identical to gsasl_property_set.
Since: 0.2.0
Definition at line 131 of file property.c.
Referenced by _gsasl_anonymous_server_step(), _gsasl_external_server_step(), _gsasl_gs2_server_step(), _gsasl_gssapi_server_step(), _gsasl_obsolete_callback(), _gsasl_securid_client_step(), and gsasl_property_set().
| GSASL_API int gsasl_random | ( | char * | data, | |
| size_t | datalen | |||
| ) |
gsasl_random:
| data | output array to be filled with strong random data. | |
| datalen | size of output array. |
Return value: Returns GSASL_OK iff successful.
Definition at line 53 of file crypto.c.
Referenced by gsasl_randomize().
| GSASL_API int gsasl_saslprep | ( | const char * | in, | |
| Gsasl_saslprep_flags | flags, | |||
| char ** | out, | |||
| int * | stringpreprc | |||
| ) |
gsasl_saslprep - prepare internationalized string
| in | a UTF-8 encoded string. | |
| flags | any SASLprep flag, e.g., GSASL_ALLOW_UNASSIGNED. | |
| out | on exit, contains newly allocated output string. | |
| stringpreprc | if non-NULL, will hold precise stringprep return code. |
Return value: Returns GSASL_OK on success, or GSASL_SASLPREP_ERROR on error.
Since: 0.2.3
Definition at line 48 of file saslprep.c.
References GSASL_ALLOW_UNASSIGNED, GSASL_MALLOC_ERROR, GSASL_OK, GSASL_SASLPREP_ERROR, i, and rc.
Referenced by _gsasl_cram_md5_client_step(), _gsasl_cram_md5_server_step(), and _gsasl_plain_server_step().
| GSASL_API int gsasl_server_mechlist | ( | Gsasl * | ctx, | |
| char ** | out | |||
| ) |
gsasl_server_mechlist:
| ctx | libgsasl handle. | |
| out | newly allocated output character array. |
Return value: Returns GSASL_OK if successful, or error code.
Definition at line 93 of file listmech.c.
References Gsasl::n_server_mechs, and Gsasl::server_mechs.
Referenced by gsasl_server_listmech().
| GSASL_API int gsasl_server_start | ( | Gsasl * | ctx, | |
| const char * | mech, | |||
| Gsasl_session ** | sctx | |||
| ) |
gsasl_server_start:
| ctx | libgsasl handle. | |
| mech | name of SASL mechanism. | |
| sctx | pointer to server handle. |
Return value: Returns GSASL_OK if successful, or error code.
Definition at line 137 of file xstart.c.
References Gsasl::n_server_mechs, and Gsasl::server_mechs.
| GSASL_API int gsasl_server_support_p | ( | Gsasl * | ctx, | |
| const char * | name | |||
| ) |
gsasl_server_support_p:
| ctx | libgsasl handle. | |
| name | name of SASL mechanism. |
Return value: Returns 1 if the libgsasl server supports the named mechanism, otherwise 0.
Definition at line 66 of file supportp.c.
References Gsasl::n_server_mechs, and Gsasl::server_mechs.
| GSASL_API void* gsasl_session_hook_get | ( | Gsasl_session * | sctx | ) |
gsasl_session_hook_get:
| sctx | libgsasl session handle. |
The application data is set using gsasl_callback_hook_set(). This is normally used by the application to maintain a per-session state between the main program and callbacks.
Return value: Returns the application specific data, or NULL.
Since: 0.2.14
Definition at line 174 of file callback.c.
References Gsasl_session::application_hook.
| GSASL_API void gsasl_session_hook_set | ( | Gsasl_session * | sctx, | |
| void * | hook | |||
| ) |
gsasl_session_hook_set:
| sctx | libgsasl session handle. | |
| hook | opaque pointer to application specific data. |
The application data can be later (for instance, inside a callback) be retrieved by calling gsasl_session_hook_get(). This is normally used by the application to maintain a per-session state between the main program and callbacks.
Since: 0.2.14
Definition at line 154 of file callback.c.
References Gsasl_session::application_hook.
| GSASL_API int gsasl_simple_getpass | ( | const char * | filename, |
| const char * |