Code cleanup

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c
index 35679ca..17479b8 100644
--- a/library/ssl_tls13_client.c
+++ b/library/ssl_tls13_client.c
@@ -248,11 +248,6 @@
     ((void) group_id);
 #endif /* PSA_WANT_ALG_ECDH || PSA_WANT_ALG_FFDH */
 
-    /*
-     * Add DHE named groups here.
-     * Pick first available DHE group compatible with TLS 1.3
-     */
-
     return ret;
 }
 
@@ -386,7 +381,7 @@
                                              const unsigned char *buf,
                                              const unsigned char *end)
 {
-#if defined(PSA_WANT_ALG_ECDH)
+#if defined(PSA_WANT_ALG_ECDH) || defined(PSA_WANT_ALG_FFDH)
     const unsigned char *p = buf;
     int selected_group;
     int found = 0;
@@ -413,6 +408,7 @@
      * then the client MUST abort the handshake with an "illegal_parameter" alert.
      */
     for (; *group_list != 0; group_list++) {
+#if defined(PSA_WANT_ALG_ECDH)
         if (mbedtls_ssl_tls13_named_group_is_ecdhe(*group_list)) {
             if ((mbedtls_ssl_get_psa_curve_info_from_tls_id(
                      *group_list, NULL, NULL) == PSA_ERROR_NOT_SUPPORTED) ||
@@ -421,10 +417,13 @@
                 break;
             }
         }
+#endif /* PSA_WANT_ALG_ECDH */
+#if defined(PSA_WANT_ALG_FFDH)
         if (mbedtls_ssl_tls13_named_group_is_dhe(*group_list)) {
             found = 1;
             break;
         }
+#endif /* PSA_WANT_ALG_FFDH */
     }
 
     /* Client MUST verify that the selected_group field does not
@@ -446,12 +445,12 @@
     ssl->handshake->offered_group_id = selected_group;
 
     return 0;
-#else
+#else /* PSA_WANT_ALG_ECDH || PSA_WANT_ALG_FFDH */
     (void) ssl;
     (void) buf;
     (void) end;
     return MBEDTLS_ERR_SSL_BAD_CONFIG;
-#endif
+#endif /* PSA_WANT_ALG_ECDH || PSA_WANT_ALG_FFDH */
 }
 
 /*
@@ -497,25 +496,10 @@
 #if defined(PSA_WANT_ALG_ECDH) || defined(PSA_WANT_ALG_FFDH)
     if (mbedtls_ssl_tls13_named_group_is_ecdhe(group) ||
         mbedtls_ssl_tls13_named_group_is_dhe(group)) {
-#if defined(PSA_WANT_ALG_ECDH)
-        if (mbedtls_ssl_tls13_named_group_is_ecdhe(group)) {
-            if (mbedtls_ssl_get_psa_curve_info_from_tls_id(group, NULL, NULL)
-                == PSA_ERROR_NOT_SUPPORTED) {
-                MBEDTLS_SSL_DEBUG_MSG(1, ("Invalid TLS curve group id"));
-                return MBEDTLS_ERR_SSL_INTERNAL_ERROR;
-            }
-
-            MBEDTLS_SSL_DEBUG_MSG(
-                2,
-                ("ECDH curve: %s", mbedtls_ssl_get_curve_name_from_tls_id(group)));
-        }
-#endif /* PSA_WANT_ALG_ECDH */
-#if defined(PSA_WANT_ALG_FFDH)
-        if (mbedtls_ssl_tls13_named_group_is_dhe(group)) {
-            MBEDTLS_SSL_DEBUG_MSG(2,
-                                  ("DHE group name: %s", mbedtls_ssl_ffdh_name_from_group(group)));
-        }
-#endif /* PSA_WANT_ALG_FFDH */
+#if defined(MBEDTLS_DEBUG_C)
+        MBEDTLS_SSL_DEBUG_MSG(2,
+                              ("DHE group name: %s", mbedtls_ssl_named_group_to_str(group)));
+#endif
         ret = mbedtls_ssl_tls13_read_public_ecdhe_share(ssl, p, end - p);
         if (ret != 0) {
             return ret;