mirror of
https://github.com/ckolivas/lrzip.git
synced 2026-01-01 22:29:55 +01:00
Convert the usecs field to a dedicated salt one which has 6 random bytes and 2 encoded loops bytes.
This commit is contained in:
parent
0ffa041f36
commit
6a903eff8d
10
lrzip.c
10
lrzip.c
|
|
@ -112,9 +112,13 @@ static char *make_magic(rzip_control *control)
|
|||
if (unlikely(gettimeofday(&tv, NULL)))
|
||||
fatal("Failed to gettimeofday in write_magic\n");
|
||||
control->secs = tv.tv_sec;
|
||||
control->usecs = tv.tv_usec;
|
||||
/* The first 6 bytes of the salt is random data. The last 2 bytes
|
||||
* encode how many times to hash the password */
|
||||
get_rand(control->salt, 6);
|
||||
control->encloops = nloops(control->secs, control->salt + 6, control->salt + 7);
|
||||
|
||||
memcpy(&magic[23], &control->secs, 8);
|
||||
memcpy(&magic[31], &control->usecs, 8);
|
||||
memcpy(&magic[31], &control->salt, 8);
|
||||
|
||||
return magic;
|
||||
}
|
||||
|
|
@ -187,7 +191,7 @@ static void get_magicver06(rzip_control *control, char *magic)
|
|||
if (magic[22] == 1)
|
||||
control->encrypt = 1;
|
||||
memcpy(&control->secs, &magic[23], 8);
|
||||
memcpy(&control->usecs, &magic[31], 8);
|
||||
memcpy(&control->salt, &magic[31], 8);
|
||||
print_maxverbose("Seconds %lld\n", control->secs);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ struct rzip_control {
|
|||
uchar loop_byte1;
|
||||
uchar loop_byte2;
|
||||
i64 secs;
|
||||
i64 usecs;
|
||||
uchar salt[8];
|
||||
unsigned char eof;
|
||||
unsigned char magic_written;
|
||||
md5_ctx ctx;
|
||||
|
|
|
|||
Loading…
Reference in a new issue