crypto-client test: implement the first IPC call for psa_crypto_init()
This commit implements the first useful IPC communication between
the client and the server. The implemented command is simple,
psa_crypto_init(), and its return value is sent back to the client.
Note: the newly added file psa_functions_codes.h is temporary
and it's probably the one that needs to be automatically
generated by a python script to support all crypto functions.
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
diff --git a/tests/psa-client-server/psasim/test/client.c b/tests/psa-client-server/psasim/test/client.c
index 3c61120..74e7bcb 100644
--- a/tests/psa-client-server/psasim/test/client.c
+++ b/tests/psa-client-server/psasim/test/client.c
@@ -8,11 +8,15 @@
#include <stdio.h>
#include <unistd.h>
+/* Includes from psasim */
#include <psa/client.h>
#include <psa/util.h>
#include "psa_manifest/sid.h"
+#include "psa_functions_codes.h"
+/* Includes from mbedtls */
#include "mbedtls/version.h"
+#include "psa/crypto.h"
#define CLIENT_PRINT(fmt, ...) \
PRINT("Client: " fmt, ##__VA_ARGS__)
@@ -20,8 +24,9 @@
int main()
{
char mbedtls_version[18];
- const char *text = "FOOBARCOOL!!";
- char output[100] = { 0 };
+ // psa_invec invecs[1];
+ // psa_outvec outvecs[1];
+ psa_status_t status;
mbedtls_version_get_string_full(mbedtls_version);
CLIENT_PRINT("%s", mbedtls_version);
@@ -34,23 +39,16 @@
if (h < 0) {
CLIENT_PRINT("Couldn't connect %d", h);
return 1;
- } else {
- int type = 2;
- CLIENT_PRINT("psa_call() w/o invec returned: %d", psa_call(h, type, NULL, 0, NULL, 0));
- psa_invec invecs[1];
- psa_outvec outvecs[1];
- invecs[0].base = text;
- invecs[0].len = sizeof(text);
- outvecs[0].base = output;
- outvecs[0].len = sizeof(output);
-
- CLIENT_PRINT("invec len: %lu", invecs[0].len);
- CLIENT_PRINT("psa_call() w/ invec returned: %d", psa_call(h, type, invecs, 1, outvecs, 1));
- CLIENT_PRINT("Received payload len: %ld", outvecs[0].len);
- CLIENT_PRINT("Received payload content: %s", output);
- CLIENT_PRINT("Closing handle");
- psa_close(h);
}
+ status = psa_call(h, PSA_CRYPTO_INIT, NULL, 0, NULL, 0);
+ CLIENT_PRINT("PSA_CRYPTO_INIT returned: %d", status);
+
+ CLIENT_PRINT("Closing handle");
+ psa_close(h);
+
+ if (status != PSA_SUCCESS) {
+ return 1;
+ }
return 0;
}