From af5363c24e822960f1c8ff7af66f76d05ddc29eb Mon Sep 17 00:00:00 2001
From: John Durkop <john.durkop@fermatsoftware.com>
Date: Mon, 24 Aug 2020 08:29:39 -0700
Subject: [PATCH] Updates to cleanup fixes for #3294

Minor updates to changelog for more concise wording and fixed styling
in other files as needed.

Signed-off-by: John Durkop <john.durkop@fermatsoftware.com>
---
 ChangeLog.d/bugfix_PR3294.txt | 8 ++------
 library/pk_wrap.c             | 8 ++++----
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/ChangeLog.d/bugfix_PR3294.txt b/ChangeLog.d/bugfix_PR3294.txt
index 9a5bbc445f..a6ea75e05c 100644
--- a/ChangeLog.d/bugfix_PR3294.txt
+++ b/ChangeLog.d/bugfix_PR3294.txt
@@ -1,8 +1,4 @@
 Bugfix
-   * Add guards in pk_wrap.c to ensure if ECDSA is not defined, errors are
-     returned. Remove warnings in pk.c for unused variables. Add new test
-     (test_depends_pkalgs_psa) to all.sh to confirm when USE_PSA_CRYPTO 
-     is defined that features are working properly. Fixes issue reported in
-     #3294 where undefined reference errors occur when using USE_PSA_CRYPTO
-     and removing ECDSA support.
+   * Fix build failure in configurations where MBEDTLS_USE_PSA_CRYPTO is
+     enabled but ECDSA is disabled. Contributed by jdurkop. Fixes #3294.
 
diff --git a/library/pk_wrap.c b/library/pk_wrap.c
index fd4a87509f..33253a4d25 100644
--- a/library/pk_wrap.c
+++ b/library/pk_wrap.c
@@ -34,7 +34,7 @@
 #include "mbedtls/ecp.h"
 #endif
 
-#if defined(MBEDTLS_ECDSA_C) || defined(MBEDTLS_USE_PSA_CRYPTO)
+#if defined(MBEDTLS_ECDSA_C)
 #include "mbedtls/ecdsa.h"
 #endif
 
@@ -1012,8 +1012,8 @@ static int pk_opaque_sign_wrap( void *ctx, mbedtls_md_type_t md_alg,
     ((void) sig_len);
     ((void) f_rng);
     ((void) p_rng);
-    return( PSA_ERROR_NOT_SUPPORTED );
-#else
+    return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE );
+#else /* !MBEDTLS_ECDSA_C */
     const psa_key_handle_t *key = (const psa_key_handle_t *) ctx;
     psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
     psa_algorithm_t alg = PSA_ALG_ECDSA( mbedtls_psa_translate_md( md_alg ) );
@@ -1044,7 +1044,7 @@ static int pk_opaque_sign_wrap( void *ctx, mbedtls_md_type_t md_alg,
 
     /* transcode it to ASN.1 sequence */
     return( pk_ecdsa_sig_asn1_from_psa( sig, sig_len, buf_len ) );
-#endif
+#endif /* !MBEDTLS_ECDSA_C */
 }
 
 const mbedtls_pk_info_t mbedtls_pk_opaque_info = {