Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1 | /* |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 2 | * |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 3 | * authfd.h |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 4 | * |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 5 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 6 | * |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 7 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
| 8 | * All rights reserved |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 9 | * |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 10 | * Created: Wed Mar 29 01:17:41 1995 ylo |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 11 | * |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 12 | * Functions to interface with the SSH_AUTHENTICATION_FD socket. |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 13 | * |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 14 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 15 | |
Damien Miller | ad833b3 | 2000-08-23 10:46:23 +1000 | [diff] [blame] | 16 | /* RCSID("$OpenBSD: authfd.h,v 1.10 2000/08/19 21:34:43 markus Exp $"); */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 17 | |
| 18 | #ifndef AUTHFD_H |
| 19 | #define AUTHFD_H |
| 20 | |
| 21 | #include "buffer.h" |
| 22 | |
| 23 | /* Messages for the authentication agent connection. */ |
| 24 | #define SSH_AGENTC_REQUEST_RSA_IDENTITIES 1 |
| 25 | #define SSH_AGENT_RSA_IDENTITIES_ANSWER 2 |
| 26 | #define SSH_AGENTC_RSA_CHALLENGE 3 |
| 27 | #define SSH_AGENT_RSA_RESPONSE 4 |
| 28 | #define SSH_AGENT_FAILURE 5 |
| 29 | #define SSH_AGENT_SUCCESS 6 |
| 30 | #define SSH_AGENTC_ADD_RSA_IDENTITY 7 |
| 31 | #define SSH_AGENTC_REMOVE_RSA_IDENTITY 8 |
| 32 | #define SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES 9 |
| 33 | |
Damien Miller | 994cf14 | 2000-07-21 10:19:44 +1000 | [diff] [blame] | 34 | #define SSH2_AGENTC_REQUEST_IDENTITIES 11 |
| 35 | #define SSH2_AGENT_IDENTITIES_ANSWER 12 |
| 36 | #define SSH2_AGENTC_SIGN_REQUEST 13 |
| 37 | #define SSH2_AGENT_SIGN_RESPONSE 14 |
Damien Miller | 994cf14 | 2000-07-21 10:19:44 +1000 | [diff] [blame] | 38 | #define SSH2_AGENTC_ADD_IDENTITY 17 |
| 39 | #define SSH2_AGENTC_REMOVE_IDENTITY 18 |
| 40 | #define SSH2_AGENTC_REMOVE_ALL_IDENTITIES 19 |
| 41 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 42 | typedef struct { |
| 43 | int fd; |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 44 | Buffer identities; |
| 45 | int howmany; |
| 46 | } AuthenticationConnection; |
Damien Miller | ad833b3 | 2000-08-23 10:46:23 +1000 | [diff] [blame] | 47 | |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 48 | /* Returns the number of the authentication fd, or -1 if there is none. */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 49 | int ssh_get_authentication_socket(); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 50 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 51 | /* |
| 52 | * This should be called for any descriptor returned by |
| 53 | * ssh_get_authentication_socket(). Depending on the way the descriptor was |
| 54 | * obtained, this may close the descriptor. |
| 55 | */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 56 | void ssh_close_authentication_socket(int authfd); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 57 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 58 | /* |
| 59 | * Opens and connects a private socket for communication with the |
| 60 | * authentication agent. Returns NULL if an error occurred and the |
| 61 | * connection could not be opened. The connection should be closed by the |
| 62 | * caller by calling ssh_close_authentication_connection(). |
| 63 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 64 | AuthenticationConnection *ssh_get_authentication_connection(); |
| 65 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 66 | /* |
| 67 | * Closes the connection to the authentication agent and frees any associated |
| 68 | * memory. |
| 69 | */ |
Damien Miller | ad833b3 | 2000-08-23 10:46:23 +1000 | [diff] [blame] | 70 | void ssh_close_authentication_connection(AuthenticationConnection *auth); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 71 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 72 | /* |
Damien Miller | ad833b3 | 2000-08-23 10:46:23 +1000 | [diff] [blame] | 73 | * Returns the first authentication identity held by the agent or NULL if |
| 74 | * no identies are available. Caller must free comment and key. |
| 75 | * Note that you cannot mix calls with different versions. |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 76 | */ |
Damien Miller | ad833b3 | 2000-08-23 10:46:23 +1000 | [diff] [blame] | 77 | Key *ssh_get_first_identity(AuthenticationConnection *auth, char **comment, int version); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 78 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 79 | /* |
| 80 | * Returns the next authentication identity for the agent. Other functions |
| 81 | * can be called between this and ssh_get_first_identity or two calls of this |
Damien Miller | ad833b3 | 2000-08-23 10:46:23 +1000 | [diff] [blame] | 82 | * function. This returns NULL if there are no more identities. The caller |
| 83 | * must free key and comment after a successful return. |
| 84 | */ |
| 85 | Key *ssh_get_next_identity(AuthenticationConnection *auth, char **comment, int version); |
| 86 | |
| 87 | /* |
| 88 | * Requests the agent to decrypt the given challenge. Returns true if the |
| 89 | * agent claims it was able to decrypt it. |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 90 | */ |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 91 | int |
Damien Miller | ad833b3 | 2000-08-23 10:46:23 +1000 | [diff] [blame] | 92 | ssh_decrypt_challenge(AuthenticationConnection *auth, |
| 93 | Key *key, BIGNUM * challenge, |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 94 | unsigned char session_id[16], |
| 95 | unsigned int response_type, |
| 96 | unsigned char response[16]); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 97 | |
Damien Miller | ad833b3 | 2000-08-23 10:46:23 +1000 | [diff] [blame] | 98 | /* Requests the agent to sign data using key */ |
| 99 | int |
| 100 | ssh_agent_sign(AuthenticationConnection *auth, |
| 101 | Key *key, |
| 102 | unsigned char **sigp, int *lenp, |
| 103 | unsigned char *data, int datalen); |
| 104 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 105 | /* |
| 106 | * Adds an identity to the authentication server. This call is not meant to |
| 107 | * be used by normal applications. This returns true if the identity was |
| 108 | * successfully added. |
| 109 | */ |
Damien Miller | 4af5130 | 2000-04-16 11:18:38 +1000 | [diff] [blame] | 110 | int |
Damien Miller | ad833b3 | 2000-08-23 10:46:23 +1000 | [diff] [blame] | 111 | ssh_add_identity(AuthenticationConnection *auth, Key *key, |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 112 | const char *comment); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 113 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 114 | /* |
| 115 | * Removes the identity from the authentication server. This call is not |
| 116 | * meant to be used by normal applications. This returns true if the |
| 117 | * identity was successfully added. |
| 118 | */ |
Damien Miller | ad833b3 | 2000-08-23 10:46:23 +1000 | [diff] [blame] | 119 | int ssh_remove_identity(AuthenticationConnection *auth, Key *key); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 120 | |
Damien Miller | 5428f64 | 1999-11-25 11:54:57 +1100 | [diff] [blame] | 121 | /* |
| 122 | * Removes all identities from the authentication agent. This call is not |
| 123 | * meant to be used by normal applications. This returns true if the |
| 124 | * operation was successful. |
| 125 | */ |
Damien Miller | ad833b3 | 2000-08-23 10:46:23 +1000 | [diff] [blame] | 126 | int ssh_remove_all_identities(AuthenticationConnection *auth, int version); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 127 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame] | 128 | #endif /* AUTHFD_H */ |