From 4661e874f4a7535c12e610dbaee7c2471dda1e8d Mon Sep 17 00:00:00 2001 From: kh1 <qt-info@nokia.com> Date: Mon, 11 Oct 2010 13:01:01 +0200 Subject: [PATCH] Fix missing member initialization. Task-number: QTCREATORBUG-2694 Reviewed-by: ck --- .../coreplugin/ssh/sshkeygenerator.cpp | 21 ++++++++++++------- src/plugins/coreplugin/ssh/sshkeygenerator.h | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/plugins/coreplugin/ssh/sshkeygenerator.cpp b/src/plugins/coreplugin/ssh/sshkeygenerator.cpp index 976d0094c78..985a6e256f1 100644 --- a/src/plugins/coreplugin/ssh/sshkeygenerator.cpp +++ b/src/plugins/coreplugin/ssh/sshkeygenerator.cpp @@ -49,21 +49,28 @@ namespace Core { using namespace Botan; using namespace Internal; -SshKeyGenerator::SshKeyGenerator() { } +SshKeyGenerator::SshKeyGenerator() + : m_type(Rsa) + , m_format(OpenSsl) +{ +} bool SshKeyGenerator::generateKeys(KeyType type, PrivateKeyFormat format, int keySize) { + m_type = type; + m_format = format; + try { AutoSeeded_RNG rng; KeyPtr key; - if (type == Rsa) + if (m_type == Rsa) key = KeyPtr(new RSA_PrivateKey(rng, keySize)); else key = KeyPtr(new DSA_PrivateKey(rng, DL_Group(rng, DL_Group::Strong, keySize))); - return format == Pkcs8 - ? generatePkcs8Keys(key) : generateOpenSslKeys(key, type); + return m_format == Pkcs8 + ? generatePkcs8Keys(key) : generateOpenSslKeys(key); } catch (Botan::Exception &e) { m_error = tr("Error generating key: %1").arg(e.what()); return false; @@ -95,12 +102,12 @@ void SshKeyGenerator::generatePkcs8Key(const KeyPtr &key, bool privateKey) pipe.message_count() - 1); } -bool SshKeyGenerator::generateOpenSslKeys(const KeyPtr &key, KeyType type) +bool SshKeyGenerator::generateOpenSslKeys(const KeyPtr &key) { QList<BigInt> publicParams; QList<BigInt> allParams; QByteArray keyId; - if (type == Rsa) { + if (m_type == Rsa) { const QSharedPointer<RSA_PrivateKey> rsaKey = key.dynamicCast<RSA_PrivateKey>(); publicParams << rsaKey->get_e() << rsaKey->get_n(); @@ -130,7 +137,7 @@ bool SshKeyGenerator::generateOpenSslKeys(const KeyPtr &key, KeyType type) encoder.encode(b); encoder.end_cons(); const char * const label - = type == Rsa ? "RSA PRIVATE KEY" : "DSA PRIVATE KEY"; + = m_type == Rsa ? "RSA PRIVATE KEY" : "DSA PRIVATE KEY"; m_privateKey = QByteArray(PEM_Code::encode (encoder.get_contents(), label).c_str()); return true; diff --git a/src/plugins/coreplugin/ssh/sshkeygenerator.h b/src/plugins/coreplugin/ssh/sshkeygenerator.h index ada06150a04..12fb1aa8d1b 100644 --- a/src/plugins/coreplugin/ssh/sshkeygenerator.h +++ b/src/plugins/coreplugin/ssh/sshkeygenerator.h @@ -61,7 +61,7 @@ private: bool generatePkcs8Keys(const KeyPtr &key); void generatePkcs8Key(const KeyPtr &key, bool privateKey); - bool generateOpenSslKeys(const KeyPtr &key, KeyType type); + bool generateOpenSslKeys(const KeyPtr &key); QString m_error; QByteArray m_publicKey; -- GitLab