aboutsummaryrefslogtreecommitdiff
path: root/libcmix-crypto/ed25519
diff options
context:
space:
mode:
Diffstat (limited to 'libcmix-crypto/ed25519')
-rw-r--r--libcmix-crypto/ed25519/gcrypt/gcrypt_ed25519.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/libcmix-crypto/ed25519/gcrypt/gcrypt_ed25519.c b/libcmix-crypto/ed25519/gcrypt/gcrypt_ed25519.c
index bcaca51..afee9b1 100644
--- a/libcmix-crypto/ed25519/gcrypt/gcrypt_ed25519.c
+++ b/libcmix-crypto/ed25519/gcrypt/gcrypt_ed25519.c
@@ -322,11 +322,9 @@ GroupElement DEF(get_group_element)(bool secure) {
check(error);
} while(gcry_mpi_cmp_ui(a, 0) == 0 || gcry_mpi_cmp(a, p) != -1);
- char* encoded_point = (char*) calloc(nr_bytes+1, sizeof(char));
- TRACE(__FILE__, __LINE__, encoded_point)
-
free(encoded_point);
encoded_point = (char*) calloc(nr_bytes+1, sizeof(char));
+ TRACE(__FILE__, __LINE__, encoded_point)
encoded_point[0] = 0x40;
unsigned int byte_size = (unsigned) ceil(gcry_mpi_get_nbits(a) / 8.0);
@@ -456,10 +454,14 @@ GroupElement DEF(derive_shared_key)(struct KeyPair keypair, unsigned char const*
(void)swap;
GroupElement ga = DEF(array_to_element)((const char*) value, value_len, false);
-
+
gcry_mpi_point_t gab = gcry_mpi_point_new(nr_point_bits);
- gcry_mpi_ec_mul(gab, (gcry_mpi_t) priv_value, (gcry_mpi_point_t) ga, ctx);
+
+ gcry_mpi_t x = gcry_mpi_new(0);
+ gcry_mpi_ec_get_affine(x, NULL, (gcry_mpi_point_t) priv_value, ctx);
+ gcry_mpi_ec_mul(gab, x, (gcry_mpi_point_t) ga, ctx);
+ gcry_mpi_release(x);
gcry_mpi_point_release((gcry_mpi_point_t) ga);
TRACE(__FILE__, __LINE__, gab);