You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.8 KiB

/* hashfunction_descriptor.h */
#include <stdint.h>
#include <avr/pgmspace.h>
#ifndef VOID_FPT
#define VOID_FPT
typedef void(*void_fpt)(void);
typedef void(*hf_init_fpt)(void*);
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*);
13 years ago
typedef void(*hf_mem_fpt)(void*, const void*, uint32_t);
typedef struct {
13 years ago
/** typefield, always 2 for hash functions */
uint8_t type; /* 2 == hashfunction */
13 years ago
/** flags, currently unused should be set to zero */
uint8_t flags;
13 years ago
/** name, flash pointer to the name string */
PGM_P name;
13 years ago
/** ctxsize_B, size of the hash context in bytes */
size_t ctxsize_B;
13 years ago
/** blocksize_b, size of an input block in bits */
uint16_t blocksize_b;
13 years ago
/** hashsize_b, size of the output hash value in bits */
uint16_t hashsize_b;
13 years ago
/** init, function pointer to the algorithms init function */
hf_init_fpt init;
13 years ago
/** nextBlock, function pointer to the algorithms nextBlock function */
hf_nextBlock_fpt nextBlock;
13 years ago
/** lastBlock, function pointer to the algorithms lastBlock function */
hf_lastBlock_fpt lastBlock;
13 years ago
/** ctx2hash, function pointer to the algorithms ctx2hash function */
hf_ctx2hash_fpt ctx2hash;
13 years ago
/** free, function pointer to the algorithms free function or NULL if
* there is no such function */
hf_free_fpt free;
13 years ago
/** 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; /* hashfunction descriptor type */
typedef struct{
hfdesc_t *desc_ptr;
void* ctx;
} hfgen_ctx_t;