speed: Always reset the outlen when calling EVP_PKEY_derive
Fixes
@@ -880,11 +880,14 @@ static int FFDH_derive_key_loop(void *args)
loopargs_t *tempargs = *(loopargs_t **) args;
EVP_PKEY_CTX *ffdh_ctx = tempargs->ffdh_ctx[testnum];
unsigned char *derived_secret = tempargs->secret_ff_a;
- size_t outlen = MAX_FFDH_SIZE;
int count;
- for (count = 0; COND(ffdh_c[testnum][0]); count++)
+ for (count = 0; COND(ffdh_c[testnum][0]); count++) {
+ /* outlen can be overwritten with a too small value (no padding used) */
+ size_t outlen = MAX_FFDH_SIZE;
+
EVP_PKEY_derive(ffdh_ctx, derived_secret, &outlen);
+ }
return count;
}
#endif /* OPENSSL_NO_DH */
