add blake lengths
This commit is contained in:
parent
177faf1ee6
commit
78435fb421
2 changed files with 8 additions and 5 deletions
|
@ -18,6 +18,9 @@ typedef enum {
|
||||||
MH_H_COUNT // number of hash functions
|
MH_H_COUNT // number of hash functions
|
||||||
} mh_hash;
|
} mh_hash;
|
||||||
|
|
||||||
|
// returns length in bytes or if returns is < 0 it is an error
|
||||||
|
int mh_hash_default_length(mh_hash hash);
|
||||||
|
|
||||||
int mh_hash_length(const unsigned char multihash[], int len, int *hash_length);
|
int mh_hash_length(const unsigned char multihash[], int len, int *hash_length);
|
||||||
|
|
||||||
int mh_hash_function(const unsigned char multihash[], int len, mh_hash *hash);
|
int mh_hash_function(const unsigned char multihash[], int len, mh_hash *hash);
|
||||||
|
|
10
src/hashes.c
10
src/hashes.c
|
@ -1,5 +1,6 @@
|
||||||
/* vim: set ts=8 sw=8 noexpandtab: */
|
/* vim: set ts=8 sw=8 noexpandtab: */
|
||||||
#include "mh/hashes.h"
|
#include "mh/hashes.h"
|
||||||
|
#include "mh/errors.h"
|
||||||
|
|
||||||
|
|
||||||
static const int hash_lengths[] = {
|
static const int hash_lengths[] = {
|
||||||
|
@ -12,17 +13,16 @@ static const int hash_lengths[] = {
|
||||||
28, // sha3-224
|
28, // sha3-224
|
||||||
16, // shake-128
|
16, // shake-128
|
||||||
32, // shake-256
|
32, // shake-256
|
||||||
// TODO(Kubuxu): implement blake lengths
|
64, // blake2b
|
||||||
|
32, // blake2s
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int mh_hash_default_length(mh_hash hash) {
|
int mh_hash_default_length(mh_hash hash) {
|
||||||
if (hash > MH_H_SHAKE_256)
|
|
||||||
return -2; // TODO(Kubuxu): remove it after blake is implemented
|
|
||||||
if (hash < 0 || hash >= MH_H_COUNT)
|
if (hash < 0 || hash >= MH_H_COUNT)
|
||||||
return -1;
|
return MH_;
|
||||||
|
|
||||||
return hash_lengths[0];
|
return hash_lengths[hash];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue