2016-07-26 11:00:54 +00:00
|
|
|
#include "mh/hashes.h"
|
2016-07-30 10:39:26 +00:00
|
|
|
#include "mh/errors.h"
|
2016-07-26 15:53:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
static const int hash_lengths[] = {
|
|
|
|
20, // sha1
|
|
|
|
32, // sha2-256
|
|
|
|
64, // sha2-512
|
|
|
|
64, // sha3-512
|
|
|
|
45, // sha3-364
|
|
|
|
32, // sha3-256
|
|
|
|
28, // sha3-224
|
|
|
|
16, // shake-128
|
|
|
|
32, // shake-256
|
2016-07-30 10:39:26 +00:00
|
|
|
64, // blake2b
|
|
|
|
32, // blake2s
|
2016-07-26 15:53:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int mh_hash_default_length(mh_hash hash) {
|
|
|
|
if (hash < 0 || hash >= MH_H_COUNT)
|
2016-07-30 10:39:26 +00:00
|
|
|
return MH_;
|
2016-07-26 15:53:52 +00:00
|
|
|
|
2016-07-30 10:39:26 +00:00
|
|
|
return hash_lengths[hash];
|
2016-07-26 15:53:52 +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,
|
|
|
|
|
|
|
|
HM_H_COUNT // number of hash functions
|
|
|
|
*/
|