diff --git a/include/psa/crypto_sizes.h b/include/psa/crypto_sizes.h index 37f72054f7..6b8ccbb9a4 100644 --- a/include/psa/crypto_sizes.h +++ b/include/psa/crypto_sizes.h @@ -253,6 +253,10 @@ * curve. */ #define PSA_TLS12_ECJPAKE_TO_PMS_DATA_SIZE 32 +/* The maximum number of iterations for PBKDF2 on this implementation, in bits. + * This is a vendor-specific macro. This can be configured if necessary */ +#define PSA_VENDOR_PBKDF2_MAX_ITERATIONS 0xffffffff + /** The maximum size of a block cipher. */ #define PSA_BLOCK_CIPHER_BLOCK_MAX_SIZE 16 diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 4615920055..a8ccde56f2 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -6419,13 +6419,14 @@ static psa_status_t psa_pbkdf2_set_input_cost( return PSA_ERROR_BAD_STATE; } - if (data > 0xFFFFFFFF) { + if (data > PSA_VENDOR_PBKDF2_MAX_ITERATIONS) { return PSA_ERROR_NOT_SUPPORTED; } if (data == 0) { return PSA_ERROR_INVALID_ARGUMENT; } + pbkdf2->input_cost = data; pbkdf2->state = PSA_PBKDF2_STATE_INPUT_COST_SET;