chiark / gitweb /
fs-util: add new CHASE_NON_EXISTING flag to chase_symlinks()
[elogind.git] / src / basic / khash.h
1 #pragma once
2
3 /***
4   This file is part of elogind.
5
6   Copyright 2016 Lennart Poettering
7
8   elogind is free software; you can redistribute it and/or modify it
9   under the terms of the GNU Lesser General Public License as published by
10   the Free Software Foundation; either version 2.1 of the License, or
11   (at your option) any later version.
12
13   elogind is distributed in the hope that it will be useful, but
14   WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   Lesser General Public License for more details.
17
18   You should have received a copy of the GNU Lesser General Public License
19   along with elogind; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include <inttypes.h>
23 #include <sys/types.h>
24 #include <sys/uio.h>
25
26 #include "macro.h"
27
28 typedef struct khash khash;
29
30 /* For plain hash functions. Hash functions commonly supported on today's kernels are: crc32c, crct10dif, crc32,
31  * sha224, sha256, sha512, sha384, sha1, md5, md4, sha3-224, sha3-256, sha3-384, sha3-512, and more.*/
32 int khash_new(khash **ret, const char *algorithm);
33
34 /* For keyed hash functions. Hash functions commonly supported on today's kernels are: hmac(sha256), cmac(aes),
35  * cmac(des3_ede), hmac(sha3-512), hmac(sha3-384), hmac(sha3-256), hmac(sha3-224), hmac(rmd160), hmac(rmd128),
36  * hmac(sha224), hmac(sha512), hmac(sha384), hmac(sha1), hmac(md5), and more. */
37 int khash_new_with_key(khash **ret, const char *algorithm, const void *key, size_t key_size);
38
39 int khash_dup(khash *h, khash **ret);
40 khash* khash_unref(khash *h);
41
42 const char *khash_get_algorithm(khash *h);
43 size_t khash_get_size(khash *h);
44
45 int khash_reset(khash *h);
46
47 int khash_put(khash *h, const void *buffer, size_t size);
48 int khash_put_iovec(khash *h, const struct iovec *iovec, size_t n);
49
50 int khash_digest_data(khash *h, const void **ret);
51 int khash_digest_string(khash *h, char **ret);
52
53 DEFINE_TRIVIAL_CLEANUP_FUNC(khash*, khash_unref);