mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 04:32:37 +01:00
eap-tls-common: introduce utility functions for eap-tls
This commit is contained in:
parent
6f833d6cad
commit
410ee2f6b9
@ -97,7 +97,8 @@ eap_sources = src/eap.c src/eap.h src/eap-private.h \
|
||||
src/wscutil.h src/wscutil.c \
|
||||
src/simutil.h src/simutil.c \
|
||||
src/simauth.h src/simauth.c \
|
||||
src/watchlist.h src/watchlist.c
|
||||
src/watchlist.h src/watchlist.c \
|
||||
src/eap-tls-common.h src/eap-tls-common.c
|
||||
|
||||
if DAEMON
|
||||
libexec_PROGRAMS += src/iwd
|
||||
@ -318,7 +319,8 @@ unit_test_eapol_SOURCES = unit/test-eapol.c \
|
||||
src/handshake.h src/handshake.c \
|
||||
src/eap.h src/eap.c src/eap-private.h \
|
||||
src/eap-tls.c src/eap-ttls.c \
|
||||
src/eap-md5.c src/util.c
|
||||
src/eap-md5.c src/util.c \
|
||||
src/eap-tls-common.h src/eap-tls-common.c
|
||||
unit_test_eapol_LDADD = ell/libell-internal.la
|
||||
|
||||
unit_test_ssid_to_utf8_SOURCES = src/util.h src/util.c \
|
||||
|
72
src/eap-tls-common.c
Normal file
72
src/eap-tls-common.c
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
*
|
||||
* Wireless daemon for Linux
|
||||
*
|
||||
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <ell/ell.h>
|
||||
|
||||
#include "eap-tls-common.h"
|
||||
|
||||
struct databuf *databuf_new(size_t capacity)
|
||||
{
|
||||
struct databuf *databuf;
|
||||
|
||||
if (!capacity)
|
||||
return NULL;
|
||||
|
||||
databuf = l_new(struct databuf, 1);
|
||||
databuf->data = l_malloc(capacity);
|
||||
databuf->capacity = capacity;
|
||||
|
||||
return databuf;
|
||||
}
|
||||
|
||||
void databuf_append(struct databuf *databuf, const uint8_t *data,
|
||||
size_t data_len)
|
||||
{
|
||||
size_t new_len;
|
||||
|
||||
if (!databuf)
|
||||
return;
|
||||
|
||||
new_len = databuf->len + data_len;
|
||||
|
||||
if (new_len > databuf->capacity) {
|
||||
databuf->capacity = new_len * 2;
|
||||
databuf->data = l_realloc(databuf->data, databuf->capacity);
|
||||
}
|
||||
|
||||
memcpy(databuf->data + databuf->len, data, data_len);
|
||||
|
||||
databuf->len = new_len;
|
||||
}
|
||||
|
||||
void databuf_free(struct databuf *databuf)
|
||||
{
|
||||
if (!databuf)
|
||||
return;
|
||||
|
||||
l_free(databuf->data);
|
||||
l_free(databuf);
|
||||
}
|
33
src/eap-tls-common.h
Normal file
33
src/eap-tls-common.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
*
|
||||
* Wireless daemon for Linux
|
||||
*
|
||||
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
struct databuf {
|
||||
uint8_t *data;
|
||||
size_t len;
|
||||
size_t capacity;
|
||||
};
|
||||
|
||||
struct databuf;
|
||||
struct databuf *databuf_new(size_t capacity);
|
||||
void databuf_append(struct databuf *databuf, const uint8_t *data,
|
||||
size_t data_len);
|
||||
void databuf_free(struct databuf *databuf);
|
Loading…
Reference in New Issue
Block a user