psa: Disallow use of invalid MAC contexts

Ensure that when doing MAC operations out of order, PSA_ERROR_BAD_STATE
is returned as documented in crypto.h and the PSA Crypto specification.
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index ad7367b..9bfe8d2 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -2238,6 +2238,11 @@
 {
     psa_status_t status;
 
+    if( operation->alg == 0 )
+    {
+        return( PSA_ERROR_BAD_STATE );
+    }
+
     /* Fill the output buffer with something that isn't a valid mac
      * (barring an attack on the mac and deliberately-crafted input),
      * in case the caller doesn't check the return status properly. */
@@ -2276,6 +2281,11 @@
     uint8_t actual_mac[PSA_MAC_MAX_SIZE];
     psa_status_t status;
 
+    if( operation->alg == 0 )
+    {
+        return( PSA_ERROR_BAD_STATE );
+    }
+
     if( operation->is_sign )
     {
         status = PSA_ERROR_BAD_STATE;