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)  

md5.c File Reference
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "writer.h"
#include "messages.h"
#include "ecma119.h"
#include "image.h"
#include "util.h"
#include "md5.h"
Include dependency graph for md5.c:

Go to the source code of this file.

Data Structures

struct  _libisofs_md5_ctx
 

Macros

#define Libisofs_md5_S11   7
 
#define Libisofs_md5_S12   12
 
#define Libisofs_md5_S13   17
 
#define Libisofs_md5_S14   22
 
#define Libisofs_md5_S21   5
 
#define Libisofs_md5_S22   9
 
#define Libisofs_md5_S23   14
 
#define Libisofs_md5_S24   20
 
#define Libisofs_md5_S31   4
 
#define Libisofs_md5_S32   11
 
#define Libisofs_md5_S33   16
 
#define Libisofs_md5_S34   23
 
#define Libisofs_md5_S41   6
 
#define Libisofs_md5_S42   10
 
#define Libisofs_md5_S43   15
 
#define Libisofs_md5_S44   21
 
#define Libisofs_md5_F(x, y, z)   (((x) & (y)) | ((~x) & (z)))
 
#define Libisofs_md5_G(x, y, z)   (((x) & (z)) | ((y) & (~z)))
 
#define Libisofs_md5_H(x, y, z)   ((x) ^ (y) ^ (z))
 
#define Libisofs_md5_I(x, y, z)   ((y) ^ ((x) | (~z)))
 
#define Libisofs_md5_ROTATE_LEFT(x, n)   (((x) << (n)) | ((x) >> (32-(n))))
 
#define Libisofs_md5_FF(a, b, c, d, x, s, ac)
 
#define Libisofs_md5_GG(a, b, c, d, x, s, ac)
 
#define Libisofs_md5_HH(a, b, c, d, x, s, ac)
 
#define Libisofs_md5_II(a, b, c, d, x, s, ac)
 

Typedefs

typedef struct _libisofs_md5_ctx libisofs_md5_ctx
 

Functions

static int md5__transform (uint32_t state[4], unsigned char block[64])
 
static int md5__encode (unsigned char *output, uint32_t *input, unsigned int len)
 
static int md5_init (libisofs_md5_ctx *ctx, int flag)
 
static int md5_update (libisofs_md5_ctx *ctx, unsigned char *data, int datalen, int flag)
 
static int md5_final (libisofs_md5_ctx *ctx, char result[16], int flag)
 
static int libisofs_md5 (void **ctx_in, char *data, int datalen, char result[16], int flag)
 
int iso_md5_start (void **md5_context)
 
int iso_md5_compute (void *md5_context, char *data, int datalen)
 
int iso_md5_clone (void *old_md5_context, void **new_md5_context)
 
int iso_md5_end (void **md5_context, char result[16])
 
int iso_md5_match (char first_md5[16], char second_md5[16])
 
int checksum_cx_xinfo_func (void *data, int flag)
 
int checksum_cx_xinfo_cloner (void *old_data, void **new_data, int flag)
 
int checksum_md5_xinfo_func (void *data, int flag)
 
int checksum_md5_xinfo_cloner (void *old_data, void **new_data, int flag)
 
static int checksum_copy_old_nodes (Ecma119Image *target, IsoNode *node, int flag)
 
static int checksum_writer_compute_data_blocks (IsoImageWriter *writer)
 
static int checksum_writer_write_vol_desc (IsoImageWriter *writer)
 
static int checksum_writer_write_data (IsoImageWriter *writer)
 
static int checksum_writer_free_data (IsoImageWriter *writer)
 
int checksum_writer_create (Ecma119Image *target)
 
static int iso_md5_write_scdbackup_tag (Ecma119Image *t, char *tag_block, int flag)
 
int iso_md5_write_tag (Ecma119Image *t, int flag)
 

Macro Definition Documentation

◆ Libisofs_md5_F

#define Libisofs_md5_F (   x,
  y,
 
)    (((x) & (y)) | ((~x) & (z)))

Definition at line 59 of file md5.c.

◆ Libisofs_md5_FF

