aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_cryptobox.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-04-07 16:38:50 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-04-07 16:39:22 +0100
commita070e5a10a3084bf75472177bedfacc612c25071 (patch)
tree347823c471e0fd3ae2c88c9d0b5ded83a3cd3212 /src/lua/lua_cryptobox.c
parent58bd6be3f7f9302e51ae4031658311f9cc9842d8 (diff)
downloadrspamd-a070e5a10a3084bf75472177bedfacc612c25071.tar.gz
rspamd-a070e5a10a3084bf75472177bedfacc612c25071.zip
[Feature] Finish all features of dkim_keygen in Lua
Diffstat (limited to 'src/lua/lua_cryptobox.c')
-rw-r--r--src/lua/lua_cryptobox.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/lua/lua_cryptobox.c b/src/lua/lua_cryptobox.c
index e342610ce..2a7b0c202 100644
--- a/src/lua/lua_cryptobox.c
+++ b/src/lua/lua_cryptobox.c
@@ -2700,6 +2700,39 @@ lua_cryptobox_gen_dkim_keypair (lua_State *L)
rspamd_explicit_memzero (pk, sizeof (pk));
rspamd_explicit_memzero (sk, sizeof (sk));
}
+ else if (strcmp (alg_str, "ed25519-seed") == 0) {
+ rspamd_sig_pk_t pk;
+ rspamd_sig_sk_t sk;
+ gchar *b64_data;
+ gsize b64_len;
+
+ rspamd_cryptobox_keypair_sig (pk, sk, RSPAMD_CRYPTOBOX_MODE_25519);
+
+ /* Process private key */
+ b64_data = rspamd_encode_base64 (sk,
+ 32,
+ -1, &b64_len);
+
+ priv_out = lua_newuserdata (L, sizeof (*priv_out));
+ rspamd_lua_setclass (L, "rspamd{text}", -1);
+ priv_out->start = b64_data;
+ priv_out->len = b64_len;
+ priv_out->flags = RSPAMD_TEXT_FLAG_OWN|RSPAMD_TEXT_FLAG_WIPE;
+
+ /* Process public key */
+ b64_data = rspamd_encode_base64 (pk,
+ rspamd_cryptobox_pk_sig_bytes (RSPAMD_CRYPTOBOX_MODE_25519),
+ -1, &b64_len);
+
+ pub_out = lua_newuserdata (L, sizeof (*pub_out));
+ rspamd_lua_setclass (L, "rspamd{text}", -1);
+ pub_out->start = b64_data;
+ pub_out->len = b64_len;
+ pub_out->flags = RSPAMD_TEXT_FLAG_OWN;
+
+ rspamd_explicit_memzero (pk, sizeof (pk));
+ rspamd_explicit_memzero (sk, sizeof (sk));
+ }
else {
return luaL_error (L, "invalid algorithm %s", alg_str);
}