Antonio Nino Diaz | 4b7059d | 2018-07-13 15:26:49 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Antonio Nino Diaz | 4b32e62 | 2018-08-16 16:52:57 +0100 | [diff] [blame] | 7 | #include <stdint.h> |
Antonio Nino Diaz | 4b7059d | 2018-07-13 15:26:49 +0100 | [diff] [blame] | 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 | |
| 15 | u_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 | } |