gsasl  2.2.1
Macros | Typedefs | Enumerations | Functions
gsasl.h File Reference
#include <stdio.h>
#include <stddef.h>
#include <unistd.h>
#include <gsasl-version.h>
#include <gsasl-mech.h>

Go to the source code of this file.

Macros

#define _GSASL_API
 

Typedefs

typedef struct Gsasl Gsasl
 
typedef struct Gsasl_session Gsasl_session
 
typedef int(* Gsasl_callback_function) (Gsasl *ctx, Gsasl_session *sctx, Gsasl_property prop)
 

Enumerations

enum  Gsasl_rc {
  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 , GSASL_NO_CB_TLS_EXPORTER = 69 , 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_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
}
 
enum  Gsasl_property {
  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_SCRAM_SERVERKEY = 23 , GSASL_SCRAM_STOREDKEY = 24 , 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 ,
  GSASL_CB_TLS_EXPORTER = 25 , GSASL_SAML20_AUTHENTICATE_IN_BROWSER = 250 , GSASL_OPENID20_AUTHENTICATE_IN_BROWSER = 251 , 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
}
 
enum  Gsasl_mechname_limits { GSASL_MIN_MECHANISM_SIZE = 1 , GSASL_MAX_MECHANISM_SIZE = 20 }
 
enum  Gsasl_qop { GSASL_QOP_AUTH = 1 , GSASL_QOP_AUTH_INT = 2 , GSASL_QOP_AUTH_CONF = 4 }
 
enum  Gsasl_saslprep_flags { GSASL_ALLOW_UNASSIGNED = 1 }
 
enum  Gsasl_hash { GSASL_HASH_SHA1 = 2 , GSASL_HASH_SHA256 = 3 }
 
enum  Gsasl_hash_length { GSASL_HASH_SHA1_SIZE = 20 , GSASL_HASH_SHA256_SIZE = 32 , GSASL_HASH_MAX_SIZE = GSASL_HASH_SHA256_SIZE }
 

Functions

_GSASL_API int gsasl_init (Gsasl **ctx)
 
_GSASL_API void gsasl_done (Gsasl *ctx)
 
_GSASL_API const char * gsasl_check_version (const char *req_version)
 
_GSASL_API void gsasl_callback_set (Gsasl *ctx, Gsasl_callback_function cb)
 
_GSASL_API int gsasl_callback (Gsasl *ctx, Gsasl_session *sctx, Gsasl_property prop)
 
_GSASL_API void gsasl_callback_hook_set (Gsasl *ctx, void *hook)
 
_GSASL_API void * gsasl_callback_hook_get (Gsasl *ctx)
 
_GSASL_API void gsasl_session_hook_set (Gsasl_session *sctx, void *hook)
 
_GSASL_API void * gsasl_session_hook_get (Gsasl_session *sctx)
 
_GSASL_API int gsasl_property_set (Gsasl_session *sctx, Gsasl_property prop, const char *data)
 
_GSASL_API int gsasl_property_set_raw (Gsasl_session *sctx, Gsasl_property prop, const char *data, size_t len)
 
_GSASL_API void gsasl_property_free (Gsasl_session *sctx, Gsasl_property prop)
 
_GSASL_API const char * gsasl_property_get (Gsasl_session *sctx, Gsasl_property prop)
 
_GSASL_API const char * gsasl_property_fast (Gsasl_session *sctx, Gsasl_property prop)
 
_GSASL_API int gsasl_client_mechlist (Gsasl *ctx, char **out)
 
_GSASL_API int gsasl_client_support_p (Gsasl *ctx, const char *name)
 
_GSASL_API const char * gsasl_client_suggest_mechanism (Gsasl *ctx, const char *mechlist)
 
_GSASL_API int gsasl_server_mechlist (Gsasl *ctx, char **out)
 
_GSASL_API int gsasl_server_support_p (Gsasl *ctx, const char *name)
 
_GSASL_API int gsasl_mechanism_name_p (const char *mech)
 
_GSASL_API int gsasl_client_start (Gsasl *ctx, const char *mech, Gsasl_session **sctx)
 
_GSASL_API int gsasl_server_start (Gsasl *ctx, const char *mech, Gsasl_session **sctx)
 
_GSASL_API int gsasl_step (Gsasl_session *sctx, const char *input, size_t input_len, char **output, size_t *output_len)
 
_GSASL_API int gsasl_step64 (Gsasl_session *sctx, const char *b64input, char **b64output)
 
_GSASL_API void gsasl_finish (Gsasl_session *sctx)
 
_GSASL_API int gsasl_encode (Gsasl_session *sctx, const char *input, size_t input_len, char **output, size_t *output_len)
 
_GSASL_API int gsasl_decode (Gsasl_session *sctx, const char *input, size_t input_len, char **output, size_t *output_len)
 
_GSASL_API const char * gsasl_mechanism_name (Gsasl_session *sctx)
 
_GSASL_API const char * gsasl_strerror (int err)
 
_GSASL_API const char * gsasl_strerror_name (int err)
 
