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

Go to the source code of this file.

Macros

#define INSIZE   32768
 

Functions

static bool base91_set_key (RzCrypto *cry, const ut8 *key, int keylen, int mode, int direction)
 
static int base91_get_key_size (RzCrypto *cry)
 
static bool base91_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_base91
 
RZ_API RzLibStruct rizin_plugin
 

Macro Definition Documentation

◆ INSIZE

#define INSIZE   32768

Definition at line 8 of file crypto_base91.c.

Function Documentation

◆ base91_get_key_size()

static int base91_get_key_size ( RzCrypto cry)
static

Definition at line 15 of file crypto_base91.c.

15  {
16  return 0;
17 }

◆ base91_set_key()

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

Definition at line 10 of file crypto_base91.c.

10  {
11  cry->dir = direction;
12  return true;
13 }

References rz_crypto_t::dir.

◆ base91_use()

static bool base91_use ( const char *  algo)
static

Definition at line 19 of file crypto_base91.c.

19  {
20  return algo && !strcmp(algo, "base91");
21 }

◆ final()

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

Definition at line 49 of file crypto_base91.c.

49  {
50  return update(cry, buf, len);
51 }
size_t len
Definition: 6502dis.c:15
static bool update(RzCrypto *cry, const ut8 *buf, int len)
Definition: crypto_base91.c:23
voidpf void * buf
Definition: ioapi.h:138

References len, and update().

◆ update()

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

Definition at line 23 of file crypto_base91.c.

23  {
24  if (len < 1) {
25  return false;
26  }
27 
28  int olen = INSIZE;
29  if (!cry || !buf || len < 1) {
30  return false;
31  }
32  ut8 *obuf = malloc(olen);
33  if (!obuf) {
34  return false;
35  }
36  if (cry->dir == RZ_CRYPTO_DIR_ENCRYPT) {
37  olen = rz_base91_encode((char *)obuf, (const ut8 *)buf, len);
38  } else if (cry->dir == 1) {
39  olen = rz_base91_decode(obuf, (const char *)buf, len);
40  } else {
41  free(obuf);
42  return false;
43  }
44  rz_crypto_append(cry, obuf, olen);
45  free(obuf);
46  return true;
47 }
RZ_API int rz_crypto_append(RzCrypto *cry, const ut8 *buf, int len)
Definition: crypto.c:175
#define INSIZE
Definition: crypto_base91.c:8
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
uint8_t ut8
Definition: lh5801.h:11
void * malloc(size_t size)
Definition: malloc.c:123
RZ_API int rz_base91_encode(char *bout, const ut8 *bin, int len)
Definition: base91.c:69
RZ_API int rz_base91_decode(ut8 *bout, const char *bin, int len)
Definition: base91.c:28
@ RZ_CRYPTO_DIR_ENCRYPT
Definition: rz_crypto.h:23
static unsigned char * obuf
Definition: z80asm.c:36

References rz_crypto_t::dir, free(), INSIZE, len, malloc(), obuf, rz_base91_decode(), rz_base91_encode(), rz_crypto_append(), and RZ_CRYPTO_DIR_ENCRYPT.

Referenced by final().

Variable Documentation

◆ rizin_plugin

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

Definition at line 65 of file crypto_base91.c.

◆ rz_crypto_plugin_base91

RzCryptoPlugin rz_crypto_plugin_base91
Initial value:
= {
.name = "base91",
.author = "rakholiyajenish.07",
.license = "LGPL-3",
.set_key = base91_set_key,
.get_key_size = base91_get_key_size,
.use = base91_use,
.update = update,
.final = final
}
static int base91_get_key_size(RzCrypto *cry)
Definition: crypto_base91.c:15
static bool base91_set_key(RzCrypto *cry, const ut8 *key, int keylen, int mode, int direction)
Definition: crypto_base91.c:10
static bool base91_use(const char *algo)
Definition: crypto_base91.c:19

Definition at line 53 of file crypto_base91.c.