1*069ac184SEd Maste /* $OpenBSD: authfd.h,v 1.52 2023/12/18 14:46:56 djm Exp $ */ 2ae1f160dSDag-Erling Smørgrav 3511b41d2SMark Murray /* 4511b41d2SMark Murray * Author: Tatu Ylonen <ylo@cs.hut.fi> 5511b41d2SMark Murray * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 6511b41d2SMark Murray * All rights reserved 7511b41d2SMark Murray * Functions to interface with the SSH_AUTHENTICATION_FD socket. 8511b41d2SMark Murray * 9b66f2d16SKris Kennaway * As far as I am concerned, the code I have written for this software 10b66f2d16SKris Kennaway * can be used freely for any purpose. Any derived versions of this 11b66f2d16SKris Kennaway * software must be clearly marked as such, and if the derived work is 12b66f2d16SKris Kennaway * incompatible with the protocol description in the RFC file, it must be 13b66f2d16SKris Kennaway * called by a name other than "ssh" or "Secure Shell". 14511b41d2SMark Murray */ 15511b41d2SMark Murray 16511b41d2SMark Murray #ifndef AUTHFD_H 17511b41d2SMark Murray #define AUTHFD_H 18511b41d2SMark Murray 191323ec57SEd Maste struct sshbuf; 201323ec57SEd Maste struct sshkey; 211323ec57SEd Maste 22bc5531deSDag-Erling Smørgrav /* List of identities returned by ssh_fetch_identitylist() */ 23bc5531deSDag-Erling Smørgrav struct ssh_identitylist { 24bc5531deSDag-Erling Smørgrav size_t nkeys; 25bc5531deSDag-Erling Smørgrav struct sshkey **keys; 26bc5531deSDag-Erling Smørgrav char **comments; 27bc5531deSDag-Erling Smørgrav }; 28bc5531deSDag-Erling Smørgrav 291323ec57SEd Maste /* Key destination restrictions */ 301323ec57SEd Maste struct dest_constraint_hop { 311323ec57SEd Maste char *user; /* wildcards allowed */ 321323ec57SEd Maste char *hostname; /* used to matching cert principals and for display */ 331323ec57SEd Maste int is_ca; 341323ec57SEd Maste u_int nkeys; /* number of entries in *both* 'keys' and 'key_is_ca' */ 351323ec57SEd Maste struct sshkey **keys; 361323ec57SEd Maste int *key_is_ca; 371323ec57SEd Maste }; 381323ec57SEd Maste struct dest_constraint { 391323ec57SEd Maste struct dest_constraint_hop from; 401323ec57SEd Maste struct dest_constraint_hop to; 411323ec57SEd Maste }; 421323ec57SEd Maste 43bc5531deSDag-Erling Smørgrav int ssh_get_authentication_socket(int *fdp); 4419261079SEd Maste int ssh_get_authentication_socket_path(const char *authsocket, int *fdp); 45bc5531deSDag-Erling Smørgrav void ssh_close_authentication_socket(int sock); 46bc5531deSDag-Erling Smørgrav 47bc5531deSDag-Erling Smørgrav int ssh_lock_agent(int sock, int lock, const char *password); 484f52dfbbSDag-Erling Smørgrav int ssh_fetch_identitylist(int sock, struct ssh_identitylist **idlp); 49bc5531deSDag-Erling Smørgrav void ssh_free_identitylist(struct ssh_identitylist *idl); 5019261079SEd Maste int ssh_add_identity_constrained(int sock, struct sshkey *key, 5119261079SEd Maste const char *comment, u_int life, u_int confirm, u_int maxsign, 521323ec57SEd Maste const char *provider, struct dest_constraint **dest_constraints, 531323ec57SEd Maste size_t ndest_constraints); 5419261079SEd Maste int ssh_agent_has_key(int sock, const struct sshkey *key); 5519261079SEd Maste int ssh_remove_identity(int sock, const struct sshkey *key); 56bc5531deSDag-Erling Smørgrav int ssh_update_card(int sock, int add, const char *reader_id, 571323ec57SEd Maste const char *pin, u_int life, u_int confirm, 581323ec57SEd Maste struct dest_constraint **dest_constraints, 59*069ac184SEd Maste size_t ndest_constraints, 60*069ac184SEd Maste int cert_only, struct sshkey **certs, size_t ncerts); 61bc5531deSDag-Erling Smørgrav int ssh_remove_all_identities(int sock, int version); 62bc5531deSDag-Erling Smørgrav 634f52dfbbSDag-Erling Smørgrav int ssh_agent_sign(int sock, const struct sshkey *key, 64bc5531deSDag-Erling Smørgrav u_char **sigp, size_t *lenp, 65acc1a9efSDag-Erling Smørgrav const u_char *data, size_t datalen, const char *alg, u_int compat); 66bc5531deSDag-Erling Smørgrav 671323ec57SEd Maste int ssh_agent_bind_hostkey(int sock, const struct sshkey *key, 681323ec57SEd Maste const struct sshbuf *session_id, const struct sshbuf *signature, 691323ec57SEd Maste int forwarding); 701323ec57SEd Maste 71511b41d2SMark Murray /* Messages for the authentication agent connection. */ 72511b41d2SMark Murray #define SSH_AGENTC_REQUEST_RSA_IDENTITIES 1 73511b41d2SMark Murray #define SSH_AGENT_RSA_IDENTITIES_ANSWER 2 74511b41d2SMark Murray #define SSH_AGENTC_RSA_CHALLENGE 3 75511b41d2SMark Murray #define SSH_AGENT_RSA_RESPONSE 4 76511b41d2SMark Murray #define SSH_AGENT_FAILURE 5 77511b41d2SMark Murray #define SSH_AGENT_SUCCESS 6 78511b41d2SMark Murray #define SSH_AGENTC_ADD_RSA_IDENTITY 7 79511b41d2SMark Murray #define SSH_AGENTC_REMOVE_RSA_IDENTITY 8 80511b41d2SMark Murray #define SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES 9 81511b41d2SMark Murray 825b9b2fafSBrian Feldman /* private OpenSSH extensions for SSH2 */ 83b66f2d16SKris Kennaway #define SSH2_AGENTC_REQUEST_IDENTITIES 11 84b66f2d16SKris Kennaway #define SSH2_AGENT_IDENTITIES_ANSWER 12 85b66f2d16SKris Kennaway #define SSH2_AGENTC_SIGN_REQUEST 13 86b66f2d16SKris Kennaway #define SSH2_AGENT_SIGN_RESPONSE 14 87b66f2d16SKris Kennaway #define SSH2_AGENTC_ADD_IDENTITY 17 88b66f2d16SKris Kennaway #define SSH2_AGENTC_REMOVE_IDENTITY 18 89b66f2d16SKris Kennaway #define SSH2_AGENTC_REMOVE_ALL_IDENTITIES 19 90b66f2d16SKris Kennaway 91ae1f160dSDag-Erling Smørgrav /* smartcard */ 92ae1f160dSDag-Erling Smørgrav #define SSH_AGENTC_ADD_SMARTCARD_KEY 20 93ae1f160dSDag-Erling Smørgrav #define SSH_AGENTC_REMOVE_SMARTCARD_KEY 21 94ae1f160dSDag-Erling Smørgrav 95545d5ecaSDag-Erling Smørgrav /* lock/unlock the agent */ 96545d5ecaSDag-Erling Smørgrav #define SSH_AGENTC_LOCK 22 97545d5ecaSDag-Erling Smørgrav #define SSH_AGENTC_UNLOCK 23 98545d5ecaSDag-Erling Smørgrav 99545d5ecaSDag-Erling Smørgrav /* add key with constraints */ 100545d5ecaSDag-Erling Smørgrav #define SSH_AGENTC_ADD_RSA_ID_CONSTRAINED 24 101545d5ecaSDag-Erling Smørgrav #define SSH2_AGENTC_ADD_ID_CONSTRAINED 25 102d95e11bfSDag-Erling Smørgrav #define SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED 26 103545d5ecaSDag-Erling Smørgrav 1041323ec57SEd Maste /* generic extension mechanism */ 1051323ec57SEd Maste #define SSH_AGENTC_EXTENSION 27 1061323ec57SEd Maste 107545d5ecaSDag-Erling Smørgrav #define SSH_AGENT_CONSTRAIN_LIFETIME 1 108d0c8c0bcSDag-Erling Smørgrav #define SSH_AGENT_CONSTRAIN_CONFIRM 2 10947dd1d1bSDag-Erling Smørgrav #define SSH_AGENT_CONSTRAIN_MAXSIGN 3 11019261079SEd Maste #define SSH_AGENT_CONSTRAIN_EXTENSION 255 111545d5ecaSDag-Erling Smørgrav 112ae1f160dSDag-Erling Smørgrav /* extended failure messages */ 113ae1f160dSDag-Erling Smørgrav #define SSH2_AGENT_FAILURE 30 114ae1f160dSDag-Erling Smørgrav 1155b9b2fafSBrian Feldman /* additional error code for ssh.com's ssh-agent2 */ 1165b9b2fafSBrian Feldman #define SSH_COM_AGENT2_FAILURE 102 1175b9b2fafSBrian Feldman 1185b9b2fafSBrian Feldman #define SSH_AGENT_OLD_SIGNATURE 0x01 119acc1a9efSDag-Erling Smørgrav #define SSH_AGENT_RSA_SHA2_256 0x02 120acc1a9efSDag-Erling Smørgrav #define SSH_AGENT_RSA_SHA2_512 0x04 1215b9b2fafSBrian Feldman 122511b41d2SMark Murray #endif /* AUTHFD_H */ 123