Defines | Enumerations | Functions

/tmp/buildd/xz-utils-5.0.0/src/liblzma/api/lzma/check.h File Reference

Integrity checks. More...

Defines

#define LZMA_CHECK_ID_MAX   15
 Maximum valid Check ID.
#define LZMA_CHECK_SIZE_MAX   64
 Maximum size of a Check field.

Enumerations

enum  lzma_check { LZMA_CHECK_NONE = 0, LZMA_CHECK_CRC32 = 1, LZMA_CHECK_CRC64 = 4, LZMA_CHECK_SHA256 = 10 }
 

Type of the integrity check (Check ID).

More...

Functions

lzma_bool lzma_check_is_supported (lzma_check check) lzma_nothrow lzma_attr_const
 Test if the given Check ID is supported.
uint32_t lzma_check_size (lzma_check check) lzma_nothrow lzma_attr_const
 Get the size of the Check field with the given Check ID.
uint32_t lzma_crc32 (const uint8_t *buf, size_t size, uint32_t crc) lzma_nothrow lzma_attr_pure
 Calculate CRC32.
uint64_t lzma_crc64 (const uint8_t *buf, size_t size, uint64_t crc) lzma_nothrow lzma_attr_pure
 Calculate CRC64.
lzma_check lzma_get_check (const lzma_stream *strm) lzma_nothrow
 Get the type of the integrity check.

Detailed Description

Integrity checks.


Define Documentation

#define LZMA_CHECK_ID_MAX   15

Maximum valid Check ID.

The .xz file format specification specifies 16 Check IDs (0-15). Some of them are only reserved, that is, no actual Check algorithm has been assigned. When decoding, liblzma still accepts unknown Check IDs for future compatibility. If a valid but unsupported Check ID is detected, liblzma can indicate a warning; see the flags LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, and LZMA_TELL_ANY_CHECK in container.h.

Referenced by lzma_block_header_decode(), lzma_block_unpadded_size(), lzma_check_is_supported(), lzma_check_size(), lzma_stream_buffer_encode(), and lzma_stream_flags_compare().

#define LZMA_CHECK_SIZE_MAX   64

Maximum size of a Check field.


Enumeration Type Documentation

enum lzma_check

Type of the integrity check (Check ID).

The .xz format supports multiple types of checks that are calculated from the uncompressed data. They vary in both speed and ability to detect errors.

Enumerator:
LZMA_CHECK_NONE 

No Check is calculated.

Size of the Check field: 0 bytes

LZMA_CHECK_CRC32 

CRC32 using the polynomial from the IEEE 802.3 standard

Size of the Check field: 4 bytes

LZMA_CHECK_CRC64 

CRC64 using the polynomial from the ECMA-182 standard

Size of the Check field: 8 bytes

LZMA_CHECK_SHA256 

SHA-256

Size of the Check field: 32 bytes


Function Documentation

lzma_bool lzma_check_is_supported ( lzma_check  check  )  const

Test if the given Check ID is supported.

Return true if the given Check ID is supported by this liblzma build. Otherwise false is returned. It is safe to call this with a value that is not in the range [0, 15]; in that case the return value is always false.

You can assume that LZMA_CHECK_NONE and LZMA_CHECK_CRC32 are always supported (even if liblzma is built with limited features).

References LZMA_CHECK_ID_MAX.

uint32_t lzma_check_size ( lzma_check  check  )  const

Get the size of the Check field with the given Check ID.

Although not all Check IDs have a check algorithm associated, the size of every Check is already frozen. This function returns the size (in bytes) of the Check field with the specified Check ID. The values are: { 0, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64 }

If the argument is not in the range [0, 15], UINT32_MAX is returned.

References LZMA_CHECK_ID_MAX.

Referenced by lzma_block_buffer_encode(), lzma_block_compressed_size(), lzma_block_unpadded_size(), lzma_index_hash_decode(), parse_block_header(), and parse_check_value().

uint32_t lzma_crc32 ( const uint8_t *  buf,
size_t  size,
uint32_t  crc 
)

Calculate CRC32.

Calculate CRC32 using the polynomial from the IEEE 802.3 standard.

Parameters:
buf Pointer to the input buffer
size Size of the input buffer
crc Previously returned CRC value. This is used to calculate the CRC of a big buffer in smaller chunks. Set to zero when starting a new calculation.
Returns:
Updated CRC value, which can be passed to this function again to continue CRC calculation.

References lzma_crc32_table.

Referenced by lzma_block_header_decode(), lzma_block_header_encode(), lzma_check_update(), lzma_index_hash_decode(), lzma_stream_footer_decode(), lzma_stream_footer_encode(), lzma_stream_header_decode(), and lzma_stream_header_encode().

uint64_t lzma_crc64 ( const uint8_t *  buf,
size_t  size,
uint64_t  crc 
)

Calculate CRC64.

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

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

Referenced by lzma_check_update().

lzma_check lzma_get_check ( const lzma_stream strm  ) 

Get the type of the integrity check.

This function can be called only immediately after lzma_code() has returned LZMA_NO_CHECK, LZMA_UNSUPPORTED_CHECK, or LZMA_GET_CHECK. Calling this function in any other situation has undefined behavior.