2013-11-28 19:36:50 +01:00
|
|
|
/*
|
|
|
|
|
This file is part of Pretty Curved Privacy (pcp1).
|
|
|
|
|
|
|
|
|
|
Copyright (C) 2013 T.Linden.
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
You can contact me by mail: <tlinden AT cpan DOT org>.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-12-02 22:53:03 +01:00
|
|
|
#include "vault++.h"
|
|
|
|
|
#include "key++.h"
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
using namespace pcp;
|
|
|
|
|
|
|
|
|
|
Key::Key() {
|
|
|
|
|
stored = false;
|
|
|
|
|
K = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Key::Key(bool generate) {
|
|
|
|
|
stored = false;
|
|
|
|
|
K = pcpkey_new();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Key::Key(const string& passphrase) {
|
|
|
|
|
stored = false;
|
|
|
|
|
K = pcpkey_new();
|
2013-11-29 20:02:27 +01:00
|
|
|
K = pcpkey_encrypt(K, (char *)passphrase.c_str());
|
2013-11-28 19:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Key::Key(const string& passphrase,
|
|
|
|
|
const string& owner,
|
|
|
|
|
const string& mail) {
|
|
|
|
|
stored = false;
|
2013-11-29 20:02:27 +01:00
|
|
|
pcp_key_t *_K = pcpkey_new();
|
|
|
|
|
K = pcpkey_encrypt(_K, (char *)passphrase.c_str());
|
2013-11-28 19:36:50 +01:00
|
|
|
memcpy(K->owner, owner.c_str(), owner.length()+1);
|
|
|
|
|
memcpy(K->mail, mail.c_str(), mail.length()+1);
|
2013-12-01 16:16:53 +01:00
|
|
|
// free(_K);
|
2013-11-28 19:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
2013-11-29 20:02:27 +01:00
|
|
|
Key::Key(pcp_key_t *k) {
|
2013-11-28 19:36:50 +01:00
|
|
|
stored = false;
|
|
|
|
|
K = k;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-01 16:16:53 +01:00
|
|
|
Key::Key(pcp_key_t *k, bool store) {
|
|
|
|
|
stored = new bool(store);
|
|
|
|
|
K = k;
|
2013-11-28 19:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
2013-12-01 16:16:53 +01:00
|
|
|
Key::Key(string &z85encoded) {
|
|
|
|
|
stored = false;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
2013-12-01 16:16:53 +01:00
|
|
|
if(z85encoded.length() == 0)
|
2013-11-29 20:02:27 +01:00
|
|
|
throw pcp::exception("Error: zero length input");
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
size_t clen;
|
2013-12-01 16:16:53 +01:00
|
|
|
unsigned char *z85decoded = pcp_z85_decode((char *)z85encoded.c_str(), &clen);
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
if(z85decoded == NULL)
|
2013-11-29 20:02:27 +01:00
|
|
|
throw pcp::exception("Error: could not decode input - it's probably not Z85.\n");
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
if(clen != PCP_RAW_KEYSIZE) {
|
2013-11-29 20:02:27 +01:00
|
|
|
free(z85decoded);
|
|
|
|
|
char m[256];
|
|
|
|
|
sprintf(m, "Error: decoded input didn't result to a proper sized key (got %ld bytes)!\n", clen);
|
|
|
|
|
throw pcp::exception(string(m));
|
2013-11-28 19:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// all good now, import the blob
|
2013-11-29 20:02:27 +01:00
|
|
|
pcp_key_t *key = (pcp_key_t *)ucmalloc(sizeof(pcp_key_t));
|
2013-11-28 19:36:50 +01:00
|
|
|
memcpy(key, z85decoded, PCP_RAW_KEYSIZE);
|
|
|
|
|
key2native(key);
|
|
|
|
|
|
|
|
|
|
if(pcp_sanitycheck_key(key) != 0) {
|
|
|
|
|
free(key);
|
|
|
|
|
free(z85decoded);
|
2013-11-29 20:02:27 +01:00
|
|
|
throw pcp::exception();
|
2013-11-28 19:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
2013-12-01 16:16:53 +01:00
|
|
|
K = key;
|
|
|
|
|
cout << 7 << " false" << endl;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-01 16:16:53 +01:00
|
|
|
Key::~Key() {
|
|
|
|
|
if (! stored) {
|
|
|
|
|
free(K);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-19 12:30:26 +01:00
|
|
|
Key& Key::operator = (const Key &k) {
|
2013-12-01 16:16:53 +01:00
|
|
|
K = k.K;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
2013-11-28 19:36:50 +01:00
|
|
|
|
2013-12-01 16:16:53 +01:00
|
|
|
string Key::to_text() {
|
2013-11-28 19:36:50 +01:00
|
|
|
size_t zlen;
|
2013-12-01 16:16:53 +01:00
|
|
|
pcp_key_t *key = K;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
key2be(key);
|
|
|
|
|
void *blob = ucmalloc(PCP_RAW_KEYSIZE);
|
|
|
|
|
pcp_seckeyblob(blob, key);
|
|
|
|
|
char *z85encoded = pcp_z85_encode((unsigned char*)blob, PCP_RAW_KEYSIZE, &zlen);
|
|
|
|
|
|
|
|
|
|
if(PCP_ERRSET == 1)
|
2013-11-29 20:02:27 +01:00
|
|
|
throw pcp::exception();
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
key2native(key);
|
|
|
|
|
|
|
|
|
|
free(blob);
|
|
|
|
|
|
|
|
|
|
struct tm *c;
|
|
|
|
|
time_t t = (time_t)key->ctime;
|
|
|
|
|
c = localtime(&t);
|
|
|
|
|
|
2013-12-01 16:16:53 +01:00
|
|
|
string z85;
|
2013-11-29 20:02:27 +01:00
|
|
|
char *out = (char *)ucmalloc(2048);
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
sprintf(out, "%s\n", PCP_KEY_HEADER);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
sprintf(out, " Generated by: %s Version %d.%d.%d\n",
|
|
|
|
|
PCP_ME, PCP_VERSION_MAJOR, PCP_VERSION_MINOR, PCP_VERSION_PATCH);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
sprintf(out, " Cipher: %s\n", PCP_KEY_PRIMITIVE);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
sprintf(out, " Key-ID: 0x%s\n", key->id);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
//2004-06-14T23:34:30.
|
|
|
|
|
sprintf(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);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
sprintf(out, " Serial Number: 0x%08X\n", key->serial);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
sprintf(out, " Key Version: 0x%08X\n", key->version);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
sprintf(out, "\n%s\n", z85encoded);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
sprintf(out, "%s\n", PCP_KEY_FOOTER);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
free(z85encoded);
|
|
|
|
|
|
2013-12-01 16:16:53 +01:00
|
|
|
return z85;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ostream& pcp::operator<<(ostream& output, Key& k) {
|
|
|
|
|
output << k.to_text();
|
2013-11-28 19:36:50 +01:00
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-02 22:53:03 +01:00
|
|
|
bool pcp::operator!(Key& k) {
|
|
|
|
|
if(k.K == NULL)
|
|
|
|
|
return true;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-28 19:36:50 +01:00
|
|
|
void Key::encrypt(const string& passphrase) {
|
2013-11-29 20:02:27 +01:00
|
|
|
K = pcpkey_encrypt(K, (char *)passphrase.c_str());
|
2013-11-28 19:36:50 +01:00
|
|
|
if(PCP_ERRSET == 1)
|
|
|
|
|
throw exception();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Key::decrypt(const string& passphrase) {
|
2013-11-29 20:02:27 +01:00
|
|
|
K = pcpkey_decrypt(K, (char *)passphrase.c_str());
|
2013-11-28 19:36:50 +01:00
|
|
|
if(PCP_ERRSET == 1)
|
|
|
|
|
throw exception();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PubKey Key::get_public() {
|
|
|
|
|
return PubKey(pcpkey_pub_from_secret(K));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string Key::get_id() {
|
2013-11-29 20:02:27 +01:00
|
|
|
string id = K->id;
|
2013-11-28 19:36:50 +01:00
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string Key::get_owner() {
|
2013-11-29 20:02:27 +01:00
|
|
|
string o = K->owner;
|
2013-11-28 19:36:50 +01:00
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string Key::get_mail() {
|
2013-11-29 20:02:27 +01:00
|
|
|
string m = K->mail;
|
2013-11-28 19:36:50 +01:00
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Key::set_owner(const string& owner) {
|
|
|
|
|
memcpy(K->owner, owner.c_str(), owner.length()+1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Key::set_mail(const string& mail) {
|
|
|
|
|
memcpy(K->mail, mail.c_str(), mail.length()+1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Key::is_stored(bool s) {
|
|
|
|
|
stored = s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Key::is_stored() {
|
|
|
|
|
return stored;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Key::is_encrypted() {
|
|
|
|
|
if(K->secret[0] == '\0')
|
|
|
|
|
return true;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-02 22:53:03 +01:00
|
|
|
// class Key ends here.
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PubKey::PubKey() {
|
|
|
|
|
stored = false;
|
|
|
|
|
K = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-11-29 20:02:27 +01:00
|
|
|
PubKey::PubKey(pcp_pubkey_t *k) {
|
2013-11-28 19:36:50 +01:00
|
|
|
stored = false;
|
|
|
|
|
K = k;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-01 16:16:53 +01:00
|
|
|
PubKey::PubKey(pcp_pubkey_t *k, bool store) {
|
|
|
|
|
stored = store;
|
|
|
|
|
K = k;
|
2013-11-28 19:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
2014-02-14 16:40:09 +01:00
|
|
|
|
|
|
|
|
// FIXME: use Buffer class for stuff like this
|
2013-12-01 16:16:53 +01:00
|
|
|
PubKey::PubKey(string &z85encoded) {
|
|
|
|
|
stored = false;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
2013-12-01 16:16:53 +01:00
|
|
|
if(z85encoded.length() == 0)
|
2013-11-29 20:02:27 +01:00
|
|
|
throw pcp::exception("Error: zero length input");
|
2013-11-28 19:36:50 +01:00
|
|
|
|
2014-02-14 16:40:09 +01:00
|
|
|
Buffer *blob = buffer_new(256, "pub");
|
|
|
|
|
buffer_add(blob, z85encoded.c_str(), z85encoded.length());
|
2013-12-02 22:53:03 +01:00
|
|
|
|
2014-02-14 16:40:09 +01:00
|
|
|
pcp_ks_bundle_t *KS = pcp_import_pub(buffer_get(blob), buffer_size(blob));
|
2013-11-28 19:36:50 +01:00
|
|
|
|
2014-02-14 16:40:09 +01:00
|
|
|
if(KS == NULL) {
|
|
|
|
|
buffer_free(blob);
|
|
|
|
|
throw pcp::exception();
|
2013-11-28 19:36:50 +01:00
|
|
|
}
|
2014-02-14 16:40:09 +01:00
|
|
|
pcp_pubkey_t *pub = KS->p;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
2014-02-14 16:40:09 +01:00
|
|
|
if(pcp_sanitycheck_pub(pub) != 0) {
|
|
|
|
|
free(KS->p);
|
|
|
|
|
free(KS->s);
|
|
|
|
|
free(KS);
|
|
|
|
|
buffer_free(blob);
|
2013-11-29 20:02:27 +01:00
|
|
|
throw pcp::exception();
|
2013-11-28 19:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
2014-02-14 16:40:09 +01:00
|
|
|
K = pub;
|
2013-12-01 16:16:53 +01:00
|
|
|
}
|
2013-11-28 19:36:50 +01:00
|
|
|
|
2013-12-01 16:16:53 +01:00
|
|
|
PubKey::~PubKey() {
|
|
|
|
|
if (! stored) {
|
|
|
|
|
free(K);
|
|
|
|
|
}
|
2013-11-28 19:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
2013-12-19 12:30:26 +01:00
|
|
|
PubKey& PubKey::operator = (const PubKey &k) {
|
2013-12-01 16:16:53 +01:00
|
|
|
K = k.K;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
2013-11-28 19:36:50 +01:00
|
|
|
|
2013-12-01 16:16:53 +01:00
|
|
|
string PubKey::to_text() {
|
2013-11-28 19:36:50 +01:00
|
|
|
size_t zlen;
|
2013-12-01 16:16:53 +01:00
|
|
|
pcp_pubkey_t *key = K;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
pubkey2be(key);
|
|
|
|
|
void *blob = ucmalloc(PCP_RAW_PUBKEYSIZE);
|
|
|
|
|
pcp_pubkeyblob(blob, key);
|
|
|
|
|
char *z85encoded = pcp_z85_encode((unsigned char*)blob, PCP_RAW_PUBKEYSIZE, &zlen);
|
|
|
|
|
|
|
|
|
|
if(PCP_ERRSET == 1)
|
2013-11-29 20:02:27 +01:00
|
|
|
throw pcp::exception();
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
pubkey2native(key);
|
|
|
|
|
|
|
|
|
|
free(blob);
|
|
|
|
|
|
|
|
|
|
struct tm *c;
|
|
|
|
|
time_t t = (time_t)key->ctime;
|
|
|
|
|
c = localtime(&t);
|
|
|
|
|
|
2013-11-29 20:02:27 +01:00
|
|
|
char *out = (char *)ucmalloc(2048);
|
2013-12-01 16:16:53 +01:00
|
|
|
string z85;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
sprintf(out, "%s\n", PCP_PUBKEY_HEADER);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
sprintf(out, " Generated by: %s Version %d.%d.%d\n",
|
|
|
|
|
PCP_ME, PCP_VERSION_MAJOR, PCP_VERSION_MINOR, PCP_VERSION_PATCH);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
sprintf(out, " Cipher: %s\n", PCP_KEY_PRIMITIVE);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
sprintf(out, " PubKey-ID: 0x%s\n", key->id);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
//2004-06-14T23:34:30.
|
|
|
|
|
sprintf(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);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
unsigned char *hash = pcppubkey_getchecksum(key);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += " Checksum: ";
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
for ( i = 0;i <15 ;++i) {
|
|
|
|
|
sprintf(out, "%02X:",(unsigned int) hash[i]);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
}
|
|
|
|
|
sprintf(out, "%02X", hash[15]);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
|
|
|
|
z85 += "\n ";
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
for ( i = 16;i <31 ;++i) {
|
|
|
|
|
sprintf(out, "%02X:",(unsigned int) hash[i]);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
}
|
|
|
|
|
sprintf(out, "%02X", hash[31]);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
|
|
|
|
z85 += "\n";
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
sprintf(out, " Serial Number: 0x%08X\n", key->serial);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
sprintf(out, " Key Version: 0x%08X\n", key->version);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
char *r = pcppubkey_get_art(key);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += " Random Art ID: ";
|
2013-11-29 20:02:27 +01:00
|
|
|
int rlen = strlen(r);
|
2013-11-28 19:36:50 +01:00
|
|
|
|
2013-11-29 20:02:27 +01:00
|
|
|
for (i=0; i<rlen; ++i) {
|
2013-11-28 19:36:50 +01:00
|
|
|
if(r[i] == '\n') {
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += "\n ";
|
2013-11-28 19:36:50 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
sprintf(out, "%c", r[i]);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
}
|
|
|
|
|
}
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += "\n";
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
sprintf(out, "\n%s\n", z85encoded);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
sprintf(out, "%s\n", PCP_PUBKEY_FOOTER);
|
2013-12-01 16:16:53 +01:00
|
|
|
z85 += out;
|
2013-11-28 19:36:50 +01:00
|
|
|
|
|
|
|
|
free(z85encoded);
|
|
|
|
|
|
2013-12-01 16:16:53 +01:00
|
|
|
return z85;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ostream& pcp::operator<<(ostream& output, PubKey& k) {
|
|
|
|
|
output << k.to_text();
|
2013-11-28 19:36:50 +01:00
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-02 22:53:03 +01:00
|
|
|
bool pcp::operator!(PubKey& k) {
|
|
|
|
|
if(k.K == NULL) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-28 19:36:50 +01:00
|
|
|
string PubKey::get_id() {
|
2013-11-29 20:02:27 +01:00
|
|
|
string id = K->id;
|
2013-11-28 19:36:50 +01:00
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string PubKey::get_owner() {
|
2013-11-29 20:02:27 +01:00
|
|
|
string o = K->owner;
|
2013-11-28 19:36:50 +01:00
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string PubKey::get_mail() {
|
2013-11-29 20:02:27 +01:00
|
|
|
string m = K->mail;
|
2013-11-28 19:36:50 +01:00
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PubKey::is_stored(bool s) {
|
|
|
|
|
stored = s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool PubKey::is_stored() {
|
|
|
|
|
return stored;
|
|
|
|
|
}
|
|
|
|
|
|