Commit Graph

76 Commits

Author SHA1 Message Date
anjiahao a4563b8744 Fix the coding style and typo issue
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-14 09:34:04 +09:00
anjiahao d07792a343 Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-14 09:34:04 +09:00
anjiahao 0c26658906 random_pool:add a new api arc4random
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-11-09 06:41:19 +01:00
Xiang Xiao d0bd68b35e Fix random_pool.c:214:13: error: conflicting types for 'getentropy'
214 | static void getentropy(FAR blake2s_state *S)
       |             ^~~~~~~~~~
 In file included from /home/work/ssd1/workspace/MiRTOS-CI@2/out/miwear/ap/.unionfs/nuttx/include/nuttx/mutex.h:31,
                  from random_pool.c:37:
 /home/work/ssd1/workspace/MiRTOS-CI@2/out/miwear/ap/.unionfs/nuttx/include/unistd.h:428:9: note: previous declaration of 'getentropy' was here
   428 | int     getentropy(FAR void *buffer, size_t length);
       |         ^~~~~~~~~~

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-22 20:52:19 +02:00
anjiahao d1d46335df Replace nxsem API when used as a lock with nxmutex API
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-17 15:59:46 +09:00
Xiang Xiao 01cb137277 crypto/random_pool: Remove the unused header file(unistd.h and nuttx/arch.h)
and include the used header files(nuttx/clock.h and nuttx/semaphore.h)

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-27 14:27:11 +03:00
Xiang Xiao d7fe0127b0 Replece clock_gettime(CLOCK_REALTIME) with clock_systime_timespec if suitable
it's better to call the kernrel api insteaad user space api in kernel

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-24 01:06:36 +08:00
Juha Niskanen 62e1821ca0 crypto: apply BSD barrier only to SW AES library
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2022-01-13 16:27:52 +01:00
Alin Jerpelea 7597b8e471 crypto: Haltian Ltd: update licenses to Apache
Gregory Nutt has submitted the SGA
Haltian Ltd has submitted the SGA

as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-11-15 06:49:32 -06:00
Alin Jerpelea ae3088c501 crypto: add BSD barrier for AES crypto
add BSD barrier for AES crypto

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-09-02 21:56:05 +08:00
ligd ec042c3dc7 crypto: fix asan report error
random_pool.c:466:14: runtime error: left shift of 305919453 by 17 places cannot be represented in type 'long int'
random_pool.c:178:11: runtime error: shift exponent 32 is too large for 32-bit type 'unsigned int'

Change-Id: I714f42b68f4af43249946aed8537cd848e569194
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-07-02 07:58:45 -07:00
Jukka Laitinen cdb1b00f34 crypto/random_pool.c: Correct indexing on void pointer
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-06-11 10:58:06 -05:00
Xiang Xiao d7f96003cf Don't include debug.h from public header file
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-01 06:42:02 +09:00
Alin Jerpelea cddde2459b crypto: update licenses to Apache
Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-05-27 08:07:25 +09:00
Gustavo Henrique Nihei 330eff36d7 sourcefiles: Fix relative path in file header 2021-03-09 23:18:28 +08:00
Alin Jerpelea 26e1f1f249 tools: Author Gregory Nutt: update licenses to Apache
Gregory Nutt has submitted the SGA and we can migrate the licenses
 to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-19 08:07:47 -08:00
chao.an 859e1ce63a crypto/arc4random: rename getrandom to arc4random_buf
Change-Id: I5c9f0c9acf5af71f01beceaf06ebe0a2c87676bc
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-13 08:49:51 -06:00
Juha Niskanen 84bbc9f5fd crypto/random_pool.c: fix getrandom() when thread calling it gets canceled
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2020-12-10 20:36:17 -06:00
chao.an c56785bd0d style/Makefile: remove unnecessary trailing whitespace
N/A

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-11-28 12:20:30 +01:00
Matias N d5b6ec450f Parallelize depend file generation 2020-11-22 09:02:59 -03:00
Gregory Nutt 2dae970ec6 Fix cases where memory is allocated using malloc()
arch/arm/src/cxd56xx/cxd56_gnss.c, arch/arm/src/xmc4/xmc4_spi.c,
 crypto/blake2s.c, drivers/lcd/pcf8574_lcd_backpack.c, drivers/lcd/st7032.c

User space memory should not be used within the OS and, when it is absolutely necessary to use user-space memory, it should be allocated using kumm_malloc().
2020-08-04 20:40:57 +01:00
SPRESENSE e249a2f82f Makefile: Fix Make.dep not updated by config changes
Make.dep file should be updated by .config changed after first make.
There are 2 cases affected for this problem:

 1) Add source files by config symbol
 2) Include header files in #ifdef directive

