GNU SASL API Reference Manual | ||||
---|---|---|---|---|
Top | Description |
#define GSASL_API #define GSASL_VERSION #define GSASL_VERSION_MAJOR #define GSASL_VERSION_MINOR #define GSASL_VERSION_NUMBER #define GSASL_VERSION_PATCH typedef Gsasl; int (*Gsasl_callback_function) (Gsasl *ctx
,Gsasl_session *sctx
,Gsasl_property prop
); enum Gsasl_cipher; enum Gsasl_property; enum Gsasl_qop; enum Gsasl_rc; enum Gsasl_saslprep_flags; typedef Gsasl_session; int gsasl_base64_from (const char *in
,size_t inlen
,char **out
,size_t *outlen
); int gsasl_base64_to (const char *in
,size_t inlen
,char **out
,size_t *outlen
); int gsasl_callback (Gsasl *ctx
,Gsasl_session *sctx
,Gsasl_property prop
); void * gsasl_callback_hook_get (Gsasl *ctx
); void gsasl_callback_hook_set (Gsasl *ctx
,void *hook
); void gsasl_callback_set (Gsasl *ctx
,Gsasl_callback_function cb
); const char * gsasl_check_version (const char *req_version
); int gsasl_client_mechlist (Gsasl *ctx
,char **out
); int gsasl_client_start (Gsasl *ctx
,const char *mech
,Gsasl_session **sctx
); const char * gsasl_client_suggest_mechanism (Gsasl *ctx
,const char *mechlist
); int gsasl_client_support_p (Gsasl *ctx
,const char *name
); int gsasl_decode (Gsasl_session *sctx
,const char *input
,size_t input_len
,char **output
,size_t *output_len
); void gsasl_done (Gsasl *ctx
); int gsasl_encode (Gsasl_session *sctx
,const char *input
,size_t input_len
,char **output
,size_t *output_len
); void gsasl_finish (Gsasl_session *sctx
); void gsasl_free (void *ptr
); int gsasl_hmac_md5 (const char *key
,size_t keylen
,const char *in
,size_t inlen
,char *outhash[16]
); int gsasl_hmac_sha1 (const char *key
,size_t keylen
,const char *in
,size_t inlen
,char *outhash[20]
); int gsasl_init (Gsasl **ctx
); int gsasl_md5 (const char *in
,size_t inlen
,char *out[16]
); const char * gsasl_mechanism_name (Gsasl_session *sctx
); int gsasl_nonce (char *data
,size_t datalen
); const char * gsasl_property_fast (Gsasl_session *sctx
,Gsasl_property prop
); const char * gsasl_property_get (Gsasl_session *sctx
,Gsasl_property prop
); void gsasl_property_set (Gsasl_session *sctx
,Gsasl_property prop
,const char *data
); void gsasl_property_set_raw (Gsasl_session *sctx
,Gsasl_property prop
,const char *data
,size_t len
); int gsasl_random (char *data
,size_t datalen
); int gsasl_saslprep (const char *in
,Gsasl_saslprep_flags flags
,char **out
,int *stringpreprc
); int gsasl_server_mechlist (Gsasl *ctx
,char **out
); int gsasl_server_start (Gsasl *ctx
,const char *mech
,Gsasl_session **sctx
); int gsasl_server_support_p (Gsasl *ctx
,const char *name
); void * gsasl_session_hook_get (Gsasl_session *sctx
); void gsasl_session_hook_set (Gsasl_session *sctx
,void *hook
); int gsasl_sha1 (const char *in
,size_t inlen
,char *out[20]
); int gsasl_simple_getpass (const char *filename
,const char *username
,char **key
); int gsasl_step (Gsasl_session *sctx
,const char *input
,size_t input_len
,char **output
,size_t *output_len
); int gsasl_step64 (Gsasl_session *sctx
,const char *b64input
,char **b64output
); const char * gsasl_strerror (int err
); const char * gsasl_strerror_name (int err
);
#define GSASL_VERSION "1.8.0"
Pre-processor symbol with a string that describe the header file
version number. Used together with gsasl_check_version()
to
verify header file and run-time library consistency.
#define GSASL_VERSION_MAJOR 1
Pre-processor symbol with a decimal value that describe the major level of the header file version number. For example, when the header version is 1.2.3 this symbol will be 1.
Since 1.1
#define GSASL_VERSION_MINOR 8
Pre-processor symbol with a decimal value that describe the minor level of the header file version number. For example, when the header version is 1.2.3 this symbol will be 2.
Since 1.1
#define GSASL_VERSION_NUMBER 0x010800
Pre-processor symbol with a hexadecimal value describing the header file version number. For example, when the header version is 1.2.3 this symbol will have the value 0x010203.
Since 1.1
#define GSASL_VERSION_PATCH 0
Pre-processor symbol with a decimal value that describe the patch level of the header file version number. For example, when the header version is 1.2.3 this symbol will be 3.
Since 1.1
int (*Gsasl_callback_function) (Gsasl *ctx
,Gsasl_session *sctx
,Gsasl_property prop
);
Prototype of function that the application should implement. Use
gsasl_callback_set()
to inform the library about your callback
function.
It is called by the SASL library when it need some information
from the application. Depending on the value of prop
, 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.
|
libgsasl handle. |
|
session handle, may be NULL. |
|
enumerated value of Gsasl_property type. |
Returns : |
Any valid return code, the interpretation of which
depend on the prop value. |
Since 0.2.0
typedef enum { GSASL_CIPHER_DES = 1, GSASL_CIPHER_3DES = 2, GSASL_CIPHER_RC4 = 4, GSASL_CIPHER_RC4_40 = 8, GSASL_CIPHER_RC4_56 = 16, GSASL_CIPHER_AES = 32 } Gsasl_cipher;
Encryption types (DIGEST-MD5) for confidentiality services of application data. We recommend that you use TLS instead as it is generally more secure and have better chance of working.
typedef enum { /* Information properties, e.g., username. */ GSASL_AUTHID = 1, GSASL_AUTHZID = 2, GSASL_PASSWORD = 3, GSASL_ANONYMOUS_TOKEN = 4, GSASL_SERVICE = 5, GSASL_HOSTNAME = 6, GSASL_GSSAPI_DISPLAY_NAME = 7, GSASL_PASSCODE = 8, GSASL_SUGGESTED_PIN = 9, GSASL_PIN = 10, GSASL_REALM = 11, GSASL_DIGEST_MD5_HASHED_PASSWORD = 12, GSASL_QOPS = 13, GSASL_QOP = 14, GSASL_SCRAM_ITER = 15, GSASL_SCRAM_SALT = 16, GSASL_SCRAM_SALTED_PASSWORD = 17, GSASL_CB_TLS_UNIQUE = 18, GSASL_SAML20_IDP_IDENTIFIER = 19, GSASL_SAML20_REDIRECT_URL = 20, GSASL_OPENID20_REDIRECT_URL = 21, GSASL_OPENID20_OUTCOME_DATA = 22, /* Client callbacks. */ GSASL_SAML20_AUTHENTICATE_IN_BROWSER = 250, GSASL_OPENID20_AUTHENTICATE_IN_BROWSER = 251, /* Server validation callback properties. */ GSASL_VALIDATE_SIMPLE = 500, GSASL_VALIDATE_EXTERNAL = 501, GSASL_VALIDATE_ANONYMOUS = 502, GSASL_VALIDATE_GSSAPI = 503, GSASL_VALIDATE_SECURID = 504, GSASL_VALIDATE_SAML20 = 505, GSASL_VALIDATE_OPENID20 = 506 } Gsasl_property;
Callback/property types.
Authentication identity (username). | |
Authorization identity. | |
Password. | |
Anonymous identifier. | |
Service name | |
Host name. | |
GSS-API credential principal name. | |
SecurID passcode. | |
SecurID suggested PIN. | |
SecurID PIN. | |
User realm. | |
Pre-computed hashed DIGEST-MD5 password, to avoid storing passwords in the clear. | |
Set of quality-of-protection values. | |
Quality-of-protection value. | |
Number of iterations in password-to-key hashing. | |
Salt for password-to-key hashing. | |
Pre-computed salted SCRAM key, to avoid re-computation and storing passwords in the clear. | |
Base64 encoded tls-unique channel binding. | |
SAML20 user IdP URL. | |
SAML 2.0 URL to access in browser. | |
OpenID 2.0 URL to access in browser. | |
OpenID 2.0 authentication outcome data. | |
Request to perform SAML 2.0 authentication in browser. | |
Request to perform OpenID 2.0 authentication in browser. | |
Request for simple validation. | |
Request for validation of EXTERNAL. | |
Request for validation of ANONYMOUS. | |
Request for validation of GSSAPI/GS2. | |
Reqest for validation of SecurID. | |
Reqest for validation of SAML20. | |
Reqest for validation of OpenID 2.0 login. |
typedef enum { GSASL_QOP_AUTH = 1, GSASL_QOP_AUTH_INT = 2, GSASL_QOP_AUTH_CONF = 4 } Gsasl_qop;
Quality of Protection types (DIGEST-MD5 and GSSAPI). The
integrity and confidentiality values is about application data
wrapping. We recommend that you use GSASL_QOP_AUTH
with TLS as
that combination is generally more secure and have better chance
of working than the integrity/confidentiality layers of SASL.
typedef enum { GSASL_OK = 0, GSASL_NEEDS_MORE = 1, GSASL_UNKNOWN_MECHANISM = 2, GSASL_MECHANISM_CALLED_TOO_MANY_TIMES = 3, GSASL_MALLOC_ERROR = 7, GSASL_BASE64_ERROR = 8, GSASL_CRYPTO_ERROR = 9, GSASL_SASLPREP_ERROR = 29, GSASL_MECHANISM_PARSE_ERROR = 30, GSASL_AUTHENTICATION_ERROR = 31, GSASL_INTEGRITY_ERROR = 33, GSASL_NO_CLIENT_CODE = 35, GSASL_NO_SERVER_CODE = 36, GSASL_NO_CALLBACK = 51, GSASL_NO_ANONYMOUS_TOKEN = 52, GSASL_NO_AUTHID = 53, GSASL_NO_AUTHZID = 54, GSASL_NO_PASSWORD = 55, GSASL_NO_PASSCODE = 56, GSASL_NO_PIN = 57, GSASL_NO_SERVICE = 58, GSASL_NO_HOSTNAME = 59, GSASL_NO_CB_TLS_UNIQUE = 65, GSASL_NO_SAML20_IDP_IDENTIFIER = 66, GSASL_NO_SAML20_REDIRECT_URL = 67, GSASL_NO_OPENID20_REDIRECT_URL = 68, /* Mechanism specific errors. */ GSASL_GSSAPI_RELEASE_BUFFER_ERROR = 37, GSASL_GSSAPI_IMPORT_NAME_ERROR = 38, GSASL_GSSAPI_INIT_SEC_CONTEXT_ERROR = 39, GSASL_GSSAPI_ACCEPT_SEC_CONTEXT_ERROR = 40, GSASL_GSSAPI_UNWRAP_ERROR = 41, GSASL_GSSAPI_WRAP_ERROR = 42, GSASL_GSSAPI_ACQUIRE_CRED_ERROR = 43, GSASL_GSSAPI_DISPLAY_NAME_ERROR = 44, GSASL_GSSAPI_UNSUPPORTED_PROTECTION_ERROR = 45, GSASL_KERBEROS_V5_INIT_ERROR = 46, GSASL_KERBEROS_V5_INTERNAL_ERROR = 47, GSASL_SHISHI_ERROR = GSASL_KERBEROS_V5_INTERNAL_ERROR, GSASL_SECURID_SERVER_NEED_ADDITIONAL_PASSCODE = 48, GSASL_SECURID_SERVER_NEED_NEW_PIN = 49, GSASL_GSSAPI_ENCAPSULATE_TOKEN_ERROR = 60, GSASL_GSSAPI_DECAPSULATE_TOKEN_ERROR = 61, GSASL_GSSAPI_INQUIRE_MECH_FOR_SASLNAME_ERROR = 62, GSASL_GSSAPI_TEST_OID_SET_MEMBER_ERROR = 63, GSASL_GSSAPI_RELEASE_OID_SET_ERROR = 64 /* When adding new values, note that integers are not necessarily assigned monotonously increasingly. */ } Gsasl_rc;
Error codes for library functions.
Successful return code, guaranteed to be always 0. | |
Mechanism expects another round-trip. | |
Application requested an unknown mechanism. | |
Application requested too many round trips from mechanism. | |
Memory allocation failed. | |
Base64 encoding/decoding failed. | |
Cryptographic error. | |
Failed to prepare internationalized string. | |
Mechanism could not parse input. | |
Authentication has failed. | |
Application data integrity check failed. | |
Library was built with client functionality. | |
Library was built with server functionality. | |
Application did not provide a callback. | |
Could not get required anonymous token. | |
Could not get required authentication identity (username). | |
Could not get required authorization identity. | |
Could not get required password. | |
Could not get required SecurID PIN. | |
Could not get required SecurID PIN. | |
Could not get required service name. | |
Could not get required hostname. | |
Could not get required tls-unique CB. | |
Could not get required SAML IdP. | |
Could not get required SAML redirect URL. | |
Could not get required OpenID redirect URL. | |
GSS-API library call error. | |
GSS-API library call error. | |
GSS-API library call error. | |
GSS-API library call error. | |
GSS-API library call error. | |
GSS-API library call error. | |
GSS-API library call error. | |
GSS-API library call error. | |
An unsupported quality-of-protection layer was requeted. | |
Init error in KERBEROS_V5. | |
General error in KERBEROS_V5. | |
Same as GSASL_KERBEROS_V5_INTERNAL_ERROR .
|
|
SecurID mechanism needs an additional passcode. | |
SecurID mechanism needs an new PIN. | |
GSS-API library call error. | |
GSS-API library call error. | |
GSS-API library call error. | |
GSS-API library call error. | |
GSS-API library call error. |
typedef enum { GSASL_ALLOW_UNASSIGNED = 1 } Gsasl_saslprep_flags;
Flags for the SASLprep function, see gsasl_saslprep()
. For
background, see the GNU Libidn documentation.
int gsasl_base64_from (const char *in
,size_t inlen
,char **out
,size_t *outlen
);
Decode Base64 data. The out
buffer must be deallocated by the
caller.
|
input byte array |
|
size of input byte array |
|
pointer to newly allocated output byte array |
|
pointer to size of newly allocated output byte array |
Returns : |
Returns GSASL_OK on success, GSASL_BASE64_ERROR if
input was invalid, and GSASL_MALLOC_ERROR on memory allocation
errors. |
Since 0.2.2
int gsasl_base64_to (const char *in
,size_t inlen
,char **out
,size_t *outlen
);
Encode data as base64. The string is zero terminated, and outlen
holds the length excluding the terminating zero. The out
buffer
must be deallocated by the caller.
|
input byte array |
|
size of input byte array |
|
pointer to newly allocated output byte array |
|
pointer to size of newly allocated output byte array |
Returns : |
Returns GSASL_OK on success, or GSASL_MALLOC_ERROR
if input was too large or memory allocation fail. |
Since 0.2.2
int gsasl_callback (Gsasl *ctx
,Gsasl_session *sctx
,Gsasl_property prop
);
Invoke the application callback. The prop
value indicate what the
callback is expected to do. For example, for
GSASL_ANONYMOUS_TOKEN
, the function is expected to invoke
gsasl_property_set(SCTX
, GSASL_ANONYMOUS_TOKEN
, "token") where
"token" is the anonymous token the application wishes the SASL
mechanism to use. See the manual for the meaning of all
parameters.
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.
|
handle received from gsasl_init() , may be NULL to derive it
from sctx . |
|
session handle. |
|
enumerated value of Gsasl_property type. |
Returns : |
Returns whatever the application callback returns, or
GSASL_NO_CALLBACK if no application was known. |
Since 0.2.0
void * gsasl_callback_hook_get (Gsasl *ctx
);
Retrieve application specific data from 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.
|
libgsasl handle. |
Returns : |
Returns the application specific data, or NULL. |
Since 0.2.0
void gsasl_callback_hook_set (Gsasl *ctx
,void *hook
);
Store application specific data in the libgsasl handle.
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.
|
libgsasl handle. |
|
opaque pointer to application specific data. |
Since 0.2.0
void gsasl_callback_set (Gsasl *ctx
,Gsasl_callback_function cb
);
Store the pointer to the application provided callback in the
library handle. The callback will be used, via gsasl_callback()
,
by mechanisms to discover various parameters (such as username and
passwords). The callback function will be called with a
Gsasl_property value indicating the requested behaviour. For
example, for GSASL_ANONYMOUS_TOKEN
, the function is expected to
invoke gsasl_property_set(CTX
, GSASL_ANONYMOUS_TOKEN
, "token")
where "token" is the anonymous token the application wishes the
SASL mechanism to use. See the manual for the meaning of all
parameters.
|
handle received from gsasl_init() . |
|
pointer to function implemented by application. |
Since 0.2.0
const char * gsasl_check_version (const char *req_version
);
Check GNU SASL Library version.
See GSASL_VERSION
for a suitable req_version
string.
This function is one of few in the library that can be used without
a successful call to gsasl_init()
.
|
version string to compare with, or NULL. |
Returns : |
Check that the version of the library is at
minimum the one given as a string in req_version 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. |
int gsasl_client_mechlist (Gsasl *ctx
,char **out
);
Return a newly allocated string containing SASL names, separated by
space, of mechanisms supported by the libgsasl client. out
is
allocated by this function, and it is the responsibility of caller
to deallocate it.
|
libgsasl handle. |
|
newly allocated output character array. |
Returns : |
Returns GSASL_OK if successful, or error code. |
int gsasl_client_start (Gsasl *ctx
,const char *mech
,Gsasl_session **sctx
);
This functions initiates a client SASL authentication. This function must be called before any other gsasl_client_*() function is called.
|
libgsasl handle. |
|
name of SASL mechanism. |
|
pointer to client handle. |
Returns : |
Returns GSASL_OK if successful, or error code. |
const char * gsasl_client_suggest_mechanism (Gsasl *ctx
,const char *mechlist
);
Given a list of mechanisms, suggest which to use.
|
libgsasl handle. |
|
input character array with SASL mechanism names, separated by invalid characters (e.g. SPC). |
Returns : |
Returns name of "best" SASL mechanism supported by the libgsasl client which is present in the input string, or NULL if no supported mechanism is found. |
int gsasl_client_support_p (Gsasl *ctx
,const char *name
);
Decide whether there is client-side support for a specified mechanism.
|
libgsasl handle. |
|
name of SASL mechanism. |
Returns : |
Returns 1 if the libgsasl client supports the named mechanism, otherwise 0. |
int gsasl_decode (Gsasl_session *sctx
,const char *input
,size_t input_len
,char **output
,size_t *output_len
);
Decode data according to negotiated SASL mechanism. This might mean that data is integrity or privacy protected.
The output
buffer is allocated by this function, and it is the
responsibility of caller to deallocate it by calling free(output
).
|
libgsasl session handle. |
|
input byte array. |
|
size of input byte array. |
|
newly allocated output byte array. |
|
size of output byte array. |
Returns : |
Returns GSASL_OK if encoding was successful,
otherwise an error code. |
void gsasl_done (Gsasl *ctx
);
This function destroys a libgsasl handle. The handle must not be used with other libgsasl functions after this call.
|
libgsasl handle. |
int gsasl_encode (Gsasl_session *sctx
,const char *input
,size_t input_len
,char **output
,size_t *output_len
);
Encode data according to negotiated SASL mechanism. This might mean that data is integrity or privacy protected.
The output
buffer is allocated by this function, and it is the
responsibility of caller to deallocate it by calling free(output
).
|
libgsasl session handle. |
|
input byte array. |
|
size of input byte array. |
|
newly allocated output byte array. |
|
size of output byte array. |
Returns : |
Returns GSASL_OK if encoding was successful,
otherwise an error code. |
void gsasl_finish (Gsasl_session *sctx
);
Destroy a libgsasl client or server handle. The handle must not be used with other libgsasl functions after this call.
|
libgsasl session handle. |
void gsasl_free (void *ptr
);
Invoke free(ptr
) to de-allocate memory pointer. Typically used on
strings allocated by other libgsasl functions.
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.
|
memory pointer |
Since 0.2.19
int gsasl_hmac_md5 (const char *key
,size_t keylen
,const char *in
,size_t inlen
,char *outhash[16]
);
Compute keyed checksum of data using HMAC-MD5. The outhash
buffer
must be deallocated by the caller.
|
input character array with key to use. |
|
length of input character array with key to use. |
|
input character array of data to hash. |
|
length of input character array of data to hash. |
|
newly allocated character array with keyed hash of data. |
Returns : |
Returns GSASL_OK iff successful. |
int gsasl_hmac_sha1 (const char *key
,size_t keylen
,const char *in
,size_t inlen
,char *outhash[20]
);
Compute keyed checksum of data using HMAC-SHA1. The outhash
buffer
must be deallocated by the caller.
|
input character array with key to use. |
|
length of input character array with key to use. |
|
input character array of data to hash. |
|
length of input character array of data to hash. |
|
newly allocated character array with keyed hash of data. |
Returns : |
Returns GSASL_OK iff successful. |
Since 1.3
int gsasl_init (Gsasl **ctx
);
This functions initializes libgsasl. The handle pointed to by ctx
is valid for use with other libgsasl functions iff this function is
successful. It also register all builtin SASL mechanisms, using
gsasl_register()
.
|
pointer to libgsasl handle. |
Returns : |
GSASL_OK iff successful, otherwise
GSASL_MALLOC_ERROR . |
int gsasl_md5 (const char *in
,size_t inlen
,char *out[16]
);
Compute hash of data using MD5. The out
buffer must be
deallocated by the caller.
|
input character array of data to hash. |
|
length of input character array of data to hash. |
|
newly allocated character array with hash of data. |
Returns : |
Returns GSASL_OK iff successful. |
const char * gsasl_mechanism_name (Gsasl_session *sctx
);
This function returns the name of the SASL mechanism used in the session.
|
libgsasl session handle. |
Returns : |
Returns a zero terminated character array with the name of the SASL mechanism, or NULL if not known. |
Since 0.2.28
int gsasl_nonce (char *data
,size_t datalen
);
Store unpredictable data of given size in the provided buffer.
|
output array to be filled with unpredictable random data. |
|
size of output array. |
Returns : |
Returns GSASL_OK iff successful. |
const char * gsasl_property_fast (Gsasl_session *sctx
,Gsasl_property prop
);
Retrieve the data stored in the session handle for given property
prop
.
The pointer is to live data, and must not be deallocated or modified in any way.
This function will not invoke the application callback.
|
session handle. |
|
enumerated value of Gsasl_property type, indicating the
type of data in data . |
Returns : |
Return property value, if known, or NULL if no value known. |
Since 0.2.0
const char * gsasl_property_get (Gsasl_session *sctx
,Gsasl_property prop
);
Retrieve the data stored in the session handle for given property
prop
, possibly invoking the application callback to get the value.
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.
|
session handle. |
|
enumerated value of Gsasl_property type, indicating the
type of data in data . |
Returns : |
Return data for property, or NULL if no value known. |
Since 0.2.0
void gsasl_property_set (Gsasl_session *sctx
,Gsasl_property prop
,const char *data
);
Make a copy of data
and store it in the session handle for the
indicated property prop
.
You can immediately deallocate data
after calling this function,
without affecting the data stored in the session handle.
|
session handle. |
|
enumerated value of Gsasl_property type, indicating the
type of data in data . |
|
zero terminated character string to store. |
Since 0.2.0
void gsasl_property_set_raw (Gsasl_session *sctx
,Gsasl_property prop
,const char *data
,size_t len
);
Make a copy of len
sized data
and store a zero terminated version
of it in the session handle for the indicated property prop
.
You can immediately deallocate data
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.
|
session handle. |
|
enumerated value of Gsasl_property type, indicating the
type of data in data . |
|
character string to store. |
|
length of character string to store. |
Since 0.2.0
int gsasl_random (char *data
,size_t datalen
);
Store cryptographically strong random data of given size in the provided buffer.
|
output array to be filled with strong random data. |
|
size of output array. |
Returns : |
Returns GSASL_OK iff successful. |
int gsasl_saslprep (const char *in
,Gsasl_saslprep_flags flags
,char **out
,int *stringpreprc
);
Prepare string using SASLprep. On success, the out
variable must
be deallocated by the caller.
|
a UTF-8 encoded string. |
|
any SASLprep flag, e.g., GSASL_ALLOW_UNASSIGNED . |
|
on exit, contains newly allocated output string. |
|
if non-NULL, will hold precise stringprep return code. |
Returns : |
Returns GSASL_OK on success, or
GSASL_SASLPREP_ERROR on error. |
Since 0.2.3
int gsasl_server_mechlist (Gsasl *ctx
,char **out
);
Return a newly allocated string containing SASL names, separated by
space, of mechanisms supported by the libgsasl server. out
is
allocated by this function, and it is the responsibility of caller
to deallocate it.
|
libgsasl handle. |
|
newly allocated output character array. |
Returns : |
Returns GSASL_OK if successful, or error code. |
int gsasl_server_start (Gsasl *ctx
,const char *mech
,Gsasl_session **sctx
);
This functions initiates a server SASL authentication. This function must be called before any other gsasl_server_*() function is called.
|
libgsasl handle. |
|
name of SASL mechanism. |
|
pointer to server handle. |
Returns : |
Returns GSASL_OK if successful, or error code. |
int gsasl_server_support_p (Gsasl *ctx
,const char *name
);
Decide whether there is server-side support for a specified mechanism.
|
libgsasl handle. |
|
name of SASL mechanism. |
Returns : |
Returns 1 if the libgsasl server supports the named mechanism, otherwise 0. |
void * gsasl_session_hook_get (Gsasl_session *sctx
);
Retrieve application specific data from 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.
|
libgsasl session handle. |
Returns : |
Returns the application specific data, or NULL. |
Since 0.2.14
void gsasl_session_hook_set (Gsasl_session *sctx
,void *hook
);
Store application specific data in the libgsasl session handle.
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.
|
libgsasl session handle. |
|
opaque pointer to application specific data. |
Since 0.2.14
int gsasl_sha1 (const char *in
,size_t inlen
,char *out[20]
);
Compute hash of data using SHA1. The out
buffer must be
deallocated by the caller.
|
input character array of data to hash. |
|
length of input character array of data to hash. |
|
newly allocated character array with hash of data. |
Returns : |
Returns GSASL_OK iff successful. |
Since 1.3
int gsasl_simple_getpass (const char *filename
,const char *username
,char **key
);
Retrieve password for user from specified file. The buffer key
contain the password if this function is successful. The caller is
responsible for deallocating it.
The file should be on the UoW "MD5 Based Authentication" format, which means it is in text format with comments denoted by # first on the line, with user entries looking as "usernameTABpassword". This function removes CR and LF at the end of lines before processing. TAB, CR, and LF denote ASCII values 9, 13, and 10, respectively.
|
filename of file containing passwords. |
|
username string. |
|
newly allocated output character array. |
Returns : |
Return GSASL_OK if output buffer contains the
password, GSASL_AUTHENTICATION_ERROR if the user could not be
found, or other error code. |
int gsasl_step (Gsasl_session *sctx
,const char *input
,size_t input_len
,char **output
,size_t *output_len
);
Perform one step of SASL authentication. This reads data from the
other end (from input
and input_len
), processes it (potentially
invoking callbacks to the application), and writes data to server
(into newly allocated variable output
and output_len
that
indicate the length of output
).
The contents of the output
buffer is unspecified if this functions
returns anything other than GSASL_OK
or GSASL_NEEDS_MORE
. If
this function return GSASL_OK
or GSASL_NEEDS_MORE
, however, the
output
buffer is allocated by this function, and it is the
responsibility of caller to deallocate it by calling free
(output
).
|
libgsasl session handle. |
|
input byte array. |
|
size of input byte array. |
|
newly allocated output byte array. |
|
pointer to output variable with size of output byte array. |
Returns : |
Returns GSASL_OK if authenticated terminated
successfully, GSASL_NEEDS_MORE if more data is needed, or error
code. |
int gsasl_step64 (Gsasl_session *sctx
,const char *b64input
,char **b64output
);
This is a simple wrapper around gsasl_step()
that base64 decodes
the input and base64 encodes the output.
The contents of the b64output
buffer is unspecified if this
functions returns anything other than GSASL_OK
or
GSASL_NEEDS_MORE
. If this function return GSASL_OK
or
GSASL_NEEDS_MORE
, however, the b64output
buffer is allocated by
this function, and it is the responsibility of caller to deallocate
it by calling free (b64output
).
|
libgsasl client handle. |
|
input base64 encoded byte array. |
|
newly allocated output base64 encoded byte array. |
Returns : |
Returns GSASL_OK if authenticated terminated
successfully, GSASL_NEEDS_MORE if more data is needed, or error
code. |
const char * gsasl_strerror (int err
);
Convert return code to human readable string explanation of the reason for the particular error code.
This string can be used to output a diagnostic message to the user.
This function is one of few in the library that can be used without
a successful call to gsasl_init()
.
|
libgsasl error code |
Returns : |
Returns a pointer to a statically allocated string
containing an explanation of the error code err . |
const char * gsasl_strerror_name (int err
);
Convert return code to human readable string representing the error
code symbol itself. For example, gsasl_strerror_name(GSASL_OK
)
returns the string "GSASL_OK".
This string can be used to output a diagnostic message to the user.
This function is one of few in the library that can be used without
a successful call to gsasl_init()
.
|
libgsasl error code |
Returns : |
Returns a pointer to a statically allocated string
containing a string version of the error code err , or NULL if
the error code is not known. |
Since 0.2.29