AnCH cryptography library aims to provide facilities for cryptography.
This library is divided in functional parts. For now parts are:
There is also some other features like HMAC which depends on hash.
anch-utils (header only) and anch-uuid (MD5 and SHA1 UUID providers).
This library has been written for fun and is not audited: prefer a reviewed library (such as OpenSSL) for security sensitive applications.
CMake target anch::crypto, option ANCH_BUILD_CRYPTO:
See installation.
Every hash implementation inherits the anch::crypto::Hash class.
Hash is a template class which is parameterized by its ouput and block size. These parameters are used to other algorithms based on hash like HMAC.
For now, implemented hashes are:
anch::crypto::SHA224_256 ; anch::crypto::SHA384 and anch::crypto::SHA512 which are type defintions of anch::crypto::SHA384_512 The SHA384 and SHA512 are optimized for 64-bits CPU. 32-bits CPU optimization isplanned for later.
Every Hash owns its context which is reset on each call.
Digest is computed on instanciation or by calling one of the Hash digest methods. Data to hash can be:
Hash result will be retrieved by calling method digest (without parameter).
Only anch::crypto::AES is implemented for now.
AES has only 2 methods:
Secret key is expanded on instanciation and is reused for each block (on each call).
Block cipher modes of operation (ECB , CBC , CFB , OFB , PCBC and CTR ) cipher and decipher streams with a block cipher and a padding (PKCS5Padding , ISO7816_4Padding , ANSIX923 , ZeroPadding ).
CTR follows NIST SP 800-38A (as OpenSSL): its nonce is the initial counter block, incremented as a big endian integer for each block. A nonce must never be used twice with the same key.