2 * Copyright (C) 2009 Martin Willi
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * @defgroup integrity_checker integrity_checker
18 * @{ @ingroup libstrongswan
21 #ifndef INTEGRITY_CHECKER_H_
22 #define INTEGRITY_CHECKER_H_
25 #include <plugins/plugin.h>
27 typedef struct integrity_checker_t integrity_checker_t
;
28 typedef struct integrity_checksum_t integrity_checksum_t
;
31 * Struct to hold a precalculated checksum, implemented in the checksum library.
33 struct integrity_checksum_t
{
34 /* name of the checksum */
36 /* checksum of the file on disk */
38 /* checksum of the executable segment in memory */
43 * Code integrity checker to detect non-malicious file manipulation.
45 * The integrity checker reads the checksums from a separate library
46 * libchecksum.so to compare the checksums.
48 struct integrity_checker_t
{
51 * Check the integrity of a file on disk.
53 * @param name name to lookup checksum
54 * @param file path to file
55 * @return TRUE if integrity tested successfully
57 bool (*check_file
)(integrity_checker_t
*this, char *name
, char *file
);
60 * Build the integrity checksum of a file on disk.
62 * @param file path to file
63 * @return checksum, 0 on error
65 u_int32_t (*build_file
)(integrity_checker_t
*this, char *file
);
68 * Check the integrity of the code segment in memory.
70 * @param name name to lookup checksum
71 * @param sym a symbol in the segment to check
72 * @return TRUE if integrity tested successfully
74 bool (*check_segment
)(integrity_checker_t
*this, char *name
, void *sym
);
77 * Build the integrity checksum of a code segment in memory.
79 * @param sym a symbol in the segment to check
80 * @return checksum, 0 on error
82 u_int32_t (*build_segment
)(integrity_checker_t
*this, void *sym
);
85 * Check both, on disk file integrity and loaded segment.
87 * @param name name to lookup checksum
88 * @param sym a symbol to look up library and segment
89 * @return TRUE if integrity tested successfully
91 bool (*check
)(integrity_checker_t
*this, char *name
, void *sym
);
94 * Destroy a integrity_checker_t.
96 void (*destroy
)(integrity_checker_t
*this);
100 * Create a integrity_checker instance.
102 * @param checksum_library library containing checksums
104 integrity_checker_t
*integrity_checker_create(char *checksum_library
);
106 #endif /* INTEGRITY_CHECKER_H_ @}*/