Merge pull request #14513 from akshaim/Kconfig_credman
net/credman : Expose configurations to Kconfig
This commit is contained in:
commit
db29db330b
@ -34,12 +34,18 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup net_credman_conf (D)TLS Credential Manager compile configurations
|
||||||
|
* @ingroup config
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* @brief Maximum number of credentials in credential pool
|
* @brief Maximum number of credentials in credential pool
|
||||||
*/
|
*/
|
||||||
#ifndef CREDMAN_MAX_CREDENTIALS
|
#ifndef CONFIG_CREDMAN_MAX_CREDENTIALS
|
||||||
#define CREDMAN_MAX_CREDENTIALS (2)
|
#define CONFIG_CREDMAN_MAX_CREDENTIALS (2)
|
||||||
#endif
|
#endif
|
||||||
|
/** @} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Buffer of the credential
|
* @brief Buffer of the credential
|
||||||
@ -173,7 +179,7 @@ void credman_delete(credman_tag_t tag, credman_type_t type);
|
|||||||
/**
|
/**
|
||||||
* @brief Gets the number of credentials currently in the credential pool
|
* @brief Gets the number of credentials currently in the credential pool
|
||||||
*
|
*
|
||||||
* Maximum number of allowed credentials is defined by CREDMAN_MAX_CREDENTIALS
|
* Maximum number of allowed credentials is defined by CONFIG_CREDMAN_MAX_CREDENTIALS
|
||||||
*
|
*
|
||||||
* @return number of credentials currently in the credential pool
|
* @return number of credentials currently in the credential pool
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
menu "Networking"
|
menu "Networking"
|
||||||
|
|
||||||
rsource "application_layer/Kconfig"
|
rsource "application_layer/Kconfig"
|
||||||
|
rsource "credman/Kconfig"
|
||||||
rsource "gnrc/Kconfig"
|
rsource "gnrc/Kconfig"
|
||||||
rsource "sock/Kconfig"
|
rsource "sock/Kconfig"
|
||||||
rsource "link_layer/Kconfig"
|
rsource "link_layer/Kconfig"
|
||||||
|
|||||||
23
sys/net/credman/Kconfig
Normal file
23
sys/net/credman/Kconfig
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Copyright (c) 2020 Freie Universitaet Berlin
|
||||||
|
#
|
||||||
|
# This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
# General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
# directory for more details.
|
||||||
|
#
|
||||||
|
menuconfig KCONFIG_MODULE_CREDMAN
|
||||||
|
bool "Configure CREDMAN"
|
||||||
|
depends on MODULE_CREDMAN
|
||||||
|
help
|
||||||
|
Configure CREDMAN, Credentials management module for (D)TLS, using
|
||||||
|
Kconfig.
|
||||||
|
|
||||||
|
if KCONFIG_MODULE_CREDMAN
|
||||||
|
|
||||||
|
config CREDMAN_MAX_CREDENTIALS
|
||||||
|
int "MAX number of credentials in credential pool"
|
||||||
|
default 2
|
||||||
|
help
|
||||||
|
Configure 'CONFIG_CREDMAN_MAX_CREDENTIALS', the maximum number of
|
||||||
|
allowed credentials in the credential pool.
|
||||||
|
|
||||||
|
endif # KCONFIG_MODULE_CREDMAN
|
||||||
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
static mutex_t _mutex = MUTEX_INIT;
|
static mutex_t _mutex = MUTEX_INIT;
|
||||||
|
|
||||||
static credman_credential_t credentials[CREDMAN_MAX_CREDENTIALS];
|
static credman_credential_t credentials[CONFIG_CREDMAN_MAX_CREDENTIALS];
|
||||||
static unsigned used = 0;
|
static unsigned used = 0;
|
||||||
|
|
||||||
static int _find_credential_pos(credman_tag_t tag, credman_type_t type,
|
static int _find_credential_pos(credman_tag_t tag, credman_type_t type,
|
||||||
@ -129,7 +129,7 @@ int credman_get_used_count(void)
|
|||||||
static int _find_credential_pos(credman_tag_t tag, credman_type_t type,
|
static int _find_credential_pos(credman_tag_t tag, credman_type_t type,
|
||||||
credman_credential_t **empty)
|
credman_credential_t **empty)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < CREDMAN_MAX_CREDENTIALS; i++) {
|
for (unsigned i = 0; i < CONFIG_CREDMAN_MAX_CREDENTIALS; i++) {
|
||||||
credman_credential_t *c = &credentials[i];
|
credman_credential_t *c = &credentials[i];
|
||||||
if ((c->tag == tag) && (c->type == type)) {
|
if ((c->tag == tag) && (c->type == type)) {
|
||||||
return i;
|
return i;
|
||||||
@ -148,7 +148,7 @@ void credman_reset(void)
|
|||||||
{
|
{
|
||||||
mutex_lock(&_mutex);
|
mutex_lock(&_mutex);
|
||||||
memset(credentials, 0,
|
memset(credentials, 0,
|
||||||
sizeof(credman_credential_t) * CREDMAN_MAX_CREDENTIALS);
|
sizeof(credman_credential_t) * CONFIG_CREDMAN_MAX_CREDENTIALS);
|
||||||
used = 0;
|
used = 0;
|
||||||
mutex_unlock(&_mutex);
|
mutex_unlock(&_mutex);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -73,7 +73,7 @@ static void test_credman_add(void)
|
|||||||
|
|
||||||
/* fill the pool */
|
/* fill the pool */
|
||||||
memcpy(&credential.params.psk, &exp_psk_params, sizeof(psk_params_t));
|
memcpy(&credential.params.psk, &exp_psk_params, sizeof(psk_params_t));
|
||||||
while (credman_get_used_count() < CREDMAN_MAX_CREDENTIALS) {
|
while (credman_get_used_count() < CONFIG_CREDMAN_MAX_CREDENTIALS) {
|
||||||
/* increase tag number so that it is not recognized as duplicate */
|
/* increase tag number so that it is not recognized as duplicate */
|
||||||
credential.tag++;
|
credential.tag++;
|
||||||
TEST_ASSERT_EQUAL_INT(CREDMAN_OK, credman_add(&credential));
|
TEST_ASSERT_EQUAL_INT(CREDMAN_OK, credman_add(&credential));
|
||||||
@ -176,7 +176,7 @@ static void test_credman_delete_random_order(void)
|
|||||||
};
|
};
|
||||||
TEST_ASSERT_EQUAL_INT(0, credman_get_used_count());
|
TEST_ASSERT_EQUAL_INT(0, credman_get_used_count());
|
||||||
|
|
||||||
/* fill the credential pool, assume CREDMAN_MAX_CREDENTIALS is 2 */
|
/* fill the credential pool, assume CONFIG_CREDMAN_MAX_CREDENTIALS is 2 */
|
||||||
TEST_ASSERT_EQUAL_INT(CREDMAN_OK, credman_add(&in_credential));
|
TEST_ASSERT_EQUAL_INT(CREDMAN_OK, credman_add(&in_credential));
|
||||||
in_credential.tag = tag2;
|
in_credential.tag = tag2;
|
||||||
TEST_ASSERT_EQUAL_INT(CREDMAN_OK, credman_add(&in_credential));
|
TEST_ASSERT_EQUAL_INT(CREDMAN_OK, credman_add(&in_credential));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user