Tor 0.4.9.0-alpha-dev
compat_blake2.h
Go to the documentation of this file.
1/* Copyright (c) 2023, The Tor Project, Inc. */
2/* See LICENSE for licensing information */
3
4/**
5 * \file compat_blake2.h
6 *
7 * \brief Compatibility adapter providing blake2b using ext/equix/hashx
8 **/
9
10#ifndef TOR_COMPAT_BLAKE2_H
11#define TOR_COMPAT_BLAKE2_H
12
13#include <stddef.h>
14#include <string.h>
16#include "ext/equix/hashx/src/blake2.h"
17
18static inline int
19blake2b_init_param(blake2b_state *S, const blake2b_param *P)
20{
21 return hashx_blake2b_init_param(S, P);
22}
23
24static inline int
25blake2b_init(blake2b_state *S, const uint8_t digest_length)
26{
28 memset(&P, 0, sizeof P);
29 P.digest_length = digest_length;
30 P.fanout = 1;
31 P.depth = 1;
32 return blake2b_init_param(S, &P);
33}
34
35static inline int
36blake2b_update(blake2b_state *S, const uint8_t *in, uint64_t inlen)
37{
38 return hashx_blake2b_update(S, in, inlen);
39}
40
41static inline int
42blake2b_final(blake2b_state *S, uint8_t *out, uint8_t outlen)
43{
44 return hashx_blake2b_final(S, out, outlen);
45}
46
47#endif /* !defined(TOR_COMPAT_BLAKE2_H) */
Utility macros to handle different features and behavior in different compilers.