supla-device
Loading...
Searching...
No Matches
src
supla
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
#ifndef SUPLA_TEST
21
22
/*
23
* Simple wrapper for Nettle RSA methods used to verify sha256 hash
24
* against another hash signed with RSA private key.
25
*/
26
27
#define RSA_NUM_BYTES 512
28
#define RSA_PUBLIC_EXPONENT 65537
29
30
#include <supla/sha256.h>
31
#include <nettle/rsa.h>
32
#include <nettle/bignum.h>
33
34
namespace
Supla {
35
36
class
RsaVerificator {
37
public
:
38
explicit
RsaVerificator(
const
uint8_t* publicKeyBytes);
39
~RsaVerificator();
40
bool
verify(
Supla::Sha256
*hash,
const
uint8_t *signatureBytes);
41
protected
:
42
struct
rsa_public_key publicKey;
43
mpz_t signature;
44
};
45
46
};
// namespace Supla
47
48
#endif
// SUPLA_TEST
49
#endif
// SRC_SUPLA_RSA_VERIFICATOR_H_
Supla::Sha256
Definition
sha256.h:30
Generated by
1.16.1