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