radare2/libr/crypto/p/crypto_punycode.c

57 lines
1.2 KiB
C
Raw Permalink Normal View History

2024-03-16 01:19:31 +00:00
/* radare - LGPL - Copyright 2009-2024 - pancake */
2017-01-29 22:05:02 +00:00
#include <r_lib.h>
#include <r_crypto.h>
static bool punycode_set_key(RCryptoJob *ci, const ut8 *key, int keylen, int mode, int direction) {
ci->flag = direction;
return true;
}
static int punycode_get_key_size(RCryptoJob *cry) {
return 0;
}
static bool punycode_check(const char *algo) {
return !strcmp (algo, "punycode");
}
static bool update(RCryptoJob *cj, const ut8 *buf, int len) {
2024-03-16 01:19:31 +00:00
char *obuf = NULL;
int olen = 0;
switch (cj->flag) {
case R_CRYPTO_DIR_DECRYPT:
obuf = r_punycode_decode ((const char *)buf, len, &olen);
2024-03-16 01:19:31 +00:00
break;
case R_CRYPTO_DIR_ENCRYPT:
obuf = r_punycode_encode (buf, len, &olen);
2024-03-16 01:19:31 +00:00
break;
}
r_crypto_job_append (cj, (ut8*)obuf, olen);
free (obuf);
2017-01-29 22:05:02 +00:00
return true;
}
RCryptoPlugin r_crypto_plugin_punycode = {
2023-09-13 00:06:53 +00:00
.meta = {
.name = "punycode",
.desc = "Unicoded represented in plain ascii",
2024-03-17 20:04:45 +00:00
.author = "pancake",
.license = "LGPL-3.0-only",
2023-09-13 00:06:53 +00:00
},
.type = R_CRYPTO_TYPE_ENCODER,
.set_key = punycode_set_key,
.get_key_size = punycode_get_key_size,
.check = punycode_check,
.update = update,
2022-09-15 09:21:42 +00:00
.end = update
};
2019-06-13 17:12:51 +00:00
#ifndef R2_PLUGIN_INCORE
2018-09-15 20:52:12 +00:00
R_API RLibStruct radare_plugin = {
.type = R_LIB_TYPE_CRYPTO,
.data = &r_crypto_plugin_punycode,
.version = R2_VERSION
};
#endif