#define Libisofs_md5_FF (   a,
  b,
  c,
  d,
  x,
  s,
  ac 
)
Value:
{ \
(a) += Libisofs_md5_F ((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = Libisofs_md5_ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define Libisofs_md5_F(x, y, z)
Definition: md5.c:59
#define Libisofs_md5_ROTATE_LEFT(x, n)
Definition: md5.c:66

Definition at line 71 of file md5.c.

◆ Libisofs_md5_G

#define Libisofs_md5_G (   x,
  y,
 
)    (((x) & (z)) | ((y) & (~z)))

Definition at line 60 of file md5.c.

◆ Libisofs_md5_GG

#define Libisofs_md5_GG (   a,
  b,
  c,
  d,
  x,
  s,
  ac 
)
Value:
{ \
(a) += Libisofs_md5_G ((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = Libisofs_md5_ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define Libisofs_md5_G(x, y, z)
Definition: md5.c:60

Definition at line 76 of file md5.c.

◆ Libisofs_md5_H

#define Libisofs_md5_H (   x,
  y,
 
)    ((x) ^ (y) ^ (z))

Definition at line 61 of file md5.c.

◆ Libisofs_md5_HH

#define Libisofs_md5_HH (   a,
  b,
  c,
  d,
  x,
  s,
  ac 
)
Value:
{ \
(a) += Libisofs_md5_H ((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = Libisofs_md5_ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define Libisofs_md5_H(x, y, z)
Definition: md5.c:61

Definition at line 81 of file md5.c.

◆ Libisofs_md5_I

#define Libisofs_md5_I (   x,
  y,
 
)    ((y) ^ ((x) | (~z)))

Definition at line 62 of file md5.c.

◆ Libisofs_md5_II

#define Libisofs_md5_II (   a,
  b,
  c,
  d,
  x,
  s,
  ac 
)
Value:
{ \
(a) += Libisofs_md5_I ((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = Libisofs_md5_ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define Libisofs_md5_I(x, y, z)
Definition: md5.c:62

Definition at line 86 of file md5.c.

◆ Libisofs_md5_ROTATE_LEFT

#define Libisofs_md5_ROTATE_LEFT (   x,
 
)    (((x) << (n)) | ((x) >> (32-(n))))

Definition at line 66 of file md5.c.

◆ Libisofs_md5_S11

#define Libisofs_md5_S11   7

Definition at line 39 of file md5.c.

◆ Libisofs_md5_S12

#define Libisofs_md5_S12   12

Definition at line 40 of file md5.c.

◆ Libisofs_md5_S13

#define Libisofs_md5_S13   17

Definition at line 41 of file md5.c.

◆ Libisofs_md5_S14

#define Libisofs_md5_S14   22

Definition at line 42 of file md5.c.

◆ Libisofs_md5_S21

#define Libisofs_md5_S21   5

Definition at line 43 of file md5.c.

◆ Libisofs_md5_S22

#define Libisofs_md5_S22   9

Definition at line 44 of file md5.c.

◆ Libisofs_md5_S23

#define Libisofs_md5_S23   14

Definition at line 45 of file md5.c.

◆ Libisofs_md5_S24

#define Libisofs_md5_S24   20

Definition at line 46 of file md5.c.

◆ Libisofs_md5_S31

#define Libisofs_md5_S31   4

Definition at line 47 of file md5.c.

◆ Libisofs_md5_S32

#define Libisofs_md5_S32   11

Definition at line 48 of file md5.c.

◆ Libisofs_md5_S33

#define Libisofs_md5_S33   16

Definition at line 49 of file md5.c.

◆ Libisofs_md5_S34

#define Libisofs_md5_S34   23

Definition at line 50 of file md5.c.

◆ Libisofs_md5_S41

#define Libisofs_md5_S41   6

Definition at line 51 of file md5.c.

◆ Libisofs_md5_S42

#define Libisofs_md5_S42   10

Definition at line 52 of file md5.c.

◆ Libisofs_md5_S43

#define Libisofs_md5_S43   15

Definition at line 53 of file md5.c.

◆ Libisofs_md5_S44

#define Libisofs_md5_S44   21

Definition at line 54 of file md5.c.

Typedef Documentation

◆ libisofs_md5_ctx

Definition at line 1 of file md5.c.

Function Documentation

◆ checksum_copy_old_nodes()

◆ checksum_cx_xinfo_cloner()

int checksum_cx_xinfo_cloner ( void *  old_data,
void **  new_data,
int  flag 
)

Definition at line 431 of file md5.c.

References ISO_XINFO_NO_CLONE.

Referenced by iso_init_with_flag().

◆ checksum_cx_xinfo_func()

int checksum_cx_xinfo_func ( void *  data,
int  flag 
)

◆ checksum_md5_xinfo_cloner()

int checksum_md5_xinfo_cloner ( void *  old_data,
void **  new_data,
int  flag 
)

Definition at line 459 of file md5.c.

References ISO_OUT_OF_MEM, and ISO_XINFO_NO_CLONE.

Referenced by iso_init_with_flag().

◆ checksum_md5_xinfo_func()

int checksum_md5_xinfo_func ( void *  data,
int  flag 
)

◆ checksum_writer_compute_data_blocks()

◆ checksum_writer_create()

◆ checksum_writer_free_data()

static int checksum_writer_free_data ( IsoImageWriter writer)
static

Definition at line 689 of file md5.c.

References ISO_SUCCESS.

Referenced by checksum_writer_create().

◆ checksum_writer_write_data()

◆ checksum_writer_write_vol_desc()

static int checksum_writer_write_vol_desc ( IsoImageWriter writer)
static

Definition at line 609 of file md5.c.

References ISO_SUCCESS.

Referenced by checksum_writer_create().

◆ iso_md5_clone()

int iso_md5_clone ( void *  old_md5_context,
void **  new_md5_context 
)

Create a MD5 computation context as clone of an existing one. One may call iso_md5_clone(old, &new, 0) and then iso_md5_end(&new, result, 0) in order to obtain an intermediate MD5 sum before the computation goes on.

Parameters
old_md5_contextAn opaque handle once returned by iso_md5_start() or iso_md5_clone().
new_md5_contextReturns the opaque handle to the new MD5 context. Submitted *md5_context must be NULL or point to freeable memory.
Returns
1= success , <0 indicates error
Since
0.6.22

Definition at line 377 of file md5.c.

References ISO_NULL_POINTER, ISO_OUT_OF_MEM, and libisofs_md5().

Referenced by checksum_writer_write_data(), iso_md5_write_scdbackup_tag(), iso_md5_write_tag(), iso_util_eval_md5_tag(), Xorriso_adjust_session_size(), Xorriso_chunk_md5(), and Xorriso_migrate_checksum_tag().

◆ iso_md5_compute()

int iso_md5_compute ( void *  md5_context,
char *  data,
int  datalen 
)

Advance the computation of a MD5 checksum by a chunk of data bytes.

Parameters
md5_contextAn opaque handle once returned by iso_md5_start() or iso_md5_clone().
dataThe bytes which shall be processed into to the checksum.
datalenThe number of bytes to be processed.
Returns
1= success , <0 indicates error
Since
0.6.22

Definition at line 365 of file md5.c.

References ISO_NULL_POINTER, and libisofs_md5().

Referenced by checksum_writer_write_data(), ecma119_image_new(), iso_filesrc_write_data(), iso_image_import(), iso_md5_write_scdbackup_tag(), iso_md5_write_tag(), iso_src_check_sb_tree(), iso_stream_make_md5(), iso_truncate_rr_name(), iso_util_decode_md5_tag(), iso_write(), make_hopefully_unique_name(), Xorriso_adjust_session_size(), Xorriso_check_md5(), Xorriso_check_md5_range(), Xorriso_chunk_md5(), Xorriso_md5_compute(), Xorriso_migrate_checksum_tag(), Xorriso_refresh_sb_tag(), Xorriso_refresh_ts_tags(), and Xorriso_verify_sb_tag().

◆ iso_md5_end()

int iso_md5_end ( void **  md5_context,
char  result[16] 
)

Obtain the MD5 checksum from a MD5 computation context and dispose this context. (If you want to keep the context then call iso_md5_clone() and apply iso_md5_end() to the clone.)

Parameters
md5_contextA pointer to an opaque handle once returned by iso_md5_start() or iso_md5_clone(). *md5_context will be set to NULL in this call.
resultGets filled with the 16 bytes of MD5 checksum.
Returns
1= success , <0 indicates error
Since
0.6.22

Definition at line 391 of file md5.c.

References ISO_NULL_POINTER, and libisofs_md5().

Referenced by checksum_writer_write_data(), ecma119_image_free(), ecma119_image_new(), iso_filesrc_write_data(), iso_image_import(), iso_md5_write_scdbackup_tag(), iso_md5_write_tag(), iso_src_check_sb_tree(), iso_stream_make_md5(), iso_truncate_rr_name(), iso_util_decode_md5_tag(), iso_util_eval_md5_tag(), make_hopefully_unique_name(), Xorriso__set_iso_check_tag_md5(), Xorriso_adjust_session_size(), Xorriso_check_interval(), Xorriso_check_md5(), Xorriso_check_md5_range(), Xorriso_chunk_md5(), Xorriso_md5_end(), Xorriso_migrate_checksum_tag(), Xorriso_refresh_sb_tag(), and Xorriso_verify_sb_tag().

◆ iso_md5_match()

int iso_md5_match ( char  first_md5[16],
char  second_md5[16] 
)

Inquire whether two MD5 checksums match. (This is trivial but such a call is convenient and completes the interface.)

Parameters
first_md5A MD5 byte string as returned by iso_md5_end()
second_md5A MD5 byte string as returned by iso_md5_end()
Returns
1= match , 0= mismatch
Since
0.6.22

Definition at line 403 of file md5.c.

Referenced by iso_filesrc_write_data(), iso_util_eval_md5_tag(), Xorriso_check_md5(), Xorriso_check_md5_range(), Xorriso_chunk_md5(), Xorriso_migrate_checksum_tag(), and Xorriso_verify_sb_tag().

◆ iso_md5_start()

int iso_md5_start ( void **  md5_context)

Create a MD5 computation context and hand out an opaque handle.

Parameters
md5_contextReturns the opaque handle. Submitted *md5_context must be NULL or point to freeable memory.
Returns
1= success , <0 indicates error
Since
0.6.22

Definition at line 353 of file md5.c.

References ISO_OUT_OF_MEM, and libisofs_md5().

Referenced by checksum_writer_write_data(), ecma119_image_new(), iso_filesrc_write_data(), iso_image_import(), iso_md5_write_scdbackup_tag(), iso_md5_write_tag(), iso_src_check_sb_tree(), iso_stream_make_md5(), iso_truncate_rr_name(), iso_util_decode_md5_tag(), make_hopefully_unique_name(), Xorriso_adjust_session_size(), Xorriso_check_interval(), Xorriso_check_md5(), Xorriso_check_md5_range(), Xorriso_chunk_md5(), Xorriso_md5_start(), Xorriso_migrate_checksum_tag(), Xorriso_refresh_sb_tag(), and Xorriso_verify_sb_tag().

◆ iso_md5_write_scdbackup_tag()

◆ iso_md5_write_tag()

◆ libisofs_md5()

static int libisofs_md5 ( void **  ctx_in,
char *  data,
int  datalen,
char  result[16],
int  flag 
)
static

Compute a MD5 checksum from one or more calls of this function. The first call has to be made with flag bit0 == 1. It may already submit processing payload in data and datalen. The last call has to be made with bit15 set. Normally bit1 will be set too in order to receive the checksum before it gets disposed. bit1 may only be set in the last call or together with bit2. The combination of bit1 and bit2 may be used to get an intermediate result without hampering an ongoing checksum computation.

Parameters
ctxthe checksum context which stores the state between calls. It gets created with flag bit0 and disposed with bit15. With flag bit0, *ctx has to be NULL or point to freeable memory.
datathe bytes to be checksummed
datalenthe number of bytes in data
resultreturns the 16 bytes of checksum if called with bit1 set
flagbit0= allocate and init *ctx bit1= transfer ctx to result bit2= with bit 0 : clone new *ctx from data bit15= free *ctx

Definition at line 308 of file md5.c.

References md5_final(), md5_init(), and md5_update().

Referenced by iso_md5_clone(), iso_md5_compute(), iso_md5_end(), and iso_md5_start().

◆ md5__encode()

static int md5__encode ( unsigned char *  output,
uint32_t *  input,
unsigned int  len 
)
static

Definition at line 197 of file md5.c.

Referenced by md5_final().

◆ md5__transform()

◆ md5_final()

static int md5_final ( libisofs_md5_ctx ctx,
char  result[16],
int  flag 
)
static

Definition at line 260 of file md5.c.

References _libisofs_md5_ctx::count, md5__encode(), md5_update(), and _libisofs_md5_ctx::state.

Referenced by libisofs_md5().

◆ md5_init()

static int md5_init ( libisofs_md5_ctx ctx,
int  flag 
)
static

Definition at line 213 of file md5.c.

References _libisofs_md5_ctx::count, and _libisofs_md5_ctx::state.

Referenced by libisofs_md5().

◆ md5_update()

static int md5_update ( libisofs_md5_ctx ctx,
unsigned char *  data,
int  datalen,
int  flag 
)
static