libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
Loading...
Searching...
No Matches
spamsum.c File Reference
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "aaruformat.h"
#include "spamsum.h"

Go to the source code of this file.

Macros

#define ROLL_SUM(ctx)
#define SUM_HASH(c, h)
#define SSDEEP_BS(index)

Functions

spamsum_ctxaaruf_spamsum_init (void)
int aaruf_spamsum_update (spamsum_ctx *ctx, const uint8_t *data, const uint32_t len)
 Updates the spamsum context with new data.
void aaruf_spamsum_free (spamsum_ctx *ctx)
 Frees a spamsum (fuzzy hash) context.
void fuzzy_engine_step (spamsum_ctx *ctx, uint8_t c)
void roll_hash (spamsum_ctx *ctx, uint8_t c)
void fuzzy_try_reduce_blockhash (spamsum_ctx *ctx)
void fuzzy_try_fork_blockhash (spamsum_ctx *ctx)
int aaruf_spamsum_final (spamsum_ctx *ctx, uint8_t *result)

Variables

static uint8_t b64 []

Macro Definition Documentation

◆ ROLL_SUM

#define ROLL_SUM ( ctx)
Value:
((ctx)->roll.h1 + (ctx)->roll.h2 + (ctx)->roll.h3)

Definition at line 80 of file spamsum.c.

Referenced by aaruf_spamsum_final(), and fuzzy_engine_step().

◆ SSDEEP_BS

#define SSDEEP_BS ( index)
Value:
(MIN_BLOCKSIZE << (index))
#define MIN_BLOCKSIZE
Definition spamsum.h:29

Definition at line 82 of file spamsum.c.

Referenced by aaruf_spamsum_final(), fuzzy_engine_step(), and fuzzy_try_reduce_blockhash().

◆ SUM_HASH

#define SUM_HASH ( c,
h )
Value:
(((h) * HASH_PRIME) ^ (c));
#define HASH_PRIME
Definition spamsum.h:28

Definition at line 81 of file spamsum.c.

Referenced by fuzzy_engine_step().

Function Documentation

◆ aaruf_spamsum_final()

◆ aaruf_spamsum_free()

void aaruf_spamsum_free ( spamsum_ctx * ctx)

Frees a spamsum (fuzzy hash) context.

Parameters
ctxPointer to the spamsum context to free.

Definition at line 75 of file spamsum.c.

References AARU_CALL, and AARU_EXPORT.

Referenced by cleanup_failed_create(), and write_checksum_block().

◆ aaruf_spamsum_init()

spamsum_ctx * aaruf_spamsum_init ( void )

◆ aaruf_spamsum_update()

int aaruf_spamsum_update ( spamsum_ctx * ctx,
const uint8_t * data,
const uint32_t len )

Updates the spamsum context with new data.

Parameters
ctxPointer to the spamsum context.
dataPointer to the data to process.
lenLength of the data in bytes.
Returns
0 on success, -1 on error.

Definition at line 59 of file spamsum.c.

References AARU_CALL, AARU_EXPORT, fuzzy_engine_step(), and spamsum_ctx::total_size.

Referenced by aaruf_write_sector(), and aaruf_write_sector_long().

◆ fuzzy_engine_step()

◆ fuzzy_try_fork_blockhash()

◆ fuzzy_try_reduce_blockhash()

void fuzzy_try_reduce_blockhash ( spamsum_ctx * ctx)
inline

◆ roll_hash()

void roll_hash ( spamsum_ctx * ctx,
uint8_t c )
inline

Variable Documentation

◆ b64

uint8_t b64[]
static
Initial value:
= {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F}

Definition at line 32 of file spamsum.c.

Referenced by aaruf_spamsum_final(), and fuzzy_engine_step().