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 7a5881e74..4ec7ec04f 100644 --- a/tests/psa-client-server/psasim/src/psa_sim_serialise.h +++ b/tests/psa-client-server/psasim/src/psa_sim_serialise.h @@ -409,12 +409,44 @@ int psasim_deserialise_psa_hash_operation_t(uint8_t **pos, size_t *remaining, psa_hash_operation_t *value); -size_t psasim_server_serialise_psa_hash_operation_t_needs(psa_hash_operation_t *operation); +/** Return how much buffer space is needed by \c psasim_server_serialise_psa_hash_operation_t() + * to serialise a `psa_hash_operation_t`. + * + * \param value The value that will be serialised into the buffer + * (needed in case some serialisations are value- + * dependent). + * + * \return The number of bytes needed in the buffer by + * \c psasim_serialise_psa_hash_operation_t() to serialise + * the given value. + */ +size_t psasim_server_serialise_psa_hash_operation_t_needs(psa_hash_operation_t *value); +/** Serialise a `psa_hash_operation_t` into a buffer on the server side. + * + * \param pos[in,out] Pointer to a `uint8_t *` holding current position + * in the buffer. + * \param remaining[in,out] Pointer to a `size_t` holding number of bytes + * remaining in the buffer. + * \param value The value to serialise into the buffer. + * + * \return \c 1 on success ("okay"), \c 0 on error. + */ int psasim_server_serialise_psa_hash_operation_t(uint8_t **pos, size_t *remaining, - psa_hash_operation_t *operation); + psa_hash_operation_t *value); +/** Deserialise a `psa_hash_operation_t` from a buffer on the server side. + * + * \param pos[in,out] Pointer to a `uint8_t *` holding current position + * in the buffer. + * \param remaining[in,out] Pointer to a `size_t` holding number of bytes + * remaining in the buffer. + * \param value Pointer to a `psa_hash_operation_t` to receive the value + * deserialised from the buffer. + * + * \return \c 1 on success ("okay"), \c 0 on error. + */ int psasim_server_deserialise_psa_hash_operation_t(uint8_t **pos, size_t *remaining, - psa_hash_operation_t **operation); + psa_hash_operation_t **value); 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 5161db1f6..21bfec52b 100755 --- a/tests/psa-client-server/psasim/src/psa_sim_serialise.pl +++ b/tests/psa-client-server/psasim/src/psa_sim_serialise.pl @@ -55,9 +55,15 @@ if ($which eq "h") { if ($type eq "buffer") { print declare_buffer_functions(); } else { - print declare_needs($type); - print declare_serialise($type); - print declare_deserialise($type); + print declare_needs($type, ""); + print declare_serialise($type, ""); + print declare_deserialise($type, ""); + + if ($type =~ /^psa_\w+_operation_t$/) { + print declare_needs($type, "server_"); + print declare_serialise($type, "server_"); + print declare_deserialise($type, "server_"); + } } } @@ -85,15 +91,17 @@ if ($which eq "h") { sub declare_needs { - my ($type) = @_; + my ($type, $server) = @_; my $an = ($type =~ /^[ui]/) ? "an" : "a"; my $type_d = $type; $type_d =~ s/ /_/g; + my $ptr = (length($server)) ? "*" : ""; + return <