easyssl 0.87.745ff01
EasySSL is base back end library for your c++ Qt projects.

This is wrapper library that make using OpenSSL library more simple. This library contains interfaces for the signing and encryption data.

Supported encryption algorithms:

  • ECDSA
  • RSA

Supported features

  • encryption
  • signing
  • keys creating
  • async auth based on the asymmetric encryption methods

Build and Include

CMake

  • cd yourRepo
  • git submodule add https://github.com/QuasarApp/easyssl.git # add the repository of EasySSL into your repo like submodule
  • git submodule update –init –recursive
  • Include in your CMakeLists.txt file the main CMakeLists.txt file of EasySSL library

    add_subdirectory(easyssl)
  • link the EasySSL library to your target
    target_link_libraries(yourLib PUBLIC easyssl)
  • rebuild your project

qmake

  • cd yourRepo
  • git submodule add https://github.com/QuasarApp/easyssl.git # add the repository of EasySSL into your repo like submodule
  • git submodule update –init –recursive
  • Include in your .pro file the EasySSL sources directly:

    ```qmake

    myapp.pro

    QT += core network

    INCLUDEPATH += $$PWD/../easyssl/src/lib/src/public

    SOURCES += \ ../easyssl/src/lib/src/public/easyssl.cpp \ ../easyssl/src/lib/src/public/easyssl/icrypto.cpp \ ../easyssl/src/lib/src/public/easyssl/ecdsassl.cpp \ ../easyssl/src/lib/src/public/easyssl/rsassl.cpp \ ../easyssl/src/lib/src/public/easyssl/x509.cpp \ ../easyssl/src/lib/src/public/easyssl/icertificate.cpp \ ../easyssl/src/lib/src/private/easysslutils.cpp

    DEFINES += EASYSSL_LIBRARY

Link the OpenSSL 3.0+ libraries:

LIBS += -lcrypto -lssl ```

  • rebuild your project

‍Note: the CMake build is the recommended way. The EasySSL library has the EASYSSL_STATIC_SSL and BUILD_WITH_OPENSSL build options that are only available for the CMake build.

Independent of SSL build

Dependency on the ssl library greatly complicates the deployment of the final product. For fix this issue, you can build EasySSL library with static SSL library. In this case, SSL library code will be saved in your EasySSL binary, and deploy of your application will be easily. The ssl code will not available for your application or other libraries, so you will not get conflicts between different major versions ssl libraries if your distribution kit has it.

Just set the EASYSSL_STATIC_SSL option to true.

bash
cmake .. -DEASYSSL_STATIC_SSL=1

The described case may be useful for the Qt 5.15.x, because the QNetwork 5.15 depends on the SSL v1.1 and EasySSL works with the SSL >= 3.0.

Build without the system OpenSSL (BUILD_WITH_OPENSSL)

If your system (or the target device) has no OpenSSL 3.0+ library, you can build the OpenSSL library together with the EasySSL library. Just set the BUILD_WITH_OPENSSL option to true:

bash
cmake .. -DBUILD_WITH_OPENSSL=1

In this case the EasySSL project clones the OpenSSL openssl-3.0.9 sources, builds the static OpenSSL libraries and links them privately into the EasySSL binary. So your application has no runtime dependency on the system OpenSSL.

  • Supported platforms: Linux, Windows (MinGW), Android, iOS and macOS (arm/x86).
  • The WASM platform is not supported.
  • On Windows the build requires the MinGW (GNU) compiler and the mingw32-make tool. The OpenSSL Configure script also requires a perl that produces Unix-like paths and that provides the perl core modules (for example the MSYS2 perl; set the MSYS2_ROOT environment variable to the MSYS2 installation directory if it is not found automatically).
  • The OpenSSL version can be changed with the EASYSSL_OPENSSL_TAG option (default openssl-3.0.9).

Unit tests

The unit tests of the EasySSL library are built and run by default. To disable the tests, set the EASYSSL_TESTS option to false:

bash
cmake .. -DEASYSSL_TESTS=0

Usage

Encryption

#include <easyssl/rsassl.h>
#include <QByteArray>
int main() {
// create a public and private keys array.
QByteArray pub, priv;
crypto.makeKeys(pub, priv);
QByteArray message = "Hello EasySSL!";
auto signature = crypto.signMessage(message, priv);
crypto.checkSign(message, signature, pub);
auto encryptedMsg = crypto.encrypt(message, pub);
auto decryptedMsg = crypto.decrypt(encryptedMsg, priv);
}
bool makeKeys(QByteArray &pubKey, QByteArray &privKey) const
makeKeys This method generate the public and private keys of the ECDSA.
Definition icrypto.cpp:16
The RSASSL class This is wrapper for RSA algorithm of openssl 3.0 libraryry.
Definition rsassl.h:21
QByteArray decrypt(const QByteArray &message, const QByteArray &key) override
decrypt This method has empty implementation.
Definition rsassl.cpp:136
QByteArray signMessage(const QByteArray &inputData, const QByteArray &key) const override
signMessage This method should be sign the message using the key.
Definition rsassl.cpp:48
QByteArray encrypt(const QByteArray &message, const QByteArray &key) override
encrypt This method has empty implementation.
Definition rsassl.cpp:205
bool checkSign(const QByteArray &inputData, const QByteArray &signature, const QByteArray &key) const override
checkSign This method should be check signature of the message using the key.
Definition rsassl.cpp:99

More information about the build options (CMake, qmake) and the usage examples (RSA, ECDSA, X509 certificates, async authentication) is available in the docs/USAGE.md file.

Authentication

class ECDSA: public EasySSL::AuthECDSA {
public:
// AsyncKeysAuth interface
void setPrivateKey(const QByteArray &newPriv) {
_priv = newPriv;
}
QByteArray getPrivateKey() const {
return _priv;
}
private:
QByteArray _priv;
};
ECDSA edsa;
QByteArray pub, priv;
QString userID;
// make public and private keys.
edsa.makeKeys(pub, priv);
edsa.setPrivateKey(priv);
edsa.setPublicKey(pub);
// prepare an authentication object.
edsa.prepare();
edsa.setPrivateKey({});
edsa.auth(1000, &userID);
The AsyncKeysAuth class is temaplate class for works with authorization of a pair of asynchronous key...
virtual QByteArray getPrivateKey() const =0
getPrivateKey This method should be return private key for the public key that saved in this object.

Documentation

Do not forget to help us make this library better...

See our main documentation about contributing to EasySSL

Full documentation and the API reference available on the EasySSL GitHub Pages site.