random.c (a6a144698db93a2c456d1e3811140cadef1ba0e3) | random.c (568bc4e87033d232c5fd00d5b0cd22a2ccc04944) |
---|---|
1/* 2 * Copyright (C) 2016 Linaro Ltd; <ard.biesheuvel@linaro.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2 as 6 * published by the Free Software Foundation. 7 * 8 */ --- 129 unchanged lines hidden (view full) --- 138 *addr = target; 139 break; 140 } 141 142 efi_call_early(free_pool, memory_map); 143 144 return status; 145} | 1/* 2 * Copyright (C) 2016 Linaro Ltd; <ard.biesheuvel@linaro.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2 as 6 * published by the Free Software Foundation. 7 * 8 */ --- 129 unchanged lines hidden (view full) --- 138 *addr = target; 139 break; 140 } 141 142 efi_call_early(free_pool, memory_map); 143 144 return status; 145} |
146 147#define RANDOM_SEED_SIZE 32 148 149efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg) 150{ 151 efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; 152 efi_guid_t rng_algo_raw = EFI_RNG_ALGORITHM_RAW; 153 efi_guid_t rng_table_guid = LINUX_EFI_RANDOM_SEED_TABLE_GUID; 154 struct efi_rng_protocol *rng; 155 struct linux_efi_random_seed *seed; 156 efi_status_t status; 157 158 status = efi_call_early(locate_protocol, &rng_proto, NULL, 159 (void **)&rng); 160 if (status != EFI_SUCCESS) 161 return status; 162 163 status = efi_call_early(allocate_pool, EFI_RUNTIME_SERVICES_DATA, 164 sizeof(*seed) + RANDOM_SEED_SIZE, 165 (void **)&seed); 166 if (status != EFI_SUCCESS) 167 return status; 168 169 status = rng->get_rng(rng, &rng_algo_raw, RANDOM_SEED_SIZE, 170 seed->bits); 171 if (status == EFI_UNSUPPORTED) 172 /* 173 * Use whatever algorithm we have available if the raw algorithm 174 * is not implemented. 175 */ 176 status = rng->get_rng(rng, NULL, RANDOM_SEED_SIZE, 177 seed->bits); 178 179 if (status != EFI_SUCCESS) 180 goto err_freepool; 181 182 seed->size = RANDOM_SEED_SIZE; 183 status = efi_call_early(install_configuration_table, &rng_table_guid, 184 seed); 185 if (status != EFI_SUCCESS) 186 goto err_freepool; 187 188 return EFI_SUCCESS; 189 190err_freepool: 191 efi_call_early(free_pool, seed); 192 return status; 193} |
|