diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2016-09-29 14:41:32 +0200 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2016-09-29 14:41:32 +0200 |
| commit | f7f0e8c53bc8231264346ef91e2f533164a25562 (patch) | |
| tree | c3ec176a2fc12bc0ee99f017d15c1f8be73bb921 /libcmix-crypto/elgamal | |
| parent | 8507aec59b92e16ed6a05c92fea6ced5dba3f753 (diff) | |
| download | cmix-f7f0e8c53bc8231264346ef91e2f533164a25562.tar.gz cmix-f7f0e8c53bc8231264346ef91e2f533164a25562.tar.bz2 cmix-f7f0e8c53bc8231264346ef91e2f533164a25562.zip | |
Replaced the RSA implementation with an Elgamal implementation.
Diffstat (limited to 'libcmix-crypto/elgamal')
| -rw-r--r-- | libcmix-crypto/elgamal/CMakeLists.txt | 29 | ||||
| -rw-r--r-- | libcmix-crypto/elgamal/elgamal.c | 11 | ||||
| -rw-r--r-- | libcmix-crypto/elgamal/elgamal.h | 19 | ||||
| -rw-r--r-- | libcmix-crypto/elgamal/null/CMakeLists.txt | 16 | ||||
| -rw-r--r-- | libcmix-crypto/elgamal/null/null_elgamal.c | 0 |
5 files changed, 75 insertions, 0 deletions
diff --git a/libcmix-crypto/elgamal/CMakeLists.txt b/libcmix-crypto/elgamal/CMakeLists.txt new file mode 100644 index 0000000..88f5ba8 --- /dev/null +++ b/libcmix-crypto/elgamal/CMakeLists.txt @@ -0,0 +1,29 @@ +add_library(elgamal-interface INTERFACE) + +target_include_directories(elgamal-interface + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_sources(elgamal-interface + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/elgamal.h +) + +target_link_libraries(elgamal-interface + INTERFACE cmix-crypto-interface +) + +foreach(impl ${elgamal_implementations}) + add_subdirectory(${impl}) +endforeach() + +add_library(elgamal-implementation + elgamal.h elgamal.c +) + +target_include_directories(elgamal-implementation + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries(elgamal-implementation + PUBLIC elgamal-${elgamal_implementation} +) diff --git a/libcmix-crypto/elgamal/elgamal.c b/libcmix-crypto/elgamal/elgamal.c new file mode 100644 index 0000000..3136688 --- /dev/null +++ b/libcmix-crypto/elgamal/elgamal.c @@ -0,0 +1,11 @@ +#include "elgamal.h" + +struct Api get_elgamal_implementation() +{ + return (struct Api) { + &elgamal_create_keypair, + &elgamal_keypair_deleter, + &elgamal_derive_shared_key, + &elgamal_shared_key_deleter + }; +} diff --git a/libcmix-crypto/elgamal/elgamal.h b/libcmix-crypto/elgamal/elgamal.h new file mode 100644 index 0000000..77b5c9b --- /dev/null +++ b/libcmix-crypto/elgamal/elgamal.h @@ -0,0 +1,19 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "api.h" + +extern struct KeyPair elgamal_create_keypair(); +extern void elgamal_keypair_deleter(struct KeyPair p); + +extern struct SharedKey elgamal_derive_shared_key(struct KeyPair pair, unsigned char* pub_key, bool swap_pub_order); +extern void elgamal_shared_key_deleter(struct SharedKey s); + +struct Api get_elgamal_implementation(); + +#ifdef __cplusplus +} +#endif diff --git a/libcmix-crypto/elgamal/null/CMakeLists.txt b/libcmix-crypto/elgamal/null/CMakeLists.txt new file mode 100644 index 0000000..39db0f0 --- /dev/null +++ b/libcmix-crypto/elgamal/null/CMakeLists.txt @@ -0,0 +1,16 @@ +include(get_target_name) + +get_target_name(target_name) + +add_library(${target_name} SHARED + null_elgamal.c +) + +target_compile_options(${target_name} + PRIVATE -std=c99 +) + +target_link_libraries(${target_name} + INTERFACE cmix-crypto + PRIVATE elgamal-interface +) diff --git a/libcmix-crypto/elgamal/null/null_elgamal.c b/libcmix-crypto/elgamal/null/null_elgamal.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/libcmix-crypto/elgamal/null/null_elgamal.c |
