Install a pkg-config file.
[fides] / lib / publickey.h
1 /* fides.h - Light-weight, decentralised trust and authorisation management
2    Copyright (C) 2008-2009  Guus Sliepen <guus@tinc-vpn.org>
3   
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.
8   
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.
13   
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/>.
16 */
17
18 #ifndef __FIDES_PUBLICKEY_H__
19 #define __FIDES_PUBLICKEY_H__
20
21 #ifdef __cplusplus
22 #include <string>
23 #include <iostream>
24 #include <botan/botan.h>
25 #include <botan/ecdsa.h>
26         
27 namespace Fides {
28         class PublicKey {
29                 protected:
30                 Botan::ECDSA_PublicKey *pub;
31
32                 public:
33                 PublicKey();
34                 ~PublicKey();
35
36                 int trust;
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;
45         };
46 }
47
48 extern "C" {
49 typedef Fides::PublicKey fides_publickey;
50 #else
51 #include <stdbool.h>
52 typedef struct fides_publickey fides_publickey;
53 #endif
54
55 extern fides_publickey *fides_publickey_new();
56 extern void fides_publickey_free(fides_publickey *k);
57
58 extern void fides_publickey_set_trust(fides_publickey *k, int trust);
59 extern int fides_publickey_get_trust(fides_publickey *k);
60
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);
67
68 #ifdef __cplusplus
69 }
70 #endif
71
72 #endif