blob: 0f566bbc3859d1e388876f46b8dd73aabb78cdee [file] [log] [blame]
djm@openbsd.org57b181e2020-01-10 23:43:26 +00001/* $OpenBSD: ssh-sk.h,v 1.10 2020/01/10 23:43:26 djm Exp $ */
djm@openbsd.orged3467c2019-10-31 21:16:20 +00002/*
3 * Copyright (c) 2019 Google LLC
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#ifndef _SSH_SK_H
19#define _SSH_SK_H 1
20
21struct sshbuf;
22struct sshkey;
djm@openbsd.orgc312ca02020-01-06 02:00:46 +000023struct sk_option;
djm@openbsd.orged3467c2019-10-31 21:16:20 +000024
djm@openbsd.orgc54cd182019-12-30 09:23:28 +000025/* Version of protocol expected from ssh-sk-helper */
djm@openbsd.org57b181e2020-01-10 23:43:26 +000026#define SSH_SK_HELPER_VERSION 5
djm@openbsd.orgc54cd182019-12-30 09:23:28 +000027
28/* ssh-sk-helper messages */
29#define SSH_SK_HELPER_ERROR 0 /* Only valid H->C */
30#define SSH_SK_HELPER_SIGN 1
31#define SSH_SK_HELPER_ENROLL 2
32#define SSH_SK_HELPER_LOAD_RESIDENT 3
33
djm@openbsd.orged3467c2019-10-31 21:16:20 +000034/*
markus@openbsd.org7c32b512019-11-12 19:31:45 +000035 * Enroll (generate) a new security-key hosted private key of given type
36 * via the specified provider middleware.
djm@openbsd.orged3467c2019-10-31 21:16:20 +000037 * If challenge_buf is NULL then a random 256 bit challenge will be used.
38 *
39 * Returns 0 on success or a ssherr.h error code on failure.
40 *
41 * If successful and the attest_data buffer is not NULL then attestation
42 * information is placed there.
43 */
djm@openbsd.orgc312ca02020-01-06 02:00:46 +000044int sshsk_enroll(int type, const char *provider_path, const char *device,
45 const char *application, const char *userid, uint8_t flags,
46 const char *pin, struct sshbuf *challenge_buf,
djm@openbsd.orgc54cd182019-12-30 09:23:28 +000047 struct sshkey **keyp, struct sshbuf *attest);
djm@openbsd.orged3467c2019-10-31 21:16:20 +000048
49/*
markus@openbsd.orgfe05a362019-11-12 19:31:18 +000050 * Calculate an ECDSA_SK or ED25519_SK signature using the specified key
markus@openbsd.orge03a29e2019-11-12 19:30:50 +000051 * and provider middleware.
djm@openbsd.orged3467c2019-10-31 21:16:20 +000052 *
53 * Returns 0 on success or a ssherr.h error code on failure.
54 */
djm@openbsd.orgb52ec0b2019-12-13 19:09:10 +000055int sshsk_sign(const char *provider_path, struct sshkey *key,
djm@openbsd.orged3467c2019-10-31 21:16:20 +000056 u_char **sigp, size_t *lenp, const u_char *data, size_t datalen,
djm@openbsd.orgc54cd182019-12-30 09:23:28 +000057 u_int compat, const char *pin);
djm@openbsd.orged3467c2019-10-31 21:16:20 +000058
djm@openbsd.org14cea362019-12-30 09:21:16 +000059/*
60 * Enumerates and loads all SSH-compatible resident keys from a security
61 * key.
62 *
63 * Returns 0 on success or a ssherr.h error code on failure.
64 */
djm@openbsd.orgc312ca02020-01-06 02:00:46 +000065int sshsk_load_resident(const char *provider_path, const char *device,
66 const char *pin, struct sshkey ***keysp, size_t *nkeysp);
djm@openbsd.org14cea362019-12-30 09:21:16 +000067
djm@openbsd.orged3467c2019-10-31 21:16:20 +000068#endif /* _SSH_SK_H */
69