-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathQSigner.h
More file actions
69 lines (58 loc) · 1.97 KB
/
QSigner.h
File metadata and controls
69 lines (58 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* QDigiDoc4
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#pragma once
#include <QtCore/QThread>
#include <digidocpp/crypto/Signer.h>
#include <QCryptographicHash>
#include <functional>
class QCryptoBackend;
class QSmartCard;
class QSslKey;
class TokenData;
class QSigner final: public QThread, public digidoc::Signer
{
Q_OBJECT
public:
explicit QSigner(QObject *parent = nullptr);
~QSigner() final;
QList<TokenData> cache() const;
digidoc::X509Cert cert() const final;
QByteArray decrypt(std::function<QByteArray (QCryptoBackend *)> &&func);
QSslKey key() const;
void logout() const;
void selectCard(const TokenData &token);
std::vector<unsigned char> sign( const std::string &method,
const std::vector<unsigned char> &digest) const final;
QSmartCard * smartcard() const;
TokenData tokenauth() const;
TokenData tokensign() const;
void setCachePIN(bool cache_pin);
Q_SIGNALS:
void cacheChanged();
void authDataChanged( const TokenData &token );
void signDataChanged( const TokenData &token );
void error( const QString &msg );
private:
static bool cardsOrder(const TokenData &s1, const TokenData &s2);
quint8 login(const TokenData &cert) const;
static QCryptographicHash::Algorithm methodToNID(const std::string &method);
void run() final;
class Private;
Private *d;
};