Data hashing, integrity and generic compression.
More...
|
u32 | gf_crc_32 (const u8 *data, u32 size) |
| CRC32 compute. More...
|
|
GF_Err | gf_gz_compress_payload (u8 **data, u32 data_len, u32 *out_size) |
|
GF_Err | gf_gz_compress_payload_ex (u8 **data, u32 data_len, u32 *out_size, u8 data_offset, Bool skip_if_larger, u8 **out_comp_data, Bool use_gz) |
|
GF_Err | gf_gz_decompress_payload (u8 *data, u32 data_len, u8 **uncompressed_data, u32 *out_size) |
|
GF_Err | gf_gz_decompress_payload_ex (u8 *data, u32 data_len, u8 **uncompressed_data, u32 *out_size, Bool use_gz) |
|
GF_Err | gf_lz_compress_payload (u8 **data, u32 data_len, u32 *out_size) |
|
GF_Err | gf_lz_decompress_payload (u8 *data, u32 data_len, u8 **uncompressed_data, u32 *out_size) |
|
u64 | gf_gzseek (void *file, u64 offset, int whence) |
|
u64 | gf_gztell (void *file) |
|
s64 | gf_gzrewind (void *file) |
|
int | gf_gzeof (void *file) |
|
int | gf_gzclose (void *file) |
|
const char * | gf_gzerror (void *file, int *errnum) |
|
void | gf_gzclearerr (void *file) |
|
void * | gf_gzopen (const char *path, const char *mode) |
|
int | gf_gzread (void *file, void *buf, unsigned len) |
|
int | gf_gzdirect (void *file) |
|
int | gf_gzgetc (void *file) |
|
char * | gf_gzgets (void *file, char *buf, int len) |
|
GF_SHA1Context * | gf_sha1_starts () |
|
void | gf_sha1_update (GF_SHA1Context *ctx, u8 *input, u32 length) |
|
void | gf_sha1_finish (GF_SHA1Context *ctx, u8 digest[GF_SHA1_DIGEST_SIZE]) |
|
GF_Err | gf_sha1_file (const char *filename, u8 digest[GF_SHA1_DIGEST_SIZE]) |
|
GF_Err | gf_sha1_file_ptr (FILE *file, u8 digest[GF_SHA1_DIGEST_SIZE]) |
|
void | gf_sha1_csum (u8 *buf, u32 buflen, u8 digest[GF_SHA1_DIGEST_SIZE]) |
|
This section documents misc data functions such as integrity and parsing such as SHA-1 hashing CRC checksum, 128 bit ID parsing...
◆ GF_SHA1_DIGEST_SIZE
#define GF_SHA1_DIGEST_SIZE 20 |
◆ GF_SHA1Context
◆ gf_crc_32()
u32 gf_crc_32 |
( |
const u8 * |
data, |
|
|
u32 |
size |
|
) |
| |
Computes the CRC32 value of a buffer.
- Parameters
-
data | buffer |
size | buffer size |
- Returns
- computed CRC32
◆ gf_gz_compress_payload()
GF_Err gf_gz_compress_payload |
( |
u8 ** |
data, |
|
|
u32 |
data_len, |
|
|
u32 * |
out_size |
|
) |
| |
Compresses a data buffer in place using zlib/deflate. Buffer may be reallocated in the process.
- Parameters
-
data | pointer to the data buffer to be compressed |
data_len | length of the data buffer to be compressed |
out_size | pointer for output buffer size |
- Returns
- error if any
◆ gf_gz_compress_payload_ex()
GF_Err gf_gz_compress_payload_ex |
( |
u8 ** |
data, |
|
|
u32 |
data_len, |
|
|
u32 * |
out_size, |
|
|
u8 |
data_offset, |
|
|
Bool |
skip_if_larger, |
|
|
u8 ** |
out_comp_data, |
|
|
Bool |
use_gz |
|
) |
| |
Compresses a data buffer in place using zlib/deflate. Buffer may be reallocated in the process.
- Parameters
-
data | pointer to the data buffer to be compressed |
data_len | length of the data buffer to be compressed |
out_size | pointer for output buffer size |
data_offset | offset in source buffer - the input payload size is data_len - data_offset |
skip_if_larger | if GF_TRUE, will not override source buffer if compressed version is larger than input data |
out_comp_data | if not NULL, the compressed result is set in this pointer rather than doing inplace compression |
use_gz | if true, GZ header is present |
- Returns
- error if any
◆ gf_gz_decompress_payload()
GF_Err gf_gz_decompress_payload |
( |
u8 * |
data, |
|
|
u32 |
data_len, |
|
|
u8 ** |
uncompressed_data, |
|
|
u32 * |
out_size |
|
) |
| |
Decompresses a data buffer using zlib/inflate.
- Parameters
-
data | data buffer to be decompressed |
data_len | length of the data buffer to be decompressed |
uncompressed_data | pointer to the uncompressed data buffer. The resulting buffer is NULL-terminated. It is the responsibility of the caller to free this buffer. |
out_size | size of the uncompressed buffer |
- Returns
- error if any
◆ gf_gz_decompress_payload_ex()
GF_Err gf_gz_decompress_payload_ex |
( |
u8 * |
data, |
|
|
u32 |
data_len, |
|
|
u8 ** |
uncompressed_data, |
|
|
u32 * |
out_size, |
|
|
Bool |
use_gz |
|
) |
| |
Decompresses a data buffer using zlib/inflate.
- Parameters
-
data | data buffer to be decompressed |
data_len | length of the data buffer to be decompressed |
uncompressed_data | pointer to the uncompressed data buffer. The resulting buffer is NULL-terminated. It is the responsibility of the caller to free this buffer. |
out_size | size of the uncompressed buffer |
use_gz | if true, gz header is present |
- Returns
- error if any
◆ gf_lz_compress_payload()
GF_Err gf_lz_compress_payload |
( |
u8 ** |
data, |
|
|
u32 |
data_len, |
|
|
u32 * |
out_size |
|
) |
| |
Compresses a data buffer in place using LZMA. Buffer may be reallocated in the process.
- Parameters
-
data | pointer to the data buffer to be compressed |
data_len | length of the data buffer to be compressed |
out_size | pointer for output buffer size |
- Returns
- error if any
◆ gf_lz_decompress_payload()
GF_Err gf_lz_decompress_payload |
( |
u8 * |
data, |
|
|
u32 |
data_len, |
|
|
u8 ** |
uncompressed_data, |
|
|
u32 * |
out_size |
|
) |
| |
Decompresses a data buffer using LZMA.
- Parameters
-
data | data buffer to be decompressed |
data_len | length of the data buffer to be decompressed |
uncompressed_data | pointer to the uncompressed data buffer. It is the responsibility of the caller to free this buffer. |
out_size | size of the uncompressed buffer |
- Returns
- error if any
◆ gf_gzseek()
u64 gf_gzseek |
( |
void * |
file, |
|
|
u64 |
offset, |
|
|
int |
whence |
|
) |
| |
Wrapper around gzseek, same parameters
- Parameters
-
file | target gzfile |
offset | offset in file |
whence | same as gzseek |
- Returns
- same as gzseek
◆ gf_gztell()
u64 gf_gztell |
( |
void * |
file | ) |
|
Wrapper around gf_gztell, same parameters
- Parameters
-
- Returns
- postion in file
◆ gf_gzrewind()
s64 gf_gzrewind |
( |
void * |
file | ) |
|
Wrapper around gzrewind, same parameters
- Parameters
-
- Returns
- same as gzrewind
◆ gf_gzeof()
int gf_gzeof |
( |
void * |
file | ) |
|
Wrapper around gzeof, same parameters
- Parameters
-
- Returns
- same as gzeof
◆ gf_gzclose()
int gf_gzclose |
( |
void * |
file | ) |
|
Wrapper around gzclose, same parameters
- Parameters
-
- Returns
- same as gzclose
◆ gf_gzerror()
const char* gf_gzerror |
( |
void * |
file, |
|
|
int * |
errnum |
|
) |
| |
Wrapper around gzerror, same parameters
- Parameters
-
file | target gzfile |
errnum | same as gzerror |
- Returns
- same as gzerror
◆ gf_gzclearerr()
void gf_gzclearerr |
( |
void * |
file | ) |
|
Wrapper around gzclearerr, same parameters
- Parameters
-
◆ gf_gzopen()
void* gf_gzopen |
( |
const char * |
path, |
|
|
const char * |
mode |
|
) |
| |
Wrapper around gzopen, same parameters
- Parameters
-
path | the file name to open |
mode | the file open mode |
- Returns
- open file
◆ gf_gzread()
int gf_gzread |
( |
void * |
file, |
|
|
void * |
buf, |
|
|
unsigned |
len |
|
) |
| |
Wrapper around gzread, same parameters
- Parameters
-
file | target gzfile |
buf | same as gzread |
len | same as gzread |
- Returns
- same as gzread
◆ gf_gzdirect()
int gf_gzdirect |
( |
void * |
file | ) |
|
Wrapper around gzdirect, same parameters
- Parameters
-
- Returns
- same as gzdirect
◆ gf_gzgetc()
int gf_gzgetc |
( |
void * |
file | ) |
|
Wrapper around gzgetc, same parameters
- Parameters
-
- Returns
- same as gzgetc
◆ gf_gzgets()
char* gf_gzgets |
( |
void * |
file, |
|
|
char * |
buf, |
|
|
int |
len |
|
) |
| |
Wrapper around gzgets, same parameters
- Parameters
-
file | target gzfile |
buf | same as gzread |
len | same as gzread |
- Returns
- same as gzgets
◆ gf_sha1_starts()
create SHA-1 context
- Returns
- the SHA1 context
◆ gf_sha1_update()
adds byte to the SHA-1 context
- Parameters
-
ctx | the target SHA1 context |
input | data to hash |
length | size of data in bytes |
◆ gf_sha1_finish()
generates SHA-1 of all bytes ingested
- Parameters
-
ctx | the target SHA1 context |
digest | buffer to store message digest |
◆ gf_sha1_file()
GF_Err gf_sha1_file |
( |
const char * |
filename, |
|
|
u8 |
digest[GF_SHA1_DIGEST_SIZE] |
|
) |
| |
gets SHA1 message digest of a file
- Parameters
-
filename | name of file to hash |
digest | buffer to store message digest |
- Returns
- error if any
◆ gf_sha1_file_ptr()
GF_Err gf_sha1_file_ptr |
( |
FILE * |
file, |
|
|
u8 |
digest[GF_SHA1_DIGEST_SIZE] |
|
) |
| |
gets SHA1 message digest of a opened file
- Parameters
-
file | handle to open file |
digest | buffer to store message digest |
- Returns
- error if any
◆ gf_sha1_csum()
void gf_sha1_csum |
( |
u8 * |
buf, |
|
|
u32 |
buflen, |
|
|
u8 |
digest[GF_SHA1_DIGEST_SIZE] |
|
) |
| |
gets SHA-1 of input buffer
- Parameters
-
buf | input buffer to hash |
buflen | size of input buffer in bytes |
digest | buffer to store message digest |