#ifndef PROOF_H
#define PROOF_H
#include
#include
#include
/*
Total encapsulation, we do not know nothing about what proof is.
Disadvantage - we have to allocate memory for it. Client looses flexibility and he has to call release.
*/
typedef struct proof_s proof_t;
/*
This is the interface for what hash function is. It is a function that takes
- data - pointer to data bufer (in parameter)
- dataLength - size of the buffer (in parameter)
- digest - buffer where to store the resulting hash (out parameter)
- digestLength - maximal length of digest and resulting digest length (in/out parameter)
Note the care for the buffer sizes. And note the care for const-correctness.
*/
typedef bool (*hash_fn_t)(const uint8_t *data, size_t dataLength, uint8_t *digest, size_t *digestLength);
proof_t* proof_create();
bool proof_init(proof_t *proof, const uint8_t *data, size_t dataLength, const hash_fn_t hashFn);
bool proof_step(proof_t *proof, const uint8_t *data, size_t dataLength);
bool proof_finish(proof_t *proof);
void proof_release(proof_t *proof);
#endif