![]() |
m2mb API docs
25.30.003
m2mb API sets documentation
|
Secure Microservice Support. More...
Go to the source code of this file.
Macros | |
| #define | M2MB_SYSTEM_FILE_ID (-1) |
| #define | M2MB_RAM_FILE_ID (0) |
| #define | M2MB_SECURE_MS_READ 0x0000 |
| #define | M2MB_SECURE_MS_WRITE 0x0001 |
| #define | M2MB_SECURE_MS_CREATE 0x0002 |
| #define | M2MB_SECURE_MS_ADMIN 0x0004 |
| #define | M2MB_SECURE_MS_READ_ONLY 0x0008 |
| #define | M2MB_SECURE_MS_TRUSTED 0x0010 |
| #define | M2MB_SECURE_MS_ALLOW_COMPARE 0x0020 |
| #define | M2MB_SECURE_MS_NO_ENCRYPTION 0x0080 |
Typedefs | |
| typedef struct M2MB_SECURE_MS_HANDLE_S * | M2MB_SECURE_MS_HANDLE |
| Opaque Handle used for the Secure Microservice calls. | |
Functions | |
| M2MB_RESULT_E | m2mb_secure_ms_manage (M2MB_SECURE_MS_MANAGE_REQ_E request, M2MB_SECURE_MS_MANAGE_STATE_E *state) |
| A management function that handles Telit's and the Customer's default values. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_remove_file (INT32 file_id) |
| Deletes the relevant secure data file. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_open (M2MB_SECURE_MS_HANDLE *handle, INT32 file_id, UINT16 item_id, UINT16 flags) |
| Open the relevant secure data file. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_read (M2MB_SECURE_MS_HANDLE handle, UINT32 max_len, UINT8 *data, UINT32 *act_len) |
| Read a Secured Data item. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_write (M2MB_SECURE_MS_HANDLE handle, UINT8 *data, UINT32 len) |
| Writes a Secured Data item. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_compare (M2MB_SECURE_MS_HANDLE handle, UINT8 *data, UINT32 len) |
| Compare the input Item to the Secured copy. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_delete (M2MB_SECURE_MS_HANDLE handle) |
| Delete an Item from the Secured file. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_close (M2MB_SECURE_MS_HANDLE handle) |
| Close the opened secure data file. More... | |
| M2MB_SECURE_MS_ERRNO_E | m2mb_secure_ms_errno (M2MB_SECURE_MS_HANDLE handle) |
| Return the last error obtained calling Secure MS functions. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_init (void) |
| Module initialization. More... | |
Secure Microservice Support.
m2m/m2m_common/m2mb_inc/m2mb_secure_ms.h
APIs for all the secure data. See also "m2mb_secure_ms_extend" module that is correlated for a complete set of APIs usage, along with "m2mb_crypto" module
| #define M2MB_RAM_FILE_ID (0) |
file_id to be used when accessing the volatile system file (ram): item created will not be present at next reboot
| #define M2MB_SECURE_MS_ADMIN 0x0004 |
When with the CREATE flag then the new item can be access only with the ADMIN flag: ADMIN property is reserved for not volatile file system part, on the user space ADMIN can be used only for not volatile file system using M2MB_RAM_FILE_ID
| #define M2MB_SECURE_MS_ALLOW_COMPARE 0x0020 |
The new item can be used by the m2mb_secure_ms_compare function (has to come with the CREATE flag)
| #define M2MB_SECURE_MS_CREATE 0x0002 |
For writing a new item
| #define M2MB_SECURE_MS_NO_ENCRYPTION 0x0080 |
The new item doesn't need to be encrypted (has to come with the CREATE flag)
| #define M2MB_SECURE_MS_READ 0x0000 |
In all modes items can be read
| #define M2MB_SECURE_MS_READ_ONLY 0x0008 |
The new item is READ ONLY (has to come with the CREATE flag). A READ_ONLY item can't be deleted
| #define M2MB_SECURE_MS_TRUSTED 0x0010 |
The new item is a trusted item (e.g. PrK, PsK) This data cannot be read using m2mb_secure_read Has to come with the CREATE flag
| #define M2MB_SECURE_MS_WRITE 0x0001 |
For writing on existing item
| #define M2MB_SYSTEM_FILE_ID (-1) |
file_id to be used when accessing the non volatile system file (flash)
Enumeration representing all supported: value different got. has line code meaning: provide number to analyze.
Management request option. Secure Microservice System File has 3 levels (see M2MB_SECURE_MS_MANAGE_STATE_E): TSD(level 0)-CSD(level 1)-OSD(level 2)
TSD - Telit Secure Data Data items written on Telit production site CSD - Custom Secure Data Data items written on Customer production site OSD - Operational Secure Data Data items written after previous phases
System starts from TSD at first boot; When a level is locked (TSD or CSD) system moves to the next level (e.g from TSD to CSD) Levels are like OTP, One Time Programmable, when locked, items in it cannot longer be removed
To update a system item locked in a previous level (e.g TSD), just rewrite it (same lenght!) A copy of it, is create and written on next level (e.g CSD)
When a system item has to be opened, Secure Microservice searchs first on the current level, and in case moves on the previous one (e.g current CSD, search on CSD, if not found look on TSD)
Below an example of current internal status when current level is OSD
TSD CSD OSD 3 ---— updated --> 3 8 4 9 10 15 -----—|updated 11 |------—> 15
Item 10: is used from OSD (can be used) Item 9: is used from CSD (not found in OSD, search in CSD, can be used) Item 3: is used from CSD (not found in OSD, search in CSD, can be used) It is an update of item 3 in TSD, is used as update Item 4: is used from TSD (not found in OSD, not found in CSD, search in TSD, can be used) Item 12: not FOUND, cannot be used. Need to create new one in OSD
The state of the Secure Storage. It represent the Secure Microservice System File levels (TSD-CSD-OSD)
| M2MB_RESULT_E m2mb_secure_ms_close | ( | M2MB_SECURE_MS_HANDLE | handle | ) |
Close the opened secure data file.
This function while closing the file deletes the secure data file handle. Content of file are saved in FS or removed in case m2mb_secure_ms_delete was used before.
| [in] | handle | Secure data file handle |
Example
| M2MB_RESULT_E m2mb_secure_ms_compare | ( | M2MB_SECURE_MS_HANDLE | handle, |
| UINT8 * | data, | ||
| UINT32 | len | ||
| ) |
Compare the input Item to the Secured copy.
This function checks if the input data is equal to the Secure Data. Only items that were created using the M2MB_SECURE_MS_ALLOW_COMPARE flag can be compared. Typically item created with M2MB_SECURE_MS_TRUSTED flag are not created with M2MB_SECURE_MS_ALLOW_COMPARE flag, to avoid attempts to reveal trusted item data
| [in] | handle | Secure data file handle |
| [in] | data | Data (item) to compare. |
| [out] | len | The number of bytes in data. |
Example
| M2MB_RESULT_E m2mb_secure_ms_delete | ( | M2MB_SECURE_MS_HANDLE | handle | ) |
Delete an Item from the Secured file.
This function deletes a specific item from the Secure Data. The item should have been open as M2MB_SECURE_MS_WRITE and in case with M2MB_SECURE_MS_ADMIN as an option flag. Item with M2MB_SECURE_MS_ADMIN attributes cannot be deleted if not opened as ADMIN. A READ_ONLY file cannot be deleted. The content of the item is deleted, but still present in File System until m2mb_secure_ms_close() is invoked which perform permanent removal from FS.
| [in] | handle | Secure data file handle |
Example
| M2MB_SECURE_MS_ERRNO_E m2mb_secure_ms_errno | ( | M2MB_SECURE_MS_HANDLE | handle | ) |
Return the last error obtained calling Secure MS functions.
This function return last specific error number.
| [in] | handle | Secure data file handle. If NULL it returns the last system general error, not specific to the handle. E.g error get during file opening, where handle is not get. |
Example
| M2MB_RESULT_E m2mb_secure_ms_init | ( | void | ) |
Module initialization.
This function initializes the module. Must be called before any other secure_ms APIs
Example
| M2MB_RESULT_E m2mb_secure_ms_manage | ( | M2MB_SECURE_MS_MANAGE_REQ_E | request, |
| M2MB_SECURE_MS_MANAGE_STATE_E * | state | ||
| ) |
A management function that handles Telit's and the Customer's default values.
There are 3 Microservice System File's level:
The effects of the request depends on the current Microservice System File level (TSD-CSD-OSD):
M2MB_SECURE_MS_LOCK_TSD
Allowed only if TSD is the current level.
From now on, no data can be added to nor deleted from the TSD.
This causes the following Microservice System File level change:
TSD -> CSD
Current level: TSD (M2MB_SECURE_MS_TSD_ACTIVE)
New level : CSD (M2MB_SECURE_MS_CSD_ACTIVE)
M2MB_SECURE_MS_TELIT_FACTORY_RESET
Allowed only if CSD is the current level.
All CSD added items are removed. Full Telit's Default items are recovered.
Microservice System File level remains unchanged:
TSD <=> TSD
Current level: CSD (M2MB_SECURE_MS_CSD_ACTIVE)
New level : unchanged
M2MB_SECURE_MS_LOCK_CSD
Allowed only if CSD is the current level.
From now on, no data can be added to nor deleted from the CSD.
This causes the following Microservice System File level change:
CSD -> OSD
Current level: CSD (M2MB_SECURE_MS_CSD_ACTIVE)
New level : OSD (M2MB_SECURE_MS_OSD_ACTIVE)
M2MB_SECURE_MS_CUSTOMER_FACTORY_RESET
Allowed only if OSD is the current level.
All OSD added items are removed. Full Customer's Default items are recovered.
Microservice System File level remains unchanged:
OSD <=> OSD
Current level: OSD (M2MB_SECURE_MS_OSD_ACTIVE)
New level : unchanged
| [in] | request | M2MB_SECURE_MS_MANAGE_REQ_E |
| [out] | state | address of M2MB_SECURE_MS_MANAGE_STATE_E |
Example
| M2MB_RESULT_E m2mb_secure_ms_open | ( | M2MB_SECURE_MS_HANDLE * | handle, |
| INT32 | file_id, | ||
| UINT16 | item_id, | ||
| UINT16 | flags | ||
| ) |
Open the relevant secure data file.
This function creates a Handle and associates it with item in the relative file (file_id). On user space only file_id == M2MB_SYSTEM_FILE_ID is allowed. file_id 0..11 are reserved for eUICC profile. See "Management request option: M2MB_SECURE_MS_MANAGE_REQ_E" Searching of a system item in M2MB_SYSTEM_FILE_ID is performed by looking first on the highest level, therefore first in to OSD(if the level exist), then in the CSD(if the level exist) and then in the TSD. Therefore item_id (of M2MB_SYSTEM_FILE_ID) is searched in the secure Microservice System Files in the following order: OSD, CSD, TSD.
| [out] | handle | Pointer to a Handle |
| [in] | file_id | M2MB_SYSTEM_FILE_ID System Data 0..11 eUICC Profile ID (reserved, not available on user space) |
| [in] | item_id | The ID of the item. See note |
| [in] | flags | A combination of the following: M2MB_SECURE_MS_READ M2MB_SECURE_MS_WRITE M2MB_SECURE_MS_ADMIN M2MB_SECURE_MS_CREATE The following flags are used only with M2MB_SECURE_MS_CREATE M2MB_SECURE_MS_READ_ONLY M2MB_SECURE_MS_TRUSTED M2MB_SECURE_MS_NO_ENCRYPTION |
Example
| M2MB_RESULT_E m2mb_secure_ms_read | ( | M2MB_SECURE_MS_HANDLE | handle, |
| UINT32 | max_len, | ||
| UINT8 * | data, | ||
| UINT32 * | act_len | ||
| ) |
Read a Secured Data item.
This function enables reading an item from the Secure Data. Partial read of saved bytes is not supported. Complete reading of the saved bytes has always to be performed, even of actual data is lesser than the saving btyes (overhead, alignment...)
| [in] | handle | Secure data file handle |
| [in] | max_len | The number of the maximum bytes to read that must be a product of 16 big enough to contain all the saved bytes of the item. Actual significant data can be shorter (overhead, alignment...) |
| [out] | data | Returned data. If specificied pointer is NULL, it represents a request to known the actual data item size |
| [out] | act_len | The actual data item size Before performing the read, the total number of bytes can be read issuing data=NULL and max_len=0, and then a compliant size buffer provided (multiple of 16). So new read with data pointer can be provided, to get the data |
Example
| M2MB_RESULT_E m2mb_secure_ms_remove_file | ( | INT32 | file_id | ) |
Deletes the relevant secure data file.
This function deletes a secure data file. Data file (file_id 0..11) are reserved for eUICC Profile and not accessible from user space. Only M2MB_SYSTEM_FILE_ID can be used to remove any items within current Secure Microservice Sytem File level (basically equivalent to M2MB_SECURE_MS_TELIT_FACTORY_RESET or M2MB_SECURE_MS_CUSTOMER_FACTORY_RESET for m2mb_secure_ms_manage API, but automatically performed dependent on the level)
| [in] | file_id | M2MB_SYSTEM_FILE_ID (perform deletion based on level) or reserved 0..11 (reserved eUICC Profile ID) |
Example
| M2MB_RESULT_E m2mb_secure_ms_write | ( | M2MB_SECURE_MS_HANDLE | handle, |
| UINT8 * | data, | ||
| UINT32 | len | ||
| ) |
Writes a Secured Data item.
This function enables writing an item to the Secure Data. If item is saved and then reopened, in order to allow data update, new data must have the same size of the previous saved data, otherwise an error is provided. So only the same size data can be updated. In case, to completely change an item also in size, open it in write mode, delete it and close it making use of m2mb_secure_ms APIs. Then open it again in create mode and write whatever needed.
| [in] | handle | Secure data file handle |
| [in] | data | Data (item) to set. |
| [out] | len | The number of bytes in data. Internally data will be saved as a multiple of 16 but keeping the actual data as specified by len |
Example