/crypto-algorithms

Fork of cryptography algorithms, like MD5, SHA1, SHA256, and others

Primary LanguageC

crypto-algorithms

About

These are basic implementations of standard cryptography algorithms, written by Brad Conte (brad@bradconte.com) from scratch and without any cross-licensing. They exist to provide publically accessible, restriction-free implementations of popular cryptographic algorithms, like AES and SHA-1. These are primarily intended for educational and pragmatic purposes (such as comparing a specification to actual implementation code, or for building an internal application that computes test vectors for a product). The algorithms have been tested against standard test vectors.

This code is released into the public domain free of any restrictions. The author requests acknowledgement if the code is used, but does not require it. This code is provided free of any liability and without any quality claims by the author.

Note that these are not cryptographically secure implementations. They have no resistence to side-channel attacks and should not be used in contexts that need cryptographically secure implementations.

These algorithms are not optimized for speed or space. They are primarily designed to be easy to read, although some basic optimization techniques have been employed.

Building

The source code for each algorithm will come in a pair of a source code file and a header file. There should be no inter-header file dependencies, no additional libraries, no platform-specific header files, or any other complicating matters. Compiling them should be as easy as adding the relevent source code to the project.

20171126: Added a cmake cross-port building mechanism, and suggest out-of-source building in the build folder, where there are build-me scripts, which may be suitable for use, with or without minor personal adjustments, but the building is easy using the cmake native default build file generation, but cmake supports a considerable list... use cmake --help to see the list available.

For unix, given the make tools are installed -

  • $ cd build
  • $ cmake .. [options]
  • $ make

For Windows, given MSVC is installed -

  • $ cd build
  • $ cmake .. [options]
  • $ cmake --build . --config Release

A common option is -DCMAKE_INSTALL_PREFIX=/base/install/path, normally /usr in *nix, but only the test applications install has been implemented in the WIP CMakeLists.txt...

In several cases, md5, sha1, and sha256, the test application has been expanded to a simple working application to generate and/or validate a given checksum for a particular input file. Run with -? will give brief help of the options available.

Again would stress the largely educational purpose of this code...

Have fun...

; eof