-C uses facilities of -x and -X

This commit is contained in:
TLINDEN
2015-07-22 07:59:28 +02:00
parent 362f7dff6b
commit 27a9a96ae4
13 changed files with 180 additions and 175 deletions

View File

@@ -363,16 +363,10 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec
void pcpchecksum(char **files, int filenum, char *key) {
int i;
byte *checksum = ucmalloc(crypto_generichash_BYTES_MAX);
byte *keyhash = NULL;
size_t hashlen = 0;
size_t keylen = 0;
if(key != NULL) {
keyhash = ucmalloc(crypto_generichash_BYTES);
crypto_generichash(keyhash, crypto_generichash_BYTES,
(byte *)key, strlen(key),
NULL, crypto_generichash_BYTES);
hashlen = crypto_generichash_BYTES;
}
if(key != NULL)
keylen = strlen(key);
for(i=0; i<filenum; i++) {
FILE *in;
@@ -387,7 +381,7 @@ void pcpchecksum(char **files, int filenum, char *key) {
}
}
Pcpstream *pin = ps_new_file(in);
if(pcp_checksum(ptx, pin, checksum, keyhash, hashlen) > 0) {
if(pcp_checksum(ptx, pin, checksum, (byte *)key, keylen) > 0) {
char *hex = _bin2hex(checksum, crypto_generichash_BYTES_MAX);
fprintf(stdout, "BLAKE2b (%s) = %s\n", files[i], hex);
free(hex);
@@ -397,7 +391,4 @@ void pcpchecksum(char **files, int filenum, char *key) {
}
free(checksum);
if(keyhash != NULL)
free(keyhash);
}

View File

@@ -114,7 +114,7 @@ int main (int argc, char **argv) {
{ "decrypt", no_argument, NULL, 'd' },
{ "anonymous", no_argument, NULL, 'A' },
{ "add-myself", no_argument, NULL, 'M' },
{ "checksum", optional_argument, NULL, 'C' },
{ "checksum", no_argument, NULL, 'C' },
/* encoding */
{ "z85-encode", no_argument, NULL, 'z' },
@@ -136,7 +136,7 @@ int main (int argc, char **argv) {
{ NULL, 0, NULL, 0 }
};
while ((opt = getopt_long(argc, argv, "klLV:vdehsO:i:I:pSPRtEx:DzaZr:gcmf:b1F:0KAMX:jC:",
while ((opt = getopt_long(argc, argv, "klLV:vdehsO:i:I:pSPRtEx:DzaZr:gcmf:b1F:0KAMX:jC",
longopts, NULL)) != -1) {
switch (opt) {
@@ -233,10 +233,6 @@ int main (int argc, char **argv) {
break;
case 'C':
mode += PCP_MODE_CHECKSUM;
if(strlen(optarg) > 0 && strncmp(optarg, "--", 3) > 0) {
xpass = smalloc(strlen(optarg)+1);
strncpy(xpass, optarg, strlen(optarg)+1);
}
break;
case 'f':
sigfile = ucmalloc(strlen(optarg)+1);

View File

@@ -16,6 +16,8 @@
"-V --vault <vaultfile> Specify an alternate vault file.\n" \
"-O --outfile <file> Output file. STDOUT if unspecified.\n" \
"-I --infile <file> Input file. STDIN if unspecified.\n" \
"-x --xpass <passwd> Provide password. INSECURE! Use for testing\n" \
" or debugging only!\n" \
"-X --password-file <file> Read passphrase from <file>.\n" \
"-i --keyid <id> Specify a key id for various operations.\n" \
"-r --recipient <string> Specify a recpipient, multiple allowed.\n" \
@@ -51,7 +53,8 @@
"-a --armor --textmode same as -z\n" \
"\n" \
"Misc Options:\n" \
"-C --checksum [<key>] calculate a Blake2 checksum of one or more files.\n" \
"-C --checksum calculate a Blake2 checksum of one or more files.\n" \
" add -x <key> to compute an authenticated hash.\n" \
"\n" \
"Arguments:\n" \
"Extra arguments after options are treated as filenames or\n" \

View File

@@ -14,6 +14,8 @@ General Options:
-V --vault <vaultfile> Specify an alternate vault file.
-O --outfile <file> Output file. STDOUT if unspecified.
-I --infile <file> Input file. STDIN if unspecified.
-x --xpass <passwd> Provide password. INSECURE! Use for testing
or debugging only!
-X --password-file <file> Read passphrase from <file>.
-i --keyid <id> Specify a key id for various operations.
-r --recipient <string> Specify a recpipient, multiple allowed.
@@ -49,7 +51,8 @@ Encoding Options:
-a --armor --textmode same as -z
Misc Options:
-C --checksum [<key>] calculate a Blake2 checksum of one or more files.
-C --checksum calculate a Blake2 checksum of one or more files.
add -x <key> to compute an authenticated hash.
Arguments:
Extra arguments after options are treated as filenames or