Closed lucas2412 closed 5 years ago
Running your NRF code on MacOS returns the same result as your Android code.
So, the issue is on the NRF side. This is a completely unsupported, untested platform for libsodium, so unfortunately you are on your own.
Libhydrogen may be easier and safer to use on that platform.
Do you have any ideas what we could maybe try to solve this?
Are there any Libsodium encryption functions that are compatible with Libhydrogen?
How do you compile it? Using the ./configure
script?
Were you able to run the test suite?
Libhydrogen encryption functions are not compatible with libsodium.
I downloaded the latest stable version and compiled it using MSYS on Windows 10 with the ./configure
script and make
. After that Iimported the compiled folder into my GCC Project in VisualGDB.
How did you get the DLL file to run on the microcontroller?
The DLL file doesn't run on the Microcontroller. I just put the whole folder into my VisualGDB Project. When I run the project VisualGDB uses the ARM Toolchain to compile the source code for the nrf chip.
If the project was configured for MingW, it is unlikely to be correct for a different platform.
You should try to cross-compile for the actual target: https://download.libsodium.org/doc/installation#cross-compiling
As a side note, I would strongly recommend against using libsodium on that platform since it has no protection against side channels in the modular addition used by the Salsa20 cipher.
The nRF52840 chip has hardware support for AES, so you should really use that instead. This will also significantly improve speed and reduce power consumption.
libhydrogen has Android bindings now: https://github.com/libly/hydride-android
Hello,
we are trying to integrate libsodium in our Android App and this NRF Microcontroller (https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52840). We succesfully integrated libsodium in our Android App and now we are trying to integrate it on the NRF Chip with C.
The problem is that we have 2 completely different results using
crypto_secretbox_easy
on those 2 Platforms.Android:
Cleartext: test Encrypted (hex): 12953B678834AE08A11D2E12A064B11A63906C17 Decrypted: test
NRF Microcontroller
Cleartext: test Encrypted (hex): 3A2E66068C8A9180C2B9434079E1805BF8D701DC Decrypted: test
We also removed
randombytes_stir()
and_sodium_alloc_init()
fromsodium_init()
since our microcontroller doesn't support generating random numbers (We don't need it). Could the problem be here?For us its not possible to encrypt something on Android and decrypt it with the NRF Controller.
Thanks in advance.