aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/pubkey.h
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-08-10 12:44:55 -0400
committerJack Lloyd <[email protected]>2018-08-10 12:44:55 -0400
commit87e4cd8c71511837b38406802f6e92e32b1890e9 (patch)
tree000aed5da6cfabd3009937a88cafb959f3988ea1 /src/lib/pubkey/pubkey.h
parent256cfa3be098fb45d5c2de047f88786e88051e73 (diff)
Add functions to get size of PK ciphertext,plaintext
Needed for https://github.com/strongswan/strongswan/pull/109
Diffstat (limited to 'src/lib/pubkey/pubkey.h')
-rw-r--r--src/lib/pubkey/pubkey.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/lib/pubkey/pubkey.h b/src/lib/pubkey/pubkey.h
index 8328861fd..a1404135d 100644
--- a/src/lib/pubkey/pubkey.h
+++ b/src/lib/pubkey/pubkey.h
@@ -66,6 +66,11 @@ class BOTAN_PUBLIC_API(2,0) PK_Encryptor
*/
virtual size_t maximum_input_size() const = 0;
+ /**
+ * Return an upper bound on the ciphertext length
+ */
+ virtual size_t ciphertext_length(size_t ctext_len) const = 0;
+
PK_Encryptor() = default;
virtual ~PK_Encryptor() = default;
@@ -140,6 +145,12 @@ class BOTAN_PUBLIC_API(2,0) PK_Decryptor
const uint8_t required_content_offsets[],
size_t required_contents) const;
+ /**
+ * Return an upper bound on the plaintext length for a particular
+ * ciphertext input length
+ */
+ virtual size_t plaintext_length(size_t ctext_len) const = 0;
+
PK_Decryptor() = default;
virtual ~PK_Decryptor() = default;
@@ -547,6 +558,12 @@ class BOTAN_PUBLIC_API(2,0) PK_Encryptor_EME final : public PK_Encryptor
PK_Encryptor_EME& operator=(const PK_Encryptor_EME&) = delete;
PK_Encryptor_EME(const PK_Encryptor_EME&) = delete;
+
+ /**
+ * Return an upper bound on the ciphertext length for a particular
+ * plaintext input length
+ */
+ size_t ciphertext_length(size_t ptext_len) const override;
private:
std::vector<uint8_t> enc(const uint8_t[], size_t,
RandomNumberGenerator& rng) const override;
@@ -586,6 +603,8 @@ class BOTAN_PUBLIC_API(2,0) PK_Decryptor_EME final : public PK_Decryptor
PK_Decryptor_EME(key, system_rng(), eme, provider) {}
#endif
+ size_t plaintext_length(size_t ptext_len) const override;
+
~PK_Decryptor_EME();
PK_Decryptor_EME& operator=(const PK_Decryptor_EME&) = delete;
PK_Decryptor_EME(const PK_Decryptor_EME&) = delete;