aboutsummaryrefslogtreecommitdiffstats
path: root/doc/man/libkeccak_spec_check.3
blob: 9cab551204014c6740dd1035674de3df3b6abf4c (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
.TH LIBKECCAK_SPEC_CHECK 3 LIBKECCAK-%VERSION%
.SH NAME
libkeccak_spec_check - Validate hashing parameters
.SH SYNOPSIS
.LP
.nf
#include <libkeccak.h>
.P
int libkeccak_spec_check(const libkeccak_spec_t *\fIspec\fP);
.fi
.P
Link with \fI-lkeccak\fP.
.SH DESCRIPTION
The
.BR libkeccak_spec_check ()
validates the parameters of \fI*spec\fP, so that
unusable configurations can be detected. It is
recommended to call this function after calling
.BR libkeccak_spec_sha3 (3),
.BR libkeccak_spec_rawshake (3),
.BR libkeccak_spec_shake (3),
or, especially, after settings the parameters
manually for Keccak hashing.
.PP
.nf
typedef struct libkeccak_spec {
    long bitrate;     /* bitrate (in bits) */
    long capacity;    /* capacity (in bits) */
    long output;      /* output size (in bits) */
} libkeccak_spec_t;
.fi
.SH RETURN VALUES
The
.BR libkeccak_spec_check ()
function returns 0 if the settings are usable. Otherwise
it will return one of the following constants.
.PP
.TP
.B LIBKECCAK_SPEC_ERROR_BITRATE_NONPOSITIVE
The specified bitrate was non-positive.
.TP
.B LIBKECCAK_SPEC_ERROR_BITRATE_MOD_8
The specified bitrate was not equivalent to 0
modulus 8, that is, it was not in whole bytes.
.TP
.B LIBKECCAK_SPEC_ERROR_CAPACITY_NONPOSITIVE
The specified capacity was non-positive.
.TP
.B LIBKECCAK_SPEC_ERROR_CAPACITY_MOD_8
The specified capacity was not equivalent to 0
modulus 8, that is, it was not in whole bytes.
.TP
.B LIBKECCAK_SPEC_ERROR_OUTPUT_NONPOSITIVE
The specified output size was non-positive.
.TP
.B LIBKECCAK_SPEC_ERROR_STATE_TOO_LARGE
The state size, that is the sum of the bitrate
and the capacity, exceeded the supported limit
(currently at 1600 bits.)
.TP
.B LIBKECCAK_SPEC_ERROR_STATE_MOD_25
The state size, that is the sum of the bitrate
and the capacity, in bits, was not equivalent
to 0 modulus 25. Meaning the state size cannot
cover all lanes equivalently.
.TP
.B LIBKECCAK_SPEC_ERROR_WORD_NON_2_POTENT
The word size, that is the state size divided
by 25, is not a power of 2.
.TP
.B LIBKECCAK_SPEC_ERROR_WORD_MOD_8
The word size, that is the state size divided
by 25, is not quivalent to 0 modulus 8, that
is, it is not in whole bytes.
.PP
Note that there may be more than one error. Only the first
detected is returned.
.SH ERRORS
The
.BR libkeccak_spec_check ()
function cannot fail.
.fi
.SH SEE ALSO
.BR libkeccak_spec_sha3 (3),
.BR libkeccak_spec_rawshake (3),
.BR libkeccak_spec_shake (3)
.SH AUTHORS
Principal author, Mattias Andrée.  See the LICENSE file for the full
list of authors.
.SH BUGS
Please report bugs to https://github.com/maandree/bus/issues or to
maandree@member.fsf.org