-/* fides.c - Light-weight, decentralised trust and authorisation management
+/* fides.cc - Light-weight, decentralised trust and authorisation management
Copyright (C) 2008-2009 Guus Sliepen <guus@tinc-vpn.org>
- Fides is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- Fides is distributed in the hope that it will be useful,
+ 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 2 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ 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/>.
*/
-#include <cstdio>
-#include <cstring>
-#include <cstdlib>
-#include <stdint.h>
#include <getopt.h>
#include <sysexits.h>
#include <iostream>
#include <fstream>
-#include <botan/types.h>
-#include <botan/botan.h>
-#include <botan/ecdsa.h>
-#include <botan/look_pk.h>
-#include <botan/lookup.h>
-#include <botan/filters.h>
-#include <botan/sha2_32.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <list>
#include "fides.h"
}
static int init() {
- fides fides;
+ Fides::Manager fides;
if(fides.is_firstrun()) {
cout << "New keys generated in " << fides.get_homedir() << '\n';
} else {
if(argc < 1)
return EX_USAGE;
- fides fides;
- fides::publickey *key = fides.find_key(fides::hexdecode(argv[0]));
+ Fides::Manager fides;
+ Fides::PublicKey *key = fides.find_key(Fides::hexdecode(argv[0]));
if(!key) {
cerr << "Unknown key!\n";
return 1;
if(argc < 1)
return EX_USAGE;
- fides fides;
- fides::publickey *key = fides.find_key(fides::hexdecode(argv[0]));
+ Fides::Manager fides;
+ Fides::PublicKey *key = fides.find_key(Fides::hexdecode(argv[0]));
if(!key) {
cerr << "Unknown key!\n";
return 1;
if(argc < 1)
return EX_USAGE;
- fides fides;
- fides::publickey *key = fides.find_key(fides::hexdecode(argv[0]));
+ Fides::Manager fides;
+ Fides::PublicKey *key = fides.find_key(Fides::hexdecode(argv[0]));
if(key)
fides.trust(key);
else {
if(argc < 1)
return EX_USAGE;
- fides fides;
- fides::publickey *key = fides.find_key(fides::hexdecode(argv[0]));
+ Fides::Manager fides;
+ Fides::PublicKey *key = fides.find_key(Fides::hexdecode(argv[0]));
if(key)
fides.dctrust(key);
else {
if(argc < 1)
return EX_USAGE;
- fides fides;
- fides::publickey *key = fides.find_key(fides::hexdecode(argv[0]));
+ Fides::Manager fides;
+ Fides::PublicKey *key = fides.find_key(Fides::hexdecode(argv[0]));
if(key)
fides.distrust(key);
else {
if(argc < 1)
return EX_USAGE;
- fides fides;
+ Fides::Manager fides;
fides.sign(argv[0]);
return 0;
}
if(argc < 1)
return EX_USAGE;
- fides fides;
+ Fides::Manager fides;
fides.allow(argv[0]);
return 0;
}
if(argc < 1)
return EX_USAGE;
- fides fides;
+ Fides::Manager fides;
fides.dontcare(argv[0]);
return 0;
}
if(argc < 1)
return EX_USAGE;
- fides fides;
+ Fides::Manager fides;
fides.deny(argv[0]);
return 0;
}
static int import(int argc, char *const argv[]) {
- fides fides;
+ Fides::Manager fides;
if(argc) {
ifstream in(argv[0]);
}
static int exprt(int argc, char *const argv[]) {
- fides fides;
+ Fides::Manager fides;
if(argc) {
ofstream out(argv[0]);
return EX_USAGE;
// Find certificates matching statement
- fides fides;
- const vector<fides::certificate *> &certs = fides.find_certificates(argv[0]);
+ Fides::Manager fides;
+ const vector<const Fides::Certificate *> &certs = fides.find_certificates(argv[0]);
for(size_t i = 0; i < certs.size(); ++i)
cout << i << ' ' << certs[i]->to_string() << '\n';
return 0;
if(argc < 1)
return EX_USAGE;
- fides fides;
+ Fides::Manager fides;
return fides.is_allowed(argv[0]) ? 0 : 1;
}
if(argc < 1)
return EX_USAGE;
- fides fides;
+ Fides::Manager fides;
return fides.is_denied(argv[0]) ? 0 : 1;
}
if(argc < 1)
return EX_USAGE;
- fides fides;
+ Fides::Manager fides;
int self, trusted, all;
fides.auth_stats(argv[0], self, trusted, all);
cout << "Self: " << self << ", trusted: " << trusted << ", all: " << all << '\n';
}
static int fsck() {
- fides fides;
+ Fides::Manager fides;
if(fides.fsck()) {
cout << "Everything OK\n";
return 0;