Loading...
Searching...
No Matches
sk_api.h
/*
* Copyright (c) 2019 Google LLC
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* This file is a copy of the OpenSSH project's sk-api.h file pulled from
* https://github.com/openssh/openssh-portable/commit/a9cbe10da2be5be76755af0cea029db0f9c1f263
* with only the flags, algorithms, error codes, and struct definitions. The
* function declarations and other OpenSSH-specific code have been removed.
*/
#ifndef SK_API_H
#define SK_API_H 1
#include <stddef.h>
#include <stdint.h>
/* FIDO2/U2F Operation Flags */
#ifndef SSH_SK_USER_PRESENCE_REQD
#define SSH_SK_USER_PRESENCE_REQD 0x01
#endif
#ifndef SSH_SK_USER_VERIFICATION_REQD
#define SSH_SK_USER_VERIFICATION_REQD 0x04
#endif
#ifndef SSH_SK_FORCE_OPERATION
#define SSH_SK_FORCE_OPERATION 0x10
#endif
#ifndef SSH_SK_RESIDENT_KEY
#define SSH_SK_RESIDENT_KEY 0x20
#endif
/* Algorithms */
#define SSH_SK_ECDSA 0x00
#define SSH_SK_ED25519 0x01
/* Error codes */
#define SSH_SK_ERR_GENERAL -1
#define SSH_SK_ERR_UNSUPPORTED -2
#define SSH_SK_ERR_PIN_REQUIRED -3
#define SSH_SK_ERR_DEVICE_NOT_FOUND -4
#define SSH_SK_ERR_CREDENTIAL_EXISTS -5
struct sk_enroll_response {
uint8_t flags;
uint8_t *public_key;
size_t public_key_len;
uint8_t *key_handle;
size_t key_handle_len;
uint8_t *signature;
size_t signature_len;
uint8_t *attestation_cert;
size_t attestation_cert_len;
uint8_t *authdata;
size_t authdata_len;
};
struct sk_sign_response {
uint8_t flags;
uint32_t counter;
uint8_t *sig_r;
size_t sig_r_len;
uint8_t *sig_s;
size_t sig_s_len;
};
struct sk_resident_key {
uint32_t alg;
size_t slot;
char *application;
struct sk_enroll_response key;
uint8_t flags;
uint8_t *user_id;
size_t user_id_len;
};
struct sk_option {
char *name;
char *value;
uint8_t required;
};
#define SSH_SK_VERSION_MAJOR 0x000a0000
#define SSH_SK_VERSION_MAJOR_MASK 0xffff0000
#endif /* SK_API_H */
sk_enroll_response
Response structure for FIDO2/U2F key enrollment operations.
Definition sk_api.h:84
sk_enroll_response::attestation_cert
uint8_t * attestation_cert
X.509 attestation certificate.
Definition sk_api.h:141
sk_enroll_response::public_key_len
size_t public_key_len
Length of public_key buffer in bytes.
Definition sk_api.h:105
sk_enroll_response::attestation_cert_len
size_t attestation_cert_len
Length of attestation_cert buffer in bytes.
Definition sk_api.h:144
sk_enroll_response::key_handle
uint8_t * key_handle
Opaque credential handle/ID used to identify this key.
Definition sk_api.h:113
sk_enroll_response::public_key
uint8_t * public_key
Public key data in standard format.
Definition sk_api.h:99
sk_enroll_response::flags
uint8_t flags
FIDO2/U2F authenticator flags from the enrollment operation.
Definition sk_api.h:91
sk_enroll_response::signature
uint8_t * signature
Enrollment signature over the enrollment data.
Definition sk_api.h:127
sk_enroll_response::authdata_len
size_t authdata_len
Length of authdata buffer in bytes.
Definition sk_api.h:158
sk_enroll_response::signature_len
size_t signature_len
Length of signature buffer in bytes.
Definition sk_api.h:133
sk_enroll_response::authdata
uint8_t * authdata
FIDO2/U2F authenticator data from enrollment.
Definition sk_api.h:152
sk_enroll_response::key_handle_len
size_t key_handle_len
Length of key_handle buffer in bytes.
Definition sk_api.h:119
sk_option
Configuration option structure for FIDO2/U2F operations.
Definition sk_api.h:263
sk_option::value
char * value
Option value as bytes.
Definition sk_api.h:268
sk_option::required
uint8_t required
Indicates if this option is required for the operation.
Definition sk_api.h:276
sk_option::name
char * name
Option name/key identifier.
Definition sk_api.h:265
sk_resident_key
Structure representing a resident/discoverable credential.
Definition sk_api.h:204
sk_resident_key::alg
uint32_t alg
Cryptographic algorithm identifier for this key.
Definition sk_api.h:210
sk_resident_key::flags
uint8_t flags
Flags associated with this resident key.
Definition sk_api.h:241
sk_resident_key::user_id_len
size_t user_id_len
Length of user_id buffer in bytes.
Definition sk_api.h:254
sk_resident_key::application
char * application
Relying Party (application) identifier string.
Definition sk_api.h:226
sk_resident_key::slot
size_t slot
Slot/index number of this key on the authenticator.
Definition sk_api.h:218
sk_resident_key::key
struct sk_enroll_response key
Embedded enrollment response containing key material.
Definition sk_api.h:233
sk_resident_key::user_id
uint8_t * user_id
User identifier associated with this resident key.
Definition sk_api.h:248
sk_sign_response
Response structure for FIDO2/U2F key signing operations.
Definition sk_api.h:167
sk_sign_response::sig_r_len
size_t sig_r_len
Length of sig_r buffer in bytes.
Definition sk_api.h:188
sk_sign_response::flags
uint8_t flags
FIDO2/U2F authenticator flags from the signing operation.
Definition sk_api.h:174
sk_sign_response::counter
uint32_t counter
Authenticator signature counter value.
Definition sk_api.h:182
sk_sign_response::sig_s_len
size_t sig_s_len
Length of sig_s buffer in bytes.
Definition sk_api.h:194
sk_sign_response::sig_r
uint8_t * sig_r
R component of ECDSA signature or Ed25519 signature.
Definition sk_api.h:185
sk_sign_response::sig_s
uint8_t * sig_s
S component of ECDSA signature.
Definition sk_api.h:191