_GSASL_API int gsasl_saslprep (const char *in, Gsasl_saslprep_flags flags, char **out, int *stringpreprc)
 
_GSASL_API int gsasl_nonce (char *data, size_t datalen)
 
_GSASL_API int gsasl_random (char *data, size_t datalen)
 
_GSASL_API size_t gsasl_hash_length (Gsasl_hash hash)
 
_GSASL_API int gsasl_scram_secrets_from_salted_password (Gsasl_hash hash, const char *salted_password, char *client_key, char *server_key, char *stored_key)
 
_GSASL_API int gsasl_scram_secrets_from_password (Gsasl_hash hash, const char *password, unsigned int iteration_count, const char *salt, size_t saltlen, char *salted_password, char *client_key, char *server_key, char *stored_key)
 
_GSASL_API int gsasl_simple_getpass (const char *filename, const char *username, char **key)
 
_GSASL_API int gsasl_base64_to (const char *in, size_t inlen, char **out, size_t *outlen)
 
_GSASL_API int gsasl_base64_from (const char *in, size_t inlen, char **out, size_t *outlen)
 
_GSASL_API int gsasl_hex_to (const char *in, size_t inlen, char **out, size_t *outlen)
 
_GSASL_API int gsasl_hex_from (const char *in, char **out, size_t *outlen)
 
_GSASL_API void gsasl_free (void *ptr)
 

Macro Definition Documentation

◆ _GSASL_API

#define _GSASL_API

SECTION:gsasl

Parameters
titlegsasl.h
short_descriptionmain library interfaces

The main library interfaces are declared in gsasl.h.

Definition at line 49 of file gsasl.h.

Typedef Documentation

◆ Gsasl

typedef struct Gsasl Gsasl

Gsasl:

Handle to global library context.

Definition at line 1 of file gsasl.h.

◆ Gsasl_callback_function

typedef int(* Gsasl_callback_function) (Gsasl *ctx, Gsasl_session *sctx, Gsasl_property prop)

Gsasl_callback_function:

Parameters
ctxlibgsasl handle.
sctxsession handle, may be NULL.
propenumerated value of Gsasl_property type.

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.

Return value: Any valid return code, the interpretation of which depend on the @prop value.

Since: 0.2.0

Definition at line 286 of file gsasl.h.

◆ Gsasl_session

typedef struct Gsasl_session Gsasl_session

Gsasl_session:

Handle to SASL session context.

Definition at line 1 of file gsasl.h.

Enumeration Type Documentation

◆ Gsasl_hash

enum Gsasl_hash

Gsasl_hash:

Parameters
GSASL_HASH_SHA1Hash function SHA-1.
GSASL_HASH_SHA256Hash function SHA-256.

Hash functions. You may use gsasl_hash_length() to get the output size of a hash function.

Currently only used as parameter to gsasl_scram_secrets_from_salted_password() and gsasl_scram_secrets_from_password() to specify for which SCRAM mechanism to prepare secrets for.

Since: 1.10

Enumerator
GSASL_HASH_SHA1 
GSASL_HASH_SHA256 

Definition at line 427 of file gsasl.h.

◆ Gsasl_hash_length

Gsasl_hash_length:

Parameters
GSASL_HASH_SHA1_SIZEOutput size of hash function SHA-1.
GSASL_HASH_SHA256_SIZEOutput size of hash function SHA-256.
GSASL_HASH_MAX_SIZEMaximum output size of any Gsasl_hash_length.

Identifiers specifying the output size of hash functions.

These can be used when statically allocating the buffers needed for, e.g., gsasl_scram_secrets_from_password().

Since: 1.10

Enumerator
GSASL_HASH_SHA1_SIZE 
GSASL_HASH_SHA256_SIZE 
GSASL_HASH_MAX_SIZE 

Definition at line 447 of file gsasl.h.

◆ Gsasl_mechname_limits

Gsasl_mechname_limits:

Parameters
GSASL_MIN_MECHANISM_SIZEMinimum size of mechanism name strings.
GSASL_MAX_MECHANISM_SIZEMaximum size of mechanism name strings.

SASL mechanisms are named by strings, from 1 to 20 characters in length, consisting of upper-case letters, digits, hyphens, and/or underscores. See also gsasl_mechanism_name_p().

Enumerator
GSASL_MIN_MECHANISM_SIZE 
GSASL_MAX_MECHANISM_SIZE 

Definition at line 298 of file gsasl.h.

◆ Gsasl_property

Gsasl_property:

Parameters
GSASL_AUTHIDAuthentication identity (username).
GSASL_AUTHZIDAuthorization identity.
GSASL_PASSWORDPassword.
GSASL_ANONYMOUS_TOKENAnonymous identifier.
GSASL_SERVICEService name
GSASL_HOSTNAMEHost name.
GSASL_GSSAPI_DISPLAY_NAMEGSS-API credential principal name.
GSASL_PASSCODESecurID passcode.
GSASL_SUGGESTED_PINSecurID suggested PIN.
GSASL_PINSecurID PIN.
GSASL_REALMUser realm.
GSASL_DIGEST_MD5_HASHED_PASSWORDPre-computed hashed DIGEST-MD5 password, to avoid storing passwords in the clear.
GSASL_QOPSSet of quality-of-protection values.
GSASL_QOPQuality-of-protection value.
GSASL_SCRAM_ITERNumber of iterations in password-to-key hashing.
GSASL_SCRAM_SALTSalt for password-to-key hashing.
GSASL_SCRAM_SALTED_PASSWORDHex-encoded hashed/salted password.
GSASL_SCRAM_SERVERKEYHex-encoded SCRAM ServerKey derived from users' passowrd.
GSASL_SCRAM_STOREDKEYHex-encoded SCRAM StoredKey derived from users' passowrd.
GSASL_CB_TLS_UNIQUEBase64 encoded tls-unique channel binding.
GSASL_CB_TLS_EXPORTERBase64 encoded tls-exporter channel binding.
GSASL_SAML20_IDP_IDENTIFIERSAML20 user IdP URL.
GSASL_SAML20_REDIRECT_URLSAML 2.0 URL to access in browser.
GSASL_OPENID20_REDIRECT_URLOpenID 2.0 URL to access in browser.
GSASL_OPENID20_OUTCOME_DATAOpenID 2.0 authentication outcome data.
GSASL_SAML20_AUTHENTICATE_IN_BROWSERRequest to perform SAML 2.0 authentication in browser.
GSASL_OPENID20_AUTHENTICATE_IN_BROWSERRequest to perform OpenID 2.0 authentication in browser.
GSASL_VALIDATE_SIMPLERequest for simple validation.
GSASL_VALIDATE_EXTERNALRequest for validation of EXTERNAL.
GSASL_VALIDATE_ANONYMOUSRequest for validation of ANONYMOUS.
GSASL_VALIDATE_GSSAPIRequest for validation of GSSAPI/GS2.
GSASL_VALIDATE_SECURIDReqest for validation of SecurID.
GSASL_VALIDATE_SAML20Reqest for validation of SAML20.
GSASL_VALIDATE_OPENID20Reqest for validation of OpenID 2.0 login.

Callback/property types.

Enumerator
GSASL_AUTHID 
GSASL_AUTHZID 
GSASL_PASSWORD 
GSASL_ANONYMOUS_TOKEN 
GSASL_SERVICE 
GSASL_HOSTNAME 
GSASL_GSSAPI_DISPLAY_NAME 
GSASL_PASSCODE 
GSASL_SUGGESTED_PIN 
GSASL_PIN 
GSASL_REALM 
GSASL_DIGEST_MD5_HASHED_PASSWORD 
GSASL_QOPS 
GSASL_QOP 
GSASL_SCRAM_ITER 
GSASL_SCRAM_SALT 
GSASL_SCRAM_SALTED_PASSWORD 
GSASL_SCRAM_SERVERKEY 
GSASL_SCRAM_STOREDKEY 
GSASL_CB_TLS_UNIQUE 
GSASL_SAML20_IDP_IDENTIFIER 
GSASL_SAML20_REDIRECT_URL 
GSASL_OPENID20_REDIRECT_URL 
GSASL_OPENID20_OUTCOME_DATA 
GSASL_CB_TLS_EXPORTER 
GSASL_SAML20_AUTHENTICATE_IN_BROWSER 
GSASL_OPENID20_AUTHENTICATE_IN_BROWSER 
GSASL_VALIDATE_SIMPLE 
GSASL_VALIDATE_EXTERNAL 
GSASL_VALIDATE_ANONYMOUS 
GSASL_VALIDATE_GSSAPI 
GSASL_VALIDATE_SECURID 
GSASL_VALIDATE_SAML20 
GSASL_VALIDATE_OPENID20 

Definition at line 221 of file gsasl.h.

◆ Gsasl_qop

enum Gsasl_qop

Gsasl_qop:

Parameters
GSASL_QOP_AUTHAuthentication only.
GSASL_QOP_AUTH_INTAuthentication and integrity.
GSASL_QOP_AUTH_CONFAuthentication, integrity and confidentiality.

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.

Enumerator
GSASL_QOP_AUTH 
GSASL_QOP_AUTH_INT 
GSASL_QOP_AUTH_CONF 

Definition at line 316 of file gsasl.h.

◆ Gsasl_rc

enum Gsasl_rc

Gsasl_rc:

Parameters
GSASL_OKSuccessful return code, guaranteed to be always 0.
GSASL_NEEDS_MOREMechanism expects another round-trip.
GSASL_UNKNOWN_MECHANISMApplication requested an unknown mechanism.
GSASL_MECHANISM_CALLED_TOO_MANY_TIMESApplication requested too many round trips from mechanism.
GSASL_MALLOC_ERRORMemory allocation failed.
GSASL_BASE64_ERRORBase64 encoding/decoding failed.
GSASL_CRYPTO_ERRORCryptographic error.
GSASL_SASLPREP_ERRORFailed to prepare internationalized string.
GSASL_MECHANISM_PARSE_ERRORMechanism could not parse input.
GSASL_AUTHENTICATION_ERRORAuthentication has failed.
GSASL_INTEGRITY_ERRORApplication data integrity check failed.
GSASL_NO_CLIENT_CODELibrary was built with client functionality.
GSASL_NO_SERVER_CODELibrary was built with server functionality.
GSASL_NO_CALLBACKApplication did not provide a callback.
GSASL_NO_ANONYMOUS_TOKENCould not get required anonymous token.
GSASL_NO_AUTHIDCould not get required authentication identity (username).
GSASL_NO_AUTHZIDCould not get required authorization identity.
GSASL_NO_PASSWORDCould not get required password.
GSASL_NO_PASSCODECould not get required SecurID PIN.
GSASL_NO_PINCould not get required SecurID PIN.
GSASL_NO_SERVICECould not get required service name.
GSASL_NO_HOSTNAMECould not get required hostname.
GSASL_NO_CB_TLS_UNIQUECould not get required tls-unique CB.
GSASL_NO_CB_TLS_EXPORTERCould not get required tls-exporter CB.
GSASL_NO_SAML20_IDP_IDENTIFIERCould not get required SAML IdP.
GSASL_NO_SAML20_REDIRECT_URLCould not get required SAML redirect URL.
GSASL_NO_OPENID20_REDIRECT_URLCould not get required OpenID redirect URL.
GSASL_GSSAPI_RELEASE_BUFFER_ERRORGSS-API library call error.
GSASL_GSSAPI_IMPORT_NAME_ERRORGSS-API library call error.
GSASL_GSSAPI_INIT_SEC_CONTEXT_ERRORGSS-API library call error.
GSASL_GSSAPI_ACCEPT_SEC_CONTEXT_ERRORGSS-API library call error.
GSASL_GSSAPI_UNWRAP_ERRORGSS-API library call error.
GSASL_GSSAPI_WRAP_ERRORGSS-API library call error.
GSASL_GSSAPI_ACQUIRE_CRED_ERRORGSS-API library call error.
GSASL_GSSAPI_DISPLAY_NAME_ERRORGSS-API library call error.
GSASL_GSSAPI_UNSUPPORTED_PROTECTION_ERRORAn unsupported quality-of-protection layer was requeted.
GSASL_GSSAPI_ENCAPSULATE_TOKEN_ERRORGSS-API library call error.
GSASL_GSSAPI_DECAPSULATE_TOKEN_ERRORGSS-API library call error.
GSASL_GSSAPI_INQUIRE_MECH_FOR_SASLNAME_ERRORGSS-API library call error.
GSASL_GSSAPI_TEST_OID_SET_MEMBER_ERRORGSS-API library call error.
GSASL_GSSAPI_RELEASE_OID_SET_ERRORGSS-API library call error.
GSASL_SECURID_SERVER_NEED_ADDITIONAL_PASSCODESecurID mechanism needs an additional passcode.
GSASL_SECURID_SERVER_NEED_NEW_PINSecurID mechanism needs an new PIN.

Error codes for library functions.

Enumerator
GSASL_OK 
GSASL_NEEDS_MORE 
GSASL_UNKNOWN_MECHANISM 
GSASL_MECHANISM_CALLED_TOO_MANY_TIMES 
GSASL_MALLOC_ERROR 
GSASL_BASE64_ERROR 
GSASL_CRYPTO_ERROR 
GSASL_SASLPREP_ERROR 
GSASL_MECHANISM_PARSE_ERROR 
GSASL_AUTHENTICATION_ERROR 
GSASL_INTEGRITY_ERROR 
GSASL_NO_CLIENT_CODE 
GSASL_NO_SERVER_CODE 
GSASL_NO_CALLBACK 
GSASL_NO_ANONYMOUS_TOKEN 
GSASL_NO_AUTHID 
GSASL_NO_AUTHZID 
GSASL_NO_PASSWORD 
GSASL_NO_PASSCODE 
GSASL_NO_PIN 
GSASL_NO_SERVICE 
GSASL_NO_HOSTNAME 
GSASL_NO_CB_TLS_UNIQUE 
GSASL_NO_SAML20_IDP_IDENTIFIER 
GSASL_NO_SAML20_REDIRECT_URL 
GSASL_NO_OPENID20_REDIRECT_URL 
GSASL_NO_CB_TLS_EXPORTER 
GSASL_GSSAPI_RELEASE_BUFFER_ERROR 
GSASL_GSSAPI_IMPORT_NAME_ERROR 
GSASL_GSSAPI_INIT_SEC_CONTEXT_ERROR 
GSASL_GSSAPI_ACCEPT_SEC_CONTEXT_ERROR 
GSASL_GSSAPI_UNWRAP_ERROR 
GSASL_GSSAPI_WRAP_ERROR 
GSASL_GSSAPI_ACQUIRE_CRED_ERROR 
GSASL_GSSAPI_DISPLAY_NAME_ERROR 
GSASL_GSSAPI_UNSUPPORTED_PROTECTION_ERROR 
GSASL_SECURID_SERVER_NEED_ADDITIONAL_PASSCODE 
GSASL_SECURID_SERVER_NEED_NEW_PIN 
GSASL_GSSAPI_ENCAPSULATE_TOKEN_ERROR 
GSASL_GSSAPI_DECAPSULATE_TOKEN_ERROR 
GSASL_GSSAPI_INQUIRE_MECH_FOR_SASLNAME_ERROR 
GSASL_GSSAPI_TEST_OID_SET_MEMBER_ERROR 
GSASL_GSSAPI_RELEASE_OID_SET_ERROR 

Definition at line 127 of file gsasl.h.

◆ Gsasl_saslprep_flags

Gsasl_saslprep_flags:

Parameters
GSASL_ALLOW_UNASSIGNEDAllow unassigned code points.

Flags for the SASLprep function, see gsasl_saslprep(). For background, see the GNU Libidn documentation.

Enumerator
GSASL_ALLOW_UNASSIGNED 

Definition at line 330 of file gsasl.h.

Function Documentation

◆ gsasl_base64_from()

_GSASL_API int gsasl_base64_from ( const char *  in,
size_t  inlen,
char **  out,
size_t *  outlen 
)

gsasl_base64_from:

Parameters
ininput byte array
inlensize of input byte array
outpointer to newly allocated output byte array
outlenpointer to size of newly allocated output byte array

Decode Base64 data. The @out buffer must be deallocated by the caller.

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 75 of file base64.c.

◆ gsasl_base64_to()

_GSASL_API int gsasl_base64_to ( const char *  in,
size_t  inlen,
char **  out,
size_t *  outlen 
)

gsasl_base64_to:

Parameters
ininput byte array.
inlensize of input byte array.
outpointer to newly allocated base64-encoded string.
outlenpointer to size of newly allocated base64-encoded string.

Encode data as base64. The @out string is zero terminated, and @outlen holds the length excluding the terminating zero. The @out buffer must be deallocated by the caller.

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 45 of file base64.c.

◆ gsasl_callback()

_GSASL_API int gsasl_callback ( Gsasl ctx,
Gsasl_session sctx,
Gsasl_property  prop 
)

gsasl_callback:

Parameters
ctxhandle received from gsasl_init(), may be NULL to derive it from @sctx.
sctxsession handle.
propenumerated value of Gsasl_property type.

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.

Return value: Returns whatever the application callback returns, or GSASL_NO_CALLBACK if no application was known.

Since: 0.2.0

Definition at line 71 of file callback.c.

◆ gsasl_callback_hook_get()

_GSASL_API void* gsasl_callback_hook_get ( Gsasl ctx)

gsasl_callback_hook_get:

Parameters
ctxlibgsasl handle.

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.

Return value: Returns the application specific data, or NULL.

Since: 0.2.0

Definition at line 120 of file callback.c.

◆ gsasl_callback_hook_set()

_GSASL_API void gsasl_callback_hook_set ( Gsasl ctx,
void *  hook 
)

gsasl_callback_hook_set:

Parameters
ctxlibgsasl handle.
hookopaque pointer to application specific data.

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.

Since: 0.2.0

Definition at line 100 of file callback.c.

◆ gsasl_callback_set()

_GSASL_API void gsasl_callback_set ( Gsasl ctx,
Gsasl_callback_function  cb 
)

gsasl_callback_set:

Parameters
ctxhandle received from gsasl_init().
cbpointer to function implemented by application.

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.

Since: 0.2.0

Definition at line 45 of file callback.c.

◆ gsasl_check_version()

_GSASL_API const char* gsasl_check_version ( const char *  req_version)

gsasl_check_version:

Parameters
req_versionversion string to compare with, or NULL.

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().

Return value: 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.

Definition at line 46 of file version.c.

◆ gsasl_client_mechlist()

_GSASL_API int gsasl_client_mechlist ( Gsasl ctx,
char **  out 
)

gsasl_client_mechlist:

Parameters
ctxlibgsasl handle.
outnewly allocated output character array.

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.

Return value: Returns GSASL_OK if successful, or error code.

Definition at line 75 of file listmech.c.

◆ gsasl_client_start()

_GSASL_API int gsasl_client_start ( Gsasl ctx,
const char *  mech,
Gsasl_session **  sctx 
)

gsasl_client_start:

Parameters
ctxlibgsasl handle.
mechname of SASL mechanism.
sctxpointer to client handle.

This functions initiates a client SASL authentication. This function must be called before any other gsasl_client_*() function is called.

Return value: Returns GSASL_OK if successful, or error code.

Definition at line 120 of file xstart.c.

◆ gsasl_client_suggest_mechanism()

_GSASL_API const char* gsasl_client_suggest_mechanism ( Gsasl ctx,
const char *  mechlist 
)

gsasl_client_suggest_mechanism:

Parameters
ctxlibgsasl handle.
mechlistinput character array with SASL mechanism names, separated by invalid characters (e.g. SPC).

Given a list of mechanisms, suggest which to use.

Return value: 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.

Definition at line 88 of file suggest.c.

◆ gsasl_client_support_p()

_GSASL_API int gsasl_client_support_p ( Gsasl ctx,
const char *  name 
)

gsasl_client_support_p:

Parameters
ctxlibgsasl handle.
namename of SASL mechanism.

Decide whether there is client-side support for a specified mechanism.

Return value: Returns 1 if the libgsasl client supports the named mechanism, otherwise 0.

Definition at line 50 of file supportp.c.

◆ gsasl_decode()

_GSASL_API int gsasl_decode ( Gsasl_session sctx,
const char *  input,
size_t  input_len,
char **  output,
size_t *  output_len 
)

gsasl_decode:

Parameters
sctxlibgsasl session handle.
inputinput byte array.
input_lensize of input byte array.
outputnewly allocated output byte array.
output_lenpointer to output variable with size of output byte array.

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 gsasl_free(@output).

Return value: Returns GSASL_OK if encoding was successful, otherwise an error code.

Definition at line 99 of file xcode.c.

◆ gsasl_done()

_GSASL_API void gsasl_done ( Gsasl ctx)

gsasl_done:

Parameters
ctxlibgsasl handle.

This function destroys a libgsasl handle. The handle must not be used with other libgsasl functions after this call.

Definition at line 34 of file done.c.

◆ gsasl_encode()

_GSASL_API int gsasl_encode ( Gsasl_session sctx,
const char *  input,
size_t  input_len,
char **  output,
size_t *  output_len 
)

gsasl_encode:

Parameters
sctxlibgsasl session handle.
inputinput byte array.
input_lensize of input byte array.
outputnewly allocated output byte array.
output_lenpointer to output variable with size of output byte array.

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 gsasl_free(@output).

Return value: Returns GSASL_OK if encoding was successful, otherwise an error code.

Definition at line 66 of file xcode.c.

◆ gsasl_finish()

_GSASL_API void gsasl_finish ( Gsasl_session sctx)

gsasl_finish:

Parameters
sctxlibgsasl session handle.

Destroy a libgsasl client or server handle. The handle must not be used with other libgsasl functions after this call.

Definition at line 34 of file xfinish.c.

◆ gsasl_free()

_GSASL_API void gsasl_free ( void *  ptr)

gsasl_free:

Parameters
ptrmemory pointer

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.

Since: 0.2.19

Definition at line 41 of file src/free.c.

◆ gsasl_hash_length()

_GSASL_API size_t gsasl_hash_length ( Gsasl_hash  hash)

gsasl_hash_length:

Parameters
hasha Gsasl_hash element, e.g., GSASL_HASH_SHA256.

Return the digest output size for hash function @hash. For example, gsasl_hash_length(GSASL_HASH_SHA256) returns GSASL_HASH_SHA256_SIZE which is 32.

Returns: size of supplied Gsasl_hash element.

Since: 1.10

Definition at line 73 of file crypto.c.

◆ gsasl_hex_from()

_GSASL_API int gsasl_hex_from ( const char *  in,
char **  out,
size_t *  outlen 
)

gsasl_hex_from:

Parameters
ininput byte array
outpointer to newly allocated output byte array
outlenpointer to size of newly allocated output byte array

Decode hex data. The @out buffer must be deallocated by the caller.

Return value: Returns GSASL_OK on success, GSASL_BASE64_ERROR if input was invalid, and GSASL_MALLOC_ERROR on memory allocation errors.

Since: 1.10

Definition at line 144 of file base64.c.

◆ gsasl_hex_to()

_GSASL_API int gsasl_hex_to ( const char *  in,
size_t  inlen,
char **  out,
size_t *  outlen 
)

gsasl_hex_to:

Parameters
ininput byte array.
inlensize of input byte array.
outpointer to newly allocated hex-encoded string.
outlenpointer to size of newly allocated hex-encoded string.

Hex encode data. The @out string is zero terminated, and @outlen holds the length excluding the terminating zero. The @out buffer must be deallocated by the caller.

Return value: Returns GSASL_OK on success, or GSASL_MALLOC_ERROR if input was too large or memory allocation fail.

Since: 1.10

Definition at line 111 of file base64.c.

◆ gsasl_init()

_GSASL_API int gsasl_init ( Gsasl **  ctx)

gsasl_init:

Parameters
ctxpointer to libgsasl handle.

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().

Return value: GSASL_OK iff successful, otherwise GSASL_MALLOC_ERROR.

Definition at line 158 of file init.c.

◆ gsasl_mechanism_name()

_GSASL_API const char* gsasl_mechanism_name ( Gsasl_session sctx)

gsasl_mechanism_name:

Parameters
sctxlibgsasl session handle.

This function returns the name of the SASL mechanism used in the session. The pointer must not be deallocated by the caller.

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 39 of file mechname.c.

◆ gsasl_mechanism_name_p()

