btashton commented on a change in pull request #566: URL: https://github.com/apache/incubator-nuttx-apps/pull/566#discussion_r563450371
########## File path: crypto/mbedtls/Kconfig ########## @@ -0,0 +1,25 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +menuconfig CRYPTO_MBEDTLS + bool "Mbed TLS Cryptography Library" + default n + ---help--- + Enable support for Mbed TLS. + +if CRYPTO_MBEDTLS + +config MBEDTLS_VERSION + string "MBEDTLS Version" + default "2.25.0" + +config MBEDTLS_DEFAULT_TASK_STACKSIZE + int "Mbed TLS app default stack size" + default 8192 Review comment: The issue is the default stack size is only 2KB but I normally see 3-4KB on real hardware. I get that the sim is probably much higher so if we kept this I could conditional this like the DEFAULT_TASK_STACKSIZE. Thoughts? ########## File path: crypto/mbedtls/Kconfig ########## @@ -0,0 +1,25 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +menuconfig CRYPTO_MBEDTLS + bool "Mbed TLS Cryptography Library" + default n + ---help--- + Enable support for Mbed TLS. + +if CRYPTO_MBEDTLS + +config MBEDTLS_VERSION + string "MBEDTLS Version" + default "2.25.0" + +config MBEDTLS_DEFAULT_TASK_STACKSIZE + int "Mbed TLS app default stack size" + default 8192 + +source "$APPSDIR/crypto/mbedtls/apps/benchmark/Kconfig" +source "$APPSDIR/crypto/mbedtls/apps/selftest/Kconfig" Review comment: The Kconfigs do not use relative paths. If you try you get an error like this: ``` /home/bashton/nuttx/wrk/apps/crypto/mbedtls/Kconfig:23: can't open file "./apps/selftest/Kconfig" ``` ########## File path: crypto/mbedtls/apps/selftest/Makefile ########## @@ -0,0 +1,33 @@ +############################################################################ +# apps/crypto/mbedtls/apps/selftest/Makefile +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(APPDIR)/Make.defs +include ../Makefile + +# mbedtls built-in benchmark application info + +PROGNAME = "mbedselftest" +PRIORITY = $(CONFIG_MBEDTLS_APP_SELFTEST_PRIORITY) +STACKSIZE = $(CONFIG_MBEDTLS_APP_SELFTEST_STACKSIZE) +MODULE = $(CONFIG_MBEDTLS_APP_SELFTEST) + +MAINSRC = $(MBEDPROGDIR)/test/selftest.c Review comment: I could not get that to work, but maybe I am doing something wrong with: ``` MAINSRC = ../../mbedtls/test/selftest.c ``` I get this ``` make[3]: *** No rule to make target '../../mbedtls/test/selftest.c', needed by '../../mbedtls/test/selftest.home.bashton.nuttx.wrk.apps.crypto.mbedtls.apps.selftest.o'. Stop. ``` ########## File path: crypto/mbedtls/Make.defs ########## @@ -0,0 +1,33 @@ +############################################################################ +# apps/crypto/mbedtls/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +ifeq ($(CONFIG_CRYPTO_MBEDTLS),y) +CONFIGURED_APPS += $(APPDIR)/crypto/mbedtls + +# Allows `<mbedtls/<>.h>` import. + +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/crypto/mbedtls/mbedtls/include} +CXXFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/crypto/mbedtls/mbedtls/include} + +CFLAGS += -DMBEDTLS_CONFIG_FILE="<crypto/mbedtls_config.h>" Review comment: Had to wrap the string in single quotes as well to get the command formatted correctly but seems good now. ########## File path: crypto/mbedtls/apps/selftest/Makefile ########## @@ -0,0 +1,33 @@ +############################################################################ +# apps/crypto/mbedtls/apps/selftest/Makefile +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(APPDIR)/Make.defs +include ../Makefile + +# mbedtls built-in benchmark application info + +PROGNAME = "mbedselftest" +PRIORITY = $(CONFIG_MBEDTLS_APP_SELFTEST_PRIORITY) +STACKSIZE = $(CONFIG_MBEDTLS_APP_SELFTEST_STACKSIZE) +MODULE = $(CONFIG_MBEDTLS_APP_SELFTEST) + +MAINSRC = $(MBEDPROGDIR)/test/selftest.c Review comment: You cannot call `include $(APPDIR)/Application.mk` twice in the same make file which is they need to be in there own folders. But I don't think that is related to this path issue. ########## File path: crypto/mbedtls/apps/selftest/Makefile ########## @@ -0,0 +1,33 @@ +############################################################################ +# apps/crypto/mbedtls/apps/selftest/Makefile +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(APPDIR)/Make.defs +include ../Makefile + +# mbedtls built-in benchmark application info + +PROGNAME = "mbedselftest" +PRIORITY = $(CONFIG_MBEDTLS_APP_SELFTEST_PRIORITY) +STACKSIZE = $(CONFIG_MBEDTLS_APP_SELFTEST_STACKSIZE) +MODULE = $(CONFIG_MBEDTLS_APP_SELFTEST) + +MAINSRC = $(MBEDPROGDIR)/test/selftest.c Review comment: also careful with your paths. `crypto/mbedtls/programs/test` does not exist. `crypto/mbedtls/mbedtls/programs/test` does, but that is inside the downloaded source. ########## File path: crypto/mbedtls/apps/selftest/Makefile ########## @@ -0,0 +1,33 @@ +############################################################################ +# apps/crypto/mbedtls/apps/selftest/Makefile +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(APPDIR)/Make.defs +include ../Makefile + +# mbedtls built-in benchmark application info + +PROGNAME = "mbedselftest" +PRIORITY = $(CONFIG_MBEDTLS_APP_SELFTEST_PRIORITY) +STACKSIZE = $(CONFIG_MBEDTLS_APP_SELFTEST_STACKSIZE) +MODULE = $(CONFIG_MBEDTLS_APP_SELFTEST) + +MAINSRC = $(MBEDPROGDIR)/test/selftest.c Review comment: Hmm interesting I did not realize that. Can you take a look at how I set it up now. MODULE only take a single value so I had to create a wrapper for all the apps to drive that, but I think it is reasonable. ########## File path: crypto/mbedtls/Makefile ########## @@ -0,0 +1,91 @@ +############################################################################ +# apps/crypto/mbedtls/Makefile +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(APPDIR)/Make.defs + +# Mbed TLS crypto library + +# Set up build configuration and environment + +MBEDTLS_URL ?= "https://github.com/ARMmbed/mbedtls/archive" + +MBEDTLS_VERSION = $(patsubst "%",%,$(strip $(CONFIG_MBEDTLS_VERSION))) +MBEDTLS_ZIP = v$(MBEDTLS_VERSION).zip + +MBEDTLS_UNPACKNAME = mbedtls +UNPACK ?= unzip -q -o + +MBEDTLS_UNPACKLIBDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)library +MBEDTLS_UNPACKPROGDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)programs + +# This lets Mbed TLS better use some of the POSIX features we have +CFLAGS += ${shell $(DEFINE) "$(CC)" __unix__} + +CSRCS = $(wildcard $(MBEDTLS_UNPACKLIBDIR)$(DELIM)*.c) + + +$(MBEDTLS_ZIP): + @echo "Downloading: $(MBEDTLS_URL)/$(MBEDTLS_ZIP)" + $(Q) curl -O -L $(MBEDTLS_URL)/$(MBEDTLS_ZIP) + +$(MBEDTLS_UNPACKNAME): $(MBEDTLS_ZIP) + @echo "Unpacking: $(MBEDTLS_ZIP) -> $(MBEDTLS_UNPACKNAME)" + $(Q) $(UNPACK) $(MBEDTLS_ZIP) + $(Q) mv mbedtls-$(MBEDTLS_VERSION) $(MBEDTLS_UNPACKNAME) + $(Q) touch $(MBEDTLS_UNPACKNAME) + +context:: $(MBEDTLS_UNPACKNAME) + +distclean:: + $(call DELDIR, $(MBEDTLS_UNPACKNAME)) + $(call DELFILE, $(MBEDTLS_ZIP)) + +# Configuration Applications + +ifneq ($(CONFIG_MBEDTLS_APPS),) +CONFIGURED_APPS += $(APPDIR)/crypto/mbedtls/ Review comment: Since we already include Application.mk at the end do we even need to include this here since they will already be registered? ########## File path: crypto/mbedtls/Makefile ########## @@ -0,0 +1,91 @@ +############################################################################ +# apps/crypto/mbedtls/Makefile +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(APPDIR)/Make.defs + +# Mbed TLS crypto library + +# Set up build configuration and environment + +MBEDTLS_URL ?= "https://github.com/ARMmbed/mbedtls/archive" + +MBEDTLS_VERSION = $(patsubst "%",%,$(strip $(CONFIG_MBEDTLS_VERSION))) +MBEDTLS_ZIP = v$(MBEDTLS_VERSION).zip + +MBEDTLS_UNPACKNAME = mbedtls +UNPACK ?= unzip -q -o + +MBEDTLS_UNPACKLIBDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)library +MBEDTLS_UNPACKPROGDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)programs + +# This lets Mbed TLS better use some of the POSIX features we have +CFLAGS += ${shell $(DEFINE) "$(CC)" __unix__} + +CSRCS = $(wildcard $(MBEDTLS_UNPACKLIBDIR)$(DELIM)*.c) + + +$(MBEDTLS_ZIP): + @echo "Downloading: $(MBEDTLS_URL)/$(MBEDTLS_ZIP)" + $(Q) curl -O -L $(MBEDTLS_URL)/$(MBEDTLS_ZIP) + +$(MBEDTLS_UNPACKNAME): $(MBEDTLS_ZIP) + @echo "Unpacking: $(MBEDTLS_ZIP) -> $(MBEDTLS_UNPACKNAME)" + $(Q) $(UNPACK) $(MBEDTLS_ZIP) + $(Q) mv mbedtls-$(MBEDTLS_VERSION) $(MBEDTLS_UNPACKNAME) + $(Q) touch $(MBEDTLS_UNPACKNAME) + +context:: $(MBEDTLS_UNPACKNAME) + +distclean:: + $(call DELDIR, $(MBEDTLS_UNPACKNAME)) + $(call DELFILE, $(MBEDTLS_ZIP)) + +# Configuration Applications + +ifneq ($(CONFIG_MBEDTLS_APPS),) +CONFIGURED_APPS += $(APPDIR)/crypto/mbedtls/ Review comment: Since we already include Application.mk at the end do we even need to include this at all since they will already be registered? ########## File path: crypto/mbedtls/Kconfig ########## @@ -0,0 +1,80 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +menuconfig CRYPTO_MBEDTLS + bool "Mbed TLS Cryptography Library" + default n + ---help--- + Enable support for Mbed TLS. + +if CRYPTO_MBEDTLS + +config MBEDTLS_VERSION + string "MBEDTLS Version" + default "2.25.0" + +menuconfig MBEDTLS_APPS Review comment: This seems wrong. The applications and the library are two separate things. Enabling the library should have no impact (besides dependency) on the applications. ########## File path: crypto/mbedtls/Kconfig ########## @@ -0,0 +1,25 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +menuconfig CRYPTO_MBEDTLS + bool "Mbed TLS Cryptography Library" + default n + ---help--- + Enable support for Mbed TLS. + +if CRYPTO_MBEDTLS + +config MBEDTLS_VERSION + string "MBEDTLS Version" + default "2.25.0" + +config MBEDTLS_DEFAULT_TASK_STACKSIZE + int "Mbed TLS app default stack size" + default 8192 Review comment: So what are you thinking is the right thing for some of these apps? DEFAULT_TASK_STACKSIZE wont work for most of them. The an especially bad offender is the app for testing parsing CRL it allocates a 100KB buffer on the stack right away (I don't know why they don't use the heap for this...) https://github.com/ARMmbed/mbedtls/blob/6fbff5b557efe661cc019ef59f42c835524e9bf2/programs/x509/crl_app.c#L75 ########## File path: crypto/mbedtls/Make.defs ########## @@ -0,0 +1,32 @@ +############################################################################ +# apps/crypto/mbedtls/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +ifeq ($(CONFIG_CRYPTO_MBEDTLS),y) +CONFIGURED_APPS += $(APPDIR)/crypto/mbedtls + +# Allows `<mbedtls/<>.h>` import. + +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/crypto/mbedtls/mbedtls/include} +CXXFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/crypto/mbedtls/mbedtls/include} + +CFLAGS += ${shell $(DEFINE) "$(CC)" MBEDTLS_CONFIG_FILE='"<crypto/mbedtls_config.h>"'} Review comment: My plan is to completely replace it so that it is fully hooked into the Kconfig, I think that will end up being cleaner for us. ########## File path: crypto/mbedtls/Makefile ########## @@ -0,0 +1,91 @@ +############################################################################ +# apps/crypto/mbedtls/Makefile +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(APPDIR)/Make.defs + +# Mbed TLS crypto library + +# Set up build configuration and environment + +MBEDTLS_URL ?= "https://github.com/ARMmbed/mbedtls/archive" + +MBEDTLS_VERSION = $(patsubst "%",%,$(strip $(CONFIG_MBEDTLS_VERSION))) +MBEDTLS_ZIP = v$(MBEDTLS_VERSION).zip + +MBEDTLS_UNPACKNAME = mbedtls +UNPACK ?= unzip -q -o + +MBEDTLS_UNPACKLIBDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)library +MBEDTLS_UNPACKPROGDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)programs + +# This lets Mbed TLS better use some of the POSIX features we have +CFLAGS += ${shell $(DEFINE) "$(CC)" __unix__} + +CSRCS = $(wildcard $(MBEDTLS_UNPACKLIBDIR)$(DELIM)*.c) + + +$(MBEDTLS_ZIP): + @echo "Downloading: $(MBEDTLS_URL)/$(MBEDTLS_ZIP)" + $(Q) curl -O -L $(MBEDTLS_URL)/$(MBEDTLS_ZIP) + +$(MBEDTLS_UNPACKNAME): $(MBEDTLS_ZIP) + @echo "Unpacking: $(MBEDTLS_ZIP) -> $(MBEDTLS_UNPACKNAME)" + $(Q) $(UNPACK) $(MBEDTLS_ZIP) + $(Q) mv mbedtls-$(MBEDTLS_VERSION) $(MBEDTLS_UNPACKNAME) + $(Q) touch $(MBEDTLS_UNPACKNAME) + +context:: $(MBEDTLS_UNPACKNAME) + +distclean:: + $(call DELDIR, $(MBEDTLS_UNPACKNAME)) + $(call DELFILE, $(MBEDTLS_ZIP)) + +# Configuration Applications + +ifneq ($(CONFIG_MBEDTLS_APPS),) +CONFIGURED_APPS += $(APPDIR)/crypto/mbedtls/ Review comment: Ok, done. ########## File path: crypto/mbedtls/Make.defs ########## @@ -0,0 +1,32 @@ +############################################################################ +# apps/crypto/mbedtls/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +ifeq ($(CONFIG_CRYPTO_MBEDTLS),y) +CONFIGURED_APPS += $(APPDIR)/crypto/mbedtls + +# Allows `<mbedtls/<>.h>` import. + +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/crypto/mbedtls/mbedtls/include} +CXXFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/crypto/mbedtls/mbedtls/include} + +CFLAGS += ${shell $(DEFINE) "$(CC)" MBEDTLS_CONFIG_FILE='"<crypto/mbedtls_config.h>"'} Review comment: Another thing I have not figured out how to do is how to get make to be aware that all the source files in here depend on `crypto/mbedtls_config.h` right now when I make change to it or to `nuttx/config.h` that drives changes it in they are not rebuilt. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org