#ifndef SECURE_BOOT_H
#define SECURE_BOOT_H
#ifdef __cplusplus
extern "C" {
#endif
#include "atca_status.h"
#include "secure_boot_memory.h"
#include "atca_command.h"
#include "crypto/atca_crypto_sw_sha2.h"
#define SECURE_BOOT_CONFIG_DISABLE 0
#define SECURE_BOOT_CONFIG_FULL_BOTH 1
#define SECURE_BOOT_CONFIG_FULL_SIGN 2
#define SECURE_BOOT_CONFIG_FULL_DIG 3
#ifndef SECURE_BOOT_CONFIGURATION
#define SECURE_BOOT_CONFIGURATION SECURE_BOOT_CONFIG_FULL_DIG
#endif
#ifndef SECURE_BOOT_DIGEST_ENCRYPT_ENABLED
#define SECURE_BOOT_DIGEST_ENCRYPT_ENABLED true
#endif
#ifndef SECURE_BOOT_UPGRADE_SUPPORT
#define SECURE_BOOT_UPGRADE_SUPPORT true
#endif
typedef struct
{
uint16_t secure_boot_mode : 2;
uint16_t secure_boot_reserved1 : 1;
uint16_t secure_boot_persistent_enable : 1;
uint16_t secure_boot_rand_nonce : 1;
uint16_t secure_boot_reserved2 : 3;
uint16_t secure_boot_sig_dig : 4;
uint16_t secure_boot_pub_key : 4;
}secure_boot_config_bits;
typedef struct
{
memory_parameters memory_params;
atcac_sha2_256_ctx s_sha_context;
uint8_t app_digest[ATCA_SHA_DIGEST_SIZE];
#if SECURE_BOOT_DIGEST_ENCRYPT_ENABLED
uint8_t randomnum[RANDOM_RSP_SIZE];
uint8_t io_protection_key[ATCA_KEY_SIZE];
#endif
}secure_boot_parameters;
ATCA_STATUS secure_boot_process(void);
ATCA_STATUS bind_host_and_secure_element_with_io_protection(uint16_t slot);
extern ATCA_STATUS host_generate_random_number(uint8_t *rand);
#ifdef __cplusplus
}
#endif
#endif