blob: 5867758ef5fb10d42639a3db7cc12ce4db68d93f (
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
|
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifndef TEST
const void *
librecrypt_get_encoding(const char *settings, size_t len, char *pad_out, int *strict_pad_out, int decoding)
{
size_t i, start = 0u;
const struct algorithm *algo;
/* Find last algorithm in the chain */
for (i = 0u; i < len; i++)
if (settings[i] == LIBRECRYPT_ALGORITHM_LINK_DELIMITER)
start = i + 1u;
settings = &settings[start];
len -= start;
/* Identify the algorithm */
algo = librecrypt_find_first_algorithm_(settings, len);
if (!algo) {
errno = ENOSYS;
return NULL;
}
/* Return the algorithms salt/hash encoding format */
*pad_out = algo->pad;
*strict_pad_out = algo->strict_pad;
if (decoding)
return algo->decoding_lut;
else
return algo->encoding_lut;
}
#else
int
main(void)
{
SET_UP_ALARM();
INIT_RESOURCE_TEST();
STOP_RESOURCE_TEST();
return 0;
}
#endif
/* TODO test */
|