aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2016-08-30 11:07:18 +0200
committerDennis Brentjes <d.brentjes@gmail.com>2016-08-30 11:07:18 +0200
commit825fc3d44eb6a3837bb922815c4351aa011a213c (patch)
tree825ec81fd14aa07d8621513ceb6c2b7e1aa95620
parent8dbc565edee65b31db68f47d41f569d9e52fef14 (diff)
downloadcmix-825fc3d44eb6a3837bb922815c4351aa011a213c.tar.gz
cmix-825fc3d44eb6a3837bb922815c4351aa011a213c.tar.bz2
cmix-825fc3d44eb6a3837bb922815c4351aa011a213c.zip
Proof of concept skeleton, linktime algorithm implementation selection.
-rw-r--r--CMakeLists.txt2
-rw-r--r--libcmix-crypto/CMakeLists.txt13
-rw-r--r--libcmix-crypto/curve25519.h16
-rw-r--r--libcmix-crypto/keymanagement.c1
-rw-r--r--libcmix-crypto/keymanagement.h28
-rw-r--r--libcmix-crypto/libsodium_curve25519.c8
-rw-r--r--libcmix/CMakeLists.txt4
-rw-r--r--network-handler/CMakeLists.txt1
-rw-r--r--network-handler/main.cpp4
9 files changed, 74 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0378b04..97191ba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,8 +12,8 @@ if(DOXYGEN_FOUND)
)
endif(DOXYGEN_FOUND)
-add_subdirectory(libcmix)
add_subdirectory(libcmix-crypto)
+add_subdirectory(libcmix)
add_subdirectory(network-handler)
diff --git a/libcmix-crypto/CMakeLists.txt b/libcmix-crypto/CMakeLists.txt
index 3bbbae6..1be60dc 100644
--- a/libcmix-crypto/CMakeLists.txt
+++ b/libcmix-crypto/CMakeLists.txt
@@ -1,6 +1,7 @@
add_library(cmix-crypto
message.h message.c
+ keymanagement.h keymanagement.c
)
target_include_directories(cmix-crypto
@@ -8,5 +9,13 @@ target_include_directories(cmix-crypto
)
target_compile_options(cmix-crypto
- PUBLIC "-std=c99"
-) \ No newline at end of file
+ PRIVATE "-std=c99"
+)
+
+add_library(libsodium_curve25519
+ libsodium_curve25519.c
+)
+
+target_link_libraries(cmix-crypto
+ PUBLIC libsodium_curve25519
+)
diff --git a/libcmix-crypto/curve25519.h b/libcmix-crypto/curve25519.h
new file mode 100644
index 0000000..2c8b1e3
--- /dev/null
+++ b/libcmix-crypto/curve25519.h
@@ -0,0 +1,16 @@
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct KeyPair {
+ char* sec;
+ char* pub;
+};
+
+extern struct KeyPair curve25519_create_keypair();
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/libcmix-crypto/keymanagement.c b/libcmix-crypto/keymanagement.c
new file mode 100644
index 0000000..49e8316
--- /dev/null
+++ b/libcmix-crypto/keymanagement.c
@@ -0,0 +1 @@
+#include "keymanagement.h"
diff --git a/libcmix-crypto/keymanagement.h b/libcmix-crypto/keymanagement.h
new file mode 100644
index 0000000..1db0ce6
--- /dev/null
+++ b/libcmix-crypto/keymanagement.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "curve25519.h"
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct KeyPair(*CmixKeyPairCreator)();
+typedef struct KeyPair(*CmixKeyPairLoader)(char*, char*);
+
+struct CmixKeyManagementImpl {
+ CmixKeyPairCreator create_new_keypair;
+ 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/libsodium_curve25519.c b/libcmix-crypto/libsodium_curve25519.c
new file mode 100644
index 0000000..d010d2f
--- /dev/null
+++ b/libcmix-crypto/libsodium_curve25519.c
@@ -0,0 +1,8 @@
+
+#include "curve25519.h"
+
+#include <stddef.h>
+
+struct KeyPair curve25519_create_keypair() {
+ return (struct KeyPair){NULL, NULL};
+}
diff --git a/libcmix/CMakeLists.txt b/libcmix/CMakeLists.txt
index 826a604..fe65e7a 100644
--- a/libcmix/CMakeLists.txt
+++ b/libcmix/CMakeLists.txt
@@ -10,3 +10,7 @@ target_include_directories(cmix
target_compile_options(cmix
PRIVATE -std=c99
)
+
+target_link_libraries(cmix
+ PUBLIC cmix-crypto
+)
diff --git a/network-handler/CMakeLists.txt b/network-handler/CMakeLists.txt
index 9fe6e99..dd80f6b 100644
--- a/network-handler/CMakeLists.txt
+++ b/network-handler/CMakeLists.txt
@@ -19,6 +19,7 @@ target_link_libraries(network-handler
PRIVATE Boost::boost
PRIVATE Boost::program_options
PRIVATE Boost::system
+ PRIVATE cmix
)
if(WIN32)
diff --git a/network-handler/main.cpp b/network-handler/main.cpp
index 128c0e8..acdd51f 100644
--- a/network-handler/main.cpp
+++ b/network-handler/main.cpp
@@ -7,6 +7,10 @@
#include <iostream>
#include <cstdint>
+#include "keymanagement.h"
+
+KeyPair pair;
+
int main(int argc, char* argv[]) {
namespace po = boost::program_options;