1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-02 03:52:49 -05:00

Pageant: factor out cross-platform parts of add_keyfile().

I've now centralised into pageant.c all the logic about trying to load
keys of any type, with no passphrase or with the passphrases used in
previous key-loading actions or with a new user-supplied passphrase,
whether we're the main Pageant process ourself or are talking to
another one as a client. The only part of that code remaining in
winpgnt.c is the user interaction via dialog boxes, which of course is
the part that will need to be done differently on other platforms.
This commit is contained in:
Simon Tatham
2015-05-11 15:06:25 +01:00
parent 8c4ce6d8c6
commit 2069de8c8f
3 changed files with 512 additions and 423 deletions

View File

@ -85,3 +85,38 @@ void pageant_listener_got_socket(struct pageant_listen_state *pl, Socket sock);
void pageant_listener_set_logfn(struct pageant_listen_state *pl,
void *logctx, pageant_logfn_t logfn);
void pageant_listener_free(struct pageant_listen_state *pl);
/*
* Functions to perform specific key actions, either as a client of an
* ssh-agent running elsewhere, or directly on the agent state in this
* process. (On at least one platform we want to do this in an
* agnostic way between the two situations.)
*
* pageant_get_keylist{1,2} work just like pageant_make_keylist{1,2}
* above, except that they can also cope if they have to contact an
* external agent.
*
* pageant_add_keyfile() is used to load a private key from a file and
* add it to the agent. Initially, you should call it with passphrase
* NULL, and it will check if the key is already in the agent, and
* whether a passphrase is required. Return values are given in the
* enum below. On return, *retstr will either be NULL, or a
* dynamically allocated string containing a key comment or an error
* message.
*
* pageant_add_keyfile() also remembers passphrases with which it's
* successfully decrypted keys (because if you try to add multiple
* keys in one go, you might very well have used the same passphrase
* for keys that have the same trust properties). Call
* pageant_forget_passphrases() to get rid of them all.
*/
void *pageant_get_keylist1(int *length);
void *pageant_get_keylist2(int *length);
enum {
PAGEANT_ACTION_OK, /* success; no further action needed */
PAGEANT_ACTION_FAILURE, /* failure; *retstr is error message */
PAGEANT_ACTION_NEED_PP /* need passphrase: *retstr is key comment */
};
int pageant_add_keyfile(Filename *filename, const char *passphrase,
char **retstr);
void pageant_forget_passphrases(void);