Loading...
Searching...
No Matches
sk_common.h
/*
* This file is part of the SSH Library
*
* Copyright (c) 2025 Praneeth Sarode <praneethsarode@gmail.com>
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 2.1 of the License.
*
* The SSH Library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef SK_COMMON_H
#define SK_COMMON_H
#include "libssh/callbacks.h"
#include "libssh/sk_api.h"
#include <stdbool.h>
#define SK_MAX_USER_ID_LEN 64
#define SK_NOT_SUPPORTED_MSG \
"Security Key functionality is not supported in this build of libssh. " \
"Please enable support by building using the WITH_FIDO2 build option."
const char *ssh_sk_err_to_string(int sk_err);
void sk_enroll_response_burn(struct sk_enroll_response *enroll_response);
void sk_enroll_response_free(struct sk_enroll_response *enroll_response);
void sk_sign_response_free(struct sk_sign_response *sign_response);
void sk_resident_key_free(struct sk_resident_key *resident_key);
void sk_options_free(struct sk_option **options);
int sk_options_validate_get(const struct sk_option **options,
const char **keys,
char ***values);
struct sk_option **sk_options_dup(const struct sk_option **options);
bool sk_callbacks_check_compatibility(
const struct ssh_sk_callbacks_struct *callbacks);
/* Convenience macros for secure freeing with NULL checks and pointer reset */
#define SK_ENROLL_RESPONSE_FREE(x) \
do { \
if ((x) != NULL) { \
sk_enroll_response_free(x); \
x = NULL; \
} \
} while (0)
#define SK_SIGN_RESPONSE_FREE(x) \
do { \
if ((x) != NULL) { \
sk_sign_response_free(x); \
x = NULL; \
} \
} while (0)
#define SK_RESIDENT_KEY_FREE(x) \
do { \
if ((x) != NULL) { \
sk_resident_key_free(x); \
x = NULL; \
} \
} while (0)
#define SK_OPTIONS_FREE(x) \
do { \
if ((x) != NULL) { \
sk_options_free(x); \
x = NULL; \
} \
} while (0)
#endif /* SK_COMMON_H */
sk_enroll_response
Response structure for FIDO2/U2F key enrollment operations.
Definition sk_api.h:84
sk_option
Configuration option structure for FIDO2/U2F operations.
Definition sk_api.h:263
sk_resident_key
Structure representing a resident/discoverable credential.
Definition sk_api.h:204
sk_sign_response
Response structure for FIDO2/U2F key signing operations.
Definition sk_api.h:167
ssh_sk_callbacks_struct
FIDO2/U2F security key callbacks structure.
Definition callbacks.h:1312