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