aboutsummaryrefslogtreecommitdiffstats
path: root/libhashsum_get_algorithm_from_string.3
blob: b01d1c7a7cd57b9fa238fde3346849e895c47b9e (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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
.TH LIBHASHSUM_GET_ALGORITHM_FROM_STRING 3 libhashsum
.SH NAME
libhashsum_get_algorithm_from_string - identify named hash function

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

\fBenum libhashsum_algorithm\fP { /* see the section DESCRIPTION for a listing of values */ };

int \fBlibhashsum_get_algorithm_from_string\fP(enum libhashsum_algorithm \fIalgorithm_out\fP, const char *\fIalgorithm\fP);
.fi
.PP
Link with
.IR -lhashsum .

.SH DESCRIPTION
The
.B libhashsum_get_algorithm_from_string
functions parses the string
.I algorithm
to identify the hash function it specifies,
and stores one of the following values in
.I *algorithm_out
to indicate the specified hash function:
.TP
.B LIBHASHSUM_MD2
MD2

.I algorithm
is
.RB \(dq MD2 \(dq.
.TP
.B LIBHASHSUM_MD4
MD4

.I algorithm
is
.RB \(dq MD4 \(dq.
.TP
.B LIBHASHSUM_MD5
MD5

.I algorithm
is
.RB \(dq MD5 \(dq.
.TP
.B LIBHASHSUM_RIPEMD_128
RIPEMD-128

.I algorithm
is
.RB \(dq RIPEMD-128 \(dq
or
.RB \(dq RMD-128 \(dq.
.TP
.B LIBHASHSUM_RIPEMD_160
RIPEMD-160

.I algorithm
is
.RB \(dq RIPEMD-160 \(dq
or
.RB \(dq RMD-160 \(dq.
.TP
.B LIBHASHSUM_RIPEMD_256
RIPEMD-256

.I algorithm
is
.RB \(dq RIPEMD-256 \(dq
or
.RB \(dq RMD-256 \(dq.
.TP
.B LIBHASHSUM_RIPEMD_512
RIPEMD-512

.I algorithm
is
.RB \(dq RIPEMD-512 \(dq
or
.RB \(dq RMD-512 \(dq.
.TP
.B LIBHASHSUM_SHA0
SHA-0

.I algorithm
is
.RB \(dq SHA-0 \(dq.
.TP
.B LIBHASHSUM_SHA1
SHA-1

.I algorithm
is
.RB \(dq SHA-1 \(dq.
.TP
.B LIBHASHSUM_SHA_224
SHA-224 (32-bit SHA-2 with 224 bit output)

.I algorithm
is
.RB \(dq SHA-224 \(dq
or
.RB \(dq SHA-2-224 \(dq.
.TP
.B LIBHASHSUM_SHA_256
SHA-256 (32-bit SHA-2 with 356 bit output)

.I algorithm
is
.RB \(dq SHA-256 \(dq
or
.RB \(dq SHA-2-256 \(dq.
.TP
.B LIBHASHSUM_SHA_384
SHA-384 (64-bit SHA-2 with 384 bit output)

.I algorithm
is
.RB \(dq SHA-384 \(dq
or
.RB \(dq SHA-2-384 \(dq.
.TP
.B LIBHASHSUM_SHA_512
SHA-512 (64-bit SHA-2 with 512 bit output)

.I algorithm
is
.RB \(dq SHA-512 \(dq
or
.RB \(dq SHA-2-512 \(dq.
.TP
.B LIBHASHSUM_SHA_512_224
SHA-512/224 (64-bit SHA-2 with 224 bit output)

.I algorithm
is
.RB \(dq SHA-512/224 \(dq
or
.RB \(dq SHA-2-512/224 \(dq,
where the slash
.RB (' / ')
may be replaces with a dash
.RB (' - ')
or underscore
.RB (' _ ').
.TP
.B LIBHASHSUM_SHA_512_256
SHA-512/256 (64-bit SHA-2 with 256 bit output)

.I algorithm
is
.RB \(dq SHA-512/256 \(dq
or
.RB \(dq SHA-2-512/256 \(dq,
where the slash
.RB (' / ')
may be replaces with a dash
.RB (' - ')
or underscore
.RB (' _ ').
.TP
.B LIBHASHSUM_KECCAK
Keccak

.I algorithm
is
.RB \(dq Keccak \(dq.
.TP
.B LIBHASHSUM_KECCAK_224
Keccak-224 (Keccak[n=224])

.I algorithm
is
.RB \(dq Keccak-224 \(dq.
.TP
.B LIBHASHSUM_KECCAK_256
Keccak-256 (Keccak[n=256])

.I algorithm
is
.RB \(dq Keccak-256 \(dq.
.TP
.B LIBHASHSUM_KECCAK_384
Keccak-384 (Keccak[n=384])

.I algorithm
is
.RB \(dq Keccak-384 \(dq.
.TP
.B LIBHASHSUM_KECCAK_512
Keccak-512 (Keccak[n=512])

.I algorithm
is
.RB \(dq Keccak-512 \(dq.
.TP
.B LIBHASHSUM_SHA3_224
SHA-3-224 (SHA-3 with 224 bit output)

.I algorithm
is
.RB \(dq SHA-3-224 \(dq.
.TP
.B LIBHASHSUM_SHA3_256
SHA-3-256 (SHA-3 with 256 bit output)

.I algorithm
is
.RB \(dq SHA-3-256 \(dq.
.TP
.B LIBHASHSUM_SHA3_384
SHA-3-384 (SHA-3 with 384 bit output)

.I algorithm
is
.RB \(dq SHA-3-384 \(dq.
.TP
.B LIBHASHSUM_SHA3_512
SHA-3-512 (SHA-3 with 512 bit output)

.I algorithm
is
.RB \(dq SHA-3-512 \(dq.
.TP
.B LIBHASHSUM_SHAKE128
SHAKE128 (SHAKE with 256 bit capacity, and default output of 128 bits)

.I algorithm
is
.RB \(dq SHAKE-128 \(dq.
.TP
.B LIBHASHSUM_SHAKE256
SHAKE128 (SHAKE with 512 bit capacity, and default output of 256 bits)

.I algorithm
is
.RB \(dq SHAKE-256 \(dq.
.TP
.B LIBHASHSUM_SHAKE512
SHAKE128 (SHAKE with 1024 bit capacity, and default output of 512 bits)

.I algorithm
is
.RB \(dq SHAKE-512 \(dq.
.TP
.B LIBHASHSUM_RAWSHAKE128
RawSHAKE128 (RawSHAKE with 256 bit capacity, and default output of 128 bits)

.I algorithm
is
.RB \(dq RawSHAKE-128 \(dq.
.TP
.B LIBHASHSUM_RAWSHAKE256
RawSHAKE128 (RawSHAKE with 512 bit capacity, and default output of 256 bits)

.I algorithm
is
.RB \(dq RawSHAKE-256 \(dq.
.TP
.B LIBHASHSUM_RAWSHAKE512
RawSHAKE128 (RawSHAKE with 1024 bit capacity, and default output of 512 bits)

.I algorithm
is
.RB \(dq RawSHAKE-512 \(dq.
.TP
.B LIBHASHSUM_BLAKE224
BLAKE224 (BLAKEs (BLAKE) with 224 bit output)

.I algorithm
is
.RB \(dq BLAKE-224 \(dq
or
.RB \(dq B224 \(dq.
.TP
.B LIBHASHSUM_BLAKE256
BLAKE256 (BLAKEs (BLAKE) with 256 bit output)

.I algorithm
is
.RB \(dq BLAKE-256 \(dq
or
.RB \(dq B256 \(dq.
.TP
.B LIBHASHSUM_BLAKE384
BLAKE384 (BLAKEb (BLAKE) with 384 bit output)

.I algorithm
is
.RB \(dq BLAKE-384 \(dq
or
.RB \(dq B384 \(dq.
.TP
.B LIBHASHSUM_BLAKE512
BLAKE512 (BLAKEb (BLAKE) with 512 bit output)

.I algorithm
is
.RB \(dq BLAKE-512 \(dq
or
.RB \(dq B512 \(dq.
.TP
.B LIBHASHSUM_BLAKE2S
BLAKE2s (BLAKE2)

.I algorithm
is
.RB \(dq BLAKE2s \(dq
or
.RB \(dq B2s \(dq.
.TP
BLAKE2b (BLAKE2)

.I algorithm
is
.RB \(dq BLAKE2b \(dq
or
.RB \(dq B2b \(dq.
.PP
The function is case-insensitive, and tolerates
skipping dashes
.RB (' - ')
that are not immediately after a digit. Additionally,
it will ignore the substring
.RB \(dq sum \(dq
if it is added to the end of the function name.

.PP
The function
.I does not
validate the parameters for the hash function
that may be places inside square brackets at
the end of
.IR algorithm ,
now will it check anything in
.I algorithm
after the opening bracket,
however it will not recognise the hash function
if brackets are used but the hash function does
not have any parameters.
.PP
.I algorithm_out
and
.I algorithm
must not be
.IR NULL .

.SH RETURN VALUE
The
.B libhashsum_get_algorithm_from_string
returns 1 if the hash function was identified.
Otherwise the function returns 0.
If 1 is returned, the
.I *algoritm_out
is set, otherwise
.I *algoritm_out
is unmodified.

.SH ERRORS
The
.B libhashsum_get_algorithm_from_string
function cannot fail.

.SH HISTORY
libhashsum 1.0.

.SH SEE ALSO
.BR libhashsum (7),
.BR libhashsum_init_hasher_from_string (3)