blob: 320996608ec1356c00bf5bf769e753bda9f738db (
plain)
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
|
/*
SSSD
Helper child to commmunicate with passkey devices
Authors:
Iker Pedrosa <ipedrosa@redhat.com>
Copyright (C) 2022 Red Hat
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <fido.h>
#include <fido/param.h>
#include "util/debug.h"
#include "util/util.h"
#include "passkey_child.h"
int main(int argc, const char *argv[])
{
TALLOC_CTX *main_ctx = NULL;
struct passkey_data data;
int init_flags = 0;
errno_t ret = EOK;
main_ctx = talloc_new(NULL);
if (main_ctx == NULL) {
ERROR("talloc_new() failed.\n");
talloc_free(discard_const(debug_prg_name));
ret = ENOMEM;
goto done;
}
ret = parse_arguments(main_ctx, argc, argv, &data);
if (ret != EOK) {
ERROR("Error parsing argument(s).\n");
goto done;
}
DEBUG(SSSDBG_TRACE_FUNC, "passkey_child started.\n");
talloc_steal(main_ctx, debug_prg_name);
ret = check_arguments(&data);
if (ret != EOK) {
ERROR("Invalid argument(s).\n");
goto done;
}
init_flags = (int)data.debug_libfido2 | FIDO_DISABLE_U2F_FALLBACK;
fido_init(init_flags);
if (data.action == ACTION_REGISTER) {
ret = register_key(&data);
if (ret != EOK) {
ERROR("Error registering key.\n");
goto done;
}
} else if (data.action == ACTION_AUTHENTICATE) {
ret = authenticate(&data);
if (ret == EOK) {
PRINT("Authentication success.\n");
goto done;
} else {
ERROR("Authentication error.\n");
goto done;
}
} else if (data.action == ACTION_GET_ASSERT) {
ret = get_assert_data(&data);
if (ret != EOK) {
ERROR("Error getting assertion data.\n");
goto done;
}
} else if (data.action == ACTION_VERIFY_ASSERT) {
ret = verify_assert_data(&data);
if (ret == EOK) {
PRINT("Verification success.\n");
goto done;
} else {
ERROR("Verification error.\n");
goto done;
}
}
done:
talloc_free(main_ctx);
if (ret != EOK) {
return EXIT_FAILURE;
} else {
return EXIT_SUCCESS;
}
}
|