Add pinentry configure options.
[pwmd.git] / src / agent.h
blob5eb506f6c7c188feaa4ee5f838fd27c2b6eec84a
1 /*
2 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
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 <assuan.h>
24 #include <gpg-error.h>
25 #include <gcrypt.h>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <stdint.h>
29 #include "crypto.h"
31 typedef struct
33 size_t len;
34 void *buf;
35 } membuf_t;
37 struct inquire_data_s
39 struct crypto_s *crypto;
40 char *line;
41 size_t len;
42 int preset;
45 struct agent_s
47 assuan_context_t ctx;
48 assuan_context_t client_ctx;
49 membuf_t data;
50 gpg_error_t (*inquire_cb) (void *data, const char *line);
51 void *inquire_data;
52 void *inquire_data2;
53 void *inquire_data3;
54 char *desc;
55 char *display;
56 char *ttyname;
57 char *ttytype;
58 char *lc_messages;
59 char *lc_ctype;
60 int restart;
61 size_t inquire_maxlen;
64 void cleanup_agent (struct agent_s *agent);
65 gpg_error_t send_to_agent (struct agent_s *agent, char **result, size_t * len,
66 const char *fmt, ...);
67 gpg_error_t agent_init (struct agent_s **);
68 gpg_error_t encrypt_data_file (assuan_context_t ctx, struct crypto_s *crypto,
69 gcry_sexp_t pubkey, gcry_sexp_t sigpkey,
70 const char *filename, const void *xml,
71 size_t len);
73 gpg_error_t generate_key (struct crypto_s *, char *, int, int);
74 gpg_error_t set_agent_option (struct agent_s *agent, const char *name,
75 const char *value);
76 gpg_error_t set_agent_passphrase (struct crypto_s *crypto, const char *key,
77 size_t len);
78 gpg_error_t set_pinentry_mode (struct agent_s *agent, const char *mode);
79 gpg_error_t get_pubkey (struct crypto_s *crypto, const char *hexgrip,
80 gcry_sexp_t * result);
81 gpg_error_t get_pubkey_bin (struct crypto_s *crypto,
82 const unsigned char *grip, gcry_sexp_t * result);
83 gpg_error_t agent_set_pinentry_options (struct agent_s *agent);
84 gpg_error_t agent_export_common (struct crypto_s *crypto, const char *keygrip,
85 const char *sign_keygrip, int no_passphrase,
86 const void *data, size_t datalen,
87 const char *outfile, const char *keyparams,
88 const char *keyfile);
89 char *default_key_params (struct crypto_s *crypto);
90 gpg_error_t agent_loopback_cb (void *user, const char *keyword);
91 gpg_error_t agent_passwd (struct crypto_s *crypto);
92 gpg_error_t kill_scd (struct agent_s *);
93 gpg_error_t agent_extract_key (struct crypto_s *crypto, unsigned char **result,
94 size_t * result_len);
95 gpg_error_t agent_verify (gcry_sexp_t pkey, gcry_sexp_t sig_sexp,
96 const void *data, size_t len);
97 gpg_error_t send_agent_common_options (struct agent_s *agent);
99 #endif