Debian Codegraph @

include/md.h

raw symbols SCIP
1 /*
2 * AIDE (Advanced Intrusion Detection Environment)
3 *
4 * Copyright (C) 2000-2002, 2005-2006, 2020, 2022, 2024, 2025 Rami Lehti,
5 * Pablo Virolainen, Richard van den Berg, Hannes von Haugwitz
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22 #ifndef _MD_H_INCLUDED
23 #define _MD_H_INCLUDED
24
25 #include "config.h"
26 #ifdef WITH_NETTLE
27 #include <nettle/md5.h>
28 #include <nettle/sha1.h>
29 #include <nettle/sha2.h>
30 #include <nettle/sha3.h>
31 #include <nettle/ripemd160.h>
32 #include <nettle/gosthash94.h>
33 #include <nettle/streebog.h>
34 #endif
35 #ifdef WITH_GCRYPT
36 #include <gcrypt.h>
37 #endif
38 #include <sys/types.h>
39 #include "attributes.h"
40 #include "hashsum.h"
41 #include "util.h"
42 struct db_line;
43
44 /*
45 This struct hold's internal data needed for md-calls.
46
47 */
48
49 typedef struct md_container {
50 /*
51 Attr which are to be calculated.
52 */
53 DB_ATTR_TYPE calc_attr;
54 /*
55 Attr which are not (yet) to be calculated.
56 After init hold's hashes which are not calculated :)
57 */
58 DB_ATTR_TYPE todo_attr;
59
60 /*
61 Variables needed to cope with the library.
62 */
63 #ifdef WITH_NETTLE
64 union {
65 struct md5_ctx md5;
66 struct sha1_ctx sha1;
67 struct sha256_ctx sha256;
68 struct sha512_ctx sha512;
69 struct ripemd160_ctx ripemd160;
70 struct gosthash94_ctx gosthash94;
71 struct streebog256_ctx streebog256;
72 struct streebog512_ctx streebog512;
73 struct sha512_256_ctx sha512_256;
74 struct sha3_512_ctx sha3_256;
75 struct sha3_256_ctx sha3_512;
76 } ctx[num_hashes];
77 #endif
78
79 #ifdef WITH_GCRYPT
80 gcry_md_hd_t mdh;
81 #endif
82
83 } md_container;
84
85 typedef struct md_hashsums {
86 unsigned char hashsums[num_hashes][HASHSUM_MAX_LENGTH];
87 DB_ATTR_TYPE attrs;
88 } md_hashsums;
89
90 int init_md(struct md_container*, const char*, const char *);
91 int update_md(struct md_container*,void*,ssize_t);
92 int close_md(struct md_container*, md_hashsums *, const char*, const char *);
93 void hashsums2line(md_hashsums*, struct db_line*, const char *);
94
95 DB_ATTR_TYPE copy_hashsums(char *, md_hashsums *, byte* (*)[num_hashes], const char *);
96
97 #endif /*_MD_H_INCLUDED*/