Port to Windows.
[libpwmd.git] / doc / libpwmd.3
blob6c8931e38723ba66760194e21d6c1cdeb4f9b3e7
1 .TH "libpwmd.h" 3 "Tue Jan 31 2017" "Version 8.1.0" "libpwmd" \" -*- nroff -*-
2 .ad l
3 .nh
4 .SH NAME
5 libpwmd.h - an API for accessing pwmd
6 .SH "Description"
7 .PP 
8 libpwmd is a library making it easy for applications to use the pwmd server\&. Pwmd version 3\&.1 or later is required; either locally or remotely\&.
9 .SH "Threads"
10 .PP
11 \fBlibpwmd\fP should be thread-safe on a per handle bases\&. Meaning that only one thread should access a \fBpwm_t\fP handle at a time\&.
12 .SH "Remote Connection Details"
13 .PP
14 There are two methods of connecting to a remote pwmd server: over SSH and over TLS\&.
15 .PP
16 Connections over SSH are done by creating an SSH channel to spawn a shell that executes a proxy server to connect to the pwmd local Unix Domain Socket\&. Authentication is done by using SSH public key (see \fBssh-keygen(1)\fP) authentication and verifying the host key against a local OpenSSH known hosts formatted file\&. A passphrase protected private SSH key is supported when \fBPWMD_OPTION_SSH_NEEDS_PASSPHRASE\fP is set\&.
17 .PP
18 An unknown servers public key can be added to a known hosts file after user confirmation by setting the callback function \fBpwmd_knownhost_cb_t\fP before connecting to the unknown host\&.
19 .PP
20 On the server side you'll need a proxy server to connect to the pwmd server\&. Below is an example of an \fBauthorized_keys(5)\fP entry that will do this\&. The \fIpublic_key\fP portion should be the same as the contents of the \fBssh-keygen(1)\fP \fIidentity\&.pub\fP file generated on the client machine\&. The private key should be passed as the \fIidentity\fP parameter to \fBpwmd_connect()\fP:
21 .PP
22 .PP
23 .nf
24 command="socat UNIX-CONNECT:$HOME/\&.pwmd/socket -" <public_key> \&.\&.\&.
25 .fi
26 .PP
27 .PP
28 Pwmd itself can accept TLS connections so no proxy program is needed as is when using SSH\&. Like SSH connections, TLS connections are created with \fBpwmd_connect()\fP\&. You will need to generate a client key and X509 certificate and then sign it with the same certificate authority (CA) that the pwmd server certificate was signed with\&.
29 .PP
30 Certificates are similar to SSH public and private keys but a little harder to setup correctly\&. See the \fBcerttool(1)\fP (recommended) and \fBopenssl(1)\fP manual pages for details\&.
31 .SH "Pinentry Details"
32 .PP
33 \fBpinentry(1)\fP is a program that prompts the user for input which is normally a passphrase or a confirmation\&. libpwmd can use this program either locally (X11 forwarding is not yet supported) or have the pwmd server (read: \fBgpg-agent(1)\fP) call pinentry to retrieve a passphrase when needed\&.
34 .PP
35 There are a few options that tell pinentry how and where to prompt for a needed passphrase\&. See the \fBpwmd_option_t\fP section for details\&. These options are sent to pwmd during \fBpwmd_open()\fP, \fBpwmd_save()\fP and \fBpwmd_passwd()\fP only when pinentry use has not been disabled (\fBPWMD_OPTION_NO_PINENTRY\fP) and when not over a remote connection\&.
36 .PP
37 Some pinentry options may also be specified in the local configuration file \fI'~/\&.config/libpwmd\&.conf'\fP\&.
38 .PP
39 \fBNote:\fP
40 .RS 4
41 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user\&.
42 .PP
43 The initial values for the pinentry TTY, TERM and DISPLAY are set during \fBpwmd_new()\fP depending on the current environment\&. They are then updated to the values specified in \fI~/\fP\&.config/libpwmd\&.conf\&. They can then be reset or changed as needed by using \fBpwmd_setopt()\fP\&.
44 .PP
45 After establishing a remote connection, pwmd's pinentry is disabled by sending the pwmd option \fI'disable-pinentry'\fP during \fBpwmd_open()\fP\&. A local pinentry will be used instead\&.
46 .RE
47 .PP
48 \fBSee also:\fP
49 .RS 4
50 \fBRemote Connection Details\fP, \fBConfiguration File\fP
51 .RE
52 .PP
53 .SH "Configuration File"
54 .PP
55 Initial values overriding libpwmd defaults for a handle may be specified in the configuration file \fI~/\fP\&.config/libpwmd\&.conf\&. This file is read only once during \fBpwmd_new()\fP\&. Option values may be updated by setting the associated option with \fBpwmd_setopt()\fP\&. Blank lines and lines beginning with a '#' are ignored as are unrecognized options\&. See the documentation for each option for its' value type\&. Valid options are:
56 .PP
57 \fBpinentry-path\fP
58 .RS 4
59 Same as \fBPWMD_OPTION_PINENTRY_PATH\fP\&.
60 .RE
61 .PP
62 \fBpinentry-display\fP
63 .RS 4
64 Same as \fBPWMD_OPTION_PINENTRY_DISPLAY\fP\&.
65 .RE
66 .PP
67 \fBpinentry-ttyname\fP
68 .RS 4
69 Same as \fBPWMD_OPTION_PINENTRY_TTY\fP\&.
70 .RE
71 .PP
72 \fBpinentry-ttytype\fP
73 .RS 4
74 Same as \fBPWMD_OPTION_PINENTRY_TERM\fP\&.
75 .RE
76 .PP
77 \fBpinentry-lc-messages\fP
78 .RS 4
79 Same as \fBPWMD_OPTION_PINENTRY_LC_MESSAGES\fP\&.
80 .RE
81 .PP
82 \fBpinentry-lc-ctype\fP
83 .RS 4
84 Same as \fBPWMD_OPTION_PINENTRY_LC_CTYPE\fP\&.
85 .RE
86 .PP
87 \fBpinentry-timeout\fP
88 .RS 4
89 Same as \fBPWMD_OPTION_PINENTRY_TIMEOUT\fP\&.
90 .RE
91 .PP
92 \fBpinentry-tries\fP
93 .RS 4
94 Same as \fBPWMD_OPTION_PINENTRY_TRIES\fP\&.
95 .RE
96 .PP
97 \fBno-pinentry\fP
98 .RS 4
99 Same as \fBPWMD_OPTION_NO_PINENTRY\fP\&.
102 \fBlocal-pinentry\fP
103 .RS 4
104 Same as \fBPWMD_OPTION_LOCAL_PINENTRY\fP\&.
107 \fBno-ssh-agent\fP
108 .RS 4
109 Same as \fBPWMD_OPTION_SSH_AGENT\fP\&.
112 \fBno-tls-verify\fP
113 .RS 4
114 Same as \fBPWMD_OPTION_TLS_VERIFY\fP\&.
117 \fBtls-priority\fP
118 .RS 4
119 Same as \fBPWMD_OPTION_TLS_PRIORITY\fP\&.
122 \fBsocket-timeout\fP
123 .RS 4
124 Same as \fBPWMD_OPTION_SOCKET_TIMEOUT\fP\&.
127 \fBno-lock\fP
128 .RS 4
129 Same as \fBPWMD_OPTION_LOCK_ON_OPEN\fP\&.
132 \fBinclude\fP
133 .RS 4
134 Path to file containing additional libpwmd\&.conf settings\&.
137 .SH "Errors"
139 libpwmd uses libgpg-error for all error codes\&. Error codes can be described by using \fBgpg_strerror()\fP, or the thread-safe \fBgpg_strerror_r()\fP\&.
141 \fBNote:\fP
142 .RS 4
143 libgpg-error returns an error code as a bitmask of an error source and the error code\&. Determining the error source can help you determine where the error occurred, be it from \fBpinentry(1)\fP, \fBgpg-agent(1)\fP, \fBlibgcrypt\fP, \fBpwmd(1)\fP or \fBlibpwmd(3)\fP\&. pwmd uses the \fBGPG_ERR_SOURCE_USER_1\fP error source and libpwmd uses \fBGPG_ERR_SOURCE_USER_2\fP\&. To view the error source and description of an error code the \fBgpg-error(1)\fP command line utility may be of use\&. Also see the \fBlibgpg-error\fP documentation for error code manipulation\&. 
147 .SH SYNOPSIS
150 .SS "Constants"
152 .in +1c
153 .ti -1c
154 .RI "#define \fBLIBPWMD_API\fP"
156 .ti -1c
157 .RI "#define \fBGPG_ERR_SOURCE_DEFAULT\fP   GPG_ERR_SOURCE_USER_2"
159 .ti -1c
160 .RI "#define \fBLIBPWMD_VERSION\fP   0x080100"
162 .ti -1c
163 .RI "#define \fBLIBPWMD_VERSION_MAJOR\fP   8"
165 .ti -1c
166 .RI "#define \fBLIBPWMD_VERSION_MINOR\fP   1"
168 .ti -1c
169 .RI "#define \fBLIBPWMD_VERSION_PATCH\fP   0"
171 .ti -1c
172 .RI "#define \fBLIBPWMD_VERSION_STR\fP   '8\&.1\&.0\-dev'"
174 .ti -1c
175 .RI "#define \fBPWMD_FEATURE_PINENTRY\fP"
177 .ti -1c
178 .RI "#define \fBPWMD_FEATURE_QUALITY\fP"
180 .ti -1c
181 .RI "#define \fBPWMD_FEATURE_SSH\fP"
183 .ti -1c
184 .RI "#define \fBPWMD_FEATURE_GNUTLS\fP"
186 .in -1c
187 .SS "Typedefs"
189 .in +1c
190 .ti -1c
191 .RI "typedef struct pwm_s \fBpwm_t\fP"
193 .ti -1c
194 .RI "typedef ssize_t(* \fBpwmd_read_cb_t\fP) (void *user, int fd, void *data, size_t len)"
196 .ti -1c
197 .RI "typedef ssize_t(* \fBpwmd_write_cb_t\fP) (void *user, int fd, const void *data, size_t len)"
199 .ti -1c
200 .RI "typedef gpg_error_t(* \fBpwmd_status_cb_t\fP) (void *user, const char *line)"
202 .ti -1c
203 .RI "typedef gpg_error_t(* \fBpwmd_inquire_cb_t\fP) (void *user, const char *keyword, gpg_error_t rc, char **data, size_t *len)"
205 .ti -1c
206 .RI "typedef gpg_error_t(* \fBpwmd_knownhost_cb_t\fP) (void *user, const char *host, const char *hostkey, size_t len)"
208 .in -1c
209 .SS "Enumerations"
211 .in +1c
212 .ti -1c
213 .RI "enum \fBpwmd_socket_t\fP { \fBPWMD_SOCKET_LOCAL\fP, \fBPWMD_SOCKET_SSH\fP, \fBPWMD_SOCKET_TLS\fP, \fBPWMD_SOCKET_USER\fP }"
215 .ti -1c
216 .RI "enum \fBpwmd_pinentry_t\fP { \fBPWMD_PINENTRY_OPEN\fP, \fBPWMD_PINENTRY_OPEN_FAILED\fP, \fBPWMD_PINENTRY_SAVE\fP, \fBPWMD_PINENTRY_SAVE_CONFIRM\fP, \fBPWMD_PINENTRY_SAVE_FAILED\fP, \fBPWMD_PINENTRY_CONFIRM\fP, \fBPWMD_PINENTRY_USER\fP, \fBPWMD_PINENTRY_CLOSE\fP }"
218 .ti -1c
219 .RI "enum \fBpwmd_option_t\fP { \fBPWMD_OPTION_PINENTRY_PATH\fP, \fBPWMD_OPTION_PINENTRY_TTY\fP, \fBPWMD_OPTION_PINENTRY_TERM\fP, \fBPWMD_OPTION_PINENTRY_DISPLAY\fP, \fBPWMD_OPTION_PINENTRY_ERROR\fP, \fBPWMD_OPTION_PINENTRY_PROMPT\fP, \fBPWMD_OPTION_PINENTRY_DESC\fP, \fBPWMD_OPTION_PINENTRY_LC_CTYPE\fP, \fBPWMD_OPTION_PINENTRY_LC_MESSAGES\fP, \fBPWMD_OPTION_PINENTRY_TIMEOUT\fP, \fBPWMD_OPTION_PINENTRY_TRIES\fP, \fBPWMD_OPTION_STATUS_CB\fP, \fBPWMD_OPTION_STATUS_DATA\fP, \fBPWMD_OPTION_KNOWNHOST_CB\fP, \fBPWMD_OPTION_KNOWNHOST_DATA\fP, \fBPWMD_OPTION_INQUIRE_TOTAL\fP, \fBPWMD_OPTION_LOCK_ON_OPEN\fP, \fBPWMD_OPTION_SSH_AGENT\fP, \fBPWMD_OPTION_NO_PINENTRY\fP, \fBPWMD_OPTION_LOCAL_PINENTRY\fP, \fBPWMD_OPTION_OVERRIDE_INQUIRE\fP, \fBPWMD_OPTION_SOCKET_TIMEOUT\fP, \fBPWMD_OPTION_TLS_VERIFY\fP, \fBPWMD_OPTION_SIGPIPE\fP, \fBPWMD_OPTION_SERVER_VERSION\fP, \fBPWMD_OPTION_SSH_NEEDS_PASSPHRASE\fP, \fBPWMD_OPTION_SSH_PASSPHRASE\fP, \fBPWMD_OPTION_TLS_PRIORITY\fP, \fBPWMD_OPTION_READ_CB\fP, \fBPWMD_OPTION_READ_CB_DATA\fP, \fBPWMD_OPTION_WRITE_CB\fP, \fBPWMD_OPTION_WRITE_CB_DATA\fP }"
221 .in -1c
222 .SS "Functions"
224 .in +1c
225 .ti -1c
226 .RI "LIBPWMD_API const char * \fBpwmd_version\fP ()"
228 .ti -1c
229 .RI "LIBPWMD_API unsigned int \fBpwmd_features\fP ()"
231 .ti -1c
232 .RI "LIBPWMD_API gpg_error_t \fBpwmd_init\fP (void)"
234 .ti -1c
235 .RI "LIBPWMD_API void \fBpwmd_deinit\fP (void)"
237 .ti -1c
238 .RI "LIBPWMD_API gpg_error_t \fBpwmd_new\fP (const char *name, \fBpwm_t\fP **pwm)"
240 .ti -1c
241 .RI "LIBPWMD_API void \fBpwmd_set_pointer\fP (\fBpwm_t\fP *pwm, void *data)"
243 .ti -1c
244 .RI "LIBPWMD_API void * \fBpwmd_get_pointer\fP (\fBpwm_t\fP *pwm)"
246 .ti -1c
247 .RI "LIBPWMD_API gpg_error_t \fBpwmd_cancel\fP (\fBpwm_t\fP *pwm)"
249 .ti -1c
250 .RI "LIBPWMD_API gpg_error_t \fBpwmd_connect_fd\fP (\fBpwm_t\fP *pwm, int fd)"
252 .ti -1c
253 .RI "LIBPWMD_API gpg_error_t \fBpwmd_connect\fP (\fBpwm_t\fP *pwm, const char *url,\&.\&.\&.)"
255 .ti -1c
256 .RI "LIBPWMD_API int \fBpwmd_gnutls_error\fP (\fBpwm_t\fP *pwm, const char **str)"
258 .ti -1c
259 .RI "LIBPWMD_API gpg_error_t \fBpwmd_setopt\fP (\fBpwm_t\fP *pwm, int opt,\&.\&.\&.)"
261 .ti -1c
262 .RI "LIBPWMD_API gpg_error_t \fBpwmd_getopt\fP (\fBpwm_t\fP *pwm, int opt,\&.\&.\&.)"
264 .ti -1c
265 .RI "LIBPWMD_API gpg_error_t \fBpwmd_getpin\fP (\fBpwm_t\fP *pwm, const char *filename, char **result, size_t *len, \fBpwmd_pinentry_t\fP which)"
267 .ti -1c
268 .RI "LIBPWMD_API gpg_error_t \fBpwmd_password\fP (\fBpwm_t\fP *pwm, const char *keyword, char **result, size_t *size)"
270 .ti -1c
271 .RI "LIBPWMD_API gpg_error_t \fBpwmd_test_quality\fP (const char *passphrase, double *result)"
273 .ti -1c
274 .RI "LIBPWMD_API gpg_error_t \fBpwmd_open\fP (\fBpwm_t\fP *pwm, const char *filename, \fBpwmd_inquire_cb_t\fP callback, void *data)"
276 .ti -1c
277 .RI "LIBPWMD_API gpg_error_t \fBpwmd_process\fP (\fBpwm_t\fP *pwm)"
279 .ti -1c
280 .RI "LIBPWMD_API gpg_error_t \fBpwmd_genkey\fP (\fBpwm_t\fP *pwm, const char *args, \fBpwmd_inquire_cb_t\fP callback, void *user)"
282 .ti -1c
283 .RI "LIBPWMD_API gpg_error_t \fBpwmd_save\fP (\fBpwm_t\fP *pwm, const char *args, \fBpwmd_inquire_cb_t\fP callback, void *user)"
285 .ti -1c
286 .RI "LIBPWMD_API gpg_error_t \fBpwmd_passwd\fP (\fBpwm_t\fP *pwm, const char *args, \fBpwmd_inquire_cb_t\fP callback, void *user)"
288 .ti -1c
289 .RI "LIBPWMD_API gpg_error_t \fBpwmd_command\fP (\fBpwm_t\fP *pwm, char **result, size_t *len, \fBpwmd_inquire_cb_t\fP callback, void *user, const char *cmd,\&.\&.\&.)"
291 .ti -1c
292 .RI "LIBPWMD_API gpg_error_t \fBpwmd_command_ap\fP (\fBpwm_t\fP *pwm, char **result, size_t *len, \fBpwmd_inquire_cb_t\fP callback, void *user, const char *cmd, va_list ap)"
294 .ti -1c
295 .RI "LIBPWMD_API gpg_error_t \fBpwmd_disconnect\fP (\fBpwm_t\fP *pwm)"
297 .ti -1c
298 .RI "LIBPWMD_API void \fBpwmd_close\fP (\fBpwm_t\fP *pwm)"
300 .ti -1c
301 .RI "LIBPWMD_API gpg_error_t \fBpwmd_socket_type\fP (\fBpwm_t\fP *pwm, \fBpwmd_socket_t\fP *type)"
303 .ti -1c
304 .RI "LIBPWMD_API gpg_error_t \fBpwmd_fd\fP (\fBpwm_t\fP *pwm, int *fd)"
306 .ti -1c
307 .RI "LIBPWMD_API void \fBpwmd_free\fP (void *ptr)"
309 .ti -1c
310 .RI "LIBPWMD_API void * \fBpwmd_malloc\fP (size_t size)"
312 .ti -1c
313 .RI "LIBPWMD_API void * \fBpwmd_calloc\fP (size_t nmemb, size_t size)"
315 .ti -1c
316 .RI "LIBPWMD_API void * \fBpwmd_realloc\fP (void *ptr, size_t size)"
318 .ti -1c
319 .RI "LIBPWMD_API char * \fBpwmd_strdup\fP (const char *str)"
321 .ti -1c
322 .RI "LIBPWMD_API char * \fBpwmd_strdup_printf\fP (const char *fmt,\&.\&.\&.)"
324 .in -1c
325 .SH "Constant Details"
326 .PP 
327 .SS "#define LIBPWMD_VERSION   0x080100"
330 Version information\&. The version of this library\&. 
331 .SS "#define LIBPWMD_VERSION_MAJOR   8"
334 Version information\&. The major release number of this library\&. 
335 .SS "#define LIBPWMD_VERSION_MINOR   1"
338 Version information\&. The minor release number of this library\&. 
339 .SS "#define LIBPWMD_VERSION_PATCH   0"
342 Version information\&. The patch level of this library\&. 
343 .SS "#define LIBPWMD_VERSION_STR   '8\&.1\&.0\-dev'"
346 Version information\&. A string representation of the version of this library\&. 
347 .SS "#define PWMD_FEATURE_GNUTLS"
350 Remote connections over TLS\&. 
352 \fBSee also:\fP
353 .RS 4
354 \fBRemote Connection Details\fP 
358 .SS "#define PWMD_FEATURE_PINENTRY"
361 Pinentry support\&. This is for a local or fork()'ed pinentry\&. 
362 .SS "#define PWMD_FEATURE_QUALITY"
365 Password quality checking\&. A password quality meter is shown when the pinentry supports it\&. 
366 .SS "#define PWMD_FEATURE_SSH"
369 Remote connections over an SSH channel\&. 
371 \fBSee also:\fP
372 .RS 4
373 \fBRemote Connection Details\fP 
377 .SH "Typedef Details"
378 .PP 
379 .SS "\fBpwm_t\fP"
382 A libpwmd handle\&. When a pwmd handle or context is mentioned in this documentation it is a pointer of this type\&. A new handle is created with \fBpwmd_new()\fP\&. 
383 .SS "pwmd_inquire_cb_t"
386 Send data to the pwmd server\&. This is a callback function that is used for sending data to the server for commands that need to reply to an INQUIRE server response\&. The reason for this callback is to let the client send as many bytes as it wants rather than the entire data at once\&. It gets called during an internal \fBassuan_transact()\fP from an internal inquire callback function which in turn calls this function by looping over its return value\&.
388 \fBParameters:\fP
389 .RS 4
390 \fIuser\fP The user data pointer passed to the libpwmd function specifying this callback\&. 
392 \fIkeyword\fP The name of this inquire\&. Could be a command name or some keyword describing what needs to be sent\&. See the pwmd and \fBgpg-agent(1)\fP documentation for details\&. 
394 \fIrc\fP The result of the last internal call to \fBassuan_send_data()\fP which did the sending of the data to the pwmd server\&. On the first call to this callback it's value will always be 0 since no data has been sent yet\&. This should be checked during each call to this function and should return the same error code when set\&. Its purpose is to let the client clean up before letting the command fail\&. 
396 \fIdata\fP The next chunk of data to send or NULL\&. 
398 \fIlen\fP The length of \fIdata\fP or 0\&.
401 \fBReturn values:\fP
402 .RS 4
403 \fI0\fP There is more data to be sent\&. 
405 \fIGPG_ERR_EOF\fP No need to call this function again, the current \fIdata\fP is the last to send\&. 
407 \fIcode\fP Any other error code which will cancel the INQUIRE\&.
410 \fBNote:\fP
411 .RS 4
412 The sent data is processed line-per-line\&. The line is either newline terminated or is buffered until ASSUAN_LINELENGTH bytes have been allocated\&. Any remaining bytes are sent after the INQUIRE has finished\&. 
416 .SS "pwmd_knownhost_cb_t"
419 Verify a remote SSH connection\&. When the current SSH connections host key was not found in the known hosts file, then this callback function can be used to confirm the addition of the new host key to the known_hosts file\&. When \fBPWMD_OPTION_KNOWNHOST_CB\fP is not set then the default callback function will be used\&.
421 \fBParameters:\fP
422 .RS 4
423 \fIuser\fP User data which was set with \fBPWMD_OPTION_KNOWNHOST_DATA\fP\&. 
425 \fIhost\fP The hostname as passed to \fBpwmd_connect()\fP\&. 
427 \fIhostkey\fP The raw binary data of the host key\&. 
429 \fIlen\fP The length of \fIhostkey\fP\&. 
432 \fBReturn values:\fP
433 .RS 4
434 \fI0\fP Add the host key to the known hosts file\&. 
436 \fIGPG_ERR_NOT_CONFIRMED\fP Do not add the host key and abort the connection\&. This is the recommended error code although any other non-zero return value will also abort the connection\&.
439 \fBNote:\fP
440 .RS 4
441 If the known hosts file cannot be modified do to filesystem restrictions when adding the new host key, no error is returned\&. Instead, the host key is added to the current connections host key cache and the connection is accepted\&.
444 \fBSee also:\fP
445 .RS 4
446 \fBRemote Connection Details\fP 
450 .SS "pwmd_read_cb_t"
453 Custom socket read callback function\&. Use this function to override the libpwmd function used for reading from a socket\&. Set with \fBpwmd_setopt()\fP\&.
455 \fBParameters:\fP
456 .RS 4
457 \fIuser\fP A user data pointer which is set with \fBPWMD_OPTION_READ_CB_DATA\fP\&. 
459 \fIfd\fP The file descriptor to read from\&. 
461 \fIdata\fP The buffer to store the read data to\&. 
463 \fIlen\fP The size of the data buffer\&. 
466 \fBReturns:\fP
467 .RS 4
468 The amount of bytes read\&. 
471 \fBSee also:\fP
472 .RS 4
473 \fBpwmd_connect_fd()\fP 
477 .SS "pwmd_status_cb_t"
480 Process status messages\&. The value of the option \fBPWMD_OPTION_STATUS_CB\fP which is set with \fBpwmd_setopt()\fP\&.
482 \fBParameters:\fP
483 .RS 4
484 \fIuser\fP A user data pointer which is set with \fBPWMD_OPTION_STATUS_DATA\fP\&. 
486 \fIline\fP The status message line received from the server\&. 
489 \fBReturns:\fP
490 .RS 4
491 0 on success or an error code which will cause a command to fail\&. 
495 .SS "pwmd_write_cb_t"
498 Custom socket write callback function\&. Use this function to override the libpwmd function used for writing to a socket\&. Set with \fBpwmd_setopt()\fP\&.
500 \fBParameters:\fP
501 .RS 4
502 \fIuser\fP A user data pointer which is set with \fBPWMD_OPTION_WRITE_CB_DATA\fP\&. 
504 \fIfd\fP The file descriptor to write to\&. 
506 \fIdata\fP The data to write\&. 
508 \fIlen\fP The amount of data bytes to write\&. 
511 \fBReturns:\fP
512 .RS 4
513 The amount of bytes written\&. 
516 \fBSee also:\fP
517 .RS 4
518 \fBpwmd_connect_fd()\fP 
522 .SH "Enumeration Details"
523 .PP 
524 .SS "enum \fBpwmd_option_t\fP"
527 libpwmd options\&. Options are set with \fBpwmd_setopt()\fP\&. Some options must be set before a connection is made to have any effect\&.
529 \fBNote:\fP
530 .RS 4
531 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user\&. 
536 \fBEnumerator\fP
537 .in +1c
539 \fB\fIPWMD_OPTION_PINENTRY_PATH \fP\fP
540 A string value which specifies the full path of the \fBpinentry(1)\fP binary\&. The default is specified at compile time\&.
542 \fBNote:\fP
543 .RS 4
544 This only affects the local pinentry\&. 
547 \fBSee also:\fP
548 .RS 4
549 \fBPinentry Details\fP 
554 \fB\fIPWMD_OPTION_PINENTRY_TTY \fP\fP
555 A string value which specifies the full path to the TTY that \fBpinentry(1)\fP will use to prompt on\&. When set and no DISPLAY is available, \fBPWMD_OPTION_PINENTRY_TERM\fP must also be set\&.
557 \fBSee also:\fP
558 .RS 4
559 \fBPinentry Details\fP 
564 \fB\fIPWMD_OPTION_PINENTRY_TERM \fP\fP
565 A string value which specifies the terminal type (i\&.e\&., vt100) that \fBpinentry(1)\fP will use when no X11 display is available\&.
567 \fBSee also:\fP
568 .RS 4
569 \fBPinentry Details\fP 
574 \fB\fIPWMD_OPTION_PINENTRY_DISPLAY \fP\fP
575 A string value which specifies the X11 display that \fBpinentry(1)\fP will use\&. \fBpinentry(1)\fP seems to make DISPLAY have a higher priority than \fBPWMD_OPTION_PINENTRY_TTY\fP\&.
577 \fBSee also:\fP
578 .RS 4
579 \fBPinentry Details\fP 
584 \fB\fIPWMD_OPTION_PINENTRY_ERROR \fP\fP
585 A character string that \fBpinentry(1)\fP will use in it's dialog window\&. 
587 \fB\fIPWMD_OPTION_PINENTRY_PROMPT \fP\fP
588 A character string that \fBpinentry(1)\fP will use in it's dialog window\&. 
590 \fB\fIPWMD_OPTION_PINENTRY_DESC \fP\fP
591 A character string that \fBpinentry(1)\fP will use in it's dialog window\&. 
593 \fB\fIPWMD_OPTION_PINENTRY_LC_CTYPE \fP\fP
594 For \fBpinentry(1)\fP localization\&. 
596 \fB\fIPWMD_OPTION_PINENTRY_LC_MESSAGES \fP\fP
597 For \fBpinentry(1)\fP localization\&. 
599 \fB\fIPWMD_OPTION_PINENTRY_TIMEOUT \fP\fP
600 An integer value that specifies the number of seconds \fBpinentry(1)\fP will wait for input before timing out and aborting the current command\&. If 0, then no timeout will be used\&. The default is 30\&.
602 \fBNote:\fP
603 .RS 4
604 This only affects the local pinentry\&. 
609 \fB\fIPWMD_OPTION_PINENTRY_TRIES \fP\fP
610 An integer value that specifies the number of times to prompt for a passphrase before returning an error\&.
612 \fBNote:\fP
613 .RS 4
614 This only affects the local pinentry\&. 
619 \fB\fIPWMD_OPTION_STATUS_CB \fP\fP
620 A function of type \fBpwmd_status_cb_t\fP that will process status messages received from the pwmd server\&. 
622 \fB\fIPWMD_OPTION_STATUS_DATA \fP\fP
623 A user data pointer which is passed to the status message function \fBPWMD_OPTION_STATUS_CB\fP\&. 
625 \fB\fIPWMD_OPTION_KNOWNHOST_CB \fP\fP
626 A function of type \fBpwmd_knownhost_cb_t\fP that will be used to confirm a host key that was not found in the known hosts file\&.
628 \fBSee also:\fP
629 .RS 4
630 \fBRemote Connection Details\fP 
635 \fB\fIPWMD_OPTION_KNOWNHOST_DATA \fP\fP
636 User supplied data which is passed to the known host function \fBPWMD_OPTION_KNOWNHOST_CB\fP\&.
638 \fBSee also:\fP
639 .RS 4
640 \fBRemote Connection Details\fP 
645 \fB\fIPWMD_OPTION_INQUIRE_TOTAL \fP\fP
646 When the total number of bytes to be sent via an INQUIRE is known, this should be set so XFER status messages can be parsed correctly\&. When not known or unset, 0 is used as the total argument to the XFER status message\&. This option should be reset in every function that uses an \fBpwmd_inquire_cb_t\fP\&.
648 \fBNote:\fP
649 .RS 4
650 During the INQUIRE, \fBPWMD_OPTION_STATUS_CB\fP is called, when set, after every iteration of the \fBpwmd_inquire_cb_t\fP\&.
652 This is a libpwmd feature\&. pwmd itself does not send XFER status messages during an INQUIRE\&. Status messages can be parsed only when \fBPWMD_OPTION_STATUS_CB\fP is set\&. 
657 \fB\fIPWMD_OPTION_LOCK_ON_OPEN \fP\fP
658 When set to 1, lock the file mutex during \fBpwmd_open()\fP as if the LOCK command had been sent\&. 
660 \fB\fIPWMD_OPTION_SSH_AGENT \fP\fP
661 Use ssh-agent to retrieve the private key to authenticate with when connecting to a remote pwmd server\&. 
663 \fB\fIPWMD_OPTION_NO_PINENTRY \fP\fP
664 When 1, disable pinentry use\&. This will prevent both pwmd and libpwmd from using a pinentry program and will prompt from the terminal if available\&.
666 \fBNote:\fP
667 .RS 4
668 This must be set before calling \fBpwmd_open()\fP\&. 
671 \fBSee also:\fP
672 .RS 4
673 \fBPWMD_OPTION_OVERRIDE_INQUIRE\fP, \fBPWMD_OPTION_LOCAL_PINENTRY\fP 
678 \fB\fIPWMD_OPTION_LOCAL_PINENTRY \fP\fP
679 When 1, libpwmd will disable pwmd's pinentry and use it's own pinentry\&. This option is set by default when the connection is a remote one\&.
681 \fBNote:\fP
682 .RS 4
683 This must be set before calling \fBpwmd_open()\fP\&. 
688 \fB\fIPWMD_OPTION_OVERRIDE_INQUIRE \fP\fP
689 When set, override libpwmd's internal handling of server inquires with the PASSPHRASE, NEW_PASSPHRASE and SIGN_PASSPHRASE keywords\&. Handling of these keywords is done automatically when \fBPWMD_OPTION_NO_PINENTRY\fP or \fBPWMD_OPTION_LOCAL_PINENTRY\fP is set or when the connection is a remote one\&.
691 \fBSee also:\fP
692 .RS 4
693 \fBRemote Connection Details\fP, \fBPWMD_OPTION_LOCAL_PINENTRY\fP, \fBpwmd_password()\fP 
698 \fB\fIPWMD_OPTION_SOCKET_TIMEOUT \fP\fP
699 An int specifying a timeout in seconds before a TCP connection or data transfer function will timeout causing a connection or command to fail\&. This option can be specified both before and after a connection has been established\&. When 0, no timeout is used\&. 
701 \fB\fIPWMD_OPTION_TLS_VERIFY \fP\fP
702 An int specifying whether to enable TLS hostname verification against the server certificate chain\&. Default is 0 or disabled\&. 
704 \fB\fIPWMD_OPTION_SIGPIPE \fP\fP
705 Set to 1 to not modify the signal handler to ignore SIGPIPE\&. The default is 0, or to ignore this signal\&. 
707 \fB\fIPWMD_OPTION_SERVER_VERSION \fP\fP
708 Get the version of the pwmd server as an unsigned integer\&. This is a read-only setting and is only available after connecting\&. 
710 \fB\fIPWMD_OPTION_SSH_NEEDS_PASSPHRASE \fP\fP
711 The SSH identity file requires a passphrase\&. When set, prompt for the passphrase after connecting\&. Note that only libssh2 built with OpenSSL supports this feature as of libssh2-1\&.7\&.0\&. 
713 \fB\fIPWMD_OPTION_SSH_PASSPHRASE \fP\fP
714 Set SSH private identity passphrase\&. When set there is no need to set \fBPWMD_OPTION_SSH_NEEDS_PASSPHRASE\fP\&. The value of this option is duplicated then freed after the call to \fBpwmd_connect()\fP\&. Note that only libssh2 built with OpenSSL supports this feature as of libssh2-1\&.7\&.0\&. 
716 \fB\fIPWMD_OPTION_TLS_PRIORITY \fP\fP
717 The TLS cipher priority string to use for a TLS connection\&. The default is SECURE256:SECURE192:SECURE128:-VERS-SSL3\&.0:-VERS-TLS1\&.0\&. 
719 \fB\fIPWMD_OPTION_READ_CB \fP\fP
720 The callback function of type \fBpwmd_read_cb_t\fP to use to read from a socket\&. 
722 \fB\fIPWMD_OPTION_READ_CB_DATA \fP\fP
723 The data to pass to the custom read function \fBpwmd_read_cb_t\fP\&. 
725 \fB\fIPWMD_OPTION_WRITE_CB \fP\fP
726 The callback function of type \fBpwmd_write_cb_t\fP to use to write to a socket\&. 
728 \fB\fIPWMD_OPTION_WRITE_CB_DATA \fP\fP
729 The data to pass to the custom write function \fBpwmd_write_cb_t\fP\&. 
730 .SS "enum \fBpwmd_pinentry_t\fP"
733 Local pinentry commands and not pwmd pinentry\&. These determine what prompt a local pinentry uses\&. For use with \fBpwmd_getpin()\fP\&. 
735 \fBEnumerator\fP
736 .in +1c
738 \fB\fIPWMD_PINENTRY_OPEN \fP\fP
739 When opening a file\&. 
741 \fB\fIPWMD_PINENTRY_OPEN_FAILED \fP\fP
742 When opening a file failed due to a bad passphrase\&. 
744 \fB\fIPWMD_PINENTRY_SAVE \fP\fP
745 When saving a file\&. 
747 \fB\fIPWMD_PINENTRY_SAVE_CONFIRM \fP\fP
748 For passphrase confirmation\&. 
750 \fB\fIPWMD_PINENTRY_SAVE_FAILED \fP\fP
751 When saving a file and passphrase confirmation failed\&. 
753 \fB\fIPWMD_PINENTRY_CONFIRM \fP\fP
754 For confirmation of a user-defined prompt\&. 
756 \fB\fIPWMD_PINENTRY_USER \fP\fP
757 For the default or user defined string set with \fBPWMD_OPTION_PINENTRY_DESC\fP\&. 
759 \fB\fIPWMD_PINENTRY_CLOSE \fP\fP
760 To terminate the pinentry process created with \fBpwmd_getpin()\fP\&. 
761 .SS "enum \fBpwmd_socket_t\fP"
764 The type of socket a handle is connected to\&. For use with \fBpwmd_socket_type()\fP\&. 
766 \fBEnumerator\fP
767 .in +1c
769 \fB\fIPWMD_SOCKET_LOCAL \fP\fP
770 A local UNIX domain socket\&. 
772 \fB\fIPWMD_SOCKET_SSH \fP\fP
773 An SSH channel over a TCP socket\&. 
775 \fB\fIPWMD_SOCKET_TLS \fP\fP
776 A TLS connection over a TCP socket\&. 
778 \fB\fIPWMD_SOCKET_USER \fP\fP
779 A socket set with \fBpwmd_connect_fd()\fP\&. 
780 .SH "Function Details"
781 .PP 
782 .SS "LIBPWMD_API void* pwmd_calloc (size_t nmemb, size_t size)"
785 A wrapper around calloc()\&. Like calloc(), but lets libpwmd keep track of the pointer\&.
787 \fBParameters:\fP
788 .RS 4
789 \fInmemb\fP The number of elements to allocate\&. 
791 \fIsize\fP The number of bytes to allocate\&. 
794 \fBReturns:\fP
795 .RS 4
796 A newly allocated pointer or NULL if there wasn't enough memory\&. 
799 \fBSee also:\fP
800 .RS 4
801 calloc(3), \fBpwmd_free()\fP 
805 .SS "LIBPWMD_API gpg_error_t pwmd_cancel (\fBpwm_t\fP * pwm)"
808 Cancel an operation\&. This is limited in functionality as it will only cancel an initiating connection to the pwmd server\&. Command cancellation is not yet supported\&.
810 \fBParameters:\fP
811 .RS 4
812 \fIpwm\fP A handle\&. 
815 \fBReturns:\fP
816 .RS 4
817 0 on success or an error code\&. 
821 .SS "LIBPWMD_API void pwmd_close (\fBpwm_t\fP * pwm)"
824 Close a handle\&. This will close the connection to a pwmd server and free any resources associated with it\&.
826 \fBParameters:\fP
827 .RS 4
828 \fIpwm\fP A handle\&. 
831 \fBReturns:\fP
832 .RS 4
833 Nothing\&. 
836 \fBSee also:\fP
837 .RS 4
838 \fBpwmd_disconnect()\fP, \fBpwmd_new()\fP 
842 .SS "LIBPWMD_API gpg_error_t pwmd_command (\fBpwm_t\fP * pwm, char ** result, size_t * len, \fBpwmd_inquire_cb_t\fP callback, void * user, const char * cmd,  \&.\&.\&.)"
845 Send a command to the pwmd server\&. You should avoid sending the BYE command here because the assuan context will be freed and bad things will happen\&. Use \fBpwmd_close()\fP instead\&.
847 For pwmd commands that use an INQUIRE to retrieve data from a client, the \fIcallback\fP parameter must be non-NULL and will be used to send the data to pwmd\&.
849 \fBParameters:\fP
850 .RS 4
851 \fIpwm\fP A handle\&. 
853 \fIresult\fP The result of the command when successful which must be freed with \fBpwmd_free()\fP\&. 
855 \fIlen\fP The length of \fIresult\fP\&. 
857 \fIcallback\fP A callback function to invoke when pwmd inquires data from the client\&. 
859 \fIuser\fP User data passed to the \fIcallback\fP function\&. 
861 \fIcmd\fP The command to send and any command arguments\&. 
864 \fBReturns:\fP
865 .RS 4
866 0 on success or an error code\&.
869 \fBNote:\fP
870 .RS 4
871 Not all commands return a \fIresult\fP\&. 
875 .SS "LIBPWMD_API gpg_error_t pwmd_command_ap (\fBpwm_t\fP * pwm, char ** result, size_t * len, \fBpwmd_inquire_cb_t\fP callback, void * user, const char * cmd, va_list ap)"
878 Send a command to the pwmd server\&. Like \fBpwmd_command()\fP but uses an argument pointer instead\&.
880 \fBParameters:\fP
881 .RS 4
882 \fIpwm\fP A handle\&. 
884 \fIresult\fP The result of the command when successful which must be freed with \fBpwmd_free()\fP\&. 
886 \fIlen\fP The length of \fIresult\fP\&. 
888 \fIcallback\fP A callback function to invoke when pwmd inquires data from the client\&. 
890 \fIuser\fP User data passed to the \fIcallback\fP function\&. 
892 \fIcmd\fP The command to send\&. 
894 \fIap\fP The arguments to \fIcmd\fP\&. 
897 \fBReturns:\fP
898 .RS 4
899 0 on success or an error code\&.
902 \fBNote:\fP
903 .RS 4
904 Not all commands return a \fIresult\fP\&. 
908 .SS "LIBPWMD_API gpg_error_t pwmd_connect (\fBpwm_t\fP * pwm, const char * url,  \&.\&.\&.)"
911 Establish a connection to a pwmd server\&. Connects to the pwmd server specified in \fIurl\fP\&. The format of \fIurl\fP is: 
913 \fB\fP
914 .RS 4
915 file:///path/to/socket, or 
918 \fB\fP
919 .RS 4
920 ssh[46]://[username@]hostname[:port], or 
923 \fB\fP
924 .RS 4
925 tls[46]://hostname[:port]
928 If \fIurl\fP is NULL then the default local pwmd socket \fI~/\fP\&.pwmd/socket will be used\&.
930 The remaining arguments are parameters for the \fIurl\fP\&.
932 For SSH connections, the first of the positional parameters should be the identity file to use and is required to be non-NULL unless \fBPWMD_OPTION_SSH_AGENT\fP is set\&. The final parameter is the known hosts file to use or NULL to use a default of \fI~/\fP\&.ssh/knownhosts\&.
934 For TLS connections, the first positional parameter should be the client certificate filename\&. The second parameter should be the client certificate key filename\&. The third parameter should be the Certificate Authority (CA) file that was used to sign the server certificate\&. The final parameter is an SHA-256 hash of the server fingerprint to verify against, or NULL\&.
936 For local connections, any remaining parameters are ignored\&.
938 \fBParameters:\fP
939 .RS 4
940 \fIpwm\fP A handle\&. 
942 \fIurl\fP The socket to connect to\&. 
944 \fI\&.\&.\&.\fP Remaining parameters for the \fIurl\fP\&. 
947 \fBReturns:\fP
948 .RS 4
949 0 on success or an error code\&. 
952 \fBNote:\fP
953 .RS 4
954 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user\&. 
957 \fBSee also:\fP
958 .RS 4
959 \fBPWMD_OPTION_SSH_AGENT\fP, \fBPWMD_OPTION_SOCKET_TIMEOUT\fP, \fBpwmd_socket_type()\fP, \fBpwmd_disconnect()\fP, \fBRemote Connection Details\fP 
963 .SS "LIBPWMD_API gpg_error_t pwmd_connect_fd (\fBpwm_t\fP * pwm, int fd)"
966 Associate an already connected socket with a handle\&. Sets a file descriptor for use with the custom read and write callbacks\&. The callbacks must be set before calling this function\&.
968 \fBParameters:\fP
969 .RS 4
970 \fIpwm\fP A handle\&. 
972 \fIfd\fP A connected file descriptor\&. 
975 \fBReturns:\fP
976 .RS 4
977 0 on success or an error code\&. 
980 \fBSee also:\fP
981 .RS 4
982 \fBpwmd_read_cb_t\fP, \fBpwmd_write_cb_t\fP 
986 .SS "LIBPWMD_API void pwmd_deinit (void)"
989 Deinitialize the library\&. This function is mainly for cleaning up other libraries that libpwmd links with to prevent memory and other leaks showing up in a debugger\&. It should be the final libpwmd function call before your app exits\&. 
990 .SS "LIBPWMD_API gpg_error_t pwmd_disconnect (\fBpwm_t\fP * pwm)"
993 Close a connection to the pwmd server\&. This will close the connection but keep any previously set options for the specified handle \fIpwm\fP\&. Calling \fBpwmd_connect()\fP will re-acquire an libassuan context\&.
995 \fBParameters:\fP
996 .RS 4
997 \fIpwm\fP A handle\&. 
1000 \fBReturns:\fP
1001 .RS 4
1002 0 on success or an error code\&. 
1005 \fBSee also:\fP
1006 .RS 4
1007 \fBpwmd_close()\fP 
1011 .SS "LIBPWMD_API gpg_error_t pwmd_fd (\fBpwm_t\fP * pwm, int * fd)"
1014 Get the file descriptor associated with a handle\&. May be useful to determine whether a handle is ready for reading or writing by using select(2) or poll(2)\&.
1016 \fBParameters:\fP
1017 .RS 4
1018 \fIpwm\fP A handle\&. 
1020 \fIfd\fP Set to the file descriptor associated with \fIpwm\fP\&. 
1023 \fBReturns:\fP
1024 .RS 4
1025 0 on success or an error code\&. 
1029 .SS "LIBPWMD_API unsigned int pwmd_features ()"
1032 libpwmd compile time features\&. Useful for clients to determine what features are compiled into libpwmd at runtime\&.
1034 \fBReturns:\fP
1035 .RS 4
1036 A bitmask of features\&. 
1040 .SS "LIBPWMD_API void pwmd_free (void * ptr)"
1043 Free a previously allocated pointer\&. Use this function to free resources allocated by the other libpwmd memory functions\&. Do not use it to free allocations made by other allocators\&.
1045 The difference between the standard free() and this function is that this one will zero out the contents of the pointer before freeing it\&.
1047 \fBParameters:\fP
1048 .RS 4
1049 \fIptr\fP The pointer to deallocate\&. 
1052 \fBReturns:\fP
1053 .RS 4
1054 Nothing\&. 
1057 \fBSee also:\fP
1058 .RS 4
1059 \fBpwmd_malloc()\fP, \fBpwmd_calloc()\fP, \fBpwmd_realloc()\fP, \fBpwmd_strdup()\fP, \fBpwmd_command()\fP 
1063 .SS "LIBPWMD_API gpg_error_t pwmd_genkey (\fBpwm_t\fP * pwm, const char * args, \fBpwmd_inquire_cb_t\fP callback, void * user)"
1066 Generate a new key\&. Generate a new signing or encryption key or both\&. This will only generate a key without saving the XML document to disk\&.
1068 The inquire \fIcallback\fP function should be used when a GENKEY option specified in \fIargs\fP inquires data\&.
1070 \fBParameters:\fP
1071 .RS 4
1072 \fIpwm\fP A handle\&. 
1074 \fIargs\fP Any GENKEY protocol command options or NULL\&. 
1076 \fIcallback\fP A callback function to invoke when pwmd inquires data from the client\&. 
1078 \fIuser\fP User data passed to the \fIcallback\fP function\&. 
1081 \fBReturns:\fP
1082 .RS 4
1083 0 on success or an error code\&. 
1086 \fBSee also:\fP
1087 .RS 4
1088 \fBPWMD_OPTION_OVERRIDE_INQUIRE\fP, \fBPWMD_OPTION_NO_PINENTRY\fP, \fBPWMD_OPTION_LOCAL_PINENTRY\fP, \fBpwmd_command()\fP, \fBPinentry Details\fP 
1092 .SS "LIBPWMD_API void* pwmd_get_pointer (\fBpwm_t\fP * pwm)"
1095 Get user data for a handle\&. Return the user data pointer previously set with \fBpwmd_set_pointer()\fP\&.
1097 \fBParameters:\fP
1098 .RS 4
1099 \fIpwm\fP A handle\&. 
1102 \fBReturns:\fP
1103 .RS 4
1104 A pointer to the user data\&. 
1108 .SS "LIBPWMD_API gpg_error_t pwmd_getopt (\fBpwm_t\fP * pwm, int opt,  \&.\&.\&.)"
1111 Get the value for a handle option\&. Retrieves the default or previously set value for a handle option\&. See \fBpwmd_option_t\fP for option specific details\&.
1113 \fBParameters:\fP
1114 .RS 4
1115 \fIpwm\fP A handle\&. 
1117 \fIopt\fP The option\&. 
1119 \fI\&.\&.\&.\fP A pointer to the option value type to store the value\&. 
1122 \fBReturns:\fP
1123 .RS 4
1124 0 on success or an error code\&. 
1127 \fBNote:\fP
1128 .RS 4
1129 The value is returned as a pointer and not duplicated\&. 
1133 .SS "LIBPWMD_API gpg_error_t pwmd_getpin (\fBpwm_t\fP * pwm, const char * filename, char ** result, size_t * len, \fBpwmd_pinentry_t\fP which)"
1136 Launch a local pinentry\&. Does not send any command to the pwmd server\&. This maybe useful if a passphrase is needed while opening a file over a remote connection and during an \fBpwmd_open()\fP server inquire\&.
1138 This function may also be used to display a user confirmation dialog with pinentry when \fIwhich\fP is \fBPWMD_PINENTRY_CONFIRM\fP\&. The text show in the pinentry is set with \fBpwmd_setopt()\fP\&.
1140 \fBParameters:\fP
1141 .RS 4
1142 \fIpwm\fP A handle\&. 
1144 \fIfilename\fP The filename to use in the pinentry dialog strings when using the default pinentry strings\&. 
1146 \fIresult\fP The entered value in the pinentry dialog which should be freed with \fBpwmd_free()\fP\&. 
1148 \fIlen\fP The length of \fIresult\fP\&. 
1150 \fIwhich\fP Determines the default strings shown in the pinentry dialog\&. \fBpwmd_setopt()\fP may also be used to override the defaults\&. In this case \fBPWMD_PINENTRY_USER\fP should be used\&. \fBPWMD_PINENTRY_CLOSE\fP should be used to terminate the pinentry process when the pinentry is no longer needed\&.
1153 \fBReturns:\fP
1154 .RS 4
1155 0 on success or an error\&.
1158 \fBSee also:\fP
1159 .RS 4
1160 \fBpwmd_password()\fP 
1164 .SS "LIBPWMD_API int pwmd_gnutls_error (\fBpwm_t\fP * pwm, const char ** str)"
1167 Get the error code of a failed GnuTLS function\&. When an TLS error occurs while connecting or during a command, this function can be used to get the error code and error description\&.
1169 \fBParameters:\fP
1170 .RS 4
1171 \fIpwm\fP A handle\&. 
1173 \fIstr\fP The textual representation of the gnutls error code\&. 
1176 \fBReturns:\fP
1177 .RS 4
1178 0 on success or a GnuTLS error code\&. 
1182 .SS "LIBPWMD_API gpg_error_t pwmd_init (void)"
1185 Initialize the library\&. This function must be the first function called in the library before any others\&. It sets up the memory allocators and internationalization among other things\&.
1187 \fBReturns:\fP
1188 .RS 4
1189 0 on success or an error code\&. 
1193 .SS "LIBPWMD_API void* pwmd_malloc (size_t size)"
1196 A wrapper around malloc\&. Like malloc(), but lets libpwmd keep track of the pointer\&.
1198 \fBParameters:\fP
1199 .RS 4
1200 \fIsize\fP The number of bytes to allocate\&. 
1203 \fBReturns:\fP
1204 .RS 4
1205 A newly allocated pointer or NULL if there wasn't enough memory\&. 
1208 \fBSee also:\fP
1209 .RS 4
1210 malloc(3), \fBpwmd_free()\fP 
1214 .SS "LIBPWMD_API gpg_error_t pwmd_new (const char * name, \fBpwm_t\fP ** pwm)"
1217 Creates a new handle\&. Creates a new handle or context for use with the other functions\&.
1219 \fBParameters:\fP
1220 .RS 4
1221 \fIname\fP If not NULL, the name of the application\&. The application name is sent to the pwmd server after successfully connecting and is used in pwmd logging\&. 
1223 \fIpwm\fP A new handle for use with the other functions\&.
1226 \fBReturns:\fP
1227 .RS 4
1228 0 on success or an error code\&. 
1232 .SS "LIBPWMD_API gpg_error_t pwmd_open (\fBpwm_t\fP * pwm, const char * filename, \fBpwmd_inquire_cb_t\fP callback, void * data)"
1235 Open a file on the pwmd server\&. This will send the OPEN command to the server\&.
1237 To make use of \fIcallback\fP, \fBPWMD_OPTION_OVERRIDE_INQUIRE\fP must also be set\&.
1239 \fBParameters:\fP
1240 .RS 4
1241 \fIpwm\fP A handle\&. 
1243 \fIfilename\fP The filename to open\&. The \fIfilename\fP is not a full path but the data filename only\&. 
1245 \fIcallback\fP A callback function to invoke when pwmd inquires data from the client\&. 
1247 \fIdata\fP User data passed to the \fIcallback\fP function\&. 
1250 \fBReturns:\fP
1251 .RS 4
1252 0 on success or an error code\&. 
1255 \fBSee also:\fP
1256 .RS 4
1257 \fBPWMD_OPTION_OVERRIDE_INQUIRE\fP, \fBPinentry Details\fP, \fBpwmd_password()\fP 
1261 .SS "LIBPWMD_API gpg_error_t pwmd_passwd (\fBpwm_t\fP * pwm, const char * args, \fBpwmd_inquire_cb_t\fP callback, void * user)"
1264 Change the passphrase for a data file\&. This will send the PASSWD command to the server taking care of pinentry settings\&.
1266 The inquire \fIcallback\fP function should be used when a PASSWD option specified in \fIargs\fP inquires data\&.
1268 \fBParameters:\fP
1269 .RS 4
1270 \fIpwm\fP A handle\&. 
1272 \fIargs\fP Any PASSWD protocol command options or NULL\&. 
1274 \fIcallback\fP A callback function to invoke when pwmd inquires data from the client\&. 
1276 \fIuser\fP User data passed to the \fIcallback\fP function\&. 
1279 \fBReturns:\fP
1280 .RS 4
1281 0 on success or an error code\&. 
1284 \fBSee also:\fP
1285 .RS 4
1286 \fBPWMD_OPTION_OVERRIDE_INQUIRE\fP, \fBPWMD_OPTION_NO_PINENTRY\fP, \fBPWMD_OPTION_LOCAL_PINENTRY\fP, \fBpwmd_command()\fP, \fBPinentry Details\fP 
1290 .SS "LIBPWMD_API gpg_error_t pwmd_password (\fBpwm_t\fP * pwm, const char * keyword, char ** result, size_t * size)"
1293 Obtain a passphrase from a local pinentry\&. This is the same function that libpwmd uses during an inquire when using the local pinentry and the inquire keyword is one of PASSPHRASE, NEW_PASSPHRASE or SIGN_PASSPHRASE\&. Provided for convenience since it sets proper pinentry strings and handles new passphrase confirmation\&.
1295 \fBParameters:\fP
1296 .RS 4
1297 \fIpwm\fP A handle\&. 
1299 \fIkeyword\fP The keyword to determine pinentry strings\&. Usually one of PASSPHRASE, NEW_PASSPHRASE or SIGN_PASSPHRASE as sent by pwmd\&. 
1301 \fIresult\fP The obtained passphrase which should be freed with \fBpwmd_free()\fP\&. 
1303 \fIsize\fP The length of \fIresult\fP\&.
1306 \fBReturns:\fP
1307 .RS 4
1308 0 on success or an error\&. 
1312 .SS "LIBPWMD_API gpg_error_t pwmd_process (\fBpwm_t\fP * pwm)"
1315 Check for socket activity\&. This function should be called periodically to check for any pending status messages sent from the server and when \fInot\fP in a command\&.
1317 \fBParameters:\fP
1318 .RS 4
1319 \fIpwm\fP A handle\&. 
1322 \fBReturns:\fP
1323 .RS 4
1324 0 on success or an error code\&.
1327 \fBNote:\fP
1328 .RS 4
1329 This function makes use of \fBpwmd_status_cb_t\fP\&. 
1333 .SS "LIBPWMD_API void* pwmd_realloc (void * ptr, size_t size)"
1336 A wrapper around realloc()\&. Like realloc(), but lets libpwmd keep track of the pointer\&.
1338 \fBParameters:\fP
1339 .RS 4
1340 \fIptr\fP The pointer to reallocate\&. 
1342 \fIsize\fP The new number of bytes to allocate\&. 
1345 \fBReturns:\fP
1346 .RS 4
1347 A newly allocated pointer or NULL if there wasn't enough memory\&. 
1350 \fBSee also:\fP
1351 .RS 4
1352 realloc(3), \fBpwmd_free()\fP 
1356 .SS "LIBPWMD_API gpg_error_t pwmd_save (\fBpwm_t\fP * pwm, const char * args, \fBpwmd_inquire_cb_t\fP callback, void * user)"
1359 Save a file on the pwmd server\&. This will send the SAVE command and write any changes to the document to disk\&.
1361 The inquire \fIcallback\fP function should be used when a SAVE option specified in \fIargs\fP inquires data\&.
1363 \fBParameters:\fP
1364 .RS 4
1365 \fIpwm\fP A handle\&. 
1367 \fIargs\fP Any SAVE protocol command options or NULL\&. 
1369 \fIcallback\fP A callback function to invoke when pwmd inquires data from the client\&. 
1371 \fIuser\fP User data passed to the \fIcallback\fP function\&. 
1374 \fBReturns:\fP
1375 .RS 4
1376 0 on success or an error code\&. 
1379 \fBSee also:\fP
1380 .RS 4
1381 \fBPWMD_OPTION_OVERRIDE_INQUIRE\fP, \fBPWMD_OPTION_NO_PINENTRY\fP, \fBPWMD_OPTION_LOCAL_PINENTRY\fP, \fBpwmd_command()\fP, \fBPinentry Details\fP 
1385 .SS "LIBPWMD_API void pwmd_set_pointer (\fBpwm_t\fP * pwm, void * data)"
1388 Set user data for a handle\&. Use this function to associate user data with a handle that can later be retrieved with \fBpwmd_get_pointer()\fP\&.
1390 \fBParameters:\fP
1391 .RS 4
1392 \fIpwm\fP A handle\&. 
1394 \fIdata\fP A pointer to the user data\&. 
1397 \fBReturns:\fP
1398 .RS 4
1399 Nothing\&. 
1403 .SS "LIBPWMD_API gpg_error_t pwmd_setopt (\fBpwm_t\fP * pwm, int opt,  \&.\&.\&.)"
1406 Set handle options\&. See \fBpwmd_option_t\fP for option specific details\&.
1408 \fBParameters:\fP
1409 .RS 4
1410 \fIpwm\fP A handle\&. 
1412 \fIopt\fP The option\&. 
1414 \fI\&.\&.\&.\fP The option value\&. 
1417 \fBReturns:\fP
1418 .RS 4
1419 0 on success or an error code\&. 
1423 .SS "LIBPWMD_API gpg_error_t pwmd_socket_type (\fBpwm_t\fP * pwm, \fBpwmd_socket_t\fP * type)"
1426 The type of connection a handle has\&. Useful when you need to know what kind of connection a handle has\&.
1428 \fBParameters:\fP
1429 .RS 4
1430 \fIpwm\fP A handle\&. 
1432 \fItype\fP The type of socket\&. 
1435 \fBReturns:\fP
1436 .RS 4
1437 0 on success or an error code\&.
1440 \fBSee also:\fP
1441 .RS 4
1442 \fBpwmd_socket_t\fP 
1446 .SS "LIBPWMD_API char* pwmd_strdup (const char * str)"
1449 A wrapper around strdup()\&. Like strdup(), but lets libpwmd keep track of the pointer\&.
1451 \fBParameters:\fP
1452 .RS 4
1453 \fIstr\fP The string to duplicate\&. 
1456 \fBReturns:\fP
1457 .RS 4
1458 A newly allocated character pointer or NULL if there wasn't enough memory\&. 
1461 \fBSee also:\fP
1462 .RS 4
1463 strdup(3), \fBpwmd_free()\fP 
1467 .SS "LIBPWMD_API char* pwmd_strdup_printf (const char * fmt,  \&.\&.\&.)"
1470 Duplicate a formatted string\&. Like \fBasprintf(3)\fP, but lets libpwmd keep track of the pointer\&.
1472 \fBParameters:\fP
1473 .RS 4
1474 \fIfmt\fP The formatted string and any following arguments\&. 
1477 \fBReturns:\fP
1478 .RS 4
1479 A newly allocated character pointer or NULL if there wasn't enough memory\&. 
1482 \fBSee also:\fP
1483 .RS 4
1484 \fBpwmd_free()\fP 
1488 .SS "LIBPWMD_API gpg_error_t pwmd_test_quality (const char * passphrase, double * result)"
1491 Test the quality of a passphrase\&. When built with passphrase quality checking, you can test the amount of entropy a passphrase contains with this function\&. It simply wraps around the zxcvbn-c quality checking function\&.
1493 \fBParameters:\fP
1494 .RS 4
1495 \fIpassphrase\fP The passphrase to test\&. 
1497 \fIresult\fP The entropy of the passphrase in bits\&.
1500 \fBReturns:\fP
1501 .RS 4
1502 0 on success or an error code\&. 
1506 .SS "LIBPWMD_API const char* pwmd_version ()"
1509 Returns this version of libpwmd\&. As a string\&. 
1511 \fBReturns:\fP
1512 .RS 4
1513 A string\&. 
1517 .SH "Author"
1518 .PP 
1519 Generated automatically by Doxygen for libpwmd from the source code\&.