Table for driving key data extraction.
[u/mdw/catacomb] / pixie.h
CommitLineData
069c185c 1/* -*-c-*-
2 *
3 * $Id: pixie.h,v 1.1 1999/12/22 15:58:41 mdw Exp $
4 *
5 * Passphrase pixie definitions (Unix-specific)
6 *
7 * (c) 1999 Straylight/Edgeware
8 */
9
10/*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of Catacomb.
13 *
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
18 *
19 * Catacomb is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
23 *
24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27 * MA 02111-1307, USA.
28 */
29
30/*----- Revision history --------------------------------------------------*
31 *
32 * $Log: pixie.h,v $
33 * Revision 1.1 1999/12/22 15:58:41 mdw
34 * Passphrase pixie support.
35 *
36 */
37
38#ifndef CATACOMB_PIXIE_H
39#define CATACOMB_PIXIE_H
40
41#ifdef __cplusplus
42 extern "C" {
43#endif
44
45/*----- Header files ------------------------------------------------------*/
46
47#include <stddef.h>
48
49#include <sys/socket.h>
50#include <sys/un.h>
51
52#ifndef CATACOMB_PASSPHRASE_H
53# include "passphrase.h"
54#endif
55
56/*----- Protocol definition -----------------------------------------------*
57 *
58 * The protocol is simple and text-based. The client connects to the
59 * server's socket and sends `request lines', each of which elicits one or
60 * more `response lines' from the server. Request and response lines contain
61 * whitespace-separated fields, and are terminated by a single linefeed. The
62 * final field on a line may contain whitespace. The first field describes
63 * the type of the line. The type field is not case-sensitive, although
64 * writing them in uppercase is conventional.
65 *
66 * The requests are:
67 *
68 * HELP
69 * Provide (very) brief help with the pixie protocol.
70 *
71 * LIST
72 * Return a list of passphrases currently stored, together with expiry
73 * information.
74 *
75 * PASS tag [expire]
76 * Request the passphrase named `tag' from the pixie.
77 *
78 * VERIFY tag [expire]
79 * Request a new passphrase, which therefore requires verification.
80 *
81 * FLUSH [tag]
82 * Flush the passphrase named `tag', or all passphrases, from memory.
83 *
84 * QUIT
85 * Requests that the pixie close down.
86 *
87 * Response lines are as follows:
88 *
89 * OK [phrase]
90 * Request completed successfully. If a passphrase was requested, it is
91 * returned by the pixie. This is the final response to a request.
92 *
93 * FAIL error
94 * Reports an error. The message given is intended to be
95 * human-readable. This is the final response to a request.
96 *
97 * INFO message
98 * Reports a human-readable informational message. Further responses
99 * follow.
100 *
101 * ITEM tag expires
102 * Reports a passphrase in response to a LIST request. One ITEM
103 * response is given for each passphrase currently in memory. An OK or
104 * FAIL response follows the last ITEM.
105 *
106 * Expiry times in requests may be given in any format acceptable to
107 * `getdate'. Expiry times in responses are returned in ISO format
108 * (YYYY-MM-DD HH:MM:SS ZZZ) and are expressed relative to local time.
109 */
110
111/*----- Functions provided ------------------------------------------------*/
112
113/* --- @pixie_open@ --- *
114 *
115 * Arguments: @const char *sock@ = path to pixie socket
116 *
117 * Returns: Less than zero if it failed, or file descriptor.
118 *
119 * Use: Opens a connection to a passphrase pixie.
120 */
121
122extern int pixie_open(const char */*sock*/);
123
124/* --- @pixie_read@ --- *
125 *
126 * Arguments: @int fd@ = connection to passphrase pixie
127 * @const char *tag@ = pointer to tag string
128 * @unsigned mode@ = reading mode
129 * @char *buf@ = pointer to destination buffer
130 * @size_t sz@ = size of the buffer
131 *
132 * Returns: Zero if all went well, nonzero if the read fails.
133 *
134 * Use: Reads a passphrase from the pixie.
135 */
136
137extern int pixie_read(int /*fd*/, const char */*tag*/, unsigned /*mode*/,
138 char */*buf*/, size_t /*sz*/);
139
140/* --- @pixie_cancel@ --- *
141 *
142 * Arguments: @int fd@ = pixie file descriptor
143 * @const char *tag@ = pointer to tag string
144 *
145 * Returns: ---
146 *
147 * Use: Cancels a passphrase if it turns out to be bogus.
148 */
149
150extern void pixie_cancel(int /*fd*/, const char */*tag*/);
151
152/* --- @pixie_address@ --- *
153 *
154 * Arguments: @const char *sock@ = pointer to socket name
155 * @size_t *psz@ = where to write the address size
156 *
157 * Returns: Pointer to filled-in Unix-domain socket address.
158 *
159 * Use: Returns a Unix-domain socket address to use to find the
160 * passphrase pixie.
161 */
162
163extern struct sockaddr_un *pixie_address(const char */*sock*/,
164 size_t */*psz*/);
165
166/* --- @pixie_fdline@ --- *
167 *
168 * Arguments: @int fd@ = file descriptor to read from
169 * @char *buf@ = pointer to buffer
170 * @size_t sz@ = size of buffer
171 *
172 * Returns: ---
173 *
174 * Use: Reads a line from a file descriptor. The read is done one
175 * character at a time. If the entire line won't fit, the end
176 * is truncated. The line is null terminated.
177 */
178
179extern void pixie_fdline(int /*fd*/, char */*buf*/, size_t /*sz*/);
180
181/* --- @pixie_getpass@ --- *
182 *
183 * Arguments: @const char *prompt@ = pointer to prompt string
184 * @char *buf@ = pointer to buffer
185 * @size_t sz@ = size of buffer
186 *
187 * Returns: Zero if it worked OK, nonzero otherwise.
188 *
189 * Use: Reads a passphrase from the terminal or some other requested
190 * source.
191 */
192
193extern int pixie_getpass(const char */*prompt*/,
194 char */*buf*/, size_t /*sz*/);
195
196/*----- That's all, folks -------------------------------------------------*/
197
198#ifdef __cplusplus
199 }
200#endif
201
202#endif