Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 1 | /* |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 2 | * |
| 3 | * authfd.h |
| 4 | * |
| 5 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
| 6 | * |
| 7 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
| 8 | * All rights reserved |
| 9 | * |
| 10 | * Created: Wed Mar 29 01:17:41 1995 ylo |
| 11 | * |
| 12 | * Functions to interface with the SSH_AUTHENTICATION_FD socket. |
| 13 | * |
| 14 | */ |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 15 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 16 | /* RCSID("$Id: authfd.h,v 1.3 1999/11/24 13:26:22 damien 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 | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 34 | typedef struct { |
| 35 | int fd; |
| 36 | Buffer packet; |
| 37 | Buffer identities; |
| 38 | int howmany; |
| 39 | } AuthenticationConnection; |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 40 | /* 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^] | 41 | int ssh_get_authentication_socket(); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 42 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 43 | /* This should be called for any descriptor returned by |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 44 | ssh_get_authentication_socket(). Depending on the way the descriptor was |
| 45 | obtained, this may close the descriptor. */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 46 | void ssh_close_authentication_socket(int authfd); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 47 | |
| 48 | /* Opens and connects a private socket for communication with the |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 49 | authentication agent. Returns NULL if an error occurred and the |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 50 | connection could not be opened. The connection should be closed by |
| 51 | the caller by calling ssh_close_authentication_connection(). */ |
| 52 | AuthenticationConnection *ssh_get_authentication_connection(); |
| 53 | |
| 54 | /* Closes the connection to the authentication agent and frees any associated |
| 55 | memory. */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 56 | void ssh_close_authentication_connection(AuthenticationConnection * ac); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 57 | |
| 58 | /* Returns the first authentication identity held by the agent. |
| 59 | Returns true if an identity is available, 0 otherwise. |
| 60 | The caller must initialize the integers before the call, and free the |
| 61 | comment after a successful call (before calling ssh_get_next_identity). */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 62 | int |
| 63 | ssh_get_first_identity(AuthenticationConnection * connection, |
| 64 | BIGNUM * e, BIGNUM * n, char **comment); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 65 | |
| 66 | /* Returns the next authentication identity for the agent. Other functions |
| 67 | can be called between this and ssh_get_first_identity or two calls of this |
| 68 | function. This returns 0 if there are no more identities. The caller |
| 69 | must free comment after a successful return. */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 70 | int |
| 71 | ssh_get_next_identity(AuthenticationConnection * connection, |
| 72 | BIGNUM * e, BIGNUM * n, char **comment); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 73 | |
| 74 | /* Requests the agent to decrypt the given challenge. Returns true if |
| 75 | the agent claims it was able to decrypt it. */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 76 | int |
| 77 | ssh_decrypt_challenge(AuthenticationConnection * auth, |
| 78 | BIGNUM * e, BIGNUM * n, BIGNUM * challenge, |
| 79 | unsigned char session_id[16], |
| 80 | unsigned int response_type, |
| 81 | unsigned char response[16]); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 82 | |
| 83 | /* Adds an identity to the authentication server. This call is not meant to |
| 84 | be used by normal applications. This returns true if the identity |
| 85 | was successfully added. */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 86 | int ssh_add_identity(AuthenticationConnection * connection, |
| 87 | RSA * key, const char *comment); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 88 | |
| 89 | /* Removes the identity from the authentication server. This call is |
| 90 | not meant to be used by normal applications. This returns true if the |
| 91 | identity was successfully added. */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 92 | int ssh_remove_identity(AuthenticationConnection * connection, |
| 93 | RSA * key); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 94 | |
| 95 | /* Removes all identities from the authentication agent. This call is not |
| 96 | meant to be used by normal applications. This returns true if the |
| 97 | operation was successful. */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 98 | int ssh_remove_all_identities(AuthenticationConnection * connection); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 99 | |
| 100 | /* Closes the connection to the authentication agent. */ |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 101 | void ssh_close_authentication(AuthenticationConnection * connection); |
Damien Miller | d4a8b7e | 1999-10-27 13:42:43 +1000 | [diff] [blame] | 102 | |
Damien Miller | 95def09 | 1999-11-25 00:26:21 +1100 | [diff] [blame^] | 103 | #endif /* AUTHFD_H */ |