]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Use proper keys when doing asymmetric encryption
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 9 Aug 2024 12:03:46 +0000 (13:03 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 9 Aug 2024 12:03:46 +0000 (13:03 +0100)
src/libcryptobox/keypair.c

index 96389dce85e08aa59ffe6bd634a6de5d8f390ced..d3f81ee2d01deaed8492aafa076ed9c4b4bc93f6 100644 (file)
@@ -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);