#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <assert.h>
#include "rdd.h"
#include "reader.h"
#include "writer.h"
#include "filter.h"
#include "filterset.h"
#include "msgprinter.h"
#include "rdd_internals.h"
#include "error.h"
#include "commandline.h"
Go to the source code of this file.
Data Structures | |
struct | verifier_opts |
Defines | |
#define | bool2str(b) ((b) ? "yes" : "no") |
#define | READ_SIZE 262144 |
#define | VFY_ADLER32 0x4 |
#define | VFY_CRC32 0x8 |
#define | VFY_MD5 0x1 |
#define | VFY_SHA1 0x2 |
Typedefs | |
typedef rdd_checksum_t(* | checksum_fun )(rdd_checksum_t, const unsigned char *, size_t) |
Functions | |
static void | add_filter (RDD_FILTERSET *fset, const char *name, RDD_FILTER *f) |
static void | check_header (char *path, RDD_CHECKSUM_FILE_HEADER *header, int type, int *swap) |
static void | close_checksum_file (const char *path, FILE *fp) |
static void | close_image_file (const char *path, RDD_READER *reader) |
static void | command_line (int argc, char **argv) |
static int | equal_digest (char *md1, char *md2, unsigned mdlen) |
static void | get_checksum_result (RDD_FILTERSET *fset, const char *name, unsigned *num_error) |
static void | get_hash_result (RDD_FILTERSET *fset, const char *name, unsigned char *md, unsigned mdsize) |
static void | handle_checksum_error (rdd_count_t pos, rdd_checksum_t expected, rdd_checksum_t computed, void *env) |
int | main (int argc, char **argv) |
static FILE * | open_checksum_file (char *path, int type, RDD_CHECKSUM_FILE_HEADER *hdr, int *swap) |
static RDD_READER * | open_image_file (const char *path) |
static void | process_options (void) |
static u_int16_t | swap16 (u_int16_t n) |
static u_int32_t | swap32 (u_int32_t n) |
static u_int64_t | swap64 (u_int64_t n) |
static void | swap_header (RDD_CHECKSUM_FILE_HEADER *hdr) |
static void | verify_file (RDD_FILTERSET *filters, const char *path) |
static int | verify_files (char **files, unsigned nfile, FILE *adler32file, rdd_count_t a32len, int a32swap, FILE *crc32file, rdd_count_t crc32len, int crc32swap) |
Variables | |
static char | copyright [] |
static struct verifier_opts | opts |
static RDD_OPTION | opttab [] |
static char * | usage_message = "rdd-verify [local options] file1 ... \n" |
#define bool2str | ( | b | ) | ((b) ? "yes" : "no") |
Definition at line 95 of file rddverify.c.
#define READ_SIZE 262144 |
Definition at line 94 of file rddverify.c.
#define VFY_ADLER32 0x4 |
Definition at line 91 of file rddverify.c.
#define VFY_CRC32 0x8 |
Definition at line 92 of file rddverify.c.
#define VFY_MD5 0x1 |
Definition at line 89 of file rddverify.c.
#define VFY_SHA1 0x2 |
Definition at line 90 of file rddverify.c.
typedef rdd_checksum_t(* checksum_fun)(rdd_checksum_t, const unsigned char *, size_t) |
Definition at line 110 of file rddverify.c.
static void add_filter | ( | RDD_FILTERSET * | fset, | |
const char * | name, | |||
RDD_FILTER * | f | |||
) | [static] |
Definition at line 343 of file rddverify.c.
References rdd_error(), rdd_fset_add(), and RDD_OK.
static void check_header | ( | char * | path, | |
RDD_CHECKSUM_FILE_HEADER * | header, | |||
int | type, | |||
int * | swap | |||
) | [static] |
Definition at line 254 of file rddverify.c.
References error(), _RDD_CHECKSUM_FILE_HEADER::flags, _RDD_CHECKSUM_FILE_HEADER::magic, RDD_CHECKSUM_MAGIC, RDD_CHECKSUM_VERSION, swap_header(), and _RDD_CHECKSUM_FILE_HEADER::version.
static void close_checksum_file | ( | const char * | path, | |
FILE * | fp | |||
) | [static] |
Definition at line 301 of file rddverify.c.
References unix_error(), and warn().
static void close_image_file | ( | const char * | path, | |
RDD_READER * | reader | |||
) | [static] |
Definition at line 232 of file rddverify.c.
References rdd_error(), RDD_OK, and rdd_reader_close().
static void command_line | ( | int | argc, | |
char ** | argv | |||
) | [static] |
Definition at line 163 of file rddverify.c.
References opts, process_options(), rdd_get_opt_with_arg(), and rdd_opt_usage().
static int equal_digest | ( | char * | md1, | |
char * | md2, | |||
unsigned | mdlen | |||
) | [static] |
Definition at line 400 of file rddverify.c.
static void get_checksum_result | ( | RDD_FILTERSET * | fset, | |
const char * | name, | |||
unsigned * | num_error | |||
) | [static] |
Definition at line 364 of file rddverify.c.
References rdd_error(), rdd_filter_get_result(), rdd_fset_get(), and RDD_OK.
static void get_hash_result | ( | RDD_FILTERSET * | fset, | |
const char * | name, | |||
unsigned char * | md, | |||
unsigned | mdsize | |||
) | [static] |
Definition at line 383 of file rddverify.c.
References rdd_error(), rdd_filter_get_result(), rdd_fset_get(), and RDD_OK.
static void handle_checksum_error | ( | rdd_count_t | pos, | |
rdd_checksum_t | expected, | |||
rdd_checksum_t | computed, | |||
void * | env | |||
) | [static] |
Definition at line 353 of file rddverify.c.
References errlognl().
int main | ( | int | argc, | |
char ** | argv | |||
) |
Definition at line 548 of file rddverify.c.
References _rdd_copy_opts::adler32file, _RDD_CHECKSUM_FILE_HEADER::blocksize, bool2str, close_checksum_file(), command_line(), _rdd_copy_opts::crc32file, errlog(), errlognl(), open_checksum_file(), opts, RDD_ADLER32, RDD_CRC32, rdd_ctime(), rdd_opt_init(), set_logfile(), set_progname(), usage_message, _rdd_copy_opts::verbose, verify_files(), VFY_ADLER32, VFY_CRC32, VFY_MD5, and VFY_SHA1.
static FILE* open_checksum_file | ( | char * | path, | |
int | type, | |||
RDD_CHECKSUM_FILE_HEADER * | hdr, | |||
int * | swap | |||
) | [static] |
Definition at line 283 of file rddverify.c.
References check_header(), and unix_error().
static RDD_READER* open_image_file | ( | const char * | path | ) | [static] |
Definition at line 219 of file rddverify.c.
References rdd_error(), RDD_OK, and rdd_open_file_reader().
static void process_options | ( | void | ) | [static] |
Definition at line 128 of file rddverify.c.
References _rdd_copy_opts::adler32file, _rdd_copy_opts::crc32file, _rdd_copy_opts::md5, opts, rdd_opt_set(), rdd_opt_set_arg(), rdd_opt_usage(), _rdd_copy_opts::sha1, and _rdd_copy_opts::verbose.
static u_int16_t swap16 | ( | u_int16_t | n | ) | [static] |
Definition at line 187 of file rddverify.c.
static u_int32_t swap32 | ( | u_int32_t | n | ) | [static] |
Definition at line 193 of file rddverify.c.
static u_int64_t swap64 | ( | u_int64_t | n | ) | [static] |
Definition at line 204 of file rddverify.c.
References swap32().
static void swap_header | ( | RDD_CHECKSUM_FILE_HEADER * | hdr | ) | [static] |
Definition at line 242 of file rddverify.c.
References _RDD_CHECKSUM_FILE_HEADER::blocksize, _RDD_CHECKSUM_FILE_HEADER::flags, _RDD_CHECKSUM_FILE_HEADER::imagesize, _RDD_CHECKSUM_FILE_HEADER::magic, _RDD_CHECKSUM_FILE_HEADER::offset, _RDD_CHECKSUM_FILE_HEADER::reserved, swap16(), swap32(), swap64(), and _RDD_CHECKSUM_FILE_HEADER::version.
static void verify_file | ( | RDD_FILTERSET * | filters, | |
const char * | path | |||
) | [static] |
Definition at line 315 of file rddverify.c.
References close_image_file(), open_image_file(), rdd_error(), rdd_fset_close(), rdd_fset_push(), RDD_OK, rdd_reader_read(), and READ_SIZE.
static int verify_files | ( | char ** | files, | |
unsigned | nfile, | |||
FILE * | adler32file, | |||
rdd_count_t | a32len, | |||
int | a32swap, | |||
FILE * | crc32file, | |||
rdd_count_t | crc32len, | |||
int | crc32swap | |||
) | [static] |
Definition at line 414 of file rddverify.c.
References add_filter(), equal_digest(), errlognl(), get_checksum_result(), get_hash_result(), handle_checksum_error(), _rdd_copy_opts::md5, opts, rdd_buf2hex(), rdd_error(), rdd_fset_clear(), rdd_fset_init(), rdd_new_md5_streamfilter(), rdd_new_sha1_streamfilter(), rdd_new_verify_adler32_blockfilter(), rdd_new_verify_crc32_blockfilter(), RDD_OK, _rdd_copy_opts::sha1, _rdd_copy_opts::verbose, verify_file(), VFY_ADLER32, VFY_CRC32, VFY_MD5, and VFY_SHA1.
char copyright[] [static] |
Initial value:
"@(#) Copyright (c) 2002\n\ Netherlands Forensic Institute. All rights reserved.\n"
Definition at line 39 of file rddverify.c.
struct verifier_opts opts [static] |
RDD_OPTION opttab[] [static] |
Initial value:
{ {"-?", "--help", 0, 0, "Print this message", 0, 0}, {"-A", "--adler32", "<file>", 0, "verify Adler32 checksums in <file> against input files", 0, 0}, {"-C", "--checksum", "<file>", 0, "verify Adler32 checksums in <file> against input files", 0, 0}, {"-c", "--crc32", "<file>", 0, "verify CRC32 checksums in <file> against input files", 0, 0}, {"-m", "--md5", "<md5 digest>", 0, "verify MD5 hash", 0, 0}, {"-s", "--sha1", "<sha-1 digest>", 0, "verify SHA1 hash", 0, 0}, {"-V", "--version", 0, 0, "Report version number and exit", 0, 0}, {"-v", "--verbose", 0, 0, "Be verbose", 0, 0}, {0, 0, 0, 0, 0, 0, 0} }
Definition at line 114 of file rddverify.c.
char* usage_message = "rdd-verify [local options] file1 ... \n" [static] |
Definition at line 112 of file rddverify.c.