1*84f89c72Schristos /* $NetBSD: authfd.h,v 1.16 2022/02/23 19:07:20 christos Exp $ */ 2*84f89c72Schristos /* $OpenBSD: authfd.h,v 1.51 2021/12/19 22:10:24 djm Exp $ */ 3ca32bd8dSchristos 4ca32bd8dSchristos /* 5ca32bd8dSchristos * Author: Tatu Ylonen <ylo@cs.hut.fi> 6ca32bd8dSchristos * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7ca32bd8dSchristos * All rights reserved 8ca32bd8dSchristos * Functions to interface with the SSH_AUTHENTICATION_FD socket. 9ca32bd8dSchristos * 10ca32bd8dSchristos * As far as I am concerned, the code I have written for this software 11ca32bd8dSchristos * can be used freely for any purpose. Any derived versions of this 12ca32bd8dSchristos * software must be clearly marked as such, and if the derived work is 13ca32bd8dSchristos * incompatible with the protocol description in the RFC file, it must be 14ca32bd8dSchristos * called by a name other than "ssh" or "Secure Shell". 15ca32bd8dSchristos */ 16ca32bd8dSchristos 17ca32bd8dSchristos #ifndef AUTHFD_H 18ca32bd8dSchristos #define AUTHFD_H 19ca32bd8dSchristos 20*84f89c72Schristos struct sshbuf; 21*84f89c72Schristos struct sshkey; 22*84f89c72Schristos 2351acf88eSchristos /* List of identities returned by ssh_fetch_identitylist() */ 2451acf88eSchristos struct ssh_identitylist { 2551acf88eSchristos size_t nkeys; 2651acf88eSchristos struct sshkey **keys; 2751acf88eSchristos char **comments; 2851acf88eSchristos }; 2951acf88eSchristos 30*84f89c72Schristos /* Key destination restrictions */ 31*84f89c72Schristos struct dest_constraint_hop { 32*84f89c72Schristos char *user; /* wildcards allowed */ 33*84f89c72Schristos char *hostname; /* used to matching cert principals and for display */ 34*84f89c72Schristos int is_ca; 35*84f89c72Schristos u_int nkeys; /* number of entries in *both* 'keys' and 'key_is_ca' */ 36*84f89c72Schristos struct sshkey **keys; 37*84f89c72Schristos int *key_is_ca; 38*84f89c72Schristos }; 39*84f89c72Schristos struct dest_constraint { 40*84f89c72Schristos struct dest_constraint_hop from; 41*84f89c72Schristos struct dest_constraint_hop to; 42*84f89c72Schristos }; 43*84f89c72Schristos 4451acf88eSchristos int ssh_get_authentication_socket(int *fdp); 45c8864e3fSchristos int ssh_get_authentication_socket_path(const char *authsocket, int *fdp); 4651acf88eSchristos void ssh_close_authentication_socket(int sock); 4751acf88eSchristos 4851acf88eSchristos int ssh_lock_agent(int sock, int lock, const char *password); 4945a1cd19Schristos int ssh_fetch_identitylist(int sock, struct ssh_identitylist **idlp); 5051acf88eSchristos void ssh_free_identitylist(struct ssh_identitylist *idl); 513f0e61bfSchristos int ssh_add_identity_constrained(int sock, struct sshkey *key, 52c8864e3fSchristos const char *comment, u_int life, u_int confirm, u_int maxsign, 53*84f89c72Schristos const char *provider, struct dest_constraint **dest_constraints, 54*84f89c72Schristos size_t ndest_constraints); 557d35d687Schristos int ssh_agent_has_key(int sock, const struct sshkey *key); 567d35d687Schristos int ssh_remove_identity(int sock, const struct sshkey *key); 5751acf88eSchristos int ssh_update_card(int sock, int add, const char *reader_id, 58*84f89c72Schristos const char *pin, u_int life, u_int confirm, 59*84f89c72Schristos struct dest_constraint **dest_constraints, 60*84f89c72Schristos size_t ndest_constraints); 6151acf88eSchristos int ssh_remove_all_identities(int sock, int version); 6251acf88eSchristos 6345a1cd19Schristos int ssh_agent_sign(int sock, const struct sshkey *key, 6451acf88eSchristos u_char **sigp, size_t *lenp, 65cf995d1fSchristos const u_char *data, size_t datalen, const char *alg, u_int compat); 6651acf88eSchristos 67*84f89c72Schristos int ssh_agent_bind_hostkey(int sock, const struct sshkey *key, 68*84f89c72Schristos const struct sshbuf *session_id, const struct sshbuf *signature, 69*84f89c72Schristos int forwarding); 70*84f89c72Schristos 71ca32bd8dSchristos /* Messages for the authentication agent connection. */ 72ca32bd8dSchristos #define SSH_AGENTC_REQUEST_RSA_IDENTITIES 1 73ca32bd8dSchristos #define SSH_AGENT_RSA_IDENTITIES_ANSWER 2 74ca32bd8dSchristos #define SSH_AGENTC_RSA_CHALLENGE 3 75ca32bd8dSchristos #define SSH_AGENT_RSA_RESPONSE 4 76ca32bd8dSchristos #define SSH_AGENT_FAILURE 5 77ca32bd8dSchristos #define SSH_AGENT_SUCCESS 6 78ca32bd8dSchristos #define SSH_AGENTC_ADD_RSA_IDENTITY 7 79ca32bd8dSchristos #define SSH_AGENTC_REMOVE_RSA_IDENTITY 8 80ca32bd8dSchristos #define SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES 9 81ca32bd8dSchristos 82ca32bd8dSchristos /* private OpenSSH extensions for SSH2 */ 83ca32bd8dSchristos #define SSH2_AGENTC_REQUEST_IDENTITIES 11 84ca32bd8dSchristos #define SSH2_AGENT_IDENTITIES_ANSWER 12 85ca32bd8dSchristos #define SSH2_AGENTC_SIGN_REQUEST 13 86ca32bd8dSchristos #define SSH2_AGENT_SIGN_RESPONSE 14 87ca32bd8dSchristos #define SSH2_AGENTC_ADD_IDENTITY 17 88ca32bd8dSchristos #define SSH2_AGENTC_REMOVE_IDENTITY 18 89ca32bd8dSchristos #define SSH2_AGENTC_REMOVE_ALL_IDENTITIES 19 90ca32bd8dSchristos 91ca32bd8dSchristos /* smartcard */ 92ca32bd8dSchristos #define SSH_AGENTC_ADD_SMARTCARD_KEY 20 93ca32bd8dSchristos #define SSH_AGENTC_REMOVE_SMARTCARD_KEY 21 94ca32bd8dSchristos 95ca32bd8dSchristos /* lock/unlock the agent */ 96ca32bd8dSchristos #define SSH_AGENTC_LOCK 22 97ca32bd8dSchristos #define SSH_AGENTC_UNLOCK 23 98ca32bd8dSchristos 99ca32bd8dSchristos /* add key with constraints */ 100ca32bd8dSchristos #define SSH_AGENTC_ADD_RSA_ID_CONSTRAINED 24 101ca32bd8dSchristos #define SSH2_AGENTC_ADD_ID_CONSTRAINED 25 102ca32bd8dSchristos #define SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED 26 103ca32bd8dSchristos 104*84f89c72Schristos /* generic extension mechanism */ 105*84f89c72Schristos #define SSH_AGENTC_EXTENSION 27 106*84f89c72Schristos 107ca32bd8dSchristos #define SSH_AGENT_CONSTRAIN_LIFETIME 1 108ca32bd8dSchristos #define SSH_AGENT_CONSTRAIN_CONFIRM 2 109e1a26310Schristos #define SSH_AGENT_CONSTRAIN_MAXSIGN 3 110c8864e3fSchristos #define SSH_AGENT_CONSTRAIN_EXTENSION 255 111ca32bd8dSchristos 112ca32bd8dSchristos /* extended failure messages */ 113ca32bd8dSchristos #define SSH2_AGENT_FAILURE 30 114ca32bd8dSchristos 115ca32bd8dSchristos /* additional error code for ssh.com's ssh-agent2 */ 116ca32bd8dSchristos #define SSH_COM_AGENT2_FAILURE 102 117ca32bd8dSchristos 118ca32bd8dSchristos #define SSH_AGENT_OLD_SIGNATURE 0x01 119cf995d1fSchristos #define SSH_AGENT_RSA_SHA2_256 0x02 120cf995d1fSchristos #define SSH_AGENT_RSA_SHA2_512 0x04 121ca32bd8dSchristos 122ca32bd8dSchristos #endif /* AUTHFD_H */ 123