Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 1 | /* |
Rich Salz | aa6bb13 | 2016-05-17 15:38:09 -0400 | [diff] [blame] | 2 | * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. |
Richard Levitte | a63d5ea | 2001-05-06 23:19:37 +0000 | [diff] [blame] | 3 | * |
Rich Salz | aa6bb13 | 2016-05-17 15:38:09 -0400 | [diff] [blame] | 4 | * Licensed under the OpenSSL license (the "License"). You may not use |
| 5 | * this file except in compliance with the License. You can obtain a copy |
| 6 | * in the file LICENSE in the source distribution or at |
| 7 | * https://www.openssl.org/source/license.html |
Richard Levitte | a63d5ea | 2001-05-06 23:19:37 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef HEADER_UI_LOCL_H |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 11 | # define HEADER_UI_LOCL_H |
Richard Levitte | a63d5ea | 2001-05-06 23:19:37 +0000 | [diff] [blame] | 12 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 13 | # include <openssl/ui.h> |
| 14 | # include <openssl/crypto.h> |
Richard Levitte | a63d5ea | 2001-05-06 23:19:37 +0000 | [diff] [blame] | 15 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 16 | # ifdef _ |
| 17 | # undef _ |
| 18 | # endif |
Andy Polyakov | 0491e05 | 2005-08-07 22:21:49 +0000 | [diff] [blame] | 19 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 20 | struct ui_method_st { |
| 21 | char *name; |
| 22 | /* |
| 23 | * All the functions return 1 or non-NULL for success and 0 or NULL for |
| 24 | * failure |
| 25 | */ |
| 26 | /* |
| 27 | * Open whatever channel for this, be it the console, an X window or |
| 28 | * whatever. This function should use the ex_data structure to save |
| 29 | * intermediate data. |
| 30 | */ |
| 31 | int (*ui_open_session) (UI *ui); |
| 32 | int (*ui_write_string) (UI *ui, UI_STRING *uis); |
| 33 | /* |
| 34 | * Flush the output. If a GUI dialog box is used, this function can be |
| 35 | * used to actually display it. |
| 36 | */ |
| 37 | int (*ui_flush) (UI *ui); |
| 38 | int (*ui_read_string) (UI *ui, UI_STRING *uis); |
| 39 | int (*ui_close_session) (UI *ui); |
| 40 | /* |
Richard Levitte | 545360c | 2017-05-28 09:35:11 +0200 | [diff] [blame] | 41 | * Duplicate the ui_data that often comes alongside a ui_method. This |
| 42 | * allows some backends to save away UI information for later use. |
| 43 | */ |
| 44 | void *(*ui_duplicate_data) (UI *ui, void *ui_data); |
| 45 | void (*ui_destroy_data) (UI *ui, void *ui_data); |
| 46 | /* |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 47 | * Construct a prompt in a user-defined manner. object_desc is a textual |
| 48 | * short description of the object, for example "pass phrase", and |
| 49 | * object_name is the name of the object (might be a card name or a file |
| 50 | * name. The returned string shall always be allocated on the heap with |
| 51 | * OPENSSL_malloc(), and need to be free'd with OPENSSL_free(). |
| 52 | */ |
| 53 | char *(*ui_construct_prompt) (UI *ui, const char *object_desc, |
| 54 | const char *object_name); |
Richard Levitte | 18cfc66 | 2016-12-06 14:36:04 +0100 | [diff] [blame] | 55 | /* |
| 56 | * UI_METHOD specific application data. |
| 57 | */ |
| 58 | CRYPTO_EX_DATA ex_data; |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 59 | }; |
Richard Levitte | a63d5ea | 2001-05-06 23:19:37 +0000 | [diff] [blame] | 60 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 61 | struct ui_string_st { |
| 62 | enum UI_string_types type; /* Input */ |
| 63 | const char *out_string; /* Input */ |
| 64 | int input_flags; /* Flags from the user */ |
| 65 | /* |
| 66 | * The following parameters are completely irrelevant for UIT_INFO, and |
| 67 | * can therefore be set to 0 or NULL |
| 68 | */ |
| 69 | char *result_buf; /* Input and Output: If not NULL, |
| 70 | * user-defined with size in result_maxsize. |
| 71 | * Otherwise, it may be allocated by the UI |
| 72 | * routine, meaning result_minsize is going |
| 73 | * to be overwritten. */ |
Richard Levitte | 4e049e2 | 2017-07-01 12:39:51 +0200 | [diff] [blame] | 74 | size_t result_len; |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 75 | union { |
| 76 | struct { |
| 77 | int result_minsize; /* Input: minimum required size of the |
| 78 | * result. */ |
| 79 | int result_maxsize; /* Input: maximum permitted size of the |
| 80 | * result */ |
| 81 | const char *test_buf; /* Input: test string to verify against */ |
| 82 | } string_data; |
| 83 | struct { |
| 84 | const char *action_desc; /* Input */ |
| 85 | const char *ok_chars; /* Input */ |
| 86 | const char *cancel_chars; /* Input */ |
| 87 | } boolean_data; |
| 88 | } _; |
Richard Levitte | 9ad0f68 | 2001-06-19 15:52:00 +0000 | [diff] [blame] | 89 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 90 | # define OUT_STRING_FREEABLE 0x01 |
| 91 | int flags; /* flags for internal use */ |
| 92 | }; |
Richard Levitte | 9ad0f68 | 2001-06-19 15:52:00 +0000 | [diff] [blame] | 93 | |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 94 | struct ui_st { |
| 95 | const UI_METHOD *meth; |
| 96 | STACK_OF(UI_STRING) *strings; /* We might want to prompt for more than |
| 97 | * one thing at a time, and with different |
| 98 | * echoing status. */ |
| 99 | void *user_data; |
| 100 | CRYPTO_EX_DATA ex_data; |
| 101 | # define UI_FLAG_REDOABLE 0x0001 |
Richard Levitte | 545360c | 2017-05-28 09:35:11 +0200 | [diff] [blame] | 102 | # define UI_FLAG_DUPL_DATA 0x0002 /* user_data was duplicated */ |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 103 | # define UI_FLAG_PRINT_ERRORS 0x0100 |
| 104 | int flags; |
Alessandro Ghedini | 41cfbcc | 2016-02-29 17:12:25 +0000 | [diff] [blame] | 105 | |
| 106 | CRYPTO_RWLOCK *lock; |
Matt Caswell | 0f113f3 | 2015-01-22 03:40:55 +0000 | [diff] [blame] | 107 | }; |
Richard Levitte | a63d5ea | 2001-05-06 23:19:37 +0000 | [diff] [blame] | 108 | |
| 109 | #endif |