From: Richard Levitte Date: Tue, 5 Feb 2002 17:15:18 +0000 (+0000) Subject: With the changed des_old API, let's complete the work by renaming the X-Git-Tag: OpenSSL-engine-0_9_6c^2^2~39 X-Git-Url: https://git.openssl.org/?p=openssl.git;a=commitdiff_plain;h=44bdb056d4c7c72494d5d4b702bbad5cc869df03 With the changed des_old API, let's complete the work by renaming the functions in ui_compat. This gave reason to rework that part more thoroughly, so here are the changes made: 1. Add DES_read_password() and DES_read_2passwords() with the same functionality as the corresponding old des_ functions, as a convenience to the users. 2. Add UI_UTIL_read_pw_string() and UI_UTIL_read_pw() with the functionality from des_read_pw_string() and des_read_pw(), again as a concenience to the users. 3. Rename des_read_password(), des_read_2passwords(), des_read_pw_string() and des_read_pw() by changing des_ to _ossl_old_des_, and add the usual mapping macros. 4. Move the implementation of des_read_password() and des_read_2passwords() to the des directory, since they are tightly tied to DES anyway. This change was inspired by a patch from Assar Westerlund : There are some functions that didn't get the kick-away-old-des-and- replace-des-with-DES action. Here's a patch that adds DES_ and des_ (in des_old.h) versions of des_read_pw_string et al. This patch includes some of the first des_old.h semi-colon macro fixes that I've already sent. --- diff --git a/crypto/des/Makefile.ssl b/crypto/des/Makefile.ssl index c6a42842a7..0e34b898a4 100644 --- a/crypto/des/Makefile.ssl +++ b/crypto/des/Makefile.ssl @@ -34,7 +34,7 @@ LIBSRC= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \ qud_cksm.c rand_key.c rpc_enc.c set_key.c \ des_enc.c fcrypt_b.c \ xcbc_enc.c \ - str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c des_old.c + str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c des_old.c read2pwd.c LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \ ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \ @@ -42,7 +42,7 @@ LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \ ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \ ${DES_ENC} \ fcrypt.o xcbc_enc.o rpc_enc.o cbc_cksm.o \ - ede_cbcm_enc.o des_old.o + ede_cbcm_enc.o des_old.o read2pwd.o SRC= $(LIBSRC) diff --git a/crypto/des/des.h b/crypto/des/des.h index 237113129d..6e4cdbd904 100644 --- a/crypto/des/des.h +++ b/crypto/des/des.h @@ -221,6 +221,10 @@ void DES_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length, void DES_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length, DES_key_schedule *schedule,DES_cblock *ivec,int *num); +int DES_read_password(DES_cblock *key, const char *prompt, int verify); +int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt, + int verify); + #define DES_fixup_key_parity DES_set_odd_parity #ifdef __cplusplus diff --git a/crypto/des/des_old.c b/crypto/des/des_old.c index 4219662214..e6cc1ce22d 100644 --- a/crypto/des/des_old.c +++ b/crypto/des/des_old.c @@ -223,6 +223,16 @@ void _ossl_old_des_random_key(des_cblock ret) { DES_random_key((DES_cblock *)ret); } +int _ossl_old_des_read_password(des_cblock *key, const char *prompt, + int verify) + { + return DES_read_password(key, prompt, verify); + } +int _ossl_old_des_read_2passwords(des_cblock *key1, des_cblock *key2, + const char *prompt, int verify) + { + return DES_read_2passwords(key1, key2, prompt, verify); + } void _ossl_old_des_set_odd_parity(des_cblock *key) { DES_set_odd_parity(key); diff --git a/crypto/des/des_old.h b/crypto/des/des_old.h index 734bfff5cc..9807415daa 100644 --- a/crypto/des/des_old.h +++ b/crypto/des/des_old.h @@ -161,6 +161,10 @@ typedef struct des_ks_struct _ossl_old_des_random_seed((k)) #define des_random_key(r)\ _ossl_old_des_random_key((r)) +#define des_read_password(k,p,v) \ + _ossl_old_des_read_password((k),(p),(v)) +#define des_read_2passwords(k1,k2,p,v) \ + _ossl_old_des_read_2passwords((k1),(k2),(p),(v)) #define des_set_odd_parity(k)\ _ossl_old_des_set_odd_parity((k)) #define des_is_weak_key(k)\ @@ -247,6 +251,9 @@ DES_LONG _ossl_old_des_quad_cksum(des_cblock *input,des_cblock *output, long length,int out_count,des_cblock *seed); void _ossl_old_des_random_seed(des_cblock key); void _ossl_old_des_random_key(des_cblock ret); +int _ossl_old_des_read_password(des_cblock *key,const char *prompt,int verify); +int _ossl_old_des_read_2passwords(des_cblock *key1,des_cblock *key2, + const char *prompt,int verify); void _ossl_old_des_set_odd_parity(des_cblock *key); int _ossl_old_des_is_weak_key(des_cblock *key); int _ossl_old_des_set_key(des_cblock *key,des_key_schedule schedule); @@ -296,4 +303,7 @@ void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long len } #endif +/* for DES_read_pw_string et al */ +#include + #endif diff --git a/crypto/des/read2pwd.c b/crypto/des/read2pwd.c index e7d8c12724..f0eef23d8d 100644 --- a/crypto/des/read2pwd.c +++ b/crypto/des/read2pwd.c @@ -1,4 +1,57 @@ /* crypto/des/read2pwd.c */ +/* ==================================================================== + * Copyright (c) 2001-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,41 +109,29 @@ * [including the GNU Public Licence.] */ -#include "des_locl.h" +#include #include -int des_read_password(des_cblock *key, const char *prompt, int verify) +int DES_read_password(DES_cblock *key, const char *prompt, int verify) { int ok; char buf[BUFSIZ],buff[BUFSIZ]; - UI *ui; - ui = UI_new(); - UI_add_input_string(ui,prompt,0,buf,0,BUFSIZ-1); - if (verify) - UI_add_verify_string(ui,prompt,0,buff,0,BUFSIZ-1,buf); - if ((ok=UI_process(ui)) == 0) - des_string_to_key(buf,key); - UI_free(ui); + if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) + DES_string_to_key(buf,key); memset(buf,0,BUFSIZ); memset(buff,0,BUFSIZ); return(ok); } -int des_read_2passwords(des_cblock *key1, des_cblock *key2, const char *prompt, +int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt, int verify) { int ok; char buf[BUFSIZ],buff[BUFSIZ]; - UI *ui; - ui = UI_new(); - UI_add_input_string(ui,prompt,0,buf,0,BUFSIZ-1); - if (verify) - UI_add_verify_string(ui,prompt,0,buff,0,BUFSIZ-1,buf); - if ((ok=UI_process(ui)) == 0) - des_string_to_2keys(buf,key1,key2); - UI_free(ui); + if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) + DES_string_to_2keys(buf,key1,key2); memset(buf,0,BUFSIZ); memset(buff,0,BUFSIZ); return(ok); diff --git a/crypto/ui/Makefile.ssl b/crypto/ui/Makefile.ssl index 24f62fd385..15afe0ccf0 100644 --- a/crypto/ui/Makefile.ssl +++ b/crypto/ui/Makefile.ssl @@ -27,8 +27,8 @@ COMPATSRC= ui_compat.c COMPATOBJ= ui_compat.o LIB=$(TOP)/libcrypto.a -LIBSRC= ui_err.c ui_lib.c ui_openssl.c $(COMPATSRC) -LIBOBJ= ui_err.o ui_lib.o ui_openssl.o $(COMPATOBJ) +LIBSRC= ui_err.c ui_lib.c ui_openssl.c ui_util.c $(COMPATSRC) +LIBOBJ= ui_err.o ui_lib.o ui_openssl.o ui_util.o $(COMPATOBJ) SRC= $(LIBSRC) diff --git a/crypto/ui/ui.h b/crypto/ui/ui.h index 233e846a45..735a2d988e 100644 --- a/crypto/ui/ui.h +++ b/crypto/ui/ui.h @@ -345,6 +345,11 @@ int UI_get_result_maxsize(UI_STRING *uis); int UI_set_result(UI *ui, UI_STRING *uis, const char *result); +/* A couple of popular utility functions */ +int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify); +int UI_UTIL_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); + + /* BEGIN ERROR CODES */ /* The following lines are auto generated by the script mkerr.pl. Any changes * made after this point may be overwritten when the script is next run. diff --git a/crypto/ui/ui_compat.c b/crypto/ui/ui_compat.c index 2b4429416f..13e0f70d90 100644 --- a/crypto/ui/ui_compat.c +++ b/crypto/ui/ui_compat.c @@ -1,117 +1,67 @@ /* crypto/ui/ui_compat.c -*- mode:C; c-file-style: "eay" -*- */ -/* This was previously crypto/des/read2pwd.c and partly crypto/des/read_pwd.c */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. +/* ==================================================================== + * Copyright (c) 2001-2002 The OpenSSL Project. All rights reserved. * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * */ #include #include -#ifndef OPENSSL_NO_DES -int des_read_password(DES_cblock *key, const char *prompt, int verify) +int _ossl_old_des_read_pw_string(char *buf,int length,const char *prompt,int verify) { - int ok; - char buf[BUFSIZ],buff[BUFSIZ]; - - if ((ok=des_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) - DES_string_to_key(buf,key); - memset(buf,0,BUFSIZ); - memset(buff,0,BUFSIZ); - return(ok); + return UI_UTIL_read_pw_string(buf, length, prompt, verify); } -int des_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt, - int verify) +int _ossl_old_des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify) { - int ok; - char buf[BUFSIZ],buff[BUFSIZ]; - - if ((ok=des_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) - DES_string_to_2keys(buf,key1,key2); - memset(buf,0,BUFSIZ); - memset(buff,0,BUFSIZ); - return(ok); - } -#endif - -int des_read_pw_string(char *buf,int length,const char *prompt,int verify) - { - char buff[BUFSIZ]; - int ret; - - ret=des_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify); - memset(buff,0,BUFSIZ); - return(ret); - } - -int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify) - { - int ok = 0; - UI *ui; - - ui = UI_new(); - if (ui) - { - ok = UI_add_input_string(ui,prompt,0,buf,0,BUFSIZ-1); - if (ok == 0 && verify) - ok = UI_add_verify_string(ui,prompt,0,buff,0,BUFSIZ-1, - buf); - if (ok == 0) - ok=UI_process(ui); - UI_free(ui); - } - return(ok); + return UI_UTIL_read_pw(buf, buff, size, prompt, verify); } diff --git a/crypto/ui/ui_compat.h b/crypto/ui/ui_compat.h index a7f62a4751..f33023718a 100644 --- a/crypto/ui/ui_compat.h +++ b/crypto/ui/ui_compat.h @@ -61,9 +61,6 @@ #include #include -#ifndef OPENSSL_NO_DES -#include -#endif #ifdef __cplusplus extern "C" { @@ -72,14 +69,13 @@ extern "C" { /* The following functions were previously part of the DES section, and are provided here for backward compatibility reasons. */ -#ifndef OPENSSL_NO_DES -int des_read_password(DES_cblock *key,const char *prompt,int verify); -int des_read_2passwords(DES_cblock *key1,DES_cblock *key2, - const char *prompt,int verify); -#endif +#define des_read_pw_string(b,l,p,v) \ + _ossl_old_des_read_pw_string((b),(l),(p),(v)) +#define des_read_pw(b,bf,s,p,v) \ + _ossl_old_des_read_pw_string((b),(bf),(s),(p),(v)) -int des_read_pw_string(char *buf,int length,const char *prompt,int verify); -int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); +int _ossl_old_des_read_pw_string(char *buf,int length,const char *prompt,int verify); +int _ossl_old_des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); #ifdef __cplusplus } diff --git a/crypto/ui/ui_util.c b/crypto/ui/ui_util.c new file mode 100644 index 0000000000..7c6f7d3a73 --- /dev/null +++ b/crypto/ui/ui_util.c @@ -0,0 +1,86 @@ +/* crypto/ui/ui_util.c -*- mode:C; c-file-style: "eay" -*- */ +/* ==================================================================== + * Copyright (c) 2001-2002 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include +#include + +int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify) + { + char buff[BUFSIZ]; + int ret; + + ret=UI_UTIL_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify); + memset(buff,0,BUFSIZ); + return(ret); + } + +int UI_UTIL_read_pw(char *buf,char *buff,int size,const char *prompt,int verify) + { + int ok = 0; + UI *ui; + + ui = UI_new(); + if (ui) + { + ok = UI_add_input_string(ui,prompt,0,buf,0,BUFSIZ-1); + if (ok == 0 && verify) + ok = UI_add_verify_string(ui,prompt,0,buff,0,BUFSIZ-1, + buf); + if (ok == 0) + ok=UI_process(ui); + UI_free(ui); + } + return(ok); + }