From b83fb594e7665008f6f127d003765ed9efd23249 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 9 Aug 2024 13:03:46 +0100 Subject: [PATCH] [Fix] Use proper keys when doing asymmetric encryption --- src/libcryptobox/keypair.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcryptobox/keypair.c b/src/libcryptobox/keypair.c index 96389dce8..d3f81ee2d 100644 --- a/src/libcryptobox/keypair.c +++ b/src/libcryptobox/keypair.c @@ -837,9 +837,9 @@ rspamd_keypair_encrypt(struct rspamd_cryptobox_keypair *kp, ottery_rand_bytes(nonce, crypto_box_noncebytes()); memcpy(data, in, inlen); - memcpy(pubkey, rspamd_keypair_component(kp, RSPAMD_KEYPAIR_COMPONENT_PK, NULL), + memcpy(pubkey, rspamd_keypair_component(local, RSPAMD_KEYPAIR_COMPONENT_PK, NULL), crypto_box_publickeybytes()); - rspamd_cryptobox_encrypt_inplace(data, inlen, nonce, pubkey, + rspamd_cryptobox_encrypt_inplace(data, inlen, nonce, rspamd_keypair_component(kp, RSPAMD_KEYPAIR_COMPONENT_PK, NULL), rspamd_keypair_component(local, RSPAMD_KEYPAIR_COMPONENT_SK, NULL), mac); rspamd_keypair_unref(local); @@ -886,9 +886,9 @@ rspamd_pubkey_encrypt(struct rspamd_cryptobox_pubkey *pk, ottery_rand_bytes(nonce, crypto_box_noncebytes()); memcpy(data, in, inlen); - memcpy(pubkey, rspamd_pubkey_get_pk(pk, NULL), + memcpy(pubkey, rspamd_keypair_component(local, RSPAMD_KEYPAIR_COMPONENT_PK, NULL), crypto_box_publickeybytes()); - rspamd_cryptobox_encrypt_inplace(data, inlen, nonce, pubkey, + rspamd_cryptobox_encrypt_inplace(data, inlen, nonce, rspamd_pubkey_get_pk(pk, NULL), rspamd_keypair_component(local, RSPAMD_KEYPAIR_COMPONENT_SK, NULL), mac); rspamd_keypair_unref(local); -- 2.39.5