Home | History | Annotate | Line # | Download | only in dist
ssh-sk.h revision 1.1
      1  1.1  christos /* $OpenBSD: ssh-sk.h,v 1.10 2020/01/10 23:43:26 djm Exp $ */
      2  1.1  christos /*
      3  1.1  christos  * Copyright (c) 2019 Google LLC
      4  1.1  christos  *
      5  1.1  christos  * Permission to use, copy, modify, and distribute this software for any
      6  1.1  christos  * purpose with or without fee is hereby granted, provided that the above
      7  1.1  christos  * copyright notice and this permission notice appear in all copies.
      8  1.1  christos  *
      9  1.1  christos  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     10  1.1  christos  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     11  1.1  christos  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     12  1.1  christos  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     13  1.1  christos  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     14  1.1  christos  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     15  1.1  christos  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     16  1.1  christos  */
     17  1.1  christos 
     18  1.1  christos #ifndef _SSH_SK_H
     19  1.1  christos #define _SSH_SK_H 1
     20  1.1  christos 
     21  1.1  christos struct sshbuf;
     22  1.1  christos struct sshkey;
     23  1.1  christos struct sk_option;
     24  1.1  christos 
     25  1.1  christos /* Version of protocol expected from ssh-sk-helper */
     26  1.1  christos #define SSH_SK_HELPER_VERSION		5
     27  1.1  christos 
     28  1.1  christos /* ssh-sk-helper messages */
     29  1.1  christos #define SSH_SK_HELPER_ERROR		0	/* Only valid H->C */
     30  1.1  christos #define SSH_SK_HELPER_SIGN		1
     31  1.1  christos #define SSH_SK_HELPER_ENROLL		2
     32  1.1  christos #define SSH_SK_HELPER_LOAD_RESIDENT	3
     33  1.1  christos 
     34  1.1  christos /*
     35  1.1  christos  * Enroll (generate) a new security-key hosted private key of given type
     36  1.1  christos  * via the specified provider middleware.
     37  1.1  christos  * If challenge_buf is NULL then a random 256 bit challenge will be used.
     38  1.1  christos  *
     39  1.1  christos  * Returns 0 on success or a ssherr.h error code on failure.
     40  1.1  christos  *
     41  1.1  christos  * If successful and the attest_data buffer is not NULL then attestation
     42  1.1  christos  * information is placed there.
     43  1.1  christos  */
     44  1.1  christos int sshsk_enroll(int type, const char *provider_path, const char *device,
     45  1.1  christos     const char *application, const char *userid, uint8_t flags,
     46  1.1  christos     const char *pin, struct sshbuf *challenge_buf,
     47  1.1  christos     struct sshkey **keyp, struct sshbuf *attest);
     48  1.1  christos 
     49  1.1  christos /*
     50  1.1  christos  * Calculate an ECDSA_SK or ED25519_SK signature using the specified key
     51  1.1  christos  * and provider middleware.
     52  1.1  christos  *
     53  1.1  christos  * Returns 0 on success or a ssherr.h error code on failure.
     54  1.1  christos  */
     55  1.1  christos int sshsk_sign(const char *provider_path, struct sshkey *key,
     56  1.1  christos     u_char **sigp, size_t *lenp, const u_char *data, size_t datalen,
     57  1.1  christos     u_int compat, const char *pin);
     58  1.1  christos 
     59  1.1  christos /*
     60  1.1  christos  * Enumerates and loads all SSH-compatible resident keys from a security
     61  1.1  christos  * key.
     62  1.1  christos  *
     63  1.1  christos  * Returns 0 on success or a ssherr.h error code on failure.
     64  1.1  christos  */
     65  1.1  christos int sshsk_load_resident(const char *provider_path, const char *device,
     66  1.1  christos     const char *pin, struct sshkey ***keysp, size_t *nkeysp);
     67  1.1  christos 
     68  1.1  christos #endif /* _SSH_SK_H */
     69  1.1  christos 
     70