moonlight-qt/app/backend/nvpairingmanager.h

53 lines
1 KiB
C
Raw Normal View History

2018-04-29 02:01:00 +00:00
#pragma once
#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
};
2018-06-28 02:55:44 +00:00
explicit NvPairingManager(QString address);
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
saltPin(const QByteArray& salt, QString pin);
2018-04-29 05:14:27 +00:00
QByteArray
encrypt(const QByteArray& plaintext, const QByteArray& key);
2018-04-29 05:14:27 +00:00
QByteArray
decrypt(const QByteArray& ciphertext, const QByteArray& key);
2018-04-29 05:14:27 +00:00
2018-04-29 08:48:41 +00:00
QByteArray
getSignatureFromPemCert(const QByteArray& certificate);
2018-04-29 08:48:41 +00:00
2018-04-29 05:14:27 +00:00
bool
verifySignature(const QByteArray& data, const QByteArray& signature, const QByteArray& serverCertificate);
2018-04-29 05:14:27 +00:00
QByteArray
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
};