mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Add encryption -e option and flag encryption with a control flag, removing encrypt field.
This commit is contained in:
parent
65f901a83c
commit
202d972a6c
|
|
@ -48,6 +48,7 @@
|
||||||
#define LZO_TEST (control->flags & FLAG_THRESHOLD)
|
#define LZO_TEST (control->flags & FLAG_THRESHOLD)
|
||||||
#define TMP_OUTBUF (control->flags & FLAG_TMP_OUTBUF)
|
#define TMP_OUTBUF (control->flags & FLAG_TMP_OUTBUF)
|
||||||
#define TMP_INBUF (control->flags & FLAG_TMP_INBUF)
|
#define TMP_INBUF (control->flags & FLAG_TMP_INBUF)
|
||||||
|
#define ENCRYPT (control->flags & FLAG_ENCRYPT)
|
||||||
|
|
||||||
#define print_output(format, args...) do {\
|
#define print_output(format, args...) do {\
|
||||||
fprintf(control->msgout, format, ##args); \
|
fprintf(control->msgout, format, ##args); \
|
||||||
|
|
|
||||||
7
lrzip.c
7
lrzip.c
|
|
@ -74,7 +74,7 @@ static char *make_magic(rzip_control *control)
|
||||||
* crc is still stored for compatibility with 0.5 versions.
|
* crc is still stored for compatibility with 0.5 versions.
|
||||||
*/
|
*/
|
||||||
magic[21] = 1;
|
magic[21] = 1;
|
||||||
if (control->encrypt)
|
if (ENCRYPT)
|
||||||
magic[22] = 1;
|
magic[22] = 1;
|
||||||
|
|
||||||
memcpy(&magic[23], &control->salt, 16);
|
memcpy(&magic[23], &control->salt, 16);
|
||||||
|
|
@ -153,11 +153,12 @@ static i64 enc_loops(uchar b1, uchar b2)
|
||||||
static void get_magicver06(rzip_control *control, char *magic)
|
static void get_magicver06(rzip_control *control, char *magic)
|
||||||
{
|
{
|
||||||
if (magic[22] == 1)
|
if (magic[22] == 1)
|
||||||
control->encrypt = 1;
|
control->flags |= FLAG_ENCRYPT;
|
||||||
memcpy(control->salt, &magic[23], 16);
|
memcpy(control->salt, &magic[23], 16);
|
||||||
memcpy(&control->secs, control->salt, 5);
|
memcpy(&control->secs, control->salt, 5);
|
||||||
print_maxverbose("Storage time in seconds %lld\n", control->secs);
|
print_maxverbose("Storage time in seconds %lld\n", control->secs);
|
||||||
control->encloops = enc_loops(control->salt[5], control->salt[6]);
|
control->encloops = enc_loops(control->salt[5], control->salt[6]);
|
||||||
|
if (ENCRYPT)
|
||||||
print_maxverbose("Encryption hash loops %lld\n", control->encloops);
|
print_maxverbose("Encryption hash loops %lld\n", control->encloops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -791,6 +792,8 @@ next_chunk:
|
||||||
|
|
||||||
print_output("%s:\nlrzip version: %d.%d file\n", infilecopy, control->major_version, control->minor_version);
|
print_output("%s:\nlrzip version: %d.%d file\n", infilecopy, control->major_version, control->minor_version);
|
||||||
|
|
||||||
|
if (ENCRYPT)
|
||||||
|
print_output("Encrypted\n");
|
||||||
print_output("Compression: ");
|
print_output("Compression: ");
|
||||||
if (ctype == CTYPE_NONE)
|
if (ctype == CTYPE_NONE)
|
||||||
print_output("rzip alone\n");
|
print_output("rzip alone\n");
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,7 @@ typedef struct md5_ctx md5_ctx;
|
||||||
#define FLAG_THRESHOLD (1 << 20)
|
#define FLAG_THRESHOLD (1 << 20)
|
||||||
#define FLAG_TMP_OUTBUF (1 << 21)
|
#define FLAG_TMP_OUTBUF (1 << 21)
|
||||||
#define FLAG_TMP_INBUF (1 << 22)
|
#define FLAG_TMP_INBUF (1 << 22)
|
||||||
|
#define FLAG_ENCRYPT (1 << 23)
|
||||||
|
|
||||||
#define NO_MD5 (!(HASH_CHECK) && !(HAS_MD5))
|
#define NO_MD5 (!(HASH_CHECK) && !(HAS_MD5))
|
||||||
|
|
||||||
|
|
@ -191,7 +192,6 @@ struct rzip_control {
|
||||||
int fd_in;
|
int fd_in;
|
||||||
int fd_out;
|
int fd_out;
|
||||||
int fd_hist;
|
int fd_hist;
|
||||||
char encrypt;
|
|
||||||
i64 encloops;
|
i64 encloops;
|
||||||
uchar loop_byte1;
|
uchar loop_byte1;
|
||||||
uchar loop_byte2;
|
uchar loop_byte2;
|
||||||
|
|
|
||||||
8
main.c
8
main.c
|
|
@ -77,6 +77,7 @@
|
||||||
#define LZO_TEST (control.flags & FLAG_THRESHOLD)
|
#define LZO_TEST (control.flags & FLAG_THRESHOLD)
|
||||||
#define TMP_OUTBUF (control.flags & FLAG_TMP_OUTBUF)
|
#define TMP_OUTBUF (control.flags & FLAG_TMP_OUTBUF)
|
||||||
#define TMP_INBUF (control.flags & FLAG_TMP_INBUF)
|
#define TMP_INBUF (control.flags & FLAG_TMP_INBUF)
|
||||||
|
#define ENCRYPT (control.flags & FLAG_ENCRYPT)
|
||||||
|
|
||||||
#define print_output(format, args...) do {\
|
#define print_output(format, args...) do {\
|
||||||
fprintf(control.msgout, format, ##args); \
|
fprintf(control.msgout, format, ##args); \
|
||||||
|
|
@ -166,6 +167,7 @@ static void usage(void)
|
||||||
print_output("General options:\n");
|
print_output("General options:\n");
|
||||||
print_output(" -c check integrity of file written on decompression\n");
|
print_output(" -c check integrity of file written on decompression\n");
|
||||||
print_output(" -d decompress\n");
|
print_output(" -d decompress\n");
|
||||||
|
print_output(" -e password protected encryption on compression\n");
|
||||||
print_output(" -h|-? show help\n");
|
print_output(" -h|-? show help\n");
|
||||||
print_output(" -H display md5 hash integrity information\n");
|
print_output(" -H display md5 hash integrity information\n");
|
||||||
print_output(" -i show compressed file information\n");
|
print_output(" -i show compressed file information\n");
|
||||||
|
|
@ -268,6 +270,7 @@ static void show_summary(void)
|
||||||
print_verbose("Using Unlimited Window size\n");
|
print_verbose("Using Unlimited Window size\n");
|
||||||
}
|
}
|
||||||
print_maxverbose("Storage time in seconds %lld\n", control.secs);
|
print_maxverbose("Storage time in seconds %lld\n", control.secs);
|
||||||
|
if (ENCRYPT)
|
||||||
print_maxverbose("Encryption hash loops %lld\n", control.encloops);
|
print_maxverbose("Encryption hash loops %lld\n", control.encloops);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -515,7 +518,7 @@ int main(int argc, char *argv[])
|
||||||
else if (!strstr(eptr,"NOCONFIG"))
|
else if (!strstr(eptr,"NOCONFIG"))
|
||||||
read_config(&control);
|
read_config(&control);
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "L:h?dS:tVvDfqo:w:nlbUO:TN:p:gziHck")) != -1) {
|
while ((c = getopt(argc, argv, "bcdDefghHiklL:nN:o:O:p:qS:tTUvVw:z?")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'b':
|
case 'b':
|
||||||
if (control.flags & FLAG_NOT_LZMA)
|
if (control.flags & FLAG_NOT_LZMA)
|
||||||
|
|
@ -532,6 +535,9 @@ int main(int argc, char *argv[])
|
||||||
case 'D':
|
case 'D':
|
||||||
control.flags &= ~FLAG_KEEP_FILES;
|
control.flags &= ~FLAG_KEEP_FILES;
|
||||||
break;
|
break;
|
||||||
|
case 'e':
|
||||||
|
control.flags |= FLAG_ENCRYPT;
|
||||||
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
control.flags |= FLAG_FORCE_REPLACE;
|
control.flags |= FLAG_FORCE_REPLACE;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue