2018-04-29 02:01:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-06-28 05:30:33 +00:00
|
|
|
#include "identitymanager.h"
|
|
|
|
#include "nvhttp.h"
|
2018-04-29 02:01:00 +00:00
|
|
|
|
2018-04-29 05:14:27 +00:00
|
|
|
#include <openssl/x509.h>
|
|
|
|
#include <openssl/evp.h>
|
|
|
|
|
2018-04-29 02:01:00 +00:00
|
|
|
class NvPairingManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum PairState
|
|
|
|
{
|
|
|
|
PAIRED,
|
|
|
|
PIN_WRONG,
|
|
|
|
FAILED,
|
|
|
|
ALREADY_IN_PROGRESS
|
|
|
|
};
|
|
|
|
|
2021-07-02 22:14:48 +00:00
|
|
|
explicit NvPairingManager(NvComputer* computer);
|
2018-04-29 05:14:27 +00:00
|
|
|
|
|
|
|
~NvPairingManager();
|
2018-04-29 02:01:00 +00:00
|
|
|
|
|
|
|
PairState
|
2018-12-22 02:08:07 +00:00
|
|
|
pair(QString appVersion, QString pin, QSslCertificate& serverCert);
|
2018-04-29 02:01:00 +00:00
|
|
|
|
|
|
|
private:
|
2018-04-29 05:14:27 +00:00
|
|
|
QByteArray
|
|
|
|
generateRandomBytes(int length);
|
|
|
|
|
|
|
|
QByteArray
|
2020-06-07 22:15:33 +00:00
|
|
|
saltPin(const QByteArray& salt, QString pin);
|
2018-04-29 05:14:27 +00:00
|
|
|
|
|
|
|
QByteArray
|
2020-06-07 23:26:19 +00:00
|
|
|
encrypt(const QByteArray& plaintext, const QByteArray& key);
|
2018-04-29 05:14:27 +00:00
|
|
|
|
|
|
|
QByteArray
|
2020-06-07 23:26:19 +00:00
|
|
|
decrypt(const QByteArray& ciphertext, const QByteArray& key);
|
2018-04-29 05:14:27 +00:00
|
|
|
|
2018-04-29 08:48:41 +00:00
|
|
|
QByteArray
|
2020-06-07 22:15:33 +00:00
|
|
|
getSignatureFromPemCert(const QByteArray& certificate);
|
2018-04-29 08:48:41 +00:00
|
|
|
|
2018-04-29 05:14:27 +00:00
|
|
|
bool
|
2020-06-07 22:15:33 +00:00
|
|
|
verifySignature(const QByteArray& data, const QByteArray& signature, const QByteArray& serverCertificate);
|
2018-04-29 05:14:27 +00:00
|
|
|
|
|
|
|
QByteArray
|
2020-06-07 22:15:33 +00:00
|
|
|
signMessage(const QByteArray& message);
|
2018-04-29 05:14:27 +00:00
|
|
|
|
2018-04-29 02:01:00 +00:00
|
|
|
NvHTTP m_Http;
|
2018-04-29 05:14:27 +00:00
|
|
|
X509* m_Cert;
|
|
|
|
EVP_PKEY* m_PrivateKey;
|
2018-04-29 02:01:00 +00:00
|
|
|
};
|