Move mbedtls_ssl_cipher_to_psa() and psa_status_to_mbedtls() defs out of MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED build flag
Signed-off-by: Przemyslaw Stekiel <przemyslaw.stekiel@mobica.com>
diff --git a/library/ssl_misc.h b/library/ssl_misc.h
index f3b4b9f..c484415 100644
--- a/library/ssl_misc.h
+++ b/library/ssl_misc.h
@@ -1282,56 +1282,6 @@
return( MBEDTLS_SVC_KEY_ID_INIT );
}
-/* Corresponding PSA algorithm for MBEDTLS_CIPHER_NULL.
- * Same value is used fo PSA_ALG_CATEGORY_CIPHER, hence it is
- * guaranteed to not be a valid PSA algorithm identifier.
- */
-#define MBEDTLS_SSL_NULL_CIPHER 0x04000000
-
-/**
- * \brief Translate mbedtls cipher type/taglen pair to psa:
- * algorithm, key type and key size.
- *
- * \param mbedtls_cipher_type [in] given mbedtls cipher type
- * \param taglen [in] given tag length
- * 0 - default tag length
- * \param alg [out] corresponding PSA alg
- * There is no corresponding PSA
- * alg for MBEDTLS_SSL_NULL_CIPHER, so
- * MBEDTLS_SSL_NULL_CIPHER is returned
- * \param key_type [out] corresponding PSA key type
- * \param key_size [out] corresponding PSA key size
- *
- * \return PSA_SUCCESS on success or PSA_ERROR_NOT_SUPPORTED if
- * conversion is not supported.
- */
-psa_status_t mbedtls_ssl_cipher_to_psa( mbedtls_cipher_type_t mbedtls_cipher_type,
- size_t taglen,
- psa_algorithm_t *alg,
- psa_key_type_t *key_type,
- size_t *key_size );
-
-/**
- * \brief Convert given PSA status to mbedtls error code.
- *
- * \param status [in] given PSA status
- *
- * \return corresponding mbedtls error code
- */
-static inline int psa_status_to_mbedtls( psa_status_t status )
-{
- switch( status )
- {
- case PSA_SUCCESS:
- return( 0 );
- case PSA_ERROR_INSUFFICIENT_MEMORY:
- return( MBEDTLS_ERR_CIPHER_ALLOC_FAILED );
- case PSA_ERROR_NOT_SUPPORTED:
- return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE );
- default:
- return( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
- }
-}
#endif /* MBEDTLS_USE_PSA_CRYPTO */
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */
@@ -2069,5 +2019,57 @@
#define MBEDTLS_SSL_SIG_ALG( hash )
#endif /* MBEDTLS_ECDSA_C && MBEDTLS_RSA_C */
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 && MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */
+#if defined(MBEDTLS_USE_PSA_CRYPTO)
+/* Corresponding PSA algorithm for MBEDTLS_CIPHER_NULL.
+ * Same value is used fo PSA_ALG_CATEGORY_CIPHER, hence it is
+ * guaranteed to not be a valid PSA algorithm identifier.
+ */
+#define MBEDTLS_SSL_NULL_CIPHER 0x04000000
+
+/**
+ * \brief Translate mbedtls cipher type/taglen pair to psa:
+ * algorithm, key type and key size.
+ *
+ * \param mbedtls_cipher_type [in] given mbedtls cipher type
+ * \param taglen [in] given tag length
+ * 0 - default tag length
+ * \param alg [out] corresponding PSA alg
+ * There is no corresponding PSA
+ * alg for MBEDTLS_SSL_NULL_CIPHER, so
+ * MBEDTLS_SSL_NULL_CIPHER is returned
+ * \param key_type [out] corresponding PSA key type
+ * \param key_size [out] corresponding PSA key size
+ *
+ * \return PSA_SUCCESS on success or PSA_ERROR_NOT_SUPPORTED if
+ * conversion is not supported.
+ */
+psa_status_t mbedtls_ssl_cipher_to_psa( mbedtls_cipher_type_t mbedtls_cipher_type,
+ size_t taglen,
+ psa_algorithm_t *alg,
+ psa_key_type_t *key_type,
+ size_t *key_size );
+
+/**
+ * \brief Convert given PSA status to mbedtls error code.
+ *
+ * \param status [in] given PSA status
+ *
+ * \return corresponding mbedtls error code
+ */
+static inline int psa_status_to_mbedtls( psa_status_t status )
+{
+ switch( status )
+ {
+ case PSA_SUCCESS:
+ return( 0 );
+ case PSA_ERROR_INSUFFICIENT_MEMORY:
+ return( MBEDTLS_ERR_CIPHER_ALLOC_FAILED );
+ case PSA_ERROR_NOT_SUPPORTED:
+ return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE );
+ default:
+ return( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
+ }
+}
+#endif /* MBEDTLS_USE_PSA_CRYPTO */
#endif /* ssl_misc.h */