aboutsummaryrefslogtreecommitdiff
path: root/libcmix-crypto/curve25519
diff options
context:
space:
mode:
Diffstat (limited to 'libcmix-crypto/curve25519')
-rw-r--r--libcmix-crypto/curve25519/CMakeLists.txt32
-rw-r--r--libcmix-crypto/curve25519/curve25519.c34
-rw-r--r--libcmix-crypto/curve25519/curve25519.h67
-rw-r--r--libcmix-crypto/curve25519/null/CMakeLists.txt15
-rw-r--r--libcmix-crypto/curve25519/null/null_curve25519.c47
-rw-r--r--libcmix-crypto/curve25519/sodium/CMakeLists.txt14
-rw-r--r--libcmix-crypto/curve25519/sodium/libsodium_curve25519.c104
7 files changed, 0 insertions, 313 deletions
diff --git a/libcmix-crypto/curve25519/CMakeLists.txt b/libcmix-crypto/curve25519/CMakeLists.txt
deleted file mode 100644
index 847c26c..0000000
--- a/libcmix-crypto/curve25519/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-add_library(curve25519-interface INTERFACE)
-
-target_include_directories(curve25519-interface
- INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
-)
-
-target_sources(curve25519-interface
- INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/curve25519.h
-)
-
-target_link_libraries(curve25519-interface
- INTERFACE cmix-crypto-interface
-)
-
-foreach(impl ${libcmix_crypto_curve25519_implementations})
- add_subdirectory(${impl})
-endforeach()
-
-add_library(curve25519-implementation
- curve25519.h curve25519.c
-)
-
-target_include_directories(curve25519-implementation
- PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
-)
-
-target_link_libraries(curve25519-implementation
- PUBLIC curve25519-interface
- PUBLIC curve25519-${libcmix_crypto_curve25519_implementation}
-)
-
-
diff --git a/libcmix-crypto/curve25519/curve25519.c b/libcmix-crypto/curve25519/curve25519.c
deleted file mode 100644
index 2fb99c3..0000000
--- a/libcmix-crypto/curve25519/curve25519.c
+++ /dev/null
@@ -1,34 +0,0 @@
-
-#include "curve25519.h"
-
-struct Api get_curve25519_implementation()
-{
- curve25519_initialize();
- return (struct Api) {
- .initialize = curve25519_initialize,
- .create_keypair = curve25519_create_keypair,
- .free_keypair = curve25519_delete_keypair,
- .element_to_array = curve25519_element_to_array,
- .free_buffer = curve25519_free_buffer,
- .array_to_element = curve25519_array_to_element,
- .message_to_element = curve25519_message_to_element,
- .get_pub_key_hash = curve25519_get_pub_key_hash,
- .get_pub_key_hash_length = curve25519_get_pub_key_hash_length,
- .get_group_element = curve25519_get_group_element,
- .get_group_element_array_size = curve25519_get_group_element_array_size,
- .free_group_element = curve25519_delete_group_element,
- .get_key_exchange_value = curve25519_get_key_exchange_value,
- .combine = curve25519_combine,
- .uncombine = curve25519_uncombine,
- .get_decryption_share = curve25519_get_decryption_share,
- .add_public_share = curve25519_add_public_share,
- .derive_shared_key = curve25519_derive_shared_key,
- .free_shared_key = curve25519_delete_shared_key,
- .encrypt = curve25519_encrypt,
- .invert = curve25519_invert,
- .get_uniform_int = curve25519_get_uniform_int,
- .deinitialize = curve25519_deinitialize
- };
-}
-
-ImplementationGetter get_implementation = &get_curve25519_implementation;
diff --git a/libcmix-crypto/curve25519/curve25519.h b/libcmix-crypto/curve25519/curve25519.h
deleted file mode 100644
index f424144..0000000
--- a/libcmix-crypto/curve25519/curve25519.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#pragma once
-
-#include "api.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*!
- * \file
- */
-
-extern Initializer curve25519_initialize;
-
-extern KeyPairCreator curve25519_create_keypair;
-
-extern KeyPairDeleter curve25519_delete_keypair;
-
-extern ElementToArray curve25519_element_to_array;
-
-extern BufferDeleter curve25519_free_buffer;
-
-extern ArrayToElement curve25519_array_to_element;
-
-extern MessageToElement curve25519_message_to_element;
-
-extern PubKeyHashGetter curve25519_get_pub_key_hash;
-
-extern PubKeyHashLengthGetter curve25519_get_pub_key_hash_length;
-
-extern GroupElementGetter curve25519_get_group_element;
-
-extern GroupElementDeleter curve25519_delete_group_element;
-
-extern KeyExchangeValueGetter curve25519_get_key_exchange_value;
-
-extern GroupElementCombiner curve25519_combine;
-
-extern GroupElementUncombiner curve25519_uncombine;
-
-extern DecryptionShareGetter curve25519_get_decryption_share;
-
-extern GroupElementArraySizeGetter curve25519_get_group_element_array_size;
-
-extern PublicShareAdder curve25519_add_public_share;
-
-extern SharedKeyDeriver curve25519_derive_shared_key;
-
-extern SharedKeyDeleter curve25519_delete_shared_key;
-
-extern Encrypter curve25519_encrypt;
-
-extern Inverter curve25519_invert;
-
-extern UniformIntGetter curve25519_get_uniform_int;
-
-extern Deinitializer curve25519_deinitialize;
-
-/*!
- * \brief get_curve25519_implementation
- * \return An Api struct filled with a curve25519 implementation.
- */
-struct Api get_curve25519_implementation();
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/libcmix-crypto/curve25519/null/CMakeLists.txt b/libcmix-crypto/curve25519/null/CMakeLists.txt
deleted file mode 100644
index 94dac1b..0000000
--- a/libcmix-crypto/curve25519/null/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-include(get_target_name)
-
-get_target_name(target_name algo api)
-
-add_library(${target_name} SHARED
- null_curve25519.c
-)
-
-target_compile_options(${target_name}
- PRIVATE -Wno-unused-parameter
-)
-
-target_link_libraries(${target_name}
- PRIVATE curve25519-interface
-)
diff --git a/libcmix-crypto/curve25519/null/null_curve25519.c b/libcmix-crypto/curve25519/null/null_curve25519.c
deleted file mode 100644
index 19c52f4..0000000
--- a/libcmix-crypto/curve25519/null/null_curve25519.c
+++ /dev/null
@@ -1,47 +0,0 @@
-
-#include "curve25519.h"
-
-#include <stddef.h>
-#include <stdbool.h>
-
-void null_curve25519_initialize(void){}
-
-struct KeyPair null_curve25519_create_keypair(void) {
- return (struct KeyPair){
- NULL,
- NULL,
- };
-}
-
-void null_curve25519_delete_keypair(struct KeyPair* p) {}
-
-void null_curve25519_get_key_array(char** buffer, size_t* len, void* key) {}
-
-void null_curve25519_add_public_share(char** buffer, size_t* len_out, char const* share, size_t in_len, void* pubkey) {}
-
-void null_curve25519_shared_key_deleter(struct SharedKey* s) {}
-
-
-GroupElement null_curve25519_derive_shared_key(struct KeyPair keypair, unsigned char const* other_pub, size_t pub_len, unsigned char const* value, size_t value_len, void* priv_value, bool swap) {
- return NULL;
-}
-
-void null_curve25519_deinitialize(void){}
-
-Initializer curve25519_initialize = &null_curve25519_initialize;
-KeyPairCreator curve25519_create_keypair = &null_curve25519_create_keypair;
-KeyPairDeleter curve25519_delete_keypair = &null_curve25519_delete_keypair;
-ElementToArray curve25519_element_to_array = NULL;//&null_curve25519_element_to_array;
-BufferDeleter curve25519_free_buffer = NULL;//&null_curve25519_free_buffer;
-ArrayToElement curve25519_array_to_element = NULL;//&null_curve25519_array_to_element;
-GroupElementGetter curve25519_get_group_element = NULL;//&null_curve25519_get_group_element;
-GroupElementDeleter curve25519_delete_group_element = NULL;//&null_curve25519_delete_group_element;
-KeyExchangeValueGetter curve25519_get_key_exchange_value = NULL;//&null_curve25519_get_key_exchange_value;
-GroupElementCombiner curve25519_multiply = NULL;//&null_curve25519_multiply;
-DecryptionShareGetter curve25519_get_decryption_share = NULL;//&null_curve25519_get_decryption_share;
-GroupElementArraySizeGetter curve25519_get_group_element_array_size = NULL;//&null_curve25519_get_group_element_array_size;
-PublicShareAdder curve25519_add_public_share = NULL;//&null_curve25519_add_public_share;
-SharedKeyDeriver curve25519_derive_shared_key = &null_curve25519_derive_shared_key;
-SharedKeyDeleter curve25519_delete_shared_key = NULL;//&null_curve25519_delete_shared_key;
-Encrypter curve25519_encrypt = NULL;//&null_curve25519_encrypt;
-Deinitializer curve25519_deinitialize = &null_curve25519_deinitialize;
diff --git a/libcmix-crypto/curve25519/sodium/CMakeLists.txt b/libcmix-crypto/curve25519/sodium/CMakeLists.txt
deleted file mode 100644
index f93abb4..0000000
--- a/libcmix-crypto/curve25519/sodium/CMakeLists.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-include(get_target_name)
-
-get_target_name(target_name algo api)
-
-find_package(sodium REQUIRED CONFIG)
-
-add_library(${target_name} SHARED
- libsodium_curve25519.c
-)
-
-target_link_libraries(${target_name}
- PRIVATE curve25519-interface
- PUBLIC sodium
-)
diff --git a/libcmix-crypto/curve25519/sodium/libsodium_curve25519.c b/libcmix-crypto/curve25519/sodium/libsodium_curve25519.c
deleted file mode 100644
index b8ed4c2..0000000
--- a/libcmix-crypto/curve25519/sodium/libsodium_curve25519.c
+++ /dev/null
@@ -1,104 +0,0 @@
-
-#include "curve25519.h"
-
-#include <sodium.h>
-
-#include <stddef.h>
-#include <stdlib.h>
-
-void sodium_curve25519_initialize(void) {
- if(sodium_init() == -1) {
- exit(-1);
- }
-}
-
-void sodium_curve25519_delete_keypair(struct KeyPair* p) {
- sodium_free(p->sec);
- free(p->pub);
-
- p->sec = NULL;
- p->pub = NULL;
-}
-
-struct KeyPair sodium_curve25519_create_keypair(void) {
- unsigned char* sec = (unsigned char*) sodium_malloc(crypto_box_SECRETKEYBYTES);
- unsigned char* pub = (unsigned char*) malloc(crypto_box_PUBLICKEYBYTES);
-
- randombytes_buf(sec, crypto_box_SECRETKEYBYTES);
- crypto_scalarmult_base(pub, sec);
-
- return (struct KeyPair){
- sec,
- pub,
- };
-}
-
-void sodium_curve25519_shared_key_deleter(struct SharedKey* s) {
- sodium_free(s->shared);
-
- s->shared = NULL;
-}
-
-void sodium_curve25519_key_to_array(unsigned char** buffer, size_t* len, void* key) {
- (void)buffer;
- (void)len;
- (void)key;
-}
-
-void sodium_curve25519_add_public_share(char** buffer, size_t* out_len, char const* share, size_t in_len, void* pubkey) {
- (void) buffer;
- (void) out_len;
- (void) share;
- (void) in_len;
- (void) pubkey;
-}
-
-GroupElement sodium_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) {
- (void) pub_len;
- (void) value_len;
- 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*) 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*) 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*) other_pub, crypto_box_PUBLICKEYBYTES);
- }
- crypto_generichash_final(&h, shared, crypto_generichash_BYTES);
-
- sodium_free(scalarmult_q);
-
- return shared;
-}
-
-void sodium_curve25519_deinitialize(void) {}
-
-Initializer curve25519_initialize = &sodium_curve25519_initialize;
-KeyPairCreator curve25519_create_keypair = &sodium_curve25519_create_keypair;
-KeyPairDeleter curve25519_delete_keypair = &sodium_curve25519_delete_keypair;
-ElementToArray curve25519_element_to_array = NULL;//&sodium_curve25519_element_to_array;
-BufferDeleter curve25519_free_buffer = NULL;//&sodium_curve25519_free_buffer;
-ArrayToElement curve25519_array_to_element = NULL;//&sodium_curve25519_array_to_element;
-GroupElementGetter curve25519_get_group_element = NULL;//&sodium_curve25519_get_group_element;
-GroupElementDeleter curve25519_delete_group_element = NULL;//&sodium_curve25519_delete_group_element;
-KeyExchangeValueGetter curve25519_get_key_exchange_value = NULL;//&sodium_curve25519_get_key_exchange_value;
-GroupElementCombiner curve25519_combine = NULL;//&sodium_curve25519_multiply;
-GroupElementUncombiner curve25519_uncombine = NULL;
-DecryptionShareGetter curve25519_get_decryption_share = NULL;//&sodium_curve25519_get_decryption_share;
-GroupElementArraySizeGetter curve25519_get_group_element_array_size = NULL;//&sodium_curve25519_get_group_element_array_size;
-PublicShareAdder curve25519_add_public_share = NULL;//&sodium_curve25519_add_public_share;
-SharedKeyDeriver curve25519_derive_shared_key = &sodium_curve25519_derive_shared_key;
-SharedKeyDeleter curve25519_delete_shared_key = NULL;//&sodium_curve25519_delete_shared_key;
-Encrypter curve25519_encrypt = NULL;//&sodium_curve25519_encrypt;
-Deinitializer curve25519_deinitialize = &sodium_curve25519_deinitialize;