-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPublicKey.h
65 lines (55 loc) · 1.84 KB
/
PublicKey.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef DATA_PUBLIC_KEY_H
#define DATA_PUBLIC_KEY_H
#include <iostream>
#include <memory>
#include <vector>
namespace data
{
class PublicKeyImpl;
/**
* data::PublicKey represents an abstract public key. Actual implementation
* is hidden inside impl::PublicKeyImpl. This class provides method to load
* public key from the exponent and modulus and also method that verifies
* that the byte array was signed with the private key.
*
* @author Ilia Yastrebov
*/
class PublicKey
{
public:
/**
* Constructs public key from exponent and modulus
*
* @param exponent Public key exponent
* @param modulus Public key modulus
*/
PublicKey(const std::string & exponent, const std::string & modulus);
/**
* Dtor.
*/
~PublicKey();
/**
* Verifies message signature with server's public key
*
* @param messageDigest Message digest
* @param originalSignature Original signature
* @return true is signature verified positively, false otherwise
*/
bool verifySignature(const std::vector<signed char> & messageDigest,
const std::vector<signed char> & originalSignature) const;
/**
* Returns Public key of the authentication server.
*
* @return Public key of the authentication server.
* @throw exception if unable to load server public key
*/
static const PublicKey & getServerPublicKey();
private:
/** Hidden copy ctor and assignment operator */
PublicKey(const PublicKey &);
void operator = (const PublicKey &);
/** Pointer to the hidden implementation */
std::unique_ptr<data::PublicKeyImpl> impl_;
};
} // namespace data
#endif