pk_wrap.c: fix length mismatch check placement

diff --git a/library/pk_wrap.c b/library/pk_wrap.c
index 9fc7e22..3690fef 100644
--- a/library/pk_wrap.c
+++ b/library/pk_wrap.c
@@ -605,12 +605,6 @@
         goto cleanup;
     }
 
-    if( p != sig + sig_len )
-    {
-        ret = MBEDTLS_ERR_PK_SIG_LEN_MISMATCH;
-        goto cleanup;
-    }
-
     if( psa_asymmetric_verify( key_slot, psa_sig_md,
                                hash, hash_len,
                                buf, 2 * signature_part_size )
@@ -619,6 +613,12 @@
          ret = MBEDTLS_ERR_ECP_VERIFY_FAILED;
          goto cleanup;
     }
+
+    if( p != sig + sig_len )
+    {
+        ret = MBEDTLS_ERR_PK_SIG_LEN_MISMATCH;
+        goto cleanup;
+    }
     ret = 0;
 
 cleanup: