char * gsasl_stringprep_nfkc
(const char * in, ssize_t len)
in: a UTF-8 encoded string.
len: length of str, in bytes, or -1 if str is nul-terminated.
Converts a string into canonical form, standardizing such issues as whether a character with an accent is represented as a base character and combining accent or as a single precomposed character.
The normalization mode is NFKC (ALL COMPOSE). It standardizes differences that do not affect the text content, such as the above-mentioned accent representation. It standardizes the "compatibility" characters in Unicode, such as SUPERSCRIPT THREE to the standard forms (in this case DIGIT THREE). Formatting information may be lost but for most text operations such characters should be considered the same. It returns a result with composed forms rather than a maximally decomposed form.
Return value: Return a newly allocated string, that is the NFKC normalized form of str, o NULL on error.
char * gsasl_stringprep_saslprep
(const char * in, int * stringprep_rc)
in: input ASCII or UTF-8 string with data to prepare according to SASLprep.
stringprep_rc: pointer to output variable with stringprep error code, or NULL to indicate that you don't care about it.
Process a Unicode string for comparison, according to the "SASLprep" stringprep profile. This function is intended to be used by Simple Authentication and Security Layer (SASL) mechanisms (such as PLAIN, CRAM-MD5, and DIGEST-MD5) as well as other protocols exchanging user names and/or passwords.
Return value: Return a newly allocated string that is the "SASLprep" processed form of the input string, or NULL on error, in which case stringprep_rc contain the stringprep library error code.
char * gsasl_stringprep_trace
(const char * in, int * stringprep_rc)
in: input ASCII or UTF-8 string with data to prepare according to "trace".
stringprep_rc: pointer to output variable with stringprep error code, or NULL to indicate that you don't care about it.
Process a Unicode string for use as trace information, according to the "trace" stringprep profile. The profile is designed for use with the SASL ANONYMOUS Mechanism.
Return value: Return a newly allocated string that is the "trace" processed form of the input string, or NULL on error, in which case stringprep_rc contain the stringprep library error code.
int gsasl_base64_encode
(char const * src, size_t srclength, char * target, size_t targsize)
src: input byte array
srclength: size of input byte array
target: output byte array
targsize: size of output byte array
Encode data as base64. Converts characters, three at a time, starting at src into four base64 characters in the target area until the entire input buffer is encoded.
Return value: Returns the number of data bytes stored at the target, or -1 on error.
int gsasl_base64_decode
(char const * src, char * target, size_t targsize)
src: input byte array
target: output byte array
targsize: size of output byte array
Decode Base64 data. Skips all whitespace anywhere. Converts characters, four at a time, starting at (or after) src from Base64 numbers into three 8 bit bytes in the target area.
Return value: Returns the number of data bytes stored at the target, or -1 on error.
int gsasl_md5pwd_get_password
(const char * filename, const char * username, char * key, size_t * keylen)
filename: filename of file containing passwords.
username: username string.
key: output character array.
keylen: input maximum size of output character array, on output contains actual length of output array.
Retrieve password for user from specified file. To find out how large the output array must be, call this function with out=NULL.
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 username\tpassword. This function removes \r and \n at the end of lines before processing.
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.
int gsasl_randomize
(int strong, char * data, size_t datalen)
strong: 0 iff operation should not block, non-0 for very strong randomness.
data: output array to be filled with random data.
datalen: size of output array.
Store cryptographically random data of given size in the provided buffer.
Return value: Returns GSASL_OK iff successful.
int gsasl_md5
(const char * in, size_t inlen, char * out[MD5_DIGEST_SIZE])
in: input character array of data to hash.
inlen: length of input character array of data to hash.
Compute hash of data using MD5. The out buffer must be deallocated by the caller.
Return value: Returns GSASL_OK iff successful.
int gsasl_hmac_md5
(const char * key, size_t keylen, const char * in, size_t inlen, char * outhash[MD5_DIGEST_SIZE])
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.
Compute keyed checksum of data using HMAC-MD5. The outhash buffer must be deallocated by the caller.
Return value: Returns GSASL_OK iff successful.