libaaruformat
1.0
Aaru Data Preservation Suite - Format Library
Loading...
Searching...
No Matches
spamsum.h
Go to the documentation of this file.
1
/*
2
* This file is part of the Aaru Data Preservation Suite.
3
* Copyright (c) 2019-2025 Natalia Portillo.
4
*
5
* This library is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU Lesser General Public License as
7
* published by the Free Software Foundation; either version 2.1 of the
8
* License, or (at your option) any later version.
9
*
10
* This library is distributed in the hope that it will be useful, but
11
* WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
14
*
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#ifndef LIBAARUFORMAT_SPAMSUM_H_
20
#define LIBAARUFORMAT_SPAMSUM_H_
21
22
#include <stdint.h>
23
24
#define SPAMSUM_LENGTH 64
25
#define NUM_BLOCKHASHES 31
26
#define ROLLING_WINDOW 7
27
#define HASH_INIT 0x28021967
28
#define HASH_PRIME 0x01000193
29
#define MIN_BLOCKSIZE 3
30
#define FUZZY_MAX_RESULT ((2 * SPAMSUM_LENGTH) + 20)
31
32
typedef
struct
33
{
34
uint32_t
h
;
35
uint32_t
half_h
;
36
uint8_t
digest
[
SPAMSUM_LENGTH
];
37
uint8_t
half_digest
;
38
uint32_t
d_len
;
39
}
blockhash_ctx
;
40
41
typedef
struct
42
{
43
uint8_t
window
[
ROLLING_WINDOW
];
44
uint32_t
h1
;
45
uint32_t
h2
;
46
uint32_t
h3
;
47
uint32_t
n
;
48
}
roll_state
;
49
50
typedef
struct
51
{
52
uint32_t
bh_start
;
53
uint32_t
bh_end
;
54
blockhash_ctx
bh
[
NUM_BLOCKHASHES
];
55
uint64_t
total_size
;
56
roll_state
roll
;
57
}
spamsum_ctx
;
58
59
#endif
// LIBAARUFORMAT_SPAMSUM_H_
SPAMSUM_LENGTH
#define SPAMSUM_LENGTH
Definition
spamsum.h:24
ROLLING_WINDOW
#define ROLLING_WINDOW
Definition
spamsum.h:26
NUM_BLOCKHASHES
#define NUM_BLOCKHASHES
Definition
spamsum.h:25
blockhash_ctx
Definition
spamsum.h:33
blockhash_ctx::d_len
uint32_t d_len
Definition
spamsum.h:38
blockhash_ctx::h
uint32_t h
Definition
spamsum.h:34
blockhash_ctx::half_digest
uint8_t half_digest
Definition
spamsum.h:37
blockhash_ctx::digest
uint8_t digest[64]
Definition
spamsum.h:36
blockhash_ctx::half_h
uint32_t half_h
Definition
spamsum.h:35
roll_state
Definition
spamsum.h:42
roll_state::h2
uint32_t h2
Definition
spamsum.h:45
roll_state::n
uint32_t n
Definition
spamsum.h:47
roll_state::h1
uint32_t h1
Definition
spamsum.h:44
roll_state::h3
uint32_t h3
Definition
spamsum.h:46
roll_state::window
uint8_t window[7]
Definition
spamsum.h:43
spamsum_ctx
Definition
spamsum.h:51
spamsum_ctx::bh
blockhash_ctx bh[31]
Definition
spamsum.h:54
spamsum_ctx::roll
roll_state roll
Definition
spamsum.h:56
spamsum_ctx::bh_end
uint32_t bh_end
Definition
spamsum.h:53
spamsum_ctx::total_size
uint64_t total_size
Definition
spamsum.h:55
spamsum_ctx::bh_start
uint32_t bh_start
Definition
spamsum.h:52
include
aaruformat
spamsum.h
Generated by
1.14.0