xref: /freebsd/crypto/openssh/ssh-pkcs11.h (revision 2574974648c68c738aec3ff96644d888d7913a37)
1 /* $OpenBSD: ssh-pkcs11.h,v 1.11 2026/03/03 09:57:25 dtucker Exp $ */
2 /*
3  * Copyright (c) 2010 Markus Friedl.  All rights reserved.
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 /* API for ssh-pkcs11.c and ssh-pkcs11-client.c */
19 
20 /* Errors for pkcs11_add_provider() */
21 #define	SSH_PKCS11_ERR_GENERIC			1
22 #define	SSH_PKCS11_ERR_LOGIN_FAIL		2
23 #define	SSH_PKCS11_ERR_NO_SLOTS			3
24 #define	SSH_PKCS11_ERR_PIN_REQUIRED		4
25 #define	SSH_PKCS11_ERR_PIN_LOCKED		5
26 
27 struct sshkey;
28 
29 int	pkcs11_init(int);
30 void	pkcs11_terminate(void);
31 int	pkcs11_add_provider(char *, char *, struct sshkey ***, char ***);
32 int	pkcs11_del_provider(char *);
33 int	pkcs11_sign(struct sshkey *, u_char **, size_t *,
34 	    const u_char *, size_t, const char *, const char *,
35 	    const char *, u_int);
36 void	pkcs11_key_free(struct sshkey *);
37 
38 #ifdef WITH_PKCS11_KEYGEN
39 struct sshkey *
40 	pkcs11_gakp(char *, char *, unsigned int, char *, unsigned int,
41 	    unsigned int, unsigned char, uint32_t *);
42 struct sshkey *
43 	pkcs11_destroy_keypair(char *, char *, unsigned long, unsigned char,
44 	    uint32_t *);
45 #endif
46 
47 /* Only available in ssh-pkcs11-client.c */
48 int pkcs11_make_cert(const struct sshkey *,
49     const struct sshkey *, struct sshkey **);
50