These 2 cases may not be included in Make.dep and this may prevent the
differential build from working correctly.
2020-07-28 03:59:45 -05:00
Xiang Xiao 23668a4b9b build: Remove the empty variable assignment
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-24 08:24:13 -06:00
Xiang Xiao 1a95cce1a3 build: Move .config check to the top Makefile
remove the workaround to handle the inexistence of .config/Make.defs

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-20 17:57:34 +01:00
Alin Jerpelea 048d4954a0 crypto: nxstyle fixes
nxstyle fixes to reduce the CI warnings

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2020-04-22 14:07:04 -06:00
Gregory Nutt ae401cecdd Check return from nxsem_wait_initialize()
Resolution of Issue 619 will require multiple steps, this part of the first step in that resolution:  Every call to nxsem_wait_uninterruptible() must handle the return value from nxsem_wait_uninterruptible properly.  This commit is only for those files under fs/driver, fs/aio, fs/nfs, crypto/, and boards/.

Please note:  The modified file under fs/nfs generates several " Mixed case identifier found" errors.  Please ignore these.  These cannot be fixed without changes to numerous other files.  They also follow a non-standard convention that is used many files:  Using lower case structure names in custom SIZEOF_ definitions.
2020-03-30 17:09:45 +01:00
YAMAMOTO Takashi 1ffa009c8b Revert "Don't generate .depend anymore"
This reverts commit 79af7fbf4e.

Because:

* btashton reported some issues in local builds:

  https://github.com/apache/incubator-nuttx/pull/603#issuecomment-602264860

* this might be related to the current CI breakage:

  > /bin/sh: 1: /__w/incubator-nuttx/incubator-nuttx/nuttx/tools/mkdeps: not found
2020-03-22 23:07:29 -05:00
Xiang Xiao 79af7fbf4e
Don't generate .depend anymore 2020-03-22 18:15:29 +00:00
Xiang Xiao 6a3c2aded6 Fix wait loop and void cast (#24)
* Simplify EINTR/ECANCEL error handling

1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx

* Unify the void cast usage

1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
2020-01-02 10:54:43 -06:00
Gregory Nutt a629dd5306 crypto/testmngr.h: Fix some issues with section block comments. 2019-11-16 17:54:48 -06:00
Gregory Nutt fe983a4471 Minor, cosmetic changes. 2019-09-23 12:58:31 -06:00
Juha Niskanen ebc6f51641 Fix some typos 2019-09-17 10:46:23 -06:00
Gregory Nutt b49be4bb20 Squashed commit of the following:
arch/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    sched/ audio/ crypto/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    Documentation/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    fs/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    graphics/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    net/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    drivers/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    include/, syscall/, wireless/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    configs/:  Remove all references to CONFIG_DISABLE_POLL.  Standard POSIX poll can no longer be disabled.
2019-05-21 18:57:54 -06:00
Gregory Nutt dc8c814ca3 Squashed commit of the following:
Fixed coding standard error in several files.  Use of while( is incorrect; a space is required between while and (.  Also ran tools/nxstyle and fix thoses complaints as well in most files.

    Changes to comply with coding standard.  Mostly focused on files with missing space after keyword in if(, switch(, and for(.  Offending files also got changes to comply with tools nxstyle.  If there were logs of nxstyle complaints, the file also got a taste of tools/indent.sh.  Still need to fix occurrences of while( with missing space.  There are a lot of them.
2019-02-27 08:41:08 -06:00
Gregory Nutt 69b28ef4ba crypto/aes.c: When we upgraded our code to NuttX 7.28 crypto/aes.c would no longer compile. Attached is a patch which fixes the compilation errors. 2019-01-23 07:25:44 -06:00
Sebastien Lorquet a7257eff52 This change:
- Avoids the use of up_aesinitialize() entirely, which resolves dependency problems, because this function does not make sure that an actual hardware aes implementation was made available: each SoC is now responsible to ensure the AES hardware is initialized before first use. This applies to lpc43xx, stm32 and sam34.
    - Remove definitions of the NEVER used aes_init and aes_update operations. The new AES API will be more suitable.
    - Change the unusual naming in stm32 (avoiding possible naming clashes)
    - Change the unusual naming in sam34 (avoiding possible naming clashes)
    - Add some FAR to pointers and enforce the 80 col limit in stm32 and sam
2018-12-19 08:42:48 -06:00
Sebastien Lorquet c912e53344 crypto/aes.c: This commit provides an improved AES cipher API in addition to the existing routines. The reasons for this new API are: 1) better performance, giving the possibility to avoid re-setting-up the key for each AES block when the same key is used multiple times. This is important for the current single user of AES, which is related to storage and FTL. And 2) suitable for simultaneous use of multiple AES keys, which will be required by the upcoming crypto framework. It retains compatibility with the previous API, so there is no need to change anything else right now. 2018-12-18 10:21:37 -06:00
Alan Carvalho de Assis 283b73edc5 Fix lots of typos in C comments and Kconfig help text 2018-07-08 18:24:45 -06:00
Gregory Nutt b54ffe858a Standardization of some function headers. 2018-03-13 09:52:27 -06:00
Alan Carvalho de Assis 97937d3d47 configs/stm32f103-minimum: Add support to BMP180 on BluePill (stm32f103-minimum) board. 2018-02-04 07:34:31 -06:00
Gregory Nutt 7cf88d7dbd Make sure that labeling is used consistently in all function headers. 2018-02-01 10:00:02 -06:00
Gregory Nutt eb79a575f6 Fix a few places where there was a semicolon following the 'if' condition, makeing the following logic unconditional. 2017-10-10 14:24:13 -06:00
Gregory Nutt 9568600ab1 Squashed commit of the following:
This commit backs out most of commit b4747286b1.  That change was added because sem_wait() would sometimes cause cancellation points inappropriated.  But with these recent changes, nxsem_wait() is used instead and it is not a cancellation point.

    In the OS, all calls to sem_wait() changed to nxsem_wait().  nxsem_wait() does not return errors via errno so each place where nxsem_wait() is now called must not examine the errno variable.

    In all OS functions (not libraries), change sem_wait() to nxsem_wait().  This will prevent the OS from creating bogus cancellation points and from modifying the per-task errno variable.

    sched/semaphore:  Add the function nxsem_wait().  This is a new internal OS interface.  It is functionally equivalent to sem_wait() except that (1) it is not a cancellation point, and (2) it does not set the per-thread errno value on return.
2017-10-04 15:22:27 -06:00
Gregory Nutt 42a0796615 Squashed commit of the following:
sched/semaphore:  Add nxsem_post() which is identical to sem_post() except that it never modifies the errno variable.  Changed all references to sem_post in the OS to nxsem_post().

    sched/semaphore:  Add nxsem_destroy() which is identical to sem_destroy() except that it never modifies the errno variable.  Changed all references to sem_destroy() in the OS to nxsem_destroy().

    libc/semaphore and sched/semaphore:  Add nxsem_getprotocol() and nxsem_setprotocola which are identical to sem_getprotocol() and set_setprotocol() except that they never modifies the errno variable.  Changed all references to sem_setprotocol in the OS to nxsem_setprotocol().  sem_getprotocol() was not used in the OS
2017-10-03 15:35:24 -06:00
Gregory Nutt 83cdb0c552 Squashed commit of the following:
libc/semaphore:  Add nxsem_getvalue() which is identical to sem_getvalue() except that it never modifies the errno variable.  Changed all references to sem_getvalue in the OS to nxsem_getvalue().

    sched/semaphore:  Rename all internal private functions from sem_xyz to nxsem_xyz.  The sem_ prefix is (will be) reserved only for the application semaphore interfaces.

    libc/semaphore:  Add nxsem_init() which is identical to sem_init() except that it never modifies the errno variable.  Changed all references to sem_init in the OS to nxsem_init().

    sched/semaphore:  Rename sem_tickwait() to nxsem_tickwait() so that it is clear this is an internal OS function.

    sched/semaphoate:  Rename sem_reset() to nxsem_reset() so that it is clear this is an internal OS function.
2017-10-03 12:52:31 -06:00
Gregory Nutt d5207efb5a Be consistent... Use Name: consistent in function headers vs Function: 2017-04-21 16:33:14 -06:00
Jussi Kivilinna 5e8ed2dd4e crypto/random_pool: fix typo in debug print, change 'crypinfo' to 'cryptinfo' 2017-03-31 06:00:32 -06:00
Jussi Kivilinna dffb8a67e3 Add entropy pool and strong random number generator
Entropy pool gathers environmental noise from device drivers, user-space, etc., and returns good random numbers, suitable for cryptographic use. Based on entropy pool design from *BSDs and uses BLAKE2Xs algorithm for CSPRNG output.

Patch also adds /dev/urandom support for using entropy pool RNG and new 'getrandom' system call for getting randomness without file-descriptor usage (thus avoiding file-descriptor exhaustion attacks). The 'getrandom' interface is similar as 'getentropy' and 'getrandom' available on OpenBSD and Linux respectively.
2017-03-30 07:38:37 -06:00
Gregory Nutt 4b4dbc79a2 Move driver related prototypes out of include/nuttx/fs/fs.h and into new include/drivers/drivers.h 2016-07-20 13:15:37 -06:00
Gregory Nutt 2a751068e6 Without lowsyslog() *llerr() is not useful. Eliminate and replace with *err(). 2016-06-20 12:44:38 -06:00