diff options
author | Jack Lloyd <[email protected]> | 2019-08-23 11:34:22 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-08-23 11:34:22 -0400 |
commit | f759cf670513ca8e501d6bbdaafc746dcf73d90b (patch) | |
tree | 72fad985b17efb930c6db9608c67a800a21be924 /src/lib/prov | |
parent | 3387f13dc427f1eb9e99149dacffaa33be5f3c02 (diff) | |
parent | d32f8a4352c013f036e9b2d05946f052119454dc (diff) |
Merge GH #2070 Precompute RSA Montgomery params
Diffstat (limited to 'src/lib/prov')
-rw-r--r-- | src/lib/prov/pkcs11/p11_rsa.cpp | 29 | ||||
-rw-r--r-- | src/lib/prov/pkcs11/p11_rsa.h | 9 |
2 files changed, 19 insertions, 19 deletions
diff --git a/src/lib/prov/pkcs11/p11_rsa.cpp b/src/lib/prov/pkcs11/p11_rsa.cpp index 991eabc42..08f4115d1 100644 --- a/src/lib/prov/pkcs11/p11_rsa.cpp +++ b/src/lib/prov/pkcs11/p11_rsa.cpp @@ -35,14 +35,14 @@ RSA_PublicKeyGenerationProperties::RSA_PublicKeyGenerationProperties(Ulong bits) } PKCS11_RSA_PublicKey::PKCS11_RSA_PublicKey(Session& session, ObjectHandle handle) - : Object(session, handle) + : Object(session, handle), + RSA_PublicKey(BigInt::decode(get_attribute_value(AttributeType::Modulus)), + BigInt::decode(get_attribute_value(AttributeType::PublicExponent))) { - m_n = BigInt::decode(get_attribute_value(AttributeType::Modulus)); - m_e = BigInt::decode(get_attribute_value(AttributeType::PublicExponent)); } PKCS11_RSA_PublicKey::PKCS11_RSA_PublicKey(Session& session, const RSA_PublicKeyImportProperties& pubkey_props) - : RSA_PublicKey(pubkey_props.modulus(), pubkey_props.pub_exponent()), Object(session, pubkey_props) + : Object(session, pubkey_props), RSA_PublicKey(pubkey_props.modulus(), pubkey_props.pub_exponent()) {} @@ -55,22 +55,22 @@ RSA_PrivateKeyImportProperties::RSA_PrivateKeyImportProperties(const BigInt& mod PKCS11_RSA_PrivateKey::PKCS11_RSA_PrivateKey(Session& session, ObjectHandle handle) - : Object(session, handle) + : Object(session, handle), + RSA_PublicKey(BigInt::decode(get_attribute_value(AttributeType::Modulus)), + BigInt::decode(get_attribute_value(AttributeType::PublicExponent))) { - m_n = BigInt::decode(get_attribute_value(AttributeType::Modulus)); - m_e = BigInt::decode(get_attribute_value(AttributeType::PublicExponent)); } PKCS11_RSA_PrivateKey::PKCS11_RSA_PrivateKey(Session& session, const RSA_PrivateKeyImportProperties& priv_key_props) - : Object(session, priv_key_props) + : Object(session, priv_key_props), + RSA_PublicKey(priv_key_props.modulus(), + BigInt::decode(get_attribute_value(AttributeType::PublicExponent))) { - m_n = priv_key_props.modulus(); - m_e = BigInt::decode(get_attribute_value(AttributeType::PublicExponent)); } PKCS11_RSA_PrivateKey::PKCS11_RSA_PrivateKey(Session& session, uint32_t bits, - const RSA_PrivateKeyGenerationProperties& priv_key_props) - : RSA_PublicKey(), Object(session) + const RSA_PrivateKeyGenerationProperties& priv_key_props) + : Object(session), RSA_PublicKey() { RSA_PublicKeyGenerationProperties pub_key_props(bits); pub_key_props.set_encrypt(true); @@ -86,8 +86,9 @@ PKCS11_RSA_PrivateKey::PKCS11_RSA_PrivateKey(Session& session, uint32_t bits, this->reset_handle(priv_key_handle); - m_n = BigInt::decode(get_attribute_value(AttributeType::Modulus)); - m_e = BigInt::decode(get_attribute_value(AttributeType::PublicExponent)); + BigInt n = BigInt::decode(get_attribute_value(AttributeType::Modulus)); + BigInt e = BigInt::decode(get_attribute_value(AttributeType::PublicExponent)); + RSA_PublicKey::init(std::move(n), std::move(e)); } RSA_PrivateKey PKCS11_RSA_PrivateKey::export_key() const diff --git a/src/lib/prov/pkcs11/p11_rsa.h b/src/lib/prov/pkcs11/p11_rsa.h index 7531a00cc..f17d6c2ee 100644 --- a/src/lib/prov/pkcs11/p11_rsa.h +++ b/src/lib/prov/pkcs11/p11_rsa.h @@ -12,6 +12,7 @@ #include <botan/p11_session.h> #include <botan/p11_object.h> #include <botan/pk_keys.h> +#include <botan/bigint.h> #if defined(BOTAN_HAS_RSA) #include <botan/rsa.h> @@ -63,8 +64,7 @@ class BOTAN_PUBLIC_API(2,0) RSA_PublicKeyImportProperties final : public PublicK }; /// Represents a PKCS#11 RSA public key -class BOTAN_PUBLIC_API(2,0) PKCS11_RSA_PublicKey : public RSA_PublicKey, - public Object +class BOTAN_PUBLIC_API(2,0) PKCS11_RSA_PublicKey : public Object, public RSA_PublicKey { public: static const ObjectClass Class = ObjectClass::PublicKey; @@ -170,9 +170,8 @@ class BOTAN_PUBLIC_API(2,0) RSA_PrivateKeyGenerationProperties final : public Pr }; /// Represents a PKCS#11 RSA private key -class BOTAN_PUBLIC_API(2,0) PKCS11_RSA_PrivateKey final : public Private_Key, - public RSA_PublicKey, - public Object +class BOTAN_PUBLIC_API(2,0) PKCS11_RSA_PrivateKey final : + public Object, public Private_Key, public RSA_PublicKey { public: static const ObjectClass Class = ObjectClass::PrivateKey; |