From: Vsevolod Stakhov Date: Mon, 19 Oct 2015 10:49:38 +0000 (+0100) Subject: Fix cryptobox ECDH X-Git-Tag: 1.0.7~59 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b31b6f5f7587a2a862901e229a38b0a82d94897c;p=rspamd.git Fix cryptobox ECDH --- diff --git a/src/libcryptobox/cryptobox.c b/src/libcryptobox/cryptobox.c index d9a0bc718..7978aa9a6 100644 --- a/src/libcryptobox/cryptobox.c +++ b/src/libcryptobox/cryptobox.c @@ -273,7 +273,7 @@ rspamd_cryptobox_keypair (rspamd_pk_t pk, rspamd_sk_t sk) g_assert (len <= (gint)sizeof (rspamd_sk_t)); BN_bn2bin (bn_sec, sk); len = BN_num_bytes (bn_pub); - g_assert (len <= rspamd_cryptobox_pk_bytes ()); + g_assert (len <= (gint)rspamd_cryptobox_pk_bytes ()); BN_bn2bin (bn_pub, pk); BN_free (bn_pub); EC_KEY_free (ec_sec); @@ -317,9 +317,7 @@ rspamd_cryptobox_nm (rspamd_nm_t nm, const rspamd_pk_t pk, const rspamd_sk_t sk) g_assert (bn_sec != NULL); g_assert (EC_KEY_set_private_key (lk, bn_sec) == 1); - ec_pub = EC_POINT_new (EC_KEY_get0_group (lk)); - g_assert (EC_POINT_set_compressed_coordinates_GF2m (EC_KEY_get0_group (lk), - ec_pub, bn_pub, pk[0] & 1, NULL) == 1); + ec_pub = EC_POINT_bn2point (EC_KEY_get0_group (lk), bn_pub, NULL, NULL); g_assert (ec_pub != NULL); len = ECDH_compute_key (s, sizeof (s), ec_pub, lk, NULL); g_assert (len == sizeof (s)); @@ -1051,4 +1049,4 @@ guint rspamd_cryptobox_mac_bytes (void) { return 16; -} \ No newline at end of file +}