3 * Passphrase pixie definitions (Unix-specific)
5 * (c) 1999 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of Catacomb.
12 * Catacomb is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * Catacomb is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with Catacomb; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 #ifndef CATACOMB_PIXIE_H
29 #define CATACOMB_PIXIE_H
35 /*----- Header files ------------------------------------------------------*/
39 #include <sys/socket.h>
42 #ifndef CATACOMB_PASSPHRASE_H
43 # include "passphrase.h"
46 /*----- Protocol definition -----------------------------------------------*
48 * The protocol is simple and text-based. The client connects to the
49 * server's socket and sends `request lines', each of which elicits one or
50 * more `response lines' from the server. Request and response lines contain
51 * whitespace-separated fields, and are terminated by a single linefeed. The
52 * final field on a line may contain whitespace. The first field describes
53 * the type of the line. The type field is not case-sensitive, although
54 * writing them in uppercase is conventional.
59 * Provide (very) brief help with the pixie protocol.
62 * Return a list of passphrases currently stored, together with expiry
66 * Request the passphrase named `tag' from the pixie.
69 * Request a new passphrase, which therefore requires verification.
71 * SET tag [expire] -- phrase
72 * Set the value of passphrase `tag'. This will usually be a follow-up
73 * to a MISSING response.
76 * Flush the passphrase named `tag', or all passphrases, from memory.
79 * Requests that the pixie close down.
81 * Response lines are as follows:
84 * Request completed successfully. If a passphrase was requested, it is
85 * returned by the pixie. This is the final response to a request.
88 * The passphrase requested is not known, and no requester mechanism is
89 * present. The client should request the passphrase itself and pass it
90 * back to the pixie. This is the final response to a request.
93 * Reports an error. The message given is intended to be
94 * human-readable. This is the final response to a request.
97 * Reports a human-readable informational message. Further responses
101 * Reports a passphrase in response to a LIST request. One ITEM
102 * response is given for each passphrase currently in memory. An OK or
103 * FAIL response follows the last ITEM.
105 * Expiry times in requests may be given in any format acceptable to
106 * `getdate'. Expiry times in responses are returned in ISO format
107 * (YYYY-MM-DD HH:MM:SS ZZZ) and are expressed relative to local time.
110 /*----- Functions provided ------------------------------------------------*/
112 /* --- @pixie_open@ --- *
114 * Arguments: @const char *sock@ = path to pixie socket
116 * Returns: Less than zero if it failed, or file descriptor.
118 * Use: Opens a connection to a passphrase pixie.
121 extern int pixie_open(const char */*sock*/);
123 /* --- @pixie_read@ --- *
125 * Arguments: @int fd@ = connection to passphrase pixie
126 * @const char *tag@ = pointer to tag string
127 * @unsigned mode@ = reading mode
128 * @char *buf@ = pointer to destination buffer
129 * @size_t sz@ = size of the buffer
131 * Returns: Zero if all went well, @-1@ if the read fails, @+1@ to
132 * request the passphrase from the user.
134 * Use: Reads a passphrase from the pixie.
137 extern int pixie_read(int /*fd*/, const char */*tag*/, unsigned /*mode*/,
138 char */*buf*/, size_t /*sz*/);
140 /* --- @pixie_set@ --- *
142 * Arguments: @int fd@ = pixie file descriptor
143 * @const char *tag@ = pointer to tag string
144 * @const char *phrase@ = pointer to passphrase string
148 * Use: Sends a passphrase to the passphrase pixie.
151 extern void pixie_set(int /*fd*/, const char */*tag*/,
152 const char */*phrase*/);
154 /* --- @pixie_cancel@ --- *
156 * Arguments: @int fd@ = pixie file descriptor
157 * @const char *tag@ = pointer to tag string
161 * Use: Cancels a passphrase if it turns out to be bogus.
164 extern void pixie_cancel(int /*fd*/, const char */*tag*/);
166 /* --- @pixie_address@ --- *
168 * Arguments: @const char *sock@ = pointer to socket name
169 * @size_t *psz@ = where to write the address size
171 * Returns: Pointer to filled-in Unix-domain socket address.
173 * Use: Returns a Unix-domain socket address to use to find the
177 extern struct sockaddr_un *pixie_address(const char */*sock*/,
180 /* --- @pixie_fdline@ --- *
182 * Arguments: @int fd@ = file descriptor to read from
183 * @char *buf@ = pointer to buffer
184 * @size_t sz@ = size of buffer
188 * Use: Reads a line from a file descriptor. The read is done one
189 * character at a time. If the entire line won't fit, the end
190 * is truncated. The line is null terminated.
193 extern void pixie_fdline(int /*fd*/, char */*buf*/, size_t /*sz*/);
195 /* --- @pixie_getpass@ --- *
197 * Arguments: @const char *prompt@ = pointer to prompt string
198 * @char *buf@ = pointer to buffer
199 * @size_t sz@ = size of buffer
201 * Returns: Zero if it worked OK, nonzero otherwise.
203 * Use: Reads a passphrase from the terminal or some other requested
207 extern int pixie_getpass(const char */*prompt*/,
208 char */*buf*/, size_t /*sz*/);
210 /*----- That's all, folks -------------------------------------------------*/