1 /* fides.h - Light-weight, decentralised trust and authorisation management
2 Copyright (C) 2008-2009 Guus Sliepen <guus@tinc-vpn.org>
4 Fides is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of
7 the License, or (at your option) any later version.
9 Fides is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, see <http://www.gnu.org/licenses/>.
18 #ifndef __FIDES_PUBLICKEY_H__
19 #define __FIDES_PUBLICKEY_H__
24 #include <botan/botan.h>
25 #include <botan/ecdsa.h>
30 Botan::ECDSA_PublicKey *pub;
37 void load(std::istream &in);
38 void save(std::ostream &out) const;
39 void load(const std::string &filename);
40 void save(const std::string &filename) const;
41 bool verify(const std::string &data, const std::string &signature) const;
42 std::string to_string() const;
43 void from_string(const std::string &in);
44 std::string fingerprint(unsigned int bits = 64) const;
49 typedef Fides::PublicKey fides_publickey;
52 typedef struct fides_publickey fides_publickey;
55 extern fides_publickey *fides_publickey_new();
56 extern void fides_publickey_free(fides_publickey *k);
58 extern void fides_publickey_set_trust(fides_publickey *k, int trust);
59 extern int fides_publickey_get_trust(fides_publickey *k);
61 extern void fides_publickey_load(fides_publickey *k, const char *filename);
62 extern void fides_publickey_save(fides_publickey *k, const char *filename);
63 extern bool fides_publickey_verify(fides_publickey *k, const char *data, const char *signature);
64 extern char *fides_publickey_to_string(fides_publickey *k);
65 extern void fides_publickey_from_string(fides_publickey *k, const char *in);
66 extern char *fides_publickey_fingerprint(fides_publickey *k, unsigned int bits);