-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
efi: stub: implement efi_get_random_bytes() based on EFI_RNG_PROTOCOL
This exposes the firmware's implementation of EFI_RNG_PROTOCOL via a new function efi_get_random_bytes(). Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
- Loading branch information
Ard Biesheuvel
authored and
Catalin Marinas
committed
Feb 24, 2016
1 parent
c031a42
commit e4fbf47
Showing
4 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (C) 2016 Linaro Ltd; <ard.biesheuvel@linaro.org> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
* | ||
*/ | ||
|
||
#include <linux/efi.h> | ||
#include <asm/efi.h> | ||
|
||
#include "efistub.h" | ||
|
||
struct efi_rng_protocol { | ||
efi_status_t (*get_info)(struct efi_rng_protocol *, | ||
unsigned long *, efi_guid_t *); | ||
efi_status_t (*get_rng)(struct efi_rng_protocol *, | ||
efi_guid_t *, unsigned long, u8 *out); | ||
}; | ||
|
||
efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table_arg, | ||
unsigned long size, u8 *out) | ||
{ | ||
efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; | ||
efi_status_t status; | ||
struct efi_rng_protocol *rng; | ||
|
||
status = efi_call_early(locate_protocol, &rng_proto, NULL, | ||
(void **)&rng); | ||
if (status != EFI_SUCCESS) | ||
return status; | ||
|
||
return rng->get_rng(rng, NULL, size, out); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters