This is a super easy and straightforward C implementation of the Elliptic Curve Integrated Encryption Scheme as defined in SECG SEC-1 (Section 5.1), ISO/IEC 18033-2, ANSI X9.63, etc...
More useful information also accessible here, here aand here.
git clone --recursive https://github.com/GlitchedPolygons/cecies.git
Just add CECIES as a git submodule to your project (e.g. into some lib/
or deps/
folder inside your project's repo; {repo_root}/lib/
is used here in the following example).
git submodule add https://github.com/GlitchedPolygons/cecies.git lib/cecies
git submodule update --init --recursive
If you don't want to use git submodules, you can also start vendoring a specific version of CECIES by copying its full repo content into the folder where you keep your project's external libraries/dependencies.
Never expose your private keys, take extra care when handling them and always clean up after doing crypto ops in C (don't leave private key buffers lying around in RAM at any point when they are not needed!).
There are pre-built binaries for every major platform for you to download inside the GitHub Releases page. Thanks for downloading, and I hope you enjoy!
Oh, you're still here :) You really want to compile it yourself, huh. Cool.
Look, just execute the following command and you'll have your CECIES comfortably built and packaged for you automatically into a .tar.gz file that you will find inside the build/
folder.
bash build.sh
This works on Windows too: just use the Git Bash for Windows CLI!
bash build-mingw.sh
Wanna compile using MinGW-w64? Run this using e.g. "Git Bash for Windows". Make sure that you have your MinGW installation directory inside your PATH
- otherwise this script will fail when trying to call mingw32-make.exe
.
Official release builds are made using mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gcc.exe
.
If you use CMake you can just add_subdirectory(path_to_submodule)
and then target_link_libraries(your_project PRIVATE cecies)
inside your CMakeLists.txt file. Done! You can now include CECIES headers in your code and be done with it.
This is equivalent to static linking by default, but much more pleasant than the manual variant.
- To dynamically link CECIES into your application on Windows, you need to
#define CECIES_DLL
before including any of the CECIES headers in your code! (Or, alternatively, add theCECIES_DLL
pre-processor definition inside your build script/solution config) -
- This will add the
__declspec(dllexport)
declaration that is needed on Windows to the various CECIES functions.
- This will add the
- If you did not grab the pre-built DLL, you need to define/pass the pre-processor macro
CECIES_BUILD_DLL
before compiling CECIES! -
- Your consuming code should then only
#define CECIES_DLL
(as stated above).
- Your consuming code should then only
- For shared libs: always have the CECIES shared library reachable inside your
$PATH
, or copy it into the same directory where your application's executable resides.
Note: the default configuration for building CECIES as a shared library compiles the MbedTLS dependency targets as position-independent code directly into the CECIES shared library, so that you only need to include one cecies.dll
file (or .so
/.dylib
file, whatever) with your application.
If this is not what you want, you are free to manually compile MbedTLS as a DLL too and modify the CMakeLists.txt file accordingly.
Linking statically feels best when done directly via CMake's add_subdirectory(path_to_submodule)
command as seen above, but if you still want to build CECIES as a static lib
yourself and link statically against it, you need to remember to also link your consuming application against mbedx509
, mbedtls
and mbedcrypto
besides cecies
!
To find out how to use the encrypt and decrypt functions, check out the docs or the provided example .c files..
There is also a graphical user interface for this available for desktop (Windows, Mac and Linux). That one costs some money, but links dynamically into this library here (which I signed using the Glitched Polygons GPG key), so no worries there. There's an Android app too.
Please consider buying the GUI from the Glitched Polygons Store (https://glitchedpolygons.com/software/cecies) to support me and my teammates in our mission to create better video games, tools and software for the world to enjoy :)