Coder Social home page Coder Social logo

Comments (14)

jedisct1 avatar jedisct1 commented on May 23, 2024 1

Once again, no need to touch the compiler flags.

There's a function to change the RNG, and it's documented: https://doc.libsodium.org/advanced/custom_rng

You should call it before sodium_init().

And try calling sodium_init() as soon as possible, before you fork(), spawn threads or whatever.

from libsodium.

jedisct1 avatar jedisct1 commented on May 23, 2024

I was not able to replicate this, no one ever reported this, and this doesn't happen on CI either.

From a vanilla macOS installation with Homebrew, what are the required steps (installation, minimal test case, compilation commands) to replicate this?

from libsodium.

calvin2021y avatar calvin2021y commented on May 23, 2024
rm -rf autom4te.cache configure Makefile.in ./src/Makefile.in ./src/libsodium/Makefile.in ./src/libsodium/include/Makefile.in ./builds/Makefile.in
./autogen.sh -f -s -o

/opt/d/C/sodium/configure --enable-static --disable-shared --without-pthreads --enable-opt

build with flags -UHAVE_AVX512FINTRIN_H -DHAVE_COMMONCRYPTO_COMMONRANDOM_H=1 -DHAVE_GETENTROPY=1 -DHAVE_TMMINTRIN_H -DHAVE_WMMINTRIN_H -Wuninitialized -DSODIUM_STATIC -DDEV_MODE

master branch.

now I will try RANDOMBYTES_DEFAULT_IMPLEMENTATION with &randombytes_internal_implementation

from libsodium.

calvin2021y avatar calvin2021y commented on May 23, 2024

recent I upgrade into clang 16. not sure this related.

from libsodium.

jedisct1 avatar jedisct1 commented on May 23, 2024

Error 35 is EAGAIN, which can only be returned for files opened in non-blocking mode. libsodium never opens files in non-blocking mode. There's just no code that could possibly do that.

Are you sure your application doesn't do something else with file descriptor 4?

from libsodium.

calvin2021y avatar calvin2021y commented on May 23, 2024

It is a huge project, I am not sure other part not touch fd 4.

from libsodium.

jedisct1 avatar jedisct1 commented on May 23, 2024

Please don't mess with the compilation flags, that doesn't help.

And try with 1.0.18-stable release tarballs and just use ./configure as documented.

from libsodium.

jedisct1 avatar jedisct1 commented on May 23, 2024

Did the test suite pass when you typed make check before make install? Because it heavily uses randombytes_buf.

from libsodium.

calvin2021y avatar calvin2021y commented on May 23, 2024

when I make test, get some missing symbol error. I will try fix this and made the test.

from libsodium.

jedisct1 avatar jedisct1 commented on May 23, 2024

????

What symbols are missing?

Was clang installed via Homebrew? Or is it zig cc?

from libsodium.

calvin2021y avatar calvin2021y commented on May 23, 2024

-DRANDOMBYTES_DEFAULT_IMPLEMENTATION=&randombytes_internal_implementation with this patch fix my problem.

diff --git a/src/libsodium/randombytes/randombytes.c b/src/libsodium/randombytes/randombytes.c
index 6741434b..ab2429cf 100644
--- a/src/libsodium/randombytes/randombytes.c
+++ b/src/libsodium/randombytes/randombytes.c
@@ -15,7 +15,7 @@
 #include "randombytes.h"
 #ifndef RANDOMBYTES_CUSTOM_IMPLEMENTATION
 # ifdef RANDOMBYTES_DEFAULT_IMPLEMENTATION
-#  include "randombytes_internal.h"
+#  include "randombytes_internal_random.h"
 # endif
 # include "randombytes_sysrandom.h"
 #endif

the make test error

lld: error: undefined symbol: crypto_aead_aegis128l_aesni_implementation
>>> referenced by aead_aegis128l.c:142 (src/libsodium/crypto_aead/aegis128l/aead_aegis128l.c:142)
>>>               ../../src/libsodium/.libs/libsodium.a(libsodium_la-aead_aegis128l.o):(symbol _crypto_aead_aegis128l_pick_best_implementation+0x22)

lld: error: undefined symbol: crypto_stream_chacha20_dolbeau_ssse3_implementation
>>> referenced by stream_chacha20.c:0 (src/libsodium/crypto_stream/chacha20/stream_chacha20.c:0)
>>>               ../../src/libsodium/.libs/libsodium.a(libsodium_la-stream_chacha20.o):(symbol _crypto_stream_chacha20_pick_best_implementation+0x2d)

