|
Anjay Lite
|
Default implementation of the LwM2M Security Object (/0). More...
#include <anj/init.h>#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include <anj/defs.h>#include <anj/dm/core.h>#include <anj/persistence.h>#include <anj/crypto.h>Go to the source code of this file.
Data Structures | |
| struct | anj_dm_security_instance_t |
| struct | anj_dm_security_instance_init_t |
| struct | anj_dm_security_obj_t |
Enumerations | |
| enum | anj_dm_security_mode_t { ANJ_DM_SECURITY_PSK = 0 , ANJ_DM_SECURITY_RPK = 1 , ANJ_DM_SECURITY_CERTIFICATE = 2 , ANJ_DM_SECURITY_NOSEC = 3 , ANJ_DM_SECURITY_EST = 4 } |
Functions | |
| void | anj_dm_security_obj_init (anj_dm_security_obj_t *security_obj_ctx) |
| int | anj_dm_security_obj_add_instance (anj_dm_security_obj_t *security_obj_ctx, const anj_dm_security_instance_init_t *instance) |
| int | anj_dm_security_obj_install (anj_t *anj, anj_dm_security_obj_t *security_obj_ctx) |
| int | anj_dm_security_obj_get_psk (const anj_t *anj, bool bootstrap_credentials, anj_crypto_security_info_t *out_psk_identity, anj_crypto_security_info_t *out_psk_key) |
| int | anj_dm_security_obj_store (anj_t *anj, anj_dm_security_obj_t *security_obj_ctx, const anj_persistence_context_t *ctx) |
| int | anj_dm_security_obj_restore (anj_t *anj, anj_dm_security_obj_t *security_obj_ctx, const anj_persistence_context_t *ctx) |
Default implementation of the LwM2M Security Object (/0).
Provides initialization, instance management, optional persistence, and access to stored security credentials.
Possible values of the Security Mode Resource, as described in the Security Object definition. For details, see OMA LwM2M Core Specification v1.2.2 [OMA-TS-LightweightM2M_Core-V1_2_2-20240613-A] §E.1.
| int anj_dm_security_obj_add_instance | ( | anj_dm_security_obj_t * | security_obj_ctx, |
| const anj_dm_security_instance_init_t * | instance | ||
| ) |
Adds new Instance of Security Object.
instance is copied, so the caller can free it.| security_obj_ctx | Security Object state. |
| instance | Instance to insert. |
| int anj_dm_security_obj_get_psk | ( | const anj_t * | anj, |
| bool | bootstrap_credentials, | ||
| anj_crypto_security_info_t * | out_psk_identity, | ||
| anj_crypto_security_info_t * | out_psk_key | ||
| ) |
Retrieves the Pre-Shared Key (PSK) identity and key for the specified connection.
| anj | Anjay object to take the Security Object from. | |
| bootstrap_credentials | If true, retrieves credentials for the Bootstrap Server, otherwise for the regular LwM2M Server. | |
| [out] | out_psk_identity | Output parameter for the PSK identity. |
| [out] | out_psk_key | Output parameter for the PSK key. |
| void anj_dm_security_obj_init | ( | anj_dm_security_obj_t * | security_obj_ctx | ) |
Initializes Security Object internal state variable.
This function must be called once, before adding any Instances.
| security_obj_ctx | Pointer to a variable that will hold the state of the Object. |
| int anj_dm_security_obj_install | ( | anj_t * | anj, |
| anj_dm_security_obj_t * | security_obj_ctx | ||
| ) |
Installs Security Object in data model.
Call this function after adding all Instances using anj_dm_security_obj_add_instance. After calling this function, new Instances can be added only by LwM2M Bootstrap Server.
| anj | Anjay object. |
| security_obj_ctx | Security Object state. |
| int anj_dm_security_obj_restore | ( | anj_t * | anj, |
| anj_dm_security_obj_t * | security_obj_ctx, | ||
| const anj_persistence_context_t * | ctx | ||
| ) |
Deserializes the LwM2M Security Object from the persistence stream.
Reads Security Object instances and their resources from the underlying medium via ctx->read.
| anj | Initialized Anjay-Lite handle. |
| security_obj_ctx | Security Object context to fill. |
| ctx | Persistence context; must have anj_persistence_context_t::direction set to ANJ_PERSISTENCE_RESTORE. |
| int anj_dm_security_obj_store | ( | anj_t * | anj, |
| anj_dm_security_obj_t * | security_obj_ctx, | ||
| const anj_persistence_context_t * | ctx | ||
| ) |
Serializes the current LwM2M Security Object into the persistence stream.
Writes all present Security Object instances and their resources to the underlying medium via ctx->write.
| anj | Initialized Anjay-Lite handle. |
| security_obj_ctx | Security Object context to serialize. |
| ctx | Persistence context; must have anj_persistence_context_t::direction set to ANJ_PERSISTENCE_STORE. |