much more debug, back to initial handling; refs #169

master
Marc Wäckerlin 11 years ago
parent 86bdcc8c75
commit 25d01618f6
  1. 22
      src/qbrowserlib/log.cxx
  2. 36
      src/qbrowserlib/log.hxx
  3. 36
      src/smartcardauth.hxx
  4. 4
      src/swissbrowser_de.ts
  5. 4
      src/swissbrowser_en.ts
  6. 4
      src/swissbrowser_fr.ts
  7. 4
      src/swissbrowser_it.ts

@ -14,23 +14,29 @@ namespace qbrowserlib {
unsigned int Log::_level(0);
Log::Log(const void* addr, const std::string& name,
const std::string& file, unsigned long line):
_debug(DEBUG), _addr(addr), _name(name), _file(file), _line(line) {
if (!_debug) return;
const std::string& file, unsigned long line,
bool traceOpenClose):
_debug(DEBUG), _close(traceOpenClose),
_addr(addr), _name(name), _file(file), _line(line) {
if (!_debug || !_close) return;
++_level;
std::stringstream ss;
init(ss);
// init(ss);
indent(ss)<<"\\ "<<_name;
std::clog<<close(ss).str()<<std::endl;
// std::clog<<close(ss).str()<<std::endl;
if (!_dialog) _dialog = new LogDialog;
_dialog->append(*this, ss.str());
}
Log::~Log() throw() {
if (!_debug) return;
if (!_debug || !_close) return;
std::stringstream ss;
init(ss);
// init(ss);
indent(ss)<<"/ "<<_name;
std::clog<<close(ss).str()<<std::endl;
// std::clog<<close(ss).str()<<std::endl;
--_level;
if (!_dialog) _dialog = new LogDialog;
_dialog->append(*this, ss.str());
}
void Log::show(QWidget* p) {

@ -13,6 +13,7 @@
#include <QtGui/QDialog>
#endif
#include <stdexcept>
#include <sstream>
#include <iostream>
#include <iomanip>
@ -29,8 +30,6 @@ namespace qbrowserlib {
#ifndef LOG
#define LOG \
QBROWSERLIB_LOCAL_TRACER
// #define LOG
// qbrowserlib::Log(1, __PRETTY_FUNCTION__, __FILE__, __LINE__)
#endif
#ifndef TRC
@ -45,6 +44,29 @@ namespace qbrowserlib {
(0, __PRETTY_FUNCTION__, __FILE__, __LINE__)
#endif
#define CRYPTOKI_LOG(X) \
qbrowserlib::Log(0, __PRETTY_FUNCTION__, __FILE__, __LINE__, false)<<X
#define PCSC_LOG(X) \
qbrowserlib::Log(0, __PRETTY_FUNCTION__, __FILE__, __LINE__, false)<<X
#define OPENSSL_LOG(X) \
qbrowserlib::Log(0, __PRETTY_FUNCTION__, __FILE__, __LINE__, false)<<X
#define OPENSSL_CHECK(X) \
if (!X) { \
ERR_load_ENGINE_strings(); \
std::stringstream ss; \
for (unsigned int err(0); err=ERR_get_error();) { \
ss<<"Error: "<<ERR_error_string(err, 0)<<"; "; \
} \
ss<<"Command "<<#X<<" failed in function "<<__PRETTY_FUNCTION__ \
<<" in file "<<__FILE__<<":"<<__LINE__; \
qbrowserlib::Log(0, __PRETTY_FUNCTION__, __FILE__, __LINE__, false) \
<<ss.str(); \
throw std::runtime_error(ss.str()); \
}
class LogDialog;
class Log {
@ -56,7 +78,8 @@ namespace qbrowserlib {
public:
Log(const void* addr, const std::string& name,
const std::string& file, unsigned long line);
const std::string& file, unsigned long line,
bool traceOpenClose=true);
template<typename TYPE> Log& operator<<(TYPE arg);
@ -79,6 +102,7 @@ namespace qbrowserlib {
static LogDialog* _dialog;
static unsigned int _level;
bool _debug;
bool _close;
const void* _addr;
const std::string _name;
const std::string _file;
@ -193,11 +217,11 @@ namespace qbrowserlib {
template<typename TYPE> Log& Log::operator<<(TYPE arg) {
if (!_debug) return *this;
std::stringstream ss;
init(ss);
// init(ss);
indent(ss)<<""<<arg;
std::clog<<close(ss).str()<<std::endl;
// std::clog<<close(ss).str()<<std::endl;
if (!_dialog) _dialog = new LogDialog;
_dialog->append(*this, arg);
_dialog->append(*this, ss.str());
return *this;
}

@ -118,40 +118,24 @@ class CryptokiEngine: public QObject, public openssl::Engine {
return "CryptokiEngine_NAME";
}
virtual std::string rsaSign(const std::string& in, unsigned int type) {
virtual std::string rsaSign(const std::string& in, unsigned int type) try {
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");
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(data+in, CKM_RSA_PKCS);
return _privateKey->sign(in, CKM_RSA_PKCS);
} catch (const std::exception& x) {
LOG<<"signature failed";
LOG<<"signature failed, reason: "<<x.what();
certRequired(); // get new certificate
return _privateKey->sign(data+in, CKM_RSA_PKCS); // try again
return _privateKey->sign(in, CKM_RSA_PKCS); // try again
}
} catch (const std::exception& x) {
TRC; LOG<<"rsaSign failed, reason: "<<x.what();
throw;
}
private:

@ -724,12 +724,12 @@ openssl-%7 (%9) %10</source>
<context>
<name>QMessageBox</name>
<message>
<location filename="smartcardauth.hxx" line="261"/>
<location filename="smartcardauth.hxx" line="245"/>
<source>Authentication failed, please try again.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="smartcardauth.hxx" line="260"/>
<location filename="smartcardauth.hxx" line="244"/>
<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="261"/>
<location filename="smartcardauth.hxx" line="245"/>
<source>Authentication failed, please try again.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="smartcardauth.hxx" line="260"/>
<location filename="smartcardauth.hxx" line="244"/>
<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="261"/>
<location filename="smartcardauth.hxx" line="245"/>
<source>Authentication failed, please try again.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="smartcardauth.hxx" line="260"/>
<location filename="smartcardauth.hxx" line="244"/>
<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="261"/>
<location filename="smartcardauth.hxx" line="245"/>
<source>Authentication failed, please try again.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="smartcardauth.hxx" line="260"/>
<location filename="smartcardauth.hxx" line="244"/>
<source>Wrong PIN</source>
<translation type="unfinished"></translation>
</message>

Loading…
Cancel
Save