Rizin
unix-like reverse engineering framework and cli tools
mod255.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 deroad <wargio@libero.it>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include "mod255.h"
5 #include <rz_util.h>
6 
9  *ctx = 0;
10  return true;
11 }
12 
13 bool rz_mod255_update(RzMod255 *ctx, const ut8 *data, size_t len) {
14  rz_return_val_if_fail(ctx && data, false);
15  ut8 value = *ctx;
16  for (size_t i = 0; i < len; ++i) {
17  value += data[i];
18  }
19  *ctx = value;
20  return true;
21 }
22 
23 bool rz_mod255_final(ut8 *digest, RzMod255 *ctx) {
24  rz_return_val_if_fail(digest && ctx, false);
25  *digest = (*ctx) % 255;
26  return true;
27 }
size_t len
Definition: 6502dis.c:15
lzma_index ** i
Definition: index.h:629
static int value
Definition: cmd_api.c:93
uint8_t ut8
Definition: lh5801.h:11
bool rz_mod255_update(RzMod255 *ctx, const ut8 *data, size_t len)
Definition: mod255.c:13
bool rz_mod255_init(RzMod255 *ctx)
Definition: mod255.c:7
bool rz_mod255_final(ut8 *digest, RzMod255 *ctx)
Definition: mod255.c:23
ut32 RzMod255
Definition: mod255.h:12
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108