sasl2_sys/
saslutil.rs

1// Copyright Materialize, Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License in the LICENSE file at the
6// root of this repository, or online at
7//
8//     http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16//! SASL utility functions.
17
18use libc::{c_char, c_int, c_uint};
19
20use super::sasl::{sasl_conn_t, sasl_rand_t};
21
22extern "C" {
23    pub fn sasl_decode64(
24        in_: *const c_char,
25        inlen: c_uint,
26        out: *mut c_char,
27        outmax: c_uint,
28        outlen: *mut c_uint,
29    ) -> c_int;
30
31    pub fn sasl_encode64(
32        in_: *const c_char,
33        inlen: c_uint,
34        out: *mut c_char,
35        outmax: c_uint,
36        outlen: *mut c_uint,
37    ) -> c_int;
38
39    pub fn sasl_mkchal(
40        conn: *mut sasl_conn_t,
41        buf: *mut c_char,
42        maxlen: c_uint,
43        hostflag: c_uint,
44    ) -> c_int;
45
46    pub fn sasl_utf8verify(str: *const c_char, len: c_uint) -> c_int;
47
48    pub fn sasl_randcreate(rpool: *mut *mut sasl_rand_t) -> c_int;
49
50    pub fn sasl_randfree(rpool: *mut *mut sasl_rand_t);
51
52    pub fn sasl_randseed(rpool: *mut sasl_rand_t, seed: *const c_char, len: c_uint);
53
54    pub fn sasl_rand(rpool: *mut sasl_rand_t, buf: *mut c_char, len: c_uint);
55
56    pub fn sasl_churn(rpool: *mut sasl_rand_t, data: *const c_char, len: c_uint);
57
58    pub fn sasl_erasebuffer(pass: *mut c_char, len: c_uint);
59
60    // Apparently missing in the libsasl2 shipped with macOS .
61    #[cfg(not(all(target_os = "macos", not(feature = "vendored"))))]
62    pub fn sasl_strlower(val: *mut c_char) -> *mut c_char;
63
64    pub fn sasl_config_init(filename: *const c_char) -> c_int;
65
66    pub fn sasl_config_done();
67}