changed public key export format to (slightly modified) RFC4880 style (openpgp format).

Current state is totally unstable, it's not yet ready.
This commit is contained in:
TLINDEN
2014-02-12 00:37:41 +01:00
parent c9e236db20
commit 6d738ccbf8
22 changed files with 5864 additions and 68 deletions

View File

@@ -427,8 +427,62 @@ int pcp_importsecret (vault_t *vault, FILE *in) {
return 1;
}
int pcp_importpublic (vault_t *vault, FILE *in) {
unsigned char *buf = ucmalloc(2048);
size_t buflen = fread(buf, 1, 2048, in);
pcp_keysig_t *sk = NULL;
pcp_pubkey_t *pub = NULL;
if(buflen > 0) {
pcp_ks_bundle_t *bundle = pcp_import_pub(buf, buflen);
pcp_keysig_t *sk = bundle->s;
if(bundle != NULL) {
pcp_pubkey_t *pub = bundle->p;
if(debug)
pcp_dumppubkey(pub);
if(sk == NULL) {
fatals_ifany();
char *yes = pcp_getstdin("WARNING: signature doesn't verify, import anyway [yes|NO]?");
if(strncmp(yes, "yes", 1024) != 0) {
free(yes);
goto errip1;
}
free(yes);
}
if(pcp_sanitycheck_pub(pub) == 0) {
if(pcpvault_addkey(vault, (void *)pub, PCP_KEY_TYPE_PUBLIC) == 0) {
fprintf(stderr, "key 0x%s added to %s.\n", pub->id, vault->filename);
}
else
goto errip2;
if(sk != NULL) {
if(pcpvault_addkey(vault, sk, sk->type) != 0)
goto errip2;
}
}
else
goto errip2;
}
}
errip2:
ucfree(pub, sizeof(pcp_pubkey_t));
errip1:
if(sk != NULL) {
ucfree(sk->blob, sk->size);
ucfree(sk, sizeof(pcp_keysig_t));
}
ucfree(buf, 2048);
return 1;
}
int pcp_importpublicOLD (vault_t *vault, FILE *in) {
pcp_pubkey_t *pub = NULL;
int pbpcompat = 0;
if(pbpcompat == 1) {

View File

@@ -524,10 +524,10 @@ int main (int argc, char **argv) {
goto ELSEMODE;
break;
}
pcpvault_close(vault);
pcphash_clean();
free(vaultfile);
}
pcpvault_close(vault);
pcphash_clean();
free(vaultfile);
}
else {
ELSEMODE:
@@ -574,7 +574,6 @@ int main (int argc, char **argv) {
}
}
fatals_ifany();
return PCP_EXIT;

View File

@@ -28,8 +28,8 @@
"-S --import-secret Import a secret key.\n" \
"-P --import-public Import a public key.\n" \
"-y --export-yaml Export all keys as YAML formatted text.\n" \
"-b --pbpcompat Enable PBP compatibility for public key\n" \
" exports and imports.\n" \
"-F --export-format <fmt> Specify exportformat, either 'pbp' or 'pcp'.\n" \
" 'pcp' is the default if unspecified.\n" \
"Encryption Options:\n" \
"-e --encrypt Asym-Encrypt a message. If none of -i or -r\n" \
" has been given, encrypt the message symetrically.\n" \

View File

@@ -26,8 +26,8 @@ Keymanagement Options:
-S --import-secret Import a secret key.
-P --import-public Import a public key.
-y --export-yaml Export all keys as YAML formatted text.
-b --pbpcompat Enable PBP compatibility for public key
exports and imports.
-F --export-format <fmt> Specify exportformat, either 'pbp' or 'pcp'.
'pcp' is the default if unspecified.
Encryption Options:
-e --encrypt Asym-Encrypt a message. If none of -i or -r
has been given, encrypt the message symetrically.