Replace se-proxy service backends with stubs

To facilitate the development of proxy backends that will
communicate with a remote secure element, the se-proxy
deployment has been modified to use stub components that
honour all service provider dependencies but don't do
anything.  This simplifies the se-proxy built image in
preparation for adding the se service clients.

Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I2dac1e295814839d4c7dccf4120667186d7ea6de
diff --git a/components/service/crypto/backend/stub/component.cmake b/components/service/crypto/backend/stub/component.cmake
new file mode 100644
index 0000000..5972f5d
--- /dev/null
+++ b/components/service/crypto/backend/stub/component.cmake
@@ -0,0 +1,21 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+if (NOT DEFINED TGT)
+	message(FATAL_ERROR "mandatory parameter TGT is not defined.")
+endif()
+
+target_sources(${TGT} PRIVATE
+	"${CMAKE_CURRENT_LIST_DIR}/stub_crypto_backend.c"
+	)
+
+# The stub crypto backend uses the psa crypto client to realize the
+# psa crypto API that the crypto provider depends on.  This define
+# configures the psa crypto client to be built with the stub crypto
+# caller.
+target_compile_definitions(${TGT} PRIVATE
+	PSA_CRYPTO_CLIENT_CALLER_SELECTION_H="service/crypto/client/caller/stub/crypto_caller.h"
+)
diff --git a/components/service/crypto/backend/stub/stub_crypto_backend.c b/components/service/crypto/backend/stub/stub_crypto_backend.c
new file mode 100644
index 0000000..f969b43
--- /dev/null
+++ b/components/service/crypto/backend/stub/stub_crypto_backend.c
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <stddef.h>
+#include <psa/crypto.h>
+#include <service/crypto/client/psa/psa_crypto_client.h>
+#include <protocols/rpc/common/packed-c/status.h>
+#include <rpc/dummy/dummy_caller.h>
+#include "stub_crypto_backend.h"
+
+psa_status_t stub_crypto_backend_init(void)
+{
+	static struct dummy_caller dummy_caller;
+	struct rpc_caller *caller = dummy_caller_init(&dummy_caller,
+		TS_RPC_CALL_ACCEPTED, PSA_ERROR_SERVICE_FAILURE);
+
+	psa_status_t status = psa_crypto_client_init(caller);
+
+	if (status == PSA_SUCCESS)
+		status = psa_crypto_init();
+
+	return status;
+}
+
+void stub_crypto_backend_deinit(void)
+{
+	psa_crypto_client_deinit();
+}
diff --git a/components/service/crypto/backend/stub/stub_crypto_backend.h b/components/service/crypto/backend/stub/stub_crypto_backend.h
new file mode 100644
index 0000000..8c0477e
--- /dev/null
+++ b/components/service/crypto/backend/stub/stub_crypto_backend.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef STUB_CRYPTO_BACKEND_H
+#define STUB_CRYPTO_BACKEND_H
+
+#include <psa/error.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Initialize the stub crypto backend
+ *
+ * Initializes a crypto backend that uses the psa API client with a
+ * stub backend caller to realize the PSA crypto API used by the crypto
+ * service proviser.
+ *
+ * \return PSA_SUCCESS if backend initialized successfully
+ */
+psa_status_t stub_crypto_backend_init(void);
+
+/**
+ * \brief Clean-up to free any resource used by the crypto backend
+ */
+void stub_crypto_backend_deinit(void);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* STUB_CRYPTO_BACKEND_H */