You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
871 B
C++
40 lines
871 B
C++
#include "eetsigner.h"
|
|
|
|
#include <QDebug>
|
|
#include <QStringList>
|
|
|
|
EetSigner::EetSigner(QObject *parent) : QObject(parent)
|
|
{
|
|
|
|
}
|
|
|
|
QByteArray EetSigner::signData(const QByteArray &data)
|
|
{
|
|
if (!QCA::isSupported("sha256"))
|
|
{
|
|
return QByteArray();
|
|
}
|
|
|
|
QCA::ConvertResult result;
|
|
QCA::KeyBundle bundle = QCA::KeyBundle::fromFile("/home/pepa/Dokumenty/dev/eet/01000003.p12", QCA::SecureArray("eet"), &result);
|
|
|
|
if (result != QCA::ConvertGood || bundle.isNull())
|
|
{
|
|
return QByteArray();
|
|
}
|
|
|
|
QCA::PrivateKey privKey = bundle.privateKey();
|
|
|
|
return privKey.signMessage(QCA::MemoryRegion(data), QCA::EMSA3_SHA256);
|
|
}
|
|
|
|
QByteArray EetSigner::sha1HashData(const QByteArray &data)
|
|
{
|
|
if (!QCA::isSupported("sha1"))
|
|
{
|
|
return QByteArray();
|
|
}
|
|
|
|
return QCA::Hash("sha1").hash(QCA::MemoryRegion(data)).toByteArray();
|
|
}
|