60 lines
1.7 KiB
C++
60 lines
1.7 KiB
C++
#ifndef QTOE_H
|
|
#define QTOE_H
|
|
|
|
#include <QObject>
|
|
#include <QtDebug>
|
|
#include <openssl/aes.h>
|
|
#include <openssl/evp.h>
|
|
#include <openssl/rsa.h>
|
|
#include <openssl/pem.h>
|
|
#include <openssl/ssl.h>
|
|
#include <openssl/bio.h>
|
|
#include <openssl/err.h>
|
|
#include <openssl/asn1.h>
|
|
#include <openssl/bio.h>
|
|
#include <openssl/conf.h>
|
|
#include <openssl/err.h>
|
|
#include <openssl/pem.h>
|
|
#include <openssl/x509.h>
|
|
#include <assert.h>
|
|
|
|
class QtOE : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit QtOE(QObject *parent = nullptr);
|
|
|
|
RSA* createPrivateRSA(QString key, QString passphrase = "");
|
|
RSA* createPublicRSA(QString key);
|
|
RSA* createPublicRSA(X509* cert);
|
|
X509* createX509(QString cert);
|
|
|
|
QString signMessage(RSA* privateKey, QString plainText);
|
|
bool verifySignature(RSA* publicKey, QString plainText, QString signatureBase64);
|
|
|
|
void printCertBio(X509* cert);
|
|
private:
|
|
bool RSASign( RSA* rsa,
|
|
const unsigned char* Msg,
|
|
size_t MsgLen,
|
|
unsigned char** EncMsg,
|
|
size_t* MsgLenEnc);
|
|
bool RSAVerifySignature( RSA* rsa,
|
|
unsigned char* MsgHash,
|
|
size_t MsgHashLen,
|
|
const char* Msg,
|
|
size_t MsgLen,
|
|
bool* Authentic);
|
|
void Base64Encode( const unsigned char* buffer,
|
|
size_t length,
|
|
char** base64Text);
|
|
size_t calcDecodeLength(const char* b64input);
|
|
void Base64Decode(const char* b64message, unsigned char** buffer, size_t* length);
|
|
static int pem_password_callback(char *buf, int max_len, int flag, void *ctx);
|
|
|
|
signals:
|
|
|
|
};
|
|
|
|
#endif // QTOE_H
|