Browse code

tls_wolfssl: add wolfssl@e722c15be8 as a submodule

S-P Chan authored on 23/06/2022 07:15:11
Showing 6 changed files
... ...
@@ -1,3 +1,6 @@
1 1
 [submodule "pkg/docker"]
2 2
 	path = pkg/docker
3 3
 	url = https://github.com/kamailio/kamailio-ci.git
4
+[submodule "src/modules/tls_wolfssl/lib/wolfssl"]
5
+	path = src/modules/tls_wolfssl/lib/wolfssl
6
+	url = https://github.com/wolfSSL/wolfssl.git
4 7
new file mode 100644
... ...
@@ -0,0 +1,4 @@
1
+lib/lib
2
+lib/include
3
+lib/bin
4
+lib/share
... ...
@@ -8,74 +8,41 @@ include ../../Makefile.defs
8 8
 auto_gen=
9 9
 NAME=tls_wolfssl.so
10 10
 
11
-# set to yes when wanting to link with static libraries
12
-LIBSSL_STATIC ?= no
13
-# set to yes when wanting to link with static libraries compiled from source
14
-LIBSSL_STATIC_SRCLIB ?= no
15
-# set to the path of the folder with static libraries compiled from source
16
-LIBSSL_STATIC_SRCPATH ?= /usr/local/src/openssl
11
+LIBS += lib/lib/libwolfssl.a
12
+DEFS += -I./lib/include/
17 13
 
18
-ifeq ($(CROSS_COMPILE),)
19
-WOLFSSL_BUILDER=$(shell \
20
-	if pkg-config --exists wolfssl; then \
21
-		echo 'pkg-config wolfssl'; \
22
-	fi)
23
-endif
24
-
25
-ifneq ($(WOLFSSL_BUILDER),)
26
-
27
-ifneq ($(WOLFSSL_STATIC),yes)
28
-	DEFS += $(shell $(WOLFSSL_BUILDER) --cflags)
29
-	LIBS += $(shell $(WOLFSSL_BUILDER) --libs)
30
-
31
-else # $(WOLFSSL_STATIC),yes)
32
-
33
-	DEFS += -DKSR_WOLFSSL_STATIC
34
-
35
-ifneq ($(WOLFSSL_STATIC_SRCLIB),yes)
36
-	## when static libs (*.a) from packages are compiled with -fPIC
37
-	DEFS += $(shell $(WOLFSSL_BUILDER) --cflags)
38
-	LIBS += $(shell $(WOLFSSL_BUILDER) --libs-only-L)
39
-	# TODO: explore use of LIBS += -Wl,-Bstatic $(shell $(SSL_BUILDER) --libs-only-l)
40
-	LIBS += -l:libwolfssl.a -l:libz.a -l:libdl.a
41
-else
42
-	## when linking against static libs compiled from sources
43
-	DEFS += -I$(WOLFSSL_STATIC_SRCPATH)/include
44
-	LIBS += $(WOLFSSL_STATIC_SRCPATH)/libwolfssl.a
45
-endif # ifneq ($(WOLFSSL_STATIC_SRCLIB),yes)
46
-
47
-endif # ifneq ($(WOLFSSL_STATIC),yes)
48
-
49
-else # ifneq ($(SSL_BUILDER),)
50
-
51
-	DEFS += -I$(LOCALBASE)/wolfssl/include
52
-	LIBS += -L$(LOCALBASE)/lib \
53
-			-L$(LOCALBASE)/lib64  \
54
-			-lwolfssl
55
-endif # ifneq ($(SSL_BUILDER),)
56
-
57
-LIBS+= $(TLS_EXTRA_LIBS)
58
-
59
-# dcm: tls.cfg installed via local 'install-cfg' to update paths
60
-#MOD_INSTALL_CFGS=tls.cfg
61 14
 
62 15
 include ../../Makefile.modules