_GSASL_API int gsasl_mechanism_name_p ( const char *  mech)

gsasl_mechanism_name_p:

Parameters
mechinput variable with mechanism name string.

Check if the mechanism name string @mech follows syntactical rules. It does not check that the name is registered with IANA. It does not check that the mechanism name is actually implemented and supported.

SASL mechanisms are named by strings, from 1 to 20 characters in length, consisting of upper-case letters, digits, hyphens, and/or underscores.

Returns: non-zero when mechanism name string @mech conforms to rules, zero when it does not meet the requirements.

Since: 2.0.0

Definition at line 53 of file suggest.c.

◆ gsasl_nonce()

_GSASL_API int gsasl_nonce ( char *  data,
size_t  datalen 
)

gsasl_nonce:

Parameters
dataoutput array to be filled with unpredictable random data.
datalensize of output array.

Store unpredictable data of given size in the provided buffer.

Return value: Returns GSASL_OK iff successful.

Definition at line 39 of file crypto.c.

◆ gsasl_property_fast()

_GSASL_API const char* gsasl_property_fast ( Gsasl_session sctx,
Gsasl_property  prop 
)

gsasl_property_fast:

Parameters
sctxsession handle.
propenumerated value of Gsasl_property type, indicating the type of data in @data.

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.

Return value: Return property value, if known, or NULL if no value known.

Since: 0.2.0

Definition at line 262 of file property.c.

◆ gsasl_property_free()

_GSASL_API void gsasl_property_free ( Gsasl_session sctx,
Gsasl_property  prop 
)

gsasl_property_free:

Parameters
sctxsession handle.
propenumerated value of Gsasl_property type to clear

Deallocate associated data with property @prop in session handle. After this call, gsasl_property_fast(@sctx, @prop) will always return NULL.

Since: 2.0.0

Definition at line 159 of file property.c.

◆ gsasl_property_get()

_GSASL_API const char* gsasl_property_get ( Gsasl_session sctx,
Gsasl_property  prop 
)

gsasl_property_get:

Parameters
sctxsession handle.
propenumerated value of Gsasl_property type, indicating the type of data in @data.

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.

Return value: Return data for property, or NULL if no value known.

Since: 0.2.0

Definition at line 292 of file property.c.

◆ gsasl_property_set()

_GSASL_API int gsasl_property_set ( Gsasl_session sctx,
Gsasl_property  prop,
const char *  data 
)

gsasl_property_set:

Parameters
sctxsession handle.
propenumerated value of Gsasl_property type, indicating the type of data in @data.
datazero terminated character string to store.

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.

Return value: GSASL_OK iff successful, otherwise GSASL_MALLOC_ERROR.

Since: 0.2.0

Definition at line 189 of file property.c.

◆ gsasl_property_set_raw()

_GSASL_API int gsasl_property_set_raw ( Gsasl_session sctx,
Gsasl_property  prop,
const char *  data,
size_t  len 
)

gsasl_property_set_raw:

Parameters
sctxsession handle.
propenumerated value of Gsasl_property type, indicating the type of data in @data.
datacharacter string to store.
lenlength of character string to store.

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.

Return value: GSASL_OK iff successful, otherwise GSASL_MALLOC_ERROR.

Since: 0.2.0

Definition at line 218 of file property.c.

◆ gsasl_random()

_GSASL_API int gsasl_random ( char *  data,
size_t  datalen 
)

gsasl_random:

Parameters
dataoutput array to be filled with strong random data.
datalensize of output array.

Store cryptographically strong random data of given size in the provided buffer.

Return value: Returns GSASL_OK iff successful.

Definition at line 55 of file crypto.c.

◆ gsasl_saslprep()

_GSASL_API int gsasl_saslprep ( const char *  in,
Gsasl_saslprep_flags  flags,
char **  out,
int *  stringpreprc 
)

◆ gsasl_scram_secrets_from_password()

_GSASL_API int gsasl_scram_secrets_from_password ( Gsasl_hash  hash,
const char *  password,
unsigned int  iteration_count,
const char *  salt,
size_t  saltlen,
char *  salted_password,
char *  client_key,
char *  server_key,
char *  stored_key 
)

gsasl_scram_secrets_from_password:

Parameters
hasha Gsasl_hash element, e.g., GSASL_HASH_SHA256.
passwordinput parameter with password.
iteration_countnumber of PBKDF2 rounds to apply.
saltinput character array of @saltlen length with salt for PBKDF2.
saltlenlength of @salt.
salted_passwordpre-allocated output array with derived salted password.
client_keypre-allocated output array with derived client key.
server_keypre-allocated output array with derived server key.
stored_keypre-allocated output array with derived stored key.

Helper function to generate SCRAM secrets from a password. The @salted_password, @client_key, @server_key, and @stored_key buffers must have room to hold digest for given @hash, use GSASL_HASH_MAX_SIZE which is sufficient for all hashes.

Return value: Returns GSASL_OK if successful, or error code.

Since: 1.10

Definition at line 156 of file crypto.c.

