more checks just to be sure
@@ -51,6 +51,8 @@ namespace yojimbo
bool Encrypt( const uint8_t * message, int messageLength, uint8_t * encryptedMessage, int & encryptedMessageLength, const uint8_t * nonce, const uint8_t * key )
{
+ assert( KeyBytes == crypto_secretbox_KEYBYTES );
+
uint8_t actual_nonce[crypto_secretbox_NONCEBYTES];
memset( actual_nonce, 0, sizeof( actual_nonce ) );
memcpy( actual_nonce, nonce, NonceBytes );
@@ -67,6 +69,8 @@ namespace yojimbo
uint8_t * decryptedMessage, int & decryptedMessageLength,
const uint8_t * nonce, const uint8_t * key )
{
+ assert( KeyBytes == crypto_secretbox_KEYBYTES );
+
uint8_t actual_nonce[crypto_secretbox_NONCEBYTES];
memset( actual_nonce, 0, sizeof( actual_nonce ) );
memcpy( actual_nonce, nonce, NonceBytes );
@@ -85,6 +89,8 @@ namespace yojimbo
const uint8_t * nonce,
const uint8_t * key )
{
+ assert( KeyBytes == crypto_aead_chacha20poly1305_KEYBYTES );
+
uint8_t actual_nonce[crypto_aead_chacha20poly1305_NPUBBYTES];
memset( actual_nonce, 0, sizeof( actual_nonce ) );
memcpy( actual_nonce, nonce, NonceBytes );
@@ -107,6 +113,8 @@ namespace yojimbo
const uint8_t * nonce,
const uint8_t * key )
{
+ assert( KeyBytes == crypto_aead_chacha20poly1305_KEYBYTES );
+
uint8_t actual_nonce[crypto_aead_chacha20poly1305_NPUBBYTES];
memset( actual_nonce, 0, sizeof( actual_nonce ) );
memcpy( actual_nonce, nonce, NonceBytes );
