mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 03:05:40 +08:00
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>
This commit is contained in:
@@ -175,7 +175,7 @@ static void addentropy(FAR const uint32_t *buf, size_t n, bool inc_new)
|
|||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
rotate = g_rng.rd_rotate;
|
rotate = g_rng.rd_rotate;
|
||||||
w = ROTL_32(*buf, rotate);
|
w = rotate ? ROTL_32(*buf, rotate) : *buf;
|
||||||
i = g_rng.rd_addptr = (g_rng.rd_addptr - 1) & POOL_MASK;
|
i = g_rng.rd_addptr = (g_rng.rd_addptr - 1) & POOL_MASK;
|
||||||
|
|
||||||
/* Normal round, we add 7 bits of rotation to the pool.
|
/* Normal round, we add 7 bits of rotation to the pool.
|
||||||
@@ -463,7 +463,7 @@ void up_rngaddentropy(enum rnd_source_t kindof, FAR const uint32_t *buf,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &ts);
|
clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
tbuf[0] = ROTL_32(ts.tv_nsec, 17) ^ ROTL_32(ts.tv_sec, 3);
|
tbuf[0] = ROTL_32((uint32_t)ts.tv_nsec, 17) ^ ROTL_32(ts.tv_sec, 3);
|
||||||
tbuf[0] += ROTL_32(kindof, 27);
|
tbuf[0] += ROTL_32(kindof, 27);
|
||||||
tbuf[0] += ROTL_32((uintptr_t)&tbuf[0], 11);
|
tbuf[0] += ROTL_32((uintptr_t)&tbuf[0], 11);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user