Allow some parameters to be NULL if the length is 0.

This change permits users of the ChaCha20/Poly1305 algorithms
(and the AEAD construction thereof) to pass NULL pointers for
data that they do not need, and avoids the need to provide a valid
buffer for data that is not used.
diff --git a/library/aead_chacha20_poly1305.c b/library/aead_chacha20_poly1305.c
index ab29dfa..2dea5c9 100644
--- a/library/aead_chacha20_poly1305.c
+++ b/library/aead_chacha20_poly1305.c
@@ -174,10 +174,15 @@
                                                size_t aad_len,
                                                const unsigned char *aad )
 {
-    if ( ( ctx == NULL ) || ( aad == NULL ) )
+    if ( ctx == NULL )
     {
         return( MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA );
     }
+    else if ( ( aad_len > 0U ) && ( aad == NULL ) )
+    {
+        /* aad pointer is allowed to be NULL if aad_len == 0 */
+        return( MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA );
+    }
     else if ( ctx->state != AEAD_CHACHA20_POLY1305_STATE_AAD )
     {
         return (MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_STATE );
@@ -197,6 +202,11 @@
     {
         return( MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA );
     }
+    else if ( ( len > 0U ) && ( ( input == NULL ) || ( output == NULL ) ) )
+    {
+        /* input and output pointers are allowed to be NULL if len == 0 */
+        return( MBEDTLS_ERR_AEAD_CHACHA20_POLY1305_BAD_INPUT_DATA );
+    }
     else if ( ( ctx->state != AEAD_CHACHA20_POLY1305_STATE_AAD ) &&
               ( ctx->state != AEAD_CHACHA20_POLY1305_STATE_CIPHERTEXT ) )
     {