blob: 71631f6c7d4f2610dce1985292112fa05593d24a (
plain) (
tree)
|
|
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifdef SUPPORT_KECCAK
int
libhashsum_init_keccak_hasher2(struct libhashsum_hasher *this, const struct libhashsum_keccak_params *params)
{
struct libkeccak_generalised_spec gspec;
struct libkeccak_spec spec;
libkeccak_generalised_spec_initialise(&gspec);
if ((params->ratebits | params->capbits |
params->hashbits | params->statebits |
params->wordbits) > (size_t)LONG_MAX)
goto einval;
if (params->ratebits)
gspec.bitrate = (long int)params->ratebits;
if (params->capbits)
gspec.capacity = (long int)params->capbits;
if (params->hashbits)
gspec.output = (long int)params->hashbits;
if (params->statebits)
gspec.state_size = (long int)params->statebits;
if (params->wordbits)
gspec.word_size = (long int)params->wordbits;
if (libkeccak_degeneralise_spec(&gspec, &spec) || libkeccak_spec_check(&spec)) {
einval:
errno = EINVAL;
return -1;
}
return libhashsum_init_keccak_hasher(this, (size_t)spec.bitrate, (size_t)spec.capacity,
(size_t)gspec.output, params->squeezes);
}
#else
int
libhashsum_init_keccak_hasher2(struct libhashsum_hasher *this, const struct libhashsum_keccak_params *params)
{
(void) this;
(void) params;
errno = ENOSYS;
return -1;
}
#endif
|