]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
0fe5f3c5 LP |
2 | #pragma once |
3 | ||
4 | /*** | |
0fe5f3c5 | 5 | Copyright 2016 Lennart Poettering |
0fe5f3c5 LP |
6 | ***/ |
7 | ||
8 | #include <inttypes.h> | |
9 | #include <sys/types.h> | |
10 | #include <sys/uio.h> | |
11 | ||
12 | #include "macro.h" | |
13 | ||
14 | typedef struct khash khash; | |
15 | ||
09b9348e LP |
16 | int khash_supported(void); |
17 | ||
0fe5f3c5 | 18 | /* For plain hash functions. Hash functions commonly supported on today's kernels are: crc32c, crct10dif, crc32, |
13e785f7 | 19 | * sha224, sha256, sha512, sha384, sha1, md5, md4, sha3-224, sha3-256, sha3-384, sha3-512, and more. */ |
0fe5f3c5 LP |
20 | int khash_new(khash **ret, const char *algorithm); |
21 | ||
22 | /* For keyed hash functions. Hash functions commonly supported on today's kernels are: hmac(sha256), cmac(aes), | |
23 | * cmac(des3_ede), hmac(sha3-512), hmac(sha3-384), hmac(sha3-256), hmac(sha3-224), hmac(rmd160), hmac(rmd128), | |
24 | * hmac(sha224), hmac(sha512), hmac(sha384), hmac(sha1), hmac(md5), and more. */ | |
25 | int khash_new_with_key(khash **ret, const char *algorithm, const void *key, size_t key_size); | |
26 | ||
27 | int khash_dup(khash *h, khash **ret); | |
28 | khash* khash_unref(khash *h); | |
29 | ||
30 | const char *khash_get_algorithm(khash *h); | |
31 | size_t khash_get_size(khash *h); | |
32 | ||
33 | int khash_reset(khash *h); | |
34 | ||
35 | int khash_put(khash *h, const void *buffer, size_t size); | |
36 | int khash_put_iovec(khash *h, const struct iovec *iovec, size_t n); | |
37 | ||
38 | int khash_digest_data(khash *h, const void **ret); | |
39 | int khash_digest_string(khash *h, char **ret); | |
40 | ||
41 | DEFINE_TRIVIAL_CLEANUP_FUNC(khash*, khash_unref); |