diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2016-08-31 14:09:51 +0200 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2016-09-01 13:08:52 +0200 |
| commit | 9d7701c370f06be663f2a485507d388ab5194ca8 (patch) | |
| tree | aea0b55017b7a6003dbd042cdb113ec6fb5ab2e9 /libcmix-crypto | |
| parent | d55e5c77d3cd2a1be150666e92e5b4f3b922f0fc (diff) | |
| download | cmix-9d7701c370f06be663f2a485507d388ab5194ca8.tar.gz cmix-9d7701c370f06be663f2a485507d388ab5194ca8.tar.bz2 cmix-9d7701c370f06be663f2a485507d388ab5194ca8.zip | |
Added a CMake system to easily add and choose crypto implementations.
Diffstat (limited to 'libcmix-crypto')
| -rw-r--r-- | libcmix-crypto/CMakeLists.txt | 23 | ||||
| -rw-r--r-- | libcmix-crypto/curve25519/CMakeLists.txt | 22 | ||||
| -rw-r--r-- | libcmix-crypto/curve25519/curve25519.h (renamed from libcmix-crypto/curve25519.h) | 0 | ||||
| -rw-r--r-- | libcmix-crypto/curve25519/sodium/CMakeLists.txt | 15 | ||||
| -rw-r--r-- | libcmix-crypto/curve25519/sodium/libsodium_curve25519.c (renamed from libcmix-crypto/libsodium_curve25519.c) | 0 | ||||
| -rw-r--r-- | libcmix-crypto/keymanagement.h | 15 | ||||
| -rw-r--r-- | libcmix-crypto/rsa/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | libcmix-crypto/rsa/sodium/CMakeLists.txt | 0 |
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 |
