aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTom Cosgrove <tom.cosgrove@arm.com>2024-06-18 12:32:57 +0100
committerTom Cosgrove <tom.cosgrove@arm.com>2024-06-18 12:32:57 +0100
commit24688968577c9889d8db0ec894f2c4f034f6127b (patch)
treeea411937babdb0ca8804fa0e59b287919489be5e /tests
parentaaf7e859a4bd6fdc2ed1bfa6d98430f1438bc798 (diff)
downloadmbedtls-24688968577c9889d8db0ec894f2c4f034f6127b.zip
mbedtls-24688968577c9889d8db0ec894f2c4f034f6127b.tar.gz
mbedtls-24688968577c9889d8db0ec894f2c4f034f6127b.tar.bz2
Have psa_sim_serialise.pl generate psa_sim_serialize_reset()
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/psa-client-server/psasim/src/psa_sim_serialise.c2
-rw-r--r--tests/psa-client-server/psasim/src/psa_sim_serialise.h4
-rwxr-xr-xtests/psa-client-server/psasim/src/psa_sim_serialise.pl34
3 files changed, 40 insertions, 0 deletions
diff --git a/tests/psa-client-server/psasim/src/psa_sim_serialise.c b/tests/psa-client-server/psasim/src/psa_sim_serialise.c
index e326637..f51133c 100644
--- a/tests/psa-client-server/psasim/src/psa_sim_serialise.c
+++ b/tests/psa-client-server/psasim/src/psa_sim_serialise.c
@@ -711,4 +711,6 @@ void psa_sim_serialize_reset(void)
{
memset(hash_operation_handles, 0, sizeof(hash_operation_handles));
memset(hash_operations, 0, sizeof(hash_operations));
+ memset(aead_operation_handles, 0, sizeof(aead_operation_handles));
+ memset(aead_operations, 0, sizeof(aead_operations));
}
diff --git a/tests/psa-client-server/psasim/src/psa_sim_serialise.h b/tests/psa-client-server/psasim/src/psa_sim_serialise.h
index 7217595..537730c 100644
--- a/tests/psa-client-server/psasim/src/psa_sim_serialise.h
+++ b/tests/psa-client-server/psasim/src/psa_sim_serialise.h
@@ -54,6 +54,10 @@
* don't contain pointers.
*/
+/** Reset all operation slots.
+ *
+ * Should be called when all clients have disconnected.
+ */
void psa_sim_serialize_reset(void);
/** Return how much buffer space is needed by \c psasim_serialise_begin().
diff --git a/tests/psa-client-server/psasim/src/psa_sim_serialise.pl b/tests/psa-client-server/psasim/src/psa_sim_serialise.pl
index e09bb81..bbd946f 100755
--- a/tests/psa-client-server/psasim/src/psa_sim_serialise.pl
+++ b/tests/psa-client-server/psasim/src/psa_sim_serialise.pl
@@ -105,6 +105,7 @@ if ($which eq "h") {
}
}
+ print define_server_serialize_reset(@types);
} else {
die("internal error - shouldn't happen");
}
@@ -329,6 +330,12 @@ sub h_header
* don't contain pointers.
*/
+/** Reset all operation slots.
+ *
+ * Should be called when all clients have disconnected.
+ */
+void psa_sim_serialize_reset(void);
+
/** Return how much buffer space is needed by \c psasim_serialise_begin().
*
* \return The number of bytes needed in the buffer for
@@ -907,6 +914,33 @@ int psasim_deserialise_begin(uint8_t **pos, size_t *remaining)
EOF
}
+# Return the code for psa_sim_serialize_reset()
+sub define_server_serialize_reset
+{
+ my @types = @_;
+
+ my $code = <<EOF;
+
+void psa_sim_serialize_reset(void)
+{
+EOF
+
+ for my $type (@types) {
+ next unless $type =~ /^psa_(\w+_operation)_t$/;
+
+ my $what = $1; # e.g. "hash_operation"
+
+ $code .= <<EOF;
+ memset(${what}_handles, 0, sizeof(${what}_handles));
+ memset(${what}s, 0, sizeof(${what}s));
+EOF
+ }
+
+ $code .= <<EOF;
+}
+EOF
+}
+
# Horrible way to align first, second and third lines of function signature to
# appease uncrustify (these are the 2nd-4th lines of code, indices 1, 2 and 3)
#