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/aes.h>
|
|
|
|
#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-07-06 06:12:55 +00:00
|
|
|
pair(QString appVersion, QString pin);
|
2018-04-29 02:01:00 +00:00
|
|
|
|
|
|
|
private:
|
2018-04-29 05:14:27 +00: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 08:48:41 +00:00
|
|
|
QByteArray
|
|
|
|
getSignatureFromPemCert(QByteArray certificate);
|
|
|
|
|
2018-04-29 05:14:27 +00:00
|
|
|
bool
|
2018-04-29 08:48:41 +00:00
|
|
|
verifySignature(QByteArray data, QByteArray signature, QByteArray serverCertificate);
|
2018-04-29 05:14:27 +00:00
|
|
|
|
|
|
|
QByteArray
|
|
|
|
signMessage(QByteArray message);
|
|
|
|
|
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
|
|
|
};
|