Skip to content

Commit

Permalink
crypto:support nuttx /dev/crypto
Browse files Browse the repository at this point in the history
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
  • Loading branch information
anjiahao1 authored and xiaoxiang781216 committed Dec 13, 2022
1 parent 82956a2 commit 3d2f0c0
Show file tree
Hide file tree
Showing 45 changed files with 1,769 additions and 1,073 deletions.
1,136 changes: 1,136 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions boards/sim/sim/sim/configs/crypto/defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
CONFIG_ALLOW_BSD_COMPONENTS=y
CONFIG_ALLSYMS=y
CONFIG_ARCH="sim"
CONFIG_ARCH_BOARD="sim"
CONFIG_ARCH_BOARD_SIM=y
CONFIG_ARCH_CHIP="sim"
CONFIG_ARCH_SIM=y
CONFIG_BOARDCTL_APP_SYMTAB=y
CONFIG_BOARDCTL_POWEROFF=y
CONFIG_BOARD_LOOPSPERMSEC=0
CONFIG_BOOT_RUNFROMEXTSRAM=y
CONFIG_BUILTIN=y
CONFIG_CRYPTO=y
CONFIG_CRYPTO_CRYPTODEV=y
CONFIG_CRYPTO_RANDOM_POOL=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEV_GPIO=y
CONFIG_DEV_LOOP=y
CONFIG_DEV_ZERO=y
CONFIG_EXAMPLES_GPIO=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
CONFIG_FSUTILS_PASSWD=y
CONFIG_FSUTILS_PASSWD_READONLY=y
CONFIG_FS_BINFS=y
CONFIG_FS_FAT=y
CONFIG_FS_PROCFS=y
CONFIG_FS_RAMMAP=y
CONFIG_FS_ROMFS=y
CONFIG_GPIO_LOWER_HALF=y
CONFIG_IDLETHREAD_STACKSIZE=4096
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_IOEXPANDER=y
CONFIG_IOEXPANDER_DUMMY=y
CONFIG_LIBC_ENVPATH=y
CONFIG_LIBC_EXECFUNCS=y
CONFIG_LIBC_LOCALE=y
CONFIG_LIBC_LOCALE_CATALOG=y
CONFIG_LIBC_LOCALE_GETTEXT=y
CONFIG_LIBC_MAX_EXITFUNS=1
CONFIG_LIBC_NUMBERED_ARGS=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_ARCHROMFS=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FATDEVNO=2
CONFIG_NSH_FILE_APPS=y
CONFIG_NSH_READLINE=y
CONFIG_NSH_ROMFSDEVNO=1
CONFIG_NSH_ROMFSETC=y
CONFIG_PATH_INITIAL="/bin"
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
CONFIG_PSEUDOFS_ATTRIBUTES=y
CONFIG_PSEUDOFS_SOFTLINKS=y
CONFIG_READLINE_TABCOMPLETION=y
CONFIG_SCHED_BACKTRACE=y
CONFIG_SCHED_HAVE_PARENT=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_START_MONTH=6
CONFIG_START_YEAR=2008
CONFIG_SYSTEM_DUMPSTACK=y
CONFIG_SYSTEM_NSH=y
CONFIG_TESTING_CRYPTO=y
1 change: 1 addition & 0 deletions crypto/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ endif # CRYPTO_ALGTEST

config CRYPTO_CRYPTODEV
bool "cryptodev support"
depends on ALLOW_BSD_COMPONENTS
default n

config CRYPTO_SW_AES
Expand Down
25 changes: 20 additions & 5 deletions crypto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,27 @@ CRYPTO_CSRCS += crypto.c testmngr.c

ifeq ($(CONFIG_CRYPTO_CRYPTODEV),y)
CRYPTO_CSRCS += cryptodev.c
endif

# Software AES library

ifeq ($(CONFIG_CRYPTO_SW_AES),y)
CRYPTO_CSRCS += cryptosoft.c
CRYPTO_CSRCS += xform.c
CRYPTO_CSRCS += aes.c
CRYPTO_CSRCS += blf.c
CRYPTO_CSRCS += cast.c
CRYPTO_CSRCS += chachapoly.c
CRYPTO_CSRCS += ecb_enc.c
CRYPTO_CSRCS += ecb3_enc.c
CRYPTO_CSRCS += set_key.c
CRYPTO_CSRCS += md5.c
CRYPTO_CSRCS += poly1305.c
CRYPTO_CSRCS += rijndael.c
CRYPTO_CSRCS += rmd160.c
CRYPTO_CSRCS += sha1.c
CRYPTO_CSRCS += sha2.c
CRYPTO_CSRCS += gmac.c
CRYPTO_CSRCS += cmac.c
CRYPTO_CSRCS += hmac.c
CRYPTO_CSRCS += idgen.c
CRYPTO_CSRCS += key_wrap.c
CRYPTO_CSRCS += siphash.c
endif

# BLAKE2s hash algorithm
Expand Down
3 changes: 1 addition & 2 deletions crypto/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
* Included Files
****************************************************************************/

#include <string.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/stdint.h>
#include <crypto/aes.h>

/****************************************************************************
Expand Down
1 change: 0 additions & 1 deletion crypto/blf.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
****************************************************************************/

#include <sys/param.h>
#include <sys/systm.h>

#include <crypto/blf.h>

Expand Down
3 changes: 2 additions & 1 deletion crypto/cast.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
* Included Files
****************************************************************************/

#include <string.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <crypto/cast.h>

#include "castsb.h"

/* Macros to access 8-bit bytes out of a 32-bit word */
Expand Down
3 changes: 2 additions & 1 deletion crypto/chacha_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
* Included Files
****************************************************************************/

#include <sys/systm.h>
#include <string.h>
#include <sys/types.h>

typedef struct
{
Expand Down
3 changes: 1 addition & 2 deletions crypto/chachapoly.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
* Included Files
****************************************************************************/

#include <endian.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <lib/libkern/libkern.h>

#include <crypto/poly1305.h>
#include <crypto/chachapoly.h>
Expand Down
7 changes: 5 additions & 2 deletions crypto/cmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@
* Included Files
****************************************************************************/

#include <string.h>
#include <sys/param.h>
#include <sys/systm.h>

#include <crypto/aes.h>
#include <crypto/cmac.h>

#ifndef MIN
# define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif

#define LSHIFT(v, r) do \
{ \
int i; \
Expand Down
Loading

0 comments on commit 3d2f0c0

Please sign in to comment.