From 0489f19ceb38557d2c2237e253b6540cba8252d1 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Tue, 8 Oct 2024 16:35:38 +0800 Subject: [PATCH] added generation of psk_key on api request --- client/core/controllers/apiController.cpp | 8 ++++++++ client/core/controllers/apiController.h | 1 + 2 files changed, 9 insertions(+) diff --git a/client/core/controllers/apiController.cpp b/client/core/controllers/apiController.cpp index 5cdaa7aec..bbeb13814 100644 --- a/client/core/controllers/apiController.cpp +++ b/client/core/controllers/apiController.cpp @@ -24,6 +24,7 @@ namespace constexpr char accessToken[] = "api_key"; constexpr char certificate[] = "certificate"; constexpr char publicKey[] = "public_key"; + constexpr char pskKey[] = "preshared_key"; constexpr char protocol[] = "protocol"; constexpr char uuid[] = "installation_uuid"; @@ -193,6 +194,12 @@ ApiController::ApiPayloadData ApiController::generateApiPayloadData(const QStrin auto connData = WireguardConfigurator::genClientKeys(); apiPayload.wireGuardClientPubKey = connData.clientPubKey; apiPayload.wireGuardClientPrivKey = connData.clientPrivKey; + QSimpleCrypto::QBlockCipher blockCipher; + apiPayload.wireGuardPskKey = blockCipher.generatePrivateSalt(32); + + qDebug() << apiPayload.wireGuardClientPubKey; + qDebug() << apiPayload.wireGuardPskKey; + } return apiPayload; } @@ -204,6 +211,7 @@ QJsonObject ApiController::fillApiPayload(const QString &protocol, const ApiCont obj[configKey::certificate] = apiPayloadData.certRequest.request; } else if (protocol == configKey::awg) { obj[configKey::publicKey] = apiPayloadData.wireGuardClientPubKey; + obj[configKey::pskKey] = apiPayloadData.wireGuardPskKey; } obj[configKey::osVersion] = QSysInfo::productType(); diff --git a/client/core/controllers/apiController.h b/client/core/controllers/apiController.h index 1f8114989..f846c6719 100644 --- a/client/core/controllers/apiController.h +++ b/client/core/controllers/apiController.h @@ -34,6 +34,7 @@ public slots: QString wireGuardClientPrivKey; QString wireGuardClientPubKey; + QString wireGuardPskKey; }; ApiPayloadData generateApiPayloadData(const QString &protocol);