unify the concatenation of the tag and update output length
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index 005b9fe..c0ef1c5 100755
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -1562,6 +1562,7 @@
         mbedtls_ccm_free( &ccm );
     }
     memcpy( ciphertext + plaintext_length, tag, sizeof( tag ) );
+    *ciphertext_length = plaintext_length + sizeof( tag );
     return( PSA_SUCCESS );
 }
 
@@ -1629,7 +1630,6 @@
         }
 
         mbedtls_gcm_free( &gcm );
-        memcpy( plaintext + ciphertext_length + 8, tag, sizeof( tag ) );
     }
     else if( alg == PSA_ALG_CCM )
     {
@@ -1659,8 +1659,10 @@
         }
 
         mbedtls_ccm_free( &ccm );
-        memcpy( plaintext + ciphertext_length, tag, sizeof( tag ) );
     }
+
+    memcpy( plaintext + ciphertext_length, tag, sizeof( tag ) );
+    *plaintext_length = ciphertext_length + sizeof( tag );
     return( PSA_SUCCESS );
 }