blob: 7b6d78e391a17f3d7d3bc00c42529f34ad47d061 (
plain) (
tree)
|
|
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifdef SUPPORT_BLAKEB
int
libhashsum_init_blake_hasher(struct libhashsum_hasher *this, size_t hashbits, const void *salt, size_t salybytes)
{
if (salt) {
if (hashbits == 224U || hashbits == 256U) {
if (salybytes != 16U)
goto einval;
} else if (hashbits == 384U || hashbits == 512U) {
if (salybytes != 32U)
goto einval;
}
}
if (hashbits == 224U)
return libhashsum_init_blake224_hasher(this, salt);
if (hashbits == 256U)
return libhashsum_init_blake256_hasher(this, salt);
if (hashbits == 384U)
return libhashsum_init_blake384_hasher(this, salt);
if (hashbits == 512U)
return libhashsum_init_blake512_hasher(this, salt);
einval:
errno = EINVAL;
return -1;
}
#else
int
libhashsum_init_blake_hasher(struct libhashsum_hasher *this, size_t hashbits, const void *salt, size_t salybytes)
{
(void) this;
(void) hashbits;
(void) salt;
(void) saltbytes;
errno = ENOSYS;
return -1;
}
#endif
|