mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-11-16 00:07:58 +00:00
52 lines
1 KiB
C++
52 lines
1 KiB
C++
#pragma once
|
|
|
|
#include "identitymanager.h"
|
|
#include "nvhttp.h"
|
|
|
|
#include <openssl/x509.h>
|
|
#include <openssl/evp.h>
|
|
|
|
class NvPairingManager
|
|
{
|
|
public:
|
|
enum PairState
|
|
{
|
|
PAIRED,
|
|
PIN_WRONG,
|
|
FAILED,
|
|
ALREADY_IN_PROGRESS
|
|
};
|
|
|
|
explicit NvPairingManager(QString address);
|
|
|
|
~NvPairingManager();
|
|
|
|
PairState
|
|
pair(QString appVersion, QString pin, QSslCertificate& serverCert);
|
|
|
|
private:
|
|
QByteArray
|
|
generateRandomBytes(int length);
|
|
|
|
QByteArray
|
|
saltPin(const QByteArray& salt, QString pin);
|
|
|
|
QByteArray
|
|
encrypt(const QByteArray& plaintext, const QByteArray& key);
|
|
|
|
QByteArray
|
|
decrypt(const QByteArray& ciphertext, const QByteArray& key);
|
|
|
|
QByteArray
|
|
getSignatureFromPemCert(const QByteArray& certificate);
|
|
|
|
bool
|
|
verifySignature(const QByteArray& data, const QByteArray& signature, const QByteArray& serverCertificate);
|
|
|
|
QByteArray
|
|
signMessage(const QByteArray& message);
|
|
|
|
NvHTTP m_Http;
|
|
X509* m_Cert;
|
|
EVP_PKEY* m_PrivateKey;
|
|
};
|