blob: ec0b1fbee966d06e51a241bb32dd26d58edc1fbc [file] [log] [blame]
dp-armb3263b32017-02-28 14:43:15 +00001/*
2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
3 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
dp-armb3263b32017-02-28 14:43:15 +00005 */
6
7#include <arch_helpers.h>
8#include <debug.h>
9#include <utils.h>
10#include "juno_decl.h"
11#include "juno_def.h"
12
13u_register_t plat_get_stack_protector_canary(void)
14{
15 u_register_t c[TRNG_NBYTES / sizeof(u_register_t)];
16 u_register_t ret = 0;
17 size_t i;
18
19 if (juno_getentropy(c, sizeof(c)) != 0) {
20 ERROR("Not enough entropy to initialize canary value\n");
21 panic();
22 }
23
24 /*
25 * On Juno we get 128-bits of entropy in one round.
26 * Fuse the values together to form the canary.
27 */
28 for (i = 0; i < ARRAY_SIZE(c); i++)
29 ret ^= c[i];
30 return ret;
31}