speed.c: Check block size before running EVP_Cipher_loop()
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/25792)
(cherry picked from commit a3660729e6
)
This commit is contained in:
parent
d0effc3705
commit
2003b1855c
1 changed files with 23 additions and 0 deletions
23
apps/speed.c
23
apps/speed.c
|
@ -1408,6 +1408,19 @@ static int SIG_verify_loop(void *args)
|
|||
return count;
|
||||
}
|
||||
|
||||
static int check_block_size(EVP_CIPHER_CTX *ctx, int length)
|
||||
{
|
||||
const EVP_CIPHER *ciph = EVP_CIPHER_CTX_get0_cipher(ctx);
|
||||
|
||||
if (length % EVP_CIPHER_get_block_size(ciph) != 0) {
|
||||
BIO_printf(bio_err,
|
||||
"\nRequested encryption length not a multiple of block size for %s!\n",
|
||||
EVP_CIPHER_get0_name(ciph));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int run_benchmark(int async_jobs,
|
||||
int (*loop_function) (void *), loopargs_t *loopargs)
|
||||
{
|
||||
|
@ -2614,6 +2627,8 @@ int speed_main(int argc, char **argv)
|
|||
}
|
||||
algindex = D_CBC_DES;
|
||||
for (testnum = 0; st && testnum < size_num; testnum++) {
|
||||
if (!check_block_size(loopargs[0].ctx, lengths[testnum]))
|
||||
break;
|
||||
print_message(names[D_CBC_DES], lengths[testnum], seconds.sym);
|
||||
Time_F(START);
|
||||
count = run_benchmark(async_jobs, EVP_Cipher_loop, loopargs);
|
||||
|
@ -2634,6 +2649,8 @@ int speed_main(int argc, char **argv)
|
|||
}
|
||||
algindex = D_EDE3_DES;
|
||||
for (testnum = 0; st && testnum < size_num; testnum++) {
|
||||
if (!check_block_size(loopargs[0].ctx, lengths[testnum]))
|
||||
break;
|
||||
print_message(names[D_EDE3_DES], lengths[testnum], seconds.sym);
|
||||
Time_F(START);
|
||||
count =
|
||||
|
@ -2658,6 +2675,8 @@ int speed_main(int argc, char **argv)
|
|||
}
|
||||
|
||||
for (testnum = 0; st && testnum < size_num; testnum++) {
|
||||
if (!check_block_size(loopargs[0].ctx, lengths[testnum]))
|
||||
break;
|
||||
print_message(names[algindex], lengths[testnum], seconds.sym);
|
||||
Time_F(START);
|
||||
count =
|
||||
|
@ -2683,6 +2702,8 @@ int speed_main(int argc, char **argv)
|
|||
}
|
||||
|
||||
for (testnum = 0; st && testnum < size_num; testnum++) {
|
||||
if (!check_block_size(loopargs[0].ctx, lengths[testnum]))
|
||||
break;
|
||||
print_message(names[algindex], lengths[testnum], seconds.sym);
|
||||
Time_F(START);
|
||||
count =
|
||||
|
@ -2707,6 +2728,8 @@ int speed_main(int argc, char **argv)
|
|||
}
|
||||
|
||||
for (testnum = 0; st && testnum < size_num; testnum++) {
|
||||
if (!check_block_size(loopargs[0].ctx, lengths[testnum]))
|
||||
break;
|
||||
print_message(names[algindex], lengths[testnum], seconds.sym);
|
||||
Time_F(START);
|
||||
count =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue