X-Git-Url: https://git.cryptolib.org/?p=avr-crypto-lib.git;a=blobdiff_plain;f=hashfunction_descriptor.h;h=de3c8074b5ce06b7271b45019c23d61a8d4b026e;hp=3440cd0dcec468ed924ec27f09404fa1607a7797;hb=2c909fca2a13cd76a526515bda5d0292483d7a55;hpb=e5a49deb52521f019e37779d6e9d81ec4f02aba4 diff --git a/hashfunction_descriptor.h b/hashfunction_descriptor.h index 3440cd0..de3c807 100644 --- a/hashfunction_descriptor.h +++ b/hashfunction_descriptor.h @@ -15,29 +15,42 @@ typedef void(*hf_nextBlock_fpt)(void*, const void*); typedef void(*hf_lastBlock_fpt)(void*, const void*, uint16_t); typedef void(*hf_ctx2hash_fpt)(void*, void*); typedef void(*hf_free_fpt)(void*); -typedef void(*hf_mem_fpt)(void*, void*, uint32_t); +typedef void(*hf_mem_fpt)(void*, const void*, uint32_t); #define HFDESC_TYPE_HASHFUNCTION 0x02 typedef struct { + /** typefield, always 2 for hash functions */ uint8_t type; /* 2 == hashfunction */ + /** flags, currently unused should be set to zero */ uint8_t flags; + /** name, flash pointer to the name string */ PGM_P name; - uint16_t ctxsize_B; + /** ctxsize_B, size of the hash context in bytes */ + size_t ctxsize_B; + /** blocksize_b, size of an input block in bits */ uint16_t blocksize_b; + /** hashsize_b, size of the output hash value in bits */ uint16_t hashsize_b; - + /** init, function pointer to the algorithms init function */ hf_init_fpt init; + /** nextBlock, function pointer to the algorithms nextBlock function */ hf_nextBlock_fpt nextBlock; + /** lastBlock, function pointer to the algorithms lastBlock function */ hf_lastBlock_fpt lastBlock; + /** ctx2hash, function pointer to the algorithms ctx2hash function */ hf_ctx2hash_fpt ctx2hash; + /** free, function pointer to the algorithms free function or NULL if + * there is no such function */ hf_free_fpt free; + /** mem, function pointer to a function which hashes a message in RAM + * completely or NULL if there is no such function */ hf_mem_fpt mem; -} hfdesc_t; /* blockcipher descriptor type */ +} hfdesc_t; /* hashfunction descriptor type */ typedef struct{ - hfdesc_t* desc_ptr; + hfdesc_t *desc_ptr; void* ctx; } hfgen_ctx_t;