c-multihash/include/mh/hashes.h

49 lines
1,014 B
C
Raw Normal View History

#pragma once
2016-07-26 11:00:54 +00:00
#include "errors.h"
2016-07-26 10:54:37 +00:00
// definitions of hash functions
#define MH_H_SHA1 0x11
#define MH_H_SHA2_256 0x12
#define MH_H_SHA2_512 0x13
#define MH_H_SHA3_512 0x14
#define MH_H_SHA3_384 0x15
#define MH_H_SHA3_256 0x16
#define MH_H_SHA3_224 0x17
#define MH_H_SHAKE_128 0x18
#define MH_H_SHAKE_256 0x19
#define MH_H_BLAKE2B 0x40
#define MH_H_BLAKE2S 0x41
2016-07-26 10:54:37 +00:00
// list of avaliable hash functions.
static const int mh_all_hashes[] = {
2016-07-26 10:54:37 +00:00
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,
};
#define MH_H_COUNT (int)(sizeof(mh_all_hashes) / sizeof(mh_all_hashes[0]))
2016-07-26 10:54:37 +00:00
2016-11-07 22:05:49 +00:00
/**
* Given the id, return the hash name
* @param hash the id (such as MH_H_SHA1)
* @returns the name as text, such as "sha1"
*/
const char *mh_hash_name(int hash);
2016-07-26 10:54:37 +00:00
2016-11-07 22:05:49 +00:00
/**
* Given the id, return the default length
* @param hash the id
* @returns the default length of that hash
*/
int mh_hash_default_length(int hash);