sync with OpenBSD -current

This commit is contained in:
purplerain 2024-01-08 00:39:27 +00:00
parent a2b5593ce1
commit 19c768bf4f
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
67 changed files with 1526 additions and 522 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: evp_key.c,v 1.30 2023/07/07 19:37:53 beck Exp $ */
/* $OpenBSD: evp_key.c,v 1.33 2024/01/05 10:18:52 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -75,18 +75,17 @@ EVP_set_pw_prompt(const char *prompt)
{
if (prompt == NULL)
prompt_string[0] = '\0';
else {
else
strlcpy(prompt_string, prompt, sizeof(prompt_string));
}
}
char *
EVP_get_pw_prompt(void)
{
if (prompt_string[0] == '\0')
return (NULL);
else
return (prompt_string);
return NULL;
return prompt_string;
}
int
@ -99,30 +98,35 @@ int
EVP_read_pw_string_min(char *buf, int min, int len, const char *prompt,
int verify)
{
int ret;
UI *ui = NULL;
char buff[BUFSIZ];
UI *ui;
int ret = -1;
if (len > BUFSIZ)
len = BUFSIZ;
/* Ensure that 0 <= min <= len - 1. In particular, 1 <= len. */
if (min < 0 || len - 1 < min)
return -1;
if ((prompt == NULL) && (prompt_string[0] != '\0'))
goto err;
if (prompt == NULL && prompt_string[0] != '\0')
prompt = prompt_string;
ui = UI_new();
if (ui == NULL)
return -1;
if ((ui = UI_new()) == NULL)
goto err;
if (UI_add_input_string(ui, prompt, 0, buf, min, len - 1) < 0)
return -1;
goto err;
if (verify) {
if (UI_add_verify_string(ui, prompt, 0, buff, min, len - 1, buf)
< 0)
return -1;
if (UI_add_verify_string(ui, prompt, 0, buff, min, len - 1,
buf) < 0)
goto err;
}
ret = UI_process(ui);
err:
UI_free(ui);
explicit_bzero(buff, BUFSIZ);
return ret;
}
@ -150,7 +154,7 @@ EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
}
if (data == NULL)
return (nkey);
return nkey;
EVP_MD_CTX_init(&c);
for (;;) {