diff options
Diffstat (limited to 'libcmix-crypto')
| -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 |
8 files changed, 73 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 |
