libfilezilla
Toggle main menu visibility
Loading...
Searching...
No Matches
lib
libfilezilla
signature.hpp
Go to the documentation of this file.
1
#ifndef LIBFILEZILLA_SIGNATURE_HEADER
2
#define LIBFILEZILLA_SIGNATURE_HEADER
3
9
10
#include "
libfilezilla.hpp
"
11
12
#include <vector>
13
#include <string>
14
#include <cstdint>
15
16
namespace
fz
{
17
22
class
FZ_PUBLIC_SYMBOL
public_verification_key
23
{
24
public
:
25
enum
{
26
key_size = 32
27
};
28
29
explicit
operator
bool()
const
{
30
return
key_.size() == key_size;
31
}
32
33
bool
operator==(
public_verification_key
const
& rhs)
const
{
34
return
key_ == rhs.key_;
35
}
36
37
bool
operator!=(
public_verification_key
const
& rhs)
const
{
38
return
!(*
this
== rhs);
39
}
40
41
bool
operator<(
public_verification_key
const
& rhs)
const
{
42
return
key_ < rhs.key_;
43
}
44
45
std::string to_base64()
const
;
46
static
public_verification_key
from_base64(std::string_view
const
& base64);
47
48
std::vector<uint8_t> key_;
49
};
50
55
class
FZ_PUBLIC_SYMBOL
private_signing_key
56
{
57
public
:
58
enum
{
59
key_size = 32
60
};
61
63
static
private_signing_key
generate
();
64
65
explicit
operator
bool()
const
{
66
return
key_.size() == key_size;
67
}
68
70
public_verification_key
pubkey
()
const
;
71
72
std::vector<uint8_t>
const
& data()
const
{
73
return
key_;
74
}
75
76
std::string to_base64()
const
;
// Keep secret!
77
static
private_signing_key
from_base64(std::string_view
const
& base64);
78
79
private
:
80
std::vector<uint8_t> key_;
81
};
82
83
enum
{
84
signature_size = 64
85
};
86
88
std::vector<uint8_t> FZ_PUBLIC_SYMBOL
sign
(std::vector<uint8_t>
const
& message,
private_signing_key
const
& priv,
bool
include_message =
true
);
89
std::vector<uint8_t> FZ_PUBLIC_SYMBOL
sign
(std::string_view
const
& message,
private_signing_key
const
& priv,
bool
include_message =
true
);
90
std::vector<uint8_t> FZ_PUBLIC_SYMBOL
sign
(uint8_t
const
* message,
size_t
const
size,
private_signing_key
const
& priv,
bool
include_message =
true
);
91
93
bool
FZ_PUBLIC_SYMBOL
verify
(std::vector<uint8_t>
const
& message,
public_verification_key
const
& pub);
94
bool
FZ_PUBLIC_SYMBOL
verify
(std::string_view
const
& message,
public_verification_key
const
& pub);
95
bool
FZ_PUBLIC_SYMBOL
verify
(uint8_t
const
* message,
size_t
const
size,
public_verification_key
const
& pub);
96
98
bool
FZ_PUBLIC_SYMBOL
verify
(std::vector<uint8_t>
const
& message, std::vector<uint8_t>
const
& signature,
public_verification_key
const
& pub);
99
bool
FZ_PUBLIC_SYMBOL
verify
(std::string_view
const
& message, std::string_view
const
& signature,
public_verification_key
const
& pub);
100
bool
FZ_PUBLIC_SYMBOL
verify
(uint8_t
const
* message,
size_t
const
message_size, uint8_t
const
* signature,
size_t
const
sig_size,
public_verification_key
const
& pub);
101
102
}
103
104
#endif
fz::private_signing_key
Represents a private key to sign message with using Ed25519.
Definition
signature.hpp:56
fz::private_signing_key::generate
static private_signing_key generate()
Generates a random private key.
fz::private_signing_key::pubkey
public_verification_key pubkey() const
Gets the public key corresponding to the private key.
fz::public_verification_key
Represents a public key to verify messages signed using Ed25519.
Definition
signature.hpp:23
libfilezilla.hpp
Sets some global macros and further includes string.hpp.
fz
The namespace used by libfilezilla.
Definition
apply.hpp:17
fz::verify
bool verify(std::vector< uint8_t > const &message, public_verification_key const &pub)
Verify a message with attached signature. Returns true iff it has been signed by the private key corr...
fz::sign
std::vector< uint8_t > sign(std::vector< uint8_t > const &message, private_signing_key const &priv, bool include_message=true)
Returns the message with the signature appended, created using the passed private key.
Generated by
1.17.0