aboutsummaryrefslogtreecommitdiff
path: root/libcmix-crypto/curve25519
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2016-10-27 13:14:28 +0200
committerDennis Brentjes <d.brentjes@gmail.com>2016-10-27 13:14:28 +0200
commit158bf81343054982800d44d507e8e50f2eeb6dd4 (patch)
tree6c09867def3377854b08656a4d5d6df7553fc80b /libcmix-crypto/curve25519
parent25db9ff8a4cfb4b98aeeaae360e8c718b9c5e20c (diff)
downloadcmix-158bf81343054982800d44d507e8e50f2eeb6dd4.tar.gz
cmix-158bf81343054982800d44d507e8e50f2eeb6dd4.tar.bz2
cmix-158bf81343054982800d44d507e8e50f2eeb6dd4.zip
Added proper keyexchange for elgamal-gcrypt.
Diffstat (limited to 'libcmix-crypto/curve25519')
-rw-r--r--libcmix-crypto/curve25519/curve25519.c3
-rw-r--r--libcmix-crypto/curve25519/curve25519.h3
-rw-r--r--libcmix-crypto/curve25519/sodium/libsodium_curve25519.c8
3 files changed, 8 insertions, 6 deletions
diff --git a/libcmix-crypto/curve25519/curve25519.c b/libcmix-crypto/curve25519/curve25519.c
index c4fae8d..0036808 100644
--- a/libcmix-crypto/curve25519/curve25519.c
+++ b/libcmix-crypto/curve25519/curve25519.c
@@ -9,6 +9,9 @@ struct Api get_curve25519_implementation()
&curve25519_create_keypair,
&curve25519_keypair_deleter,
&curve25519_get_key_array,
+ NULL,
+ NULL,
+ NULL,
&curve25519_add_public_share,
&curve25519_derive_shared_key,
&curve25519_shared_key_deleter,
diff --git a/libcmix-crypto/curve25519/curve25519.h b/libcmix-crypto/curve25519/curve25519.h
index 5d004cf..2dc2e48 100644
--- a/libcmix-crypto/curve25519/curve25519.h
+++ b/libcmix-crypto/curve25519/curve25519.h
@@ -51,8 +51,7 @@ extern void curve25519_add_public_share(char** buffer, size_t* out_len, char con
* \param swap_pub_order Should we swap the order in which we feed the public keys to the hash function.
* \return A Shared key
*/
-extern struct SharedKey curve25519_derive_shared_key(struct KeyPair pair, void const* pub_key, bool swap_pub_order);
-
+extern struct SharedKey curve25519_derive_shared_key(struct KeyPair pair, unsigned char const* other_pub, size_t pub_len, unsigned char const* value, size_t value_len, void* priv_value, bool swap_pub_order);
/*!
* \brief curve25519_shared_key_deleter
* \param s the Shared key to free.
diff --git a/libcmix-crypto/curve25519/sodium/libsodium_curve25519.c b/libcmix-crypto/curve25519/sodium/libsodium_curve25519.c
index 06453c5..0fbd387 100644
--- a/libcmix-crypto/curve25519/sodium/libsodium_curve25519.c
+++ b/libcmix-crypto/curve25519/sodium/libsodium_curve25519.c
@@ -47,25 +47,25 @@ void curve25519_add_public_share(char** buffer, size_t* out_len, char const* sha
}
-struct SharedKey curve25519_derive_shared_key(struct KeyPair pair, void const* pub_key, bool swap_pub_order) {
+struct SharedKey curve25519_derive_shared_key(struct KeyPair pair, unsigned char const* other_pub, size_t pub_len, unsigned char const* value, size_t value_len, void* priv_value, bool swap_pub_order) {
unsigned char* shared = (unsigned char*) sodium_malloc(crypto_generichash_BYTES);
crypto_generichash_state h;
unsigned char* scalarmult_q = (unsigned char*) sodium_malloc(crypto_scalarmult_BYTES);
- if (crypto_scalarmult(scalarmult_q, (unsigned char const*) pair.sec, (unsigned char const*) pub_key) != 0) {
+ if (crypto_scalarmult(scalarmult_q, (unsigned char const*) priv_value, (unsigned char const*) value) != 0) {
exit(-1);
}
crypto_generichash_init(&h, NULL, 0U, crypto_generichash_BYTES);
crypto_generichash_update(&h, scalarmult_q, crypto_scalarmult_BYTES);
if(swap_pub_order) {
- crypto_generichash_update(&h, (unsigned char const*) pub_key, crypto_box_PUBLICKEYBYTES);
+ crypto_generichash_update(&h, (unsigned char const*) other_pub, crypto_box_PUBLICKEYBYTES);
crypto_generichash_update(&h, (unsigned char const*) pair.pub, crypto_box_PUBLICKEYBYTES);
} else {
crypto_generichash_update(&h, (unsigned char const*) pair.pub, crypto_box_PUBLICKEYBYTES);
- crypto_generichash_update(&h, (unsigned char const*) pub_key, crypto_box_PUBLICKEYBYTES);
+ crypto_generichash_update(&h, (unsigned char const*) other_pub, crypto_box_PUBLICKEYBYTES);
}
crypto_generichash_final(&h, shared, crypto_generichash_BYTES);