2N/A/*
2N/A * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A/*
2N/A * saslutil.h -- various utility functions in SASL library
2N/A */
2N/A
2N/A#ifndef _SASL_SASLUTIL_H
2N/A#define _SASL_SASLUTIL_H
2N/A
2N/A#ifndef _SASL_SASL_H
2N/A#include <sasl/sasl.h>
2N/A#endif
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A/*
2N/A * base64 decode
2N/A * in -- input data
2N/A * inlen -- length of input data
2N/A * out -- output data (may be same as in, must have enough space)
2N/A * outmax -- max size of output buffer
2N/A * result:
2N/A * outlen -- actual output length
2N/A *
2N/A * returns SASL_BADPROT on bad base64,
2N/A * SASL_BUFOVER if result won't fit
2N/A * SASL_OK on success
2N/A */
2N/ALIBSASL_API int sasl_decode64(const char *in, unsigned inlen,
2N/A char *out, unsigned outmax, unsigned *outlen);
2N/A
2N/A/*
2N/A * base64 encode
2N/A * in -- input data
2N/A * inlen -- input data length
2N/A * out -- output buffer (will be NUL terminated)
2N/A * outmax -- max size of output buffer
2N/A * result:
2N/A * outlen -- gets actual length of output buffer (optional)
2N/A *
2N/A * Returns SASL_OK on success, SASL_BUFOVER if result won't fit
2N/A */
2N/ALIBSASL_API int sasl_encode64(const char *in, unsigned inlen,
2N/A char *out, unsigned outmax, unsigned *outlen);
2N/A
2N/A#if 0
2N/A/*
2N/A * The following is not supported:
2N/A *
2N/A * make a challenge string (NUL terminated)
2N/A * buf -- buffer for result
2N/A * maxlen -- max length of result
2N/A * hostflag -- 0 = don't include hostname, 1 = include hostname
2N/A * returns final length or 0 if not enough space
2N/A */
2N/ALIBSASL_API int sasl_mkchal(sasl_conn_t *conn, char *buf,
2N/A unsigned maxlen, unsigned hostflag);
2N/A#endif
2N/A
2N/A/*
2N/A * verify a string is valid UTF-8
2N/A * if len == 0, strlen(str) will be used.
2N/A * returns SASL_BADPROT on error, SASL_OK on success
2N/A */
2N/ALIBSASL_API int sasl_utf8verify(const char *str, unsigned len);
2N/A
2N/A#if 0
2N/A/* The following are not supported */
2N/A
2N/A/* create random pool seeded with OS-based params */
2N/ALIBSASL_API int sasl_randcreate(sasl_rand_t **rpool);
2N/A
2N/A/* free random pool from randcreate */
2N/ALIBSASL_API void sasl_randfree(sasl_rand_t **rpool);
2N/A
2N/A/* seed random number generator */
2N/ALIBSASL_API void sasl_randseed(sasl_rand_t *rpool, const char *seed,
2N/A unsigned len);
2N/A
2N/A/* generate random octets */
2N/ALIBSASL_API void sasl_rand(sasl_rand_t *rpool, char *buf, unsigned len);
2N/A
2N/A/* churn data into random number generator */
2N/ALIBSASL_API void sasl_churn(sasl_rand_t *rpool, const char *data,
2N/A unsigned len);
2N/A#endif
2N/A
2N/A/*
2N/A * erase a security sensitive buffer or password.
2N/A * Implementation may use recovery-resistant erase logic.
2N/A */
2N/ALIBSASL_API void sasl_erasebuffer(char *pass, unsigned len);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _SASL_SASLUTIL_H */