random.c (818c7ce724770fbcdcd43725c81f2b3535f82b76) | random.c (1786e83011644e18732ed006413339d5323766e9) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (C) 2016 Linaro Ltd; <ard.biesheuvel@linaro.org> 4 */ 5 6#include <linux/efi.h> 7#include <linux/log2.h> 8#include <asm/efi.h> 9 10#include "efistub.h" 11 | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (C) 2016 Linaro Ltd; <ard.biesheuvel@linaro.org> 4 */ 5 6#include <linux/efi.h> 7#include <linux/log2.h> 8#include <asm/efi.h> 9 10#include "efistub.h" 11 |
12typedef struct efi_rng_protocol efi_rng_protocol_t; | 12typedef union efi_rng_protocol efi_rng_protocol_t; |
13 14typedef struct { 15 u32 get_info; 16 u32 get_rng; 17} efi_rng_protocol_32_t; 18 19typedef struct { 20 u64 get_info; 21 u64 get_rng; 22} efi_rng_protocol_64_t; 23 | 13 14typedef struct { 15 u32 get_info; 16 u32 get_rng; 17} efi_rng_protocol_32_t; 18 19typedef struct { 20 u64 get_info; 21 u64 get_rng; 22} efi_rng_protocol_64_t; 23 |
24struct efi_rng_protocol { 25 efi_status_t (*get_info)(struct efi_rng_protocol *, 26 unsigned long *, efi_guid_t *); 27 efi_status_t (*get_rng)(struct efi_rng_protocol *, 28 efi_guid_t *, unsigned long, u8 *out); | 24union efi_rng_protocol { 25 struct { 26 efi_status_t (*get_info)(efi_rng_protocol_t *, 27 unsigned long *, efi_guid_t *); 28 efi_status_t (*get_rng)(efi_rng_protocol_t *, 29 efi_guid_t *, unsigned long, u8 *out); 30 }; 31 struct { 32 u32 get_info; 33 u32 get_rng; 34 } mixed_mode; |
29}; 30 31efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table_arg, 32 unsigned long size, u8 *out) 33{ 34 efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; 35 efi_status_t status; | 35}; 36 37efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table_arg, 38 unsigned long size, u8 *out) 39{ 40 efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; 41 efi_status_t status; |
36 struct efi_rng_protocol *rng = NULL; | 42 efi_rng_protocol_t *rng = NULL; |
37 38 status = efi_call_early(locate_protocol, &rng_proto, NULL, 39 (void **)&rng); 40 if (status != EFI_SUCCESS) 41 return status; 42 43 return efi_call_proto(efi_rng_protocol, get_rng, rng, NULL, size, out); 44} --- 112 unchanged lines hidden (view full) --- 157 return status; 158} 159 160efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg) 161{ 162 efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; 163 efi_guid_t rng_algo_raw = EFI_RNG_ALGORITHM_RAW; 164 efi_guid_t rng_table_guid = LINUX_EFI_RANDOM_SEED_TABLE_GUID; | 43 44 status = efi_call_early(locate_protocol, &rng_proto, NULL, 45 (void **)&rng); 46 if (status != EFI_SUCCESS) 47 return status; 48 49 return efi_call_proto(efi_rng_protocol, get_rng, rng, NULL, size, out); 50} --- 112 unchanged lines hidden (view full) --- 163 return status; 164} 165 166efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg) 167{ 168 efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; 169 efi_guid_t rng_algo_raw = EFI_RNG_ALGORITHM_RAW; 170 efi_guid_t rng_table_guid = LINUX_EFI_RANDOM_SEED_TABLE_GUID; |
165 struct efi_rng_protocol *rng = NULL; | 171 efi_rng_protocol_t *rng = NULL; |
166 struct linux_efi_random_seed *seed = NULL; 167 efi_status_t status; 168 169 status = efi_call_early(locate_protocol, &rng_proto, NULL, 170 (void **)&rng); 171 if (status != EFI_SUCCESS) 172 return status; 173 --- 32 unchanged lines hidden --- | 172 struct linux_efi_random_seed *seed = NULL; 173 efi_status_t status; 174 175 status = efi_call_early(locate_protocol, &rng_proto, NULL, 176 (void **)&rng); 177 if (status != EFI_SUCCESS) 178 return status; 179 --- 32 unchanged lines hidden --- |