diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-02-27 14:58:51 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-02-27 14:59:11 +0000 |
commit | 6740640ad0d2a812c1bc3e96dc120aed7c12a3bb (patch) | |
tree | 00ba8347c7ddbfe9c7800b6c1cfd296c9beb645d | |
parent | e65e1123fcf918409bba94cf621fac172532769e (diff) | |
download | rspamd-6740640ad0d2a812c1bc3e96dc120aed7c12a3bb.tar.gz rspamd-6740640ad0d2a812c1bc3e96dc120aed7c12a3bb.zip |
[Minor] Allow to generate both seeded and non-seeded ed25519 keys
-rw-r--r-- | src/rspamadm/dkim_keygen.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/rspamadm/dkim_keygen.c b/src/rspamadm/dkim_keygen.c index 86f786295..62b47f557 100644 --- a/src/rspamadm/dkim_keygen.c +++ b/src/rspamadm/dkim_keygen.c @@ -188,7 +188,7 @@ rspamd_dkim_generate_rsa_keypair (const gchar *domain, const gchar *selector, static void rspamd_dkim_generate_ed25519_keypair (const gchar *domain, const gchar *selector, const gchar *priv_fname, const gchar *pub_fname, - guint keylen) + guint keylen, gboolean seeded) { rspamd_sig_sk_t ed_sk; rspamd_sig_pk_t ed_pk; @@ -196,9 +196,17 @@ rspamd_dkim_generate_ed25519_keypair (const gchar *domain, const gchar *selector FILE *pubfile = NULL, *privfile = NULL; rspamd_cryptobox_keypair_sig (ed_pk, ed_sk, RSPAMD_CRYPTOBOX_MODE_25519); - /* Just encode seed, not the full sk */ - base64_sk = rspamd_encode_base64_common (ed_sk, 32, 0, NULL, FALSE, - RSPAMD_TASK_NEWLINES_LF); + if (seeded) { + /* Just encode seed, not the full sk */ + base64_sk = rspamd_encode_base64_common (ed_sk, 32, 0, NULL, FALSE, + RSPAMD_TASK_NEWLINES_LF); + } + else { + base64_sk = rspamd_encode_base64_common (ed_sk, + rspamd_cryptobox_sk_sig_bytes (RSPAMD_CRYPTOBOX_MODE_25519), + 0, NULL, FALSE, + RSPAMD_TASK_NEWLINES_LF); + } base64_pk = rspamd_encode_base64_common (ed_pk, sizeof (ed_pk), 0, NULL, FALSE, RSPAMD_TASK_NEWLINES_LF); @@ -279,7 +287,11 @@ rspamadm_dkim_generate_keypair (const gchar *domain, const gchar *selector, } else if (strcmp (type, "ed25519") == 0) { rspamd_dkim_generate_ed25519_keypair (domain, selector, priv_fname, - pub_fname, keylen); + pub_fname, keylen, FALSE); + } + else if (strcmp (type, "ed25519-seed") == 0) { + rspamd_dkim_generate_ed25519_keypair (domain, selector, priv_fname, + pub_fname, keylen, TRUE); } else { fprintf (stderr, "invalid key type: %s\n", type); |