10Sstevel@tonic-gate /* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */ 20Sstevel@tonic-gate /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL 30Sstevel@tonic-gate * project 2001. 40Sstevel@tonic-gate */ 50Sstevel@tonic-gate /* ==================================================================== 60Sstevel@tonic-gate * Copyright (c) 2001 The OpenSSL Project. All rights reserved. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 90Sstevel@tonic-gate * modification, are permitted provided that the following conditions 100Sstevel@tonic-gate * are met: 110Sstevel@tonic-gate * 120Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright 130Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 140Sstevel@tonic-gate * 150Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 160Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in 170Sstevel@tonic-gate * the documentation and/or other materials provided with the 180Sstevel@tonic-gate * distribution. 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this 210Sstevel@tonic-gate * software must display the following acknowledgment: 220Sstevel@tonic-gate * "This product includes software developed by the OpenSSL Project 230Sstevel@tonic-gate * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 240Sstevel@tonic-gate * 250Sstevel@tonic-gate * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 260Sstevel@tonic-gate * endorse or promote products derived from this software without 270Sstevel@tonic-gate * prior written permission. For written permission, please contact 280Sstevel@tonic-gate * openssl-core@openssl.org. 290Sstevel@tonic-gate * 300Sstevel@tonic-gate * 5. Products derived from this software may not be called "OpenSSL" 310Sstevel@tonic-gate * nor may "OpenSSL" appear in their names without prior written 320Sstevel@tonic-gate * permission of the OpenSSL Project. 330Sstevel@tonic-gate * 340Sstevel@tonic-gate * 6. Redistributions of any form whatsoever must retain the following 350Sstevel@tonic-gate * acknowledgment: 360Sstevel@tonic-gate * "This product includes software developed by the OpenSSL Project 370Sstevel@tonic-gate * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 380Sstevel@tonic-gate * 390Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 400Sstevel@tonic-gate * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 410Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 420Sstevel@tonic-gate * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 430Sstevel@tonic-gate * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 440Sstevel@tonic-gate * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 450Sstevel@tonic-gate * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 460Sstevel@tonic-gate * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 470Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 480Sstevel@tonic-gate * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 490Sstevel@tonic-gate * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 500Sstevel@tonic-gate * OF THE POSSIBILITY OF SUCH DAMAGE. 510Sstevel@tonic-gate * ==================================================================== 520Sstevel@tonic-gate * 530Sstevel@tonic-gate * This product includes cryptographic software written by Eric Young 540Sstevel@tonic-gate * (eay@cryptsoft.com). This product includes software written by Tim 550Sstevel@tonic-gate * Hudson (tjh@cryptsoft.com). 560Sstevel@tonic-gate * 570Sstevel@tonic-gate */ 580Sstevel@tonic-gate 590Sstevel@tonic-gate #ifndef HEADER_UI_LOCL_H 600Sstevel@tonic-gate #define HEADER_UI_LOCL_H 610Sstevel@tonic-gate 620Sstevel@tonic-gate #include <openssl/ui.h> 63*2139Sjp161948 #include <openssl/crypto.h> 64*2139Sjp161948 65*2139Sjp161948 #ifdef _ 66*2139Sjp161948 #undef _ 67*2139Sjp161948 #endif 680Sstevel@tonic-gate 690Sstevel@tonic-gate struct ui_method_st 700Sstevel@tonic-gate { 710Sstevel@tonic-gate char *name; 720Sstevel@tonic-gate 730Sstevel@tonic-gate /* All the functions return 1 or non-NULL for success and 0 or NULL 740Sstevel@tonic-gate for failure */ 750Sstevel@tonic-gate 760Sstevel@tonic-gate /* Open whatever channel for this, be it the console, an X window 770Sstevel@tonic-gate or whatever. 780Sstevel@tonic-gate This function should use the ex_data structure to save 790Sstevel@tonic-gate intermediate data. */ 800Sstevel@tonic-gate int (*ui_open_session)(UI *ui); 810Sstevel@tonic-gate 820Sstevel@tonic-gate int (*ui_write_string)(UI *ui, UI_STRING *uis); 830Sstevel@tonic-gate 840Sstevel@tonic-gate /* Flush the output. If a GUI dialog box is used, this function can 850Sstevel@tonic-gate be used to actually display it. */ 860Sstevel@tonic-gate int (*ui_flush)(UI *ui); 870Sstevel@tonic-gate 880Sstevel@tonic-gate int (*ui_read_string)(UI *ui, UI_STRING *uis); 890Sstevel@tonic-gate 900Sstevel@tonic-gate int (*ui_close_session)(UI *ui); 910Sstevel@tonic-gate 920Sstevel@tonic-gate /* Construct a prompt in a user-defined manner. object_desc is a 930Sstevel@tonic-gate textual short description of the object, for example "pass phrase", 940Sstevel@tonic-gate and object_name is the name of the object (might be a card name or 950Sstevel@tonic-gate a file name. 960Sstevel@tonic-gate The returned string shall always be allocated on the heap with 970Sstevel@tonic-gate OPENSSL_malloc(), and need to be free'd with OPENSSL_free(). */ 980Sstevel@tonic-gate char *(*ui_construct_prompt)(UI *ui, const char *object_desc, 990Sstevel@tonic-gate const char *object_name); 1000Sstevel@tonic-gate }; 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate struct ui_string_st 1030Sstevel@tonic-gate { 1040Sstevel@tonic-gate enum UI_string_types type; /* Input */ 1050Sstevel@tonic-gate const char *out_string; /* Input */ 1060Sstevel@tonic-gate int input_flags; /* Flags from the user */ 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate /* The following parameters are completely irrelevant for UIT_INFO, 1090Sstevel@tonic-gate and can therefore be set to 0 or NULL */ 1100Sstevel@tonic-gate char *result_buf; /* Input and Output: If not NULL, user-defined 1110Sstevel@tonic-gate with size in result_maxsize. Otherwise, it 1120Sstevel@tonic-gate may be allocated by the UI routine, meaning 1130Sstevel@tonic-gate result_minsize is going to be overwritten.*/ 1140Sstevel@tonic-gate union 1150Sstevel@tonic-gate { 1160Sstevel@tonic-gate struct 1170Sstevel@tonic-gate { 1180Sstevel@tonic-gate int result_minsize; /* Input: minimum required 1190Sstevel@tonic-gate size of the result. 1200Sstevel@tonic-gate */ 1210Sstevel@tonic-gate int result_maxsize; /* Input: maximum permitted 1220Sstevel@tonic-gate size of the result */ 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate const char *test_buf; /* Input: test string to verify 1250Sstevel@tonic-gate against */ 1260Sstevel@tonic-gate } string_data; 1270Sstevel@tonic-gate struct 1280Sstevel@tonic-gate { 1290Sstevel@tonic-gate const char *action_desc; /* Input */ 1300Sstevel@tonic-gate const char *ok_chars; /* Input */ 1310Sstevel@tonic-gate const char *cancel_chars; /* Input */ 1320Sstevel@tonic-gate } boolean_data; 1330Sstevel@tonic-gate } _; 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate #define OUT_STRING_FREEABLE 0x01 1360Sstevel@tonic-gate int flags; /* flags for internal use */ 1370Sstevel@tonic-gate }; 1380Sstevel@tonic-gate 1390Sstevel@tonic-gate struct ui_st 1400Sstevel@tonic-gate { 1410Sstevel@tonic-gate const UI_METHOD *meth; 1420Sstevel@tonic-gate STACK_OF(UI_STRING) *strings; /* We might want to prompt for more 1430Sstevel@tonic-gate than one thing at a time, and 1440Sstevel@tonic-gate with different echoing status. */ 1450Sstevel@tonic-gate void *user_data; 1460Sstevel@tonic-gate CRYPTO_EX_DATA ex_data; 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate #define UI_FLAG_REDOABLE 0x0001 1490Sstevel@tonic-gate #define UI_FLAG_PRINT_ERRORS 0x0100 1500Sstevel@tonic-gate int flags; 1510Sstevel@tonic-gate }; 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate #endif 154