blob: 812f6edfa9de6a36f788b68c7006d58e49dfc909 [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 Diaz4b7059d2018-07-13 15:26:49 +01008#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}