Originally based on various contributions released into the Public Domain, this repository contains Cryptographic C/C++/CUDA support intended for continued use in the Open Source community.
Generally, hashing functions may be used by declaring an algorithms "context", and calling initial, update and final hash functions as required, OR; by simply calling the convenient "all-in-one" function that handles the algorithm's steps internally.
For example, the popular SHA256 algorithm may be used with a single call:
#include "sha256.h"
void simple_hash(void *data, size_t datalen, void *out)
{
sha256(data, datalen, out);
}
OR; it may be used with more control:
#include "sha256.h"
void thrice_hash(void *data, size_t datalen, void *out)
{
SHA256_CTX ctx;
sha256_init(&ctx);
sha256_update(&ctx, data, datalen);
sha256_update(&ctx, data, datalen);
sha256_update(&ctx, data, datalen);
sha256_final(&ctx, out);
}
Most hashing algorithms follow the same syntax. For specific usage information, see the documentation.
The Crypto C/C++ Library was designed to be included in other projects as a Git Submodule. For C projects utilizing a similar structure and makefile, it is recommended to add submodules to the include/
directory of "superproject".
git submodule add https://github.com/adequatesystems/crypto-c include/crypto-c
git commit -m "include crypto-c submodule"
git -C include/crypto-c pull origin main
git commit -m "update crypto-c to latest revision"
git -C include/crypto-c fetch
git -C include/crypto-c checkout <hash or version tag>
git commit -m "checkout crypto-c submodule to <hash or version tag>"
The source for Blake2b, CRC16, CRC32, MD2, MD5, SHA1, SHA256 and the associated device utility header is released into the Public Domain under the Creative Commons Zero v1.0 Universal license.
The source for SHA3 is (re)released under the MIT license (MIT) which can be viewed in the relevant sha3.c and sha3.h files.
The remaining build and workflow utilities are components of Adequate Systems' build-c
repository, which is licensed separately to this repository. See https://github.com/adequatesystems/build-c/ for more information on that license.