Factor hash operations to sub-provider
To allow for per-deployment configuration of supported crypto
operations, hash operations have been factored to a separate
sub-provider. This approach allows extended operations to
be supported without bloating the base crypto provider.
Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I7a785762e8958c916a2668dba96efb533908bc8a
diff --git a/deployments/crypto/opteesp/crypto_sp.c b/deployments/crypto/opteesp/crypto_sp.c
index bca971b..ce236d9 100644
--- a/deployments/crypto/opteesp/crypto_sp.c
+++ b/deployments/crypto/opteesp/crypto_sp.c
@@ -6,9 +6,7 @@
#include <rpc/ffarpc/endpoint/ffarpc_call_ep.h>
#include <service/secure_storage/factory/storage_factory.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/factory/crypto_provider_factory.h>
#include <service/crypto/backend/mbedcrypto/mbedcrypto_backend.h>
#include <protocols/rpc/common/packed-c/status.h>
#include <config/ramstore/config_ramstore.h>
@@ -27,7 +25,7 @@
void __noreturn sp_main(struct ffa_init_info *init_info)
{
- struct 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 };
@@ -47,15 +45,10 @@
/* Initialize the crypto service */
crypto_iface = NULL;
- if (mbedcrypto_backend_init(storage_backend, 0) == PSA_SUCCESS) {
+ 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());
-
- crypto_provider_register_serializer(&crypto_provider,
- TS_RPC_ENCODING_PACKED_C, packedc_crypto_provider_serializer_instance());
+ crypto_provider = crypto_provider_factory_create();
+ crypto_iface = service_provider_get_rpc_interface(&crypto_provider->base_provider);
}
ffa_call_ep_init(&ffarpc_call_ep, crypto_iface);