![]() |
m2mb API docs
30.00.007
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 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.
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 data to the TEE buffer.
Adds the 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. |
Example
| 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.
| [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. |
Example
| 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. |
Example
| 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. |
Example
| 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. |
Example
| 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. |
Example
| 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.
| [in] | bfr | The TEE Buffer Handle. |
| [in] | num_of_bytes | The number of bytes for the left circular shift. |
Example
| 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. |
Example