mirror of
https://github.com/Ysurac/openmptcprouter.git
synced 2025-03-09 15:40:20 +00:00
Add first test for kernel 6.10 support
This commit is contained in:
parent
f735d6c75a
commit
f023e9c6e5
271 changed files with 57306 additions and 14 deletions
76
6.10/package/libs/libnftnl/Makefile
Normal file
76
6.10/package/libs/libnftnl/Makefile
Normal file
|
@ -0,0 +1,76 @@
|
|||
#
|
||||
# Copyright (C) 2014 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=libnftnl
|
||||
PKG_CPE_ID:=cpe:/a:netfilter:libnftnl
|
||||
PKG_VERSION:=1.2.6
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
PKG_SOURCE_URL:=https://netfilter.org/projects/$(PKG_NAME)/files
|
||||
PKG_HASH:=ceeaea2cd92147da19f13a35a7f1a4bc2767ff897e838e4b479cf54b59c777f4
|
||||
|
||||
PKG_MAINTAINER:=Steven Barth <steven@midlink.org>
|
||||
PKG_LICENSE:=GPL-2.0-or-later
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
|
||||
PKG_INSTALL:=1
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_BUILD_FLAGS:=lto
|
||||
PKG_FIXUP:=autoreconf
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
DISABLE_NLS:=
|
||||
|
||||
define Package/libnftnl
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
DEPENDS:=+libmnl
|
||||
TITLE:=Low-level netlink library for the nf_tables subsystem
|
||||
URL:=http://www.netfilter.org/projects/libnftnl
|
||||
ABI_VERSION:=11
|
||||
endef
|
||||
|
||||
define Package/libnftnl/description
|
||||
libnftnl is a userspace library providing a low-level netlink
|
||||
programming interface (API) to the in-kernel nf_tables subsystem.
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += $(FPIC)
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-static \
|
||||
--enable-shared
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include/libnftnl
|
||||
$(CP) \
|
||||
$(PKG_INSTALL_DIR)/usr/include/libnftnl/*.h \
|
||||
$(1)/usr/include/libnftnl/
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) \
|
||||
$(PKG_INSTALL_DIR)/usr/lib/libnftnl.{so*,a,la} \
|
||||
$(1)/usr/lib/
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
|
||||
$(CP) \
|
||||
$(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libnftnl.pc \
|
||||
$(1)/usr/lib/pkgconfig/
|
||||
endef
|
||||
|
||||
define Package/libnftnl/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) \
|
||||
$(PKG_INSTALL_DIR)/usr/lib/libnftnl.so.* \
|
||||
$(1)/usr/lib/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libnftnl))
|
|
@ -0,0 +1,254 @@
|
|||
From 6c39f04febd7cfdbd474233379416babcd0fc341 Mon Sep 17 00:00:00 2001
|
||||
From: Syrone Wong <wong.syrone@gmail.com>
|
||||
Date: Fri, 8 Apr 2022 23:52:11 +0800
|
||||
Subject: [PATCH] libnftnl: add fullcone expression support
|
||||
|
||||
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
|
||||
---
|
||||
include/libnftnl/expr.h | 6 +
|
||||
include/linux/netfilter/nf_tables.h | 16 +++
|
||||
src/Makefile.am | 1 +
|
||||
src/expr/fullcone.c | 167 ++++++++++++++++++++++++++++
|
||||
src/expr_ops.c | 2 +
|
||||
5 files changed, 192 insertions(+)
|
||||
create mode 100644 src/expr/fullcone.c
|
||||
|
||||
--- a/include/libnftnl/expr.h
|
||||
+++ b/include/libnftnl/expr.h
|
||||
@@ -245,6 +245,12 @@ enum {
|
||||
};
|
||||
|
||||
enum {
|
||||
+ NFTNL_EXPR_FULLCONE_FLAGS = NFTNL_EXPR_BASE,
|
||||
+ NFTNL_EXPR_FULLCONE_REG_PROTO_MIN,
|
||||
+ NFTNL_EXPR_FULLCONE_REG_PROTO_MAX,
|
||||
+};
|
||||
+
|
||||
+enum {
|
||||
NFTNL_EXPR_REDIR_REG_PROTO_MIN = NFTNL_EXPR_BASE,
|
||||
NFTNL_EXPR_REDIR_REG_PROTO_MAX,
|
||||
NFTNL_EXPR_REDIR_FLAGS,
|
||||
--- a/include/linux/netfilter/nf_tables.h
|
||||
+++ b/include/linux/netfilter/nf_tables.h
|
||||
@@ -1434,6 +1434,22 @@ enum nft_masq_attributes {
|
||||
#define NFTA_MASQ_MAX (__NFTA_MASQ_MAX - 1)
|
||||
|
||||
/**
|
||||
+ * enum nft_fullcone_attributes - nf_tables fullcone expression attributes
|
||||
+ *
|
||||
+ * @NFTA_FULLCONE_FLAGS: NAT flags (see NF_NAT_RANGE_* in linux/netfilter/nf_nat.h) (NLA_U32)
|
||||
+ * @NFTA_FULLCONE_REG_PROTO_MIN: source register of proto range start (NLA_U32: nft_registers)
|
||||
+ * @NFTA_FULLCONE_REG_PROTO_MAX: source register of proto range end (NLA_U32: nft_registers)
|
||||
+ */
|
||||
+enum nft_fullcone_attributes {
|
||||
+ NFTA_FULLCONE_UNSPEC,
|
||||
+ NFTA_FULLCONE_FLAGS,
|
||||
+ NFTA_FULLCONE_REG_PROTO_MIN,
|
||||
+ NFTA_FULLCONE_REG_PROTO_MAX,
|
||||
+ __NFTA_FULLCONE_MAX
|
||||
+};
|
||||
+#define NFTA_FULLCONE_MAX (__NFTA_FULLCONE_MAX - 1)
|
||||
+
|
||||
+/**
|
||||
* enum nft_redir_attributes - nf_tables redirect expression netlink attributes
|
||||
*
|
||||
* @NFTA_REDIR_REG_PROTO_MIN: source register of proto range start (NLA_U32: nft_registers)
|
||||
--- a/src/Makefile.am
|
||||
+++ b/src/Makefile.am
|
||||
@@ -54,6 +54,7 @@ libnftnl_la_SOURCES = utils.c \
|
||||
expr/target.c \
|
||||
expr/tunnel.c \
|
||||
expr/masq.c \
|
||||
+ expr/fullcone.c \
|
||||
expr/redir.c \
|
||||
expr/hash.c \
|
||||
expr/socket.c \
|
||||
--- /dev/null
|
||||
+++ b/src/expr/fullcone.c
|
||||
@@ -0,0 +1,168 @@
|
||||
+/*
|
||||
+ * (C) 2022 wongsyrone
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License as published
|
||||
+ * by the Free Software Foundation; either version 2 of the License, or
|
||||
+ * (at your option) any later version.
|
||||
+ */
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+#include <stdint.h>
|
||||
+#include <arpa/inet.h>
|
||||
+#include <errno.h>
|
||||
+#include <inttypes.h>
|
||||
+
|
||||
+#include <linux/netfilter/nf_tables.h>
|
||||
+
|
||||
+#include "internal.h"
|
||||
+#include <libmnl/libmnl.h>
|
||||
+#include <libnftnl/expr.h>
|
||||
+#include <libnftnl/rule.h>
|
||||
+
|
||||
+struct nftnl_expr_fullcone {
|
||||
+ uint32_t flags;
|
||||
+ enum nft_registers sreg_proto_min;
|
||||
+ enum nft_registers sreg_proto_max;
|
||||
+};
|
||||
+
|
||||
+static int
|
||||
+nftnl_expr_fullcone_set(struct nftnl_expr *e, uint16_t type,
|
||||
+ const void *data, uint32_t data_len)
|
||||
+{
|
||||
+ struct nftnl_expr_fullcone *fullcone = nftnl_expr_data(e);
|
||||
+
|
||||
+ switch (type) {
|
||||
+ case NFTNL_EXPR_FULLCONE_FLAGS:
|
||||
+ memcpy(&fullcone->flags, data, sizeof(fullcone->flags));
|
||||
+ break;
|
||||
+ case NFTNL_EXPR_FULLCONE_REG_PROTO_MIN:
|
||||
+ memcpy(&fullcone->sreg_proto_min, data, sizeof(fullcone->sreg_proto_min));
|
||||
+ break;
|
||||
+ case NFTNL_EXPR_FULLCONE_REG_PROTO_MAX:
|
||||
+ memcpy(&fullcone->sreg_proto_max, data, sizeof(fullcone->sreg_proto_max));
|
||||
+ break;
|
||||
+ default:
|
||||
+ return -1;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const void *
|
||||
+nftnl_expr_fullcone_get(const struct nftnl_expr *e, uint16_t type,
|
||||
+ uint32_t *data_len)
|
||||
+{
|
||||
+ struct nftnl_expr_fullcone *fullcone = nftnl_expr_data(e);
|
||||
+
|
||||
+ switch (type) {
|
||||
+ case NFTNL_EXPR_FULLCONE_FLAGS:
|
||||
+ *data_len = sizeof(fullcone->flags);
|
||||
+ return &fullcone->flags;
|
||||
+ case NFTNL_EXPR_FULLCONE_REG_PROTO_MIN:
|
||||
+ *data_len = sizeof(fullcone->sreg_proto_min);
|
||||
+ return &fullcone->sreg_proto_min;
|
||||
+ case NFTNL_EXPR_FULLCONE_REG_PROTO_MAX:
|
||||
+ *data_len = sizeof(fullcone->sreg_proto_max);
|
||||
+ return &fullcone->sreg_proto_max;
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static int nftnl_expr_fullcone_cb(const struct nlattr *attr, void *data)
|
||||
+{
|
||||
+ const struct nlattr **tb = data;
|
||||
+ int type = mnl_attr_get_type(attr);
|
||||
+
|
||||
+ if (mnl_attr_type_valid(attr, NFTA_FULLCONE_MAX) < 0)
|
||||
+ return MNL_CB_OK;
|
||||
+
|
||||
+ switch (type) {
|
||||
+ case NFTA_FULLCONE_REG_PROTO_MIN:
|
||||
+ case NFTA_FULLCONE_REG_PROTO_MAX:
|
||||
+ case NFTA_FULLCONE_FLAGS:
|
||||
+ if (mnl_attr_validate(attr, MNL_TYPE_U32) < 0)
|
||||
+ abi_breakage();
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ tb[type] = attr;
|
||||
+ return MNL_CB_OK;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+nftnl_expr_fullcone_build(struct nlmsghdr *nlh, const struct nftnl_expr *e)
|
||||
+{
|
||||
+ struct nftnl_expr_fullcone *fullcone = nftnl_expr_data(e);
|
||||
+
|
||||
+ if (e->flags & (1 << NFTNL_EXPR_FULLCONE_FLAGS))
|
||||
+ mnl_attr_put_u32(nlh, NFTA_FULLCONE_FLAGS, htobe32(fullcone->flags));
|
||||
+ if (e->flags & (1 << NFTNL_EXPR_FULLCONE_REG_PROTO_MIN))
|
||||
+ mnl_attr_put_u32(nlh, NFTA_FULLCONE_REG_PROTO_MIN,
|
||||
+ htobe32(fullcone->sreg_proto_min));
|
||||
+ if (e->flags & (1 << NFTNL_EXPR_FULLCONE_REG_PROTO_MAX))
|
||||
+ mnl_attr_put_u32(nlh, NFTA_FULLCONE_REG_PROTO_MAX,
|
||||
+ htobe32(fullcone->sreg_proto_max));
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+nftnl_expr_fullcone_parse(struct nftnl_expr *e, struct nlattr *attr)
|
||||
+{
|
||||
+ struct nftnl_expr_fullcone *fullcone = nftnl_expr_data(e);
|
||||
+ struct nlattr *tb[NFTA_FULLCONE_MAX+1] = {};
|
||||
+
|
||||
+ if (mnl_attr_parse_nested(attr, nftnl_expr_fullcone_cb, tb) < 0)
|
||||
+ return -1;
|
||||
+
|
||||
+ if (tb[NFTA_FULLCONE_FLAGS]) {
|
||||
+ fullcone->flags = be32toh(mnl_attr_get_u32(tb[NFTA_FULLCONE_FLAGS]));
|
||||
+ e->flags |= (1 << NFTNL_EXPR_FULLCONE_FLAGS);
|
||||
+ }
|
||||
+ if (tb[NFTA_FULLCONE_REG_PROTO_MIN]) {
|
||||
+ fullcone->sreg_proto_min =
|
||||
+ be32toh(mnl_attr_get_u32(tb[NFTA_FULLCONE_REG_PROTO_MIN]));
|
||||
+ e->flags |= (1 << NFTNL_EXPR_FULLCONE_REG_PROTO_MIN);
|
||||
+ }
|
||||
+ if (tb[NFTA_FULLCONE_REG_PROTO_MAX]) {
|
||||
+ fullcone->sreg_proto_max =
|
||||
+ be32toh(mnl_attr_get_u32(tb[NFTA_FULLCONE_REG_PROTO_MAX]));
|
||||
+ e->flags |= (1 << NFTNL_EXPR_FULLCONE_REG_PROTO_MAX);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int nftnl_expr_fullcone_snprintf(char *buf, size_t remain,
|
||||
+ uint32_t flags, const struct nftnl_expr *e)
|
||||
+{
|
||||
+ struct nftnl_expr_fullcone *fullcone = nftnl_expr_data(e);
|
||||
+ int offset = 0, ret = 0;
|
||||
+
|
||||
+ if (e->flags & (1 << NFTNL_EXPR_FULLCONE_REG_PROTO_MIN)) {
|
||||
+ ret = snprintf(buf + offset, remain, "proto_min reg %u ",
|
||||
+ fullcone->sreg_proto_min);
|
||||
+ SNPRINTF_BUFFER_SIZE(ret, remain, offset);
|
||||
+ }
|
||||
+ if (e->flags & (1 << NFTNL_EXPR_FULLCONE_REG_PROTO_MAX)) {
|
||||
+ ret = snprintf(buf + offset, remain, "proto_max reg %u ",
|
||||
+ fullcone->sreg_proto_max);
|
||||
+ SNPRINTF_BUFFER_SIZE(ret, remain, offset);
|
||||
+ }
|
||||
+ if (e->flags & (1 << NFTNL_EXPR_FULLCONE_FLAGS)) {
|
||||
+ ret = snprintf(buf + offset, remain, "flags 0x%x ", fullcone->flags);
|
||||
+ SNPRINTF_BUFFER_SIZE(ret, remain, offset);
|
||||
+ }
|
||||
+
|
||||
+ return offset;
|
||||
+}
|
||||
+
|
||||
+struct expr_ops expr_ops_fullcone = {
|
||||
+ .name = "fullcone",
|
||||
+ .alloc_len = sizeof(struct nftnl_expr_fullcone),
|
||||
+ .max_attr = NFTA_FULLCONE_MAX,
|
||||
+ .set = nftnl_expr_fullcone_set,
|
||||
+ .get = nftnl_expr_fullcone_get,
|
||||
+ .parse = nftnl_expr_fullcone_parse,
|
||||
+ .build = nftnl_expr_fullcone_build,
|
||||
+ .output = nftnl_expr_fullcone_snprintf,
|
||||
+};
|
||||
+
|
||||
--- a/src/expr_ops.c
|
||||
+++ b/src/expr_ops.c
|
||||
@@ -19,6 +19,7 @@ extern struct expr_ops expr_ops_limit;
|
||||
extern struct expr_ops expr_ops_log;
|
||||
extern struct expr_ops expr_ops_lookup;
|
||||
extern struct expr_ops expr_ops_masq;
|
||||
+extern struct expr_ops expr_ops_fullcone;
|
||||
extern struct expr_ops expr_ops_match;
|
||||
extern struct expr_ops expr_ops_meta;
|
||||
extern struct expr_ops expr_ops_ng;
|
||||
@@ -63,6 +64,7 @@ static struct expr_ops *expr_ops[] = {
|
||||
&expr_ops_log,
|
||||
&expr_ops_lookup,
|
||||
&expr_ops_masq,
|
||||
+ &expr_ops_fullcone,
|
||||
&expr_ops_match,
|
||||
&expr_ops_meta,
|
||||
&expr_ops_ng,
|
200
6.10/package/libs/mbedtls/Config.in
Normal file
200
6.10/package/libs/mbedtls/Config.in
Normal file
|
@ -0,0 +1,200 @@
|
|||
if PACKAGE_libmbedtls
|
||||
|
||||
comment "Option details in source code: include/mbedtls/mbedtls_config.h"
|
||||
|
||||
comment "Ciphers - unselect old or less-used ciphers to reduce binary size"
|
||||
|
||||
config MBEDTLS_AES_C
|
||||
bool "MBEDTLS_AES_C"
|
||||
default y
|
||||
|
||||
config MBEDTLS_CAMELLIA_C
|
||||
bool "MBEDTLS_CAMELLIA_C"
|
||||
default n
|
||||
|
||||
config MBEDTLS_CCM_C
|
||||
bool "MBEDTLS_CCM_C"
|
||||
default n
|
||||
|
||||
config MBEDTLS_CMAC_C
|
||||
bool "MBEDTLS_CMAC_C (old but used by hostapd)"
|
||||
default y
|
||||
|
||||
config MBEDTLS_DES_C
|
||||
bool "MBEDTLS_DES_C (old but used by hostapd)"
|
||||
default y
|
||||
|
||||
config MBEDTLS_GCM_C
|
||||
bool "MBEDTLS_GCM_C"
|
||||
default y
|
||||
|
||||
config MBEDTLS_NIST_KW_C
|
||||
bool "MBEDTLS_NIST_KW_C (old but used by hostapd)"
|
||||
default y
|
||||
|
||||
config MBEDTLS_RIPEMD160_C
|
||||
bool "MBEDTLS_RIPEMD160_C"
|
||||
default n
|
||||
|
||||
config MBEDTLS_XTEA_C
|
||||
bool "MBEDTLS_XTEA_C"
|
||||
default n
|
||||
|
||||
config MBEDTLS_RSA_NO_CRT
|
||||
bool "MBEDTLS_RSA_NO_CRT"
|
||||
default y
|
||||
|
||||
config MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
|
||||
bool "MBEDTLS_KEY_EXCHANGE_PSK_ENABLED"
|
||||
default y
|
||||
|
||||
config MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED
|
||||
bool "MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED"
|
||||
default n
|
||||
|
||||
config MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
|
||||
bool "MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED"
|
||||
default y
|
||||
|
||||
config MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
|
||||
bool "MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED"
|
||||
default n
|
||||
|
||||
config MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
|
||||
bool "MBEDTLS_KEY_EXCHANGE_RSA_ENABLED"
|
||||
default n
|
||||
|
||||
config MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
|
||||
bool "MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED"
|
||||
default n
|
||||
|
||||
config MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
|
||||
bool "MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED"
|
||||
default y
|
||||
|
||||
config MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
|
||||
bool "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED"
|
||||
default y
|
||||
|
||||
config MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
|
||||
bool "MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED"
|
||||
default n
|
||||
|
||||
config MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
|
||||
bool "MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED"
|
||||
default n
|
||||
|
||||
comment "Curves - unselect old or less-used curves to reduce binary size"
|
||||
|
||||
config MBEDTLS_ECP_DP_SECP192R1_ENABLED
|
||||
bool "MBEDTLS_ECP_DP_SECP192R1_ENABLED"
|
||||
default n
|
||||
|
||||
config MBEDTLS_ECP_DP_SECP224R1_ENABLED
|
||||
bool "MBEDTLS_ECP_DP_SECP224R1_ENABLED"
|
||||
default n
|
||||
|
||||
config MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
||||
bool "MBEDTLS_ECP_DP_SECP256R1_ENABLED"
|
||||
default y
|
||||
|
||||
config MBEDTLS_ECP_DP_SECP384R1_ENABLED
|
||||
bool "MBEDTLS_ECP_DP_SECP384R1_ENABLED"
|
||||
default y
|
||||
|
||||
config MBEDTLS_ECP_DP_SECP521R1_ENABLED
|
||||
bool "MBEDTLS_ECP_DP_SECP521R1_ENABLED"
|
||||
default y
|
||||
|
||||
config MBEDTLS_ECP_DP_SECP192K1_ENABLED
|
||||
bool "MBEDTLS_ECP_DP_SECP192K1_ENABLED"
|
||||
default n
|
||||
|
||||
config MBEDTLS_ECP_DP_SECP224K1_ENABLED
|
||||
bool "MBEDTLS_ECP_DP_SECP224K1_ENABLED"
|
||||
default n
|
||||
|
||||
config MBEDTLS_ECP_DP_SECP256K1_ENABLED
|
||||
bool "MBEDTLS_ECP_DP_SECP256K1_ENABLED"
|
||||
default y
|
||||
|
||||
config MBEDTLS_ECP_DP_BP256R1_ENABLED
|
||||
bool "MBEDTLS_ECP_DP_BP256R1_ENABLED"
|
||||
default n
|
||||
|
||||
config MBEDTLS_ECP_DP_BP384R1_ENABLED
|
||||
bool "MBEDTLS_ECP_DP_BP384R1_ENABLED"
|
||||
default n
|
||||
|
||||
config MBEDTLS_ECP_DP_BP512R1_ENABLED
|
||||
bool "MBEDTLS_ECP_DP_BP512R1_ENABLED"
|
||||
default n
|
||||
|
||||
config MBEDTLS_ECP_DP_CURVE25519_ENABLED
|
||||
bool "MBEDTLS_ECP_DP_CURVE25519_ENABLED"
|
||||
default y
|
||||
|
||||
config MBEDTLS_ECP_DP_CURVE448_ENABLED
|
||||
bool "MBEDTLS_ECP_DP_CURVE448_ENABLED"
|
||||
default n
|
||||
|
||||
comment "Build Options - unselect features to reduce binary size"
|
||||
|
||||
config MBEDTLS_CERTS_C
|
||||
bool "MBEDTLS_CERTS_C"
|
||||
default n
|
||||
|
||||
config MBEDTLS_CIPHER_MODE_OFB
|
||||
bool "MBEDTLS_CIPHER_MODE_OFB"
|
||||
default n
|
||||
|
||||
config MBEDTLS_CIPHER_MODE_XTS
|
||||
bool "MBEDTLS_CIPHER_MODE_XTS"
|
||||
default n
|
||||
|
||||
config MBEDTLS_DEBUG_C
|
||||
bool "MBEDTLS_DEBUG_C"
|
||||
default n
|
||||
|
||||
config MBEDTLS_HKDF_C
|
||||
bool "MBEDTLS_HKDF_C"
|
||||
default n
|
||||
|
||||
config MBEDTLS_PLATFORM_C
|
||||
bool "MBEDTLS_PLATFORM_C"
|
||||
default n
|
||||
|
||||
config MBEDTLS_SELF_TEST
|
||||
bool "MBEDTLS_SELF_TEST"
|
||||
default n
|
||||
|
||||
config MBEDTLS_SSL_TRUNCATED_HMAC
|
||||
bool "MBEDTLS_SSL_TRUNCATED_HMAC"
|
||||
default n
|
||||
|
||||
config MBEDTLS_THREADING_C
|
||||
bool "MBEDTLS_THREADING_C"
|
||||
default y
|
||||
|
||||
config MBEDTLS_THREADING_PTHREAD
|
||||
def_bool MBEDTLS_THREADING_C
|
||||
|
||||
config MBEDTLS_VERSION_C
|
||||
bool "MBEDTLS_VERSION_C"
|
||||
default n
|
||||
|
||||
config MBEDTLS_VERSION_FEATURES
|
||||
bool "MBEDTLS_VERSION_FEATURES"
|
||||
default n
|
||||
|
||||
comment "Build Options"
|
||||
|
||||
config MBEDTLS_ENTROPY_FORCE_SHA256
|
||||
bool "MBEDTLS_ENTROPY_FORCE_SHA256"
|
||||
default y
|
||||
|
||||
config MBEDTLS_SSL_RENEGOTIATION
|
||||
bool "MBEDTLS_SSL_RENEGOTIATION"
|
||||
default n
|
||||
|
||||
endif
|
164
6.10/package/libs/mbedtls/Makefile
Normal file
164
6.10/package/libs/mbedtls/Makefile
Normal file
|
@ -0,0 +1,164 @@
|
|||
#
|
||||
# Copyright (C) 2011-2015 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=mbedtls
|
||||
PKG_VERSION:=2.28.7
|
||||
PKG_RELEASE:=2
|
||||
PKG_BUILD_FLAGS:=no-mips16 gc-sections no-lto
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/ARMmbed/mbedtls/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=1df6073f0cf6a4e1953890bf5e0de2a8c7e6be50d6d6c69fa9fefcb1d14e981a
|
||||
|
||||
PKG_LICENSE:=GPL-2.0-or-later
|
||||
PKG_LICENSE_FILES:=gpl-2.0.txt
|
||||
PKG_CPE_ID:=cpe:/a:arm:mbed_tls
|
||||
|
||||
MBEDTLS_BUILD_OPTS_CURVES= \
|
||||
CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED \
|
||||
CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED \
|
||||
CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED \
|
||||
CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED \
|
||||
CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED \
|
||||
CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED \
|
||||
CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED \
|
||||
CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED \
|
||||
CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED \
|
||||
CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED \
|
||||
CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED \
|
||||
CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED \
|
||||
CONFIG_MBEDTLS_ECP_DP_CURVE448_ENABLED
|
||||
|
||||
MBEDTLS_BUILD_OPTS_CIPHERS= \
|
||||
CONFIG_MBEDTLS_AES_C \
|
||||
CONFIG_MBEDTLS_CAMELLIA_C \
|
||||
CONFIG_MBEDTLS_CCM_C \
|
||||
CONFIG_MBEDTLS_CMAC_C \
|
||||
CONFIG_MBEDTLS_DES_C \
|
||||
CONFIG_MBEDTLS_GCM_C \
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED \
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED \
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED \
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED \
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_ENABLED \
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED \
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED \
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED \
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED \
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED \
|
||||
CONFIG_MBEDTLS_NIST_KW_C \
|
||||
CONFIG_MBEDTLS_RIPEMD160_C \
|
||||
CONFIG_MBEDTLS_RSA_NO_CRT \
|
||||
CONFIG_MBEDTLS_XTEA_C
|
||||
|
||||
MBEDTLS_BUILD_OPTS= \
|
||||
$(MBEDTLS_BUILD_OPTS_CURVES) \
|
||||
$(MBEDTLS_BUILD_OPTS_CIPHERS) \
|
||||
CONFIG_MBEDTLS_CERTS_C \
|
||||
CONFIG_MBEDTLS_CIPHER_MODE_OFB \
|
||||
CONFIG_MBEDTLS_CIPHER_MODE_XTS \
|
||||
CONFIG_MBEDTLS_DEBUG_C \
|
||||
CONFIG_MBEDTLS_ENTROPY_FORCE_SHA256 \
|
||||
CONFIG_MBEDTLS_HKDF_C \
|
||||
CONFIG_MBEDTLS_PLATFORM_C \
|
||||
CONFIG_MBEDTLS_SELF_TEST \
|
||||
CONFIG_MBEDTLS_SSL_RENEGOTIATION \
|
||||
CONFIG_MBEDTLS_SSL_TRUNCATED_HMAC \
|
||||
CONFIG_MBEDTLS_THREADING_C \
|
||||
CONFIG_MBEDTLS_THREADING_PTHREAD \
|
||||
CONFIG_MBEDTLS_VERSION_C \
|
||||
CONFIG_MBEDTLS_VERSION_FEATURES
|
||||
|
||||
PKG_CONFIG_DEPENDS := $(MBEDTLS_BUILD_OPTS)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
|
||||
define Package/mbedtls/Default
|
||||
TITLE:=Embedded SSL
|
||||
URL:=https://tls.mbed.org
|
||||
endef
|
||||
|
||||
define Package/mbedtls/Default/description
|
||||
The aim of the mbedtls project is to provide a quality, open-source
|
||||
cryptographic library written in C and targeted at embedded systems.
|
||||
endef
|
||||
|
||||
define Package/libmbedtls
|
||||
$(call Package/mbedtls/Default)
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
SUBMENU:=SSL
|
||||
TITLE+= (library)
|
||||
ABI_VERSION:=13
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
define Package/libmbedtls/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
define Package/mbedtls-util
|
||||
$(call Package/mbedtls/Default)
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE+= (utilities)
|
||||
DEPENDS:=+libmbedtls
|
||||
endef
|
||||
|
||||
define Package/libmbedtls/description
|
||||
$(call Package/mbedtls/Default/description)
|
||||
This package contains the mbedtls library.
|
||||
endef
|
||||
|
||||
define Package/mbedtls-util/description
|
||||
$(call Package/mbedtls/Default/description)
|
||||
This package contains mbedtls helper programs for private key and
|
||||
CSR generation (gen_key, cert_req)
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS))
|
||||
|
||||
CMAKE_OPTIONS += \
|
||||
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
|
||||
-DUSE_SHARED_MBEDTLS_LIBRARY:Bool=ON \
|
||||
-DENABLE_TESTING:Bool=OFF \
|
||||
-DENABLE_PROGRAMS:Bool=ON
|
||||
|
||||
define Build/Prepare
|
||||
$(call Build/Prepare/Default)
|
||||
|
||||
$(if $(strip $(foreach opt,$(MBEDTLS_BUILD_OPTS),$($(opt)))),
|
||||
$(foreach opt,$(MBEDTLS_BUILD_OPTS),
|
||||
$(PKG_BUILD_DIR)/scripts/config.py \
|
||||
-f $(PKG_BUILD_DIR)/include/mbedtls/config.h \
|
||||
$(if $($(opt)),set,unset) $(patsubst CONFIG_%,%,$(opt))),)
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/include/mbedtls $(1)/usr/include/
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so* $(1)/usr/lib/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.a $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/libmbedtls/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so.* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/mbedtls-util/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gen_key $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/cert_req $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libmbedtls))
|
||||
$(eval $(call BuildPackage,mbedtls-util))
|
|
@ -0,0 +1,197 @@
|
|||
From eb9d4fdf1846e688d51d86a9a50f0312aca2af25 Mon Sep 17 00:00:00 2001
|
||||
From: Glenn Strauss <gstrauss@gluelogic.com>
|
||||
Date: Sun, 23 Oct 2022 19:48:18 -0400
|
||||
Subject: [PATCH] x509 crt verify SAN iPAddress
|
||||
|
||||
Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
|
||||
---
|
||||
include/mbedtls/x509_crt.h | 2 +-
|
||||
library/x509_crt.c | 126 ++++++++++++++++++++++++++++++-------
|
||||
2 files changed, 103 insertions(+), 25 deletions(-)
|
||||
|
||||
--- a/include/mbedtls/x509_crt.h
|
||||
+++ b/include/mbedtls/x509_crt.h
|
||||
@@ -608,7 +608,7 @@ int mbedtls_x509_crt_verify_info(char *b
|
||||
* \param cn The expected Common Name. This will be checked to be
|
||||
* present in the certificate's subjectAltNames extension or,
|
||||
* if this extension is absent, as a CN component in its
|
||||
- * Subject name. Currently only DNS names are supported. This
|
||||
+ * Subject name. DNS names and IP addresses are supported. This
|
||||
* may be \c NULL if the CN need not be verified.
|
||||
* \param flags The address at which to store the result of the verification.
|
||||
* If the verification couldn't be completed, the flag value is
|
||||
--- a/library/x509_crt.c
|
||||
+++ b/library/x509_crt.c
|
||||
@@ -57,6 +57,10 @@
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
|
||||
+#define WIN32_LEAN_AND_MEAN
|
||||
+#ifndef _WIN32_WINNT
|
||||
+#define _WIN32_WINNT 0x0600
|
||||
+#endif
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <time.h>
|
||||
@@ -3002,6 +3006,61 @@ find_parent:
|
||||
}
|
||||
}
|
||||
|
||||
+#ifdef _WIN32
|
||||
+#ifdef _MSC_VER
|
||||
+#pragma comment(lib, "ws2_32.lib")
|
||||
+#include <winsock2.h>
|
||||
+#include <ws2tcpip.h>
|
||||
+#elif (defined(__MINGW32__) || defined(__MINGW64__)) && _WIN32_WINNT >= 0x0600
|
||||
+#include <winsock2.h>
|
||||
+#include <ws2tcpip.h>
|
||||
+#endif
|
||||
+#elif defined(__sun)
|
||||
+/* Solaris requires -lsocket -lnsl for inet_pton() */
|
||||
+#elif defined(__has_include)
|
||||
+#if __has_include(<sys/socket.h>)
|
||||
+#include <sys/socket.h>
|
||||
+#endif
|
||||
+#if __has_include(<arpa/inet.h>)
|
||||
+#include <arpa/inet.h>
|
||||
+#endif
|
||||
+#endif
|
||||
+
|
||||
+/* Use whether or not AF_INET6 is defined to indicate whether or not to use
|
||||
+ * the platform inet_pton() or a local implementation (below). The local
|
||||
+ * implementation may be used even in cases where the platform provides
|
||||
+ * inet_pton(), e.g. when there are different includes required and/or the
|
||||
+ * platform implementation requires dependencies on additional libraries.
|
||||
+ * Specifically, Windows requires custom includes and additional link
|
||||
+ * dependencies, and Solaris requires additional link dependencies.
|
||||
+ * Also, as a coarse heuristic, use the local implementation if the compiler
|
||||
+ * does not support __has_include(), or if the definition of AF_INET6 is not
|
||||
+ * provided by headers included (or not) via __has_include() above. */
|
||||
+#ifndef AF_INET6
|
||||
+
|
||||
+#define x509_cn_inet_pton(cn, dst) (0)
|
||||
+
|
||||
+#else
|
||||
+
|
||||
+static int x509_inet_pton_ipv6(const char *src, void *dst)
|
||||
+{
|
||||
+ return inet_pton(AF_INET6, src, dst) == 1 ? 0 : -1;
|
||||
+}
|
||||
+
|
||||
+static int x509_inet_pton_ipv4(const char *src, void *dst)
|
||||
+{
|
||||
+ return inet_pton(AF_INET, src, dst) == 1 ? 0 : -1;
|
||||
+}
|
||||
+
|
||||
+#endif /* AF_INET6 */
|
||||
+
|
||||
+static size_t x509_cn_inet_pton(const char *cn, void *dst)
|
||||
+{
|
||||
+ return strchr(cn, ':') == NULL
|
||||
+ ? x509_inet_pton_ipv4(cn, dst) == 0 ? 4 : 0
|
||||
+ : x509_inet_pton_ipv6(cn, dst) == 0 ? 16 : 0;
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* Check for CN match
|
||||
*/
|
||||
@@ -3022,24 +3081,51 @@ static int x509_crt_check_cn(const mbedt
|
||||
return -1;
|
||||
}
|
||||
|
||||
+static int x509_crt_check_san_ip(const mbedtls_x509_sequence *san,
|
||||
+ const char *cn, size_t cn_len)
|
||||
+{
|
||||
+ uint32_t ip[4];
|
||||
+ cn_len = x509_cn_inet_pton(cn, ip);
|
||||
+ if (cn_len == 0) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ for (const mbedtls_x509_sequence *cur = san; cur != NULL; cur = cur->next) {
|
||||
+ const unsigned char san_type = (unsigned char) cur->buf.tag &
|
||||
+ MBEDTLS_ASN1_TAG_VALUE_MASK;
|
||||
+ if (san_type == MBEDTLS_X509_SAN_IP_ADDRESS &&
|
||||
+ cur->buf.len == cn_len && memcmp(cur->buf.p, ip, cn_len) == 0) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* Check for SAN match, see RFC 5280 Section 4.2.1.6
|
||||
*/
|
||||
-static int x509_crt_check_san(const mbedtls_x509_buf *name,
|
||||
+static int x509_crt_check_san(const mbedtls_x509_sequence *san,
|
||||
const char *cn, size_t cn_len)
|
||||
{
|
||||
- const unsigned char san_type = (unsigned char) name->tag &
|
||||
- MBEDTLS_ASN1_TAG_VALUE_MASK;
|
||||
-
|
||||
- /* dNSName */
|
||||
- if (san_type == MBEDTLS_X509_SAN_DNS_NAME) {
|
||||
- return x509_crt_check_cn(name, cn, cn_len);
|
||||
+ int san_ip = 0;
|
||||
+ for (const mbedtls_x509_sequence *cur = san; cur != NULL; cur = cur->next) {
|
||||
+ switch ((unsigned char) cur->buf.tag & MBEDTLS_ASN1_TAG_VALUE_MASK) {
|
||||
+ case MBEDTLS_X509_SAN_DNS_NAME: /* dNSName */
|
||||
+ if (x509_crt_check_cn(&cur->buf, cn, cn_len) == 0) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+ break;
|
||||
+ case MBEDTLS_X509_SAN_IP_ADDRESS: /* iPAddress */
|
||||
+ san_ip = 1;
|
||||
+ break;
|
||||
+ /* (We may handle other types here later.) */
|
||||
+ default: /* Unrecognized type */
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
|
||||
- /* (We may handle other types here later.) */
|
||||
-
|
||||
- /* Unrecognized type */
|
||||
- return -1;
|
||||
+ return san_ip ? x509_crt_check_san_ip(san, cn, cn_len) : -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3050,31 +3136,23 @@ static void x509_crt_verify_name(const m
|
||||
uint32_t *flags)
|
||||
{
|
||||
const mbedtls_x509_name *name;
|
||||
- const mbedtls_x509_sequence *cur;
|
||||
size_t cn_len = strlen(cn);
|
||||
|
||||
if (crt->ext_types & MBEDTLS_X509_EXT_SUBJECT_ALT_NAME) {
|
||||
- for (cur = &crt->subject_alt_names; cur != NULL; cur = cur->next) {
|
||||
- if (x509_crt_check_san(&cur->buf, cn, cn_len) == 0) {
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- if (cur == NULL) {
|
||||
- *flags |= MBEDTLS_X509_BADCERT_CN_MISMATCH;
|
||||
+ if (x509_crt_check_san(&crt->subject_alt_names, cn, cn_len) == 0) {
|
||||
+ return;
|
||||
}
|
||||
} else {
|
||||
for (name = &crt->subject; name != NULL; name = name->next) {
|
||||
if (MBEDTLS_OID_CMP(MBEDTLS_OID_AT_CN, &name->oid) == 0 &&
|
||||
x509_crt_check_cn(&name->val, cn, cn_len) == 0) {
|
||||
- break;
|
||||
+ return;
|
||||
}
|
||||
}
|
||||
|
||||
- if (name == NULL) {
|
||||
- *flags |= MBEDTLS_X509_BADCERT_CN_MISMATCH;
|
||||
- }
|
||||
}
|
||||
+
|
||||
+ *flags |= MBEDTLS_X509_BADCERT_CN_MISMATCH;
|
||||
}
|
||||
|
||||
/*
|
15
6.10/package/libs/mbedtls/patches/101-remove-test.patch
Normal file
15
6.10/package/libs/mbedtls/patches/101-remove-test.patch
Normal file
|
@ -0,0 +1,15 @@
|
|||
--- a/programs/CMakeLists.txt
|
||||
+++ b/programs/CMakeLists.txt
|
||||
@@ -1,12 +1,8 @@
|
||||
add_subdirectory(aes)
|
||||
-if (NOT WIN32)
|
||||
- add_subdirectory(fuzz)
|
||||
-endif()
|
||||
add_subdirectory(hash)
|
||||
add_subdirectory(pkey)
|
||||
add_subdirectory(psa)
|
||||
add_subdirectory(random)
|
||||
add_subdirectory(ssl)
|
||||
-add_subdirectory(test)
|
||||
add_subdirectory(util)
|
||||
add_subdirectory(x509)
|
Loading…
Add table
Add a link
Reference in a new issue