mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-16 08:42:50 +00:00
Adapt import/export test for FFDH
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
parent
ed23b61020
commit
1d9c2b63d9
@ -1503,6 +1503,7 @@ void import_export(data_t *data,
|
|||||||
size_t reexported_length;
|
size_t reexported_length;
|
||||||
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||||
psa_key_attributes_t got_attributes = PSA_KEY_ATTRIBUTES_INIT;
|
psa_key_attributes_t got_attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||||
|
psa_status_t expected_import_result = PSA_SUCCESS;
|
||||||
|
|
||||||
export_size = (ptrdiff_t) data->len + export_size_delta;
|
export_size = (ptrdiff_t) data->len + export_size_delta;
|
||||||
ASSERT_ALLOC(exported, export_size);
|
ASSERT_ALLOC(exported, export_size);
|
||||||
@ -1516,8 +1517,24 @@ void import_export(data_t *data,
|
|||||||
psa_set_key_algorithm(&attributes, alg);
|
psa_set_key_algorithm(&attributes, alg);
|
||||||
psa_set_key_type(&attributes, type);
|
psa_set_key_type(&attributes, type);
|
||||||
|
|
||||||
|
if (PSA_KEY_TYPE_IS_DH(type) &&
|
||||||
|
expected_export_status == PSA_ERROR_BUFFER_TOO_SMALL) {
|
||||||
|
export_size -= 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PSA_KEY_TYPE_IS_DH(type) &&
|
||||||
|
(data->len != 256 && data->len != 384 &&
|
||||||
|
data->len != 512 && data->len != 768 && data->len != 1024)) {
|
||||||
|
expected_import_result = PSA_ERROR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
/* Import the key */
|
/* Import the key */
|
||||||
PSA_ASSERT(psa_import_key(&attributes, data->x, data->len, &key));
|
TEST_EQUAL(psa_import_key(&attributes, data->x, data->len, &key),
|
||||||
|
expected_import_result);
|
||||||
|
|
||||||
|
if (expected_import_result != PSA_SUCCESS) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
/* Test the key information */
|
/* Test the key information */
|
||||||
PSA_ASSERT(psa_get_key_attributes(key, &got_attributes));
|
PSA_ASSERT(psa_get_key_attributes(key, &got_attributes));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user