Crypto Library support NaCl

Hi all somebody know any compatible crypto library that implement NaCl (https://nacl.cr.yp.to/) I tried two options:

But without any result, can somebody share some hints, thanks!

I was able to clone the libsodium repository and compile the library based on the instructions from: https://download.libsodium.org/doc/installation#cross-compiling

export PATH=/path/to/gcc-arm-none-eabi/bin:$PATH # I already had gcc-arm-none-eabi in my PATH
cd libsodium
git checkout stable
export LDFLAGS='--specs=nosys.specs'
export CFLAGS='-Os'
mkdir output
./autogen.sh
./configure --host=arm-none-eabi --prefix=$PWD/output
make install

In the output directory the resulting “usable” library is saved.

Hope this helps.

Hi Mark thanks for the tip. I just did the cross compile the library and works.

But now another doubt arise, looking at the particle docs

Every Particle library complies with the following file structure that will be automatically generated when a new library is initialized:

  • examples
    • usage
      • usage.ino
  • src
    • mylibrary.cpp
    • mylibrary.h
  • library.properties
  • README.md
  • LICENSE.txt

so looking at the structure of the output

./
├── include
│   ├── sodium
│   │   ├── core.h
│   │   ├── crypto_aead_aes256gcm.h
│   │   ├── crypto_aead_chacha20poly1305.h
│   │   ├── crypto_aead_xchacha20poly1305.h
│   │   ├── crypto_auth.h
│   │   ├── crypto_auth_hmacsha256.h
│   │   ├── crypto_auth_hmacsha512.h
│   │   ├── crypto_auth_hmacsha512256.h
│   │   ├── crypto_box.h
│   │   ├── crypto_box_curve25519xchacha20poly1305.h
│   │   ├── crypto_box_curve25519xsalsa20poly1305.h
│   │   ├── crypto_core_ed25519.h
│   │   ├── crypto_core_hchacha20.h
│   │   ├── crypto_core_hsalsa20.h
│   │   ├── crypto_core_ristretto255.h
│   │   ├── crypto_core_salsa20.h
│   │   ├── crypto_core_salsa2012.h
│   │   ├── crypto_core_salsa208.h
│   │   ├── crypto_generichash.h
│   │   ├── crypto_generichash_blake2b.h
│   │   ├── crypto_hash.h
│   │   ├── crypto_hash_sha256.h
│   │   ├── crypto_hash_sha512.h
│   │   ├── crypto_kdf.h
│   │   ├── crypto_kdf_blake2b.h
│   │   ├── crypto_kx.h
│   │   ├── crypto_onetimeauth.h
│   │   ├── crypto_onetimeauth_poly1305.h
│   │   ├── crypto_pwhash.h
│   │   ├── crypto_pwhash_argon2i.h
│   │   ├── crypto_pwhash_argon2id.h
│   │   ├── crypto_pwhash_scryptsalsa208sha256.h
│   │   ├── crypto_scalarmult.h
│   │   ├── crypto_scalarmult_curve25519.h
│   │   ├── crypto_scalarmult_ed25519.h
│   │   ├── crypto_scalarmult_ristretto255.h
│   │   ├── crypto_secretbox.h
│   │   ├── crypto_secretbox_xchacha20poly1305.h
│   │   ├── crypto_secretbox_xsalsa20poly1305.h
│   │   ├── crypto_secretstream_xchacha20poly1305.h
│   │   ├── crypto_shorthash.h
│   │   ├── crypto_shorthash_siphash24.h
│   │   ├── crypto_sign.h
│   │   ├── crypto_sign_ed25519.h
│   │   ├── crypto_sign_edwards25519sha512batch.h
│   │   ├── crypto_stream.h
│   │   ├── crypto_stream_chacha20.h
│   │   ├── crypto_stream_salsa20.h
│   │   ├── crypto_stream_salsa2012.h
│   │   ├── crypto_stream_salsa208.h
│   │   ├── crypto_stream_xchacha20.h
│   │   ├── crypto_stream_xsalsa20.h
│   │   ├── crypto_verify_16.h
│   │   ├── crypto_verify_32.h
│   │   ├── crypto_verify_64.h
│   │   ├── export.h
│   │   ├── randombytes.h
│   │   ├── randombytes_internal_random.h
│   │   ├── randombytes_sysrandom.h
│   │   ├── runtime.h
│   │   ├── utils.h
│   │   └── version.h
│   └── sodium.h
└── lib
    ├── libsodium.a
    ├── libsodium.la
    └── pkgconfig
        └── libsodium.pc

So my guess is that lib/ dir and its content must be specified in the library.properties in the field whitelist in order the lib work properly. I only add the sodium dir into the lib directory

lib
└── sodium
    └── src
        ├── sodium
        │   ├── core.h
        │   ├── crypto_aead_aes256gcm.h
        │   ├── crypto_aead_chacha20poly1305.h
        │   ├── crypto_aead_xchacha20poly1305.h
        │   ├── crypto_auth.h
        │   ├── crypto_auth_hmacsha256.h
        │   ├── crypto_auth_hmacsha512.h
        │   ├── crypto_auth_hmacsha512256.h
        │   ├── crypto_box.h
        │   ├── crypto_box_curve25519xchacha20poly1305.h
        │   ├── crypto_box_curve25519xsalsa20poly1305.h
        │   ├── crypto_core_ed25519.h
        │   ├── crypto_core_hchacha20.h
        │   ├── crypto_core_hsalsa20.h
        │   ├── crypto_core_ristretto255.h
        │   ├── crypto_core_salsa20.h
        │   ├── crypto_core_salsa2012.h
        │   ├── crypto_core_salsa208.h
        │   ├── crypto_generichash.h
        │   ├── crypto_generichash_blake2b.h
        │   ├── crypto_hash.h
        │   ├── crypto_hash_sha256.h
        │   ├── crypto_hash_sha512.h
        │   ├── crypto_kdf.h
        │   ├── crypto_kdf_blake2b.h
        │   ├── crypto_kx.h
        │   ├── crypto_onetimeauth.h
        │   ├── crypto_onetimeauth_poly1305.h
        │   ├── crypto_pwhash.h
        │   ├── crypto_pwhash_argon2i.h
        │   ├── crypto_pwhash_argon2id.h
        │   ├── crypto_pwhash_scryptsalsa208sha256.h
        │   ├── crypto_scalarmult.h
        │   ├── crypto_scalarmult_curve25519.h
        │   ├── crypto_scalarmult_ed25519.h
        │   ├── crypto_scalarmult_ristretto255.h
        │   ├── crypto_secretbox.h
        │   ├── crypto_secretbox_xchacha20poly1305.h
        │   ├── crypto_secretbox_xsalsa20poly1305.h
        │   ├── crypto_secretstream_xchacha20poly1305.h
        │   ├── crypto_shorthash.h
        │   ├── crypto_shorthash_siphash24.h
        │   ├── crypto_sign.h
        │   ├── crypto_sign_ed25519.h
        │   ├── crypto_sign_edwards25519sha512batch.h
        │   ├── crypto_stream.h
        │   ├── crypto_stream_chacha20.h
        │   ├── crypto_stream_salsa20.h
        │   ├── crypto_stream_salsa2012.h
        │   ├── crypto_stream_salsa208.h
        │   ├── crypto_stream_xchacha20.h
        │   ├── crypto_stream_xsalsa20.h
        │   ├── crypto_verify_16.h
        │   ├── crypto_verify_32.h
        │   ├── crypto_verify_64.h
        │   ├── export.h
        │   ├── randombytes.h
        │   ├── randombytes_internal_random.h
        │   ├── randombytes_sysrandom.h
        │   ├── runtime.h
        │   ├── utils.h
        │   └── version.h
        └── sodium.h

And add in the loop(), the code recomended on the quick start of the libsodium sodium_init() but when try to compile (cloud compile) errors appeared.

make[2]: Leaving directory '/firmware/user'
make -C ../../../hal-dynalib 
make[2]: Entering directory '/firmware/hal-dynalib'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/firmware/hal-dynalib'
make -C ../../../services-dynalib 
make[2]: Enterin
	at makeError (/Users/jaimelabra/.vscode/extensions/particle.particle-vscode-core-1.5.4/node_modules/execa/index.js:174:9)
	at module.exports.Promise.all.then.arr (/Users/jaimelabra/.vscode/extensions/particle.particle-vscode-core-1.5.4/node_modules/execa/index.js:278:16)

I'll keep testing in order to use it with my particle device.

Thanks!