xorriso  1.5.4.pl02
About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.
  Fossies Dox: xorriso-1.5.4.pl02.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

checksum.h
Go to the documentation of this file.
1 /*
2  * checksum.h
3  *
4  * Copyright (c) 2008-2019 Steve McIntyre <steve@einval.com>
5  *
6  * Definitions and prototypes for a generic checksum interface, used
7  * in JTE. Inspired heavily by the interface to the MD5 code we're
8  * using already.
9  *
10  * GNU GPL v2
11  */
12 
13 #ifndef _JTE_CHECKSUM_H_
14 #define _JTE_CHECKSUM_H_
15 
17 {
18  CHECK_MD5 = 0,
23 };
24 
25 #define CHECK_MD5_USED (1 << CHECK_MD5)
26 #define CHECK_SHA1_USED (1 << CHECK_SHA1)
27 #define CHECK_SHA256_USED (1 << CHECK_SHA256)
28 #define CHECK_SHA512_USED (1 << CHECK_SHA512)
29 #define CHECK_ALL_USED 0xFFFFFFFF
30 
31 typedef void checksum_context_t;
32 
34 {
35  char *name;
36  char *prog;
38 };
39 
40 /* Ask the library for information about a particular checksum
41  * algorithm. Returns a pointer to internal memory - DO NOT
42  * MODIFY/FREE! */
44 
45 /* Allocate / initialise a context for the chosen checksums. OR
46  * together the desired checksums as the parameter */
47 checksum_context_t *checksum_init_context(int checksums, const char *owner);
48 
49 /* Cleanup and free a context when it's finished with */
51 
52 /* Pass a new buffer full of data through the checksum code */
54  unsigned char const *buf,
55  unsigned int len);
56 
57 /* Finish the current set of checksums */
58 void checksum_final(checksum_context_t *context);
59 
60 /* Extract a particular algorithm's checksum once checksum_final() has
61  * been called. Use the details in checksum_information() above first
62  * to see how big the digest will be. Only valid once checksum_final()
63  * has been called, otherwise the digest returned will be all
64  * zeroes. */
65 void checksum_copy(checksum_context_t *context,
66  enum checksum_types which,
67  unsigned char *digest);
68 
69 /* Helper function: return a pointer to a string containing the ASCII
70  * hexadecimal dump of a checksum. Only valid once checksum_final()
71  * has been called, otherwise will return NULL */
72 const char * checksum_hex(checksum_context_t *context,
73  enum checksum_types which);
74 
75 
76 extern int parse_checksum_algo(char *arg,
77  int *algo);
78 
79 /* Helper function: Simply calculate the checksum of the first "size"
80  * bytes of a file using the specified algorithm. If size == -1,
81  * calculate the checksum for the whole of the file. The caller is
82  * responsible for passing in a large enough buffer as "digest", based
83  * on their choice of algorithm. */
84 extern int checksum_calculate(char *filename,
85  int64_t size,
86  unsigned char *digest,
87  enum checksum_types which);
88 
89 
90 /* Helper function: Parse a hexadecimal string "in" of length "size"
91  characters (must be even) and convert to a raw checksum in
92  "out". out must be allocated of a large-enough size by the
93  caller */
94 int checksum_parse_hex(char *in, unsigned char *out, int size);
95 
96 #endif
97 /* _JTE_CHECKSUM_H_ */
checksum_context_t * checksum_init_context(int checksums, const char *owner)
Definition: checksum.c:236
const char * checksum_hex(checksum_context_t *context, enum checksum_types which)
Definition: checksum.c:460
void checksum_context_t
Definition: checksum.h:31
void checksum_update(checksum_context_t *context, unsigned char const *buf, unsigned int len)
Definition: checksum.c:383
checksum_types
Definition: checksum.h:17
@ NUM_CHECKSUMS
Definition: checksum.h:22
@ CHECK_SHA1
Definition: checksum.h:19
@ CHECK_SHA512
Definition: checksum.h:21
@ CHECK_MD5
Definition: checksum.h:18
@ CHECK_SHA256
Definition: checksum.h:20
int checksum_calculate(char *filename, int64_t size, unsigned char *digest, enum checksum_types which)
Definition: checksum.c:528
void checksum_copy(checksum_context_t *context, enum checksum_types which, unsigned char *digest)
Definition: checksum.c:440
void checksum_final(checksum_context_t *context)
Definition: checksum.c:401
int checksum_parse_hex(char *in, unsigned char *out, int size)
Definition: checksum.c:576
void checksum_free_context(checksum_context_t *context)
Definition: checksum.c:318
int parse_checksum_algo(char *arg, int *algo)
Definition: checksum.c:474
struct checksum_info * checksum_information(enum checksum_types which)
Definition: checksum.c:180
char * prog
Definition: checksum.h:36
int digest_size
Definition: checksum.h:37
char * name
Definition: checksum.h:35