Go to the documentation of this file.
37 static void DetectFileSha1RegisterTests(
void);
39 static int g_file_match_list_id = 0;
57 SCLogDebug(
"registering filesha1 rule option");
74 static int SHA1MatchLookupString(
ROHashTable *hash,
const char *
string)
78 void *ptr =
ROHashLookup(hash, &sha1, (uint16_t)
sizeof(sha1));
87 static int SHA1MatchTest01(
void)
106 FAIL_IF(SHA1MatchLookupString(hash,
"447661c5de965bd4d837b50244467e37bddc184d") != 1);
107 FAIL_IF(SHA1MatchLookupString(hash,
"75a9af1e34dc0bb2f7fcde9d56b2503072ac35dd") != 1);
108 FAIL_IF(SHA1MatchLookupString(hash,
"53224a297bbb30631670fdcd2d295d87a1d328e9") != 1);
109 FAIL_IF(SHA1MatchLookupString(hash,
"3395856ce81f2b7382dee72602f798b642f14140") != 1);
110 FAIL_IF(SHA1MatchLookupString(hash,
"65559245709fe98052eb284577f1fd61c01ad20d") != 1);
111 FAIL_IF(SHA1MatchLookupString(hash,
"0931fd4e05e6ea81c75f8488ecc1db9e66f22cbb") != 1);
113 FAIL_IF(SHA1MatchLookupString(hash,
"3333333333333333333333333333333333333333") == 1);
119 static void DetectFileSha1RegisterTests(
void)
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
SigTableElmt * sigmatch_table
void(* Free)(DetectEngineCtx *, void *)
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
int(* FileMatch)(DetectEngineThreadCtx *, Flow *, uint8_t flags, File *, const Signature *, const SigMatchCtx *)
main detection engine ctx
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
int ROHashInitFinalize(ROHashTable *table)
create final hash data structure
void DetectFileHashFree(DetectEngineCtx *de_ctx, void *ptr)
this function will free memory associated with DetectFileHashData
#define PASS
Pass the test.
int DetectFileHashSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str, uint16_t type, int list)
this function is used to parse filemd5, filesha1 and filesha256 options
void * ROHashLookup(ROHashTable *table, void *data, uint16_t size)
int DetectFileHashMatch(DetectEngineThreadCtx *det_ctx, Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchCtx *m)
Match the specified file hash.
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
int DetectBufferTypeRegister(const char *name)
ROHashTable * ROHashInit(uint8_t hash_bits, uint16_t item_size)
initialize a new rohash
void DetectFileSha1Register(void)
Registration function for keyword: filesha1.
void ROHashFree(ROHashTable *table)
int LoadHashTable(ROHashTable *hash_table, const char *string, const char *filename, int line_no, uint32_t type)
Store a hash into the hash table.
int ReadHashString(uint8_t *hash, const char *string, const char *filename, int line_no, uint16_t expected_len)
Read the bytes of a hash from an hexadecimal string.
void(* RegisterTests)(void)