show PIN attempts if known, nothing if unknown; refs #37

master
Marc Wäckerlin 14 years ago
parent b92ec55a79
commit 114878a9d0
  1. 5
      swisssurfer/src/pinentry.hxx
  2. 90
      swisssurfer/src/pinentry.ui
  3. 2
      swisssurfer/src/qmake.pro.in
  4. 61
      swisssurfer/src/smartcardauth.hxx
  5. 29
      swisssurfer/src/swisssurfer_de.ts
  6. 29
      swisssurfer/src/swisssurfer_en.ts
  7. 29
      swisssurfer/src/swisssurfer_fr.ts
  8. 29
      swisssurfer/src/swisssurfer_it.ts

@ -40,6 +40,11 @@ class PinEntry: public QDialog, public Ui::PinEntry {
_issuerCa->setVisible(_issuerCa->text().size());
_issuerCaLabel->setVisible(_issuerCa->text().size());
}
PinEntry& retries(int num) {
_pinstatus->setCurrentIndex(num==-1?1:(num==-2?2:0));
_retries->setText(tr("there are %1 PIN attempts left").arg(num));
return *this;
}
QString pin() const {
return _pin->text();
}

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>351</width>
<height>369</height>
<width>435</width>
<height>412</height>
</rect>
</property>
<property name="windowTitle">
@ -23,7 +23,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Please enter your Certificate PIN to authenticate:</string>
<string>Please enter your PIN to unlock Certificate:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@ -159,31 +159,77 @@
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="1">
<widget class="QLabel" name="_tries">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>You have %1 tries left</string>
</property>
<property name="wordWrap">
<bool>true</bool>
<widget class="QStackedWidget" name="_pinstatus">
<property name="currentIndex">
<number>2</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="_status">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="_status">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'DejaVu Serif'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:24pt; color:#00b900;&quot;&gt;✔&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="_retries">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>there are %1 PIN attempts left</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="_status_2">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'DejaVu Serif'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'sans-serif'; font-size:24pt; color:#ff0000;&quot;&gt;✘&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="_tries_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>certificate is bad or locked</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_3"/>
</widget>
</item>
</layout>

