mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 12:00:56 +01:00
changed invalid // c++ comments to valid /* .. */ C comments
This commit is contained in:
@@ -50,11 +50,11 @@ int pcpdecrypt(char *id, int useid, char *infile, char *outfile, char *passwd, i
|
||||
}
|
||||
}
|
||||
|
||||
// determine crypt mode
|
||||
/* determine crypt mode */
|
||||
fread(&head, 1, 1, in);
|
||||
if(!feof(in) && !ferror(in)) {
|
||||
if(head == PCP_SYM_CIPHER) {
|
||||
// symetric mode
|
||||
/* symetric mode */
|
||||
unsigned char *salt = ucmalloc(90);
|
||||
char stsalt[] = PBP_COMPAT_SALT;
|
||||
memcpy(salt, stsalt, 90);
|
||||
@@ -73,7 +73,7 @@ int pcpdecrypt(char *id, int useid, char *infile, char *outfile, char *passwd, i
|
||||
free(salt);
|
||||
}
|
||||
else {
|
||||
// asymetric mode
|
||||
/* asymetric mode */
|
||||
if(useid) {
|
||||
HASH_FIND_STR(pcpkey_hash, id, secret);
|
||||
if(secret == NULL) {
|
||||
@@ -90,7 +90,7 @@ int pcpdecrypt(char *id, int useid, char *infile, char *outfile, char *passwd, i
|
||||
}
|
||||
}
|
||||
if(secret->secret[0] == 0) {
|
||||
// encrypted, decrypt it
|
||||
/* encrypted, decrypt it */
|
||||
char *passphrase;
|
||||
if(passwd == NULL) {
|
||||
pcp_readpass(&passphrase,
|
||||
@@ -135,7 +135,7 @@ int pcpdecrypt(char *id, int useid, char *infile, char *outfile, char *passwd, i
|
||||
int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *recipient, int signcrypt) {
|
||||
FILE *in = NULL;
|
||||
FILE *out = NULL;
|
||||
pcp_pubkey_t *pubhash = NULL; // FIXME: add free()
|
||||
pcp_pubkey_t *pubhash = NULL; /* FIXME: add free() */
|
||||
pcp_pubkey_t *tmp = NULL;
|
||||
pcp_pubkey_t *pub = NULL;
|
||||
pcp_key_t *secret = NULL;
|
||||
@@ -143,7 +143,7 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec
|
||||
int self = 0;
|
||||
|
||||
if(id == NULL && recipient == NULL) {
|
||||
// self mode
|
||||
/* self mode */
|
||||
self = 1;
|
||||
char *passphrase;
|
||||
if(passwd == NULL) {
|
||||
@@ -154,17 +154,17 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec
|
||||
passphrase = ucmalloc(strlen(passwd)+1);
|
||||
strncpy(passphrase, passwd, strlen(passwd)+1);
|
||||
}
|
||||
unsigned char *salt = ucmalloc(90); // FIXME: use random salt, concat it with result afterwards
|
||||
unsigned char *salt = ucmalloc(90); /* FIXME: use random salt, concat it with result afterwards */
|
||||
char stsalt[] = PBP_COMPAT_SALT;
|
||||
memcpy(salt, stsalt, 90);
|
||||
symkey = pcp_scrypt(passphrase, crypto_secretbox_KEYBYTES, salt, 90);
|
||||
free(salt);
|
||||
}
|
||||
else if(id != NULL && recipient == NULL) {
|
||||
// lookup by id
|
||||
/* lookup by id */
|
||||
HASH_FIND_STR(pcppubkey_hash, id, tmp);
|
||||
if(tmp == NULL) {
|
||||
// self-encryption: look if its a secret one
|
||||
/* self-encryption: look if its a secret one */
|
||||
pcp_key_t *s = NULL;
|
||||
HASH_FIND_STR(pcpkey_hash, id, s);
|
||||
if(s != NULL) {
|
||||
@@ -179,16 +179,16 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec
|
||||
}
|
||||
}
|
||||
else {
|
||||
// found one by id, copy into local hash
|
||||
/* found one by id, copy into local hash */
|
||||
pub = ucmalloc(sizeof(pcp_pubkey_t));
|
||||
memcpy(pub, tmp, sizeof(pcp_pubkey_t));
|
||||
HASH_ADD_STR( pubhash, id, tmp);
|
||||
}
|
||||
}
|
||||
else if(recipient != NULL) {
|
||||
// lookup by recipient list
|
||||
// iterate through global hashlist
|
||||
// copy matches into temporary pubhash
|
||||
/* lookup by recipient list */
|
||||
/* iterate through global hashlist */
|
||||
/* copy matches into temporary pubhash */
|
||||
plist_t *rec;
|
||||
pcphash_iteratepub(tmp) {
|
||||
rec = recipient->first;
|
||||
@@ -198,7 +198,7 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec
|
||||
pub = ucmalloc(sizeof(pcp_pubkey_t));
|
||||
memcpy(pub, tmp, sizeof(pcp_pubkey_t));
|
||||
HASH_ADD_STR( pubhash, id, tmp);
|
||||
//fprintf(stderr, " => found a matching key %s\n", tmp->id);
|
||||
/* fprintf(stderr, " => found a matching key %s\n", tmp->id); */
|
||||
}
|
||||
rec = rec->next;
|
||||
}
|
||||
@@ -211,7 +211,7 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec
|
||||
|
||||
|
||||
if(self != 1) {
|
||||
// we're using a random secret keypair on our side
|
||||
/* we're using a random secret keypair on our side */
|
||||
#ifdef PCP_ASYM_ADD_SENDER_PUB
|
||||
secret = pcpkey_new();
|
||||
#else
|
||||
@@ -222,7 +222,7 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec
|
||||
}
|
||||
|
||||
if(secret->secret[0] == 0) {
|
||||
// encrypted, decrypt it
|
||||
/* encrypted, decrypt it */
|
||||
char *passphrase;
|
||||
if(passwd == NULL) {
|
||||
pcp_readpass(&passphrase,
|
||||
@@ -284,7 +284,7 @@ int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *rec
|
||||
}
|
||||
|
||||
erren2:
|
||||
free(pubhash); // FIXME: it's a uthash, dont use free() but func instead
|
||||
free(pubhash); /* FIXME: it's a uthash, dont use free() but func instead */
|
||||
free(tmp);
|
||||
free(pub);
|
||||
|
||||
|
||||
@@ -39,4 +39,4 @@
|
||||
int pcpdecrypt(char *id, int useid, char *infile, char *outfile, char *passwd, int verify);
|
||||
int pcpencrypt(char *id, char *infile, char *outfile, char *passwd, plist_t *recipient, int signcrypt);
|
||||
|
||||
#endif // _HAVE_ENCRYPTION_H
|
||||
#endif /* _HAVE_ENCRYPTION_H */
|
||||
|
||||
@@ -192,7 +192,7 @@ pcp_key_t *pcp_find_primary_secret() {
|
||||
}
|
||||
}
|
||||
|
||||
// no primary? whoops
|
||||
/* no primary? whoops */
|
||||
int nkeys = HASH_COUNT(pcpkey_hash);
|
||||
if(nkeys == 1) {
|
||||
pcphash_iterate(k) {
|
||||
@@ -209,7 +209,7 @@ void pcp_exportsecret(char *keyid, int useid, char *outfile) {
|
||||
pcp_key_t *key = NULL;
|
||||
|
||||
if(useid == 1) {
|
||||
// look if we've got that one
|
||||
/* look if we've got that one */
|
||||
HASH_FIND_STR(pcpkey_hash, keyid, key);
|
||||
if(key == NULL) {
|
||||
fatal("Could not find a secret key with id 0x%s in vault %s!\n", keyid, vault->filename);
|
||||
@@ -217,7 +217,7 @@ void pcp_exportsecret(char *keyid, int useid, char *outfile) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
// look for our primary key
|
||||
/* look for our primary key */
|
||||
key = pcp_find_primary_secret();
|
||||
if(key == NULL) {
|
||||
fatal("There's no primary secret key in the vault %s!\n", vault->filename);
|
||||
@@ -246,9 +246,9 @@ void pcp_exportsecretkey(pcp_key_t *key, char *outfile) {
|
||||
pcp_dumpkey(key);
|
||||
else
|
||||
pcpkey_print(key, out);
|
||||
// scip
|
||||
//printf("EXPORT:\n");
|
||||
// pcpprint_bin(stdout, key, PCP_RAW_KEYSIZE); printf("\n");
|
||||
/* scip */
|
||||
/* printf("EXPORT:\n"); */
|
||||
/* pcpprint_bin(stdout, key, PCP_RAW_KEYSIZE); printf("\n"); */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,10 +263,10 @@ void pcp_exportpublic(char *keyid, char *recipient, char *passwd, char *outfile,
|
||||
pcp_pubkey_t *key = NULL;
|
||||
|
||||
if(keyid != NULL) {
|
||||
// look if we've got that one
|
||||
/* look if we've got that one */
|
||||
HASH_FIND_STR(pcppubkey_hash, keyid, key);
|
||||
if(key == NULL) {
|
||||
// maybe it's a secret key?
|
||||
/* maybe it's a secret key? */
|
||||
pcp_key_t *s = NULL;
|
||||
HASH_FIND_STR(pcpkey_hash, keyid, s);
|
||||
if(s == NULL) {
|
||||
@@ -279,7 +279,7 @@ void pcp_exportpublic(char *keyid, char *recipient, char *passwd, char *outfile,
|
||||
}
|
||||
}
|
||||
else {
|
||||
// look for the primary secret
|
||||
/* look for the primary secret */
|
||||
pcp_key_t *s = NULL;
|
||||
s = pcp_find_primary_secret();
|
||||
if(s == NULL) {
|
||||
@@ -304,9 +304,9 @@ void pcp_exportpublic(char *keyid, char *recipient, char *passwd, char *outfile,
|
||||
}
|
||||
|
||||
if(out != NULL) {
|
||||
// scip
|
||||
//printf("EXPORT:\n");
|
||||
//pcpprint_bin(stdout, key, PCP_RAW_PUBKEYSIZE); printf("\n");
|
||||
/* scip */
|
||||
/* printf("EXPORT:\n"); */
|
||||
/* pcpprint_bin(stdout, key, PCP_RAW_PUBKEYSIZE); printf("\n"); */
|
||||
pcppubkey_print(key, out, pbpcompat);
|
||||
if(pbpcompat)
|
||||
fprintf(stderr, "public key exported in PBP format.\n");
|
||||
@@ -341,7 +341,7 @@ int pcp_importsecret (vault_t *vault, FILE *in) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// all good now, import the blob
|
||||
/* all good now, import the blob */
|
||||
pcp_key_t *key = ucmalloc(sizeof(pcp_key_t));
|
||||
memcpy(key, z85decoded, PCP_RAW_KEYSIZE);
|
||||
key2native(key);
|
||||
@@ -351,7 +351,7 @@ int pcp_importsecret (vault_t *vault, FILE *in) {
|
||||
|
||||
if(pcp_sanitycheck_key(key) == 0) {
|
||||
if(key->secret[0] != 0) {
|
||||
// unencrypted, encrypt it
|
||||
/* unencrypted, encrypt it */
|
||||
fprintf(stderr, "Key to be imported is unencrypted.\n");
|
||||
char *passphrase;
|
||||
pcp_readpass(&passphrase, "Enter passphrase for key encryption", NULL, 1);
|
||||
@@ -385,9 +385,9 @@ int pcp_importpublic (vault_t *vault, FILE *in, int pbpcompat) {
|
||||
size_t buflen;
|
||||
size_t klen;
|
||||
|
||||
buflen = fread(buf, 1, 2048, in); // base85 encoded
|
||||
buflen = fread(buf, 1, 2048, in); /* base85 encoded */
|
||||
|
||||
// remove trailing newline, if any
|
||||
/* remove trailing newline, if any */
|
||||
size_t i, nlen;
|
||||
nlen = buflen;
|
||||
for(i=buflen; i>0; --i) {
|
||||
@@ -407,7 +407,7 @@ int pcp_importpublic (vault_t *vault, FILE *in, int pbpcompat) {
|
||||
goto errimp1;
|
||||
}
|
||||
|
||||
// unpad result, if any
|
||||
/* unpad result, if any */
|
||||
for(i=klen; i>0; --i) {
|
||||
if(bin[i] != '\0' && i < klen) {
|
||||
klen = i + 1;
|
||||
@@ -415,10 +415,10 @@ int pcp_importpublic (vault_t *vault, FILE *in, int pbpcompat) {
|
||||
}
|
||||
}
|
||||
|
||||
// use first part as sig and verify
|
||||
/* use first part as sig and verify */
|
||||
memcpy(b, &bin[crypto_sign_BYTES], klen - crypto_sign_BYTES);
|
||||
|
||||
// parse the name
|
||||
/* parse the name */
|
||||
parts = strtok (b->name, "<>");
|
||||
pnum = 0;
|
||||
while (parts != NULL) {
|
||||
@@ -437,8 +437,8 @@ int pcp_importpublic (vault_t *vault, FILE *in, int pbpcompat) {
|
||||
free(owner);
|
||||
}
|
||||
|
||||
// fill in the fields
|
||||
pub->ctime = (long)time(0); // pbp exports no ctime
|
||||
/* fill in the fields */
|
||||
pub->ctime = (long)time(0); /* pbp exports no ctime */
|
||||
pub->type = PCP_KEY_TYPE_PUBLIC;
|
||||
pub->version = PCP_KEY_VERSION;
|
||||
pub->serial = arc4random();
|
||||
@@ -487,7 +487,7 @@ int pcp_importpublic (vault_t *vault, FILE *in, int pbpcompat) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// all good now
|
||||
/* all good now */
|
||||
pub = ucmalloc(sizeof(pcp_pubkey_t));
|
||||
memcpy(pub, z85decoded, PCP_RAW_PUBKEYSIZE);
|
||||
pubkey2native(pub);
|
||||
@@ -513,7 +513,7 @@ void pcpdelete_key(char *keyid) {
|
||||
pcp_pubkey_t *p = pcphash_pubkeyexists(keyid);
|
||||
|
||||
if(p != NULL) {
|
||||
// delete public
|
||||
/* delete public */
|
||||
HASH_DEL(pcppubkey_hash, p);
|
||||
free(p);
|
||||
vault->unsafed = 1;
|
||||
@@ -522,7 +522,7 @@ void pcpdelete_key(char *keyid) {
|
||||
else {
|
||||
pcp_key_t *s = pcphash_keyexists(keyid);
|
||||
if(s != NULL) {
|
||||
// delete secret
|
||||
/* delete secret */
|
||||
HASH_DEL(pcpkey_hash, s);
|
||||
free(s);
|
||||
vault->unsafed = 1;
|
||||
@@ -559,7 +559,7 @@ void pcpedit_key(char *keyid) {
|
||||
if(debug)
|
||||
pcp_dumpkey(key);
|
||||
|
||||
vault->unsafed = 1; // will be safed automatically
|
||||
vault->unsafed = 1; /* will be safed automatically */
|
||||
fprintf(stderr, "Key key changed.\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,4 +58,4 @@ int pcp_importsecret (vault_t *vault, FILE *in);
|
||||
void pcpdelete_key(char *keyid);
|
||||
char *pcp_find_id_byrec(char *recipient);
|
||||
|
||||
#endif // _HAVE_KEYMGMT_H
|
||||
#endif /* _HAVE_KEYMGMT_H */
|
||||
|
||||
@@ -41,7 +41,7 @@ int pcptext_infile(char *infile) {
|
||||
goto tdone;
|
||||
}
|
||||
|
||||
// maybe a vault?
|
||||
/* maybe a vault? */
|
||||
vault_t *v = pcpvault_init(infile);
|
||||
if(v != NULL) {
|
||||
fprintf(stdout, "%s is a vault file\n", infile);
|
||||
@@ -49,7 +49,7 @@ int pcptext_infile(char *infile) {
|
||||
goto tdone;
|
||||
}
|
||||
|
||||
// try z85ing it
|
||||
/* try z85ing it */
|
||||
char *z85 = pcp_readz85file(in);
|
||||
if(z85 == NULL) {
|
||||
fprintf(stdout, "Can't handle %s - unknown file type.\n", infile);
|
||||
@@ -65,11 +65,11 @@ int pcptext_infile(char *infile) {
|
||||
goto errtinf1;
|
||||
}
|
||||
|
||||
//fprintf(stdout, "have: %d, secret: %d, public: %d, sig: %d, hh: %d\n", (int)clen,
|
||||
// (int)sizeof(pcp_key_t), (int)sizeof(pcp_pubkey_t), (int)sizeof(pcp_sig_t), (int)sizeof(UT_hash_handle));
|
||||
/* fprintf(stdout, "have: %d, secret: %d, public: %d, sig: %d, hh: %d\n", (int)clen, */
|
||||
/* (int)sizeof(pcp_key_t), (int)sizeof(pcp_pubkey_t), (int)sizeof(pcp_sig_t), (int)sizeof(UT_hash_handle)); */
|
||||
|
||||
if(clen == PCP_RAW_KEYSIZE) {
|
||||
// secret key?
|
||||
/* secret key? */
|
||||
pcp_key_t *key = (pcp_key_t *)bin;
|
||||
key2native(key);
|
||||
if(pcp_sanitycheck_key(key) == 0) {
|
||||
@@ -86,7 +86,7 @@ int pcptext_infile(char *infile) {
|
||||
}
|
||||
|
||||
if(clen == PCP_RAW_PUBKEYSIZE) {
|
||||
// public key?
|
||||
/* public key? */
|
||||
pcp_pubkey_t *key = (pcp_pubkey_t *)bin;
|
||||
pubkey2native(key);
|
||||
if(pcp_sanitycheck_pub(key) == 0) {
|
||||
@@ -102,7 +102,7 @@ int pcptext_infile(char *infile) {
|
||||
}
|
||||
}
|
||||
|
||||
// still there?
|
||||
/* still there? */
|
||||
fprintf(stdout, "%s looks Z85 encoded but otherwise unknown and is possibly encrypted.\n", infile);
|
||||
|
||||
tdone:
|
||||
@@ -199,7 +199,7 @@ void pcpkey_print(pcp_key_t *key, FILE* out) {
|
||||
|
||||
fprintf(out, " Key-ID: 0x%s\n", key->id);
|
||||
|
||||
//2004-06-14T23:34:30.
|
||||
/* 2004-06-14T23:34:30. */
|
||||
fprintf(out, " Creation Time: %04d-%02d-%02dT%02d:%02d:%02d\n",
|
||||
c->tm_year+1900, c->tm_mon+1, c->tm_mday,
|
||||
c->tm_hour, c->tm_min, c->tm_sec);
|
||||
@@ -249,7 +249,7 @@ void pcppubkey_print(pcp_pubkey_t *key, FILE* out, int pbpcompat) {
|
||||
|
||||
unsigned char *sig = pcp_ed_sign(blob, pbplen, secret);
|
||||
fprintf(stderr, " sig: "); pcpprint_bin(stderr, sig, pbplen+crypto_sign_BYTES); fprintf(stderr, "\n");
|
||||
fprintf(stderr, "siglen: %ld, inlen: %ld\n", crypto_sign_BYTES, pbplen);
|
||||
fprintf(stderr, "siglen: %d, inlen: %ld\n", crypto_sign_BYTES, pbplen);
|
||||
if(sig != NULL) {
|
||||
size_t siglen = pbplen + crypto_sign_BYTES;
|
||||
size_t blen = ((siglen / 4) * 5) + siglen;
|
||||
@@ -266,7 +266,7 @@ void pcppubkey_print(pcp_pubkey_t *key, FILE* out, int pbpcompat) {
|
||||
else {
|
||||
size_t zlen;
|
||||
|
||||
//printf("version: %08x\n", key->version);
|
||||
/* printf("version: %08x\n", key->version); */
|
||||
|
||||
pubkey2be(key);
|
||||
|
||||
@@ -292,7 +292,7 @@ void pcppubkey_print(pcp_pubkey_t *key, FILE* out, int pbpcompat) {
|
||||
fprintf(out, " Key-ID: 0x%s\n", key->id);
|
||||
fprintf(out, " Public-Key: %s\n", pcp_z85_encode(key->pub, 32, &zlen));
|
||||
|
||||
//2004-06-14T23:34:30.
|
||||
/* 2004-06-14T23:34:30. */
|
||||
fprintf(out, " Creation Time: %04d-%02d-%02dT%02d:%02d:%02d\n",
|
||||
c->tm_year+1900, c->tm_mon+1, c->tm_mday,
|
||||
c->tm_hour, c->tm_min, c->tm_sec);
|
||||
|
||||
@@ -50,4 +50,4 @@ int pcptext_infile(char *infile);
|
||||
void pcpexport_yaml(char *outfile);
|
||||
void pcpprint_bin(FILE *out, unsigned char *data, size_t len);
|
||||
|
||||
#endif // _HAVE_PCP_KEYPRINT_H
|
||||
#endif /* _HAVE_PCP_KEYPRINT_H */
|
||||
|
||||
28
src/pcp.c
28
src/pcp.c
@@ -71,7 +71,7 @@ int main (int argc, char **argv) {
|
||||
pbpcompat = 0;
|
||||
|
||||
static struct option longopts[] = {
|
||||
// generics
|
||||
/* generics */
|
||||
{ "vault", required_argument, NULL, 'V' },
|
||||
{ "outfile", required_argument, NULL, 'O' },
|
||||
{ "infile", required_argument, NULL, 'I' },
|
||||
@@ -80,7 +80,7 @@ int main (int argc, char **argv) {
|
||||
{ "xpass", required_argument, NULL, 'x' },
|
||||
{ "recipient", required_argument, NULL, 'r' },
|
||||
|
||||
// key management
|
||||
/* key management */
|
||||
{ "keygen", no_argument, NULL, 'k' },
|
||||
{ "listkeys", no_argument, NULL, 'l' },
|
||||
{ "export-secret", no_argument, NULL, 's' },
|
||||
@@ -92,21 +92,21 @@ int main (int argc, char **argv) {
|
||||
{ "export-yaml", no_argument, NULL, 'y' },
|
||||
{ "pbpcompat", no_argument, NULL, 'b' },
|
||||
|
||||
// crypto
|
||||
/* crypto */
|
||||
{ "encrypt", no_argument, NULL, 'e' },
|
||||
{ "encrypt-me", no_argument, NULL, 'm' },
|
||||
{ "decrypt", no_argument, NULL, 'd' },
|
||||
|
||||
// encoding
|
||||
/* encoding */
|
||||
{ "z85-encode", no_argument, NULL, 'z' },
|
||||
{ "z85-decode", no_argument, NULL, 'Z' },
|
||||
|
||||
// globals
|
||||
/* globals */
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "version", no_argument, NULL, 'v' },
|
||||
{ "debug", no_argument, NULL, 'D' },
|
||||
|
||||
// signing
|
||||
/* signing */
|
||||
{ "sign", no_argument, NULL, 'g' },
|
||||
{ "check-signature", no_argument, NULL, 'c' },
|
||||
{ "sigfile", required_argument, NULL, 'f' },
|
||||
@@ -256,7 +256,7 @@ int main (int argc, char **argv) {
|
||||
}
|
||||
|
||||
|
||||
sodium_init(); // FIXME: better called from the lib?
|
||||
sodium_init(); /* FIXME: better called from the lib? */
|
||||
|
||||
if(mode == PCP_MODE_ENCRYPT && useid == 0 && userec == 0) {
|
||||
usevault = 0;
|
||||
@@ -361,16 +361,16 @@ int main (int argc, char **argv) {
|
||||
|
||||
case PCP_MODE_ENCRYPT:
|
||||
if(useid == 1 && userec == 0) {
|
||||
// one dst, FIXME: make id a list as well
|
||||
/* one dst, FIXME: make id a list as well */
|
||||
id = pcp_normalize_id(keyid);
|
||||
pcpencrypt(id, infile, outfile, xpass, NULL, signcrypt);
|
||||
}
|
||||
else if(useid == 0 && userec == 1) {
|
||||
// multiple dst
|
||||
/* multiple dst */
|
||||
pcpencrypt(NULL, infile, outfile, xpass, recipient, signcrypt);
|
||||
}
|
||||
else {
|
||||
// -i and -r specified
|
||||
/* -i and -r specified */
|
||||
fatal("You can't specify both -i and -r, use either -i or -r!\n");
|
||||
}
|
||||
if(id != NULL)
|
||||
@@ -426,14 +426,14 @@ int main (int argc, char **argv) {
|
||||
break;
|
||||
|
||||
default:
|
||||
//
|
||||
/* */
|
||||
goto ELSEMODE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pcpvault_close(vault);
|
||||
pcphash_clean();
|
||||
ucfree(vaultfile);
|
||||
free(vaultfile);
|
||||
}
|
||||
else {
|
||||
ELSEMODE:
|
||||
@@ -469,12 +469,12 @@ int main (int argc, char **argv) {
|
||||
}
|
||||
pcpvault_close(vault);
|
||||
pcphash_clean();
|
||||
ucfree(vaultfile);
|
||||
free(vaultfile);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// mode params mixed
|
||||
/* mode params mixed */
|
||||
fatal("Sorry, invalid combination of commandline parameters (0x%04X)!\n", mode);
|
||||
break;
|
||||
}
|
||||
|
||||
10
src/pcp.h
10
src/pcp.h
@@ -32,7 +32,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <compat_getopt.h>
|
||||
|
||||
// lib
|
||||
/* lib */
|
||||
#include "mem.h"
|
||||
#include "z85.h"
|
||||
#include "zmq_z85.h"
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "version.h"
|
||||
#include "vault.h"
|
||||
|
||||
// subs
|
||||
/* subs */
|
||||
#include "keymgmt.h"
|
||||
#include "usage.h"
|
||||
#include "encryption.h"
|
||||
@@ -48,8 +48,8 @@
|
||||
#include "keyhash.h"
|
||||
#include "plist.h"
|
||||
|
||||
// operation modi
|
||||
// perl -e '$x=0; while ($x<100000) { $x++; $x *= 1.7; printf "0x%08X: %d\n", $x, $x }'
|
||||
/* operation modi */
|
||||
/* perl -e '$x=0; while ($x<100000) { $x++; $x *= 1.7; printf "0x%08X: %d\n", $x, $x }' */
|
||||
#define PCP_MODE_KEYGEN 0x00000001
|
||||
#define PCP_MODE_LISTKEYS 0x00000004
|
||||
#define PCP_MODE_EXPORT_SECRET 0x00000009
|
||||
@@ -88,4 +88,4 @@ void version();
|
||||
void usage();
|
||||
char *default_vault();
|
||||
|
||||
#endif // _HAVE_PCP_H
|
||||
#endif /* _HAVE_PCP_H */
|
||||
|
||||
@@ -55,7 +55,7 @@ int pcpsign(char *infile, char *outfile, char *passwd, int z85, int detach) {
|
||||
}
|
||||
|
||||
if(secret->secret[0] == 0) {
|
||||
// encrypted, decrypt it
|
||||
/* encrypted, decrypt it */
|
||||
char *passphrase;
|
||||
if(passwd == NULL) {
|
||||
pcp_readpass(&passphrase,
|
||||
@@ -121,8 +121,6 @@ int pcpverify(char *infile, char *sigfile, char *id, int detach) {
|
||||
fprintf(stderr, "Signature verified (signed by %s <%s>).\n", pub->owner, pub->mail);
|
||||
|
||||
|
||||
errv4:
|
||||
|
||||
errv1:
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -37,4 +37,4 @@ int pcpverify(char *infile, char *sigfile, char *id, int detach);
|
||||
|
||||
|
||||
|
||||
#endif // _HAVE_SIGNATURE_H
|
||||
#endif /* _HAVE_SIGNATURE_H */
|
||||
|
||||
Reference in New Issue
Block a user