aboutsummaryrefslogtreecommitdiffstats
path: root/librecrypt_get_encoding.3
blob: a3f3d41291d93403896113d6ddb23555852637c6 (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
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
.TH LIBRECRYPT_GET_ENCODING 3 LIBRECRYPT
.SH NAME
librecrypt_get_encoding - Get encoding alphabet for the last algorithm in a chain

.SH SYNOPSIS
.nf
#include <librecrypt.h>

const void *\fBlibrecrypt_get_encoding\fP(const char *\fIsettings\fP, size_t \fIlen\fP, char *\fIpad_out\fP,
                                    int *\fIstrict_pad_out\fP, int \fIdecoding\fP, LIBRECRYPT_CONTEXT *\fIctx\fP);
.fi
.PP
Link with
.IR -lrecrypt .

.SH DESCRIPTION
The
.BR librecrypt_get_encoding ()
function returns the ASCII encoding used for
the last algorithm in the algorithm chain
specified by
.IR settings .
.PP
If
.I decoding
is zero, the returned pointer is suitable for
use as the
.I lut
parameter to
.BR librecrypt_encode (3)
and points to an encoding alphabet consisting
of 64 characters repeated 4 times.
.PP
If
.I decoding
is non-zero, the returned pointer is suitable
for use as the
.I lut
parameter to
.BR librecrypt_decode (3)
and points to a reverse lookup table mapping
any valid character (except the padding
character) to its value in the encoding
alphabet and any other character to
.BR 0xFFu .
.PP
The
.I ctx
parameter is used for providing library
configurations, see
.BR librecrypt_create_context (3)
for more information; used
.I NULL
for default configurations.
.PP
On successful completion,
.IR *pad_out
is set to the padding character, or to the
null byte if there is no padding.
.IR *strict_pad_out
is set to 1 if padding is mandatory,
0 otherwise.
.IR *strict_pad_out
is set arbitrarily to 0 or 1 if
.IR *pad_out
is set to the null byte.
.PP
.I pad_out
and
.I strict_pad_out
must not be
.IR NULL .

.SH RETURN VALUES
The
.BR librecrypt_get_encoding ()
function returns a pointer to the encoding
data, or
.IR NULL
on failure. On failure,
.IR errno
is set to describe the error.

.SH ERRORS
The
.BR librecrypt_get_encoding ()
function will fail if:
.TP
.B ENOSYS
The last algorithm in
.I settings
is not recognised or was disabled at compile-time.

.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
.PP
.TS
allbox;
lb lb lb
l l l.
Interface	Attribute	Value
T{
.BR librecrypt_get_encoding ()
T}	Thread safety	MT-Safe
T{
.BR librecrypt_get_encoding ()
T}	Async-signal safety	AS-Safe
.TE
.sp

.SH HISTORY
The
.BR librecrypt_get_encoding ()
function was introduced in version 1.0 of
.BR librecrypt .

Since version 1.1 of the
.BR librecrypt_get_encoding ()
function, the
.I ctx
parameter (previously called
.IR reserved )
has the type
.B LIBRECRYPT_CONTEXT *
(previously
.BR "void *" ),
and setting it to
.RI non- NULL
no longer causes failure with
.I errno
set to
.IR EINVAL .

.SH SEE ALSO
.BR librecrypt (7),
.BR librecrypt_encode (3),
.BR librecrypt_decode (3)