~ubuntu-branches/ubuntu/oneiric/jabberd2/oneiric-security

« back to all changes in this revision

Viewing changes to sx/scod/scod.h

  • Committer: Bazaar Package Importer
  • Author(s): Nicolai Spohrer
  • Date: 2008-08-12 16:13:43 UTC
  • mfrom: (1.1.3 upstream) (0.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20080812161343-6trz3r97dtevxd17
Tags: 2.2.1-1ubuntu1
* Merge with Debian unstable (LP: #257130), remaining changes:
  - debian/control:
    + Modify Maintainer field as per spec
    + Depend on libdb4.6-dev instead of libdb4.4-dev
    + Added Conflicts and Replaces: ..., jabber for jabberd2
  - debian/rules: Added libtoolize call (jabberd2 ships with
     an older ltmain.sh version that conflicts with the
     current libtool version)
  - debian/init: create /var/run/jabber directory with correct
     permissions
* Dropped changes:
  - Debian already depends on libpq-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * scod - a minimal sasl implementation for jabberd2
 
3
 * Copyright (c) 2003 Robert Norris
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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
 
18
 */
 
19
 
 
20
#ifndef INCL_SCOD_H
 
21
#define INCL_SCOD_H
 
22
 
 
23
#include "util/util.h"
 
24
 
 
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;
 
28
 
 
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)
 
34
 
 
35
typedef int (*scod_callback_t)(scod_t sd, int cb, void *arg, void **res, void *cbarg);
 
36
 
 
37
typedef struct _scod_cb_creds_st {
 
38
    char        *authnid;
 
39
    char        *realm;
 
40
    char        *pass;
 
41
    char        *authzid;
 
42
} *scod_cb_creds_t;
 
43
 
 
44
struct _scod_ctx_st {
 
45
    scod_callback_t cb;
 
46
    void            *cbarg;
 
47
 
 
48
    scod_mech_t     *mechs;
 
49
    int             nmechs;
 
50
 
 
51
    char            **names;
 
52
};
 
53
 
 
54
typedef enum {
 
55
    sd_type_NONE = 0,
 
56
    sd_type_CLIENT = 1,
 
57
    sd_type_SERVER = 2
 
58
} scod_type_t;
 
59
 
 
60
struct _scod_st {
 
61
    scod_ctx_t      ctx;
 
62
 
 
63
    scod_type_t     type;
 
64
 
 
65
    scod_mech_t     mech;
 
66
 
 
67
    void            *mech_data;
 
68
 
 
69
    char            *authzid;
 
70
    char            *authnid;
 
71
    char            *pass;
 
72
 
 
73
    char            *realm;
 
74
 
 
75
    int             authd;
 
76
    int             failed;
 
77
 
 
78
    void            *app_private;
 
79
};
 
80
 
 
81
#define sd_flag_CHECK_PASS      (0x01)
 
82
#define sd_flag_GET_PASS        (0x02)
 
83
 
 
84
struct _scod_mech_st {
 
85
    scod_ctx_t      ctx;
 
86
 
 
87
    void            *private;
 
88
 
 
89
    char            *name;
 
90
 
 
91
    int             flags;
 
92
 
 
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);
 
95
 
 
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);
 
98
 
 
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);
 
101
 
 
102
    void            (*free)(scod_mech_t mech);
 
103
};
 
104
 
 
105
typedef int (*scod_mech_init_fn)(scod_mech_t);
 
106
 
 
107
scod_ctx_t  scod_ctx_new(scod_callback_t cb, void *cbarg);
 
108
void        scod_ctx_free(scod_ctx_t ctx);
 
109
 
 
110
int         scod_mech_flags(scod_ctx_t ctx, char *name);
 
111
 
 
112
scod_t      scod_new(scod_ctx_t ctx, scod_type_t type);
 
113
void        scod_free(scod_t sd);
 
114
 
 
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);
 
117
 
 
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);
 
120
 
 
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);
 
123
 
 
124
#define sd_SUCCESS                  (0x00)
 
125
#define sd_CONTINUE                 (0x01)
 
126
 
 
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)
 
134
 
 
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)
 
143
 
 
144
#endif