Install a pkg-config file.
[fides] / lib / privatekey.h
1 /* PrivateKey.h - Fides private key 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_PRIVATEKEY_H__
19 #define __FIDES_PRIVATEKEY_H__
20
21 #include "publickey.h"
22
23 #ifdef __cplusplus
24 #include <string>
25 #include <botan/botan.h>
26 #include <botan/ecdsa.h>
27
28 namespace Fides {
29         class PrivateKey: public PublicKey {
30                 Botan::ECDSA_PrivateKey *priv;
31
32                 public:
33                 PrivateKey();
34                 ~PrivateKey();
35
36                 void load_private(std::istream &in);
37                 void save_private(std::ostream &out) const;
38                 void load_private(const std::string &filename);
39                 void save_private(const std::string &filename) const;
40                 void generate(const std::string &field);
41                 void generate(unsigned int bits = 224);
42                 std::string sign(const std::string &data) const;
43         };
44 }
45
46 extern "C" {
47 typedef Fides::PrivateKey fides_privatekey;
48 #else
49 typedef struct fides_privatekey fides_privatekey;
50 #endif
51
52 extern fides_privatekey *fides_privatekey_new();
53 extern void fides_privatekey_free(fides_privatekey *k);
54
55 extern void fides_privatekey_load_public(fides_privatekey *k, const char *filename);
56 extern void fides_privatekey_save_public(fides_privatekey *k, const char *filename);
57 extern void fides_privatekey_load(fides_privatekey *k, const char *filename);
58 extern void fides_privatekey_save(fides_privatekey *k, const char *filename);
59 extern void fides_privatekey_generate_field(fides_privatekey *k, const char *field);
60 extern void fides_privatekey_generate(fides_privatekey *k, unsigned int bits);
61 extern char *fides_privatekey_sign(fides_privatekey *k, const char *data);
62 #ifdef __cplusplus
63 }
64 #endif
65
66 #endif