diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2016-11-28 13:07:37 +0100 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2016-11-28 13:07:37 +0100 |
| commit | f8a927984a56e75718bfc273b61693442c9ce649 (patch) | |
| tree | 30c9d3f7b6e0252647cf94a51d018678f22154f0 | |
| parent | 74cea534fd189a2db423ae60997447e66265922b (diff) | |
| download | cmix-f8a927984a56e75718bfc273b61693442c9ce649.tar.gz cmix-f8a927984a56e75718bfc273b61693442c9ce649.tar.bz2 cmix-f8a927984a56e75718bfc273b61693442c9ce649.zip | |
Removed the Bignum abstraction library, as it was not needed.
| -rw-r--r-- | CMakeLists.txt | 1 | ||||
| -rw-r--r-- | client/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | libcmix-bignum/CMakeLists.txt | 33 | ||||
| -rw-r--r-- | libcmix-bignum/bignum.h | 72 | ||||
| -rw-r--r-- | libcmix-bignum/gmp/CMakeLists.txt | 14 | ||||
| -rw-r--r-- | libcmix-bignum/gmp/gmp_bignum.c | 49 | ||||
| -rw-r--r-- | libcmix-bignum/null/CMakeLists.txt | 11 | ||||
| -rw-r--r-- | libcmix-bignum/null/null_bignum.c | 9 | ||||
| -rw-r--r-- | libcmix/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | libcmix/cmix.c | 8 | ||||
| -rw-r--r-- | libcmix/cmix.h | 9 | ||||
| -rw-r--r-- | node/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | node/node.cpp | 1 |
13 files changed, 0 insertions, 210 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d4c104..847d6b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,6 @@ endif(use_lto) set(CMAKE_CXX_STANDARD 11) set(CMAKE_C_STANDARD 99) -add_subdirectory(libcmix-bignum) add_subdirectory(libcmix-crypto) add_subdirectory(libcmix) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index c457c16..cd0b308 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -11,7 +11,6 @@ target_link_libraries(client PRIVATE Boost::system PRIVATE log PRIVATE cmix - PRIVATE cmix-bignum PRIVATE cmix-network PRIVATE cmix-protobuf PRIVATE cmix-common diff --git a/libcmix-bignum/CMakeLists.txt b/libcmix-bignum/CMakeLists.txt deleted file mode 100644 index 2cadc87..0000000 --- a/libcmix-bignum/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ - -add_library(cmix-bignum-interface INTERFACE) - -target_include_directories(cmix-bignum-interface - INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} -) - -set(interface_sources - ${CMAKE_CURRENT_SOURCE_DIR}/bignum.h -) - -target_sources(cmix-bignum-interface - INTERFACE ${interface_sources} -) - -include(bignum_implementations) -foreach(impl ${libcmix_bignum_implementations}) - add_subdirectory(${impl}) -endforeach() - -add_library(cmix-bignum INTERFACE) - -target_include_directories(cmix-bignum - INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} -) - -target_sources(cmix-bignum - INTERFACE ${interface_sources} -) - -target_link_libraries(cmix-bignum - INTERFACE libcmix-bignum-${libcmix_bignum_implementation} -) diff --git a/libcmix-bignum/bignum.h b/libcmix-bignum/bignum.h deleted file mode 100644 index fe690cc..0000000 --- a/libcmix-bignum/bignum.h +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#include <stddef.h> -#include <stdlib.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/*! - * \file - */ - -/*! - * \brief The bignum_error enum - */ -enum bignum_error { - NoError = 0, - error = -1 -}; - -/*! - * \brief cMix internal bignum representation. - */ -struct Bignum { - unsigned char* data; ///< Pointer to the start of the bignum. - size_t len; ///< The length of the data array. -}; - -/*! - * \brief allocate_bignum. Reserves space for a len size Bignum. - * \param len The length of the bignum data array. - * \return The Bignum array just allocated. - */ -inline struct Bignum allocate_bignum(size_t len) { - return (struct Bignum){ - (unsigned char*) malloc(len), - len - }; -} - -/*! - * \brief free_bignum. Counterpart to allocate_bignum. - * \param b The bignum to free - */ -inline void free_bignum(struct Bignum* b) { - free(b->data); - b->data = 0; - b->len = 0; -} - -/*! - * \brief get_curve25519_mod. Conveniance for now, but this returns the mod of curve25519 algorith (2^255-19) - * \param result The bignum to store the modulus in, has to be preallocated. - * \return Error status code based on backend errors. - */ -extern enum bignum_error get_curve25519_mod(struct Bignum* result); - -/*! - * \brief multiply_mod Multiplies 2 bignums module mod and stores the result in result. - * \param result Preallocated Bignum where the result will be stored. - * \param lh Lefthand of Multiplication. - * \param rh Righthand of Multiplaction. - * \param mod The modulus. - * \return Error status code based on backend errors. - */ -extern enum bignum_error multiply_mod(struct Bignum* result, struct Bignum const lh, struct Bignum const rh, struct Bignum const mod); - - -#ifdef __cplusplus -} -#endif
\ No newline at end of file diff --git a/libcmix-bignum/gmp/CMakeLists.txt b/libcmix-bignum/gmp/CMakeLists.txt deleted file mode 100644 index 4b3acbb..0000000 --- a/libcmix-bignum/gmp/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -include(get_target_name) - -get_target_name(target_name) - -find_package(gmp REQUIRED) - -add_library(${target_name} SHARED - gmp_bignum.c -) - -target_link_libraries(${target_name} - PRIVATE cmix-bignum-interface - PRIVATE gmp -) diff --git a/libcmix-bignum/gmp/gmp_bignum.c b/libcmix-bignum/gmp/gmp_bignum.c deleted file mode 100644 index cc40b48..0000000 --- a/libcmix-bignum/gmp/gmp_bignum.c +++ /dev/null @@ -1,49 +0,0 @@ -#include "bignum.h" - -#include "gmp.h" - -void from_bignum(mpz_t i, struct Bignum b) { - mpz_import(i, b.len, -1, 1, 0, 0, b.data); -} - -void to_bignum(struct Bignum* b, mpz_t i) { - mpz_export(b->data, &b->len, -1, 1, 0, 0, i); -} - -enum bignum_error get_curve25519_mod(struct Bignum* result) { - mpz_t mod; - mpz_init(mod); - mpz_ui_pow_ui(mod, 2, 255); - mpz_sub_ui(mod, mod, 19); - - to_bignum(result, mod); - return NoError; -} - -enum bignum_error multiply_mod(struct Bignum* result, struct Bignum const lh, struct Bignum const rh, struct Bignum const mod) { - mpz_t lh_; - mpz_init(lh_); - from_bignum(lh_, lh); - - mpz_t rh_; - mpz_init(rh_); - from_bignum(rh_, rh); - - mpz_t result_; - mpz_init(result_); - mpz_mul(result_, lh_, rh_); - - mpz_t mod_; - mpz_init(mod_); - from_bignum(mod_, mod); - mpz_mod(result_, result_, mod_); - - to_bignum(result, result_); - - mpz_clear(result_); - mpz_clear(lh_); - mpz_clear(rh_); - mpz_clear(mod_); - - return NoError; -} diff --git a/libcmix-bignum/null/CMakeLists.txt b/libcmix-bignum/null/CMakeLists.txt deleted file mode 100644 index 325d1c8..0000000 --- a/libcmix-bignum/null/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -include(get_target_name) - -get_target_name(target_name) - -add_library(${target_name} SHARED - null_bignum.c -) - -target_link_libraries(${target_name} - PRIVATE cmix-bignum-interface -) diff --git a/libcmix-bignum/null/null_bignum.c b/libcmix-bignum/null/null_bignum.c deleted file mode 100644 index 3b45132..0000000 --- a/libcmix-bignum/null/null_bignum.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "bignum.h" - -extern enum bignum_error get_curve25519_mod(struct Bignum* result) { - return NoError; -} - -extern enum bignum_error multiply_mod(struct Bignum* result, struct Bignum const lh, struct Bignum const rh, struct Bignum const mod) { - return NoError; -} diff --git a/libcmix/CMakeLists.txt b/libcmix/CMakeLists.txt index 5a7761b..a6d1c1b 100644 --- a/libcmix/CMakeLists.txt +++ b/libcmix/CMakeLists.txt @@ -9,5 +9,4 @@ target_include_directories(cmix target_link_libraries(cmix PUBLIC cmix-crypto - PUBLIC cmix-bignum ) diff --git a/libcmix/cmix.c b/libcmix/cmix.c index 2adca78..2311bea 100644 --- a/libcmix/cmix.c +++ b/libcmix/cmix.c @@ -6,14 +6,6 @@ #include <stdio.h> #include <math.h> -enum cmix_error calculate_shared_key_part(struct Bignum* result, struct Bignum partial_shared, struct Bignum my_share, struct Bignum mod) -{ - if(multiply_mod(result, partial_shared, my_share, mod) != NoError) { - return cmix_bignum_error; - } - return no_error; -} - struct CMixContext initialize_cmix_context(struct Api api) { return (struct CMixContext){ .api = api, diff --git a/libcmix/cmix.h b/libcmix/cmix.h index c3eeb3a..0b2a42a 100644 --- a/libcmix/cmix.h +++ b/libcmix/cmix.h @@ -7,7 +7,6 @@ extern "C" { #include "api.h" #include "keypair.h" #include "groupelement.h" -#include "bignum.h" /*! * \file @@ -35,15 +34,7 @@ enum cmix_error { }; /*! - * \brief calculate_shared_key_part Calculates (partly) the shared key which is needed by all the nodes. - * \param result Storage for the result - * \param partial_shared The shared key so far. - * \param my_share My part to add to the key. - * \param mod The modulus of the group we are in. - * \return An error_code. */ -enum cmix_error calculate_shared_key_part(struct Bignum* result, struct Bignum partial_shared, struct Bignum my_share, struct Bignum mod); - struct CMixContext { struct Api api; struct KeyPair keypair; diff --git a/node/CMakeLists.txt b/node/CMakeLists.txt index 3659984..87d3385 100644 --- a/node/CMakeLists.txt +++ b/node/CMakeLists.txt @@ -22,7 +22,6 @@ target_link_libraries(node PRIVATE Boost::system PRIVATE log PRIVATE cmix - PRIVATE cmix-bignum PRIVATE cmix-network PRIVATE cmix-protobuf PRIVATE cmix-common diff --git a/node/node.cpp b/node/node.cpp index 84ea179..b31f60a 100644 --- a/node/node.cpp +++ b/node/node.cpp @@ -1,7 +1,6 @@ #include "node.hpp" #include "cmix.h" -#include "bignum.h" #include "logging.hpp" |
