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