1 #ifndef LIBFILEZILLA_ENCRYPTION_HEADER
2 #define LIBFILEZILLA_ENCRYPTION_HEADER
30 explicit operator bool()
const {
31 return key_.size() == key_size && salt_.size() == salt_size;
35 return key_ == rhs.key_ && salt_ == rhs.salt_;
39 return !(*
this == rhs);
43 return key_ < rhs.key_ || (key_ == rhs.key_ && salt_ < rhs.salt_);
46 std::string to_base64()
const;
47 static public_key from_base64(std::string_view
const& base64);
49 std::vector<uint8_t> key_;
50 std::vector<uint8_t> salt_;
70 static private_key from_password(std::vector<uint8_t>
const& password, std::vector<uint8_t>
const& salt);
71 static private_key from_password(std::string_view
const& password, std::vector<uint8_t>
const& salt)
73 return from_password(std::vector<uint8_t>(password.begin(), password.end()), salt);
76 explicit operator bool()
const {
77 return key_.size() == key_size && salt_.size() == salt_size;
80 std::vector<uint8_t>
const& salt()
const {
88 std::vector<uint8_t> shared_secret(
public_key const& pub)
const;
90 std::string to_base64()
const;
91 static private_key from_base64(std::string_view
const& base64);
94 std::vector<uint8_t> key_;
95 std::vector<uint8_t> salt_;
119 std::vector<uint8_t> FZ_PUBLIC_SYMBOL
encrypt(std::vector<uint8_t>
const& plain,
public_key const& pub,
bool authenticated =
true);
120 std::vector<uint8_t> FZ_PUBLIC_SYMBOL
encrypt(std::string_view
const& plain,
public_key const& pub,
bool authenticated =
true);
121 std::vector<uint8_t> FZ_PUBLIC_SYMBOL
encrypt(uint8_t
const* plain,
size_t size,
public_key const& pub,
bool authenticated =
true);
148 std::vector<uint8_t> FZ_PUBLIC_SYMBOL
decrypt(std::vector<uint8_t>
const& chiper,
private_key const& priv,
bool authenticated =
true);
149 std::vector<uint8_t> FZ_PUBLIC_SYMBOL
decrypt(std::string_view
const& chiper,
private_key const& priv,
bool authenticated =
true);
150 std::vector<uint8_t> FZ_PUBLIC_SYMBOL
decrypt(uint8_t
const* cipher,
size_t size,
private_key const& priv,
bool authenticated =
true);
std::vector< uint8_t > encrypt(std::vector< uint8_t > const &plain, public_key const &pub, bool authenticated=true)
Encrypt the plaintext to the given public key.
Represents a X25519 public key with associated salt.
Definition: encryption.hpp:21
std::vector< uint8_t > decrypt(std::vector< uint8_t > const &chiper, private_key const &priv, bool authenticated=true)
Decrypt the ciphertext using the given private key.
The namespace used by libfilezilla.
Definition: apply.hpp:16
Sets some global macros and further includes string.hpp.
Represents a X25519 private key with associated salt.
Definition: encryption.hpp:57