diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2016-09-08 14:10:48 +0200 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2016-09-08 14:10:48 +0200 |
| commit | f77ce5a0226014c811a46d8ab1ba8c9164768ed3 (patch) | |
| tree | 77405cce94039217e3162b3772196e50ce01115b | |
| parent | 4f13051f763cab3d431847305eff913e4bf9d77a (diff) | |
| download | cmix-f77ce5a0226014c811a46d8ab1ba8c9164768ed3.tar.gz cmix-f77ce5a0226014c811a46d8ab1ba8c9164768ed3.tar.bz2 cmix-f77ce5a0226014c811a46d8ab1ba8c9164768ed3.zip | |
Added null-rsa implementation.
| -rw-r--r-- | libcmix-crypto/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | libcmix-crypto/curve25519/curve25519.h | 3 | ||||
| -rw-r--r-- | libcmix-crypto/curve25519/null/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | libcmix-crypto/rsa/CMakeLists.txt | 27 | ||||
| -rw-r--r-- | libcmix-crypto/rsa/null/CMakeLists.txt | 16 | ||||
| -rw-r--r-- | libcmix-crypto/rsa/null/null_rsa.c (renamed from libcmix-crypto/rsa/sodium/CMakeLists.txt) | 0 | ||||
| -rw-r--r-- | libcmix-crypto/rsa/rsa.c | 11 | ||||
| -rw-r--r-- | libcmix-crypto/rsa/rsa.h | 19 | ||||
| -rw-r--r-- | network-handler/main.cpp | 12 |
9 files changed, 85 insertions, 6 deletions
diff --git a/libcmix-crypto/CMakeLists.txt b/libcmix-crypto/CMakeLists.txt index f039946..6895444 100644 --- a/libcmix-crypto/CMakeLists.txt +++ b/libcmix-crypto/CMakeLists.txt @@ -35,5 +35,5 @@ option(UseEC "Use curve25519 instead of RSA" ON) target_link_libraries(cmix-crypto INTERFACE curve25519-implementation -# INTERFACE rsa-implementation + INTERFACE rsa-implementation ) diff --git a/libcmix-crypto/curve25519/curve25519.h b/libcmix-crypto/curve25519/curve25519.h index ef466a3..19c68e6 100644 --- a/libcmix-crypto/curve25519/curve25519.h +++ b/libcmix-crypto/curve25519/curve25519.h @@ -6,9 +6,6 @@ extern "C" { #include "api.h" -#include <stdlib.h> - - extern struct KeyPair curve25519_create_keypair(); extern void curve25519_keypair_deleter(struct KeyPair p); diff --git a/libcmix-crypto/curve25519/null/CMakeLists.txt b/libcmix-crypto/curve25519/null/CMakeLists.txt index bf30adc..12264db 100644 --- a/libcmix-crypto/curve25519/null/CMakeLists.txt +++ b/libcmix-crypto/curve25519/null/CMakeLists.txt @@ -13,5 +13,4 @@ target_compile_options(${target_name} target_link_libraries(${target_name} INTERFACE cmix-crypto PRIVATE curve25519-interface - PUBLIC sodium ) diff --git a/libcmix-crypto/rsa/CMakeLists.txt b/libcmix-crypto/rsa/CMakeLists.txt index 82e56a9..2eb847f 100644 --- a/libcmix-crypto/rsa/CMakeLists.txt +++ b/libcmix-crypto/rsa/CMakeLists.txt @@ -1,4 +1,29 @@ +add_library(rsa-interface INTERFACE) + +target_include_directories(rsa-interface + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_sources(rsa-interface + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/rsa.h +) + +target_link_libraries(rsa-interface + INTERFACE cmix-crypto-interface +) + foreach(impl ${rsa_implementations}) add_subdirectory(${impl}) endforeach() - + +add_library(rsa-implementation + rsa.h rsa.c +) + +target_include_directories(rsa-implementation + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries(rsa-implementation + PUBLIC rsa-${rsa_implementation} +) diff --git a/libcmix-crypto/rsa/null/CMakeLists.txt b/libcmix-crypto/rsa/null/CMakeLists.txt index e69de29..50977fb 100644 --- a/libcmix-crypto/rsa/null/CMakeLists.txt +++ b/libcmix-crypto/rsa/null/CMakeLists.txt @@ -0,0 +1,16 @@ +include(get_target_name) + +get_target_name(target_name) + +add_library(${target_name} SHARED + null_rsa.c +) + +target_compile_options(${target_name} + PRIVATE -std=c99 +) + +target_link_libraries(${target_name} + INTERFACE cmix-crypto + PRIVATE rsa-interface +) diff --git a/libcmix-crypto/rsa/sodium/CMakeLists.txt b/libcmix-crypto/rsa/null/null_rsa.c index e69de29..e69de29 100644 --- a/libcmix-crypto/rsa/sodium/CMakeLists.txt +++ b/libcmix-crypto/rsa/null/null_rsa.c diff --git a/libcmix-crypto/rsa/rsa.c b/libcmix-crypto/rsa/rsa.c new file mode 100644 index 0000000..61ade32 --- /dev/null +++ b/libcmix-crypto/rsa/rsa.c @@ -0,0 +1,11 @@ +#include "rsa.h" + +struct Api get_rsa_implementation() +{ + return (struct Api) { + &rsa_create_keypair, + &rsa_keypair_deleter, + &rsa_derive_shared_key, + &rsa_shared_key_deleter + }; +} diff --git a/libcmix-crypto/rsa/rsa.h b/libcmix-crypto/rsa/rsa.h new file mode 100644 index 0000000..f479a95 --- /dev/null +++ b/libcmix-crypto/rsa/rsa.h @@ -0,0 +1,19 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "api.h" + +extern struct KeyPair rsa_create_keypair(); +extern void rsa_keypair_deleter(struct KeyPair p); + +extern struct SharedKey rsa_derive_shared_key(struct KeyPair pair, unsigned char* pub_key, bool swap_pub_order); +extern void rsa_shared_key_deleter(struct SharedKey s); + +struct Api get_rsa_implementation(); + +#ifdef __cplusplus +} +#endif diff --git a/network-handler/main.cpp b/network-handler/main.cpp index 128c0e8..c8cae05 100644 --- a/network-handler/main.cpp +++ b/network-handler/main.cpp @@ -1,5 +1,6 @@ #include "networkhandler.hpp" +#include "nodemanager.hpp" #include <boost/program_options.hpp> @@ -7,6 +8,8 @@ #include <iostream> #include <cstdint> +NodeManager key_exchange_phase(); + int main(int argc, char* argv[]) { namespace po = boost::program_options; @@ -35,8 +38,17 @@ int main(int argc, char* argv[]) { std::string if6 = vm["interface6"].as<std::string>(); uint16_t port = vm["port"].as<uint16_t>(); + NodeManager node_manager = key_exchange_phase(); + ListenSettings lsettings{en4, if4, en6, if6, port}; NetworkHandler handler(lsettings); handler.run(); } + +NodeManager key_exchange_phase() { + NodeManager manager; + + return manager; +} + |
