HashEngine.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CRYPTO_HASH_ENGINE(class_, name_, hashsize_, statesize_, blocksize_, INIT)
 Macro template to construct Engine class wrapper for a given hash API. More...
 
#define CRYPTO_HASH_ENGINE_STD(class_, name_, hashsize_, statesize_, blocksize_)   CRYPTO_HASH_ENGINE(class_, name_, hashsize_, statesize_, blocksize_, CRYPTO_HASH_ENGINE_STD_INIT)
 Macro template to construct standard hash engines. More...
 
#define CRYPTO_HASH_ENGINE_STD_INIT(name_)
 Macro template to provide init/state methods for standard hash engines. More...
 

Macro Definition Documentation

◆ CRYPTO_HASH_ENGINE

#define CRYPTO_HASH_ENGINE (   class_,
  name_,
  hashsize_,
  statesize_,
  blocksize_,
  INIT 
)
Value:
class class_##Engine \
{ \
public: \
static constexpr const char* name = #name_; \
static constexpr size_t hashsize = hashsize_; \
static constexpr size_t statesize = statesize_; \
static constexpr size_t blocksize = blocksize_; \
\
INIT(name_) \
\
void update(const void* data, size_t size) \
{ \
CRYPTO_NAME(name_, update)(&ctx, static_cast<const uint8_t*>(data), size); \
} \
\
void final(uint8_t* hash) \
{ \
CRYPTO_NAME(name_, final)(hash, &ctx); \
} \
\
private: \
CRYPTO_CTX(name_) ctx; \
};

Macro template to construct Engine class wrapper for a given hash API.

Parameters
class_Name for the class type, upper-case camel
name_Name for the C API, lower-case camel
hashsize_Size of hash in bytes
statesize_Size of state in bytes
blocksize_Size of block buffer in bytes
INITMacro to implement init/state and any other custom interface code

Init methods may have optional parameters. State methods are only required for standard hashes. These are used by Bear SSL multi-hash implementation.

◆ CRYPTO_HASH_ENGINE_STD

#define CRYPTO_HASH_ENGINE_STD (   class_,
  name_,
  hashsize_,
  statesize_,
  blocksize_ 
)    CRYPTO_HASH_ENGINE(class_, name_, hashsize_, statesize_, blocksize_, CRYPTO_HASH_ENGINE_STD_INIT)

Macro template to construct standard hash engines.

◆ CRYPTO_HASH_ENGINE_STD_INIT

#define CRYPTO_HASH_ENGINE_STD_INIT (   name_)
Value:
void init() \
{ \
CRYPTO_NAME(name_, init)(&ctx); \
} \
\
uint64_t get_state(void* state) \
{ \
return CRYPTO_NAME(name_, get_state)(&ctx, state); \
} \
\
void set_state(const void* state, uint64_t count) \
{ \
CRYPTO_NAME(name_, set_state)(&ctx, state, count); \
}
void CRYPTO_NAME(blake2s, initkey)(crypto_blake2s_context_t *ctx

Macro template to provide init/state methods for standard hash engines.