blob: aa24e705fff3e604ac8c9e4a58fd98bb4a795339 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifdef SUPPORT_SHA3
int
libhashsum_init_sha3_hasher(struct libhashsum_hasher *this, size_t hashbits)
{
struct libkeccak_spec spec;
int r;
if (hashbits == 224U) {
this->algorithm = LIBHASHSUM_SHA3_224;
this->algorithm_string = "SHA3-224";
} else if (hashbits == 256U) {
this->algorithm = LIBHASHSUM_SHA3_256;
this->algorithm_string = "SHA3-256";
} else if (hashbits == 384U) {
this->algorithm = LIBHASHSUM_SHA3_384;
this->algorithm_string = "SHA3-384";
} else if (hashbits == 512U) {
this->algorithm = LIBHASHSUM_SHA3_512;
this->algorithm_string = "SHA3-512";
} else {
errno = EINVAL;
return -1;
}
libkeccak_spec_sha3(&spec, (long int)hashbits);
r = libhashsum_init_keccak__(this, hashbits, &spec, 1U, LIBKECCAK_SHA3_SUFFIX);
this->standard_partial_byte_output_encoding = LIBHASHSUM_UNSUPPORTED;
return r;
}
#else
int
libhashsum_init_sha3_hasher(struct libhashsum_hasher *this, size_t hashbits)
{
(void) this;
(void) hashbits;
errno = ENOSYS;
return -1;
}
#endif
|