4
1
mirror of https://github.com/QuasarApp/Heart.git synced 2025-05-09 16:09:49 +00:00

added the signer template class

This commit is contained in:
Andrei Yankovich 2022-08-06 22:02:02 +03:00
parent da35a09878
commit 13249254b9
12 changed files with 117 additions and 30 deletions

@ -1,9 +0,0 @@
/*
* Copyright (C) 2021-2022 QuasarApp.
* Distributed under the lgplv3 software license, see the accompanying
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
#include "asynckeysauth.h"

@ -1,9 +0,0 @@
//#
//# Copyright (C) 2021-2022 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#include "authecdsa.h"

@ -16,6 +16,7 @@
#include <openssl/err.h>
#include <QCryptographicHash>
#include <QDataStream>
#include <QIODevice>
#include <QVector>
#include <quasarapp.h>
@ -199,8 +200,6 @@ bool ECDSASSL11::checkSign(const QByteArray &inputData,
}
QByteArray ECDSASSL11::decript(const QByteArray &message, const QByteArray &key) {
QuasarAppUtils::Params::log("");
return {};
}

@ -12,8 +12,6 @@
#ifdef USE_HEART_SSL
#include "abstractdata.h"
#include "icrypto.h"
#include <openssl/ec.h> // for EC_GROUP_new_by_curve_name, EC_GROUP_free, EC_KEY_new, EC_KEY_set_group, EC_KEY_generate_key,EC_KEY_free

@ -12,8 +12,6 @@
#include <time.h>
#include <QString>
#include "heart_global.h"
#include "hcrypto/icrypto.h"
namespace QH {

@ -13,10 +13,9 @@
#ifdef USE_HEART_SSL
#include "abstractdata.h"
#include "hcrypto/ecdsassl11.h"
#include <asynckeysauth.h>
#include "asynckeysauth.h"
namespace QH {

@ -0,0 +1,22 @@
/*
* Copyright (C) 2021-2022 QuasarApp.
* Distributed under the lgplv3 software license, see the accompanying
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
#ifndef ECDSASIGNER_H
#define ECDSASIGNER_H
#include "signer.h"
#include "hcrypto/ecdsassl11.h"
namespace QH {
/**
* @brief The ECDSASigner class is ecdsa implementation of the Signer class. This implementation based on Openssl library.
*/
typedef Signer<ECDSASSL11> ECDSASigner;
}
#endif // ECDSASIGNER_H

@ -0,0 +1,88 @@
/*
* Copyright (C) 2021-2022 QuasarApp.
* Distributed under the lgplv3 software license, see the accompanying
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
#ifndef SIGNER_H
#define SIGNER_H
#include <QByteArray>
#include <QCryptographicHash>
namespace QH {
/**
* @brief The Signer class is base wraper class for sining objects
* This class implement simple verification of the object with public and private keys and do not use any certificates.
* @tparam CryptoImplementation This is internal implementaion of base encription functions.
* @see iCrypto class.
*/
template<class CryptoImplementation>
class Signer: public CryptoImplementation
{
public:
Signer() {};
~Signer() {};
/**
* @brief signature This method should be return constant reference to the signature array.
* @return constant reference to the signature array.
*/
virtual const QByteArray &signature() const = 0;
/**
* @brief setSignature This method should be set the new signature of this object.
* @param newSignature new signature value.
*/
virtual void setSignature(const QByteArray &newSignature) = 0;
/**
* @brief signMessage This is main method for signing of this object.
* @return true if the object signed sucessful
*/
bool signMessage() const override {
auto sign = CryptoImplementation::signMessage(getMessage(), getPrivateKey());
if (sign.size()) {
setSignature(sign);
return true;
}
return false;
};
/**
* @brief checkSign This method check signatyre of this object.
* @return true if the objec signed
*/
bool checkSign() const override {
return CryptoImplementation::checkSign(getMessage(), signature(), getPublicKey());
};
protected:
/**
* @brief getPrivateKey This method should be return private key for the public key that saved in this object.
* @return private key for the public key that saved in this object.
*/
virtual const QByteArray& getPrivateKey() const = 0;
/**
* @brief getPublicKey This method should be return public key for the private key that encrypted this object.
* @return public key for the private key that ecrypt this object.
*/
virtual const QByteArray& getPublicKey() const = 0;
/**
* @brief getMessage This method should be return message that you want to sign.
* @return message that you want to sign.
*/
virtual const QByteArray& getMessage() const = 0;
};
}
#endif // SIGNER_H

@ -121,7 +121,7 @@ protected:
* If the implementation of this method differs from the example, the data will not be copied correctly.
* @see AbstractNode
*/
class HEARTSHARED_EXPORT AbstractData : public StreamBase, public QuasarAppUtils::HRO
class HEARTSHARED_EXPORT AbstractData : public StreamBase, public QuasarAppUtils::iHRO
{
public:

@ -37,6 +37,7 @@ if (${HEART_BUILD_LVL} GREATER_EQUAL 0)
"AbstractSpace/packages/*.cpp" "AbstractSpace/packages/*.h" "AbstractSpace/packages/*.qrc"
"AbstractSpace/Private/*.cpp" "AbstractSpace/Private/*.h" "AbstractSpace/Private/*.qrc"
"AbstractSpace/hcrypto/*.cpp" "AbstractSpace/hcrypto/*.h" "AbstractSpace/hcrypto/*.qrc"
"AbstractSpace/hcryptoFeatures/*.cpp" "AbstractSpace/hcryptoFeatures/*.h" "AbstractSpace/hcryptoFeatures/*.qrc"
)

@ -6,9 +6,9 @@
*/
#include "ecdsaauthtest.h"
#include "authecdsa.h"
#include <QtTest>
#include "thread"
#include <hcryptoFeatures/authecdsa.h>
#include <thread>
#ifdef USE_HEART_SSL

@ -1 +1 @@
Subproject commit 246ea80b36aed8e1cbe4ff7b546161d48531d731
Subproject commit ee6df818d0045e17510c23917e5f1e0a9caddbc5