2
0

ui_locl.h 3.8 KB

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