2017-01-29 22:05:02 +00:00
|
|
|
/* radare - LGPL - Copyright 2009-2016 - pancake */
|
|
|
|
|
2016-05-07 10:31:13 +00:00
|
|
|
#include <r_util.h>
|
|
|
|
#include <r_lib.h>
|
|
|
|
#include <r_crypto.h>
|
|
|
|
|
|
|
|
static int flag = 0;
|
|
|
|
|
2017-01-29 22:05:02 +00:00
|
|
|
static bool punycode_set_key(RCrypto *cry, const ut8 *key, int keylen, int mode, int direction) {
|
2016-05-07 10:31:13 +00:00
|
|
|
flag = direction;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int punycode_get_key_size(RCrypto *cry) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool punycode_use(const char *algo) {
|
|
|
|
return !strcmp (algo, "punycode");
|
|
|
|
}
|
|
|
|
|
2017-01-29 22:05:02 +00:00
|
|
|
static bool update(RCrypto *cry, const ut8 *buf, int len) {
|
2016-05-07 10:31:13 +00:00
|
|
|
char *obuf;
|
|
|
|
int olen;
|
|
|
|
if (flag) {
|
|
|
|
obuf = r_punycode_decode ((const char *)buf, len, &olen);
|
|
|
|
} else {
|
2017-03-08 07:49:31 +00:00
|
|
|
obuf = r_punycode_encode (buf, len, &olen);
|
2016-05-07 10:31:13 +00:00
|
|
|
}
|
|
|
|
r_crypto_append (cry, (ut8*)obuf, olen);
|
|
|
|
free (obuf);
|
2017-01-29 22:05:02 +00:00
|
|
|
return true;
|
2016-05-07 10:31:13 +00:00
|
|
|
}
|
|
|
|
|
2017-01-29 22:05:02 +00:00
|
|
|
static bool final(RCrypto *cry, const ut8* buf, int len) {
|
2016-05-07 10:31:13 +00:00
|
|
|
return update (cry, buf, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
RCryptoPlugin r_crypto_plugin_punycode = {
|
|
|
|
.name = "punycode",
|
|
|
|
.set_key = punycode_set_key,
|
|
|
|
.get_key_size = punycode_get_key_size,
|
|
|
|
.use = punycode_use,
|
|
|
|
.update = update,
|
|
|
|
.final = final
|
|
|
|
};
|
|
|
|
|
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
|