renamed 'public' to 'pub' to avoid conflict with c++ api

This commit is contained in:
TLINDEN
2013-11-29 20:01:42 +01:00
parent 2fdbf8e1be
commit a9b2796af2
10 changed files with 165 additions and 162 deletions

View File

@@ -444,107 +444,6 @@ int pcp_importpublic (vault_t *vault, FILE *in) {
return 1;
}
int pcp_sanitycheck_pub(pcp_pubkey_t *key) {
if(key->public[0] == 0) {
fatal("Pubkey sanity check: public key contained in key seems to be empty!\n");
return 1;
}
if(key->type != PCP_KEY_TYPE_PUBLIC) {
fatal("Pubkey sanity check: key type is not PUBLIC (expected: %02x, got: %02x)!\n",
PCP_KEY_TYPE_PUBLIC, key->type);
return 1;
}
if(key->version != PCP_KEY_VERSION) {
fatal("Pubkey sanity check: unknown key version (expected: %08X, got: %08X)!\n",
PCP_KEY_VERSION, key->version);
return 1;
}
if(key->serial <= 0) {
fatal("Pubkey sanity check: invalid serial number: %08X!\n", key->serial);
return 1;
}
if(key->id[16] != '\0') {
char *got = ucmalloc(17);
memcpy(got, key->id, 17);
got[16] = '\0';
fatal("Pubkey sanity check: invalid key id (expected 16 bytes, got: %s)!\n", got);
free(got);
return 1;
}
struct tm *c;
time_t t = (time_t)key->ctime;
c = localtime(&t);
if(c->tm_year <= 0 || c->tm_year > 1100) {
// well, I'm perhaps overacting here :)
fatal("Pubkey sanity check: invalid creation timestamp (got year %04d)!\n", c->tm_year + 1900);
return 1;
}
pcp_pubkey_t *maybe = pcphash_pubkeyexists(key->id);
if(maybe != NULL) {
fatal("Pubkey sanity check: there already exists a key with the id 0x%s\n", key->id);
return 1;
}
return 0;
}
int pcp_sanitycheck_key(pcp_key_t *key) {
if(key->encrypted[0] == 0) {
fatal("Secretkey sanity check: secret key contained in key seems to be empty!\n");
return 1;
}
if(key->type != PCP_KEY_TYPE_SECRET && key->type != PCP_KEY_TYPE_MAINSECRET) {
fatal("Secretkey sanity check: key type is not SECRET (expected: %02x, got: %02x)!\n",
PCP_KEY_TYPE_SECRET, key->type);
return 1;
}
if(key->version != PCP_KEY_VERSION) {
fatal("Secretkey sanity check: unknown key version (expected: %08X, got: %08X)!\n",
PCP_KEY_VERSION, key->version);
return 1;
}
if(key->serial <= 0) {
fatal("Secretkey sanity check: invalid serial number: %08X!\n", key->serial);
return 1;
}
if(key->id[16] != '\0') {
char *got = ucmalloc(17);
memcpy(got, key->id, 17);
got[16] = '\0';
fatal("Secretkey sanity check: invalid key id (expected 16 bytes, got: %s)!\n", got);
free(got);
return 1;
}
struct tm *c;
time_t t = (time_t)key->ctime;
c = localtime(&t);
if(c->tm_year <= 0 || c->tm_year > 1100) {
// well, I'm perhaps overacting here :)
fatal("Secretkey sanity check: invalid creation timestamp (got year %04d)!\n", c->tm_year + 1900);
return 1;
}
pcp_key_t *maybe = pcphash_keyexists(key->id);
if(maybe != NULL) {
fatal("Secretkey sanity check: there already exists a key with the id 0x%s\n", key->id);
return 1;
}
return 0;
}
void pcpdelete_key(char *keyid) {
pcp_pubkey_t *p = pcphash_pubkeyexists(keyid);