API Documentation
-
namespace Crypto
Typedefs
-
template<size_t hashsize>
using Blake2s = HashContext<Blake2sEngine<hashsize>>
-
template<size_t hashsize>
using HmacBlake2s = HmacContext<Blake2s<hashsize>>
-
using HmacBlake2s256 = HmacBlake2s<32>
-
using HmacBlake2s128 = HmacBlake2s<16>
-
template<size_t size_>
using ByteArray = 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 Md5 = HashContext<Md5Engine>
-
using HmacMd5 = HmacContext<Md5>
-
using Sha1 = HashContext<Sha1Engine>
-
using HmacSha1 = HmacContext<Sha1>
-
using Sha224 = HashContext<Sha224Engine>
-
using Sha256 = HashContext<Sha256Engine>
-
using Sha384 = HashContext<Sha384Engine>
-
using Sha512 = HashContext<Sha512Engine>
-
using HmacSha224 = HmacContext<Sha224>
-
using HmacSha256 = HmacContext<Sha256>
-
using HmacSha384 = HmacContext<Sha384>
-
using HmacSha512 = HmacContext<Sha512>
Functions
-
class Blob
- #include <Blob.h>
Wraps a pointer to some data with size.
-
template<class Engine_>
class HashContext - #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
-
inline HashContext &update(const Blob &blob)
Data from Blob.
-
inline HashContext &update(const FSTR::ObjectBase &obj)
Data from flash object.
-
inline HashContext &update(const void *data, size_t size)
Pointer to data + size.
- Parameters:
data – Data block
size – Length of data in bytes
-
template<size_t size_>
inline HashContext &update(const ByteArray<size_> &array) Data in ByteArray.
Public Functions
-
template<typename ...EngineArgs>
inline HashContext &reset(EngineArgs&&... engineArgs) Reset the context for a new calculation.
-
template<typename ...Ts>
inline Hash calculate(Ts&&... args) Calculate hash on some data.
- Parameters:
args – See update() methods
- Return values:
Hash –
-
inline Hash getHash()
Finalise and return the final hash value.
- Return values:
Hash –
-
inline 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 values:
uint64_t – Number of bytes processed so far
-
inline 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>
class HmacContext - #include <HmacContext.h>
HMAC class template.
Implements the HMAC algorithm using any defined hash context
Public Functions
-
inline HmacContext &init(const Secret &key)
Initialise HMAC with key.
- Return values:
Reference – to enable method chaining
-
template<typename ...Ts>
inline HmacContext &update(Ts&&... args) Update HMAC with some message content.
- Parameters:
args – See HashContext update() methods
- Return values:
Reference – to enable method chaining
-
template<typename ...Ts>
inline Hash calculate(Ts&&... args) Calculate hash for some data.
Use like this:
auto hash = Crypto::HmacMd5(mySecret).calculate(myData);
- Parameters:
args – See HashContext update() methods
- Return values:
Hash –
-
inline HmacContext &init(const Secret &key)
-
template<size_t hashsize>