diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 19:10:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 19:10:49 +0000 |
commit | cfe5e3905201349e9cf3f95d52ff4bd100bde37d (patch) | |
tree | d0baf160cbee3195249d095f85e52d20c21acf02 /include/fileeq.h | |
parent | Initial commit. (diff) | |
download | util-linux-cfe5e3905201349e9cf3f95d52ff4bd100bde37d.tar.xz util-linux-cfe5e3905201349e9cf3f95d52ff4bd100bde37d.zip |
Adding upstream version 2.39.3.upstream/2.39.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'include/fileeq.h')
-rw-r--r-- | include/fileeq.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/include/fileeq.h b/include/fileeq.h new file mode 100644 index 0000000..df5e6d8 --- /dev/null +++ b/include/fileeq.h @@ -0,0 +1,62 @@ + +/* + * No copyright is claimed. This code is in the public domain; do with + * it what you wish. + */ +#ifndef UTIL_LINUX_FILEEQ +#define UTIL_LINUX_FILEEQ + +#include <stdlib.h> +#include <stdint.h> +#include <stdbool.h> + +#if defined(__linux__) && defined(HAVE_LINUX_IF_ALG_H) +# define USE_FILEEQ_CRYPTOAPI 1 +#endif + +/* Number of bytes from the beginning of the file we always + * compare by memcmp() */ +#define UL_FILEEQ_INTROSIZ 32 + +struct ul_fileeq_data { + unsigned char intro[UL_FILEEQ_INTROSIZ]; + unsigned char *blocks; + size_t nblocks; + size_t maxblocks; + int fd; + const char *name; + bool is_eof; +}; + +struct ul_fileeq { + int fd_api; /* Crypto socket */ + int fd_cip; /* Cipher handler */ + + size_t readsiz; + uint64_t filesiz; + uint64_t blocksmax; + const struct ul_fileeq_method *method; + + /* UL_FILEEQ_MEMCMP buffers */ + unsigned char *buf_a; + unsigned char *buf_b; + unsigned char *buf_last; +}; + +extern int ul_fileeq_init(struct ul_fileeq *eq, const char *method); +extern void ul_fileeq_deinit(struct ul_fileeq *eq); + + +extern int ul_fileeq_data_associated(struct ul_fileeq_data *data); +extern void ul_fileeq_data_close_file(struct ul_fileeq_data *data); +extern void ul_fileeq_data_init(struct ul_fileeq_data *data); +extern void ul_fileeq_data_deinit(struct ul_fileeq_data *data); +extern void ul_fileeq_data_set_file(struct ul_fileeq_data *data, + const char *name); +extern size_t ul_fileeq_set_size(struct ul_fileeq *eq, uint64_t filesiz, + size_t readsiz, size_t memsiz); + +extern int ul_fileeq(struct ul_fileeq *eq, + struct ul_fileeq_data *a, struct ul_fileeq_data *b); + +#endif /* UTIL_LINUX_FILEEQ */ |