mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-16 08:42:50 +00:00
psasim: minor fixes to the core
- do not try to close a connection that was never started - fix data chunks length for psa_write (prevent memcpy-ing to large blocks of data) Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
parent
76ac620d70
commit
7fe75ba72d
@ -474,7 +474,7 @@ void psa_write(psa_handle_t msg_handle, uint32_t outvec_idx,
|
|||||||
|
|
||||||
while (sofar < num_bytes) {
|
while (sofar < num_bytes) {
|
||||||
size_t sending = (num_bytes - sofar);
|
size_t sending = (num_bytes - sofar);
|
||||||
if (sending >= MAX_FRAGMENT_SIZE) {
|
if (sending > (MAX_FRAGMENT_SIZE - (sizeof(size_t) * 2))) {
|
||||||
sending = MAX_FRAGMENT_SIZE - (sizeof(size_t) * 2);
|
sending = MAX_FRAGMENT_SIZE - (sizeof(size_t) * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ int psa_crypto_call(int function,
|
|||||||
invec.base = in_params;
|
invec.base = in_params;
|
||||||
invec.len = in_params_len;
|
invec.len = in_params_len;
|
||||||
|
|
||||||
size_t max_receive = 8192;
|
size_t max_receive = 24576;
|
||||||
uint8_t *receive = malloc(max_receive);
|
uint8_t *receive = malloc(max_receive);
|
||||||
if (receive == NULL) {
|
if (receive == NULL) {
|
||||||
fprintf(stderr, "FAILED to allocate %u bytes\n", (unsigned) max_receive);
|
fprintf(stderr, "FAILED to allocate %u bytes\n", (unsigned) max_receive);
|
||||||
@ -119,6 +119,11 @@ fail:
|
|||||||
|
|
||||||
void mbedtls_psa_crypto_free(void)
|
void mbedtls_psa_crypto_free(void)
|
||||||
{
|
{
|
||||||
|
/* Do not try to close a connection that was never started.*/
|
||||||
|
if (handle == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CLIENT_PRINT("Closing handle");
|
CLIENT_PRINT("Closing handle");
|
||||||
psa_close(handle);
|
psa_close(handle);
|
||||||
handle = -1;
|
handle = -1;
|
||||||
|
@ -349,7 +349,7 @@ int psa_crypto_call(int function,
|
|||||||
invec.base = in_params;
|
invec.base = in_params;
|
||||||
invec.len = in_params_len;
|
invec.len = in_params_len;
|
||||||
|
|
||||||
size_t max_receive = 8192;
|
size_t max_receive = 24576;
|
||||||
uint8_t *receive = malloc(max_receive);
|
uint8_t *receive = malloc(max_receive);
|
||||||
if (receive == NULL) {
|
if (receive == NULL) {
|
||||||
fprintf(stderr, "FAILED to allocate %u bytes\n", (unsigned) max_receive);
|
fprintf(stderr, "FAILED to allocate %u bytes\n", (unsigned) max_receive);
|
||||||
@ -424,6 +424,11 @@ fail:
|
|||||||
|
|
||||||
void mbedtls_psa_crypto_free(void)
|
void mbedtls_psa_crypto_free(void)
|
||||||
{
|
{
|
||||||
|
/* Do not try to close a connection that was never started.*/
|
||||||
|
if (handle == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CLIENT_PRINT("Closing handle");
|
CLIENT_PRINT("Closing handle");
|
||||||
psa_close(handle);
|
psa_close(handle);
|
||||||
handle = -1;
|
handle = -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user