summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ui
diff options
context:
space:
mode:
authordjm <>2008-09-06 12:15:56 +0000
committerdjm <>2008-09-06 12:15:56 +0000
commit5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80 (patch)
treeaba68249883aa9d2361d92eef69a81d0c4961732 /src/lib/libcrypto/ui
parentf6198d4d0ab97685dc56be2d48715ed39fcc74b9 (diff)
downloadopenbsd-5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80.tar.gz
openbsd-5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80.tar.bz2
openbsd-5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80.zip
import of OpenSSL 0.9.8h
Diffstat (limited to 'src/lib/libcrypto/ui')
-rw-r--r--src/lib/libcrypto/ui/ui.h20
-rw-r--r--src/lib/libcrypto/ui/ui_err.c9
-rw-r--r--src/lib/libcrypto/ui/ui_lib.c8
-rw-r--r--src/lib/libcrypto/ui/ui_locl.h5
-rw-r--r--src/lib/libcrypto/ui/ui_openssl.c48
-rw-r--r--src/lib/libcrypto/ui/ui_util.c2
6 files changed, 61 insertions, 31 deletions
diff --git a/src/lib/libcrypto/ui/ui.h b/src/lib/libcrypto/ui/ui.h
index 735a2d988e..018296412b 100644
--- a/src/lib/libcrypto/ui/ui.h
+++ b/src/lib/libcrypto/ui/ui.h
@@ -59,25 +59,19 @@
59#ifndef HEADER_UI_H 59#ifndef HEADER_UI_H
60#define HEADER_UI_H 60#define HEADER_UI_H
61 61
62#ifndef OPENSSL_NO_DEPRECATED
62#include <openssl/crypto.h> 63#include <openssl/crypto.h>
64#endif
63#include <openssl/safestack.h> 65#include <openssl/safestack.h>
66#include <openssl/ossl_typ.h>
64 67
65#ifdef __cplusplus 68#ifdef __cplusplus
66extern "C" { 69extern "C" {
67#endif 70#endif
68 71
69/* The UI type is a holder for a specific user interface session. It can 72/* Declared already in ossl_typ.h */
70 contain an illimited number of informational or error strings as well 73/* typedef struct ui_st UI; */
71 as things to prompt for, both passwords (noecho mode) and others (echo 74/* typedef struct ui_method_st UI_METHOD; */
72 mode), and verification of the same. All of these are called strings,
73 and are further described below. */
74typedef struct ui_st UI;
75
76/* All instances of UI have a reference to a method structure, which is a
77 ordered vector of functions that implement the lower level things to do.
78 There is an instruction on the implementation further down, in the section
79 for method implementors. */
80typedef struct ui_method_st UI_METHOD;
81 75
82 76
83/* All the following functions return -1 or NULL on error and in some cases 77/* All the following functions return -1 or NULL on error and in some cases
@@ -217,7 +211,7 @@ int UI_process(UI *ui);
217/* Give a user interface parametrised control commands. This can be used to 211/* Give a user interface parametrised control commands. This can be used to
218 send down an integer, a data pointer or a function pointer, as well as 212 send down an integer, a data pointer or a function pointer, as well as
219 be used to get information from a UI. */ 213 be used to get information from a UI. */
220int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)()); 214int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)(void));
221 215
222/* The commands */ 216/* The commands */
223/* Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the 217/* Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the
diff --git a/src/lib/libcrypto/ui/ui_err.c b/src/lib/libcrypto/ui/ui_err.c
index d983cdd66f..786bd0dbc3 100644
--- a/src/lib/libcrypto/ui/ui_err.c
+++ b/src/lib/libcrypto/ui/ui_err.c
@@ -101,15 +101,12 @@ static ERR_STRING_DATA UI_str_reasons[]=
101 101
102void ERR_load_UI_strings(void) 102void ERR_load_UI_strings(void)
103 { 103 {
104 static int init=1; 104#ifndef OPENSSL_NO_ERR
105 105
106 if (init) 106 if (ERR_func_error_string(UI_str_functs[0].error) == NULL)
107 { 107 {
108 init=0;
109#ifndef OPENSSL_NO_ERR
110 ERR_load_strings(0,UI_str_functs); 108 ERR_load_strings(0,UI_str_functs);
111 ERR_load_strings(0,UI_str_reasons); 109 ERR_load_strings(0,UI_str_reasons);
112#endif
113
114 } 110 }
111#endif
115 } 112 }
diff --git a/src/lib/libcrypto/ui/ui_lib.c b/src/lib/libcrypto/ui/ui_lib.c
index dbc9711a2d..7ab249c3be 100644
--- a/src/lib/libcrypto/ui/ui_lib.c
+++ b/src/lib/libcrypto/ui/ui_lib.c
@@ -57,12 +57,12 @@
57 */ 57 */
58 58
59#include <string.h> 59#include <string.h>
60#include "cryptlib.h"
60#include <openssl/e_os2.h> 61#include <openssl/e_os2.h>
61#include <openssl/buffer.h> 62#include <openssl/buffer.h>
62#include <openssl/ui.h> 63#include <openssl/ui.h>
63#include <openssl/err.h> 64#include <openssl/err.h>
64#include "ui_locl.h" 65#include "ui_locl.h"
65#include "cryptlib.h"
66 66
67IMPLEMENT_STACK_OF(UI_STRING_ST) 67IMPLEMENT_STACK_OF(UI_STRING_ST)
68 68
@@ -545,7 +545,7 @@ int UI_process(UI *ui)
545 return ok; 545 return ok;
546 } 546 }
547 547
548int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)()) 548int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)(void))
549 { 549 {
550 if (ui == NULL) 550 if (ui == NULL)
551 { 551 {
@@ -620,8 +620,10 @@ UI_METHOD *UI_create_method(char *name)
620 UI_METHOD *ui_method = (UI_METHOD *)OPENSSL_malloc(sizeof(UI_METHOD)); 620 UI_METHOD *ui_method = (UI_METHOD *)OPENSSL_malloc(sizeof(UI_METHOD));
621 621
622 if (ui_method) 622 if (ui_method)
623 {
623 memset(ui_method, 0, sizeof(*ui_method)); 624 memset(ui_method, 0, sizeof(*ui_method));
624 ui_method->name = BUF_strdup(name); 625 ui_method->name = BUF_strdup(name);
626 }
625 return ui_method; 627 return ui_method;
626 } 628 }
627 629
diff --git a/src/lib/libcrypto/ui/ui_locl.h b/src/lib/libcrypto/ui/ui_locl.h
index 7d3a75a619..aa4a55637d 100644
--- a/src/lib/libcrypto/ui/ui_locl.h
+++ b/src/lib/libcrypto/ui/ui_locl.h
@@ -60,6 +60,11 @@
60#define HEADER_UI_LOCL_H 60#define HEADER_UI_LOCL_H
61 61
62#include <openssl/ui.h> 62#include <openssl/ui.h>
63#include <openssl/crypto.h>
64
65#ifdef _
66#undef _
67#endif
63 68
64struct ui_method_st 69struct ui_method_st
65 { 70 {
diff --git a/src/lib/libcrypto/ui/ui_openssl.c b/src/lib/libcrypto/ui/ui_openssl.c
index 75318d48a1..1f23a45a33 100644
--- a/src/lib/libcrypto/ui/ui_openssl.c
+++ b/src/lib/libcrypto/ui/ui_openssl.c
@@ -117,6 +117,17 @@
117 117
118#include <openssl/e_os2.h> 118#include <openssl/e_os2.h>
119 119
120/* need for #define _POSIX_C_SOURCE arises whenever you pass -ansi to gcc
121 * [maybe others?], because it masks interfaces not discussed in standard,
122 * sigaction and fileno included. -pedantic would be more appropriate for
123 * the intended purposes, but we can't prevent users from adding -ansi.
124 */
125#define _POSIX_C_SOURCE 1
126#include <signal.h>
127#include <stdio.h>
128#include <string.h>
129#include <errno.h>
130
120#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) 131#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS)
121# ifdef OPENSSL_UNISTD 132# ifdef OPENSSL_UNISTD
122# include OPENSSL_UNISTD 133# include OPENSSL_UNISTD
@@ -145,10 +156,6 @@
145/* 06-Apr-92 Luke Brennan Support for VMS */ 156/* 06-Apr-92 Luke Brennan Support for VMS */
146#include "ui_locl.h" 157#include "ui_locl.h"
147#include "cryptlib.h" 158#include "cryptlib.h"
148#include <signal.h>
149#include <stdio.h>
150#include <string.h>
151#include <errno.h>
152 159
153#ifdef OPENSSL_SYS_VMS /* prototypes for sys$whatever */ 160#ifdef OPENSSL_SYS_VMS /* prototypes for sys$whatever */
154# include <starlet.h> 161# include <starlet.h>
@@ -199,6 +206,12 @@
199#undef SGTTY 206#undef SGTTY
200#endif 207#endif
201 208
209#if defined(OPENSSL_SYS_NETWARE)
210#undef TERMIOS
211#undef TERMIO
212#undef SGTTY
213#endif
214
202#ifdef TERMIOS 215#ifdef TERMIOS
203# include <termios.h> 216# include <termios.h>
204# define TTY_STRUCT struct termios 217# define TTY_STRUCT struct termios
@@ -247,7 +260,7 @@ struct IOSB {
247 typedef int sig_atomic_t; 260 typedef int sig_atomic_t;
248#endif 261#endif
249 262
250#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(MAC_OS_GUSI_SOURCE) 263#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(MAC_OS_GUSI_SOURCE) || defined(OPENSSL_SYS_NETWARE)
251/* 264/*
252 * This one needs work. As a matter of fact the code is unoperational 265 * This one needs work. As a matter of fact the code is unoperational
253 * and this is only a trick to get it compiled. 266 * and this is only a trick to get it compiled.
@@ -460,7 +473,7 @@ static int open_console(UI *ui)
460 CRYPTO_w_lock(CRYPTO_LOCK_UI); 473 CRYPTO_w_lock(CRYPTO_LOCK_UI);
461 is_a_tty = 1; 474 is_a_tty = 1;
462 475
463#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VXWORKS) 476#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE)
464 tty_in=stdin; 477 tty_in=stdin;
465 tty_out=stderr; 478 tty_out=stderr;
466#else 479#else
@@ -476,7 +489,7 @@ static int open_console(UI *ui)
476#endif 489#endif
477 490
478#if defined(TTY_get) && !defined(OPENSSL_SYS_VMS) 491#if defined(TTY_get) && !defined(OPENSSL_SYS_VMS)
479 if (TTY_get(fileno(tty_in),&tty_orig) == -1) 492 if (TTY_get(fileno(tty_in),&tty_orig) == -1)
480 { 493 {
481#ifdef ENOTTY 494#ifdef ENOTTY
482 if (errno == ENOTTY) 495 if (errno == ENOTTY)
@@ -565,7 +578,9 @@ static int close_console(UI *ui)
565/* Internal functions to handle signals and act on them */ 578/* Internal functions to handle signals and act on them */
566static void pushsig(void) 579static void pushsig(void)
567 { 580 {
581#ifndef OPENSSL_SYS_WIN32
568 int i; 582 int i;
583#endif
569#ifdef SIGACTION 584#ifdef SIGACTION
570 struct sigaction sa; 585 struct sigaction sa;
571 586
@@ -573,6 +588,14 @@ static void pushsig(void)
573 sa.sa_handler=recsig; 588 sa.sa_handler=recsig;
574#endif 589#endif
575 590
591#ifdef OPENSSL_SYS_WIN32
592 savsig[SIGABRT]=signal(SIGABRT,recsig);
593 savsig[SIGFPE]=signal(SIGFPE,recsig);
594 savsig[SIGILL]=signal(SIGILL,recsig);
595 savsig[SIGINT]=signal(SIGINT,recsig);
596 savsig[SIGSEGV]=signal(SIGSEGV,recsig);
597 savsig[SIGTERM]=signal(SIGTERM,recsig);
598#else
576 for (i=1; i<NX509_SIG; i++) 599 for (i=1; i<NX509_SIG; i++)
577 { 600 {
578#ifdef SIGUSR1 601#ifdef SIGUSR1
@@ -593,6 +616,7 @@ static void pushsig(void)
593 savsig[i]=signal(i,recsig); 616 savsig[i]=signal(i,recsig);
594#endif 617#endif
595 } 618 }
619#endif
596 620
597#ifdef SIGWINCH 621#ifdef SIGWINCH
598 signal(SIGWINCH,SIG_DFL); 622 signal(SIGWINCH,SIG_DFL);
@@ -601,8 +625,15 @@ static void pushsig(void)
601 625
602static void popsig(void) 626static void popsig(void)
603 { 627 {
628#ifdef OPENSSL_SYS_WIN32
629 signal(SIGABRT,savsig[SIGABRT]);
630 signal(SIGFPE,savsig[SIGFPE]);
631 signal(SIGILL,savsig[SIGILL]);
632 signal(SIGINT,savsig[SIGINT]);
633 signal(SIGSEGV,savsig[SIGSEGV]);
634 signal(SIGTERM,savsig[SIGTERM]);
635#else
604 int i; 636 int i;
605
606 for (i=1; i<NX509_SIG; i++) 637 for (i=1; i<NX509_SIG; i++)
607 { 638 {
608#ifdef SIGUSR1 639#ifdef SIGUSR1
@@ -619,6 +650,7 @@ static void popsig(void)
619 signal(i,savsig[i]); 650 signal(i,savsig[i]);
620#endif 651#endif
621 } 652 }
653#endif
622 } 654 }
623 655
624static void recsig(int i) 656static void recsig(int i)
diff --git a/src/lib/libcrypto/ui/ui_util.c b/src/lib/libcrypto/ui/ui_util.c
index 46bc8c1a9a..5d9760bb7b 100644
--- a/src/lib/libcrypto/ui/ui_util.c
+++ b/src/lib/libcrypto/ui/ui_util.c
@@ -54,7 +54,7 @@
54 */ 54 */
55 55
56#include <string.h> 56#include <string.h>
57#include <openssl/ui.h> 57#include "ui_locl.h"
58 58
59int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify) 59int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify)
60 { 60 {