2024-03-16 01:19:31 +00:00
|
|
|
/* radare - LGPL - Copyright 2009-2024 - pancake */
|
2017-01-29 22:05:02 +00:00
|
|
|
|
2016-05-07 10:31:13 +00:00
|
|
|
#include <r_lib.h>
|
|
|
|
#include <r_crypto.h>
|
|
|
|
|
2022-09-15 01:25:53 +00:00
|
|
|
static bool punycode_set_key(RCryptoJob *ci, const ut8 *key, int keylen, int mode, int direction) {
|
|
|
|
ci->flag = direction;
|
2016-05-07 10:31:13 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-09-15 01:25:53 +00:00
|
|
|
static int punycode_get_key_size(RCryptoJob *cry) {
|
2016-05-07 10:31:13 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-09-15 01:25:53 +00:00
|
|
|
static bool punycode_check(const char *algo) {
|
2016-05-07 10:31:13 +00:00
|
|
|
return !strcmp (algo, "punycode");
|
|
|
|
}
|
|
|
|
|
2022-09-15 01:25:53 +00:00
|
|
|
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:
|
2016-05-07 10:31:13 +00:00
|
|
|
obuf = r_punycode_decode ((const char *)buf, len, &olen);
|
2024-03-16 01:19:31 +00:00
|
|
|
break;
|
|
|
|
case R_CRYPTO_DIR_ENCRYPT:
|
2017-03-08 07:49:31 +00:00
|
|
|
obuf = r_punycode_encode (buf, len, &olen);
|
2024-03-16 01:19:31 +00:00
|
|
|
break;
|
2016-05-07 10:31:13 +00:00
|
|
|
}
|
2022-09-15 01:25:53 +00:00
|
|
|
r_crypto_job_append (cj, (ut8*)obuf, olen);
|
2016-05-07 10:31:13 +00:00
|
|
|
free (obuf);
|
2017-01-29 22:05:02 +00:00
|
|
|
return true;
|
2016-05-07 10:31:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RCryptoPlugin r_crypto_plugin_punycode = {
|
2023-09-13 00:06:53 +00:00
|
|
|
.meta = {
|
|
|
|
.name = "punycode",
|
2024-10-18 15:32:56 +00:00
|
|
|
.desc = "Unicoded represented in plain ascii",
|
2024-03-17 20:04:45 +00:00
|
|
|
.author = "pancake",
|
2024-10-18 15:32:56 +00:00
|
|
|
.license = "LGPL-3.0-only",
|
2023-09-13 00:06:53 +00:00
|
|
|
},
|
2022-09-21 16:35:36 +00:00
|
|
|
.type = R_CRYPTO_TYPE_ENCODER,
|
2016-05-07 10:31:13 +00:00
|
|
|
.set_key = punycode_set_key,
|
|
|
|
.get_key_size = punycode_get_key_size,
|
2022-09-15 01:25:53 +00:00
|
|
|
.check = punycode_check,
|
2016-05-07 10:31:13 +00:00
|
|
|
.update = update,
|
2022-09-15 09:21:42 +00:00
|
|
|
.end = update
|
2016-05-07 10:31:13 +00:00
|
|
|
};
|
|
|
|
|
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 = {
|
2016-05-07 10:31:13 +00:00
|
|
|
.type = R_LIB_TYPE_CRYPTO,
|
|
|
|
.data = &r_crypto_plugin_punycode,
|
|
|
|
.version = R2_VERSION
|
2017-05-02 03:05:36 +00:00
|
|
|
};
|
2016-05-07 10:31:13 +00:00
|
|
|
#endif
|