This repository has been archived by the owner on Oct 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
libar2simplified_decode.3
143 lines (136 loc) · 2.94 KB
/
libar2simplified_decode.3
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
.TH LIBAR2SIMPLIFIED_DECODE 3 LIBAR2SIMPLIFIED
.SH NAME
libar2simplified_decode - Decode hashing parameters
.SH SYNOPSIS
.nf
#include <libar2simplified.h>
struct libar2_argon2_parameters *
libar2simplified_decode(const char *\fIstr\fP, char **\fItagp\fP, char **\fIendp\fP,
int (*\fIrandom_byte_generator\fP)(char *\fIout\fP, size_t \fIn\fP));
.fi
.PP
Link with
.IR "-lar2simplified -lar2" .
.SH DESCRIPTION
The
.BR libar2simplified_decode ()
function a decode hashing parameter string provided
in the
.I str
parameter.
.PP
This function supports the extended format described in
.BR libar2simplified_encode (3).
If the parameter string only specifies a salt length, and
not an actual salt, one is generate using the function
provided via the
.I random_byte_generator
parameter; or if
.I random_byte_generator
is
.IR NULL ,
a function built into the library itself. If the parameter
string specifies a tag (hash result), a pointer to it
is stored in
.IR *tagp ,
otherwise
.I *tagp
is set to
.IR NULL .
.RI ( *tagp
is only set unless
.I tagp
is
.IR NULL )
.PP
Unless
.I endp
is
.IR NULL ,
.I *endp
will be set to the end of the parameter string, which
terminates the tag. The application shall make sure
that
.I *endp
is a proper termination of the parameter string,
typically this would be a colon
.RB ( : ),
if read from
.I /etc/shadow
or a similar file, or a NUL byte. The
.BR libar2simplified_decode ()
function will
.B not
make this check even if
.I endp
is
.IR NULL .
.PP
Unless
.I random_byte_generator
is
.IR NULL ,
it shall generate
.I n
random bytes and store them in
.I out
and return 0, or on failure -1. Each byte need
only have its 6 lower bits set randomly.
.PP
The hashing string does not encode information
about the secret (pepper) or associated data,
which will therefore be set to zero-length.
.PP
.I params
may not be
.IR NULL .
.SH RETURN VALUES
The
.BR libar2simplified_decode ()
function returns a dynamically allocated
structure detailing the contents of
.IR str ,
which can be deallocated using the
.BR free (3)
function, upon successful completion.
On error,
.I NULL
is returned and
.I errno
is set to describe the error.
.SH ERRORS
The
.BR libar2simplified_decode ()
function will fail if:
.TP
.B EINVAL
The contents of
.I str
is invalid or unsupported.
.TP
.B ENOMEM
Insufficient storage space is available.
.PP
The
.BR libar2simplified_decode ()
function will fail if the
.I random_byte_generator
fails, in which case it will not modify
the value of
.IR errno .
.SH NOTES
The returned objects allocation size will
exceed the size of its type, so that the
salt can be stored in it, and automatically
deallocated when the returned pointer is
deallocated.
.SH SEE ALSO
.BR libar2simplified (7),
.BR libar2simplified_decode_r (3),
.BR libar2simplified_encode (3),
.BR libar2simplified_encode_hash (3),
.BR libar2simplified_recommendation (3),
.BR libar2simplified_hash (3),
.BR libar2_decode_params (3),
.BR libar2_validate_params (3),
.BR libar2_hash (3)