aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/prov
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/prov
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/prov')
-rw-r--r--src/lib/prov/openssl/openssl_ec.cpp2
-rw-r--r--src/lib/prov/openssl/openssl_rsa.cpp4
-rw-r--r--src/lib/prov/pkcs11/p11_rsa.cpp4
3 files changed, 9 insertions, 1 deletions
diff --git a/src/lib/prov/openssl/openssl_ec.cpp b/src/lib/prov/openssl/openssl_ec.cpp
index 33f277d5a..5da466c0c 100644
--- a/src/lib/prov/openssl/openssl_ec.cpp
+++ b/src/lib/prov/openssl/openssl_ec.cpp
@@ -232,7 +232,7 @@ class OpenSSL_ECDSA_Signing_Operation final : public PK_Ops::Signature_with_EMSA
m_order_bytes = (m_order_bits + 7) / 8;
}
- size_t signature_length() const { return 2*m_order_bytes; }
+ size_t signature_length() const override { return 2*m_order_bytes; }
secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator&) override
diff --git a/src/lib/prov/openssl/openssl_rsa.cpp b/src/lib/prov/openssl/openssl_rsa.cpp
index cf9c2b52b..8108526a1 100644
--- a/src/lib/prov/openssl/openssl_rsa.cpp
+++ b/src/lib/prov/openssl/openssl_rsa.cpp
@@ -57,6 +57,8 @@ class OpenSSL_RSA_Encryption_Operation final : public PK_Ops::Encryption
m_bits = 8 * (n_size() - pad_overhead) - 1;
}
+ size_t ciphertext_length(size_t) const override { return ::RSA_size(m_openssl_rsa.get()); }
+
size_t max_input_bits() const override { return m_bits; };
secure_vector<uint8_t> encrypt(const uint8_t msg[], size_t msg_len,
@@ -110,6 +112,8 @@ class OpenSSL_RSA_Decryption_Operation final : public PK_Ops::Decryption
throw OpenSSL_Error("d2i_RSAPrivateKey");
}
+ size_t plaintext_length(size_t) const override { return ::RSA_size(m_openssl_rsa.get()); }
+
secure_vector<uint8_t> decrypt(uint8_t& valid_mask,
const uint8_t msg[], size_t msg_len) override
{
diff --git a/src/lib/prov/pkcs11/p11_rsa.cpp b/src/lib/prov/pkcs11/p11_rsa.cpp
index 65bcd2d22..225e49bb2 100644
--- a/src/lib/prov/pkcs11/p11_rsa.cpp
+++ b/src/lib/prov/pkcs11/p11_rsa.cpp
@@ -131,6 +131,8 @@ class PKCS11_RSA_Decryption_Operation final : public PK_Ops::Decryption
m_bits = m_key.get_n().bits() - 1;
}
+ size_t plaintext_length(size_t) const override { return m_key.get_n().bytes(); }
+
secure_vector<uint8_t> decrypt(uint8_t& valid_mask, const uint8_t ciphertext[], size_t ciphertext_len) override
{
valid_mask = 0;
@@ -177,6 +179,8 @@ class PKCS11_RSA_Encryption_Operation final : public PK_Ops::Encryption
m_bits = 8 * (key.get_n().bytes() - m_mechanism.padding_size()) - 1;
}
+ size_t ciphertext_length(size_t) const override { return m_key.get_n().bytes(); }
+
size_t max_input_bits() const override
{
return m_bits;