summaryrefslogtreecommitdiff
path: root/libs/libsodium/src/randombytes
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2018-07-18 00:06:49 +0300
committeraunsane <aunsane@gmail.com>2018-07-18 00:17:42 +0300
commit5a8dadd96ca13797f67c39079ba5c4889ef8c421 (patch)
tree0532b9a3c21feb03a6a3be810f559ebf0af45947 /libs/libsodium/src/randombytes
parent39d52f0ab12ecf2a3a5f48bf7af140db282a13a6 (diff)
updated libsodium
Diffstat (limited to 'libs/libsodium/src/randombytes')
-rw-r--r--libs/libsodium/src/randombytes/randombytes.c2
-rw-r--r--libs/libsodium/src/randombytes/salsa20/randombytes_salsa20_random.c20
2 files changed, 8 insertions, 14 deletions
diff --git a/libs/libsodium/src/randombytes/randombytes.c b/libs/libsodium/src/randombytes/randombytes.c
index 708616b8aa..4c1a536ef2 100644
--- a/libs/libsodium/src/randombytes/randombytes.c
+++ b/libs/libsodium/src/randombytes/randombytes.c
@@ -107,7 +107,7 @@ randombytes_stir(void)
try {
var crypto = require('crypto');
var randomValueNodeJS = function() {
- var buf = crypto.randomBytes(4);
+ var buf = crypto['randomBytes'](4);
return (buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]) >>> 0;
};
randomValueNodeJS();
diff --git a/libs/libsodium/src/randombytes/salsa20/randombytes_salsa20_random.c b/libs/libsodium/src/randombytes/salsa20/randombytes_salsa20_random.c
index 79916eabc0..477fda1c39 100644
--- a/libs/libsodium/src/randombytes/salsa20/randombytes_salsa20_random.c
+++ b/libs/libsodium/src/randombytes/salsa20/randombytes_salsa20_random.c
@@ -329,9 +329,6 @@ randombytes_salsa20_random_init(void)
static void
randombytes_salsa20_random_stir(void)
{
- unsigned char m0[crypto_stream_salsa20_KEYBYTES +
- crypto_stream_salsa20_NONCEBYTES];
-
memset(stream.rnd32, 0, sizeof stream.rnd32);
stream.rnd32_outleft = (size_t) 0U;
if (global.initialized == 0) {
@@ -345,34 +342,31 @@ randombytes_salsa20_random_stir(void)
#ifndef _WIN32
# ifdef HAVE_SAFE_ARC4RANDOM
- arc4random_buf(m0, sizeof m0);
+ arc4random_buf(stream.key, sizeof stream.key);
# elif defined(SYS_getrandom) && defined(__NR_getrandom)
if (global.getrandom_available != 0) {
- if (randombytes_linux_getrandom(m0, sizeof m0) != 0) {
+ if (randombytes_linux_getrandom(stream.key, sizeof stream.key) != 0) {
sodium_misuse(); /* LCOV_EXCL_LINE */
}
} else if (global.random_data_source_fd == -1 ||
- safe_read(global.random_data_source_fd, m0,
- sizeof m0) != (ssize_t) sizeof m0) {
+ safe_read(global.random_data_source_fd, stream.key,
+ sizeof stream.key) != (ssize_t) sizeof stream.key) {
sodium_misuse(); /* LCOV_EXCL_LINE */
}
# else
if (global.random_data_source_fd == -1 ||
- safe_read(global.random_data_source_fd, m0,
- sizeof m0) != (ssize_t) sizeof m0) {
+ safe_read(global.random_data_source_fd, stream.key,
+ sizeof stream.key) != (ssize_t) sizeof stream.key) {
sodium_misuse(); /* LCOV_EXCL_LINE */
}
# endif
#else /* _WIN32 */
- if (! RtlGenRandom((PVOID) m0, (ULONG) sizeof m0)) {
+ if (! RtlGenRandom((PVOID) stream.key, (ULONG) sizeof stream.key)) {
sodium_misuse(); /* LCOV_EXCL_LINE */
}
#endif
- crypto_stream_salsa20(stream.key, sizeof stream.key,
- m0 + crypto_stream_salsa20_KEYBYTES, m0);
- sodium_memzero(m0, sizeof m0);
stream.initialized = 1;
}