suricata
datasets-md5.c
Go to the documentation of this file.
1
/* Copyright (C) 2017-2019 Open Information Security Foundation
2
*
3
* You can copy, redistribute or modify this Program under the terms of
4
* the GNU General Public License version 2 as published by the Free
5
* Software Foundation.
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* version 2 along with this program; if not, write to the Free Software
14
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15
* 02110-1301, USA.
16
*/
17
18
/**
19
* \file
20
*
21
* \author Victor Julien <victor@inliniac.net>
22
*/
23
24
#include "
suricata-common.h
"
25
#include "
conf.h
"
26
#include "
datasets.h
"
27
#include "
datasets-md5.h
"
28
#include "
util-thash.h
"
29
#include "
util-print.h
"
30
#include "
util-base64.h
"
// decode base64
31
32
int
Md5StrSet
(
void
*
dst
,
void
*
src
)
33
{
34
Md5Type
*src_s =
src
;
35
Md5Type
*dst_s =
dst
;
36
memcpy(dst_s->
md5
, src_s->
md5
,
sizeof
(dst_s->
md5
));
37
dst_s->
rep
= src_s->
rep
;
38
return
0;
39
}
40
41
bool
Md5StrCompare
(
void
*a,
void
*b)
42
{
43
const
Md5Type
*as = a;
44
const
Md5Type
*bs = b;
45
46
return
(memcmp(as->
md5
, bs->
md5
,
sizeof
(as->
md5
)) == 0);
47
}
48
49
uint32_t
Md5StrHash
(
void
*s)
50
{
51
const
Md5Type
*
str
= s;
52
uint32_t hash = 5381;
53
54
for
(
int
i = 0; i < (int)
sizeof
(
str
->md5); i++) {
55
hash = ((hash << 5) + hash) +
str
->md5[i];
/* hash * 33 + c */
56
}
57
return
hash;
58
}
59
60
// data stays in hash
61
void
Md5StrFree
(
void
*s)
62
{
63
}
datasets-md5.h
Md5Type
Definition:
datasets-md5.h:29
Md5Type::rep
DataRepType rep
Definition:
datasets-md5.h:31
util-base64.h
Md5Type::md5
uint8_t md5[16]
Definition:
datasets-md5.h:30
Md5StrCompare
bool Md5StrCompare(void *a, void *b)
Definition:
datasets-md5.c:41
Md5StrHash
uint32_t Md5StrHash(void *s)
Definition:
datasets-md5.c:49
datasets.h
util-print.h
conf.h
suricata-common.h
Md5StrSet
int Md5StrSet(void *dst, void *src)
Definition:
datasets-md5.c:32
str
#define str(s)
Definition:
suricata-common.h:286
src
uint16_t src
Definition:
app-layer-dnp3.h:5
dst
uint16_t dst
Definition:
app-layer-dnp3.h:4
util-thash.h
Md5StrFree
void Md5StrFree(void *s)
Definition:
datasets-md5.c:61
src
datasets-md5.c
Generated on Sat Sep 23 2023 23:30:28 for suricata by
1.8.18