dominictarr / tweetnacl

MIT License
3 stars 1 forks source link

Trying to integrate tweetnacl with contiki #1

Open imashoksundar opened 7 years ago

imashoksundar commented 7 years ago

Hi I've successfully compiled and generated public and secret keys in cc2650 contiki3.0 using this https://github.com/ultramancool/tweetnacl-usable . But the decryption fails with "crypto_box_open returned: -1".

I generated random numbers using contiki's random_rand() function. I'm using the same nonce key for encrypting and decrypting but I have no idea why it is failing to decrypt though. errorgit

`void randombytes(u8 *rnd,u64 len){ int i; u8 randomNumber[32];

for (i=0;i<len;i++){
        randomNumber[i]=random_rand();
*rnd = randomNumber[i];
rnd++;

} }`

Any ideas much appreciated.

dominictarr commented 7 years ago

If you used tweetnacl-usable why did you post the issue here? To be honest, I forgot I even started this project.

However, what I would if I was you, would be to compare the output of your encrypt function with the output of the same method from another nacl binding. If they not exactly the same, then the problem is in the encrypt function, but if they are, the problem is the decrypt. If you are passing the same nonce and keys in, then it's not those.

I'd recommend just using http://npm.im/sodium-native though

dominictarr commented 7 years ago

hang on, if contiki uses cc2650 keys (whatever those are) I'm not surprised if it wouldn't work with nacl, which uses ed25519 and curve25519 keys.