apps/speed.c: detect evp cipher 32-bit ctr overflow and reset iv

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4846)
This commit is contained in:
Patrick Steuer 2017-12-05 13:10:11 +01:00 committed by Rich Salz
parent 40866074c2
commit 723a7c5af0

View file

@ -872,16 +872,23 @@ static int EVP_Update_loop(void *args)
loopargs_t *tempargs = *(loopargs_t **) args;
unsigned char *buf = tempargs->buf;
EVP_CIPHER_CTX *ctx = tempargs->ctx;
int outl, count;
int outl, count, rc;
#ifndef SIGALRM
int nb_iter = save_count * 4 * lengths[0] / lengths[testnum];
#endif
if (decrypt)
for (count = 0; COND(nb_iter); count++)
EVP_DecryptUpdate(ctx, buf, &outl, buf, lengths[testnum]);
else
for (count = 0; COND(nb_iter); count++)
EVP_EncryptUpdate(ctx, buf, &outl, buf, lengths[testnum]);
if (decrypt) {
for (count = 0; COND(nb_iter); count++) {
rc = EVP_DecryptUpdate(ctx, buf, &outl, buf, lengths[testnum]);
if (rc != 1)
EVP_CipherInit_ex(ctx, NULL, NULL, NULL, iv, -1);
}
} else {
for (count = 0; COND(nb_iter); count++) {
rc = EVP_EncryptUpdate(ctx, buf, &outl, buf, lengths[testnum]);
if (rc != 1)
EVP_CipherInit_ex(ctx, NULL, NULL, NULL, iv, -1);
}
}
if (decrypt)
EVP_DecryptFinal_ex(ctx, buf, &outl);
else