Crypto: Add option to disable separate modules

This patch introduces the configuration option in
the Crypto service to allow disabling at build time
of different submodules, such as Cipher, Hash, Mac,
Generator, Aead and Asymmetric.

Change-Id: I3ccfde15cfe2cb6fd540815ad4a47fb24a98ada9
Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
diff --git a/secure_fw/services/crypto/crypto_cipher.c b/secure_fw/services/crypto/crypto_cipher.c
index 466cbfe..eb0c3a5 100644
--- a/secure_fw/services/crypto/crypto_cipher.c
+++ b/secure_fw/services/crypto/crypto_cipher.c
@@ -29,6 +29,9 @@
                                            psa_outvec out_vec[],
                                            size_t out_len)
 {
+#if (TFM_CRYPTO_CIPHER_MODULE_DISABLED != 0)
+    return PSA_ERROR_NOT_SUPPORTED;
+#else
     psa_status_t status = PSA_SUCCESS;
     psa_cipher_operation_t *operation = NULL;
 
@@ -68,6 +71,7 @@
     }
 
     return status;
+#endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
 }
 
 psa_status_t tfm_crypto_cipher_set_iv(psa_invec in_vec[],
@@ -75,6 +79,9 @@
                                       psa_outvec out_vec[],
                                       size_t out_len)
 {
+#if (TFM_CRYPTO_CIPHER_MODULE_DISABLED != 0)
+    return PSA_ERROR_NOT_SUPPORTED;
+#else
     psa_status_t status = PSA_SUCCESS;
     psa_cipher_operation_t *operation = NULL;
 
@@ -111,6 +118,7 @@
     }
 
     return status;
+#endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
 }
 
 psa_status_t tfm_crypto_cipher_encrypt_setup(psa_invec in_vec[],
@@ -118,6 +126,9 @@
                                              psa_outvec out_vec[],
                                              size_t out_len)
 {
+#if (TFM_CRYPTO_CIPHER_MODULE_DISABLED != 0)
+    return PSA_ERROR_NOT_SUPPORTED;
+#else
     psa_status_t status = PSA_SUCCESS;
     psa_cipher_operation_t *operation = NULL;
 
@@ -158,6 +169,7 @@
     }
 
     return status;
+#endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
 }
 
 psa_status_t tfm_crypto_cipher_decrypt_setup(psa_invec in_vec[],
@@ -165,6 +177,9 @@
                                              psa_outvec out_vec[],
                                              size_t out_len)
 {
+#if (TFM_CRYPTO_CIPHER_MODULE_DISABLED != 0)
+    return PSA_ERROR_NOT_SUPPORTED;
+#else
     psa_status_t status = PSA_SUCCESS;
     psa_cipher_operation_t *operation = NULL;
 
@@ -205,6 +220,7 @@
     }
 
     return status;
+#endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
 }
 
 psa_status_t tfm_crypto_cipher_update(psa_invec in_vec[],
@@ -212,6 +228,9 @@
                                       psa_outvec out_vec[],
                                       size_t out_len)
 {
+#if (TFM_CRYPTO_CIPHER_MODULE_DISABLED != 0)
+    return PSA_ERROR_NOT_SUPPORTED;
+#else
     psa_status_t status = PSA_SUCCESS;
     psa_cipher_operation_t *operation = NULL;
 
@@ -254,6 +273,7 @@
     }
 
     return status;
+#endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
 }
 
 psa_status_t tfm_crypto_cipher_finish(psa_invec in_vec[],
@@ -261,6 +281,9 @@
                                       psa_outvec out_vec[],
                                       size_t out_len)
 {
+#if (TFM_CRYPTO_CIPHER_MODULE_DISABLED != 0)
+    return PSA_ERROR_NOT_SUPPORTED;
+#else
     psa_status_t status = PSA_SUCCESS;
     psa_cipher_operation_t *operation = NULL;
 
@@ -302,6 +325,7 @@
     status = tfm_crypto_operation_release(handle_out);
 
     return status;
+#endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
 }
 
 psa_status_t tfm_crypto_cipher_abort(psa_invec in_vec[],
@@ -309,6 +333,9 @@
                                      psa_outvec out_vec[],
                                      size_t out_len)
 {
+#if (TFM_CRYPTO_CIPHER_MODULE_DISABLED != 0)
+    return PSA_ERROR_NOT_SUPPORTED;
+#else
     psa_status_t status = PSA_SUCCESS;
     psa_cipher_operation_t *operation = NULL;
 
@@ -347,5 +374,6 @@
     status = tfm_crypto_operation_release(handle_out);
 
     return status;
+#endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
 }
 /*!@}*/