Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Qt support RSA encryption?

Tags:

rsa

encryption

qt

Does Qt support rsa encryption,QSslkey seems doesn't work. thanks in advance.

like image 240
vincent Avatar asked Nov 22 '10 09:11

vincent


3 Answers

Qt supports RSA for SSL-connections. There are no interfaces to use RSA keys directly.

You could take a look at the Qt Cryptographic Architecture project, but it does not look to be maintained anymore.

like image 196
Rasmus Faber Avatar answered Nov 12 '22 08:11

Rasmus Faber


Qt is supporting RSA encryption. You have to indicate to QSslKey the correct algorithm used: http://doc.qt.io/qt-5/qssl.html#KeyAlgorithm-enum

like image 33
Patrice Bernassola Avatar answered Nov 12 '22 08:11

Patrice Bernassola


If you want encrypt data without ssl dependencies then you can use my library Qt-Secret. This library supports the qmake build system, which makes it very easy to connect to your project.


For example:

Build

  • git clone 'https://github.com/QuasarApp/Qt-Secret.git'
    cd Qt-Secret
    git submodule update --init --recursive
    qmake -r 
    make -j8
    make test #(for testing)
    

Include

For qmake projects

  • cd yourRepo
    git submodule add https://github.com/QuasarApp/Qt-Secret.git # add the repository of Qt-Secret into your repo like submodule
    git submodule update --init --update
    
  • Include in your pro file the pri file of Qt-Secret library:

    include($$PWD/Qt-Secret/src/Qt-Secret.pri)
    
  • Rebuild your project.

For other build systems

  • cd yourRepo
    git submodule add https://github.com/QuasarApp/Qt-Secret.git # add the repository of Qt-Secret into your repo like submodule
    git submodule update --init --update
    
  • Add the rule to build Qt-Secret.

  • Add INCLUDEPATH and LIBS for your build system .
  • Rebuild your project.

Usage

RSA

Encryption and decryption of messages.

#include <qrsaencryption.h>

    QByteArray pub, priv;
    QRSAEncryption e(QRSAEncryption::Rsa::RSA_2048);
    e.generatePairKey(pub, priv);
    QByteArray msg = "test message";

    auto encodeData = e.encode(msg, pub);
    auto decodeData = e.decode(encodeData, priv);

Signature and verification of the message signature.

#include <qrsaencryption.h>

    QByteArray pub, priv;
    QRSAEncryption e;
    e.generatePairKey(pub, priv, QRSAEncryption::Rsa::RSA_128); // or other rsa size 

    QByteArray msg = "test message";

    auto signedMessage = e.signMessage(msg, priv);

    if (e.checkSignMessage(signedMessage, pub)) {
        // message signed success
    }

like image 1
Andrey Yankovich Avatar answered Nov 12 '22 06:11

Andrey Yankovich