]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/gcrypt-util.h
tree-wide: beautify remaining copyright statements
[thirdparty/systemd.git] / src / basic / gcrypt-util.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
91e023d8
ZJS
2
3/***
96b2fb93 4 Copyright © 2016 Zbigniew Jędrzejewski-Szmek
91e023d8
ZJS
5***/
6
bd944e6e
ZJS
7#pragma once
8
b68f10bf 9#include <errno.h>
91e023d8 10#include <stdbool.h>
b68f10bf
ZJS
11#include <stddef.h>
12
349cc4a5 13#if HAVE_GCRYPT
b68f10bf 14#include <gcrypt.h>
91e023d8 15
bd944e6e
ZJS
16#include "macro.h"
17
91e023d8 18void initialize_libgcrypt(bool secmem);
4ac2ca1b 19int string_hashsum(const char *s, size_t len, int md_algorithm, char **out);
bd944e6e
ZJS
20
21DEFINE_TRIVIAL_CLEANUP_FUNC(gcry_md_hd_t, gcry_md_close);
b68f10bf
ZJS
22#endif
23
24static inline int string_hashsum_sha224(const char *s, size_t len, char **out) {
349cc4a5 25#if HAVE_GCRYPT
b68f10bf
ZJS
26 return string_hashsum(s, len, GCRY_MD_SHA224, out);
27#else
28 return -EOPNOTSUPP;
29#endif
30}
a60f4d0b
SS
31
32static inline int string_hashsum_sha256(const char *s, size_t len, char **out) {
349cc4a5 33#if HAVE_GCRYPT
a60f4d0b
SS
34 return string_hashsum(s, len, GCRY_MD_SHA256, out);
35#else
36 return -EOPNOTSUPP;
37#endif
38}