From 77dbb98428b0661f0ceee54208d226fc7fb27130 Mon Sep 17 00:00:00 2001
From: Harsimran Singh Tungal <harsimransingh.tungal@arm.com>
Date: Sun, 1 Jun 2025 11:06:00 +0000
Subject: [PATCH 02/11] se proxy protobuf change

Upstream-Status: Pending (not yet submitted to upstream)
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
Signed-off-by: Harsimran Singh Tungal <harsimransingh.tungal@arm.com>
---
 .../se-proxy/env/commonsp/se_proxy_sp.c       | 24 ++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/deployments/se-proxy/env/commonsp/se_proxy_sp.c b/deployments/se-proxy/env/commonsp/se_proxy_sp.c
index 485d7649..9f94092b 100644
--- a/deployments/se-proxy/env/commonsp/se_proxy_sp.c
+++ b/deployments/se-proxy/env/commonsp/se_proxy_sp.c
@@ -13,6 +13,7 @@
 #include "trace.h"
 #include "deployments/se-proxy/infra/service_proxy_factory.h"
 #include "deployments/se-proxy/se_proxy_interfaces.h"
+#include <service/crypto/factory/crypto_provider_factory.h>
 
 static bool sp_init(uint16_t *own_sp_id);
 
@@ -25,6 +26,8 @@ void __noreturn sp_main(union ffa_boot_info *boot_info)
 	uint16_t own_id = 0;
 	sp_result result = SP_RESULT_INTERNAL_ERROR;
 	rpc_status_t rpc_status = RPC_ERROR_INTERNAL;
+       struct rpc_service_interface *crypto_iface_protobuf = NULL;
+       struct crypto_provider *crypto_protobuf_provider = NULL;
 
 	/* Boot phase */
 	if (!sp_init(&own_id)) {
@@ -39,7 +42,7 @@ void __noreturn sp_main(union ffa_boot_info *boot_info)
 		goto fatal_error;
 	}
 
-	rpc_status = ts_rpc_endpoint_sp_init(&rpc_endpoint, 5, 16);
+	rpc_status = ts_rpc_endpoint_sp_init(&rpc_endpoint, 6, 16);
 	if (rpc_status != RPC_SUCCESS) {
 		EMSG("Failed to initialize RPC endpoint: %d", rpc_status);
 		goto fatal_error;
@@ -106,6 +109,25 @@ void __noreturn sp_main(union ffa_boot_info *boot_info)
 		goto fatal_error;
 	}
 
+       crypto_protobuf_provider = crypto_protobuf_provider_factory_create();
+       if (!crypto_protobuf_provider) {
+               EMSG("Failed to create crypto protobuf provider factory");
+               goto fatal_error;
+       }
+
+       crypto_iface_protobuf = service_provider_get_rpc_interface(
+               &crypto_protobuf_provider->base_provider);
+       if (!crypto_iface_protobuf) {
+               EMSG("Failed to create service provider RPC interface");
+               goto fatal_error;
+       }
+
+       rpc_status = ts_rpc_endpoint_sp_add_service(&rpc_endpoint, crypto_iface_protobuf);
+       if (rpc_status != RPC_SUCCESS) {
+               EMSG("Failed to add service to RPC endpoint: %d", rpc_status);
+               goto fatal_error;
+       }
+
 	/* End of boot phase */
 	result = sp_msg_wait(&req_msg);
 	if (result != SP_RESULT_OK) {
-- 
2.34.1

