File: md.h

package info (click to toggle)
aide 0.18.3-1%2Bdeb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,368 kB
  • sloc: ansic: 10,364; sh: 6,196; lex: 764; yacc: 123; makefile: 104
file content (76 lines) | stat: -rw-r--r-- 2,010 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * AIDE (Advanced Intrusion Detection Environment)
 *
 * Copyright (C) 2000-2002, 2005-2006, 2020, 2022 Rami Lehti, Pablo Virolainen,
 *               Richard van den Berg, Hannes von Haugwitz
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef _MD_H_INCLUDED
#define _MD_H_INCLUDED

#include "config.h"
#ifdef WITH_MHASH
#include <mhash.h>
#endif
#ifdef WITH_GCRYPT
#include <gcrypt.h>
#endif
#include <sys/types.h>
#include "attributes.h"
#include "hashsum.h"
struct db_line;

/*
  This struct hold's internal data needed for md-calls.

 */

typedef struct md_container {
  /* 
     Attr which are to be calculated.
  */
  DB_ATTR_TYPE calc_attr; 
  /*
    Attr which are not (yet) to be calculated.
    After init hold's hashes which are not calculated :)
  */
  DB_ATTR_TYPE todo_attr;

  /*
    Variables needed to cope with the library.
   */
#ifdef WITH_MHASH
  MHASH mhash_mdh[num_hashes];
#endif

#ifdef WITH_GCRYPT
  gcry_md_hd_t mdh;
#endif

} md_container;

typedef struct md_hashsums {
  char hashsums[num_hashes][HASHSUM_MAX_LENGTH];
  DB_ATTR_TYPE attrs;
} md_hashsums;

int init_md(struct md_container*, const char*);
int update_md(struct md_container*,void*,ssize_t);
int close_md(struct md_container*, md_hashsums *, const char*);
void hashsums2line(md_hashsums*, struct db_line*);

#endif /*_MD_H_INCLUDED*/