1/* gsasl-mech.h --- Header file for mechanism handling in GNU SASL Library.
2 * Copyright (C) 2002-2012 Simon Josefsson
3 *
4 * This file is part of GNU SASL Library.
5 *
6 * GNU SASL Library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
10 *
11 * GNU SASL Library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License License along with GNU SASL Library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#ifndef GSASL_MECH_H
24#define GSASL_MECH_H
25
26/* Mechanism function prototypes. */
27typedef int (*Gsasl_init_function) (Gsasl * ctx);
28typedef void (*Gsasl_done_function) (Gsasl * ctx);
29typedef int (*Gsasl_start_function) (Gsasl_session * sctx, void **mech_data);
30typedef int (*Gsasl_step_function) (Gsasl_session * sctx, void *mech_data,
31 const char *input, size_t input_len,
32 char **output, size_t * output_len);
33typedef void (*Gsasl_finish_function) (Gsasl_session * sctx, void *mech_data);
34typedef int (*Gsasl_code_function) (Gsasl_session * sctx, void *mech_data,
35 const char *input, size_t input_len,
36 char **output, size_t * output_len);
37
38/* Collection of mechanism functions for either client or server. */
39struct Gsasl_mechanism_functions
40{
41 Gsasl_init_function init;
42 Gsasl_done_function done;
43 Gsasl_start_function start;
44 Gsasl_step_function step;
45 Gsasl_finish_function finish;
46 Gsasl_code_function encode;
47 Gsasl_code_function decode;
48};
49typedef struct Gsasl_mechanism_functions Gsasl_mechanism_functions;
50
51/* Information about a mechanism. */
52struct Gsasl_mechanism
53{
54 const char *name;
55
56 struct Gsasl_mechanism_functions client;
57 struct Gsasl_mechanism_functions server;
58};
59typedef struct Gsasl_mechanism Gsasl_mechanism;
60
61/* Register new mechanism: register.c. */
62extern GSASL_API int gsasl_register (Gsasl * ctx,
63 const Gsasl_mechanism * mech);
64
65#endif /* GSASL_MECH_H */
66