gsasl  2.2.1
mechtools.h
Go to the documentation of this file.
1 /* mechtools.h --- Helper functions available for use by any mechanism.
2  * Copyright (C) 2010-2024 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 along with GNU SASL Library; if not, write to the Free
18  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef MECHTOOLS_H
24 # define MECHTOOLS_H
25 
26 /* Get size_t. */
27 # include <stddef.h>
28 
29 /* Get bool. */
30 # include <stdbool.h>
31 
32 # include <gsasl.h>
33 
34 extern int _gsasl_parse_gs2_header (const char *data, size_t len,
35  char **authzid, size_t *headerlen);
36 
37 extern int _gsasl_gs2_generate_header (bool nonstd, char cbflag,
38  const char *cbname,
39  const char *authzid, size_t extralen,
40  const char *extra, char **gs2h,
41  size_t *gs2hlen);
42 
43 extern void _gsasl_hex_encode (const char *in, size_t inlen, char *out);
44 extern void _gsasl_hex_decode (const char *hexstr, char *bin);
45 extern bool _gsasl_hex_p (const char *hexstr);
46 
47 extern int _gsasl_hash (Gsasl_hash hash,
48  const char *in, size_t inlen, char *out);
49 extern int _gsasl_hmac (Gsasl_hash hash,
50  const char *key, size_t keylen,
51  const char *in, size_t inlen, char *outhash);
52 
53 extern int _gsasl_pbkdf2 (Gsasl_hash hash,
54  const char *password,
55  size_t passwordlen,
56  const char *salt,
57  size_t saltlen,
58  unsigned int c, char *dk, size_t dklen);
59 
60 #endif
Gsasl_hash
Definition: gsasl.h:428
void _gsasl_hex_decode(const char *hexstr, char *bin)
Definition: mechtools.c:256
int _gsasl_hmac(Gsasl_hash hash, const char *key, size_t keylen, const char *in, size_t inlen, char *outhash)
Definition: mechtools.c:329
int _gsasl_parse_gs2_header(const char *data, size_t len, char **authzid, size_t *headerlen)
Definition: mechtools.c:97
int _gsasl_gs2_generate_header(bool nonstd, char cbflag, const char *cbname, const char *authzid, size_t extralen, const char *extra, char **gs2h, size_t *gs2hlen)
Definition: mechtools.c:166
int _gsasl_pbkdf2(Gsasl_hash hash, const char *password, size_t passwordlen, const char *salt, size_t saltlen, unsigned int c, char *dk, size_t dklen)
Definition: mechtools.c:368
bool _gsasl_hex_p(const char *hexstr)
Definition: mechtools.c:268
int _gsasl_hash(Gsasl_hash hash, const char *in, size_t inlen, char *out)
Definition: mechtools.c:296
void _gsasl_hex_encode(const char *in, size_t inlen, char *out)
Definition: mechtools.c:221