mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-09-14 21:11:55 +00:00
Add TLS credential management subsystem that enables to register TLS credentials in the system. Once specific credentials are registered in the system, they will be available for TLS secure sockets to use. To use a TLS credential with a socket, the following steps have to be taken: 1. TLS credential has to be registered in a system-wide pool, using the API provided in "net/tls_credentials.h" header file. 2. TLS credential (and other TLS parameters) should be set on a socket using setsockopt(). Note, that there is no need to repeat step 1 for different sockets using the same credentials. Once TLS credential is registered in the system, it can be used with mulitple sockets, as long as it's not deleted. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
55 lines
1.3 KiB
C
55 lines
1.3 KiB
C
/*
|
|
* Copyright (c) 2018 Nordic Semiconductor ASA
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/** @file
|
|
* @brief Internal API for fetching TLS credentials
|
|
*/
|
|
|
|
#ifndef __TLS_INTERNAL_H
|
|
#define __TLS_INTERNAL_H
|
|
|
|
#include <net/tls_credentials.h>
|
|
|
|
/* Internal structure representing TLS credential. */
|
|
struct tls_credential {
|
|
/* TLS credential type. */
|
|
enum tls_credential_type type;
|
|
|
|
/* Secure tag that credential can be referenced with. */
|
|
sec_tag_t tag;
|
|
|
|
/* A pointer to the credential buffer. */
|
|
const void *buf;
|
|
|
|
/* Credential length. */
|
|
size_t len;
|
|
};
|
|
|
|
/* Lock TLS credential access. */
|
|
void credentials_lock(void);
|
|
|
|
/* Unlock TLS credential access. */
|
|
void credentials_unlock(void);
|
|
|
|
/* Function for getting credential by tag and type.
|
|
*
|
|
* Note, that to assure thread safety, credential access should be locked with
|
|
* credentials_lock before calling this function.
|
|
*/
|
|
struct tls_credential *credential_get(sec_tag_t tag,
|
|
enum tls_credential_type type);
|
|
|
|
|
|
/* Function for iterating over credentials by tag.
|
|
*
|
|
* Note, that to assure thread safety, credential access should be locked with
|
|
* credentials_lock before calling this function.
|
|
*/
|
|
struct tls_credential *credential_next_get(sec_tag_t tag,
|
|
struct tls_credential *iter);
|
|
|
|
#endif /* __TLS_INTERNAL_H */
|