Version 3.0.12.
[pwmd.git] / src / agent.h
blobb519ee6211467e8b9c32c9e416c6e3c5eda9e390
1 /*
2 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014
3 Ben Kibbey <bjk@luxsci.net>
5 This file is part of pwmd.
7 Pwmd is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 2 of the License, or
10 (at your option) any later version.
12 Pwmd is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Pwmd. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef AGENT_H
21 #define AGENT_H
23 #include "pinentry.h"
25 struct inquire_data_s
27 struct crypto_s *crypto;
28 char *line;
29 size_t len;
30 int preset;
33 struct agent_s
35 assuan_context_t ctx;
36 assuan_context_t client_ctx;
37 membuf_t data;
38 gpg_error_t (*inquire_cb) (void *data, const char *line);
39 void *inquire_data;
40 void *inquire_data2;
41 void *inquire_data3;
42 struct pinentry_option_s pinentry_opts;
43 int restart;
44 int did_restart;
45 size_t inquire_maxlen;
48 void cleanup_agent (struct agent_s *agent);
49 gpg_error_t send_to_agent (struct agent_s *agent, char **result, size_t * len,
50 const char *fmt, ...);
51 gpg_error_t agent_init (struct agent_s **);
52 gpg_error_t encrypt_data_file (assuan_context_t ctx, struct crypto_s *crypto,
53 gcry_sexp_t pubkey, gcry_sexp_t sigpkey,
54 const char *filename, const void *xml,
55 size_t len);
57 gpg_error_t generate_key (struct crypto_s *, char *, int, int);
58 gpg_error_t set_agent_option (struct agent_s *agent, const char *name,
59 const char *value);
60 gpg_error_t set_agent_passphrase (struct crypto_s *crypto, const char *key,
61 size_t len);
62 gpg_error_t set_pinentry_mode (struct agent_s *agent, const char *mode);
63 gpg_error_t get_pubkey (struct crypto_s *crypto, const char *hexgrip,
64 gcry_sexp_t * result);
65 gpg_error_t get_pubkey_bin (struct crypto_s *crypto,
66 const unsigned char *grip, gcry_sexp_t * result);
67 gpg_error_t agent_set_pinentry_options (struct agent_s *agent);
68 gpg_error_t agent_export_common (struct crypto_s *crypto, const char *keygrip,
69 const char *sign_keygrip, int no_passphrase,
70 const void *data, size_t datalen,
71 const char *outfile, const char *keyparams,
72 const char *keyfile);
73 char *default_key_params (struct crypto_s *crypto);
74 gpg_error_t agent_loopback_cb (void *user, const char *keyword);
75 gpg_error_t agent_passwd (struct crypto_s *crypto);
76 gpg_error_t kill_scd (struct agent_s *);
77 gpg_error_t agent_extract_key (struct crypto_s *crypto, unsigned char **result,
78 size_t * result_len);
79 gpg_error_t agent_verify (gcry_sexp_t pkey, gcry_sexp_t sig_sexp,
80 const void *data, size_t len);
81 gpg_error_t send_agent_common_options (struct agent_s *agent);
83 #endif