diff options
author | Richard Levitte <levitte@openssl.org> | 2001-05-06 23:19:37 +0000 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2001-05-06 23:19:37 +0000 |
commit | a63d5eaab28a20463818b43a76ce8acd19d58812 (patch) | |
tree | 5f37af72a5a2d7462cb4b8d1bdce2e939798db51 /crypto/evp/evp_key.c | |
parent | 6af59bc095a51caa6deb092f911b44dd09b0eb0d (diff) |
Add a general user interface API. This is designed to replace things
like des_read_password and friends (backward compatibility functions
using this new API are provided). The purpose is to remove prompting
functions from the DES code section as well as provide for prompting
through dialog boxes in a window system and the like.
Diffstat (limited to 'crypto/evp/evp_key.c')
-rw-r--r-- | crypto/evp/evp_key.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/crypto/evp/evp_key.c b/crypto/evp/evp_key.c index 26cdcdf195..91738a273f 100644 --- a/crypto/evp/evp_key.c +++ b/crypto/evp/evp_key.c @@ -61,6 +61,7 @@ #include <openssl/x509.h> #include <openssl/objects.h> #include <openssl/evp.h> +#include <openssl/ui.h> /* should be init to zeros. */ static char prompt_string[80]; @@ -86,13 +87,21 @@ char *EVP_get_pw_prompt(void) * this function will fail */ int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify) { -#ifndef OPENSSL_NO_DES + int ret; + char buff[BUFSIZ]; + UI *ui; + if ((prompt == NULL) && (prompt_string[0] != '\0')) prompt=prompt_string; - return(des_read_pw_string(buf,len,prompt,verify)); -#else - return -1; -#endif + ui = UI_new(); + UI_add_input_string(ui,prompt,0,buf,0,(len>=BUFSIZ)?BUFSIZ-1:len); + if (verify) + UI_add_verify_string(ui,prompt,0, + buff,0,(len>=BUFSIZ)?BUFSIZ-1:len,buf); + ret = UI_process(ui); + UI_free(ui); + memset(buff,0,BUFSIZ); + return ret; } int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, |