diff options
author | Tomas Mraz <tomas@openssl.org> | 2024-10-24 16:06:32 +0200 |
---|---|---|
committer | Todd Short <todd.short@me.com> | 2024-10-28 20:53:31 +0100 |
commit | a3660729e68dc11c01edb4a349ff2610b6b59ee0 (patch) | |
tree | 9f22006aea1e7aa3acf0b20883c0f9868a731956 /apps/speed.c | |
parent | test_speed: Explicitly test the crashing command line on sparc (diff) | |
download | openssl-a3660729e68dc11c01edb4a349ff2610b6b59ee0.tar.xz openssl-a3660729e68dc11c01edb4a349ff2610b6b59ee0.zip |
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)
Diffstat (limited to '')
-rw-r--r-- | apps/speed.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/apps/speed.c b/apps/speed.c index c9137995cd..a6da71fe6d 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -1445,6 +1445,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) { @@ -2665,6 +2678,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); @@ -2685,6 +2700,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 = @@ -2709,6 +2726,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 = @@ -2734,6 +2753,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 = @@ -2758,6 +2779,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 = |