sasl.h 3.78 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
/*
 * Copyright 2022 Hans Leidekker for CodeWeavers
 *
 * Minimal compatible sasl.h header
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#ifndef SASL_H
#define SASL_H 1

#define SASL_VERSION_MAJOR 2
#define SASL_VERSION_MINOR 1

#define SASL_CONTINUE   1
#define SASL_INTERACT   2
#define SASL_OK         0
#define SASL_FAIL      -1
#define SASL_NOMEM     -2
#define SASL_BUFOVER   -3
#define SASL_NOMECH    -4
#define SASL_BADPROT   -5
#define SASL_NOTDONE   -6
#define SASL_BADPARAM  -7
#define SASL_TRYAGAIN  -8
#define SASL_BADMAC    -9
#define SASL_BADSERV   -10
#define SASL_WRONGMECH -11
#define SASL_NOTINIT   -12
#define SASL_BADAUTH   -13
#define SASL_NOAUTHZ   -14
#define SASL_TOOWEAK   -15
#define SASL_ENCRYPT   -16

typedef unsigned int sasl_ssf_t;

#define SASL_SEC_NOPLAINTEXT        0x0001
#define SASL_SEC_NOACTIVE           0x0002
#define SASL_SEC_NODICTIONARY       0x0004
#define SASL_SEC_FORWARD_SECRECY    0x0008
#define SASL_SEC_NOANONYMOUS        0x0010
#define SASL_SEC_PASS_CREDENTIALS   0x0020
#define SASL_SEC_MUTUAL_AUTH        0x0040
#define SASL_SEC_MAXIMUM            0x00FF

typedef struct sasl_security_properties
{
    sasl_ssf_t min_ssf;
    sasl_ssf_t max_ssf;
    unsigned int maxbufsize;
    unsigned int security_flags;
    const char **property_names;
    const char **property_values;
} sasl_security_properties_t;

#define SASL_CB_LIST_END        0
#define SASL_CB_USER            0x4001
#define SASL_CB_AUTHNAME        0x4002
#define SASL_CB_PASS            0x4004
#define SASL_CB_ECHOPROMPT      0x4005
#define SASL_CB_NOECHOPROMPT    0x4006
#define SASL_CB_GETREALM        0x4008

typedef struct sasl_callback
{
    unsigned long id;
    int (*proc)(void);
    void *context;
} sasl_callback_t;

typedef struct sasl_interact
{
    unsigned long id;
    const char *challenge;
    const char *prompt;
    const char *defresult;
    const void *result;
    unsigned len;
} sasl_interact_t;

#define SASL_USERNAME   0
#define SASL_SSF        1
#define SASL_MAXOUTBUF  2

typedef struct sasl_conn sasl_conn_t;

#define SASL_SSF_EXTERNAL  100
#define SASL_SEC_PROPS     101
#define SASL_AUTH_EXTERNAL 102

int sasl_client_init(const sasl_callback_t *);
int sasl_client_new(const char *, const char *, const char *, const char *, const sasl_callback_t *,
                    unsigned int, sasl_conn_t **);
int sasl_client_start(sasl_conn_t *conn, const char *, sasl_interact_t **, const char **, unsigned int *,
                      const char **);
int sasl_client_step(sasl_conn_t *conn, const char *, unsigned int, sasl_interact_t **, const char **,
                     unsigned int *);
int sasl_decode(sasl_conn_t *, const char *, unsigned int, const char **, unsigned int *);
void sasl_dispose(sasl_conn_t **);
int sasl_encode(sasl_conn_t *, const char *, unsigned int, const char **, unsigned int *);
const char *sasl_errdetail(sasl_conn_t *);
const char *sasl_errstring(int, const char *, const char **);
int sasl_getprop(sasl_conn_t *, int, const void **);
const char **sasl_global_listmech(void);
void sasl_set_mutex(void *, void *, void *, void *);
int sasl_setprop(sasl_conn_t *, int, const void *);

#endif /* SASL_H */