Commit 723a7c5a authored by Patrick Steuer's avatar Patrick Steuer Committed by Rich Salz
Browse files

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

parent 40866074
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
@@ -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