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

Go to the source code of this file.

Functions

static bool punycode_set_key (RzCrypto *cry, const ut8 *key, int keylen, int mode, int direction)
 
static int punycode_get_key_size (RzCrypto *cry)
 
static bool punycode_use (const char *algo)
 
static bool update (RzCrypto *cry, const ut8 *buf, int len)
 
static bool final (RzCrypto *cry, const ut8 *buf, int len)
 

Variables

RzCryptoPlugin rz_crypto_plugin_punycode
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ final()

static bool final ( RzCrypto cry,
const ut8 buf,
int  len 
)
static

Definition at line 38 of file crypto_punycode.c.

38  {
39  return update(cry, buf, len);
40 }
size_t len
Definition: 6502dis.c:15
static bool update(RzCrypto *cry, const ut8 *buf, int len)
voidpf void * buf
Definition: ioapi.h:138

References len, and update().

◆ punycode_get_key_size()

static int punycode_get_key_size ( RzCrypto cry)
static

Definition at line 13 of file crypto_punycode.c.

13  {
14  return 0;
15 }

◆ punycode_set_key()

static bool punycode_set_key ( RzCrypto cry,
const ut8 key,
int  keylen,
int  mode,
int  direction 
)
static

Definition at line 8 of file crypto_punycode.c.

8  {
9  cry->dir = direction;
10  return true;
11 }

References rz_crypto_t::dir.

◆ punycode_use()

static bool punycode_use ( const char *  algo)
static

Definition at line 17 of file crypto_punycode.c.

17  {
18  return !strcmp(algo, "punycode");
19 }

◆ update()

static bool update ( RzCrypto cry,
const ut8 buf,
int  len 
)
static

Definition at line 21 of file crypto_punycode.c.

21  {
22  if (len < 1 || !buf) {
23  return false;
24  }
25 
26  char *obuf;
27  int olen;
28  if (cry->dir == RZ_CRYPTO_DIR_DECRYPT) {
29  obuf = rz_punycode_decode((const char *)buf, len, &olen);
30  } else {
31  obuf = rz_punycode_encode(buf, len, &olen);
32  }
33  rz_crypto_append(cry, (ut8 *)obuf, olen);
34  free(obuf);
35  return true;
36 }
RZ_API int rz_crypto_append(RzCrypto *cry, const ut8 *buf, int len)
Definition: crypto.c:175
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
uint8_t ut8
Definition: lh5801.h:11
@ RZ_CRYPTO_DIR_DECRYPT
Definition: rz_crypto.h:24
RZ_API char * rz_punycode_encode(const ut8 *src, int srclen, int *dstlen)
Definition: punycode.c:176
RZ_API char * rz_punycode_decode(const char *src, int srclen, int *dstlen)
Definition: punycode.c:255
static unsigned char * obuf
Definition: z80asm.c:36

References rz_crypto_t::dir, free(), len, obuf, rz_crypto_append(), RZ_CRYPTO_DIR_DECRYPT, rz_punycode_decode(), and rz_punycode_encode().

Referenced by final().

Variable Documentation

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
.version = RZ_VERSION
}
RzCryptoPlugin rz_crypto_plugin_punycode
@ RZ_LIB_TYPE_CRYPTO
Definition: rz_lib.h:81
#define RZ_VERSION
Definition: rz_version.h:8

Definition at line 54 of file crypto_punycode.c.

◆ rz_crypto_plugin_punycode

RzCryptoPlugin rz_crypto_plugin_punycode
Initial value:
= {
.name = "punycode",
.author = "pancake",
.license = "LGPL-3",
.set_key = punycode_set_key,
.get_key_size = punycode_get_key_size,
.use = punycode_use,
.update = update,
.final = final
}
static bool punycode_set_key(RzCrypto *cry, const ut8 *key, int keylen, int mode, int direction)
static bool punycode_use(const char *algo)
static int punycode_get_key_size(RzCrypto *cry)

Definition at line 42 of file crypto_punycode.c.