1 /* 2 * bcmrand.h. 3 * 4 * Copyright (C) 2020, Broadcom. 5 * 6 * Unless you and Broadcom execute a separate written software license 7 * agreement governing use of this software, this software is licensed to you 8 * under the terms of the GNU General Public License version 2 (the "GPL"), 9 * available at http://www.broadcom.com/licenses/GPLv2.php, with the 10 * following added to such license: 11 * 12 * As a special exception, the copyright holders of this software give you 13 * permission to link this software with independent modules, and to copy and 14 * distribute the resulting executable under terms of your choice, provided that 15 * you also meet, for each linked independent module, the terms and conditions of 16 * the license of that module. An independent module is a module which is not 17 * derived from this software. The special exception does not apply to any 18 * modifications of the software. 19 * 20 * 21 * <<Broadcom-WL-IPTag/Dual:>> 22 */ 23 24 #ifndef _bcmrand_h_ 25 #define _bcmrand_h_ 26 27 /* When HOST driver is for PCIE dongle image, we suppose the HOST must provide the entropy 28 * input if it does not define the macro BCM_RNG_NO_HOST_ENTROPY 29 */ 30 #if defined(BCMPCIEDEV) && !defined(BCMFUZZ) 31 #if !defined(BCM_RNG_HOST_ENTROPY) && !defined(BCM_RNG_NO_HOST_ENTROPY) 32 #define BCM_RNG_HOST_ENTROPY 33 #define BCM_RNG_PCIEDEV_DEFAULT 34 #endif /* !BCM_RNG_HOST_ENTROPY && !BCM_RNG_NO_HOST_ENTROPY */ 35 #endif /* BCMPCIEDEV */ 36 37 /* the format of current TCM layout during boot 38 * 39 * Code Unused memory Random numbers Random number Magic number NVRAM NVRAM 40 * byte Count 0xFEEDC0DE Size 41 * |<-----Variable---->|<---Variable--->|<-----4 bytes-->|<---4 bytes---->|<---V--->|<--4B--->| 42 * |<------------- BCM_ENTROPY_HOST_MAXSIZE --------->| 43 */ 44 45 /* The HOST need to provided 64 bytes (512 bits) entropy for the bcm SW RNG */ 46 #define BCM_ENTROPY_MAGIC_SIZE 4u 47 #define BCM_ENTROPY_COUNT_SIZE 4u 48 #define BCM_ENTROPY_SEED_NBYTES 64u 49 #define BCM_ENTROPY_NONCE_NBYTES 16u 50 #define BCM_ENTROPY_HOST_NBYTES 128u 51 52 #ifdef DBG_RNG_SEC_TEST 53 #define BCM_ENTROPY_MAX_NBYTES 128u 54 #else 55 #define BCM_ENTROPY_MAX_NBYTES 512u 56 #endif /* DBG_RNG_SEC_TEST */ 57 #define BCM_ENTROPY_HOST_MAXSIZE \ 58 (BCM_ENTROPY_MAGIC_SIZE + BCM_ENTROPY_COUNT_SIZE + BCM_ENTROPY_MAX_NBYTES) 59 60 /* Constant for calculate the location of host entropy input */ 61 #define BCM_NVRAM_OFFSET_TCM 4u 62 #define BCM_NVRAM_IMG_COMPRS_FACTOR 4u 63 #define BCM_NVRAM_RNG_SIGNATURE 0xFEEDC0DEu 64 65 #endif /* _bcmrand_h_ */ 66