libssh 0.11.0
The SSH library
Loading...
Searching...
No Matches
sk_common.h
1/*
2 * This file is part of the SSH Library
3 *
4 * Copyright (c) 2025 Praneeth Sarode <praneethsarode@gmail.com>
5 *
6 * The SSH Library is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, version 2.1 of the License.
9 *
10 * The SSH Library is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13 * License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with the SSH Library; see the file COPYING. If not, write to
17 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA.
19 */
20
21#ifndef SK_COMMON_H
22#define SK_COMMON_H
23
24#include "libssh/callbacks.h"
25#include "libssh/sk_api.h"
26
27#include <stdbool.h>
28
29#define SK_MAX_USER_ID_LEN 64
30
31#define SK_NOT_SUPPORTED_MSG \
32 "Security Key functionality is not supported in this build of libssh. " \
33 "Please enable support by building using the WITH_FIDO2 build option."
34
48const char *ssh_sk_err_to_string(int sk_err);
49
64void sk_enroll_response_burn(struct sk_enroll_response *enroll_response);
65
79void sk_enroll_response_free(struct sk_enroll_response *enroll_response);
80
94void sk_sign_response_free(struct sk_sign_response *sign_response);
95
109void sk_resident_key_free(struct sk_resident_key *resident_key);
110
123void sk_options_free(struct sk_option **options);
124
146int sk_options_validate_get(const struct sk_option **options,
147 const char **keys,
148 char ***values);
149
164struct sk_option **sk_options_dup(const struct sk_option **options);
165
177bool sk_callbacks_check_compatibility(
178 const struct ssh_sk_callbacks_struct *callbacks);
179
180/* Convenience macros for secure freeing with NULL checks and pointer reset */
181#define SK_ENROLL_RESPONSE_FREE(x) \
182 do { \
183 if ((x) != NULL) { \
184 sk_enroll_response_free(x); \
185 x = NULL; \
186 } \
187 } while (0)
188
189#define SK_SIGN_RESPONSE_FREE(x) \
190 do { \
191 if ((x) != NULL) { \
192 sk_sign_response_free(x); \
193 x = NULL; \
194 } \
195 } while (0)
196
197#define SK_RESIDENT_KEY_FREE(x) \
198 do { \
199 if ((x) != NULL) { \
200 sk_resident_key_free(x); \
201 x = NULL; \
202 } \
203 } while (0)
204
205#define SK_OPTIONS_FREE(x) \
206 do { \
207 if ((x) != NULL) { \
208 sk_options_free(x); \
209 x = NULL; \
210 } \
211 } while (0)
212
213#endif /* SK_COMMON_H */
Response structure for FIDO2/U2F key enrollment operations.
Definition sk_api.h:84
Configuration option structure for FIDO2/U2F operations.
Definition sk_api.h:263
Structure representing a resident/discoverable credential.
Definition sk_api.h:204
Response structure for FIDO2/U2F key signing operations.
Definition sk_api.h:167
FIDO2/U2F security key callbacks structure.
Definition callbacks.h:1286