Rizin
unix-like reverse engineering framework and cli tools
base64.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rz_util/rz_base64.h>
#include "sdb.h"

Go to the source code of this file.

Functions

RZ_API void sdb_encode_raw (char *bout, const ut8 *bin, int len)
 
RZ_API int sdb_decode_raw (ut8 *bout, const char *bin, int len)
 
RZ_API char * sdb_encode (const ut8 *bin, int len)
 
RZ_API ut8sdb_decode (const char *in, int *len)
 

Function Documentation

◆ sdb_decode()

RZ_API ut8* sdb_decode ( const char *  in,
int len 
)

Definition at line 37 of file base64.c.

37  {
38  ut8 *out;
39  ut32 size;
40  int olen, ilen;
41  if (len) {
42  *len = 0;
43  }
44  if (!in) {
45  return NULL;
46  }
47  ilen = strlen(in);
48  if (!ilen) {
49  return NULL;
50  }
51  size = (ilen * 3) + 16;
52  if (size < (ut32)ilen) {
53  return NULL;
54  }
55  out = calloc(1, size);
56  if (!out) {
57  return NULL;
58  }
59  olen = sdb_decode_raw(out, in, ilen);
60  if (!olen) {
61  free(out);
62  return NULL;
63  }
64  out[olen] = 0;
65  if (len) {
66  *len = olen;
67  }
68  return out;
69 }
size_t len
Definition: 6502dis.c:15
RZ_API int sdb_decode_raw(ut8 *bout, const char *bin, int len)
Definition: base64.c:14
const lzma_allocator const uint8_t * in
Definition: block.h:527
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
#define NULL
Definition: cris-opc.c:27
uint32_t ut32
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void uLong size
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
void * calloc(size_t number, size_t size)
Definition: malloc.c:102

References calloc(), free(), in, len, NULL, out, and sdb_decode_raw().

Referenced by base64decode(), bin_pe_versioninfo(), compareString(), deserialize_checkpoints_cb(), foreach_list_cb(), meta_variable_comment_append(), rz_comment_unique_handler(), sdb_fmt_tobin(), and sdb_querys().

◆ sdb_decode_raw()

RZ_API int sdb_decode_raw ( ut8 bout,
const char *  bin,
int  len 
)

Definition at line 14 of file base64.c.

14  {
15  return rz_base64_decode(bout, bin, len);
16 }
RZ_API int rz_base64_decode(ut8 *bout, const char *bin, int len)
Definition: ubase64.c:48
Definition: malloc.c:26

References len, and rz_base64_decode().

Referenced by sdb_decode().

◆ sdb_encode()

RZ_API char* sdb_encode ( const ut8 bin,
int  len 
)

Definition at line 18 of file base64.c.

18  {
19  char *out;
20  if (!bin) {
21  return NULL;
22  }
23  if (len < 0) {
24  len = strlen((const char *)bin);
25  }
26  if (!len) {
27  return strdup("");
28  }
29  out = calloc(8 + (len * 2), sizeof(char));
30  if (!out) {
31  return NULL;
32  }
34  return out;
35 }
RZ_API void sdb_encode_raw(char *bout, const ut8 *bin, int len)
Definition: base64.c:10
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")

References calloc(), len, NULL, out, sdb_encode_raw(), and strdup().

Referenced by base64encode(), core_analysis_graph_nodes(), meta_variable_comment_print(), Pe_r_bin_store_string(), Pe_r_bin_store_string_table(), rz_agraph_add_node_with_color(), rz_core_meta_print(), rz_core_print_disasm_json(), sdb_fmt_tostr(), sdb_querys(), sdb_set_enc(), and serialize_checkpoints().

◆ sdb_encode_raw()

RZ_API void sdb_encode_raw ( char *  bout,
const ut8 bin,
int  len 
)

Definition at line 10 of file base64.c.

10  {
11  rz_base64_encode(bout, bin, len);
12 }
RZ_API size_t rz_base64_encode(char *bout, const ut8 *bin, size_t sz)
Definition: ubase64.c:81

References len, and rz_base64_encode().

Referenced by sdb_encode().