Anjay Lite
Loading...
Searching...
No Matches
security_object.h
Go to the documentation of this file.
1/*
2 * Copyright 2023-2026 AVSystem <avsystem@avsystem.com>
3 * AVSystem Anjay Lite LwM2M SDK
4 * All rights reserved.
5 *
6 * Licensed under AVSystem Anjay Lite LwM2M Client SDK - Non-Commercial License.
7 * See the attached LICENSE file for details.
8 */
9
10#include <anj/init.h>
11
20#ifndef ANJ_DM_SECURITY_OBJECT_H
21# define ANJ_DM_SECURITY_OBJECT_H
22
23# include <stdbool.h>
24# include <stddef.h>
25# include <stdint.h>
26
27# include <anj/defs.h>
28# include <anj/dm/core.h>
29
30# ifdef ANJ_WITH_PERSISTENCE
31# include <anj/persistence.h>
32# endif // ANJ_WITH_PERSISTENCE
33
34# ifdef ANJ_WITH_SECURITY
35# include <anj/crypto.h>
36# endif // ANJ_WITH_SECURITY
37
38# ifdef __cplusplus
39extern "C" {
40# endif
41
62
63# ifdef ANJ_WITH_DEFAULT_SECURITY_OBJ
64
66# ifdef ANJ_WITH_BOOTSTRAP
67# define ANJ_DM_SECURITY_OBJ_INSTANCES 2
68# else // ANJ_WITH_BOOTSTRAP
69# define ANJ_DM_SECURITY_OBJ_INSTANCES 1
70# endif // ANJ_WITH_BOOTSTRAP
74typedef struct {
75 // resources
76 char server_uri[ANJ_SERVER_URI_MAX_SIZE];
79# ifdef ANJ_WITH_SECURITY
80 uint8_t public_key_or_identity_buff
82 uint8_t server_public_key_buff[ANJ_SEC_OBJ_MAX_SERVER_PUBLIC_KEY_SIZE];
83 uint8_t secret_key_buff[ANJ_SEC_OBJ_MAX_SECRET_KEY_SIZE];
87# endif // ANJ_WITH_SECURITY
88 uint16_t ssid;
90
91 // metadata
94
138
148typedef struct {
150 anj_dm_obj_inst_t inst[ANJ_DM_SECURITY_OBJ_INSTANCES];
151 anj_dm_obj_inst_t cache_inst[ANJ_DM_SECURITY_OBJ_INSTANCES];
153 security_instances[ANJ_DM_SECURITY_OBJ_INSTANCES];
155 cache_security_instances[ANJ_DM_SECURITY_OBJ_INSTANCES];
159
169
184 anj_dm_security_obj_t *security_obj_ctx,
185 const anj_dm_security_instance_init_t *instance);
186
200 anj_dm_security_obj_t *security_obj_ctx);
201
202# ifdef ANJ_WITH_SECURITY
203
222 bool bootstrap_credentials,
223 anj_crypto_security_info_t *out_psk_identity,
224 anj_crypto_security_info_t *out_psk_key);
225# endif // ANJ_WITH_SECURITY
226
227# ifdef ANJ_WITH_PERSISTENCE
243 anj_dm_security_obj_t *security_obj_ctx,
244 const anj_persistence_context_t *ctx);
245
261 anj_dm_security_obj_t *security_obj_ctx,
262 const anj_persistence_context_t *ctx);
263# endif // ANJ_WITH_PERSISTENCE
264
265# endif // ANJ_WITH_DEFAULT_SECURITY_OBJ
266
267# ifdef __cplusplus
268}
269# endif
270
271#endif // ANJ_DM_SECURITY_OBJECT_H
#define ANJ_SEC_OBJ_MAX_SERVER_PUBLIC_KEY_SIZE
Definition anj_config.h:123
#define ANJ_SEC_OBJ_MAX_SECRET_KEY_SIZE
Definition anj_config.h:132
#define ANJ_SEC_OBJ_MAX_PUBLIC_KEY_OR_IDENTITY_SIZE
Definition anj_config.h:114
Cryptographic data descriptors used by Security Object and networking.
Core type and constant definitions for Anjay Lite.
struct anj_struct anj_t
Definition defs.h:129
#define ANJ_SERVER_URI_MAX_SIZE
Definition defs.h:144
uint16_t anj_iid_t
Definition defs.h:121
Core data model API: object management, read/write helpers, bootstrap.
Global configuration validation header for Anjay Lite.
Persistence API for storing and restoring Anjay Lite state.
void anj_dm_security_obj_init(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)
anj_dm_security_mode_t
Definition security_object.h:46
@ ANJ_DM_SECURITY_CERTIFICATE
Definition security_object.h:54
@ ANJ_DM_SECURITY_NOSEC
Definition security_object.h:57
@ ANJ_DM_SECURITY_EST
Definition security_object.h:60
@ ANJ_DM_SECURITY_PSK
Definition security_object.h:48
@ ANJ_DM_SECURITY_RPK
Definition security_object.h:51
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_install(anj_t *anj, anj_dm_security_obj_t *security_obj_ctx)
int anj_dm_security_obj_restore(anj_t *anj, anj_dm_security_obj_t *security_obj_ctx, const anj_persistence_context_t *ctx)
int anj_dm_security_obj_add_instance(anj_dm_security_obj_t *security_obj_ctx, const anj_dm_security_instance_init_t *instance)
Definition crypto.h:101
Definition defs.h:124
Definition defs.h:157
Definition security_object.h:99
uint16_t ssid
Definition security_object.h:124
const anj_iid_t * iid
Definition security_object.h:136
uint32_t client_hold_off_time
Definition security_object.h:130
anj_crypto_security_info_t public_key_or_identity
Definition security_object.h:111
bool bootstrap_server
Definition security_object.h:104
anj_crypto_security_info_t secret_key
Definition security_object.h:117
const char * server_uri
Definition security_object.h:101
anj_crypto_security_info_t server_public_key
Definition security_object.h:114
anj_dm_security_mode_t security_mode
Definition security_object.h:107
Definition security_object.h:74
uint16_t ssid
Definition security_object.h:88
anj_iid_t iid
Definition security_object.h:92
uint32_t client_hold_off_time
Definition security_object.h:89
anj_crypto_security_info_t public_key_or_identity
Definition security_object.h:84
bool bootstrap_server
Definition security_object.h:77
anj_crypto_security_info_t secret_key
Definition security_object.h:86
anj_crypto_security_info_t server_public_key
Definition security_object.h:85
anj_dm_security_mode_t security_mode
Definition security_object.h:78
Definition security_object.h:148
anj_dm_obj_t obj
Definition security_object.h:149
anj_iid_t new_instance_iid
Definition security_object.h:157
bool installed
Definition security_object.h:156
Definition persistence.h:91