![]() |
m2mb API docs
25.30.003
m2mb API sets documentation
|
Secure Microservice Support. More...
Go to the source code of this file.
Typedefs | |
| typedef struct M2MB_SECURE_MS_BUFFER_S * | M2MB_SECURE_MS_BUFFER |
| Opaque Handle used for the m2mb_secure_ms_crypto_buffer_* calls. | |
Enumerations | |
| enum | M2MB_SECURE_MS_IMPORT_TYPE_E { M2MB_SECURE_MS_IMPORT_PsK, M2MB_SECURE_MS_IMPORT_PuK, M2MB_SECURE_MS_IMPORT_PrK, M2MB_SECURE_MS_IMPORT_ECC_DP_P, M2MB_SECURE_MS_IMPORT_ECC_DP_A, M2MB_SECURE_MS_IMPORT_ECC_DP_B, M2MB_SECURE_MS_IMPORT_ECC_DP_G_XY, M2MB_SECURE_MS_IMPORT_ECC_DP_G_X, M2MB_SECURE_MS_IMPORT_ECC_DP_G_Y, M2MB_SECURE_MS_IMPORT_ECC_DP_N, M2MB_SECURE_MS_IMPORT_ECC_DP_H } |
| Enumeration representing the type of the parameter that is going to be imported from the secure storage into the given context. More... | |
Functions | |
| M2MB_RESULT_E | m2mb_secure_ms_crypto_alloc (UINT16 size, M2MB_SECURE_MS_BUFFER *bfr) |
| Allocates TEE buffer. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_crypto_add_data (UINT8 *data, UINT32 length, M2MB_SECURE_MS_BUFFER bfr, UINT32 out_offset) |
| Adds the provided data to the TEE buffer. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_crypto_add_key (UINT8 *key_blob, UINT32 length, M2MB_SECURE_MS_BUFFER bfr, UINT32 out_offset) |
| Adds the key (as key_blob) to the TEE buffer. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_crypto_add_item (M2MB_SECURE_MS_HANDLE handle, M2MB_SECURE_MS_BUFFER bfr, UINT32 out_offset) |
| Adds the secured item data to the TEE buffer. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_crypto_md (M2MB_CRYPTO_MD_ALG_E md_info, M2MB_SECURE_MS_BUFFER in_bfr, UINT32 in_offset, UINT32 length, M2MB_SECURE_MS_BUFFER out_bfr, UINT32 out_offset) |
| Performs a MD operation on (part of) the TEE buffers. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_crypto_final (M2MB_CRYPTO_GEN_CONTEXT ctx, M2MB_SECURE_MS_BUFFER out_bfr, UINT32 out_offset) |
| Performs the final operation and adds it to the TEE buffer. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_crypto_encrypt (M2MB_SECURE_MS_BUFFER in_bfr, UINT32 in_offset, UINT32 length, M2MB_CRYPTO_GEN_CONTEXT ctx, UINT8 *ivec, M2MB_SECURE_MS_BUFFER out_bfr, UINT32 out_offset) |
| Encrypts (part of) the data in the input TEE buffer into the output TEE buffer. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_crypto_decrypt (M2MB_SECURE_MS_BUFFER in_bfr, UINT32 in_offset, UINT32 length, M2MB_CRYPTO_GEN_CONTEXT ctx, UINT8 *ivec, M2MB_SECURE_MS_BUFFER out_bfr, UINT32 out_offset) |
| Decrypts (part of) the data in the input TEE buffer into the output TEE buffer. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_crypto_xor (M2MB_SECURE_MS_BUFFER in_bfr, UINT32 in_offset, UINT32 length, M2MB_SECURE_MS_BUFFER out_bfr, UINT32 out_offset) |
| Performs a XOR operation between (part of) the TEE buffers. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_crypto_rotate (M2MB_SECURE_MS_BUFFER bfr, UINT32 num_of_bytes) |
| Circular shift left of the data in the TEE buffer. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_crypto_write (M2MB_SECURE_MS_BUFFER bfr, UINT32 in_offset, UINT32 length, M2MB_SECURE_MS_HANDLE handle) |
| Writes (part of) the TEE buffer to the Secure Storage. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_crypto_read (M2MB_SECURE_MS_BUFFER bfr, UINT32 offset, UINT32 max_len, UINT8 *data, UINT32 *act_len) |
| Reads the TEE buffer from the Secure Storage. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_crypto_find (M2MB_SECURE_MS_BUFFER bfr, char *str, UINT32 *offset) |
| Searches for a string within a TEE buffer. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_crypto_free (M2MB_SECURE_MS_BUFFER bfr) |
| Free the TEE buffer. More... | |
| M2MB_RESULT_E | m2mb_secure_ms_crypto_import (M2MB_SECURE_MS_HANDLE handle, M2MB_CRYPTO_GEN_CONTEXT ctx, M2MB_SECURE_MS_IMPORT_TYPE_E type) |
| Import a stored secured item (e.g. key, domain parameters), into a given context. More... | |
| M2MB_SECURE_MS_ERRNO_E | m2mb_secure_ms_crypto_errno (M2MB_SECURE_MS_BUFFER bfr) |
| Return the last error obtained calling Secure MS Crypto functions. More... | |
Secure Microservice Support.
m2m/m2m_common/m2mb_inc/m2mb_secure_ms_extend.h
Wrapper APIs for the CryptoLib (m2mb_crypto.h) that uses data from the secure data storage. TEE is Trusted Exexution Environment region, protected by TrustZone
Enumeration representing the type of the parameter that is going to be imported from the secure storage into the given context.
| M2MB_RESULT_E m2mb_secure_ms_crypto_add_data | ( | UINT8 * | data, |
| UINT32 | length, | ||
| M2MB_SECURE_MS_BUFFER | bfr, | ||
| UINT32 | out_offset | ||
| ) |
Adds the provided data to the TEE buffer.
Adds the provided data to the TEE buffer.
| [in] | data | Data to add. |
| [in] | length | Data length. |
| [in] | bfr | The TEE Buffer Handle. |
| [in] | out_offset | The offset in the TEE Buffer Handle were the data is written. |
Example
| M2MB_RESULT_E m2mb_secure_ms_crypto_add_item | ( | M2MB_SECURE_MS_HANDLE | handle, |
| M2MB_SECURE_MS_BUFFER | bfr, | ||
| UINT32 | out_offset | ||
| ) |
Adds the secured item data to the TEE buffer.
This function adds the secured item data to the TEE buffer.
| [in] | handle | Secure data file handle |
| [in] | bfr | The TEE Buffer Handle. |
| [in] | out_offset | The offset in the TEE Buffer Handle were the data from the item is written. |
| M2MB_RESULT_E m2mb_secure_ms_crypto_add_key | ( | UINT8 * | key_blob, |
| UINT32 | length, | ||
| M2MB_SECURE_MS_BUFFER | bfr, | ||
| UINT32 | out_offset | ||
| ) |
Adds the key (as key_blob) to the TEE buffer.
Uses a dedicated TEE function to export the key from the key_blob and then adds the key to the TEE buffer. The key can be used inside TEE
| [in] | key_blob | A key_blob, either exported by the m2mb_crypto_*_keyblob_export function or created using m2mb_crypto_ecdh_shared_key_derive. |
| [in] | length | key_blob length. |
| [in] | bfr | The TEE Buffer Handle. |
| [in] | out_offset | The offset in the TEE Buffer Handle were the data is written. |
| M2MB_RESULT_E m2mb_secure_ms_crypto_alloc | ( | UINT16 | size, |
| M2MB_SECURE_MS_BUFFER * | bfr | ||
| ) |
Allocates TEE buffer.
This function allocates a TEE buffer to be later used by m2mb_secure_ms_crypto_buffer_* functions. The buffer is zero initialized.
| [in] | size | Buffer size (in bytes) to allocate. |
| [out] | bfr | Pointer to a handle to be allocated by this function. |
Example
| M2MB_RESULT_E m2mb_secure_ms_crypto_decrypt | ( | M2MB_SECURE_MS_BUFFER | in_bfr, |
| UINT32 | in_offset, | ||
| UINT32 | length, | ||
| M2MB_CRYPTO_GEN_CONTEXT | ctx, | ||
| UINT8 * | ivec, | ||
| M2MB_SECURE_MS_BUFFER | out_bfr, | ||
| UINT32 | out_offset | ||
| ) |
Decrypts (part of) the data in the input TEE buffer into the output TEE buffer.
Decrypts (part of) the data in the input TEE buffer into the output TEE buffer.
| [in] | in_bfr | The TEE input Buffer Handle. |
| [in] | in_offset | Offset (in bytes) in the input buffer. |
| [in] | length | length (in bytes) of the data to decrypt. |
| [in] | ctx | A context previously initialized by m2mb_crypto_aes_init() or m2mb_crypto_des_init(). |
| [in] | ivec | Initialization vector. |
| [in] | out_bfr | The TEE output Buffer Handle. |
| [in] | out_offset | Offset (in bytes) in the output buffer. |
Example
| M2MB_RESULT_E m2mb_secure_ms_crypto_encrypt | ( | M2MB_SECURE_MS_BUFFER | in_bfr, |
| UINT32 | in_offset, | ||
| UINT32 | length, | ||
| M2MB_CRYPTO_GEN_CONTEXT | ctx, | ||
| UINT8 * | ivec, | ||
| M2MB_SECURE_MS_BUFFER | out_bfr, | ||
| UINT32 | out_offset | ||
| ) |
Encrypts (part of) the data in the input TEE buffer into the output TEE buffer.
Encrypts (part of) the data in the input TEE buffer into the output TEE buffer.
| [in] | in_bfr | The TEE input Buffer Handle. |
| [in] | in_offset | Offset (in bytes) in the input buffer. |
| [in] | length | length (in bytes) of the data to encrypt. |
| [in] | ctx | A context previously initialized by m2mb_crypto_aes_init() or m2mb_crypto_des_init(). |
| [in] | ivec | Initialization vector. |
| [in] | out_bfr | The TEE output Buffer Handle. |
| [in] | out_offset | Offset (in bytes) in the output buffer. |
| M2MB_SECURE_MS_ERRNO_E m2mb_secure_ms_crypto_errno | ( | M2MB_SECURE_MS_BUFFER | bfr | ) |
Return the last error obtained calling Secure MS Crypto functions.
This function return last specific error number.
| [in] | bfr | The TEE Buffer Handle. If NULL is provided, it returns the internal error if any not associated with buffer |
| M2MB_RESULT_E m2mb_secure_ms_crypto_final | ( | M2MB_CRYPTO_GEN_CONTEXT | ctx, |
| M2MB_SECURE_MS_BUFFER | out_bfr, | ||
| UINT32 | out_offset | ||
| ) |
Performs the final operation and adds it to the TEE buffer.
This function performs the MD/CMAC/HMAC final operation and add the result to the TEE buffer.
| [in] | ctx | A context previously initialized by m2mb_crypto_*_init(). |
| [in] | out_bfr | The TEE Buffer Handle. |
| [in] | out_offset | Offset (in bytes) in the TEE buffer. |
| M2MB_RESULT_E m2mb_secure_ms_crypto_find | ( | M2MB_SECURE_MS_BUFFER | bfr, |
| char * | str, | ||
| UINT32 * | offset | ||
| ) |
Searches for a string within a TEE buffer.
This function searches for a string within a TEE buffer. this is useful for decoding an *.INI file or an XML file.
| [in] | bfr | The TEE Buffer Handle. |
| [in] | str | String to search for. |
| [in,out] | offset | In - Offset from where to start the search. Out - Offset of the string in the buffer (0 if not found). |
Example
| M2MB_RESULT_E m2mb_secure_ms_crypto_free | ( | M2MB_SECURE_MS_BUFFER | bfr | ) |
Free the TEE buffer.
This function De-allocates the TEE buffer.
| [in] | bfr | The TEE Buffer Handle. |
Example
| M2MB_RESULT_E m2mb_secure_ms_crypto_import | ( | M2MB_SECURE_MS_HANDLE | handle, |
| M2MB_CRYPTO_GEN_CONTEXT | ctx, | ||
| M2MB_SECURE_MS_IMPORT_TYPE_E | type | ||
| ) |
Import a stored secured item (e.g. key, domain parameters), into a given context.
This function is a complementary function for the m2mb_crypto_* functions. It imports a stored secured item identified by its handle (e.g. key, domain parameters) to a given context.
| [in] | handle | Secure data file handle (stored secure item) |
| [in] | ctx | A context previously initialized by m2mb_crypto_*_init(). |
| [in] | type | The type of the item to import (M2MB_SECURE_MS_IMPORT_TYPE_E). |
Example
| M2MB_RESULT_E m2mb_secure_ms_crypto_md | ( | M2MB_CRYPTO_MD_ALG_E | md_info, |
| M2MB_SECURE_MS_BUFFER | in_bfr, | ||
| UINT32 | in_offset, | ||
| UINT32 | length, | ||
| M2MB_SECURE_MS_BUFFER | out_bfr, | ||
| UINT32 | out_offset | ||
| ) |
Performs a MD operation on (part of) the TEE buffers.
This function performs a Message Digest operation on (part of) the TEE input buffer and stores the MD result in the output buffer.
| [in] | md_info | The message digest method to use. |
| [in] | in_bfr | The TEE 1st Buffer Handle. |
| [in] | in_offset | Offset (in bytes) in the 1st buffer. |
| [in] | length | length (in bytes) of the data to be digested. |
| [in,out] | out_bfr | The TEE 2nd Buffer Handle. For the XOR operation this is input and output, for all the rest only output. |
| [in] | out_offset | Offset (in bytes) in the 2nd buffer. |
| M2MB_RESULT_E m2mb_secure_ms_crypto_read | ( | M2MB_SECURE_MS_BUFFER | bfr, |
| UINT32 | offset, | ||
| UINT32 | max_len, | ||
| UINT8 * | data, | ||
| UINT32 * | act_len | ||
| ) |
Reads the TEE buffer from the Secure Storage.
This function Reads the TEE buffer from the Secure Storage. Note that the Trusted Data was zeroed by the Write function.
| [in] | bfr | The TEE Buffer Handle. |
| [in] | offset | Offset in the buffer. |
| [in] | max_len | The number of the maximum bytes to read. |
| [out] | data | Returned data. If NULL, "act_len" will return the buffer size. |
| [out] | act_len | The actual number of bytes returned. |
Example
| M2MB_RESULT_E m2mb_secure_ms_crypto_rotate | ( | M2MB_SECURE_MS_BUFFER | bfr, |
| UINT32 | num_of_bytes | ||
| ) |
Circular shift left of the data in the TEE buffer.
This function performs a left circular shift of the data in the TEE buffer. Rotation has to be intended for string, so for hex values rotation is right. Rotation versus has to be considered when string or array is considered E.g. "help" rotated by 1 bytes is "elph" for string but in hex the representation is array[0]='h', array[1]='e', array[2]='l', array[3]='p' so 0x 'p' 'l' 'e' 'h' => 0x706C6568 rotation is right on hex 0x 'p' 'l' 'e' 'h'>>8bit => 0x 'h' 'p' 'l' 'e' => 0x68706C65 so "elph" as expected for string By looking on the array instead, in case of rotation left for hex, 0x 'p' 'l' 'e' 'h' <<8bit is 0x 'l' 'e' 'h' 'p' so relative string would be "help" => "phel" which is considered as rotation right for string.
| [in] | bfr | The TEE Buffer Handle. |
| [in] | num_of_bytes | The number of bytes for the left circular shift. |
| M2MB_RESULT_E m2mb_secure_ms_crypto_write | ( | M2MB_SECURE_MS_BUFFER | bfr, |
| UINT32 | in_offset, | ||
| UINT32 | length, | ||
| M2MB_SECURE_MS_HANDLE | handle | ||
| ) |
Writes (part of) the TEE buffer to the Secure Storage.
This function Writes (part of) the TEE buffer to the Secure Storage. Data that is written is zeroed.
| [in] | bfr | The TEE Buffer Handle. |
| [in] | in_offset | Offset (in bytes) in the buffer of the relevant data. |
| [in] | length | length (in bytes) of the relevant data. |
| [in] | handle | Secure data file handle |
Example
| M2MB_RESULT_E m2mb_secure_ms_crypto_xor | ( | M2MB_SECURE_MS_BUFFER | in_bfr, |
| UINT32 | in_offset, | ||
| UINT32 | length, | ||
| M2MB_SECURE_MS_BUFFER | out_bfr, | ||
| UINT32 | out_offset | ||
| ) |
Performs a XOR operation between (part of) the TEE buffers.
This function performs a XOR operation between (part of) the TEE buffers.
| [in] | in_bfr | The TEE 1st Buffer Handle |
| [in] | in_offset | Offset (in bytes) in the 1st buffer. |
| [in] | length | length (in bytes) to XOR. |
| [in] | out_bfr | The TEE 2nd Buffer Handle. |
| [in] | out_offset | Offset (in bytes) in the 2nd buffer. |