diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/stand/efi32/efirng.c | 9 | ||||
-rw-r--r-- | sys/arch/amd64/stand/efi64/efirng.c | 9 | ||||
-rw-r--r-- | sys/arch/amd64/stand/efiboot/efirng.c | 9 | ||||
-rw-r--r-- | sys/arch/arm64/stand/efiboot/efirng.c | 9 | ||||
-rw-r--r-- | sys/stand/boot/bootarg.h | 6 |
5 files changed, 27 insertions, 15 deletions
diff --git a/sys/arch/amd64/stand/efi32/efirng.c b/sys/arch/amd64/stand/efi32/efirng.c index 0178c14551a..2f503909488 100644 --- a/sys/arch/amd64/stand/efi32/efirng.c +++ b/sys/arch/amd64/stand/efi32/efirng.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efirng.c,v 1.1 2019/05/11 02:33:34 mlarkin Exp $ */ +/* $OpenBSD: efirng.c,v 1.2 2020/05/25 14:53:59 deraadt Exp $ */ /* * Copyright (c) 2018 Mark Kettenis <kettenis@openbsd.org> @@ -59,23 +59,25 @@ typedef struct _EFI_RNG_PROTOCOL { static EFI_GUID rng_guid = EFI_RNG_PROTOCOL_GUID; -void +int fwrandom(char *buf, size_t buflen) { EFI_STATUS status; EFI_RNG_PROTOCOL *rng = NULL; UINT8 *random; size_t i; + int ret = 0; status = EFI_CALL(BS->LocateProtocol, &rng_guid, NULL, (void **)&rng); if (rng == NULL || EFI_ERROR(status)) - return; + return -1; random = alloc(buflen); status = EFI_CALL(rng->GetRNG, rng, NULL, buflen, random); if (EFI_ERROR(status)) { printf("RNG GetRNG() failed (%d)\n", status); + ret = -1; goto out; } @@ -84,4 +86,5 @@ fwrandom(char *buf, size_t buflen) out: free(random, buflen); + return ret; } diff --git a/sys/arch/amd64/stand/efi64/efirng.c b/sys/arch/amd64/stand/efi64/efirng.c index 2caaaff34d6..2f503909488 100644 --- a/sys/arch/amd64/stand/efi64/efirng.c +++ b/sys/arch/amd64/stand/efi64/efirng.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efirng.c,v 1.1 2019/05/11 02:36:10 mlarkin Exp $ */ +/* $OpenBSD: efirng.c,v 1.2 2020/05/25 14:53:59 deraadt Exp $ */ /* * Copyright (c) 2018 Mark Kettenis <kettenis@openbsd.org> @@ -59,23 +59,25 @@ typedef struct _EFI_RNG_PROTOCOL { static EFI_GUID rng_guid = EFI_RNG_PROTOCOL_GUID; -void +int fwrandom(char *buf, size_t buflen) { EFI_STATUS status; EFI_RNG_PROTOCOL *rng = NULL; UINT8 *random; size_t i; + int ret = 0; status = EFI_CALL(BS->LocateProtocol, &rng_guid, NULL, (void **)&rng); if (rng == NULL || EFI_ERROR(status)) - return; + return -1; random = alloc(buflen); status = EFI_CALL(rng->GetRNG, rng, NULL, buflen, random); if (EFI_ERROR(status)) { printf("RNG GetRNG() failed (%d)\n", status); + ret = -1; goto out; } @@ -84,4 +86,5 @@ fwrandom(char *buf, size_t buflen) out: free(random, buflen); + return ret; } diff --git a/sys/arch/amd64/stand/efiboot/efirng.c b/sys/arch/amd64/stand/efiboot/efirng.c index 7df4272c053..2f503909488 100644 --- a/sys/arch/amd64/stand/efiboot/efirng.c +++ b/sys/arch/amd64/stand/efiboot/efirng.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efirng.c,v 1.1 2019/05/05 19:17:03 kettenis Exp $ */ +/* $OpenBSD: efirng.c,v 1.2 2020/05/25 14:53:59 deraadt Exp $ */ /* * Copyright (c) 2018 Mark Kettenis <kettenis@openbsd.org> @@ -59,23 +59,25 @@ typedef struct _EFI_RNG_PROTOCOL { static EFI_GUID rng_guid = EFI_RNG_PROTOCOL_GUID; -void +int fwrandom(char *buf, size_t buflen) { EFI_STATUS status; EFI_RNG_PROTOCOL *rng = NULL; UINT8 *random; size_t i; + int ret = 0; status = EFI_CALL(BS->LocateProtocol, &rng_guid, NULL, (void **)&rng); if (rng == NULL || EFI_ERROR(status)) - return; + return -1; random = alloc(buflen); status = EFI_CALL(rng->GetRNG, rng, NULL, buflen, random); if (EFI_ERROR(status)) { printf("RNG GetRNG() failed (%d)\n", status); + ret = -1; goto out; } @@ -84,4 +86,5 @@ fwrandom(char *buf, size_t buflen) out: free(random, buflen); + return ret; } diff --git a/sys/arch/arm64/stand/efiboot/efirng.c b/sys/arch/arm64/stand/efiboot/efirng.c index a90f86d57f7..9d769e75b47 100644 --- a/sys/arch/arm64/stand/efiboot/efirng.c +++ b/sys/arch/arm64/stand/efiboot/efirng.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efirng.c,v 1.1 2018/04/08 13:27:22 kettenis Exp $ */ +/* $OpenBSD: efirng.c,v 1.2 2020/05/25 14:53:58 deraadt Exp $ */ /* * Copyright (c) 2018 Mark Kettenis <kettenis@openbsd.org> @@ -59,23 +59,25 @@ typedef struct _EFI_RNG_PROTOCOL { static EFI_GUID rng_guid = EFI_RNG_PROTOCOL_GUID; -void +int fwrandom(char *buf, size_t buflen) { EFI_STATUS status; EFI_RNG_PROTOCOL *rng = NULL; UINT8 *random; size_t i; + int ret = 0; status = EFI_CALL(BS->LocateProtocol, &rng_guid, NULL, (void **)&rng); if (rng == NULL || EFI_ERROR(status)) - return; + return -1; random = alloc(buflen); status = EFI_CALL(rng->GetRNG, rng, NULL, buflen, random); if (EFI_ERROR(status)) { printf("RNG GetRNG() failed (%d)\n", status); + ret = -1; goto out; } @@ -84,4 +86,5 @@ fwrandom(char *buf, size_t buflen) out: free(random, buflen); + return ret; } diff --git a/sys/stand/boot/bootarg.h b/sys/stand/boot/bootarg.h index 02f6f3f339a..9ccc3c3a5fd 100644 --- a/sys/stand/boot/bootarg.h +++ b/sys/stand/boot/bootarg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bootarg.h,v 1.15 2018/04/08 13:24:36 kettenis Exp $ */ +/* $OpenBSD: bootarg.h,v 1.16 2020/05/25 14:53:57 deraadt Exp $ */ /* * Copyright (c) 1996-1999 Michael Shalayeff @@ -50,8 +50,8 @@ extern bootarg_t *bootargp; #endif void loadrandom(char *name, char *buf, size_t buflen); -void mdrandom(char *buf, size_t buflen); -void fwrandom(char *buf, size_t buflen); +int mdrandom(char *buf, size_t buflen); +int fwrandom(char *buf, size_t buflen); #ifdef _STANDALONE void addbootarg(int, size_t, void *); |