| 1 | /* -*-c-*- |
| 2 | * |
| 3 | * Reading passphrases |
| 4 | * |
| 5 | * (c) 1999 Straylight/Edgeware |
| 6 | */ |
| 7 | |
| 8 | /*----- Licensing notice --------------------------------------------------* |
| 9 | * |
| 10 | * This file is part of Catacomb. |
| 11 | * |
| 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. |
| 16 | * |
| 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. |
| 21 | * |
| 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, |
| 25 | * MA 02111-1307, USA. |
| 26 | */ |
| 27 | |
| 28 | #ifndef CATACOMB_PASSPHRASE_H |
| 29 | #define CATACOMB_PASSPHRASE_H |
| 30 | |
| 31 | #ifdef __cplusplus |
| 32 | extern "C" { |
| 33 | #endif |
| 34 | |
| 35 | /*----- Header files ------------------------------------------------------*/ |
| 36 | |
| 37 | #include <stddef.h> |
| 38 | |
| 39 | /*----- Data structures ---------------------------------------------------*/ |
| 40 | |
| 41 | /* --- Passphrase modes --- * |
| 42 | * |
| 43 | * @PMODE_VERIFY@ requests that the passphrase be repeated to make sure it's |
| 44 | * right. |
| 45 | */ |
| 46 | |
| 47 | enum { |
| 48 | PMODE_READ, |
| 49 | PMODE_VERIFY |
| 50 | }; |
| 51 | |
| 52 | /*----- Functions provided ------------------------------------------------*/ |
| 53 | |
| 54 | /* --- @passphrase_connect@ --- |
| 55 | * |
| 56 | * Arguments: @const char *sock@ = socket name to connect to, or null for |
| 57 | * default |
| 58 | * |
| 59 | * Returns: Zero if OK, nonzero if it failed |
| 60 | * |
| 61 | * Use: Attempts to connect to the passphrase pixie. |
| 62 | */ |
| 63 | |
| 64 | extern int passphrase_connect(const char */*sock*/); |
| 65 | |
| 66 | /* --- @passphrase_read@ --- * |
| 67 | * |
| 68 | * Arguments: @const char *tag@ = pointer to passphrase tag string |
| 69 | * @unsigned mode@ = reading mode |
| 70 | * @char *buf@ = pointer to destination buffer |
| 71 | * @size_t sz@ = size of destination buffer |
| 72 | * |
| 73 | * Returns: Zero if successful, nonzero on failure. |
| 74 | * |
| 75 | * Use: Reads a passphrase from the user, using some system-specific |
| 76 | * secure mechanism. The mechanism may keep a cache of |
| 77 | * passphrases, so the user may not necessarily be prompted. |
| 78 | */ |
| 79 | |
| 80 | extern int passphrase_read(const char */*tag*/, unsigned /*mode*/, |
| 81 | char */*buf*/, size_t /*sz*/); |
| 82 | |
| 83 | /* --- @passphrase_cancel@ --- * |
| 84 | * |
| 85 | * Arguments: @const char *tag@ = pointer to passphrase tag string |
| 86 | * |
| 87 | * Returns: --- |
| 88 | * |
| 89 | * Use: Attempts to make the passphrase cache forget about a |
| 90 | * particular passphrase. This may be useful if the passphrase |
| 91 | * turns out to be wrong, or if the user is attempting to change |
| 92 | * the passphrase. |
| 93 | */ |
| 94 | |
| 95 | extern void passphrase_cancel(const char */*tag*/); |
| 96 | |
| 97 | /*----- That's all, folks -------------------------------------------------*/ |
| 98 | |
| 99 | #ifdef __cplusplus |
| 100 | } |
| 101 | #endif |
| 102 | |
| 103 | #endif |