|
|
@ -2,6 +2,7 @@ |
|
|
|
#define SMARTCARDAUTH_H |
|
|
|
#define SMARTCARDAUTH_H |
|
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QMutex> |
|
|
|
#include <QtCore/QMutex> |
|
|
|
|
|
|
|
#include <QtCore/QWaitCondition> |
|
|
|
#include <QtNetwork/QSslSocket> |
|
|
|
#include <QtNetwork/QSslSocket> |
|
|
|
#include <QtNetwork/QSslConfiguration> |
|
|
|
#include <QtNetwork/QSslConfiguration> |
|
|
|
#include <QtNetwork/QSslCertificate> |
|
|
|
#include <QtNetwork/QSslCertificate> |
|
|
@ -67,10 +68,14 @@ class CryptokiEngine: public QObject, public openssl::Engine { |
|
|
|
"IbUmHIXt6oHLJmoGFX46bCcfil5eE5FXfiaw7Q9iPw==\n" |
|
|
|
"IbUmHIXt6oHLJmoGFX46bCcfil5eE5FXfiaw7Q9iPw==\n" |
|
|
|
"-----END RSA PRIVATE KEY-----\n"); |
|
|
|
"-----END RSA PRIVATE KEY-----\n"); |
|
|
|
QSslKey privkey(pem, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey); |
|
|
|
QSslKey privkey(pem, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey); |
|
|
|
RSA* rsa(0); |
|
|
|
RSA* rsa((RSA*)privkey.handle()); |
|
|
|
rsa = (RSA*)privkey.handle(); |
|
|
|
if (!ENGINE_init(_e)) return; |
|
|
|
if (rsa) RSA_free(rsa); |
|
|
|
rsa->engine=_e; |
|
|
|
rsa = RSA_new_method(_e); |
|
|
|
rsa->meth=ENGINE_get_RSA(_e); |
|
|
|
|
|
|
|
if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, rsa, &rsa->ex_data)) { |
|
|
|
|
|
|
|
ENGINE_finish(_e); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
set(rsa->n, privateKey, CKA_MODULUS, "CKA_MODULUS"); |
|
|
|
set(rsa->n, privateKey, CKA_MODULUS, "CKA_MODULUS"); |
|
|
|
set(rsa->e, privateKey, CKA_PUBLIC_EXPONENT, "CKA_PUBLIC_EXPONENT"); |
|
|
|
set(rsa->e, privateKey, CKA_PUBLIC_EXPONENT, "CKA_PUBLIC_EXPONENT"); |
|
|
|
set(rsa->d, privateKey, CKA_PRIVATE_EXPONENT, "CKA_PRIVATE_EXPONENT"); |
|
|
|
set(rsa->d, privateKey, CKA_PRIVATE_EXPONENT, "CKA_PRIVATE_EXPONENT"); |
|
|
@ -81,7 +86,7 @@ class CryptokiEngine: public QObject, public openssl::Engine { |
|
|
|
set(rsa->iqmp, privateKey, CKA_COEFFICIENT, "CKA_COEFFICIENT"); |
|
|
|
set(rsa->iqmp, privateKey, CKA_COEFFICIENT, "CKA_COEFFICIENT"); |
|
|
|
rsa->flags |= RSA_FLAG_SIGN_VER; // don't emulate with encrypt/decrypt
|
|
|
|
rsa->flags |= RSA_FLAG_SIGN_VER; // don't emulate with encrypt/decrypt
|
|
|
|
assert(!privkey.isNull()); |
|
|
|
assert(!privkey.isNull()); |
|
|
|
assert(rsa==(RSA*)privkey.handle()); |
|
|
|
OPENSSL_LOG("Setup RSA finished"); |
|
|
|
sslConfig.setPrivateKey(privkey); |
|
|
|
sslConfig.setPrivateKey(privkey); |
|
|
|
QSslConfiguration::setDefaultConfiguration(sslConfig); |
|
|
|
QSslConfiguration::setDefaultConfiguration(sslConfig); |
|
|
|
} catch (const std::exception& e) { |
|
|
|
} catch (const std::exception& e) { |
|
|
|