Skip to content

Commit 600578a

Browse files
committed
Add entropy injection with hardcoded entropy
* All platforms will use hardcoded entropy injection. This is needed only for non-TRNG boards, but for code simplicity, do it for all. * Accept also CA_CERT existing error from fcc_developer() API.
1 parent 07f4d33 commit 600578a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
static MbedCloudClient *cloud_client;
2929
static bool cloud_client_registered = false;
3030

31+
// Fake entropy needed for non-TRNG boards. Suitable only for demo devices.
32+
const uint8_t MBED_CLOUD_DEV_ENTROPY[] = { 0xf6, 0xd6, 0xc0, 0x09, 0x9e, 0x6e, 0xf2, 0x37, 0xdc, 0x29, 0x88, 0xf1, 0x57, 0x32, 0x7d, 0xde, 0xac, 0xb3, 0x99, 0x8c, 0xb9, 0x11, 0x35, 0x18, 0xeb, 0x48, 0x29, 0x03, 0x6a, 0x94, 0x6d, 0xe8, 0x40, 0xc0, 0x28, 0xcc, 0xe4, 0x04, 0xc3, 0x1f, 0x4b, 0xc2, 0xe0, 0x68, 0xa0, 0x93, 0xe6, 0x3a };
33+
3134
static M2MResource* m2m_get_res;
3235
static M2MResource* m2m_put_res;
3336
static M2MResource* m2m_post_res;
@@ -118,8 +121,11 @@ int main(void)
118121
printf("fcc_init() failed with %d\n", status);
119122
return -1;
120123
}
124+
125+
// Inject hardcoded entropy for the device. Suitable only for demo devices.
126+
(void) fcc_entropy_set(MBED_CLOUD_DEV_ENTROPY, sizeof(MBED_CLOUD_DEV_ENTROPY));
121127
status = fcc_developer_flow();
122-
if (status != FCC_STATUS_SUCCESS && status != FCC_STATUS_KCM_FILE_EXIST_ERROR) {
128+
if (status != FCC_STATUS_SUCCESS && status != FCC_STATUS_KCM_FILE_EXIST_ERROR && status != FCC_STATUS_CA_ERROR) {
123129
printf("fcc_developer_flow() failed with %d\n", status);
124130
return -1;
125131
}

0 commit comments

Comments
 (0)