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