1 /* PrivateKey.h - Fides private key 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_PRIVATEKEY_H__
19 #define __FIDES_PRIVATEKEY_H__
21 #include "publickey.h"
25 #include <botan/botan.h>
26 #include <botan/ecdsa.h>
29 class PrivateKey: public PublicKey {
30 Botan::ECDSA_PrivateKey *priv;
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;
47 typedef Fides::PrivateKey fides_privatekey;
49 typedef struct fides_privatekey fides_privatekey;
52 extern fides_privatekey *fides_privatekey_new();
53 extern void fides_privatekey_free(fides_privatekey *k);
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);