diff --git a/.gitignore b/.gitignore index dbf9294..52f731c 100644 --- a/.gitignore +++ b/.gitignore @@ -47,7 +47,7 @@ target_wrapper.* # QtCreator CMake CMakeLists.txt.user* -# QtCreator 4.8< compilation database +# QtCreator 4.8< compilation database compile_commands.json # QtCreator local machine specific files for imported projects diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 251d284..6ac84d2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,19 +1,19 @@ -# Contributing in to EeasySSL +# Contributing in to EasySSL This is a wrap library for the Qt developers. So if you think that is a good library, and you use it in your projects - you can add new improvements and create a pull request with new features. -## What can you do for this Library ? +## What can you do for this Library ? -1. You can add a support of new encryption algorithms +1. You can add a support of new encryption algorithms. 2. You can implement new certificate generator. ## Adding new implementation of crypto algorithms -All Algorithms must be pass simple test. Encrypt, decrypt short and long data arrays. This simple test already implemented, and you just need to add it into main test file. +All algorithms must pass simple test. Encrypt, decrypt short and long data arrays. This simple test is already implemented, and you just need to add it into the main test file. ### Example -Adding supporting RSA algorithm to this library. +Adding supporting RSA algorithm to this library. 1. Create implementation of the iCrypto interface. @@ -25,7 +25,7 @@ Adding supporting RSA algorithm to this library. * @brief The RSASSL class This is wrapper for RSA algorithm of openssl 3.0 libraryry. */ class EASYSSL_EXPORT RSASSL: public EasySSL::ICrypto { - + // override main methods of the interface. EVP_PKEY *makeRawKeys() const override; Features supportedFeatures() const override; @@ -34,36 +34,35 @@ Adding supporting RSA algorithm to this library. bool checkSign(const QByteArray &inputData, const QByteArray &signature, const QByteArray &key) const override; QByteArray decrypt(const QByteArray &message, const QByteArray &key) override; QByteArray encrypt(const QByteArray &message, const QByteArray &key) override; - + } ``` - + Full implementation of the RSA you can see [here](https://github.com/QuasarApp/easyssl/blob/main/src/lib/src/public/easyssl/rsassl.h). 2. Add your class to the tests Using The Template class [CryptoTest](https://github.com/QuasarApp/easyssl/blob/main/tests/units/cryptotest.h). See The [tstMain.cpp](https://github.com/QuasarApp/easyssl/blob/main/tests/tstMain.cpp) file ```cpp - - TestCase(cryptoTestRSA, CryptoTest) +TestCase(cryptoTestRSA, CryptoTest) ``` -## Adding new implementation of Certificate generator. +## Adding new implementation of Certificate generator. 1. Create implementation of the iCrypto interface. And override the create method. ```cpp - /** - * @brief The X509 class This is wrapper of the ssl objects. - */ - class EASYSSL_EXPORT X509: public EasySSL::ICertificate - { - public: - X509(const QSharedPointer& generator); - - // ICertificate interface - public: - SelfSignedSertificate create(const SslSrtData& certificateData) const override; - }; +/** + * @brief The X509 class This is wrapper of the ssl objects. + */ +class EASYSSL_EXPORT X509: public EasySSL::ICertificate +{ +public: + X509(const QSharedPointer& generator); + + // ICertificate interface +public: + SelfSignedSertificate create(const SslSrtData& certificateData) const override; +}; ``` Full implementation of x509 certificate format you can see [here](https://github.com/QuasarApp/easyssl/blob/main/src/lib/src/public/easyssl/x509.h). @@ -71,18 +70,17 @@ Full implementation of x509 certificate format you can see [here](https://github 2. Add your class to the tests Using The Template class [CrtTest](https://github.com/QuasarApp/easyssl/blob/main/tests/units/crttest.h). See The [tstMain.cpp](https://github.com/QuasarApp/easyssl/blob/main/tests/tstMain.cpp) file ```cpp - #include "crttest.h" - - using CrtTestX509ECDSA = CrtTest; - TestCase(crtTestX509ECDSA, CrtTestX509ECDSA) +#include "crttest.h" +using CrtTestX509ECDSA = CrtTest; +TestCase(crtTestX509ECDSA, CrtTestX509ECDSA) ``` ## Extra rools 1. All shared tools or useful functions located on the [EasySSLUtils](https://github.com/QuasarApp/easyssl/blob/main/src/lib/src/private/easysslutils.h) class. -2. All implementation must contains goxygen xml comments (documentation) +2. All implementation must contain doxygen xml comments (documentation) 3. All implementation must be inner EasySSL name space. -# Thank you +# Thank you diff --git a/README.md b/README.md index b0106be..71ad78b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # EasySSL -This is wrapper library that make using OpenSSL library more simple. +This is wrapper library that make using OpenSSL library more simple. This library contains interfaces for the signing and encryption data. ### Supported encryption algorithms: @@ -14,16 +14,16 @@ This library contains interfaces for the signing and encryption data. ## Build and Include - + * cd yourRepo * git submodule add https://github.com/QuasarApp/easyssl.git # add the repository of Heart into your repo like submodule * git submodule update --init --recursive * Include in your CMakeLists.txt file the main CMakeLists.txt file of Heart library - + ```cmake add_subdirectory(easyssl) ``` - + * link the Heart library to your target ```cmake target_link_libraries(yourLib PUBLIC easyssl) @@ -44,10 +44,10 @@ int main() { QByteArray pub, priv; EasySSL::RSASSL crypto; crypto.makeKeys(pub, priv) - + auto siganture = crypto.signMessage(message, priv); crypto.checkSign(message, siganture, pub); - + auto encryptedMsg = crypto.encrypt(message, pub); auto decryptedMsg = crypto.decrypt(encryptedMsg, priv); } @@ -56,7 +56,7 @@ int main() { ``` -### Authentication +### Authentication ```cpp #include @@ -96,7 +96,7 @@ edsa.auth(1000, &userID) ``` -## Do not forget to help us make this library better... -See our main documentation about contributing to [EasySsl](https://github.com/QuasarApp/easyssl/blob/main/CONTRIBUTING.md) +## Do not forget to help us make this library better... +See our main documentation about contributing to [EasySsl](https://github.com/QuasarApp/easyssl/blob/main/CONTRIBUTING.md) -Full documentation available [here](https://quasarapp.ddns.net:3031/docs/QuasarApp/easyssl/latest/index.html) +Full documentation available [here](https://quasarapp.ddns.net:3031/docs/QuasarApp/easyssl/latest/index.html) diff --git a/src/lib/src/public/easyssl/rsassl.cpp b/src/lib/src/public/easyssl/rsassl.cpp index 00255d1..31742a6 100644 --- a/src/lib/src/public/easyssl/rsassl.cpp +++ b/src/lib/src/public/easyssl/rsassl.cpp @@ -139,7 +139,7 @@ QByteArray RSASSL::decrypt(const QByteArray &message, const QByteArray &key) { auto rsaPrivateKey = PEM_read_bio_PrivateKey(pkey, nullptr, nullptr, nullptr); BIO_free(pkey); - if (!rsaPrivateKey) { + if (!rsaPrivateKey) { qCritical() << "Error reading private key"; EasySSLUtils::printlastOpenSSlError(); return {}; @@ -164,7 +164,7 @@ QByteArray RSASSL::decrypt(const QByteArray &message, const QByteArray &key) { EasySSLUtils::printlastOpenSSlError(); EVP_PKEY_CTX_free(ctx); - EVP_PKEY_free(rsaPrivateKey); + EVP_PKEY_free(rsaPrivateKey); return {}; }