libhomegear-base  0.7
Base library for Homegear and Homegear family modules.
Sign.h
Go to the documentation of this file.
1 /* Copyright 2013-2019 Homegear GmbH
2  *
3  * libhomegear-base is free software: you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public License as
5  * published by the Free Software Foundation, either version 3 of the
6  * License, or (at your option) any later version.
7  *
8  * libhomegear-base is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with libhomegear-base. If not, see
15  * <http://www.gnu.org/licenses/>.
16  *
17  * In addition, as a special exception, the copyright holders give
18  * permission to link the code of portions of this program with the
19  * OpenSSL library under certain conditions as described in each
20  * individual source file, and distribute linked combinations
21  * including the two.
22  * You must obey the GNU Lesser General Public License in all respects
23  * for all of the code used other than OpenSSL. If you modify
24  * file(s) with this exception, you may extend this exception to your
25  * version of the file(s), but you are not obligated to do so. If you
26  * do not wish to do so, delete this exception statement from your
27  * version. If you delete this exception statement from all source
28  * files in the program, then also delete it here.
29 */
30 
31 #ifndef BASELIB_SECURITY_SIGN_H_
32 #define BASELIB_SECURITY_SIGN_H_
33 
34 #include "../Exception.h"
35 #include <gnutls/gnutls.h>
36 #include <gnutls/abstract.h>
37 
38 #include <memory>
39 #include <vector>
40 #include <cstdint>
41 
42 namespace BaseLib
43 {
44 namespace Security
45 {
46 
52 class SignException : public Exception
53 {
54 public:
55  SignException(std::string message) : Exception(message) {}
56 };
57 
58 class Sign
59 {
60 private:
61  gnutls_privkey_t _privateKey = nullptr;
62  gnutls_pubkey_t _publicKey = nullptr;
63 public:
70  Sign(const std::string& privateKey, const std::string& publicKey);
71  ~Sign();
72 
80  std::vector<char> sign(const std::vector<char>& data);
81 
90  bool verify(const std::vector<char>& data, const std::vector<char>& signature);
91 };
92 
93 typedef std::shared_ptr<Sign> PSign;
94 
95 }
96 }
97 #endif
Definition: BaseLib.cpp:34
Definition: Sign.h:58
SignException(std::string message)
Definition: Sign.h:55
Exception class for GnuTls.
Definition: Sign.h:52
std::shared_ptr< Sign > PSign
Definition: Sign.h:93
Base class for all exceptions defined in Homegear.
Definition: Exception.h:41