blob: 815f73135dd94e895ebbbc4043e517ec9d968758 [file] [log] [blame]
Antonio Nino Diaz4b7059d2018-07-13 15:26:49 +01001/*
2 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Antonio Nino Diaz4b32e622018-08-16 16:52:57 +01007#include <stdint.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
9#include <lib/utils.h>
Antonio Nino Diaz4b7059d2018-07-13 15:26:49 +010010
11#include "rpi3_private.h"
12
13/* Get 128 bits of entropy and fuse the values together to form the canary. */
14#define TRNG_NBYTES 16U
15
16u_register_t plat_get_stack_protector_canary(void)
17{
18 size_t i;
19 u_register_t buf[TRNG_NBYTES / sizeof(u_register_t)];
20 u_register_t ret = 0U;
21
22 rpi3_rng_read(buf, sizeof(buf));
23
24 for (i = 0U; i < ARRAY_SIZE(buf); i++)
25 ret ^= buf[i];
26
27 return ret;
28}