diff options
author | Richard Levitte <levitte@openssl.org> | 2016-03-21 18:08:57 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2016-03-31 13:32:01 +0200 |
commit | 923b1857decf4440b13b82f2aa7cf1189327d1a3 (patch) | |
tree | 6b6a6387610cdad0b7a1bdbb0b23da12ac80bc94 /apps/enc.c | |
parent | 4de9913b8c2a11f17258a2ad5e357046fd221360 (diff) |
Fix "no-ui" configuration
Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'apps/enc.c')
-rw-r--r-- | apps/enc.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/apps/enc.c b/apps/enc.c index 520ee47ebe..77df79d953 100644 --- a/apps/enc.c +++ b/apps/enc.c @@ -347,26 +347,33 @@ int enc_main(int argc, char **argv) } if ((str == NULL) && (cipher != NULL) && (hkey == NULL)) { - for (;;) { - char prompt[200]; - - BIO_snprintf(prompt, sizeof prompt, "enter %s %s password:", - OBJ_nid2ln(EVP_CIPHER_nid(cipher)), - (enc) ? "encryption" : "decryption"); - strbuf[0] = '\0'; - i = EVP_read_pw_string((char *)strbuf, SIZE, prompt, enc); - if (i == 0) { - if (strbuf[0] == '\0') { - ret = 1; + if (1) { +#ifndef OPENSSL_NO_UI + for (;;) { + char prompt[200]; + + BIO_snprintf(prompt, sizeof prompt, "enter %s %s password:", + OBJ_nid2ln(EVP_CIPHER_nid(cipher)), + (enc) ? "encryption" : "decryption"); + strbuf[0] = '\0'; + i = EVP_read_pw_string((char *)strbuf, SIZE, prompt, enc); + if (i == 0) { + if (strbuf[0] == '\0') { + ret = 1; + goto end; + } + str = strbuf; + break; + } + if (i < 0) { + BIO_printf(bio_err, "bad password read\n"); goto end; } - str = strbuf; - break; - } - if (i < 0) { - BIO_printf(bio_err, "bad password read\n"); - goto end; } + } else { +#endif + BIO_printf(bio_err, "password required\n"); + goto end; } } |