Program Listing for File security.h

Return to documentation for file (include_public/anj/security.h)

/*
 * Copyright 2023-2026 AVSystem <avsystem@avsystem.com>
 * AVSystem Anjay Lite LwM2M SDK
 * All rights reserved.
 *
 * Licensed under AVSystem Anjay Lite LwM2M Client SDK - Non-Commercial License.
 * See the attached LICENSE file for details.
 */

#include <anj/init.h>

#ifndef ANJ_SECURITY_H
#    define ANJ_SECURITY_H

#    include <stdbool.h>

#    include <anj/compat/net/anj_net_api.h>
#    include <anj/crypto.h>
#    include <anj/defs.h>

#    ifdef __cplusplus
extern "C" {
#    endif

#    ifdef ANJ_WITH_SECURITY

typedef int
anj_security_get_psk_info_handler_t(const anj_t *anj,
                                    bool bootstrap_credentials,
                                    anj_net_psk_info_t *out_psk_info);

#        ifdef ANJ_WITH_CERTIFICATES
typedef int
anj_security_get_cert_info_handler_t(const anj_t *anj,
                                     bool bootstrap_credentials,
                                     anj_net_certificate_info_t *out_cert_info);
#        endif // ANJ_WITH_CERTIFICATES

#        ifdef ANJ_WITH_EXTERNAL_CRYPTO_STORAGE
typedef int anj_security_offload_keys_and_certs_handler_t(anj_t *anj);
#        endif // ANJ_WITH_EXTERNAL_CRYPTO_STORAGE

typedef struct {
    anj_security_get_psk_info_handler_t *get_psk_info;
#        ifdef ANJ_WITH_CERTIFICATES
    anj_security_get_cert_info_handler_t *get_cert_info;
#        endif // ANJ_WITH_CERTIFICATES
#        ifdef ANJ_WITH_EXTERNAL_CRYPTO_STORAGE
    anj_security_offload_keys_and_certs_handler_t *offload_keys_and_certs;
#        endif // ANJ_WITH_EXTERNAL_CRYPTO_STORAGE
} anj_security_credential_handlers_t;

void anj_security_register_credential_handlers(
        anj_t *anj, const anj_security_credential_handlers_t *handlers);

int anj_security_get_psk_info(const anj_t *anj,
                              bool bootstrap_credentials,
                              anj_net_psk_info_t *out_psk_info);

#        ifdef ANJ_WITH_CERTIFICATES
int anj_security_get_cert_info(const anj_t *anj,
                               bool bootstrap_credentials,
                               anj_net_certificate_info_t *out_cert_info);
#        endif // ANJ_WITH_CERTIFICATES

#    endif // ANJ_WITH_SECURITY

#    ifdef __cplusplus
}
#    endif

#endif // ANJ_SECURITY_H