Add stubs for unsupported PSA Crypto API client operations
The psa-api-test/crypto deployment (formally called ts-arch-test)
is modified to use PSA API client methods instead of MbedTLS
directly. This change is the first step to adding missing
operations that the PSA arch tests exercise.
Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I6179c389d3176e649290e373ddfa9d9f8974770c
diff --git a/deployments/psa-api-test/crypto/crypto_locator.c b/deployments/psa-api-test/crypto/crypto_locator.c
new file mode 100644
index 0000000..8571b23
--- /dev/null
+++ b/deployments/psa-api-test/crypto/crypto_locator.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <stddef.h>
+#include <service_locator.h>
+#include <service/crypto/client/psa/psa_crypto_client.h>
+#include <protocols/rpc/common/packed-c/encoding.h>
+#include "../service_under_test.h"
+
+/* RPC context */
+static rpc_session_handle session_handle = NULL;
+static struct service_context *crypto_service_context = NULL;
+
+
+int locate_service_under_test(void)
+{
+ int status = -1;
+
+ if (!session_handle && !crypto_service_context) {
+
+ struct rpc_caller *caller;
+
+ crypto_service_context =
+ service_locator_query("sn:trustedfirmware.org:crypto:0", &status);
+
+ if (crypto_service_context) {
+
+ session_handle =
+ service_context_open(crypto_service_context, TS_RPC_ENCODING_PACKED_C, &caller);
+
+ if (session_handle) {
+
+ psa_crypto_client_init(caller);
+ status = 0;
+ }
+ else {
+
+ status = -1;
+ relinquish_service_under_test();
+ }
+ }
+ }
+
+ return status;
+}
+
+void relinquish_service_under_test(void)
+{
+ psa_crypto_client_deinit();
+
+ if (crypto_service_context && session_handle) {
+
+ service_context_close(crypto_service_context, session_handle);
+ session_handle = NULL;
+ }
+
+ if (crypto_service_context) {
+
+ service_context_relinquish(crypto_service_context);
+ crypto_service_context = NULL;
+ }
+}