remove getrnd() to sync with upstream (#735)

This commit is contained in:
Tess Gauthier 2024-08-01 14:04:37 -04:00 committed by GitHub
parent e829ad267c
commit 43c6e39474
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 0 additions and 52 deletions

View File

@ -107,58 +107,6 @@ _rs_init(u_char *buf, size_t n)
chacha_ivsetup(&rsx->rs_chacha, buf + KEYSZ);
}
#ifndef WITH_OPENSSL
#ifdef WINDOWS
#include <Wincrypt.h>
static void
getrnd(u_char *s, size_t len) {
HCRYPTPROV hProvider;
if (CryptAcquireContextW(&hProvider, 0, 0, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT | CRYPT_SILENT) == FALSE ||
CryptGenRandom(hProvider, len, s) == FALSE ||
CryptReleaseContext(hProvider, 0) == FALSE)
fatal("%s Crypto error: %d", __func__, GetLastError());
}
#else /* !WINDOWS */
# ifndef SSH_RANDOM_DEV
# define SSH_RANDOM_DEV "/dev/urandom"
# endif /* SSH_RANDOM_DEV */
static void
getrnd(u_char *s, size_t len)
{
int fd, save_errno;
ssize_t r;
size_t o = 0;
#ifdef HAVE_GETRANDOM
if ((r = getrandom(s, len, 0)) > 0 && (size_t)r == len)
return;
#endif /* HAVE_GETRANDOM */
if ((fd = open(SSH_RANDOM_DEV, O_RDONLY)) == -1) {
save_errno = errno;
/* Try egd/prngd before giving up. */
if (seed_from_prngd(s, len) == 0)
return;
fatal("Couldn't open %s: %s", SSH_RANDOM_DEV,
strerror(save_errno));
}
while (o < len) {
r = read(fd, s + o, len - o);
if (r < 0) {
if (errno == EAGAIN || errno == EINTR ||
errno == EWOULDBLOCK)
continue;
fatal("read %s: %s", SSH_RANDOM_DEV, strerror(errno));
}
o += r;
}
close(fd);
}
#endif /* !WINDOWS */
#endif /* WITH_OPENSSL */
static void
_rs_stir(void)
{