Loading...
Searching...
No Matches
security.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 HAW Hamburg
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
9#pragma once
10
159
160#ifdef __cplusplus
161extern "C" {
162#endif
163
164#include <stdio.h>
165#include <stdlib.h>
166#include <string.h>
167#include <assert.h>
168
169#include "liblwm2m.h"
170#include "net/credman.h"
171#include "lwm2m_client.h"
172#include "lwm2m_client_config.h"
173
174/* these are defined in liblwm2m.h, and are reproduced here for documentation purposes */
175#ifdef DOXYGEN
183#define LWM2M_SECURITY_MODE_PRE_SHARED_KEY 0
184
188#define LWM2M_SECURITY_MODE_RAW_PUBLIC_KEY 1
189
193#define LWM2M_SECURITY_MODE_CERTIFICATE 2
194
198#define LWM2M_SECURITY_MODE_NONE 3
200
208#define LWM2M_SECURITY_URI_ID 0
209
213#define LWM2M_SECURITY_BOOTSTRAP_ID 1
214
218#define LWM2M_SECURITY_SECURITY_ID 2
219
223#define LWM2M_SECURITY_PUBLIC_KEY_ID 3
224
228#define LWM2M_SECURITY_SERVER_PUBLIC_KEY_ID 4
229
233#define LWM2M_SECURITY_SECRET_KEY_ID 5
234
238#define LWM2M_SECURITY_SMS_SECURITY_ID 6
239
243#define LWM2M_SECURITY_SMS_KEY_PARAM_ID 7
244
248#define LWM2M_SECURITY_SMS_SECRET_KEY_ID 8
249
253#define LWM2M_SECURITY_SMS_SERVER_NUMBER_ID 9
254
258#define LWM2M_SECURITY_SHORT_SERVER_ID 10
259
263#define LWM2M_SECURITY_HOLD_OFF_ID 11
264
268#define LWM2M_SECURITY_BOOTSTRAP_TIMEOUT_ID 12
270#endif /* DOXYGEN */
271
280#ifndef CONFIG_LWM2M_OBJ_SECURITY_INSTANCES_MAX
281#define CONFIG_LWM2M_OBJ_SECURITY_INSTANCES_MAX (2)
282#endif
283
287#ifndef CONFIG_LWM2M_OBJ_SECURITY_PUB_KEY_ID_BUFSIZE
288#define CONFIG_LWM2M_OBJ_SECURITY_PUB_KEY_ID_BUFSIZE (128)
289#endif
290
294#ifndef CONFIG_LWM2M_OBJ_SECURITY_SERVER_PUB_KEY_BUFSIZE
295#define CONFIG_LWM2M_OBJ_SECURITY_SERVER_PUB_KEY_BUFSIZE (128)
296#endif
297
301#ifndef CONFIG_LWM2M_OBJ_SECURITY_SEC_KEY_BUFSIZE
302#define CONFIG_LWM2M_OBJ_SECURITY_SEC_KEY_BUFSIZE (64)
303#endif
305
314 uint16_t server_id;
315
321 const char *server_uri;
322
329
338 const uint8_t *pub_key_or_id;
339
344
353 const uint8_t *secret_key;
354
359
368 const uint8_t *server_pub_key;
369
374
379
385
392
401
415 int32_t instance_id);
416
426
427#ifdef __cplusplus
428}
429#endif
430
POSIX.1-2008 compliant version of the assert macro.
(D)TLS credentials management module definitions
credman_tag_t lwm2m_object_security_get_credential(uint16_t instance_id)
Get the credential of a given instance of the security object.
lwm2m_object_t * lwm2m_object_security_init(lwm2m_client_data_t *client_data)
Initialize the Security object.
struct lwm2m_obj_security_args lwm2m_obj_security_args_t
Arguments for a new Security object instance creation (lwm2m_object_security_instance_create).
int lwm2m_object_security_instance_create(const lwm2m_obj_security_args_t *args, int32_t instance_id)
Create a new Security instance and add it to the object list.
uint16_t credman_tag_t
Tag of the credential.
Definition credman.h:95
Definitions and public API for a LwM2M client using Wakaama.
LwM2M client configurations.
LwM2M client descriptor.
Arguments for a new Security object instance creation (lwm2m_object_security_instance_create).
Definition security.h:310
const uint8_t * pub_key_or_id
Pointer to the Key ID when using LWM2M_SECURITY_MODE_PRE_SHARED_KEY.
Definition security.h:338
uint16_t server_id
Server's short ID the instance is associated to.
Definition security.h:314
const uint8_t * server_pub_key
Pointer to the server public key encoded as a SubjectPublicKeyInfo sequence when using LWM2M_SECURITY...
Definition security.h:368
size_t secret_key_len
Length of lwm2m_obj_security_args_t::secret_key.
Definition security.h:358
const char * server_uri
Server's URI the instance is associated to.
Definition security.h:321
bool is_bootstrap
When true the security instance is associated to the Bootstrap-Server.
Definition security.h:378
uint8_t security_mode
Security mode to use.
Definition security.h:328
size_t pub_key_or_id_len
Length of lwm2m_obj_security_args_t::pub_key_or_id.
Definition security.h:343
const uint8_t * secret_key
Pointer to the Key when using LWM2M_SECURITY_MODE_PRE_SHARED_KEY.
Definition security.h:353
uint32_t client_hold_off_time
Time, in seconds, to wait before initiating a 'Client Initiated Bootstrap', after it has been determi...
Definition security.h:384
uint32_t bootstrap_account_timeout
Time, in seconds, that the client waits before it purges the Bootstrap-Server's account.
Definition security.h:390
size_t server_pub_key_len
Length of lwm2m_obj_security_args_t::server_pub_key.
Definition security.h:373