Rizin
unix-like reverse engineering framework and cli tools
adler32.c File Reference
#include "adler32.h"
#include <rz_util.h>

Go to the source code of this file.

Functions

bool rz_adler32_init (RzAdler32 *ctx)
 
bool rz_adler32_update (RzAdler32 *ctx, const ut8 *data, size_t len)
 
bool rz_adler32_final (ut8 *digest, RzAdler32 *ctx)
 

Function Documentation

◆ rz_adler32_final()

bool rz_adler32_final ( ut8 digest,
RzAdler32 ctx 
)

Definition at line 23 of file adler32.c.

23  {
24  rz_return_val_if_fail(digest && ctx, false);
25  rz_write_le32(digest, ctx->high << 16 | ctx->low);
26  return true;
27 }
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
static void rz_write_le32(void *dest, ut32 val)
Definition: rz_endian.h:256

References rz_return_val_if_fail, and rz_write_le32().

Referenced by plugin_adler32_final(), and plugin_adler32_small_block().

◆ rz_adler32_init()

bool rz_adler32_init ( RzAdler32 ctx)

Definition at line 7 of file adler32.c.

7  {
9  ctx->low = 1;
10  ctx->high = 0;
11  return true;
12 }

References rz_return_val_if_fail.

Referenced by plugin_adler32_init(), and plugin_adler32_small_block().

◆ rz_adler32_update()

bool rz_adler32_update ( RzAdler32 ctx,
const ut8 data,
size_t  len 
)

Definition at line 14 of file adler32.c.

14  {
15  rz_return_val_if_fail(ctx && data, false);
16  for (size_t index = 0; index < len; index++) {
17  ctx->low = (ctx->low + data[index]) % 65521;
18  ctx->high = (ctx->high + ctx->low) % 65521;
19  }
20  return true;
21 }
size_t len
Definition: 6502dis.c:15

References len, and rz_return_val_if_fail.

Referenced by plugin_adler32_small_block(), and plugin_adler32_update().