2016-05-17 19:38:09 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
2002-02-05 17:15:18 +00:00
|
|
|
*
|
2016-05-17 19:38:09 +00:00
|
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
2002-02-05 17:15:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
2004-05-17 18:01:28 +00:00
|
|
|
#include "ui_locl.h"
|
2002-02-05 17:15:18 +00:00
|
|
|
|
2015-09-11 18:56:32 +00:00
|
|
|
#ifndef BUFSIZ
|
|
|
|
#define BUFSIZ 256
|
|
|
|
#endif
|
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt,
|
|
|
|
int verify)
|
|
|
|
{
|
|
|
|
char buff[BUFSIZ];
|
|
|
|
int ret;
|
2002-02-05 17:15:18 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
ret =
|
|
|
|
UI_UTIL_read_pw(buf, buff, (length > BUFSIZ) ? BUFSIZ : length,
|
|
|
|
prompt, verify);
|
|
|
|
OPENSSL_cleanse(buff, BUFSIZ);
|
|
|
|
return (ret);
|
|
|
|
}
|
2002-02-05 17:15:18 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt,
|
|
|
|
int verify)
|
|
|
|
{
|
|
|
|
int ok = 0;
|
|
|
|
UI *ui;
|
2002-02-05 17:15:18 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
if (size < 1)
|
|
|
|
return -1;
|
2002-07-11 09:12:29 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
ui = UI_new();
|
2015-10-30 11:12:26 +00:00
|
|
|
if (ui != NULL) {
|
2015-01-22 03:40:55 +00:00
|
|
|
ok = UI_add_input_string(ui, prompt, 0, buf, 0, size - 1);
|
|
|
|
if (ok >= 0 && verify)
|
|
|
|
ok = UI_add_verify_string(ui, prompt, 0, buff, 0, size - 1, buf);
|
|
|
|
if (ok >= 0)
|
|
|
|
ok = UI_process(ui);
|
|
|
|
UI_free(ui);
|
|
|
|
}
|
|
|
|
if (ok > 0)
|
|
|
|
ok = 0;
|
|
|
|
return (ok);
|
|
|
|
}
|