radare2/libr/crypto/p/crypto_punycode.c

52 lines
1.1 KiB
C
Raw Normal View History

/* radare - LGPL - Copyright 2009-2022 - pancake */
2017-01-29 22:05:02 +00:00
#include <r_util.h>
#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) {
char *obuf;
int olen;
if (cj->flag) {
obuf = r_punycode_decode ((const char *)buf, len, &olen);
} else {
obuf = r_punycode_encode (buf, len, &olen);
}
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",
},
.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