mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 20:00:58 +01:00
added -F parameter (-F pbp or -F pcp, the latter being the default), which can be used to specify the key export format
This commit is contained in:
52
src/pcp.c
52
src/pcp.c
@@ -46,7 +46,7 @@ char *default_vault() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main (int argc, char **argv) {
|
int main (int argc, char **argv) {
|
||||||
int opt, mode, usevault, useid, userec, lo, armor, detach, signcrypt, pbpcompat, rfc;
|
int opt, mode, usevault, useid, userec, lo, armor, detach, signcrypt, exportformat;
|
||||||
char *vaultfile = default_vault();
|
char *vaultfile = default_vault();
|
||||||
char *outfile = NULL;
|
char *outfile = NULL;
|
||||||
char *infile = NULL;
|
char *infile = NULL;
|
||||||
@@ -69,8 +69,7 @@ int main (int argc, char **argv) {
|
|||||||
armor = 0;
|
armor = 0;
|
||||||
detach = 0;
|
detach = 0;
|
||||||
signcrypt = 0;
|
signcrypt = 0;
|
||||||
pbpcompat = 0;
|
exportformat = EXP_FORMAT_NATIVE;
|
||||||
rfc = 0;
|
|
||||||
|
|
||||||
static struct option longopts[] = {
|
static struct option longopts[] = {
|
||||||
/* generics */
|
/* generics */
|
||||||
@@ -92,8 +91,7 @@ int main (int argc, char **argv) {
|
|||||||
{ "remove-key", no_argument, NULL, 'R' },
|
{ "remove-key", no_argument, NULL, 'R' },
|
||||||
{ "edit-key", no_argument, NULL, 'E' },
|
{ "edit-key", no_argument, NULL, 'E' },
|
||||||
{ "export-yaml", no_argument, NULL, 'y' },
|
{ "export-yaml", no_argument, NULL, 'y' },
|
||||||
{ "pbpcompat", no_argument, NULL, 'b' },
|
{ "export-format", required_argument, NULL, 'F' },
|
||||||
{ "rfc-format", no_argument, NULL, '1' }, /* no short option */
|
|
||||||
|
|
||||||
/* crypto */
|
/* crypto */
|
||||||
{ "encrypt", no_argument, NULL, 'e' },
|
{ "encrypt", no_argument, NULL, 'e' },
|
||||||
@@ -153,9 +151,6 @@ int main (int argc, char **argv) {
|
|||||||
mode += PCP_MODE_IMPORT_SECRET;
|
mode += PCP_MODE_IMPORT_SECRET;
|
||||||
usevault = 1;
|
usevault = 1;
|
||||||
break;
|
break;
|
||||||
case '1':
|
|
||||||
rfc = 1;
|
|
||||||
break;
|
|
||||||
case 'R':
|
case 'R':
|
||||||
mode += PCP_MODE_DELETE_KEY;
|
mode += PCP_MODE_DELETE_KEY;
|
||||||
usevault = 1;
|
usevault = 1;
|
||||||
@@ -185,8 +180,17 @@ int main (int argc, char **argv) {
|
|||||||
case 'Z':
|
case 'Z':
|
||||||
armor = 2;
|
armor = 2;
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'F':
|
||||||
pbpcompat = 1;
|
if(strncmp(optarg, "pbp", 3) == 0) {
|
||||||
|
exportformat = EXP_FORMAT_PBP;
|
||||||
|
}
|
||||||
|
else if(strncmp(optarg, "pcp", 3) == 0) {
|
||||||
|
exportformat = EXP_FORMAT_NATIVE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
warn("Unknown export format specified, using native\n");
|
||||||
|
exportformat = EXP_FORMAT_NATIVE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
mode += PCP_MODE_SIGN;
|
mode += PCP_MODE_SIGN;
|
||||||
@@ -385,24 +389,16 @@ int main (int argc, char **argv) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PCP_MODE_EXPORT_PUBLIC:
|
case PCP_MODE_EXPORT_PUBLIC:
|
||||||
if(rfc) {
|
if(useid) {
|
||||||
pcp_exportpublic2(xpass, outfile, armor);
|
id = pcp_normalize_id(keyid);
|
||||||
}
|
if(id == NULL)
|
||||||
else {
|
break;
|
||||||
if(useid) {
|
|
||||||
id = pcp_normalize_id(keyid);
|
|
||||||
if(id == NULL)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (recipient != NULL)
|
|
||||||
pcp_exportpublic(id, recipient->value, xpass, outfile, pbpcompat);
|
|
||||||
else
|
|
||||||
pcp_exportpublic(id, NULL, xpass, outfile, pbpcompat);
|
|
||||||
if(xpass != NULL)
|
|
||||||
free(xpass);
|
|
||||||
if(recipient != NULL)
|
|
||||||
free(recipient);
|
|
||||||
}
|
}
|
||||||
|
pcp_exportpublic(id, xpass, outfile, exportformat, armor);
|
||||||
|
if(xpass != NULL)
|
||||||
|
free(xpass);
|
||||||
|
if(recipient != NULL)
|
||||||
|
free(recipient);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCP_MODE_IMPORT_PUBLIC:
|
case PCP_MODE_IMPORT_PUBLIC:
|
||||||
@@ -415,7 +411,7 @@ int main (int argc, char **argv) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pcp_importpublic(vault, in, pbpcompat);
|
pcp_importpublic(vault, in);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCP_MODE_IMPORT_SECRET:
|
case PCP_MODE_IMPORT_SECRET:
|
||||||
|
|||||||
Reference in New Issue
Block a user