demo/secure_element/common.h

/*******************************************************************************
* # License
* Copyright 2019 Silicon Laboratories Inc. www.silabs.com
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/
#pragma once
#include "gos.h"
#include "gos_atca.h"
#include "cert_templates/cert_def_1_signer.h"
#include "cert_templates/cert_def_2_device.h"
#include "cert_templates/cert_def_3_device_csr.h"
// ATECCx08A Slot Configuration
#define SE_DEVICE_KEY_SLOT (0) // Slot is where the device's private key is stored
#define SE_KEY_EXCHANGE_SLOT (2) // This slot is used for storing temporary keys during a TLS handshake
#define SE_METADATA_SLOT (8) // This slot stores metadata such as 'hostname' and if the device has been provisioned
#define SE_SIGNER_CA_PUBLIC_KEY_SLOT (15) // This slot stores the root CA cert's public key
// ATECCx08A Slot 8 Metadata
#define SLOT8_SIZE (256)
#define SLOT8_HOSTNAME_SIZE (128)
#define SLOT8_WIFI_PROVISIONED_VALUE (0x72B0)
#define SLOT8_AWS_PROVISIONED_VALUE (0xF309)
//ATECCx08A Slot 8 Metadata structure
typedef struct
{
#define SLOT8_PROVISIONED_FLAG_VALUE (0xF309)
uint32_t provision_flag;
uint32_t hostname_size;
uint8_t hostname[SLOT8_HOSTNAME_SIZE]; // Hostname to issue HTTP requests to
} se_metadata_t;
extern char se_hostname[];
extern bool is_configured;
extern bool is_provisioned;
gos_result_t se_is_configured(bool *is_configured);
gos_result_t se_is_provisioned(bool *is_provisioned);
gos_result_t se_get_hostname(char *hostname);
gos_result_t se_configure(void);