Rizin
unix-like reverse engineering framework and cli tools
rz_crypto.h
Go to the documentation of this file.
1 #ifndef RZ_CRYPTO_H
2 #define RZ_CRYPTO_H
3 
4 #include "rz_types.h"
5 #include "rz_list.h"
6 #include "rz_crypto/rz_des.h"
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
13 
14 enum {
19 };
20 
21 /* Defines in which direction the set_key methods needs to run */
22 enum {
25 };
26 
27 typedef struct rz_crypto_t {
29  ut8 *key;
30  ut8 *iv;
31  int key_len;
35  int dir;
36  void *user;
39 
40 typedef struct rz_crypto_plugin_t {
41  const char *name;
42  const char *license;
43  const char *author;
45  bool (*set_iv)(RzCrypto *cry, const ut8 *iv, int ivlen);
46  bool (*set_key)(RzCrypto *cry, const ut8 *key, int keylen, int mode, int direction);
47  bool (*update)(RzCrypto *cry, const ut8 *buf, int len);
48  bool (*final)(RzCrypto *cry, const ut8 *buf, int len);
49  bool (*use)(const char *algo);
50  bool (*init)(RzCrypto *cry);
51  bool (*fini)(RzCrypto *cry);
53 
55 
56 #ifdef RZ_API
59 RZ_API void rz_crypto_free(RzCrypto *cry);
60 RZ_API bool rz_crypto_use(RzCrypto *cry, const char *algo);
61 RZ_API bool rz_crypto_set_key(RzCrypto *cry, const ut8 *key, int keylen, int mode, int direction);
62 RZ_API bool rz_crypto_set_iv(RzCrypto *cry, const ut8 *iv, int ivlen);
63 RZ_API int rz_crypto_update(RzCrypto *cry, const ut8 *buf, int len);
64 RZ_API int rz_crypto_final(RzCrypto *cry, const ut8 *buf, int len);
65 RZ_API int rz_crypto_append(RzCrypto *cry, const ut8 *buf, int len);
66 RZ_API const ut8 *rz_crypto_get_output(RzCrypto *cry, int *size);
67 RZ_API const char *rz_crypto_name(const RzCryptoSelector bit);
70 #endif
71 
72 /* plugin pointers */
89 
90 #define RZ_CRYPTO_NONE 0ULL
91 #define RZ_CRYPTO_RC2 1ULL
92 #define RZ_CRYPTO_RC4 1ULL << 1
93 #define RZ_CRYPTO_RC6 1ULL << 2
94 #define RZ_CRYPTO_AES_ECB 1ULL << 3
95 #define RZ_CRYPTO_AES_CBC 1ULL << 4
96 #define RZ_CRYPTO_ROR 1ULL << 5
97 #define RZ_CRYPTO_ROL 1ULL << 6
98 #define RZ_CRYPTO_ROT 1ULL << 7
99 #define RZ_CRYPTO_BLOWFISH 1ULL << 8
100 #define RZ_CRYPTO_CPS2 1ULL << 9
101 #define RZ_CRYPTO_DES_ECB 1ULL << 10
102 #define RZ_CRYPTO_XOR 1ULL << 11
103 #define RZ_CRYPTO_SERPENT 1ULL << 12
104 #define RZ_CRYPTO_ALL 0xFFFF
105 
106 #define RZ_CODEC_NONE 0ULL
107 #define RZ_CODEC_B64 1ULL
108 #define RZ_CODEC_B91 1ULL << 1
109 #define RZ_CODEC_PUNYCODE 1ULL << 2
110 #define RZ_CODEC_ALL 0xFFFF
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif
size_t len
Definition: 6502dis.c:15
#define RZ_API
RzCryptoSelector bit
Definition: crypto.c:16
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
Definition: sflib.h:118
voidpf void uLong size
Definition: ioapi.h:138
const char int mode
Definition: ioapi.h:137
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
RZ_API int rz_crypto_update(RzCrypto *cry, const ut8 *buf, int len)
Definition: crypto.c:166
RzCryptoPlugin rz_crypto_plugin_punycode
RZ_LIB_VERSION_HEADER(rz_crypto)
RzCryptoPlugin rz_crypto_plugin_rol
Definition: crypto_rol.c:89
RzCryptoPlugin rz_crypto_plugin_blowfish
@ RZ_CRYPTO_DIR_DECRYPT
Definition: rz_crypto.h:24
@ RZ_CRYPTO_DIR_ENCRYPT
Definition: rz_crypto.h:23
RZ_API bool rz_crypto_set_iv(RzCrypto *cry, const ut8 *iv, int ivlen)
Definition: crypto.c:161
RZ_API int rz_crypto_final(RzCrypto *cry, const ut8 *buf, int len)
Definition: crypto.c:170
@ RZ_CRYPTO_MODE_CFB
Definition: rz_crypto.h:18
@ RZ_CRYPTO_MODE_OFB
Definition: rz_crypto.h:17
@ RZ_CRYPTO_MODE_ECB
Definition: rz_crypto.h:15
@ RZ_CRYPTO_MODE_CBC
Definition: rz_crypto.h:16
RzCryptoPlugin rz_crypto_plugin_serpent
RzCryptoPlugin rz_crypto_plugin_cps2
Definition: crypto_cps2.c:2954
RzCryptoPlugin rz_crypto_plugin_rc6
Definition: crypto_rc6.c:219
RZ_API int rz_crypto_add(RzCrypto *cry, RzCryptoPlugin *h)
Definition: crypto.c:72
RzCryptoPlugin rz_crypto_plugin_xor
Definition: crypto_xor.c:90
RZ_API const char * rz_crypto_codec_name(const RzCryptoSelector bit)
Definition: crypto.c:54
RZ_API const ut8 * rz_crypto_get_output(RzCrypto *cry, int *size)
Definition: crypto.c:193
struct rz_crypto_t RzCrypto
RzCryptoPlugin rz_crypto_plugin_ror
Definition: crypto_ror.c:89
RzCryptoPlugin rz_crypto_plugin_des
Definition: crypto_des.c:183
struct rz_crypto_plugin_t RzCryptoPlugin
RZ_API const char * rz_crypto_name(const RzCryptoSelector bit)
Definition: crypto.c:44
RzCryptoPlugin rz_crypto_plugin_aes
Definition: crypto_aes.c:161
RzCryptoPlugin rz_crypto_plugin_aes_cbc
RzCryptoPlugin rz_crypto_plugin_rc4
Definition: crypto_rc4.c:126
RZ_API bool rz_crypto_set_key(RzCrypto *cry, const ut8 *key, int keylen, int mode, int direction)
Definition: crypto.c:151
RZ_API void rz_crypto_free(RzCrypto *cry)
Definition: crypto.c:116
RZ_API RzCrypto * rz_crypto_new(void)
Definition: crypto.c:83
RzCryptoPlugin rz_crypto_plugin_base91
Definition: crypto_base91.c:53
RZ_API const RzCryptoPlugin * rz_crypto_plugin_by_index(size_t index)
Definition: crypto.c:64
RzCryptoPlugin rz_crypto_plugin_rc2
Definition: crypto_rc2.c:257
RzCryptoPlugin rz_crypto_plugin_rot
Definition: crypto_rot.c:115
RzCryptoPlugin rz_crypto_plugin_base64
Definition: crypto_base64.c:60
RZ_API bool rz_crypto_use(RzCrypto *cry, const char *algo)
Definition: crypto.c:130
RZ_API int rz_crypto_append(RzCrypto *cry, const ut8 *buf, int len)
Definition: crypto.c:175
ut64 RzCryptoSelector
Definition: rz_crypto.h:54
static int
Definition: sfsocketcall.h:114
#define h(i)
Definition: sha256.c:48
int(* get_key_size)(RzCrypto *cry)
Definition: rz_crypto.h:44
bool(* update)(RzCrypto *cry, const ut8 *buf, int len)
Definition: rz_crypto.h:47
bool(* use)(const char *algo)
Definition: rz_crypto.h:49
bool(* init)(RzCrypto *cry)
Definition: rz_crypto.h:50
const char * name
Definition: rz_crypto.h:41
bool(* set_key)(RzCrypto *cry, const ut8 *key, int keylen, int mode, int direction)
Definition: rz_crypto.h:46
bool(* set_iv)(RzCrypto *cry, const ut8 *iv, int ivlen)
Definition: rz_crypto.h:45
const char * license
Definition: rz_crypto.h:42
bool(* fini)(RzCrypto *cry)
Definition: rz_crypto.h:51
const char * author
Definition: rz_crypto.h:43
struct rz_crypto_plugin_t * h
Definition: rz_crypto.h:28
ut8 * iv
Definition: rz_crypto.h:30
ut8 * output
Definition: rz_crypto.h:32
RzList * plugins
Definition: rz_crypto.h:37
void * user
Definition: rz_crypto.h:36
ut8 * key
Definition: rz_crypto.h:29
int output_len
Definition: rz_crypto.h:33
int output_size
Definition: rz_crypto.h:34
int key_len
Definition: rz_crypto.h:31
#define bool
Definition: sysdefs.h:146
ut64(WINAPI *w32_GetEnabledXStateFeatures)()