diff options
author | Jack Lloyd <[email protected]> | 2016-11-12 01:53:56 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-11-12 01:53:56 -0500 |
commit | 9c72dabc9dc73e2603c22dfce48611b5b626238b (patch) | |
tree | bda4f84f78bfbdd28e2199ee8f9998b08cc3c634 /src/lib/prov/openssl | |
parent | 618f890fd7ede74c728612ca8bc590c72ee353f1 (diff) |
Pubkey cleanups
Add Public_Key::key_length usable for policy checking (as in
TLS::Policy::check_peer_key_acceptable)
Remove Public_Key::max_input_bits because it didn't make much sense
for most algorithms actually.
Remove message_parts and message_part_size from PK_Ops
Diffstat (limited to 'src/lib/prov/openssl')
-rw-r--r-- | src/lib/prov/openssl/openssl.h | 2 | ||||
-rw-r--r-- | src/lib/prov/openssl/openssl_ec.cpp | 9 | ||||
-rw-r--r-- | src/lib/prov/openssl/openssl_rsa.cpp | 2 |
3 files changed, 4 insertions, 9 deletions
diff --git a/src/lib/prov/openssl/openssl.h b/src/lib/prov/openssl/openssl.h index 8b2b41c1d..e28fb2931 100644 --- a/src/lib/prov/openssl/openssl.h +++ b/src/lib/prov/openssl/openssl.h @@ -8,7 +8,7 @@ #ifndef BOTAN_INTERNAL_OPENSSL_H__ #define BOTAN_INTERNAL_OPENSSL_H__ -#include <botan/internal/pk_ops.h> +#include <botan/pk_ops_fwd.h> #include <botan/secmem.h> #include <botan/exceptn.h> #include <memory> diff --git a/src/lib/prov/openssl/openssl_ec.cpp b/src/lib/prov/openssl/openssl_ec.cpp index ca4352370..51d24a119 100644 --- a/src/lib/prov/openssl/openssl_ec.cpp +++ b/src/lib/prov/openssl/openssl_ec.cpp @@ -117,8 +117,6 @@ class OpenSSL_ECDSA_Verification_Operation : public PK_Ops::Verification_with_EM m_order_bits = ::EC_GROUP_get_degree(group); } - size_t message_parts() const override { return 2; } - size_t message_part_size() const override { return (m_order_bits + 7) / 8; } size_t max_input_bits() const override { return m_order_bits; } bool with_recovery() const override { return false; } @@ -126,7 +124,8 @@ class OpenSSL_ECDSA_Verification_Operation : public PK_Ops::Verification_with_EM bool verify(const byte msg[], size_t msg_len, const byte sig_bytes[], size_t sig_len) override { - if(sig_len != message_part_size() * message_parts()) + const size_t order_bytes = (m_order_bits + 7) / 8; + if(sig_len != 2 * order_bytes) return false; std::unique_ptr<ECDSA_SIG, std::function<void (ECDSA_SIG*)>> sig(nullptr, ECDSA_SIG_free); @@ -172,7 +171,7 @@ class OpenSSL_ECDSA_Signing_Operation : public PK_Ops::Signature_with_EMSA if(!sig) throw OpenSSL_Error("ECDSA_do_sign"); - const size_t order_bytes = message_part_size(); + const size_t order_bytes = (m_order_bits + 7) / 8; const size_t r_bytes = BN_num_bytes(sig->r); const size_t s_bytes = BN_num_bytes(sig->s); secure_vector<byte> sigval(2*order_bytes); @@ -181,8 +180,6 @@ class OpenSSL_ECDSA_Signing_Operation : public PK_Ops::Signature_with_EMSA return sigval; } - size_t message_parts() const override { return 2; } - size_t message_part_size() const override { return (m_order_bits + 7) / 8; } size_t max_input_bits() const override { return m_order_bits; } private: diff --git a/src/lib/prov/openssl/openssl_rsa.cpp b/src/lib/prov/openssl/openssl_rsa.cpp index b03b747aa..77f74fab6 100644 --- a/src/lib/prov/openssl/openssl_rsa.cpp +++ b/src/lib/prov/openssl/openssl_rsa.cpp @@ -106,8 +106,6 @@ class OpenSSL_RSA_Decryption_Operation : public PK_Ops::Decryption throw OpenSSL_Error("d2i_RSAPrivateKey"); } - size_t max_input_bits() const override { return ::BN_num_bits(m_openssl_rsa->n) - 1; } - secure_vector<byte> decrypt(byte& valid_mask, const byte msg[], size_t msg_len) override { |