@ -5,6 +5,8 @@ QMAKE_LIBS += -lproxyface -lcryptoki++ -lssl -lcrypto
unix {
!macx {
CONFIG += debug
QMAKE_INCDIR += /usr/include/PCSC
QMAKE_INCDIR += /usr/local/include/PCSC
}
}
macx {

@ -11,6 +11,7 @@
#include <pinentry.hxx>
#include <cryptoki.hxx>
#include <pcsc.hxx>
#include <openssl-engine.hxx>
#include <openssl.hxx>
@ -56,20 +57,13 @@ class CryptokiEngine: public QObject, public openssl::Engine {
QByteArray pem // empty dummy key for qt object instantiation
("-----BEGIN RSA PRIVATE KEY-----\n"
"MIIBOwIBAAJBAMH2yqAGeVNPdgeZ2GoHo"
"31m9aUxZ7QfK2Go2qLTahLpQ3UL1C8G\n"
"LkuMS8SNK0ZGfRMalIpIhv6bW5l3kjogO"
"ncCAwEAAQJABVGECtFCoGMsZFb2lSmy\n"
"dOzOzYHGSy0TnnDn1dEgNnZ8sIljElPtU"
"zm9dyXs2P3ICL1sOd7qjpzfJeyxknDL\n"
"AQIhAO5iKdLmhyuW+EDEH19vDs1Pmqs3/"
"ZnT5UgUiJnTJqz3AiEA0ExIfUOCnxq2\n"
"a3Z46KEivcr8JB2P9VqouBbVryiq/oECI"
"QDj8bPCejMoiEzMSX0iWWTTB9qC/KAg\n"
"FtF4skHIrXKfEwIgPCs86Uo+Ch2aQjKHv"
"JMHSRHAgeI0OmiEwiB+e0lhE4ECIQDd\n"
"IbUmHIXt6oHLJmoGFX46bCcfil5eE5FXf"
"iaw7Q9iPw==\n"
"MIIBOwIBAAJBAMH2yqAGeVNPdgeZ2GoHo31m9aUxZ7QfK2Go2qLTahLpQ3UL1C8G\n"
"LkuMS8SNK0ZGfRMalIpIhv6bW5l3kjogOncCAwEAAQJABVGECtFCoGMsZFb2lSmy\n"
"dOzOzYHGSy0TnnDn1dEgNnZ8sIljElPtUzm9dyXs2P3ICL1sOd7qjpzfJeyxknDL\n"
"AQIhAO5iKdLmhyuW+EDEH19vDs1Pmqs3/ZnT5UgUiJnTJqz3AiEA0ExIfUOCnxq2\n"
"a3Z46KEivcr8JB2P9VqouBbVryiq/oECIQDj8bPCejMoiEzMSX0iWWTTB9qC/KAg\n"
"FtF4skHIrXKfEwIgPCs86Uo+Ch2aQjKHvJMHSRHAgeI0OmiEwiB+e0lhE4ECIQDd\n"
"IbUmHIXt6oHLJmoGFX46bCcfil5eE5FXfiaw7Q9iPw==\n"
"-----END RSA PRIVATE KEY-----\n");
QSslKey privkey(pem, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
RSA* rsa(0);
@ -200,7 +194,8 @@ class SmartCardAuth: public QObject {
PinEntry pinEntry(QSslCertificate(QByteArray(c.data.data(),
c.data.size()),
QSsl::Der), _parent);
while (pinEntry.exec()==PinEntry::Accepted)
while (pinEntry.retries(retries(c.slot->slotinfo().slotDescription))
.exec()==PinEntry::Accepted)
try {
_session = // session login with pin
std::auto_ptr<cryptoki::Session>
@ -228,6 +223,42 @@ class SmartCardAuth: public QObject {
}
}
private:
int retries(const std::string& name) try {
qDebug()<<__PRETTY_FUNCTION__<<name.c_str();
pcsc::Connection pcsc;
pcsc::Connection::Reader& reader(pcsc.reader(name));
#ifndef Q_OS_MAC
pcsc::Connection::Reader::Transaction lock(reader);
#endif
// first try to read version info
if (reader.transmit(0x00, 0xA4, 0x08, 0x0C, "\x3f\x00\x56\x49", 4)
!= std::string("\x90\x00", 2) || !reader) return -2;
std::string res(reader.transmit(0x00, 0xB0, 0x00, 0x00));
qDebug()<<" T E X T I S : "<<res.substr(6, res[5]).c_str();
if (res.substr(0, 2)!=std::string("\x90\x00", 2) ||
res.substr(6, res[5]) == "PZ2007") return -2;
if (retCode(reader.transmit(0x00, 0xA4, 0x00, 0x0C)) == 0x9000) {
int value(retCode(reader.transmit(0x00, 0x20, 0x00, 0x81)));
if ((value&0x63C0)==0x63C0) return value&0x0F;
} else {
qDebug()<<"**** ERROR in select MF while reading pin status";
}
return -1; // locked
} catch (const std::exception& x) {
qDebug()<<"**** ERROR while reading pin status: "<<x.what();
return -2;
}
int retCode(const std::string& res) {
if (res.size()>=2)
return ((((unsigned int)(unsigned char)res[res.size()-2])*256)
+((unsigned int)(unsigned char)res[res.size()-1]));
else
return -1;
}
private:
struct CertInfo {

@ -510,8 +510,8 @@ Compiled: qt-%5</oldsource>
</message>
<message>
<location filename="pinentry.ui" line="26"/>
<source>Please enter your Certificate PIN to authenticate:</source>
<oldsource>Please enter your SwissSign Certificate PIN to authenticate yourself:</oldsource>
<source>Please enter your PIN to unlock Certificate:</source>
<oldsource>Please enter your Certificate PIN to authenticate:</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
@ -565,12 +565,27 @@ Compiled: qt-%5</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pinentry.ui" line="171"/>
<source>You have %1 tries left</source>
<location filename="pinentry.ui" line="192"/>
<location filename="pinentry.hxx" line="45"/>
<source>there are %1 PIN attempts left</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pinentry.ui" line="181"/>
<location filename="pinentry.ui" line="206"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;DejaVu Serif&apos;; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;sans-serif&apos;; font-size:24pt; color:#ff0000;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pinentry.ui" line="223"/>
<source>certificate is bad or locked</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pinentry.ui" line="175"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
@ -582,12 +597,12 @@ p, li { white-space: pre-wrap; }
<context>
<name>QMessageBox</name>
<message>
<location filename="smartcardauth.hxx" line="221"/>
<location filename="smartcardauth.hxx" line="216"/>
<source>Wrong PIN</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="smartcardauth.hxx" line="222"/>
<location filename="smartcardauth.hxx" line="217"/>
<source>Authentication failed, please try again.</source>
<translation type="unfinished"></translation>
</message>

@ -510,8 +510,8 @@ Compiled: qt-%5</oldsource>
</message>
<message>
<location filename="pinentry.ui" line="26"/>
<source>Please enter your Certificate PIN to authenticate:</source>
<oldsource>Please enter your SwissSign Certificate PIN to authenticate yourself:</oldsource>
<source>Please enter your PIN to unlock Certificate:</source>
<oldsource>Please enter your Certificate PIN to authenticate:</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
@ -565,12 +565,27 @@ Compiled: qt-%5</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pinentry.ui" line="171"/>
<source>You have %1 tries left</source>
<location filename="pinentry.ui" line="192"/>
<location filename="pinentry.hxx" line="45"/>
<source>there are %1 PIN attempts left</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pinentry.ui" line="181"/>
<location filename="pinentry.ui" line="206"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;DejaVu Serif&apos;; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;sans-serif&apos;; font-size:24pt; color:#ff0000;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pinentry.ui" line="223"/>
<source>certificate is bad or locked</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pinentry.ui" line="175"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
@ -582,12 +597,12 @@ p, li { white-space: pre-wrap; }
<context>
<name>QMessageBox</name>
<message>
<location filename="smartcardauth.hxx" line="221"/>
<location filename="smartcardauth.hxx" line="216"/>
<source>Wrong PIN</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="smartcardauth.hxx" line="222"/>
<location filename="smartcardauth.hxx" line="217"/>
<source>Authentication failed, please try again.</source>
<translation type="unfinished"></translation>
</message>

@ -510,8 +510,8 @@ Compiled: qt-%5</oldsource>
</message>
<message>
<location filename="pinentry.ui" line="26"/>
<source>Please enter your Certificate PIN to authenticate:</source>
<oldsource>Please enter your SwissSign Certificate PIN to authenticate yourself:</oldsource>
<source>Please enter your PIN to unlock Certificate:</source>
<oldsource>Please enter your Certificate PIN to authenticate:</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
@ -565,12 +565,27 @@ Compiled: qt-%5</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pinentry.ui" line="171"/>
<source>You have %1 tries left</source>
<location filename="pinentry.ui" line="192"/>
<location filename="pinentry.hxx" line="45"/>
<source>there are %1 PIN attempts left</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pinentry.ui" line="181"/>
<location filename="pinentry.ui" line="206"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;DejaVu Serif&apos;; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;sans-serif&apos;; font-size:24pt; color:#ff0000;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pinentry.ui" line="223"/>
<source>certificate is bad or locked</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pinentry.ui" line="175"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
@ -582,12 +597,12 @@ p, li { white-space: pre-wrap; }
<context>
<name>QMessageBox</name>
<message>
<location filename="smartcardauth.hxx" line="221"/>
<location filename="smartcardauth.hxx" line="216"/>
<source>Wrong PIN</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="smartcardauth.hxx" line="222"/>
<location filename="smartcardauth.hxx" line="217"/>
<source>Authentication failed, please try again.</source>
<translation type="unfinished"></translation>
</message>

@ -510,8 +510,8 @@ Compiled: qt-%5</oldsource>
</message>
<message>
<location filename="pinentry.ui" line="26"/>
<source>Please enter your Certificate PIN to authenticate:</source>
<oldsource>Please enter your SwissSign Certificate PIN to authenticate yourself:</oldsource>
<source>Please enter your PIN to unlock Certificate:</source>
<oldsource>Please enter your Certificate PIN to authenticate:</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
@ -565,12 +565,27 @@ Compiled: qt-%5</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pinentry.ui" line="171"/>
<source>You have %1 tries left</source>
<location filename="pinentry.ui" line="192"/>
<location filename="pinentry.hxx" line="45"/>
<source>there are %1 PIN attempts left</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pinentry.ui" line="181"/>
<location filename="pinentry.ui" line="206"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;DejaVu Serif&apos;; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;sans-serif&apos;; font-size:24pt; color:#ff0000;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pinentry.ui" line="223"/>
<source>certificate is bad or locked</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="pinentry.ui" line="175"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
@ -582,12 +597,12 @@ p, li { white-space: pre-wrap; }
<context>
<name>QMessageBox</name>
<message>
<location filename="smartcardauth.hxx" line="221"/>
<location filename="smartcardauth.hxx" line="216"/>
<source>Wrong PIN</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="smartcardauth.hxx" line="222"/>
<location filename="smartcardauth.hxx" line="217"/>
<source>Authentication failed, please try again.</source>
<translation type="unfinished"></translation>
</message>

Loading…
Cancel
Save