API Documentation¶
-
namespace
Crypto
¶ Typedefs
-
using
Crypto::Blake2s = typedef HashContext<Blake2sEngine<hashsize> >
-
using
Crypto::Blake2s256 = typedef Blake2s<32>
-
using
Crypto::Blake2s128 = typedef Blake2s<16>
-
using
Crypto::HmacBlake2s = typedef HmacContext<Blake2s<hashsize> >
-
using
Crypto::HmacBlake2s256 = typedef HmacBlake2s<32>
-
using
Crypto::HmacBlake2s128 = typedef HmacBlake2s<16>
-
using
Crypto::Secret = typedef Blob
Identifies data which should be treated with care.
-
using
Crypto::ByteArray = typedef std::array<uint8_t, size_>
Class template for fixed byte array.
- Note
- Until C++17 (and GCC > 5.5) inheriting from std::array<> breaks aggregate initialization.
-
using
Crypto::Md5 = typedef HashContext<Md5Engine>
-
using
Crypto::HmacMd5 = typedef HmacContext<Md5>
-
using
Crypto::Sha1 = typedef HashContext<Sha1Engine>
-
using
Crypto::HmacSha1 = typedef HmacContext<Sha1>
-
using
Crypto::Sha224 = typedef HashContext<Sha224Engine>
-
using
Crypto::Sha256 = typedef HashContext<Sha256Engine>
-
using
Crypto::Sha384 = typedef HashContext<Sha384Engine>
-
using
Crypto::Sha512 = typedef HashContext<Sha512Engine>
-
using
Crypto::HmacSha224 = typedef HmacContext<Sha224>
-
using
Crypto::HmacSha256 = typedef HmacContext<Sha256>
-
using
Crypto::HmacSha384 = typedef HmacContext<Sha384>
-
using
Crypto::HmacSha512 = typedef HmacContext<Sha512>
Functions
-
CRYPTO_HASH_ENGINE_STD
(Md5, md5, MD5_SIZE, MD5_STATESIZE, MD5_BLOCKSIZE)¶
-
CRYPTO_HASH_ENGINE_STD
(Sha1, sha1, SHA1_SIZE, SHA1_STATESIZE, SHA1_BLOCKSIZE)¶
-
CRYPTO_HASH_ENGINE_STD
(Sha224, sha224, SHA224_SIZE, SHA224_STATESIZE, SHA224_BLOCKSIZE)¶
-
CRYPTO_HASH_ENGINE_STD
(Sha256, sha256, SHA256_SIZE, SHA256_STATESIZE, SHA256_BLOCKSIZE)¶
-
CRYPTO_HASH_ENGINE_STD
(Sha384, sha384, SHA384_SIZE, SHA384_STATESIZE, SHA384_BLOCKSIZE)¶
-
CRYPTO_HASH_ENGINE_STD
(Sha512, sha512, SHA512_SIZE, SHA512_STATESIZE, SHA512_BLOCKSIZE)¶
-
class
Blob
¶ - #include <Blob.h>
Wraps a pointer to some data with size.
-
template <class Engine_>
classHashContext
¶ - #include <HashContext.h>
Class template for a Hash implementation ‘Context’.
- Template Parameters
Engine
: The HashEngine implementation
Subclassed by OtaUpgrade::ChecksumVerifier
Update hash over a given block of data
-
HashContext &
update
(const Blob &blob)¶
-
HashContext &
update
(const FSTR::ObjectBase &obj)¶
-
HashContext &
update
(const void *data, size_t size)¶
-
template <size_t size_>
HashContext &update
(const ByteArray<size_> &array)¶
Public Functions
-
template <typename... EngineArgs>
HashContext
(EngineArgs&&... engineArgs)¶
-
template <typename... EngineArgs>
HashContext &reset
(EngineArgs&&... engineArgs)¶ Reset the context for a new calculation.
-
template <typename... Ts>
Hashcalculate
(Ts&&... args)¶ Calculate hash on some data.
- Parameters
args
: See update() methods
- Return Value
Hash
:
-
Hash
getHash
()¶ Finalise and return the final hash value.
- Return Value
Hash
:
-
State
getState
()¶ Get intermediate hash state.
- Note
- This method is only required for core hashes, used by Bear SSL
- Parameters
state
: OUT: current state
- Return Value
uint64_t
: Number of bytes processed so far
-
void
setState
(const State &state)¶ Restore intermediate hash state.
Parameter values obtained via previous getState() call
- Note
- This method is only required for core hashes, used by Bear SSL
- Parameters
state
:count
:
-
struct
State
¶ - #include <HashContext.h>
-
template <class HashContext>
classHmacContext
¶ - #include <HmacContext.h>
HMAC class template.
Implements the HMAC algorithm using any defined hash context
Public Types
-
template<>
usingEngine
= typename HashContext::Engine¶
-
template<>
usingHash
= typename HashContext::Hash¶
Public Functions
-
HmacContext
(const Secret &key)¶ Initialise HMAC context with key.
-
HmacContext &
init
(const Secret &key)¶ Initialise HMAC with key.
- Return Value
Reference
: to enable method chaining
-
template <typename... Ts>
HmacContext &update
(Ts&&... args)¶ Update HMAC with some message content.
- Parameters
args
: See HashContext update() methods
- Return Value
Reference
: to enable method chaining
-
Hash
getHash
()¶
-
template <typename... Ts>
Hashcalculate
(Ts&&... args)¶ Calculate hash for some data.
Use like this:
auto hash = Crypto::HmacMd5(mySecret).calculate(myData);
- Parameters
args
: See HashContext update() methods
- Return Value
Hash
:
Public Static Attributes
-
constexpr size_t
blocksize
= Engine::blocksize¶
-
template<>
-
using