63
-
64
-install-tls-cert: $(cfg_prefix)/$(cfg_dir)
65
-	MAIN_NAME=$(MAIN_NAME) ./tls_cert.sh -d $(cfg_prefix)/$(cfg_dir)
66
-
67
-install-cfg:
68
-	@if ! [ -d $(cfg_prefix)/$(cfg_dir) ]; then \
69
-		mkdir -p "$(cfg_prefix)/$(cfg_dir)" ; \
70
-	fi
71
-	@$(call try_err, $(INSTALL_TOUCH) \
72
-			"$(cfg_prefix)/$(cfg_dir)tls.cfg.sample" )
73
-	@sed -e "s#\/usr/local/etc/kamailio/#$(cfg_target)#g" \
74
-			-e "s#kamailio-selfsigned#$(MAIN_NAME)-selfsigned#g" \
75
-				< ./tls.cfg > "$(cfg_prefix)/$(cfg_dir)tls.cfg.sample"
76
-	@if [ -z "${skip_cfg_install}" -a \
77
-			! -f "$(cfg_prefix)/$(cfg_dir)tls.cfg" ]; then \
78
-		mv -f "$(cfg_prefix)/$(cfg_dir)tls.cfg.sample" \
79
-						"$(cfg_prefix)/$(cfg_dir)tls.cfg" ; \
80
-	fi
81
-
16
+SOURCES := $(shell ls *.c)
17
+OBJECTS = $(SOURCES:.c=.o)
18
+MOD_DIR := $(shell pwd)
19
+
20
+$(OBJECTS): lib/lib/libwolfssl.a
21
+
22
+lib/lib/libwolfssl.a:
23
+	@cd ./lib/wolfssl; \
24
+	if [ ! -f "configure" ]; then \
25
+		./autogen.sh; \
26
+	fi; \
27
+	if [ ! -f "Makefile" ]; then \
28
+		env -u DEFS -u CFLAGS -u LDFLAGS -u LIBS EXTRA_CFLAGS="-g -fPIC" ./configure \
29
+		--enable-all --enable-pkcs11 --enable-static --enable-aligndata=no \
30
+		--disable-shared --disable-silent-rules --disable-examples \
31
+		--prefix=$(MOD_DIR)/lib \
32
+		--exec-prefix=$(MOD_DIR)/lib; \
33
+		sed -i s/-Werror// Makefile; \
34
+	fi;
35
+	@$(MAKE) -C ./lib/wolfssl install
36
+
37
+$(NAME): lib/lib/libwolfssl.a
38
+
39
+clean-wolfssl:
40
+	@rm -rf ./lib/{bin,include,share,lib}; \
41
+	cd ./lib/wolfssl; make clean || /bin/true
42
+
43
+clean-module:
44
+	@rm -f *.o *.so
45
+
46
+clean-all: clean-wolfssl clean-module
47
+  
48
+.PHONY: clean-wolfssl clean-module clean-all
82 49
new file mode 160000
... ...
@@ -0,0 +1 @@
1
+Subproject commit e722c15be860794179082a05d09e6a90dc77ccf0
... ...
@@ -215,7 +215,27 @@ static void* ser_realloc(void *ptr, size_t size, const char* file, int line)
215 215
 }
216 216
 
217 217
 #else /*TLS_MALLOC_DBG */
218
+static void* ser_malloc(size_t size)
219
+{
220
+	return shm_malloc(size);
221
+
222
+}
223
+
224
+static void* ser_realloc(void *ptr, size_t size)
225
+{
226
+	return shm_realloc(ptr, size);
227
+
228
+}
229
+#endif
218 230
 
231
+static void ser_free(void *ptr)
232
+{
233
+	if (ptr) {
234
+		shm_free(ptr);
235
+	}
236
+}
237
+
238
+#if 0
219 239
 // up align memory allocations to 16 bytes for
220 240
 // wolfSSL --enable-aligndata=yes (the default)
221 241
 static const int MAX_ALIGN = __alignof__(max_align_t);
... ...
@@ -245,7 +265,6 @@ static void* ser_realloc(void *ptr, size_t new_size)
245 265
 		
246 266
 	return new_ptr + new_pad;
247 267
 }
248
-#endif /* LIBRESSL_VERSION_NUMBER */
249 268
 
250 269
 static void ser_free(void *ptr)
251 270
 {
... ...
@@ -254,7 +273,7 @@ static void ser_free(void *ptr)
254 273
 		shm_free((unsigned char*)ptr - pad);
255 274
 	}
256 275
 }
257
-
276
+#endif
258 277
 
259 278
 /*
260 279
  * Initialize TLS socket
... ...
@@ -309,7 +309,7 @@ static int tls_complete_init(struct tcp_connection* c)
309 309
 error:
310 310
 	atomic_dec(&cfg->ref_count);
311 311
 	if (data) shm_free(data);
312
-error2:
312
+
313 313
 	return -1;
314 314
 }
315 315