Rizin
unix-like reverse engineering framework and cli tools
index_hash.h File Reference

Validate Index by using a hash function. More...

Go to the source code of this file.

Typedefs

typedef struct lzma_index_hash_s lzma_index_hash
 Opaque data type to hold the Index hash. More...
 

Functions

 LZMA_API (lzma_index_hash *) lzma_index_hash_init(lzma_index_hash *index_hash
 Allocate and initialize a new lzma_index_hash structure. More...
 
 LZMA_API (void) lzma_index_hash_end(lzma_index_hash *index_hash
 Deallocate lzma_index_hash structure. More...
 
 LZMA_API (lzma_ret) lzma_index_hash_append(lzma_index_hash *index_hash
 Add a new Record to an Index hash. More...
 
 LZMA_API (lzma_vli) lzma_index_hash_size(const lzma_index_hash *index_hash) lzma_nothrow lzma_attr_pure
 Get the size of the Index field as bytes. More...
 

Variables

const lzma_allocator *allocator lzma_nothrow lzma_attr_warn_unused_result
 
const lzma_allocator *allocator lzma_nothrow
 
lzma_vli unpadded_size
 
const uint8_tin
 
const uint8_t size_tin_pos
 

Detailed Description

Validate Index by using a hash function.

Hashing makes it possible to use constant amount of memory to validate Index of arbitrary size.

Definition in file index_hash.h.

Typedef Documentation

◆ lzma_index_hash

Opaque data type to hold the Index hash.

Definition at line 1 of file index_hash.h.

Function Documentation

◆ LZMA_API() [1/4]

LZMA_API ( lzma_index_hash )

Allocate and initialize a new lzma_index_hash structure.

If index_hash is NULL, a new lzma_index_hash structure is allocated, initialized, and a pointer to it returned. If allocation fails, NULL is returned.

If index_hash is non-NULL, it is reinitialized and the same pointer returned. In this case, return value cannot be NULL or a different pointer than the index_hash that was given as an argument.

◆ LZMA_API() [2/4]

LZMA_API ( lzma_ret  )

Add a new Record to an Index hash.

Decode and validate the Index field.

Parameters
indexPointer to a lzma_index_hash structure
unpadded_sizeUnpadded Size of a Block
uncompressed_sizeUncompressed Size of a Block
Returns
- LZMA_OK
  • LZMA_DATA_ERROR: Compressed or uncompressed size of the Stream or size of the Index field would grow too big.
  • LZMA_PROG_ERROR: Invalid arguments or this function is being used when lzma_index_hash_decode() has already been used.

After telling the sizes of all Blocks with lzma_index_hash_append(), the actual Index field is decoded with this function. Specifically, once decoding of the Index field has been started, no more Records can be added using lzma_index_hash_append().

This function doesn't use lzma_stream structure to pass the input data. Instead, the input buffer is specified using three arguments. This is because it matches better the internal APIs of liblzma.

Parameters
index_hashPointer to a lzma_index_hash structure
inPointer to the beginning of the input buffer
in_posin[*in_pos] is the next byte to process
in_sizein[in_size] is the first byte not to process
Returns
- LZMA_OK: So far good, but more input is needed.
  • LZMA_STREAM_END: Index decoded successfully and it matches the Records given with lzma_index_hash_append().
  • LZMA_DATA_ERROR: Index is corrupt or doesn't match the information given with lzma_index_hash_append().
  • LZMA_BUF_ERROR: Cannot progress because *in_pos >= in_size.
  • LZMA_PROG_ERROR

◆ LZMA_API() [3/4]

LZMA_API ( uint64_t  ) const

Get the size of the Index field as bytes.

This is needed to verify the Backward Size field in the Stream Footer.

Get the size of the Index field as bytes.

Calculate approximate memory requirements for raw encoder.

Calculate Unpadded Size.

Get the memory usage of decoder filter chain.

Calculate CRC64 using the polynomial from the ECMA-182 standard.

This function is used similarly to lzma_crc32(). See its documentation.

Definition at line 131 of file block_util.c.

83 {
84  lzma_vli unpadded_size = lzma_block_unpadded_size(block);
85 
88 
89  return unpadded_size;
90 }
const lzma_allocator lzma_vli unpadded_size
Definition: index.h:345
static lzma_vli vli_ceil4(lzma_vli vli)
Round the variable-length integer to the next multiple of four.
Definition: index.h:39
uint64_t lzma_vli
Variable-length integer type.
Definition: vli.h:63
#define LZMA_VLI_UNKNOWN
VLI value to denote that the value is unknown.
Definition: vli.h:39

◆ LZMA_API() [4/4]

LZMA_API ( void  )

Deallocate lzma_index_hash structure.

Variable Documentation

◆ in

Definition at line 96 of file index_hash.h.

◆ in_pos

const uint8_t size_t* in_pos

Definition at line 96 of file index_hash.h.

◆ lzma_attr_warn_unused_result

const uint8_t size_t size_t in_size lzma_nothrow lzma_attr_warn_unused_result

Definition at line 41 of file index_hash.h.

◆ lzma_nothrow

Definition at line 49 of file index_hash.h.

◆ unpadded_size

lzma_vli unpadded_size

Definition at line 66 of file index_hash.h.