next try, idea stolen from https://svn.eesti.ee/projektid/idkaart_public/trunk/qdigidoc/common/QPKCS11.cpp; refs #169
This commit is contained in:
@@ -121,14 +121,35 @@ class CryptokiEngine: public QObject, public openssl::Engine {
|
||||
virtual std::string rsaSign(const std::string& in, unsigned int type) {
|
||||
TRC; LOG<<"log; type="<<type<<"; size="<<in.size();
|
||||
LOG<<crypto::readable(in).c_str();
|
||||
std::string data;
|
||||
switch( type ) {
|
||||
case NID_sha1:
|
||||
data += QString(QByteArray::fromHex("3021300906052b0e03021a05000414")).toStdString();
|
||||
break;
|
||||
case NID_sha224:
|
||||
data += QString(QByteArray::fromHex("302d300d06096086480165030402040500041c")).toStdString();
|
||||
break;
|
||||
case NID_sha256:
|
||||
data += QString(QByteArray::fromHex("3031300d060960864801650304020105000420")).toStdString();
|
||||
break;
|
||||
case NID_sha384:
|
||||
data += QString(QByteArray::fromHex("3041300d060960864801650304020205000430")).toStdString();
|
||||
break;
|
||||
case NID_sha512:
|
||||
data += QString(QByteArray::fromHex("3051300d060960864801650304020305000440")).toStdString();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
// see ticket #169
|
||||
// if (type != NID_md5_sha1) throw std::runtime_error("wrong sign type");
|
||||
// if (in.size() != 36) throw std::runtime_error("wrong msg size to sign");
|
||||
LOG<<"ready to sign";
|
||||
try {
|
||||
return _privateKey->sign(in, CKM_RSA_PKCS);
|
||||
return _privateKey->sign(data+in, CKM_RSA_PKCS);
|
||||
} catch (const std::exception& x) {
|
||||
LOG<<"signature failed";
|
||||
certRequired(); // get new certificate
|
||||
return _privateKey->sign(in, CKM_RSA_PKCS); // try again
|
||||
return _privateKey->sign(data+in, CKM_RSA_PKCS); // try again
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -724,12 +724,12 @@ openssl-%7 (%9) %10</source>
|
||||
<context>
|
||||
<name>QMessageBox</name>
|
||||
<message>
|
||||
<location filename="smartcardauth.hxx" line="240"/>
|
||||
<location filename="smartcardauth.hxx" line="261"/>
|
||||
<source>Authentication failed, please try again.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="smartcardauth.hxx" line="239"/>
|
||||
<location filename="smartcardauth.hxx" line="260"/>
|
||||
<source>Wrong PIN</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@@ -724,12 +724,12 @@ openssl-%7 (%9) %10</source>
|
||||
<context>
|
||||
<name>QMessageBox</name>
|
||||
<message>
|
||||
<location filename="smartcardauth.hxx" line="240"/>
|
||||
<location filename="smartcardauth.hxx" line="261"/>
|
||||
<source>Authentication failed, please try again.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="smartcardauth.hxx" line="239"/>
|
||||
<location filename="smartcardauth.hxx" line="260"/>
|
||||
<source>Wrong PIN</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@@ -724,12 +724,12 @@ openssl-%7 (%9) %10</source>
|
||||
<context>
|
||||
<name>QMessageBox</name>
|
||||
<message>
|
||||
<location filename="smartcardauth.hxx" line="240"/>
|
||||
<location filename="smartcardauth.hxx" line="261"/>
|
||||
<source>Authentication failed, please try again.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="smartcardauth.hxx" line="239"/>
|
||||
<location filename="smartcardauth.hxx" line="260"/>
|
||||
<source>Wrong PIN</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@@ -724,12 +724,12 @@ openssl-%7 (%9) %10</source>
|
||||
<context>
|
||||
<name>QMessageBox</name>
|
||||
<message>
|
||||
<location filename="smartcardauth.hxx" line="240"/>
|
||||
<location filename="smartcardauth.hxx" line="261"/>
|
||||
<source>Authentication failed, please try again.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="smartcardauth.hxx" line="239"/>
|
||||
<location filename="smartcardauth.hxx" line="260"/>
|
||||
<source>Wrong PIN</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
Reference in New Issue
Block a user