mirror of
https://github.com/cuberite/polarssl.git
synced 2025-10-03 10:34:16 -04:00
Merge pull request #9280 from valeriosetti/psasim-reset-slots-on-disconnection
psasim-server: add function to reset operations slots
This commit is contained in:
commit
150b88c9d2
@ -2314,3 +2314,8 @@ psa_status_t psa_crypto_call(psa_msg_t msg)
|
|||||||
|
|
||||||
return ok ? PSA_SUCCESS : PSA_ERROR_GENERIC_ERROR;
|
return ok ? PSA_SUCCESS : PSA_ERROR_GENERIC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void psa_crypto_close(void)
|
||||||
|
{
|
||||||
|
psa_sim_serialize_reset();
|
||||||
|
}
|
||||||
|
@ -242,6 +242,16 @@ EOF
|
|||||||
|
|
||||||
return ok ? PSA_SUCCESS : PSA_ERROR_GENERIC_ERROR;
|
return ok ? PSA_SUCCESS : PSA_ERROR_GENERIC_ERROR;
|
||||||
}
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Finally, add psa_crypto_close()
|
||||||
|
|
||||||
|
print $fh <<EOF;
|
||||||
|
|
||||||
|
void psa_crypto_close(void)
|
||||||
|
{
|
||||||
|
psa_sim_serialize_reset();
|
||||||
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
close($fh);
|
close($fh);
|
||||||
|
@ -713,3 +713,11 @@ int psasim_deserialise_mbedtls_svc_key_id_t(uint8_t **pos,
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
@ -54,6 +54,12 @@
|
|||||||
* don't contain pointers.
|
* 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 how much buffer space is needed by \c psasim_serialise_begin().
|
||||||
*
|
*
|
||||||
* \return The number of bytes needed in the buffer for
|
* \return The number of bytes needed in the buffer for
|
||||||
|
@ -105,6 +105,7 @@ if ($which eq "h") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print define_server_serialize_reset(@types);
|
||||||
} else {
|
} else {
|
||||||
die("internal error - shouldn't happen");
|
die("internal error - shouldn't happen");
|
||||||
}
|
}
|
||||||
@ -329,6 +330,12 @@ sub h_header
|
|||||||
* don't contain pointers.
|
* 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 how much buffer space is needed by \c psasim_serialise_begin().
|
||||||
*
|
*
|
||||||
* \return The number of bytes needed in the buffer for
|
* \return The number of bytes needed in the buffer for
|
||||||
@ -913,6 +920,33 @@ int psasim_deserialise_begin(uint8_t **pos, size_t *remaining)
|
|||||||
EOF
|
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
|
# 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)
|
# appease uncrustify (these are the 2nd-4th lines of code, indices 1, 2 and 3)
|
||||||
#
|
#
|
||||||
|
@ -54,6 +54,7 @@ int psa_server_main(int argc, char *argv[])
|
|||||||
int client_disconnected = 0;
|
int client_disconnected = 0;
|
||||||
char mbedtls_version[18];
|
char mbedtls_version[18];
|
||||||
extern psa_status_t psa_crypto_call(psa_msg_t msg);
|
extern psa_status_t psa_crypto_call(psa_msg_t msg);
|
||||||
|
extern psa_status_t psa_crypto_close(void);
|
||||||
|
|
||||||
mbedtls_version_get_string_full(mbedtls_version);
|
mbedtls_version_get_string_full(mbedtls_version);
|
||||||
SERVER_PRINT("%s", mbedtls_version);
|
SERVER_PRINT("%s", mbedtls_version);
|
||||||
@ -81,6 +82,7 @@ int psa_server_main(int argc, char *argv[])
|
|||||||
SERVER_PRINT("Got a disconnection message");
|
SERVER_PRINT("Got a disconnection message");
|
||||||
ret = PSA_SUCCESS;
|
ret = PSA_SUCCESS;
|
||||||
client_disconnected = 1;
|
client_disconnected = 1;
|
||||||
|
psa_crypto_close();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SERVER_PRINT("Got an IPC call of type %d", msg.type);
|
SERVER_PRINT("Got an IPC call of type %d", msg.type);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user