diff --git a/swisssurfer/src/smartcardauth.hxx b/swisssurfer/src/smartcardauth.hxx index b347503..e950b80 100644 --- a/swisssurfer/src/smartcardauth.hxx +++ b/swisssurfer/src/smartcardauth.hxx @@ -55,6 +55,7 @@ class CryptokiEngine: public QObject, public openssl::Engine { sslConfig.setLocalCertificate(localcert); assert(localcert.isValid()); + //RSA_set_default_method(ENGINE_get_RSA(_e)); QByteArray pem // empty dummy key for qt object instantiation ("-----BEGIN RSA PRIVATE KEY-----\n" "MIIBOwIBAAJBAMH2yqAGeVNPdgeZ2GoHo31m9aUxZ7QfK2Go2qLTahLpQ3UL1C8G\n" @@ -67,21 +68,20 @@ class CryptokiEngine: public QObject, public openssl::Engine { "-----END RSA PRIVATE KEY-----\n"); QSslKey privkey(pem, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey); RSA* rsa(0); - do { - rsa = ((RSA*)privkey.handle()); - //! @todo call RSA_free(rsa); later, see #82 - rsa = RSA_new_method(_e); - set(rsa->n, privateKey, CKA_MODULUS, "CKA_MODULUS"); - set(rsa->e, privateKey, CKA_PUBLIC_EXPONENT, "CKA_PUBLIC_EXPONENT"); - set(rsa->d, privateKey, CKA_PRIVATE_EXPONENT, "CKA_PRIVATE_EXPONENT"); - set(rsa->p, privateKey, CKA_PRIME_1, "CKA_PRIME_1"); - set(rsa->q, privateKey, CKA_PRIME_2, "CKA_PRIME_2"); - set(rsa->dmp1, privateKey, CKA_EXPONENT_1, "CKA_EXPONENT_1"); - set(rsa->dmq1, privateKey, CKA_EXPONENT_2, "CKA_EXPONENT_2"); - set(rsa->iqmp, privateKey, CKA_COEFFICIENT, "CKA_COEFFICIENT"); - rsa->flags |= RSA_FLAG_SIGN_VER; // don't emulate with encrypt/decrypt - assert(!privkey.isNull()); - } while (rsa!=(RSA*)privkey.handle()); + rsa = (RSA*)privkey.handle(); + if (rsa) RSA_free(rsa); + rsa = RSA_new_method(_e); + set(rsa->n, privateKey, CKA_MODULUS, "CKA_MODULUS"); + set(rsa->e, privateKey, CKA_PUBLIC_EXPONENT, "CKA_PUBLIC_EXPONENT"); + set(rsa->d, privateKey, CKA_PRIVATE_EXPONENT, "CKA_PRIVATE_EXPONENT"); + set(rsa->p, privateKey, CKA_PRIME_1, "CKA_PRIME_1"); + set(rsa->q, privateKey, CKA_PRIME_2, "CKA_PRIME_2"); + set(rsa->dmp1, privateKey, CKA_EXPONENT_1, "CKA_EXPONENT_1"); + set(rsa->dmq1, privateKey, CKA_EXPONENT_2, "CKA_EXPONENT_2"); + set(rsa->iqmp, privateKey, CKA_COEFFICIENT, "CKA_COEFFICIENT"); + rsa->flags |= RSA_FLAG_SIGN_VER; // don't emulate with encrypt/decrypt + assert(!privkey.isNull()); + assert(rsa==(RSA*)privkey.handle()); sslConfig.setPrivateKey(privkey); QSslConfiguration::setDefaultConfiguration(sslConfig); } catch (const std::exception& e) { diff --git a/swisssurfer/src/swisssurfer_de.ts b/swisssurfer/src/swisssurfer_de.ts index 0cadf95..cc7c02a 100644 --- a/swisssurfer/src/swisssurfer_de.ts +++ b/swisssurfer/src/swisssurfer_de.ts @@ -675,12 +675,12 @@ p, li { white-space: pre-wrap; } QMessageBox - + Wrong PIN - + Authentication failed, please try again. @@ -688,7 +688,7 @@ p, li { white-space: pre-wrap; } QObject - + Usage: %1 [OPTIONS...] [<url> ...] Options: -h, --help show this help text @@ -736,27 +736,27 @@ Environment: - + Cannot read PEM certificate from file: %1 - + Read PEM certificates from file: %1 - + Cannot read PEM RSA key from file: %1 - + Read private key from file: %1 - + Too few arguments. Try: %1 --help diff --git a/swisssurfer/src/swisssurfer_en.ts b/swisssurfer/src/swisssurfer_en.ts index 8d19c68..8344c8f 100644 --- a/swisssurfer/src/swisssurfer_en.ts +++ b/swisssurfer/src/swisssurfer_en.ts @@ -660,12 +660,12 @@ p, li { white-space: pre-wrap; } QMessageBox - + Wrong PIN - + Authentication failed, please try again. @@ -673,7 +673,7 @@ p, li { white-space: pre-wrap; } QObject - + Usage: %1 [OPTIONS...] [<url> ...] Options: -h, --help show this help text @@ -699,27 +699,27 @@ Environment: - + Cannot read PEM certificate from file: %1 - + Read PEM certificates from file: %1 - + Cannot read PEM RSA key from file: %1 - + Read private key from file: %1 - + Too few arguments. Try: %1 --help diff --git a/swisssurfer/src/swisssurfer_fr.ts b/swisssurfer/src/swisssurfer_fr.ts index 0cadf95..cc7c02a 100644 --- a/swisssurfer/src/swisssurfer_fr.ts +++ b/swisssurfer/src/swisssurfer_fr.ts @@ -675,12 +675,12 @@ p, li { white-space: pre-wrap; } QMessageBox - + Wrong PIN - + Authentication failed, please try again. @@ -688,7 +688,7 @@ p, li { white-space: pre-wrap; } QObject - + Usage: %1 [OPTIONS...] [<url> ...] Options: -h, --help show this help text @@ -736,27 +736,27 @@ Environment: - + Cannot read PEM certificate from file: %1 - + Read PEM certificates from file: %1 - + Cannot read PEM RSA key from file: %1 - + Read private key from file: %1 - + Too few arguments. Try: %1 --help diff --git a/swisssurfer/src/swisssurfer_it.ts b/swisssurfer/src/swisssurfer_it.ts index 0cadf95..cc7c02a 100644 --- a/swisssurfer/src/swisssurfer_it.ts +++ b/swisssurfer/src/swisssurfer_it.ts @@ -675,12 +675,12 @@ p, li { white-space: pre-wrap; } QMessageBox - + Wrong PIN - + Authentication failed, please try again. @@ -688,7 +688,7 @@ p, li { white-space: pre-wrap; } QObject - + Usage: %1 [OPTIONS...] [<url> ...] Options: -h, --help show this help text @@ -736,27 +736,27 @@ Environment: - + Cannot read PEM certificate from file: %1 - + Read PEM certificates from file: %1 - + Cannot read PEM RSA key from file: %1 - + Read private key from file: %1 - + Too few arguments. Try: %1 --help