authfd.h revision 76259
157429Smarkm/* 257429Smarkm * Author: Tatu Ylonen <ylo@cs.hut.fi> 357429Smarkm * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 457429Smarkm * All rights reserved 557429Smarkm * Functions to interface with the SSH_AUTHENTICATION_FD socket. 660573Skris * 765668Skris * As far as I am concerned, the code I have written for this software 865668Skris * can be used freely for any purpose. Any derived versions of this 965668Skris * software must be clearly marked as such, and if the derived work is 1065668Skris * incompatible with the protocol description in the RFC file, it must be 1165668Skris * called by a name other than "ssh" or "Secure Shell". 1257429Smarkm */ 1357429Smarkm 1476259Sgreen/* RCSID("$OpenBSD: authfd.h,v 1.16 2000/12/20 19:37:21 markus Exp $"); */ 1557429Smarkm 1657429Smarkm#ifndef AUTHFD_H 1757429Smarkm#define AUTHFD_H 1857429Smarkm 1957429Smarkm#include "buffer.h" 2057429Smarkm 2157429Smarkm/* Messages for the authentication agent connection. */ 2257429Smarkm#define SSH_AGENTC_REQUEST_RSA_IDENTITIES 1 2357429Smarkm#define SSH_AGENT_RSA_IDENTITIES_ANSWER 2 2457429Smarkm#define SSH_AGENTC_RSA_CHALLENGE 3 2557429Smarkm#define SSH_AGENT_RSA_RESPONSE 4 2657429Smarkm#define SSH_AGENT_FAILURE 5 2757429Smarkm#define SSH_AGENT_SUCCESS 6 2857429Smarkm#define SSH_AGENTC_ADD_RSA_IDENTITY 7 2957429Smarkm#define SSH_AGENTC_REMOVE_RSA_IDENTITY 8 3057429Smarkm#define SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES 9 3157429Smarkm 3269587Sgreen/* private OpenSSH extensions for SSH2 */ 3365668Skris#define SSH2_AGENTC_REQUEST_IDENTITIES 11 3465668Skris#define SSH2_AGENT_IDENTITIES_ANSWER 12 3565668Skris#define SSH2_AGENTC_SIGN_REQUEST 13 3665668Skris#define SSH2_AGENT_SIGN_RESPONSE 14 3765668Skris#define SSH2_AGENTC_ADD_IDENTITY 17 3865668Skris#define SSH2_AGENTC_REMOVE_IDENTITY 18 3965668Skris#define SSH2_AGENTC_REMOVE_ALL_IDENTITIES 19 4065668Skris 4169587Sgreen/* additional error code for ssh.com's ssh-agent2 */ 4269587Sgreen#define SSH_COM_AGENT2_FAILURE 102 4369587Sgreen 4469587Sgreen#define SSH_AGENT_OLD_SIGNATURE 0x01 4569587Sgreen 4669587Sgreen 4757429Smarkmtypedef struct { 4857429Smarkm int fd; 4957429Smarkm Buffer identities; 5057429Smarkm int howmany; 5157429Smarkm} AuthenticationConnection; 5265668Skris 5357429Smarkm/* Returns the number of the authentication fd, or -1 if there is none. */ 5476259Sgreenint ssh_get_authentication_socket(void); 5557429Smarkm 5657429Smarkm/* 5757429Smarkm * This should be called for any descriptor returned by 5857429Smarkm * ssh_get_authentication_socket(). Depending on the way the descriptor was 5957429Smarkm * obtained, this may close the descriptor. 6057429Smarkm */ 6157429Smarkmvoid ssh_close_authentication_socket(int authfd); 6257429Smarkm 6357429Smarkm/* 6457429Smarkm * Opens and connects a private socket for communication with the 6557429Smarkm * authentication agent. Returns NULL if an error occurred and the 6657429Smarkm * connection could not be opened. The connection should be closed by the 6757429Smarkm * caller by calling ssh_close_authentication_connection(). 6857429Smarkm */ 6976259SgreenAuthenticationConnection *ssh_get_authentication_connection(void); 7057429Smarkm 7157429Smarkm/* 7257429Smarkm * Closes the connection to the authentication agent and frees any associated 7357429Smarkm * memory. 7457429Smarkm */ 7565668Skrisvoid ssh_close_authentication_connection(AuthenticationConnection *auth); 7657429Smarkm 7757429Smarkm/* 7876259Sgreen * Returns the number authentication identity held by the agent. 7976259Sgreen */ 8076259Sgreenint ssh_get_num_identities(AuthenticationConnection *auth, int version); 8176259Sgreen 8276259Sgreen/* 8365668Skris * Returns the first authentication identity held by the agent or NULL if 8465668Skris * no identies are available. Caller must free comment and key. 8565668Skris * Note that you cannot mix calls with different versions. 8657429Smarkm */ 8765668SkrisKey *ssh_get_first_identity(AuthenticationConnection *auth, char **comment, int version); 8857429Smarkm 8957429Smarkm/* 9057429Smarkm * Returns the next authentication identity for the agent. Other functions 9157429Smarkm * can be called between this and ssh_get_first_identity or two calls of this 9265668Skris * function. This returns NULL if there are no more identities. The caller 9365668Skris * must free key and comment after a successful return. 9457429Smarkm */ 9565668SkrisKey *ssh_get_next_identity(AuthenticationConnection *auth, char **comment, int version); 9657429Smarkm 9765668Skris/* 9865668Skris * Requests the agent to decrypt the given challenge. Returns true if the 9965668Skris * agent claims it was able to decrypt it. 10065668Skris */ 10160573Skrisint 10265668Skrisssh_decrypt_challenge(AuthenticationConnection *auth, 10365668Skris Key *key, BIGNUM * challenge, 10476259Sgreen u_char session_id[16], 10576259Sgreen u_int response_type, 10676259Sgreen u_char response[16]); 10757429Smarkm 10865668Skris/* Requests the agent to sign data using key */ 10965668Skrisint 11065668Skrisssh_agent_sign(AuthenticationConnection *auth, 11165668Skris Key *key, 11276259Sgreen u_char **sigp, int *lenp, 11376259Sgreen u_char *data, int datalen); 11465668Skris 11557429Smarkm/* 11657429Smarkm * Adds an identity to the authentication server. This call is not meant to 11757429Smarkm * be used by normal applications. This returns true if the identity was 11857429Smarkm * successfully added. 11957429Smarkm */ 12060573Skrisint 12165668Skrisssh_add_identity(AuthenticationConnection *auth, Key *key, 12257429Smarkm const char *comment); 12357429Smarkm 12457429Smarkm/* 12557429Smarkm * Removes the identity from the authentication server. This call is not 12657429Smarkm * meant to be used by normal applications. This returns true if the 12757429Smarkm * identity was successfully added. 12857429Smarkm */ 12965668Skrisint ssh_remove_identity(AuthenticationConnection *auth, Key *key); 13057429Smarkm 13157429Smarkm/* 13257429Smarkm * Removes all identities from the authentication agent. This call is not 13357429Smarkm * meant to be used by normal applications. This returns true if the 13457429Smarkm * operation was successful. 13557429Smarkm */ 13665668Skrisint ssh_remove_all_identities(AuthenticationConnection *auth, int version); 13757429Smarkm 13857429Smarkm#endif /* AUTHFD_H */ 139