supla-device
Loading...
Searching...
No Matches
rsa_verificator.h
1/*
2 Copyright (C) AC SOFTWARE SP. Z O.O.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 This program 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 General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15*/
16
17#ifndef SRC_SUPLA_RSA_VERIFICATOR_H_
18#define SRC_SUPLA_RSA_VERIFICATOR_H_
19
20/*
21 * Simple wrapper for Nettle RSA methods used to verify sha256 hash
22 * against another hash signed with RSA private key.
23 */
24
25#define RSA_NUM_BYTES 512
26#define RSA_PUBLIC_EXPONENT 65537
27
28#include <supla/sha256.h>
29#include <nettle/rsa.h>
30#include <nettle/bignum.h>
31
32namespace Supla {
33
34class RsaVerificator {
35 public:
36 explicit RsaVerificator(const uint8_t* publicKeyBytes);
37 ~RsaVerificator();
38 bool verify(Supla::Sha256 *hash, const uint8_t *signatureBytes);
39 protected:
40 struct rsa_public_key publicKey;
41 mpz_t signature;
42};
43
44}; // namespace Supla
45
46#endif // SRC_SUPLA_RSA_VERIFICATOR_H_
Definition sha256.h:28