Only check current clock() on every 32-th cycle, in order to limit the overhead.
This commit is contained in:
parent
73f2e71342
commit
163dee5e9d
@ -317,7 +317,8 @@ static int encrypt(const char* const passphrase, const CHR* const input_path, co
|
|||||||
goto clean_up;
|
goto clean_up;
|
||||||
}
|
}
|
||||||
|
|
||||||
clock_t clk_now, clk_update = clock();
|
unsigned refresh_cycles = 0U;
|
||||||
|
clock_t clk_update = clock();
|
||||||
uint64_t bytes_read = 0U;
|
uint64_t bytes_read = 0U;
|
||||||
uint8_t buffer[BUFFER_SIZE];
|
uint8_t buffer[BUFFER_SIZE];
|
||||||
|
|
||||||
@ -351,11 +352,15 @@ static int encrypt(const char* const passphrase, const CHR* const input_path, co
|
|||||||
{
|
{
|
||||||
break; /*EOF*/
|
break; /*EOF*/
|
||||||
}
|
}
|
||||||
if ((clk_now = clock()) - clk_update > UPDATE_INTERVAL)
|
if (!(++refresh_cycles & 0x1F))
|
||||||
{
|
{
|
||||||
FPRINTF(stderr, T("\b\b\b\b\b\b\b%5.1f%% "), (bytes_read / ((double)file_size)) * 100.0);
|
const clock_t clk_now = clock();
|
||||||
fflush(stderr);
|
if ((clk_now < clk_update) || (clk_now - clk_update > UPDATE_INTERVAL))
|
||||||
clk_update = clk_now;
|
{
|
||||||
|
FPRINTF(stderr, T("\b\b\b\b\b\b\b%5.1f%% "), (bytes_read / ((double)file_size)) * 100.0);
|
||||||
|
fflush(stderr);
|
||||||
|
clk_update = clk_now;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,9 +493,11 @@ static int decrypt(const char* const passphrase, const CHR* const input_path, co
|
|||||||
goto clean_up;
|
goto clean_up;
|
||||||
}
|
}
|
||||||
|
|
||||||
clock_t clk_now, clk_update = clock();
|
unsigned refresh_cycles = 0U;
|
||||||
|
clock_t clk_update = clock();
|
||||||
uint64_t bytes_read = sizeof(uint64_t);
|
uint64_t bytes_read = sizeof(uint64_t);
|
||||||
uint8_t buffer[BUFFER_SIZE];
|
uint8_t buffer[BUFFER_SIZE];
|
||||||
|
|
||||||
const uint64_t read_limit = round_down(file_size, sizeof(uint64_t)) - (2U * sizeof(uint64_t));
|
const uint64_t read_limit = round_down(file_size, sizeof(uint64_t)) - (2U * sizeof(uint64_t));
|
||||||
|
|
||||||
blake2s_t blake2s_state;
|
blake2s_t blake2s_state;
|
||||||
@ -523,11 +530,15 @@ static int decrypt(const char* const passphrase, const CHR* const input_path, co
|
|||||||
{
|
{
|
||||||
break; /*EOF*/
|
break; /*EOF*/
|
||||||
}
|
}
|
||||||
if ((clk_now = clock()) - clk_update > UPDATE_INTERVAL)
|
if (!(++refresh_cycles & 0x1F))
|
||||||
{
|
{
|
||||||
FPRINTF(stderr, T("\b\b\b\b\b\b\b%5.1f%% "), (bytes_read / ((double)read_limit)) * 100.0);
|
const clock_t clk_now = clock();
|
||||||
fflush(stderr);
|
if ((clk_now < clk_update) || (clk_now - clk_update > UPDATE_INTERVAL))
|
||||||
clk_update = clk_now;
|
{
|
||||||
|
FPRINTF(stderr, T("\b\b\b\b\b\b\b%5.1f%% "), (bytes_read / ((double)read_limit)) * 100.0);
|
||||||
|
fflush(stderr);
|
||||||
|
clk_update = clk_now;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,8 +242,7 @@ static int initialize_state(crypt_state_t* const crypt_state, const uint64_t non
|
|||||||
}
|
}
|
||||||
for (i = 0U; i < 256U; ++i)
|
for (i = 0U; i < 256U; ++i)
|
||||||
{
|
{
|
||||||
const size_t j = crypt_state->wheel_fwd[r][i];
|
crypt_state->wheel_bwd[255U - r][crypt_state->wheel_fwd[r][i]] = (uint8_t)i;
|
||||||
crypt_state->wheel_bwd[255U - r][j] = (uint8_t)i;
|
|
||||||
}
|
}
|
||||||
CHECK_ABORTED();
|
CHECK_ABORTED();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user