c-multihash/include/mh/hashes.h

45 lines
858 B
C
Raw Normal View History

2016-07-26 10:54:37 +00:00
/* vim: set ts=8 sw=8 noexpandtab: */
2016-07-26 11:00:54 +00:00
#include "errors.h"
2016-07-26 10:54:37 +00:00
// 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
2016-07-26 10:54:37 +00:00
} 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);
2016-07-26 10:54:37 +00:00
// returns wire format code of given hash function
int mh_hash_code(mh_hash hash);
typedef struct {
mh_hash hash;
int code;
int length;
2016-07-26 11:00:54 +00:00
} mh_hashinfo;
2016-07-26 10:54:37 +00:00
// 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);