Install a pkg-config file.
[fides] / lib / certificate.h
1 /* Certificate.h - Fides Certificate class
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_CERTIFICATE_H__
19 #define __FIDES_CERTIFICATE_H__
20
21 #include <sys/time.h>
22 #include "publickey.h"
23 #include "privatekey.h"
24
25 #ifdef __cplusplus
26 #include <string>
27
28 namespace Fides {
29         class Certificate {
30                 friend class Manager;
31
32                 /// Public key that signed this certificate.
33                 const PublicKey *signer;
34                 struct timeval timestamp;
35                 std::string statement;
36                 std::string signature;
37
38                 public:
39                 Certificate(const PublicKey *pub, struct timeval timestamp, const std::string &statement, const std::string &signature);
40                 Certificate(const PrivateKey *priv, struct timeval timestamp, const std::string &statement);
41
42                 std::string to_string() const;
43                 std::string fingerprint(unsigned int bits = 64) const;
44                 bool validate() const;
45         };
46 }
47
48 extern "C" {
49 typedef Fides::Certificate fides_certificate;
50 #else
51 typedef struct fides_certificate fides_certificate;
52 #endif
53
54 extern fides_certificate *fides_certificate_new(const fides_publickey *pub, struct timeval timestamp, const char *statement, const char *signature);
55 extern fides_certificate *fides_certificate_new_priv(const fides_privatekey *priv, struct timeval timestamp, const char *statement);
56 extern void fides_certificate_free(fides_certificate *c);
57
58 extern char *fides_certificate_to_string(fides_certificate *c);
59 extern char *fides_certificate_fingerprint(fides_certificate *c, unsigned int bits);
60 extern bool fides_certificate_validate(fides_certificate *c);
61
62 #ifdef __cplusplus
63 }
64 #endif
65
66 #endif