◆ gsasl_scram_secrets_from_salted_password()

_GSASL_API int gsasl_scram_secrets_from_salted_password ( Gsasl_hash  hash,
const char *  salted_password,
char *  client_key,
char *  server_key,
char *  stored_key 
)

gsasl_scram_secrets_from_salted_password:

Parameters
hasha Gsasl_hash element, e.g., GSASL_HASH_SHA256.
salted_passwordinput array with salted password.
client_keypre-allocated output array with derived client key.
server_keypre-allocated output array with derived server key.
stored_keypre-allocated output array with derived stored key.

Helper function to derive SCRAM ClientKey/ServerKey/StoredKey. The @client_key, @server_key, and @stored_key buffers must have room to hold digest for given @hash, use GSASL_HASH_MAX_SIZE which is sufficient for all hashes.

Return value: Returns GSASL_OK if successful, or error code.

Since: 1.10

Definition at line 104 of file crypto.c.

◆ gsasl_server_mechlist()

_GSASL_API int gsasl_server_mechlist ( Gsasl ctx,
char **  out 
)

gsasl_server_mechlist:

Parameters
ctxlibgsasl handle.
outnewly allocated output character array.

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.

Return value: Returns GSASL_OK if successful, or error code.

Definition at line 94 of file listmech.c.

◆ gsasl_server_start()

_GSASL_API int gsasl_server_start ( Gsasl ctx,
const char *  mech,
Gsasl_session **  sctx 
)

gsasl_server_start:

Parameters
ctxlibgsasl handle.
mechname of SASL mechanism.
sctxpointer to server handle.

This functions initiates a server SASL authentication. This function must be called before any other gsasl_server_*() function is called.

Return value: Returns GSASL_OK if successful, or error code.

Definition at line 138 of file xstart.c.

◆ gsasl_server_support_p()

_GSASL_API int gsasl_server_support_p ( Gsasl ctx,
const char *  name 
)

gsasl_server_support_p:

Parameters
ctxlibgsasl handle.
namename of SASL mechanism.

Decide whether there is server-side support for a specified mechanism.

Return value: Returns 1 if the libgsasl server supports the named mechanism, otherwise 0.

Definition at line 67 of file supportp.c.

◆ gsasl_session_hook_get()

_GSASL_API void* gsasl_session_hook_get ( Gsasl_session sctx)

gsasl_session_hook_get:

Parameters
sctxlibgsasl session handle.

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.

Return value: Returns the application specific data, or NULL.

Since: 0.2.14

Definition at line 160 of file callback.c.

◆ gsasl_session_hook_set()

_GSASL_API void gsasl_session_hook_set ( Gsasl_session sctx,
void *  hook 
)

gsasl_session_hook_set:

Parameters
sctxlibgsasl session handle.
hookopaque pointer to application specific data.

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.

Since: 0.2.14

Definition at line 140 of file callback.c.

◆ gsasl_simple_getpass()

_GSASL_API int gsasl_simple_getpass ( const char *  filename,
const char *  username,
char **  key 
)

gsasl_simple_getpass:

Parameters
filenamefilename of file containing passwords.
usernameusername string.
keynewly allocated output character array.

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.

Return value: Return GSASL_OK if output buffer contains the password, GSASL_AUTHENTICATION_ERROR if the user could not be found, or other error code.

Definition at line 48 of file md5pwd.c.

◆ gsasl_step()

_GSASL_API int gsasl_step ( Gsasl_session sctx,
const char *  input,
size_t  input_len,
char **  output,
size_t *  output_len 
)

gsasl_step:

Parameters
sctxlibgsasl session handle.
inputinput byte array.
input_lensize of input byte array.
outputnewly allocated output byte array.
output_lenpointer to output variable with size of output byte array.

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 gsasl_free(@output).

Return value: Returns GSASL_OK if authenticated terminated successfully, GSASL_NEEDS_MORE if more data is needed, or error code.

Definition at line 52 of file xstep.c.

◆ gsasl_step64()

_GSASL_API int gsasl_step64 ( Gsasl_session sctx,
const char *  b64input,
char **  b64output 
)

gsasl_step64:

Parameters
sctxlibgsasl client handle.
b64inputinput base64 encoded byte array.
b64outputnewly allocated output base64 encoded byte array.

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 gsasl_free(@b64output).

Return value: Returns GSASL_OK if authenticated terminated successfully, GSASL_NEEDS_MORE if more data is needed, or error code.

Definition at line 87 of file xstep.c.

◆ gsasl_strerror()

_GSASL_API const char* gsasl_strerror ( int  err)

gsasl_strerror:

Parameters
errlibgsasl error code

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().

Return value: Returns a pointer to a statically allocated string containing an explanation of the error code @err.

Definition at line 185 of file error.c.

◆ gsasl_strerror_name()

_GSASL_API const char* gsasl_strerror_name ( int  err)

gsasl_strerror_name:

Parameters
errlibgsasl error code

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().

Return value: 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

Definition at line 223 of file error.c.