mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 14:49:24 +01:00
eap-tls-common: Introduce a common tls state and load settings
This commit is contained in:
parent
514d442db1
commit
87c411f816
@ -29,6 +29,7 @@
|
|||||||
#include <ell/ell.h>
|
#include <ell/ell.h>
|
||||||
|
|
||||||
#include "src/eap.h"
|
#include "src/eap.h"
|
||||||
|
#include "src/eap-private.h"
|
||||||
#include "src/eap-tls-common.h"
|
#include "src/eap-tls-common.h"
|
||||||
|
|
||||||
struct databuf *databuf_new(size_t capacity)
|
struct databuf *databuf_new(size_t capacity)
|
||||||
@ -74,6 +75,40 @@ void databuf_free(struct databuf *databuf)
|
|||||||
l_free(databuf);
|
l_free(databuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct eap_tls_state {
|
||||||
|
enum eap_tls_version version_negotiated;
|
||||||
|
|
||||||
|
char *ca_cert;
|
||||||
|
char *client_cert;
|
||||||
|
char *client_key;
|
||||||
|
char *passphrase;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void __eap_tls_common_state_reset(struct eap_tls_state *eap_tls)
|
||||||
|
{
|
||||||
|
eap_tls->version_negotiated = EAP_TLS_VERSION_NOT_NEGOTIATED;
|
||||||
|
}
|
||||||
|
|
||||||
|
void eap_tls_common_state_free(struct eap_state *eap)
|
||||||
|
{
|
||||||
|
struct eap_tls_state *eap_tls = eap_get_data(eap);
|
||||||
|
|
||||||
|
__eap_tls_common_state_reset(eap_tls);
|
||||||
|
|
||||||
|
eap_set_data(eap, NULL);
|
||||||
|
|
||||||
|
l_free(eap_tls->ca_cert);
|
||||||
|
l_free(eap_tls->client_cert);
|
||||||
|
l_free(eap_tls->client_key);
|
||||||
|
|
||||||
|
if (eap_tls->passphrase) {
|
||||||
|
memset(eap_tls->passphrase, 0, strlen(eap_tls->passphrase));
|
||||||
|
l_free(eap_tls->passphrase);
|
||||||
|
}
|
||||||
|
|
||||||
|
l_free(eap_tls);
|
||||||
|
}
|
||||||
|
|
||||||
int eap_tls_common_settings_check(struct l_settings *settings,
|
int eap_tls_common_settings_check(struct l_settings *settings,
|
||||||
struct l_queue *secrets,
|
struct l_queue *secrets,
|
||||||
const char *prefix,
|
const char *prefix,
|
||||||
@ -188,3 +223,36 @@ int eap_tls_common_settings_check(struct l_settings *settings,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool eap_tls_common_settings_load(struct eap_state *eap,
|
||||||
|
struct l_settings *settings,
|
||||||
|
const char *prefix)
|
||||||
|
{
|
||||||
|
struct eap_tls_state *eap_tls;
|
||||||
|
char setting_key[72];
|
||||||
|
|
||||||
|
eap_tls = l_new(struct eap_tls_state, 1);
|
||||||
|
|
||||||
|
eap_tls->version_negotiated = EAP_TLS_VERSION_NOT_NEGOTIATED;
|
||||||
|
|
||||||
|
snprintf(setting_key, sizeof(setting_key), "%sCACert", prefix);
|
||||||
|
eap_tls->ca_cert = l_settings_get_string(settings, "Security",
|
||||||
|
setting_key);
|
||||||
|
|
||||||
|
snprintf(setting_key, sizeof(setting_key), "%sClientCert", prefix);
|
||||||
|
eap_tls->client_cert = l_settings_get_string(settings, "Security",
|
||||||
|
setting_key);
|
||||||
|
|
||||||
|
snprintf(setting_key, sizeof(setting_key), "%sClientKey", prefix);
|
||||||
|
eap_tls->client_key = l_settings_get_string(settings, "Security",
|
||||||
|
setting_key);
|
||||||
|
|
||||||
|
snprintf(setting_key, sizeof(setting_key), "%sClientKeyPassphrase",
|
||||||
|
prefix);
|
||||||
|
eap_tls->passphrase = l_settings_get_string(settings, "Security",
|
||||||
|
setting_key);
|
||||||
|
|
||||||
|
eap_set_data(eap, eap_tls);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -32,7 +32,19 @@ void databuf_append(struct databuf *databuf, const uint8_t *data,
|
|||||||
size_t data_len);
|
size_t data_len);
|
||||||
void databuf_free(struct databuf *databuf);
|
void databuf_free(struct databuf *databuf);
|
||||||
|
|
||||||
|
enum eap_tls_version {
|
||||||
|
EAP_TLS_VERSION_0 = 0x00,
|
||||||
|
EAP_TLS_VERSION_1 = 0x01,
|
||||||
|
EAP_TLS_VERSION_MASK = 0x07,
|
||||||
|
EAP_TLS_VERSION_NOT_NEGOTIATED = 0x08,
|
||||||
|
};
|
||||||
|
|
||||||
|
void eap_tls_common_state_free(struct eap_state *eap);
|
||||||
|
|
||||||
int eap_tls_common_settings_check(struct l_settings *settings,
|
int eap_tls_common_settings_check(struct l_settings *settings,
|
||||||
struct l_queue *secrets,
|
struct l_queue *secrets,
|
||||||
const char *prefix,
|
const char *prefix,
|
||||||
struct l_queue **out_missing);
|
struct l_queue **out_missing);
|
||||||
|
bool eap_tls_common_settings_load(struct eap_state *eap,
|
||||||
|
struct l_settings *settings,
|
||||||
|
const char *prefix);
|
||||||
|
Loading…
Reference in New Issue
Block a user