src/rddverify.c File Reference

#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"

Include dependency graph for rddverify.c:

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_READERopen_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 Documentation

#define bool2str (  )     ((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 Documentation

typedef rdd_checksum_t(* checksum_fun)(rdd_checksum_t, const unsigned char *, size_t)

Definition at line 110 of file rddverify.c.


Function Documentation

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.

Here is the call graph for this function:

static void check_header ( char *  path,
RDD_CHECKSUM_FILE_HEADER header,
int  type,
int *  swap 
) [static]

static void close_checksum_file ( const char *  path,
FILE *  fp 
) [static]

Definition at line 301 of file rddverify.c.

References unix_error(), and warn().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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.

Here is the call graph for this function:

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.

Here is the call graph for this function:

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().

Here is the call graph for this function:

int main ( int  argc,
char **  argv 
)

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

static void process_options ( void   )  [static]

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().

Here is the call graph for this function:

static void swap_header ( RDD_CHECKSUM_FILE_HEADER hdr  )  [static]

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.

Here is the call graph for this function:

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]


Variable Documentation

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.


Generated on Sun Feb 6 12:36:33 2011 for rdd by  doxygen 1.5.6