Limit the number of PBKDF2 iterations when fuzzing.
(Otherwise the fuzzer will discover that it can trigger extremely large amounts of computation and start timing out.) BUG=oss-fuzz:9767 Change-Id: Ibc1da5a90da169c7caf522f792530d1020f8cb54 Reviewed-on: https://boringssl-review.googlesource.com/30404 Commit-Queue: David Benjamin <davidben@google.com> Reviewed-by: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
This commit is contained in:
parent
6410e18e91
commit
2bcb315138
@ -669,11 +669,17 @@ int PKCS12_get_key_and_certs(EVP_PKEY **out_key, STACK_OF(X509) *out_certs,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(BORINGSSL_UNSAFE_FUZZER_MODE)
|
||||||
|
static const uint64_t kIterationsLimit = 1024;
|
||||||
|
#else
|
||||||
|
static const uint64_t kIterationsLimit = UINT_MAX;
|
||||||
|
#endif
|
||||||
|
|
||||||
// The iteration count is optional and the default is one.
|
// The iteration count is optional and the default is one.
|
||||||
uint64_t iterations = 1;
|
uint64_t iterations = 1;
|
||||||
if (CBS_len(&mac_data) > 0) {
|
if (CBS_len(&mac_data) > 0) {
|
||||||
if (!CBS_get_asn1_uint64(&mac_data, &iterations) ||
|
if (!CBS_get_asn1_uint64(&mac_data, &iterations) ||
|
||||||
iterations > UINT_MAX) {
|
iterations > kIterationsLimit) {
|
||||||
OPENSSL_PUT_ERROR(PKCS8, PKCS8_R_BAD_PKCS12_DATA);
|
OPENSSL_PUT_ERROR(PKCS8, PKCS8_R_BAD_PKCS12_DATA);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user