11#include <botan/pk_keys.h>
12#include <botan/pk_ops_fwd.h>
13#include <botan/symkey.h>
18class RandomNumberGenerator;
35 std::vector<uint8_t>
encrypt(
const uint8_t in[],
size_t length,
38 return enc(in, length, rng);
47 template<
typename Alloc>
48 std::vector<uint8_t>
encrypt(
const std::vector<uint8_t, Alloc>& in,
51 return enc(in.data(), in.size(), rng);
74 virtual
std::vector<uint8_t> enc(const uint8_t[],
size_t,
100 template<
typename Alloc>
103 return decrypt(in.data(), in.size());
113 decrypt_or_random(
const uint8_t in[],
115 size_t expected_pt_len,
133 decrypt_or_random(
const uint8_t in[],
135 size_t expected_pt_len,
137 const uint8_t required_content_bytes[],
138 const uint8_t required_content_offsets[],
139 size_t required_contents)
const;
156 virtual
secure_vector<uint8_t> do_decrypt(uint8_t& valid_mask,
157 const uint8_t in[],
size_t in_len) const = 0;
180 const std::string& emsa,
182 const std::string& provider =
"");
198 std::vector<uint8_t> sign_message(const uint8_t in[],
size_t length,
202 return this->signature(rng);
211 template<
typename Alloc>
212 std::vector<uint8_t>
sign_message(
const std::vector<uint8_t, Alloc>& in,
215 return sign_message(in.data(), in.size(), rng);
229 void update(
const uint8_t in[],
size_t length);
235 template<
typename Alloc>
236 void update(
const std::vector<uint8_t, Alloc>& in)
238 update(in.data(), in.size());
269 size_t signature_length()
const;
272 std::unique_ptr<PK_Ops::Signature> m_op;
274 size_t m_parts, m_part_size;
293 const std::string& emsa,
295 const std::string& provider =
"");
312 bool verify_message(const uint8_t msg[],
size_t msg_length,
313 const uint8_t sig[],
size_t sig_length);
320 template<typename Alloc, typename Alloc2>
321 bool verify_message(const
std::vector<uint8_t, Alloc>& msg,
322 const
std::vector<uint8_t, Alloc2>& sig)
324 return verify_message(msg.data(), msg.size(),
325 sig.data(), sig.size());
341 void update(
const uint8_t msg_part[],
size_t length);
348 template<
typename Alloc>
349 void update(
const std::vector<uint8_t, Alloc>& in)
351 update(in.data(), in.size());
370 bool check_signature(
const uint8_t sig[],
size_t length);
378 template<
typename Alloc>
381 return check_signature(sig.data(), sig.size());
391 std::unique_ptr<PK_Ops::Verification> m_op;
393 size_t m_parts, m_part_size;
412 const std::string& kdf,
413 const std::string& provider =
"");
435 const uint8_t params[],
436 size_t params_len) const;
446 const
std::vector<uint8_t>& in,
447 const uint8_t params[],
448 size_t params_len)
const
450 return derive_key(key_len, in.data(), in.size(),
462 const uint8_t in[],
size_t in_len,
463 const std::string& params =
"")
const
465 return derive_key(key_len, in, in_len,
477 const std::vector<uint8_t>& in,
478 const std::string& params =
"")
const
480 return derive_key(key_len, in.data(), in.size(),
490 size_t agreed_value_size()
const;
493 std::unique_ptr<PK_Ops::Key_Agreement> m_op;
503 size_t maximum_input_size()
const override;
514 const std::string& padding,
515 const std::string& provider =
"");
528 size_t ciphertext_length(
size_t ptext_len)
const override;
530 std::vector<uint8_t> enc(
const uint8_t[],
size_t,
533 std::unique_ptr<PK_Ops::Encryption> m_op;
551 const std::string& eme,
552 const std::string& provider =
"");
554 size_t plaintext_length(
size_t ptext_len)
const override;
564 size_t in_len)
const override;
566 std::unique_ptr<PK_Ops::Decryption> m_op;
584 const std::string& kem_param =
"",
585 const std::string& provider =
"");
605 size_t desired_shared_key_len,
607 const uint8_t salt[],
618 template<
typename Alloc>
621 size_t desired_shared_key_len,
623 const std::vector<uint8_t, Alloc>& salt)
625 this->
encrypt(out_encapsulated_key,
627 desired_shared_key_len,
629 salt.data(), salt.size());
642 size_t desired_shared_key_len,
645 this->
encrypt(out_encapsulated_key,
647 desired_shared_key_len,
654 std::unique_ptr<PK_Ops::KEM_Encryption> m_op;
672 const std::string& kem_param =
"",
673 const std::string& provider =
"");
691 size_t encap_key_len,
692 size_t desired_shared_key_len,
693 const uint8_t salt[],
704 size_t encap_key_len,
705 size_t desired_shared_key_len)
707 return this->
decrypt(encap_key, encap_key_len,
708 desired_shared_key_len,
719 template<
typename Alloc1,
typename Alloc2>
721 size_t desired_shared_key_len,
722 const std::vector<uint8_t, Alloc2>& salt)
724 return this->
decrypt(encap_key.data(), encap_key.size(),
725 desired_shared_key_len,
726 salt.data(), salt.size());
730 std::unique_ptr<PK_Ops::KEM_Decryption> m_op;
PK_Decryptor_EME(PK_Decryptor_EME &&)=delete
PK_Decryptor_EME(const PK_Decryptor_EME &)=delete
PK_Decryptor_EME & operator=(PK_Decryptor_EME &&)=delete
PK_Decryptor_EME & operator=(const PK_Decryptor_EME &)=delete
virtual ~PK_Decryptor()=default
virtual size_t plaintext_length(size_t ctext_len) const =0
secure_vector< uint8_t > decrypt(const std::vector< uint8_t, Alloc > &in) const
PK_Decryptor(const PK_Decryptor &)=delete
PK_Decryptor(PK_Decryptor &&) noexcept=delete
PK_Encryptor_EME & operator=(PK_Encryptor_EME &&)=delete
PK_Encryptor_EME(PK_Encryptor_EME &&)=delete
PK_Encryptor_EME & operator=(const PK_Encryptor_EME &)=delete
PK_Encryptor_EME(const PK_Encryptor_EME &)=delete
PK_Encryptor(PK_Encryptor &&) noexcept=delete
virtual size_t maximum_input_size() const =0
virtual size_t ciphertext_length(size_t ctext_len) const =0
std::vector< uint8_t > encrypt(const std::vector< uint8_t, Alloc > &in, RandomNumberGenerator &rng) const
virtual ~PK_Encryptor()=default
std::vector< uint8_t > encrypt(const uint8_t in[], size_t length, RandomNumberGenerator &rng) const
PK_Encryptor(const PK_Encryptor &)=delete
PK_KEM_Decryptor(PK_KEM_Decryptor &&)=delete
PK_KEM_Decryptor & operator=(const PK_KEM_Decryptor &)=delete
PK_KEM_Decryptor(const PK_KEM_Decryptor &)=delete
secure_vector< uint8_t > decrypt(const uint8_t encap_key[], size_t encap_key_len, size_t desired_shared_key_len)
secure_vector< uint8_t > decrypt(const std::vector< uint8_t, Alloc1 > &encap_key, size_t desired_shared_key_len, const std::vector< uint8_t, Alloc2 > &salt)
PK_KEM_Decryptor & operator=(PK_KEM_Decryptor &&)=delete
void encrypt(secure_vector< uint8_t > &out_encapsulated_key, secure_vector< uint8_t > &out_shared_key, size_t desired_shared_key_len, Botan::RandomNumberGenerator &rng, const std::vector< uint8_t, Alloc > &salt)
PK_KEM_Encryptor(PK_KEM_Encryptor &&)=delete
PK_KEM_Encryptor & operator=(PK_KEM_Encryptor &&)=delete
void encrypt(secure_vector< uint8_t > &out_encapsulated_key, secure_vector< uint8_t > &out_shared_key, size_t desired_shared_key_len, Botan::RandomNumberGenerator &rng)
PK_KEM_Encryptor(const PK_KEM_Encryptor &)=delete
PK_KEM_Encryptor & operator=(const PK_KEM_Encryptor &)=delete
PK_Key_Agreement & operator=(const PK_Key_Agreement &)=delete
PK_Key_Agreement & operator=(PK_Key_Agreement &&)=delete
SymmetricKey derive_key(size_t key_len, const uint8_t in[], size_t in_len, const std::string ¶ms="") const
SymmetricKey derive_key(size_t key_len, const std::vector< uint8_t > &in, const std::string ¶ms="") const
PK_Key_Agreement(const PK_Key_Agreement &)=delete
PK_Key_Agreement(PK_Key_Agreement &&) noexcept
void update(const std::string &in)
std::vector< uint8_t > sign_message(const std::vector< uint8_t, Alloc > &in, RandomNumberGenerator &rng)
void set_output_format(Signature_Format format)
PK_Signer(const PK_Signer &)=delete
PK_Signer(PK_Signer &&) noexcept=delete
void update(const std::vector< uint8_t, Alloc > &in)
bool check_signature(const std::vector< uint8_t, Alloc > &sig)
PK_Verifier(const PK_Verifier &)=delete
void update(const std::string &in)
PK_Verifier(PK_Verifier &&) noexcept=delete
void update(const std::vector< uint8_t, Alloc > &in)
int(* update)(CTX *, const void *, CC_LONG len)
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
std::string decrypt(const uint8_t input[], size_t input_len, const std::string &passphrase)
std::string encrypt(const uint8_t input[], size_t input_len, const std::string &passphrase, RandomNumberGenerator &rng)
std::vector< T, secure_allocator< T > > secure_vector
const uint8_t * cast_char_ptr_to_uint8(const char *s)