crypto:add tinycrypt to apps/crypto

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2022-10-18 22:58:25 +08:00 committed by Xiang Xiao
parent 195ffe71e4
commit 263f4ab8b9
5 changed files with 226 additions and 1 deletions

View File

@ -256,4 +256,5 @@ Technology Software Unrestricted (TSU) exception (see the BIS Export Administrat
Regulations, Section 740.13) for both object code and source code.
The following provides more details on the included cryptographic software:
https://tls.mbed.org/supported-ssl-ciphersuites.
https://tls.mbed.org/supported-ssl-ciphersuites.
https://github.com/intel/tinycrypt

2
crypto/tinycrypt/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.zip
tinycrypt/*

98
crypto/tinycrypt/Kconfig Normal file
View File

@ -0,0 +1,98 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
menu "Crypto: TinyCrypt cryptography library"
config TINYCRYPT
bool "TinyCrypt Support"
help
This option enables the TinyCrypt cryptography library.
if TINYCRYPT
config TINYCRYPT_VERSION
string "Tinycrypt Version"
default "0.2.8"
config TINYCRYPT_CTR_PRNG
bool "PRNG in counter mode"
default n
help
This option enables support for the pseudo-random number
generator in counter mode.
config TINYCRYPT_SHA256
bool "SHA-256 Hash function support"
default n
help
This option enables support for SHA-256
hash function primitive.
config TINYCRYPT_SHA256_HMAC
bool "HMAC (via SHA256) message auth support"
default n
help
This option enables support for HMAC using SHA-256
message authentication code.
config TINYCRYPT_SHA256_HMAC_PRNG
bool "PRNG (via HMAC-SHA256) support"
default n
help
This option enables support for pseudo-random number
generator.
config TINYCRYPT_ECC_DH
bool "ECC_DH anonymous key agreement protocol"
default n
help
This option enables support for the Elliptic curve
Diffie-Hellman anonymous key agreement protocol.
Enabling ECC requires a cryptographically secure random number
generator.
config TINYCRYPT_ECC_DSA
bool "ECC_DSA digital signature algorithm"
default n
help
This option enables support for the Elliptic Curve Digital
Signature Algorithm (ECDSA).
Enabling ECC requires a cryptographically secure random number
generator.
config TINYCRYPT_AES
bool "AES-128 decrypt/encrypt"
default n
help
This option enables support for AES-128 decrypt and encrypt.
config TINYCRYPT_AES_CBC
bool "AES-128 block cipher"
default n
help
This option enables support for AES-128 block cipher mode.
config TINYCRYPT_AES_CTR
bool "AES-128 counter mode"
default n
help
This option enables support for AES-128 counter mode.
config TINYCRYPT_AES_CCM
bool "AES-128 CCM mode"
default n
help
This option enables support for AES-128 CCM mode.
config TINYCRYPT_AES_CMAC
bool "AES-128 CMAC mode"
default n
help
This option enables support for AES-128 CMAC mode.
endif
endmenu

View File

@ -0,0 +1,25 @@
############################################################################
# apps/crypto/tinycrypt/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.
#
############################################################################
ifneq ($(CONFIG_TINYCRYPT),)
CONFIGURED_APPS += $(APPDIR)/crypto/tinycrypt
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/crypto/tinycrypt/tinycrypt/lib/include}
CXXFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/crypto/tinycrypt/tinycrypt/lib/include}
endif

99
crypto/tinycrypt/Makefile Normal file
View File

@ -0,0 +1,99 @@
############################################################################
# apps/crypto/tinycrypt/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
TINYCRYPT_VERSION = $(patsubst "%",%,$(strip $(CONFIG_TINYCRYPT_VERSION)))
TINYCRYPT_URL ?= "https://github.com/intel/tinycrypt/archive/refs/tags/v$(TINYCRYPT_VERSION).zip"
TINYCRYPT_ZIP = v$(TINYCRYPT_VERSION).zip
TINYCRYPT_UNPACKNAME = tinycrypt
UNPACK ?= unzip -q -o
$(TINYCRYPT_ZIP):
@echo "Downloading: $(TINYCRYPT_URL)/$(TINYCRYPT_ZIP)"
$(Q) curl -O -L $(TINYCRYPT_URL)
$(TINYCRYPT_UNPACKNAME): $(TINYCRYPT_ZIP)
@echo "Unpacking: $(TINYCRYPT_ZIP) -> $(TINYCRYPT_UNPACKNAME)"
$(Q) $(UNPACK) $(TINYCRYPT_ZIP)
$(Q) mv tinycrypt-$(TINYCRYPT_VERSION) $(TINYCRYPT_UNPACKNAME)
$(Q) touch $(TINYCRYPT_UNPACKNAME)
ifeq ($(wildcard $(TINYCRYPT_UNPACKNAME)/.git),)
context:: $(TINYCRYPT_UNPACKNAME)
distclean::
$(Q) rm -rf $(TINYCRYPT_UNPACKNAME)
endif
CSRCS += tinycrypt/lib/source/utils.c
CSRCS += tinycrypt/lib/source/ecc.c
ifeq ($(CONFIG_TINYCRYPT_ECC_DH),y)
CSRCS += tinycrypt/lib/source/ecc_dh.c
endif
ifeq ($(CONFIG_TINYCRYPT_ECC_DSA),y)
CSRCS += tinycrypt/lib/source/ecc_dsa.c
endif
ifeq ($(CONFIG_TINYCRYPT_AES),y)
CSRCS += tinycrypt/lib/source/aes_decrypt.c
endif
ifeq ($(CONFIG_TINYCRYPT_AES),y)
CSRCS += tinycrypt/lib/source/aes_encrypt.c
endif
ifeq ($(CONFIG_TINYCRYPT_AES_CBC),y)
CSRCS += tinycrypt/lib/source/cbc_mode.c
endif
ifeq ($(CONFIG_TINYCRYPT_AES_CTR),y)
CSRCS += tinycrypt/lib/source/ctr_mode.c
endif
ifeq ($(CONFIG_TINYCRYPT_AES_CCM),y)
CSRCS += tinycrypt/lib/source/ccm_mode.c
endif
ifeq ($(CONFIG_TINYCRYPT_AES_CMAC),y)
CSRCS += tinycrypt/lib/source/cmac_mode.c
endif
ifeq ($(CONFIG_TINYCRYPT_SHA256),y)
CSRCS += tinycrypt/lib/source/sha256.c
endif
ifeq ($(CONFIG_TINYCRYPT_SHA256_HMAC),y)
CSRCS += tinycrypt/lib/source/hmac.c
endif
ifeq ($(CONFIG_TINYCRYPT_SHA256_HMAC_PRNG),y)
CSRCS += tinycrypt/lib/source/hmac_prng.c
endif
ifeq ($(CONFIG_TINYCRYPT_CTR_PRNG),y)
CSRCS += tinycrypt/lib/source/ctr_prng.c
endif
include $(APPDIR)/Application.mk