mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-25 13:43:31 +00:00
crypto-client test: ensure that client/server are linked against proper MbedTLS libraries
Ensure that both server and client can call mbedtls_version_get_string_full() to verify that they are linked against proper libraries. Note: each side (client/server) performs the call against its own MbedTLS library. There is no IPC communication involved in this test. Client/server communication will come later. Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
parent
d1b6ef1959
commit
4362aaef7f
@ -1,4 +1,4 @@
|
||||
CFLAGS ?= -Wall -Werror -std=c99 -D_XOPEN_SOURCE=1 -D_POSIX_C_SOURCE=200809L
|
||||
CFLAGS += -Wall -Werror -std=c99 -D_XOPEN_SOURCE=1 -D_POSIX_C_SOURCE=200809L
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
CFLAGS += -DDEBUG -O0 -g
|
||||
@ -9,10 +9,10 @@ endif
|
||||
all: lib test
|
||||
|
||||
lib:
|
||||
$(MAKE) -C src CFLAGS="$(CFLAGS)"
|
||||
$(MAKE) -C src CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
|
||||
|
||||
test: lib
|
||||
$(MAKE) -C test CFLAGS="$(CFLAGS)"
|
||||
$(MAKE) -C test CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
|
||||
|
||||
clean:
|
||||
rm -f $(PSA_LIB) $(PSA_LIB_OBJS)
|
||||
|
@ -1,5 +1,16 @@
|
||||
INCLUDE := -I../include/ -I./psa_manifest
|
||||
LIB := -L../src -lpsaff
|
||||
LIBPSASIM_PATH := ..
|
||||
LIBPSACLIENT_PATH := ../../../libpsaclient
|
||||
LIBPSASERVER_PATH := ../../../libpsaserver
|
||||
|
||||
LIBPSASIM := -L$(LIBPSASIM_PATH)/src -lpsaff
|
||||
LIBPSACLIENT := -L$(LIBPSACLIENT_PATH)/library -lmbedcrypto -lmbedx509 -lmbedtls
|
||||
LIBPSASERVER := -L$(LIBPSASERVER_PATH)/library -lmbedcrypto
|
||||
|
||||
LIBPSASIM_H := -I$(LIBPSASIM_PATH)/include
|
||||
LIBPSACLIENT_H := -I$(LIBPSACLIENT_PATH)/include
|
||||
LIBPSASERVER_H := -I$(LIBPSASERVER_PATH)/include
|
||||
|
||||
COMMON_INCLUDE := $(LIBPSASIM_H) -I./psa_manifest
|
||||
|
||||
TEST_BIN = psa_client \
|
||||
psa_partition
|
||||
@ -15,10 +26,10 @@ PARTITION_SERVER_BOOTSTRAP = psa_ff_bootstrap_TEST_PARTITION.c
|
||||
all: $(TEST_BIN)
|
||||
|
||||
psa_client: client.c $(GENERATED_H_FILES)
|
||||
$(CC) $(INCLUDE) $(CFLAGS) $< $(LIB) -o $@
|
||||
$(CC) $(COMMON_INCLUDE) $(LIBPSACLIENT_H) $(CFLAGS) $< $(LIBPSASIM) $(LIBPSACLIENT) -o $@
|
||||
|
||||
psa_partition: $(PARTITION_SERVER_BOOTSTRAP) $(GENERATED_H_FILES)
|
||||
$(CC) $(INCLUDE) $(CFLAGS) $< $(LIB) -o $@
|
||||
$(CC) $(COMMON_INCLUDE) $(LIBPSASERVER_H) $(CFLAGS) $< $(LIBPSASIM) $(LIBPSASERVER) -o $@
|
||||
|
||||
$(PARTITION_SERVER_BOOTSTRAP) $(GENERATED_H_FILES): manifest.json server.c
|
||||
../tools/psa_autogen.py $<
|
||||
|
@ -5,19 +5,27 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <psa/client.h>
|
||||
#include <psa/util.h>
|
||||
#include "psa_manifest/sid.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mbedtls/version.h"
|
||||
|
||||
#define CLIENT_PRINT(fmt, ...) \
|
||||
PRINT("Client: " fmt, ##__VA_ARGS__)
|
||||
|
||||
int main()
|
||||
{
|
||||
char mbedtls_version[18];
|
||||
const char *text = "FOOBARCOOL!!";
|
||||
char output[100] = { 0 };
|
||||
|
||||
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));
|
||||
|
@ -27,8 +27,8 @@ function wait_for_server_startup() {
|
||||
|
||||
clean_run
|
||||
|
||||
./psa_partition -k &
|
||||
./psa_partition -k > psa_partition.log 2>&1 &
|
||||
SERV_PID=$!
|
||||
wait_for_server_startup
|
||||
./psa_client
|
||||
./psa_client > psa_client.log 2>&1
|
||||
wait $SERV_PID
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include "psa/util.h"
|
||||
#include "psa_manifest/manifest.h"
|
||||
|
||||
#include "mbedtls/version.h"
|
||||
|
||||
#define SERVER_PRINT(fmt, ...) \
|
||||
PRINT("Server: " fmt, ##__VA_ARGS__)
|
||||
|
||||
@ -43,6 +45,10 @@ int psa_sha256_main(int argc, char *argv[])
|
||||
char foo[BUF_SIZE] = { 0 };
|
||||
const int magic_num = 66;
|
||||
int client_disconnected = 0;
|
||||
char mbedtls_version[18];
|
||||
|
||||
mbedtls_version_get_string_full(mbedtls_version);
|
||||
SERVER_PRINT("%s", mbedtls_version);
|
||||
|
||||
parse_input_args(argc, argv);
|
||||
SERVER_PRINT("Starting");
|
||||
|
@ -6210,7 +6210,7 @@ component_test_psasim() {
|
||||
helper_crypto_client_build server
|
||||
|
||||
msg "build psasim"
|
||||
make -C tests/psa-client-server/psasim
|
||||
make -C tests/psa-client-server/psasim CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS"
|
||||
|
||||
msg "test psasim"
|
||||
make -C tests/psa-client-server/psasim run
|
||||
|
Loading…
x
Reference in New Issue
Block a user