aboutsummaryrefslogtreecommitdiff
path: root/libcmix-crypto
diff options
context:
space:
mode:
Diffstat (limited to 'libcmix-crypto')
-rw-r--r--libcmix-crypto/api.h6
-rw-r--r--libcmix-crypto/curve25519/curve25519.c2
-rw-r--r--libcmix-crypto/curve25519/curve25519.h2
-rw-r--r--libcmix-crypto/curve25519/null/null_curve25519.c2
-rw-r--r--libcmix-crypto/curve25519/sodium/libsodium_curve25519.c2
-rw-r--r--libcmix-crypto/elgamal/elgamal.c2
-rw-r--r--libcmix-crypto/elgamal/elgamal.h2
-rw-r--r--libcmix-crypto/elgamal/null/null_elgamal.c2
8 files changed, 14 insertions, 6 deletions
diff --git a/libcmix-crypto/api.h b/libcmix-crypto/api.h
index 09b474b..06afcd2 100644
--- a/libcmix-crypto/api.h
+++ b/libcmix-crypto/api.h
@@ -29,7 +29,7 @@ typedef void (*KeyPairDeleter)(struct KeyPair);
* \brief Defines how a Derived Shared Key function should look like.
* Used to store a pointer to function to a implementation.
*/
-typedef struct SharedKey (*SharedKeyDeriver)(struct KeyPair, unsigned char*, bool);
+typedef struct SharedKey (*SharedKeyDeriver)(struct KeyPair, unsigned char const*, bool);
/*!
* \brief Defines how a Derived Shared Key deleter function should look like.
@@ -47,6 +47,10 @@ struct Api {
SharedKeyDeleter free_shared_key; ///< Pointer to shared key deleter function
};
+typedef struct Api(*ImplementationGetter)();
+
+extern ImplementationGetter get_implementation;
+
#ifdef __cplusplus
}
#endif
diff --git a/libcmix-crypto/curve25519/curve25519.c b/libcmix-crypto/curve25519/curve25519.c
index 824daf9..4d53ddf 100644
--- a/libcmix-crypto/curve25519/curve25519.c
+++ b/libcmix-crypto/curve25519/curve25519.c
@@ -10,3 +10,5 @@ struct Api get_curve25519_implementation()
&curve25519_shared_key_deleter
};
}
+
+ImplementationGetter get_implementation = &get_curve25519_implementation;
diff --git a/libcmix-crypto/curve25519/curve25519.h b/libcmix-crypto/curve25519/curve25519.h
index 8e2ad4e..fde317a 100644
--- a/libcmix-crypto/curve25519/curve25519.h
+++ b/libcmix-crypto/curve25519/curve25519.h
@@ -28,7 +28,7 @@ extern void curve25519_keypair_deleter(struct KeyPair p);
* \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, unsigned char* pub_key, bool swap_pub_order);
+extern struct SharedKey curve25519_derive_shared_key(struct KeyPair pair, unsigned char const* pub_key, bool swap_pub_order);
/*!
* \brief curve25519_shared_key_deleter
* \param s the Shared key to free.
diff --git a/libcmix-crypto/curve25519/null/null_curve25519.c b/libcmix-crypto/curve25519/null/null_curve25519.c
index 317455f..63280ec 100644
--- a/libcmix-crypto/curve25519/null/null_curve25519.c
+++ b/libcmix-crypto/curve25519/null/null_curve25519.c
@@ -17,7 +17,7 @@ struct KeyPair curve25519_create_keypair() {
void curve25519_shared_key_deleter(struct SharedKey s) {}
-struct SharedKey curve25519_derive_shared_key(struct KeyPair pair, unsigned char* pub_key, bool swap_pub_order) {
+struct SharedKey curve25519_derive_shared_key(struct KeyPair pair, unsigned char const* pub_key, bool swap_pub_order) {
return (struct SharedKey){
NULL,
0
diff --git a/libcmix-crypto/curve25519/sodium/libsodium_curve25519.c b/libcmix-crypto/curve25519/sodium/libsodium_curve25519.c
index 59e9258..e86ec09 100644
--- a/libcmix-crypto/curve25519/sodium/libsodium_curve25519.c
+++ b/libcmix-crypto/curve25519/sodium/libsodium_curve25519.c
@@ -43,7 +43,7 @@ void curve25519_shared_key_deleter(struct SharedKey s) {
s.shared = NULL;
}
-struct SharedKey curve25519_derive_shared_key(struct KeyPair pair, unsigned char* pub_key, bool swap_pub_order) {
+struct SharedKey curve25519_derive_shared_key(struct KeyPair pair, unsigned char const* pub_key, bool swap_pub_order) {
init();
unsigned char* shared = (unsigned char*) sodium_malloc(crypto_generichash_BYTES);
diff --git a/libcmix-crypto/elgamal/elgamal.c b/libcmix-crypto/elgamal/elgamal.c
index 3136688..d50126c 100644
--- a/libcmix-crypto/elgamal/elgamal.c
+++ b/libcmix-crypto/elgamal/elgamal.c
@@ -9,3 +9,5 @@ struct Api get_elgamal_implementation()
&elgamal_shared_key_deleter
};
}
+
+ImplementationGetter get_implementation = &get_elgamal_implementation; \ No newline at end of file
diff --git a/libcmix-crypto/elgamal/elgamal.h b/libcmix-crypto/elgamal/elgamal.h
index 77b5c9b..feac7f5 100644
--- a/libcmix-crypto/elgamal/elgamal.h
+++ b/libcmix-crypto/elgamal/elgamal.h
@@ -9,7 +9,7 @@ extern "C" {
extern struct KeyPair elgamal_create_keypair();
extern void elgamal_keypair_deleter(struct KeyPair p);
-extern struct SharedKey elgamal_derive_shared_key(struct KeyPair pair, unsigned char* pub_key, bool swap_pub_order);
+extern struct SharedKey elgamal_derive_shared_key(struct KeyPair pair, unsigned char const* pub_key, bool swap_pub_order);
extern void elgamal_shared_key_deleter(struct SharedKey s);
struct Api get_elgamal_implementation();
diff --git a/libcmix-crypto/elgamal/null/null_elgamal.c b/libcmix-crypto/elgamal/null/null_elgamal.c
index ef98912..285e2fd 100644
--- a/libcmix-crypto/elgamal/null/null_elgamal.c
+++ b/libcmix-crypto/elgamal/null/null_elgamal.c
@@ -17,7 +17,7 @@ struct KeyPair elgamal_create_keypair() {
void elgamal_shared_key_deleter(struct SharedKey s) {}
-struct SharedKey elgamal_derive_shared_key(struct KeyPair pair, unsigned char* pub_key, bool swap_pub_order) {
+struct SharedKey elgamal_derive_shared_key(struct KeyPair pair, unsigned char const* pub_key, bool swap_pub_order) {
return (struct SharedKey){
NULL,
0