The rs_signature class implementation of a file signature.
More...
Go to the source code of this file.
|
rs_result | rs_signature_init (rs_signature_t *sig, rs_magic_number magic, size_t block_len, size_t strong_len, rs_long_t sig_fsize) |
| Initialize an rs_signature instance. More...
|
|
void | rs_signature_done (rs_signature_t *sig) |
| Destroy an rs_signature instance. More...
|
|
rs_block_sig_t * | rs_signature_add_block (rs_signature_t *sig, rs_weak_sum_t weak_sum, rs_strong_sum_t *strong_sum) |
| Add a block to an rs_signature instance. More...
|
|
rs_long_t | rs_signature_find_match (rs_signature_t *sig, rs_weak_sum_t weak_sum, void const *buf, size_t len) |
| Find a matching block offset in a signature. More...
|
|
static weaksum_kind_t | rs_signature_weaksum_kind (rs_signature_t const *sig) |
| Get the weaksum kind for a signature. More...
|
|
static strongsum_kind_t | rs_signature_strongsum_kind (rs_signature_t const *sig) |
| Get the strongsum kind for a signature. More...
|
|
static rs_weak_sum_t | rs_signature_calc_weak_sum (rs_signature_t const *sig, void const *buf, size_t len) |
| Calculate the weak sum of a buffer. More...
|
|
static void | rs_signature_calc_strong_sum (rs_signature_t const *sig, void const *buf, size_t len, rs_strong_sum_t *sum) |
| Calculate the strong sum of a buffer. More...
|
|
The rs_signature class implementation of a file signature.
Definition in file sumset.h.
◆ rs_sig_args_check
#define rs_sig_args_check |
( |
|
magic, |
|
|
|
block_len, |
|
|
|
strong_len |
|
) |
| |
Value: do {\
assert(((magic) & 0xf0) == 0x30 || ((magic) & 0xf0) == 0x40);\
assert((((magic) & 0x0f) == 0x06 &&\
(int)(strong_len) <= RS_MD4_SUM_LENGTH) ||\
(((magic) & 0x0f) == 0x07 &&\
(int)(strong_len) <= RS_BLAKE2_SUM_LENGTH));\
assert(0 < (block_len));\
assert(0 < (strong_len) && (strong_len) <= RS_MAX_STRONG_SUM_LENGTH);\
} while (0)
@ RS_MD4_SIG_MAGIC
A signature file with MD4 signatures.
Assert that rs_sig_args() args for rs_signature_init() are valid.
We don't use a static inline function here so that assert failure output points at where rs_sig_args_check() was called from.
Definition at line 92 of file sumset.h.
◆ rs_signature_check
#define rs_signature_check |
( |
|
sig | ) |
|
Value: do {\
rs_sig_args_check((sig)->magic, (sig)->block_len, (sig)->strong_sum_len);\
assert(0 <= (sig)->count && (sig)->count <= (sig)->size);\
} while (0)
int count
Number of entries in hashtable.
Assert that a signature is valid.
We don't use a static inline function here so that assert failure output points at where rs_signature_check() was called from.
Definition at line 107 of file sumset.h.
◆ rs_block_sig_t
Signature of a single block.
◆ rs_signature_init()
Initialize an rs_signature instance.
- Parameters
-
*sig | the signature to initialize. |
magic | - the magic type to use (0 for "recommended"). |
block_len | - the block length to use (0 for "recommended"). |
strong_len | - the strongsum length to use (0 for "maximum", -1 for "minimum"). Must be <= the max strongsum size for the strongsum type indicated by the magic value. |
sig_fsize | - the signature file size (-1 for "unknown"). Used to preallocate required storage. |
Definition at line 183 of file sumset.c.
◆ rs_signature_done()
◆ rs_signature_add_block()
◆ rs_signature_find_match()
rs_long_t rs_signature_find_match |
( |
rs_signature_t * |
sig, |
|
|
rs_weak_sum_t |
weak_sum, |
|
|
void const * |
buf, |
|
|
size_t |
len |
|
) |
| |
Find a matching block offset in a signature.
Definition at line 242 of file sumset.c.
◆ rs_signature_weaksum_kind()
Get the weaksum kind for a signature.
Definition at line 114 of file sumset.h.
◆ rs_signature_strongsum_kind()
Get the strongsum kind for a signature.
Definition at line 121 of file sumset.h.
◆ rs_signature_calc_weak_sum()
static rs_weak_sum_t rs_signature_calc_weak_sum |
( |
rs_signature_t const * |
sig, |
|
|
void const * |
buf, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
Calculate the weak sum of a buffer.
Definition at line 128 of file sumset.h.
◆ rs_signature_calc_strong_sum()
static void rs_signature_calc_strong_sum |
( |
rs_signature_t const * |
sig, |
|
|
void const * |
buf, |
|
|
size_t |
len, |
|
|
rs_strong_sum_t * |
sum |
|
) |
| |
|
inlinestatic |
Calculate the strong sum of a buffer.
Definition at line 136 of file sumset.h.