de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen#ifndef DSASL_CLIENT_H
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen#define DSASL_CLIENT_H
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainenstruct dsasl_client_settings {
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen /* authentication ID - must be set with most mechanisms */
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen const char *authid;
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen /* authorization ID (who to log in as, if authentication ID is a
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen master user) */
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen const char *authzid;
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen /* password - must be set with most mechanisms */
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen const char *password;
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen};
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen/* PLAIN mechanism always exists and can be accessed directly via this. */
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainenextern const struct dsasl_client_mech dsasl_client_mech_plain;
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainenconst struct dsasl_client_mech *dsasl_client_mech_find(const char *name);
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainenconst char *dsasl_client_mech_get_name(const struct dsasl_client_mech *mech);
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainenstruct dsasl_client *dsasl_client_new(const struct dsasl_client_mech *mech,
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen const struct dsasl_client_settings *set);
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainenvoid dsasl_client_free(struct dsasl_client **client);
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen/* Call for server input. */
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainenint dsasl_client_input(struct dsasl_client *client,
a669d351502e15802b121e1a0bd83f27d1d95f01Timo Sirainen const unsigned char *input, size_t input_len,
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen const char **error_r);
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen/* Call for getting server output. Also used to get the initial SASL response
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen if supported by the protocol. */
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainenint dsasl_client_output(struct dsasl_client *client,
a669d351502e15802b121e1a0bd83f27d1d95f01Timo Sirainen const unsigned char **output_r, size_t *output_len_r,
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen const char **error_r);
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen
2d74a1ed4c9da3d8b0f2eb0fc45d74376c9c22a7Aki Tuomi/* Call for setting extra parameters for authentication, these are mechanism
211c638d81d382517d196ad47565e0d85012c927klemens dependent. -1 = error, 0 = not found, 1 = ok
2d74a1ed4c9da3d8b0f2eb0fc45d74376c9c22a7Aki Tuomi value can be NULL. */
2d74a1ed4c9da3d8b0f2eb0fc45d74376c9c22a7Aki Tuomiint dsasl_client_set_parameter(struct dsasl_client *client,
2d74a1ed4c9da3d8b0f2eb0fc45d74376c9c22a7Aki Tuomi const char *param, const char *value,
2d74a1ed4c9da3d8b0f2eb0fc45d74376c9c22a7Aki Tuomi const char **error_r) ATTR_NULL(3);
2d74a1ed4c9da3d8b0f2eb0fc45d74376c9c22a7Aki Tuomi
2d74a1ed4c9da3d8b0f2eb0fc45d74376c9c22a7Aki Tuomi/* Call for getting extra result information.
2d74a1ed4c9da3d8b0f2eb0fc45d74376c9c22a7Aki Tuomi -1 = error, 0 = not found, 1 = ok */
2d74a1ed4c9da3d8b0f2eb0fc45d74376c9c22a7Aki Tuomiint dsasl_client_get_result(struct dsasl_client *client,
2d74a1ed4c9da3d8b0f2eb0fc45d74376c9c22a7Aki Tuomi const char *key, const char **value_r,
2d74a1ed4c9da3d8b0f2eb0fc45d74376c9c22a7Aki Tuomi const char **error_r);
2d74a1ed4c9da3d8b0f2eb0fc45d74376c9c22a7Aki Tuomi
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainenvoid dsasl_clients_init(void);
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainenvoid dsasl_clients_deinit(void);
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen
de754cb78f75e8b3b994cddafe41c9ed1467c33dTimo Sirainen#endif