Valerio Setti 655b9793c0 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>
2024-05-10 05:22:23 +02:00

55 lines
1.2 KiB
C

/* psasim test client */
/*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/
#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__)
int main()
{
char mbedtls_version[18];
// psa_invec invecs[1];
// psa_outvec outvecs[1];
psa_status_t status;
mbedtls_version_get_string_full(mbedtls_version);
CLIENT_PRINT("%s", mbedtls_version);
CLIENT_PRINT("My PID: %d", getpid());
CLIENT_PRINT("PSA version: %u", psa_version(PSA_SID_SHA256_SID));
psa_handle_t h = psa_connect(PSA_SID_SHA256_SID, 1);
if (h < 0) {
CLIENT_PRINT("Couldn't connect %d", h);
return 1;
}
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;
}