1 /*!
2  * \file      secure-element-nvm.h
3  *
4  * \brief     Secure Element non-volatile data.
5  *
6  * \copyright Revised BSD License, see section \ref LICENSE.
7  *
8  * \code
9  *                ______                              _
10  *               / _____)             _              | |
11  *              ( (____  _____ ____ _| |_ _____  ____| |__
12  *               \____ \| ___ |    (_   _) ___ |/ ___)  _ \
13  *               _____) ) ____| | | || |_| ____( (___| | | |
14  *              (______/|_____)_|_|_| \__)_____)\____)_| |_|
15  *              (C)2013 Semtech
16  *
17  *               ___ _____ _   ___ _  _____ ___  ___  ___ ___
18  *              / __|_   _/_\ / __| |/ / __/ _ \| _ \/ __| __|
19  *              \__ \ | |/ _ \ (__| ' <| _| (_) |   / (__| _|
20  *              |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
21  *              embedded.connectivity.solutions===============
22  *
23  * \endcode
24  *
25  * \author    Miguel Luis ( Semtech )
26  *
27  * \author    Daniel Jaeckle ( STACKFORCE )
28  *
29  * \addtogroup  SECUREELEMENT
30  *
31  * \{
32  *
33  */
34 #ifndef __SECURE_ELEMENT_NVM_H__
35 #define __SECURE_ELEMENT_NVM_H__
36 
37 #ifdef __cplusplus
38 extern "C"
39 {
40 #endif
41 
42 #include <stdint.h>
43 #include "LoRaMacTypes.h"
44 
45 /*!
46  * Secure-element keys size in bytes
47  */
48 #define SE_KEY_SIZE             16
49 
50 /*!
51  * Secure-element EUI size in bytes
52  */
53 #define SE_EUI_SIZE             8
54 
55 /*!
56  * Secure-element pin size in bytes
57  */
58 #define SE_PIN_SIZE             4
59 
60 #ifdef SOFT_SE
61 /*!
62  * Number of supported crypto keys for the soft-se
63  */
64 #define NUM_OF_KEYS             23
65 
66 /*!
67  * Key structure definition for the soft-se
68  */
69 typedef struct sKey
70 {
71     /*!
72      * Key identifier
73      */
74     KeyIdentifier_t KeyID;
75     /*!
76      * Key value
77      */
78     uint8_t KeyValue[SE_KEY_SIZE];
79 } Key_t;
80 #endif
81 
82 typedef struct sSecureElementNvCtx
83 {
84     /*!
85      * DevEUI storage
86      */
87     uint8_t DevEui[SE_EUI_SIZE];
88     /*!
89      * Join EUI storage
90      */
91     uint8_t JoinEui[SE_EUI_SIZE];
92     /*!
93      * Pin storage
94      */
95     uint8_t Pin[SE_PIN_SIZE];
96 #ifdef SOFT_SE
97     /*!
98      * The key list is required for the soft-se only. All other secure-elements
99      * handle the storage on their own.
100      */
101     Key_t KeyList[NUM_OF_KEYS];
102 #endif
103     /*!
104      * CRC32 value of the SecureElement data structure.
105      */
106     uint32_t Crc32;
107 } SecureElementNvmData_t;
108 
109 
110 /*! \} addtogroup SECUREELEMENT */
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif //  __SECURE_ELEMENT_NVM_H__
117