Rizin
unix-like reverse engineering framework and cli tools
xor.h File Reference
#include <rz_types.h>

Go to the source code of this file.

Macros

#define RZ_HASH_XOR8_DIGEST_SIZE   1
 
#define RZ_HASH_XOR_BLOCK_LENGTH   0
 
#define RZ_HASH_XOR16_DIGEST_SIZE   2
 

Typedefs

typedef ut8 RzXor8
 
typedef ut16 RzXor16
 

Functions

bool rz_xor8_init (RzXor8 *ctx)
 
bool rz_xor8_update (RzXor8 *ctx, const ut8 *data, size_t len)
 
bool rz_xor8_final (ut8 *digest, RzXor8 *ctx)
 
bool rz_xor16_init (RzXor16 *ctx)
 
bool rz_xor16_update (RzXor16 *ctx, const ut8 *data, size_t len)
 
bool rz_xor16_final (ut8 *digest, RzXor16 *ctx)
 

Macro Definition Documentation

◆ RZ_HASH_XOR16_DIGEST_SIZE

#define RZ_HASH_XOR16_DIGEST_SIZE   2

Definition at line 18 of file xor.h.

◆ RZ_HASH_XOR8_DIGEST_SIZE

#define RZ_HASH_XOR8_DIGEST_SIZE   1

Definition at line 9 of file xor.h.

◆ RZ_HASH_XOR_BLOCK_LENGTH

#define RZ_HASH_XOR_BLOCK_LENGTH   0

Definition at line 10 of file xor.h.

Typedef Documentation

◆ RzXor16

typedef ut16 RzXor16

Definition at line 20 of file xor.h.

◆ RzXor8

typedef ut8 RzXor8

Definition at line 12 of file xor.h.

Function Documentation

◆ rz_xor16_final()

bool rz_xor16_final ( ut8 digest,
RzXor16 ctx 
)

Definition at line 49 of file xor.c.

49  {
50  rz_return_val_if_fail(digest && ctx, false);
51  rz_write_le16(digest, *ctx);
52  return true;
53 }
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
static void rz_write_le16(void *dest, ut16 val)
Definition: rz_endian.h:222

References rz_return_val_if_fail, and rz_write_le16().

Referenced by plugin_xor16_final(), and plugin_xor16_small_block().

◆ rz_xor16_init()

bool rz_xor16_init ( RzXor16 ctx)

Definition at line 29 of file xor.c.

29  {
30  rz_return_val_if_fail(ctx, false);
31  *ctx = 0;
32  return true;
33 }

References rz_return_val_if_fail.

Referenced by plugin_xor16_init(), and plugin_xor16_small_block().

◆ rz_xor16_update()

bool rz_xor16_update ( RzXor16 ctx,
const ut8 data,
size_t  len 
)

Definition at line 35 of file xor.c.

35  {
36  rz_return_val_if_fail(ctx && data, false);
37  ut16 value = *ctx;
38  for (size_t i = 0; i < len; i += sizeof(ut16)) {
39  if (len - i > sizeof(ut16)) {
40  value ^= rz_read_at_le16(data, i);
41  } else {
42  value ^= (((ut16)data[i]) << 8);
43  }
44  }
45  *ctx = value;
46  return true;
47 }
size_t len
Definition: 6502dis.c:15
lzma_index ** i
Definition: index.h:629
static int value
Definition: cmd_api.c:93
uint16_t ut16
static ut16 rz_read_at_le16(const void *src, size_t offset)
Definition: rz_endian.h:214

References i, len, rz_read_at_le16(), rz_return_val_if_fail, and value.

Referenced by plugin_xor16_small_block(), and plugin_xor16_update().

◆ rz_xor8_final()

bool rz_xor8_final ( ut8 digest,
RzXor8 ctx 
)

Definition at line 23 of file xor.c.

23  {
24  rz_return_val_if_fail(digest && ctx, false);
25  *digest = *ctx;
26  return true;
27 }

References rz_return_val_if_fail.

Referenced by plugin_xor8_final(), and plugin_xor8_small_block().

◆ rz_xor8_init()

bool rz_xor8_init ( RzXor8 ctx)

Definition at line 7 of file xor.c.

7  {
9  *ctx = 0;
10  return true;
11 }

References rz_return_val_if_fail.

Referenced by plugin_xor8_init(), and plugin_xor8_small_block().

◆ rz_xor8_update()

bool rz_xor8_update ( RzXor8 ctx,
const ut8 data,
size_t  len 
)

Definition at line 13 of file xor.c.

13  {
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 }
uint8_t ut8
Definition: lh5801.h:11

References i, len, rz_return_val_if_fail, and value.

Referenced by plugin_xor8_small_block(), and plugin_xor8_update().