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