aboutsummaryrefslogtreecommitdiff
path: root/libcmix-crypto
diff options
context:
space:
mode:
Diffstat (limited to 'libcmix-crypto')
-rw-r--r--libcmix-crypto/CMakeLists.txt23
-rw-r--r--libcmix-crypto/curve25519/CMakeLists.txt22
-rw-r--r--libcmix-crypto/curve25519/curve25519.h (renamed from libcmix-crypto/curve25519.h)0
-rw-r--r--libcmix-crypto/curve25519/sodium/CMakeLists.txt15
-rw-r--r--libcmix-crypto/curve25519/sodium/libsodium_curve25519.c (renamed from libcmix-crypto/libsodium_curve25519.c)0
-rw-r--r--libcmix-crypto/keymanagement.h15
-rw-r--r--libcmix-crypto/rsa/CMakeLists.txt4
-rw-r--r--libcmix-crypto/rsa/sodium/CMakeLists.txt0
8 files changed, 62 insertions, 17 deletions
diff --git a/libcmix-crypto/CMakeLists.txt b/libcmix-crypto/CMakeLists.txt
index 37e60aa..907c601 100644
--- a/libcmix-crypto/CMakeLists.txt
+++ b/libcmix-crypto/CMakeLists.txt
@@ -1,10 +1,21 @@
+add_library(cmix-crypto-interface INTERFACE)
+
+target_include_directories(cmix-crypto-interface
+ INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+include(curve25519_implementations)
+add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/curve25519/)
+
+include(rsa_implementations)
+add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/rsa)
+
+
add_library(cmix-crypto
message.h message.c
keymanagement.h keymanagement.c
keypair.h
- curve25519.h
-
)
target_include_directories(cmix-crypto
@@ -15,10 +26,10 @@ target_compile_options(cmix-crypto
PRIVATE "-std=c99"
)
-add_library(libsodium_curve25519
- libsodium_curve25519.c
-)
+option(UseEC "Use curve25519 instead of RSA" ON)
+
target_link_libraries(cmix-crypto
- PUBLIC libsodium_curve25519
+ PUBLIC curve25519-implementation
+# PUBLIC rsa-implementation
)
diff --git a/libcmix-crypto/curve25519/CMakeLists.txt b/libcmix-crypto/curve25519/CMakeLists.txt
new file mode 100644
index 0000000..7885e7d
--- /dev/null
+++ b/libcmix-crypto/curve25519/CMakeLists.txt
@@ -0,0 +1,22 @@
+
+add_library(curve25519-interface INTERFACE)
+
+target_include_directories(curve25519-interface
+ INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+target_link_libraries(curve25519-interface
+ INTERFACE cmix-crypto-interface
+)
+
+foreach(impl ${curve25519_implementations})
+ add_subdirectory(${impl})
+endforeach()
+
+add_library(curve25519-implementation INTERFACE)
+
+target_link_libraries(curve25519-implementation
+ INTERFACE curve25519-${curve25519_implementation}
+)
+
+
diff --git a/libcmix-crypto/curve25519.h b/libcmix-crypto/curve25519/curve25519.h
index 319e693..319e693 100644
--- a/libcmix-crypto/curve25519.h
+++ b/libcmix-crypto/curve25519/curve25519.h
diff --git a/libcmix-crypto/curve25519/sodium/CMakeLists.txt b/libcmix-crypto/curve25519/sodium/CMakeLists.txt
new file mode 100644
index 0000000..9fbf010
--- /dev/null
+++ b/libcmix-crypto/curve25519/sodium/CMakeLists.txt
@@ -0,0 +1,15 @@
+include(get_target_name)
+
+get_target_name(target_name)
+
+add_library(${target_name}
+ libsodium_curve25519.c
+)
+
+target_compile_options(${target_name}
+ PRIVATE -std=c99
+)
+
+target_link_libraries(${target_name}
+ PUBLIC curve25519-interface
+)
diff --git a/libcmix-crypto/libsodium_curve25519.c b/libcmix-crypto/curve25519/sodium/libsodium_curve25519.c
index 23dbf12..23dbf12 100644
--- a/libcmix-crypto/libsodium_curve25519.c
+++ b/libcmix-crypto/curve25519/sodium/libsodium_curve25519.c
diff --git a/libcmix-crypto/keymanagement.h b/libcmix-crypto/keymanagement.h
index 1db0ce6..18b578a 100644
--- a/libcmix-crypto/keymanagement.h
+++ b/libcmix-crypto/keymanagement.h
@@ -1,13 +1,13 @@
#pragma once
-#include "curve25519.h"
-
-#include <stddef.h>
-
#ifdef __cplusplus
extern "C" {
#endif
+#include "keypair.h"
+
+#include <stddef.h>
+
typedef struct KeyPair(*CmixKeyPairCreator)();
typedef struct KeyPair(*CmixKeyPairLoader)(char*, char*);
@@ -16,13 +16,6 @@ struct CmixKeyManagementImpl {
CmixKeyPairLoader load_keypair;
};
-struct CmixKeyManagementImpl get_curve25519_key_management_implementation() {
- return (struct CmixKeyManagementImpl) {\
- &curve25519_create_keypair,
- NULL
- };\
-}
-
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/libcmix-crypto/rsa/CMakeLists.txt b/libcmix-crypto/rsa/CMakeLists.txt
new file mode 100644
index 0000000..82e56a9
--- /dev/null
+++ b/libcmix-crypto/rsa/CMakeLists.txt
@@ -0,0 +1,4 @@
+foreach(impl ${rsa_implementations})
+ add_subdirectory(${impl})
+endforeach()
+
diff --git a/libcmix-crypto/rsa/sodium/CMakeLists.txt b/libcmix-crypto/rsa/sodium/CMakeLists.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libcmix-crypto/rsa/sodium/CMakeLists.txt