diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-12-26 22:43:05 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-12-26 22:43:05 +0000 |
commit | e72b64dd5332029857201919fcd45bdf7e217d5f (patch) | |
tree | 6a53be62ac7535a0dfe16b3ddf16bde1360adbda /src/libcryptobox | |
parent | 37bd2212f625089a81c7518e8f0b033c056a722c (diff) | |
download | rspamd-e72b64dd5332029857201919fcd45bdf7e217d5f.tar.gz rspamd-e72b64dd5332029857201919fcd45bdf7e217d5f.zip |
[Minor] Remove unused stuff
Diffstat (limited to 'src/libcryptobox')
-rw-r--r-- | src/libcryptobox/keypair.c | 88 | ||||
-rw-r--r-- | src/libcryptobox/keypair.h | 36 |
2 files changed, 0 insertions, 124 deletions
diff --git a/src/libcryptobox/keypair.c b/src/libcryptobox/keypair.c index 24bd93c0b..ce9a9200d 100644 --- a/src/libcryptobox/keypair.c +++ b/src/libcryptobox/keypair.c @@ -833,94 +833,6 @@ rspamd_keypair_to_ucl (struct rspamd_cryptobox_keypair *kp, } gboolean -rspamd_keypair_sign (struct rspamd_cryptobox_keypair *kp, - const void *data, gsize len, guchar **sig, gsize *outlen, - GError **err) -{ - unsigned long long siglen; - guint sklen; - - g_assert (kp != NULL); - g_assert (data != NULL); - g_assert (sig != NULL); - - if (kp->type != RSPAMD_KEYPAIR_SIGN) { - g_set_error (err, rspamd_keypair_quark (), EINVAL, - "invalid keypair: expected signature pair"); - - return FALSE; - } - - siglen = rspamd_cryptobox_signature_bytes (kp->alg); - *sig = g_malloc (siglen); - rspamd_cryptobox_sign (*sig, &siglen, data, len, - rspamd_cryptobox_keypair_sk (kp, &sklen), kp->alg); - - if (outlen != NULL) { - *outlen = siglen; - } - - return TRUE; -} - -gboolean -rspamd_keypair_verify (struct rspamd_cryptobox_pubkey *pk, - const void *data, gsize len, const guchar *sig, gsize siglen, - GError **err) -{ - guint pklen; - - g_assert (pk != NULL); - g_assert (data != NULL); - g_assert (sig != NULL); - - if (pk->type != RSPAMD_KEYPAIR_SIGN) { - g_set_error (err, rspamd_keypair_quark (), EINVAL, - "invalid keypair: expected signature pair"); - - return FALSE; - } - - if (siglen != rspamd_cryptobox_signature_bytes (pk->alg)) { - g_set_error (err, rspamd_keypair_quark (), E2BIG, - "invalid signature length: %d; expected %d", - (int)siglen, (int) rspamd_cryptobox_signature_bytes (pk->alg)); - - return FALSE; - } - - if (!rspamd_cryptobox_verify (sig, siglen, data, len, - rspamd_cryptobox_pubkey_pk (pk, &pklen), pk->alg)) { - g_set_error (err, rspamd_keypair_quark (), EPERM, - "signature verification failed"); - - return FALSE; - } - - return TRUE; -} - -gboolean -rspamd_pubkey_equal (const struct rspamd_cryptobox_pubkey *k1, - const struct rspamd_cryptobox_pubkey *k2) -{ - guchar *p1 = NULL, *p2 = NULL; - guint len1, len2; - - - if (k1->alg == k2->alg && k1->type == k2->type) { - p1 = rspamd_cryptobox_pubkey_pk (k1, &len1); - p2 = rspamd_cryptobox_pubkey_pk (k2, &len2); - - if (len1 == len2) { - return (memcmp (p1, p2, len1) == 0); - } - } - - return FALSE; -} - -gboolean rspamd_keypair_decrypt (struct rspamd_cryptobox_keypair *kp, const guchar *in, gsize inlen, guchar **out, gsize *outlen, diff --git a/src/libcryptobox/keypair.h b/src/libcryptobox/keypair.h index e2b20dc55..778e2ce6a 100644 --- a/src/libcryptobox/keypair.h +++ b/src/libcryptobox/keypair.h @@ -245,42 +245,6 @@ struct rspamd_cryptobox_keypair *rspamd_keypair_from_ucl (const ucl_object_t *ob ucl_object_t *rspamd_keypair_to_ucl (struct rspamd_cryptobox_keypair *kp, gboolean is_hex); -/** - * Signs memory using the specified keypair - * @param kp keypair - * @param data data to sign - * @param data to sign - * @param sig output signature (allocated by function, must be freed by a callee) - * @param outlen length of output data - * @param err filled if function returns `FALSE` - * @return TRUE if signature operation succeeded - */ -gboolean rspamd_keypair_sign (struct rspamd_cryptobox_keypair *kp, - const void *data, gsize len, guchar **sig, gsize *outlen, - GError **err); - -/*** - * Verifies data using public key - * @param pk public key - * @param data data to sign - * @param len data to sign - * @param sig signature to verify - * @param siglen length of signature - * @param err filled if function returns `FALSE` - * @return TRUE if signature is valid - */ -gboolean rspamd_keypair_verify (struct rspamd_cryptobox_pubkey *pk, - const void *data, gsize len, const guchar *sig, gsize siglen, - GError **err); - -/** - * Compares two public keys - * @param k1 key to compare - * @param k2 key to compare - * @return TRUE if two keys are equal - */ -gboolean rspamd_pubkey_equal (const struct rspamd_cryptobox_pubkey *k1, - const struct rspamd_cryptobox_pubkey *k2); /** * Decrypts data using keypair and a pubkey stored in in, in must start from |