2 * hash-helper.h - Helper functions for calculating hashes
4 * Copyright Jonathan McDowell <noodles@earth.li>
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program. If not, see <https://www.gnu.org/licenses/>.
19 #ifndef __HASH_HELPER_H__
20 #define __HASH_HELPER_H__
24 #include "build-config.h"
27 #include <nettle/md5.h>
28 #include <nettle/ripemd160.h>
29 #include <nettle/sha.h>
38 #define MAX_HASH_CHUNKS 8
40 struct onak_hash_ctx {
44 struct sha1x_ctx sha1x;
47 struct ripemd160_ctx ripemd160;
48 struct sha224_ctx sha224;
49 struct sha256_ctx sha256;
50 struct sha384_ctx sha384;
51 struct sha512_ctx sha512;
56 struct onak_hash_data {
59 size_t len[MAX_HASH_CHUNKS];
60 uint8_t *data[MAX_HASH_CHUNKS];
63 onak_status_t onak_hash(struct onak_hash_data *data, uint8_t *hash);
65 #endif /* __HASH_HELPER_H__ */