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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
.TH LIBAR2_VALIDATE_PARAMS 3 LIBAR2
.SH NAME
libar2_validate_params - Validate Argon2 hashing parameters
.SH SYNOPSIS
.nf
#include <libar2.h>
enum libar2_parameter_error {
LIBAR2_OK,
LIBAR2_T_COST_TOO_SMALL,
LIBAR2_T_COST_TOO_LARGE,
LIBAR2_M_COST_TOO_SMALL,
LIBAR2_M_COST_TOO_LARGE,
LIBAR2_TOO_FEW_LANES,
LIBAR2_TOO_MANY_LANES,
LIBAR2_SALT_TOO_SMALL,
LIBAR2_SALT_TOO_LARGE,
LIBAR2_KEY_TOO_LARGE,
LIBAR2_AD_TOO_LARGE,
LIBAR2_HASH_TOO_SMALL,
LIBAR2_HASH_TOO_LARGE,
LIBAR2_INVALID_TYPE,
LIBAR2_INVALID_VERSION
};
enum libar2_argon2_version {
LIBAR2_ARGON2_VERSION_10 = 0x10,
LIBAR2_ARGON2_VERSION_13 = 0x13
};
enum libar2_argon2_type {
LIBAR2_ARGON2D = 0,
LIBAR2_ARGON2I = 1,
LIBAR2_ARGON2ID = 2,
LIBAR2_ARGON2DS = 4
};
struct libar2_argon2_parameters {
enum libar2_argon2_type \fItype\fP;
enum libar2_argon2_version \fIversion\fP;
uint_least32_t \fIt_cost\fP;
uint_least32_t \fIm_cost\fP;
uint_least32_t \fIlanes\fP;
unsigned char *\fIsalt\fP;
size_t \fIsaltlen\fP;
unsigned char *\fIkey\fP;
size_t \fIkeylen\fP;
unsigned char *\fIad\fP;
size_t \fIadlen\fP;
size_t \fIhashlen\fP;
};
enum libar2_parameter_error libar2_validate_params(const struct libar2_argon2_parameters *\fIparams\fP, const char **\fIerrmsgp\fP);
.fi
.PP
Link with
.IR -lar2 .
.SH DESCRIPTION
The
.BR libar2_validate_params ()
function checks that the hashing parameters
provided in the
.I params
parameters are valid and can be used for
hashing by the libar2 library. An error
description will be stored in
.I *errmsgp
unless
.I errmsgp
is
.IR NULL .
.PP
Only the first discovered invalid data
will be described.
.PP
.I params
may not be
.IR NULL .
.SH RETURN VALUES
The
.BR libar2_validate_params ()
function returns
.I LIBAR2_OK
(which has the value 0) and stores the
statically allocated string
.B \(dqOK\(dq
in
.I *errmsgp
(unless
.I errmsgp
is
.IR NULL )
if the input is valid. If the input is
invalid, an error code (with a positive
value) will returned and description of
what is incorrect is stored in
.I *errmsgp
(unless
.I errmsgp
is
.IR NULL ).
The return values that indicate invalid
input, in the current version of the
function are:
.TP
.B LIBAR2_T_COST_TOO_SMALL
The time-cost parameter is too small.
.TP
.B LIBAR2_T_COST_TOO_LARGE
The time-cost parameter is too large.
.TP
.B LIBAR2_M_COST_TOO_SMALL
The memory-cost parameter is too small.
.TP
.B LIBAR2_M_COST_TOO_LARGE
The memory-cost parameter is too large.
.TP
.B LIBAR2_TOO_FEW_LANES
The lane-count parameter is too small.
.TP
.B LIBAR2_TOO_MANY_LANES
The lane-count parameter is too large
.TP
.B LIBAR2_SALT_TOO_SMALL
The salt parameter is too small.
.TP
.B LIBAR2_SALT_TOO_LARGE
The salt parameter is too large.
.TP
.B LIBAR2_KEY_TOO_LARGE
The secret (pepper) parameter is too large.
.TP
.B LIBAR2_AD_TOO_LARGE
The associated data parameter is too large.
.TP
.B LIBAR2_HASH_TOO_SMALL
The tag length is too small.
.TP
.B LIBAR2_HASH_TOO_LARGE
The tag length is too large.
.TP
.B LIBAR2_INVALID_TYPE
The primitive type parameter is not supported
by the linked version of the libar2 library.
.TP
.B LIBAR2_INVALID_VERSION
The Argon2 version parameter is not supported
by the linked version of the libar2 library.
.SH ERRORS
The
.BR libar2_validate_params ()
function cannot fail.
.SH SEE ALSO
.BR libar2 (7),
.BR libar2_encode_params (3),
.BR libar2_decode_params (3),
.BR libar2_hash (3)
|