Allow alternative backends for crypto provider

The crypto service provider is refactored to make it easy to add
alternative backends.  There is still only a single backend that
uses the mbedcrypto library from MbedTLS.  However, all dependencies
from the crypto provider on mbedcrypto have been removed, allowing
the crypto provider to be used with alternative implementations
of the PSA Crypto API.

Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: Ic5d1d9d47d149b634d147712749fdee48f260d85
diff --git a/deployments/crypto/opteesp/crypto_sp.c b/deployments/crypto/opteesp/crypto_sp.c
index f3679d1..bca971b 100644
--- a/deployments/crypto/opteesp/crypto_sp.c
+++ b/deployments/crypto/opteesp/crypto_sp.c
@@ -6,9 +6,10 @@
 
 #include <rpc/ffarpc/endpoint/ffarpc_call_ep.h>
 #include <service/secure_storage/factory/storage_factory.h>
-#include <service/crypto/provider/mbedcrypto/crypto_provider.h>
+#include <service/crypto/provider/crypto_provider.h>
 #include <service/crypto/provider/serializer/protobuf/pb_crypto_provider_serializer.h>
 #include <service/crypto/provider/serializer/packed-c/packedc_crypto_provider_serializer.h>
+#include <service/crypto/backend/mbedcrypto/mbedcrypto_backend.h>
 #include <protocols/rpc/common/packed-c/status.h>
 #include <config/ramstore/config_ramstore.h>
 #include <config/loader/sp/sp_config_loader.h>
@@ -26,7 +27,7 @@
 
 void __noreturn sp_main(struct ffa_init_info *init_info)
 {
-	struct mbed_crypto_provider crypto_provider;
+	struct crypto_provider crypto_provider;
 	struct ffa_call_ep ffarpc_call_ep;
 	struct rpc_interface *crypto_iface;
 	struct sp_msg req_msg = { 0 };
@@ -44,13 +45,18 @@
 	if (!storage_backend) goto fatal_error;
 
 	/* Initialize the crypto service */
-	crypto_iface = mbed_crypto_provider_init(&crypto_provider, storage_backend, 0);
+	crypto_iface = NULL;
 
-	mbed_crypto_provider_register_serializer(&crypto_provider,
+    if (mbedcrypto_backend_init(storage_backend, 0) == PSA_SUCCESS) {
+
+        crypto_iface = crypto_provider_init(&crypto_provider);
+
+		crypto_provider_register_serializer(&crypto_provider,
                     TS_RPC_ENCODING_PROTOBUF, pb_crypto_provider_serializer_instance());
 
-	mbed_crypto_provider_register_serializer(&crypto_provider,
+		crypto_provider_register_serializer(&crypto_provider,
                     TS_RPC_ENCODING_PACKED_C, packedc_crypto_provider_serializer_instance());
+	}
 
 	ffa_call_ep_init(&ffarpc_call_ep, crypto_iface);