lld: error: undefined symbol: crypto_stream_chacha20_dolbeau_avx2_implementation
>>> referenced by stream_chacha20.c:0 (src/libsodium/crypto_stream/chacha20/stream_chacha20.c:0)
>>>               ../../src/libsodium/.libs/libsodium.a(libsodium_la-stream_chacha20.o):(symbol _crypto_stream_chacha20_pick_best_implementation+0x1b)

lld: error: undefined symbol: crypto_aead_aegis256_aesni_implementation
>>> referenced by aead_aegis256.c:141 (src/libsodium/crypto_aead/aegis256/aead_aegis256.c:141)
>>>               ../../src/libsodium/.libs/libsodium.a(libsodium_la-aead_aegis256.o):(symbol _crypto_aead_aegis256_pick_best_implementation+0x22)

lld: error: undefined symbol: _sodium_blake2b_compress_ssse3
>>> referenced by blake2b-ref.c:0 (src/libsodium/crypto_generichash/blake2b/ref/blake2b-ref.c:0)
>>>               ../../src/libsodium/.libs/libsodium.a(libsodium_la-blake2b-ref.o):(symbol _sodium_blake2b_pick_best_implementation+0x3a)

lld: error: undefined symbol: _sodium_blake2b_compress_sse41
>>> referenced by blake2b-ref.c:0 (src/libsodium/crypto_generichash/blake2b/ref/blake2b-ref.c:0)
>>>               ../../src/libsodium/.libs/libsodium.a(libsodium_la-blake2b-ref.o):(symbol _sodium_blake2b_pick_best_implementation+0x1f)

lld: error: undefined symbol: _sodium_blake2b_compress_avx2
>>> referenced by blake2b-ref.c:0 (src/libsodium/crypto_generichash/blake2b/ref/blake2b-ref.c:0)
>>>               ../../src/libsodium/.libs/libsodium.a(libsodium_la-blake2b-ref.o):(symbol _sodium_blake2b_pick_best_implementation+0xd)

lld: error: undefined symbol: crypto_onetimeauth_poly1305_sse2_implementation
>>> referenced by onetimeauth_poly1305.c:86 (src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c:86)
>>>               ../../src/libsodium/.libs/libsodium.a(libsodium_la-onetimeauth_poly1305.o):(symbol _crypto_onetimeauth_poly1305_pick_best_implementation+0x1b)

lld: error: undefined symbol: _sodium_argon2_fill_segment_ssse3
>>> referenced by argon2-core.c:0 (src/libsodium/crypto_pwhash/argon2/argon2-core.c:0)
>>>               ../../src/libsodium/.libs/libsodium.a(libsodium_la-argon2-core.o):(symbol _crypto_pwhash_argon2_pick_best_implementation+0x28)

lld: error: undefined symbol: _sodium_argon2_fill_segment_avx2
>>> referenced by argon2-core.c:0 (src/libsodium/crypto_pwhash/argon2/argon2-core.c:0)
>>>               ../../src/libsodium/.libs/libsodium.a(libsodium_la-argon2-core.o):(symbol _crypto_pwhash_argon2_pick_best_implementation+0xd)

lld: error: undefined symbol: crypto_stream_salsa20_xmm6int_avx2_implementation
>>> referenced by stream_salsa20.c:89 (src/libsodium/crypto_stream/salsa20/stream_salsa20.c:89)
>>>               ../../src/libsodium/.libs/libsodium.a(libsodium_la-stream_salsa20.o):(symbol _crypto_stream_salsa20_pick_best_implementation+0x1b)
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

from libsodium.

jedisct1 avatar jedisct1 commented on May 23, 2024

If you invent your own way to compile it, you are on your own.

Please compile as documented.

Either just with ./configure && make check && make install, or with zig build -Doptimize=ReleaseFast.

from libsodium.

jedisct1 avatar jedisct1 commented on May 23, 2024

Also, start from a fresh clone of the repository, or type make distclean before ./configure to get rid of a previous failed compilation.

from libsodium.

calvin2021y avatar calvin2021y commented on May 23, 2024

I use ./configure && make check && make install, get this result.

# TOTAL: 82
# PASS:  82

I find for the default systemrandom, it work after start init process. late on a client request get this error. so could be some code change the fd. (is there a way to reopen it?)

and '-DRANDOMBYTES_DEFAULT_IMPLEMENTATION=&randombytes_internal_implementation' is safe to use for apple OSX, iOS ?

from libsodium.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.