2
* scod - a minimal sasl implementation for jabberd2
3
* Copyright (c) 2003 Robert Norris
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
23
#include "util/util.h"
25
typedef struct _scod_ctx_st *scod_ctx_t;
26
typedef struct _scod_st *scod_t;
27
typedef struct _scod_mech_st *scod_mech_t;
29
#define sd_cb_GET_PASS (0x00)
30
#define sd_cb_CHECK_PASS (0x01)
31
#define sd_cb_CHECK_AUTHZID (0x02)
32
#define sd_cb_DIGEST_MD5_CHOOSE_REALM (0x03)
33
#define sd_cb_ANONYMOUS_GEN_AUTHZID (0x04)
35
typedef int (*scod_callback_t)(scod_t sd, int cb, void *arg, void **res, void *cbarg);
37
typedef struct _scod_cb_creds_st {
81
#define sd_flag_CHECK_PASS (0x01)
82
#define sd_flag_GET_PASS (0x02)
84
struct _scod_mech_st {
93
int (*client_start)(scod_mech_t mech, scod_t sd, char **resp, int *resplen);
94
int (*client_step)(scod_mech_t mech, scod_t sd, const char *chal, int challen, char **resp, int *resplen);
96
int (*server_start)(scod_mech_t mech, scod_t sd, const char *resp, int resplen, char **chal, int *challen);
97
int (*server_step)(scod_mech_t mech, scod_t sd, const char *resp, int resplen, char **chal, int *challen);
99
int (*encode)(scod_mech_t mech, scod_t sd, const char *in, int inlen, char **out, char *outlen);
100
int (*decode)(scod_mech_t mech, scod_t sd, const char *in, int inlen, char **out, char *outlen);
102
void (*free)(scod_mech_t mech);
105
typedef int (*scod_mech_init_fn)(scod_mech_t);
107
scod_ctx_t scod_ctx_new(scod_callback_t cb, void *cbarg);
108
void scod_ctx_free(scod_ctx_t ctx);
110
int scod_mech_flags(scod_ctx_t ctx, char *name);
112
scod_t scod_new(scod_ctx_t ctx, scod_type_t type);
113
void scod_free(scod_t sd);
115
int scod_client_start(scod_t sd, char *name, char *authzid, char *authnid, char *pass, char **resp, int *resplen);
116
int scod_client_step(scod_t sd, const char *chal, int challen, char **resp, int *resplen);
118
int scod_server_start(scod_t sd, char *name, char *realm, const char *resp, int resplen, char **chal, int *challen);
119
int scod_server_step(scod_t sd, const char *resp, int resplen, char **chal, int *challen);
121
int scod_sasl_encode(scod_t sd, const char *in, int inlen, char **out, char *outlen);
122
int scod_sasl_decode(scod_t sd, const char *in, int inlen, char **out, char *outlen);
124
#define sd_SUCCESS (0x00)
125
#define sd_CONTINUE (0x01)
127
#define sd_err_NOT_IMPLEMENTED (0x10)
128
#define sd_err_IN_PROGRESS (0x11)
129
#define sd_err_WRONG_TYPE (0x12)
130
#define sd_err_UNKNOWN_MECH (0x13)
131
#define sd_err_COMPLETED (0x14)
132
#define sd_err_OPTS_REQUIRED (0x15)
133
#define sd_err_MASK (0x10)
135
#define sd_auth_USER_UNKNOWN (0x20)
136
#define sd_auth_AUTH_FAILED (0x21)
137
#define sd_auth_MALFORMED_DATA (0x22)
138
#define sd_auth_AUTHZID_REQUIRED (0x23)
139
#define sd_auth_MISMATCH (0x24)
140
#define sd_auth_NOT_OFFERED (0x25)
141
#define sd_auth_AUTHZID_POLICY (0x26)
142
#define sd_auth_MASK (0x20)