2 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
7 * saslutil.h -- various utility functions in SASL library
10 #ifndef _SASL_SASLUTIL_H
11 #define _SASL_SASLUTIL_H
13 #pragma ident "%Z%%M% %I% %E% SMI"
16 #include <sasl/sasl.h>
26 * inlen -- length of input data
27 * out -- output data (may be same as in, must have enough space)
28 * outmax -- max size of output buffer
30 * outlen -- actual output length
32 * returns SASL_BADPROT on bad base64,
33 * SASL_BUFOVER if result won't fit
36 LIBSASL_API
int sasl_decode64(const char *in
, unsigned inlen
,
37 char *out
, unsigned outmax
, unsigned *outlen
);
42 * inlen -- input data length
43 * out -- output buffer (will be NUL terminated)
44 * outmax -- max size of output buffer
46 * outlen -- gets actual length of output buffer (optional)
48 * Returns SASL_OK on success, SASL_BUFOVER if result won't fit
50 LIBSASL_API
int sasl_encode64(const char *in
, unsigned inlen
,
51 char *out
, unsigned outmax
, unsigned *outlen
);
55 * The following is not supported:
57 * make a challenge string (NUL terminated)
58 * buf -- buffer for result
59 * maxlen -- max length of result
60 * hostflag -- 0 = don't include hostname, 1 = include hostname
61 * returns final length or 0 if not enough space
63 LIBSASL_API
int sasl_mkchal(sasl_conn_t
*conn
, char *buf
,
64 unsigned maxlen
, unsigned hostflag
);
68 * verify a string is valid UTF-8
69 * if len == 0, strlen(str) will be used.
70 * returns SASL_BADPROT on error, SASL_OK on success
72 LIBSASL_API
int sasl_utf8verify(const char *str
, unsigned len
);
75 /* The following are not supported */
77 /* create random pool seeded with OS-based params */
78 LIBSASL_API
int sasl_randcreate(sasl_rand_t
**rpool
);
80 /* free random pool from randcreate */
81 LIBSASL_API
void sasl_randfree(sasl_rand_t
**rpool
);
83 /* seed random number generator */
84 LIBSASL_API
void sasl_randseed(sasl_rand_t
*rpool
, const char *seed
,
87 /* generate random octets */
88 LIBSASL_API
void sasl_rand(sasl_rand_t
*rpool
, char *buf
, unsigned len
);
90 /* churn data into random number generator */
91 LIBSASL_API
void sasl_churn(sasl_rand_t
*rpool
, const char *data
,
96 * erase a security sensitive buffer or password.
97 * Implementation may use recovery-resistant erase logic.
99 LIBSASL_API
void sasl_erasebuffer(char *pass
, unsigned len
);
105 #endif /* _SASL_SASLUTIL_H */