diff --git a/library/psa_crypto.c b/library/psa_crypto.c index ddc834f95c..36c5f75665 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -4346,6 +4346,20 @@ psa_status_t psa_cipher_encrypt(mbedtls_svc_key_id_t key, size_t default_iv_length = 0; psa_key_attributes_t attributes; + psa_crypto_local_input_t local_input = PSA_CRYPTO_LOCAL_INPUT_INIT; + status = psa_crypto_local_input_alloc(input, input_length, &local_input); + if (status != PSA_SUCCESS) { + goto exit; + } + input = local_input.buffer; + + psa_crypto_local_output_t local_output = PSA_CRYPTO_LOCAL_OUTPUT_INIT; + status = psa_crypto_local_output_alloc(output, output_size, &local_output); + if (status != PSA_SUCCESS) { + goto exit; + } + output = local_output.buffer; + if (!PSA_ALG_IS_CIPHER(alg)) { status = PSA_ERROR_INVALID_ARGUMENT; goto exit; @@ -4401,6 +4415,9 @@ exit: *output_length = 0; } + psa_crypto_local_input_free(&local_input); + psa_crypto_local_output_free(&local_output); + return status; }