1 /* Certificate.h - Fides Certificate class
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_CERTIFICATE_H__
19 #define __FIDES_CERTIFICATE_H__
22 #include "publickey.h"
23 #include "privatekey.h"
32 /// Public key that signed this certificate.
33 const PublicKey *signer;
34 struct timeval timestamp;
35 std::string statement;
36 std::string signature;
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);
42 std::string to_string() const;
43 std::string fingerprint(unsigned int bits = 64) const;
44 bool validate() const;
49 typedef Fides::Certificate fides_certificate;
51 typedef struct fides_certificate fides_certificate;
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);
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);