Implemented PKP and BKP code generation. Certificate path temporary hardcoded.
							parent
							
								
									47b89cfa61
								
							
						
					
					
						commit
						1fd6bfde3e
					
				@ -0,0 +1,39 @@
 | 
			
		||||
#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();
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,24 @@
 | 
			
		||||
#ifndef EETSIGNER_H
 | 
			
		||||
#define EETSIGNER_H
 | 
			
		||||
 | 
			
		||||
#include <QObject>
 | 
			
		||||
#include <QByteArray>
 | 
			
		||||
#include <Qca-qt5/QtCrypto/QtCrypto>
 | 
			
		||||
 | 
			
		||||
class EetSigner : public QObject
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
public:
 | 
			
		||||
    explicit EetSigner(QObject *parent = 0);
 | 
			
		||||
    QByteArray signData(const QByteArray &data);
 | 
			
		||||
    QByteArray sha1HashData(const QByteArray &data);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    QCA::Initializer m_qcaInit;
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
 | 
			
		||||
public slots:
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // EETSIGNER_H
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue