Nuki Bluetooth API - Encrypted Writing

Hello,

we are trying to integrate some basic functionality in our Android App. We already did the authentification and are now trying to write something encrypted.
In the Documentation is specified that we need to use the function crypto_secretbox_xsalsa20poly1305 (c,m,mlen,n,k) to encrypt the message. But we have some problems regarding the input parameters.

  • c —> the output of the function (the encrypted cleartext)
  • m —> cleartext input (our pdata byte array)
  • mlen —> what is the input of this parameter? How we understood it is the output length of c. But how can we know how long the encrypted pdata length should be?
  • n —> random 24 byte nonce
  • k —> our shared key

I hope you can help us.

Thanks in advance.

Hi,
mlen is the message length of the unencrypted data. You should be able to easily compute that :slight_smile:

1 Like