Go to the documentation of this file.
37 static void DetectFileSha256RegisterTests(
void);
39 static int g_file_match_list_id = 0;
58 SCLogDebug(
"registering filesha256 rule option");
78 static int SHA256MatchLookupString(
ROHashTable *hash,
const char *
string)
82 void *ptr =
ROHashLookup(hash, &sha256, (uint16_t)
sizeof(sha256));
91 static int SHA256MatchTest01(
void)
108 FAIL_IF(SHA256MatchLookupString(
109 hash,
"9c891edb5da763398969b6aaa86a5d46971bd28a455b20c2067cb512c9f9a0f8") != 1);
110 FAIL_IF(SHA256MatchLookupString(
111 hash,
"6eee51705f34b6cfc7f0c872a7949ec3e3172a908303baf5d67d03b98f70e7e3") != 1);
112 FAIL_IF(SHA256MatchLookupString(
113 hash,
"b12c7d57507286bbbe36d7acf9b34c22c96606ffd904e3c23008399a4a50c047") != 1);
114 FAIL_IF(SHA256MatchLookupString(
115 hash,
"ca496e1ddadc290050339dd75ce8830ad3028ce1556a5368874a4aec3aee114b") != 1);
116 FAIL_IF(SHA256MatchLookupString(
117 hash,
"275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f") != 1);
118 FAIL_IF(SHA256MatchLookupString(
119 hash,
"d765e722e295969c0a5c2d90f549db8b89ab617900bf4698db41c7cdad993bb9") != 1);
121 FAIL_IF(SHA256MatchLookupString(
122 hash,
"3333333333333333333333333333333333333333333333333333333333333333") == 1);
127 void DetectFileSha256RegisterTests(
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.
void DetectFileSha256Register(void)
Registration function for keyword: filesha256.
#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 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)