c-multihash/include/mh/hashes.h

45 lines
858 B
C

/* vim: set ts=8 sw=8 noexpandtab: */
#include "errors.h"
// list of avaliable hash functions.
typedef enum {
MH_H_SHA1,
MH_H_SHA2_256,
MH_H_SHA2_512,
MH_H_SHA3_512,
MH_H_SHA3_384,
MH_H_SHA3_256,
MH_H_SHA3_224,
MH_H_SHAKE_128,
MH_H_SHAKE_256,
MH_H_BLAKE2B,
MH_H_BLAKE2S,
MH_H_COUNT // number of hash functions
} mh_hash;
// returns default length in bytes of given hash function
// or -1 in case of invalid arguemnt
int mh_hash_default_length(mh_hash hash);
// returns wire format code of given hash function
int mh_hash_code(mh_hash hash);
typedef struct {
mh_hash hash;
int code;
int length;
} mh_hashinfo;
// decodes code info hash info, leaves length field zeroed
mh_error mh_hashinfo_from_code(int code, mh_hashinfo *hinfo);
// decodes bytes into hashinfo
mh_error mh_hashinfo_from_bytes(char bytes[2], mh_hashinfo *hinfo);