blob: d939cd391788413e68a01aa5e1c8bd9d27f61543 [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
7#include <sys/types.h>
8#include <utils.h>
9
10#include "rpi3_private.h"
11
12/* Get 128 bits of entropy and fuse the values together to form the canary. */
13#define TRNG_NBYTES 16U
14
15u_register_t plat_get_stack_protector_canary(void)
16{
17 size_t i;
18 u_register_t buf[TRNG_NBYTES / sizeof(u_register_t)];
19 u_register_t ret = 0U;
20
21 rpi3_rng_read(buf, sizeof(buf));
22
23 for (i = 0U; i < ARRAY_SIZE(buf); i++)
24 ret ^= buf[i];
25
26 return ret;
27}