Skip to content

Commit

Permalink
added generation of psk_key on api request
Browse files Browse the repository at this point in the history
  • Loading branch information
Nethius committed Oct 8, 2024
1 parent d4fff4a commit bb3c36c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions client/core/controllers/apiController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace
constexpr char accessToken[] = "api_key";
constexpr char certificate[] = "certificate";
constexpr char publicKey[] = "public_key";
constexpr char pskKey[] = "psk_key";
constexpr char protocol[] = "protocol";

constexpr char uuid[] = "installation_uuid";
Expand Down Expand Up @@ -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;
}
Expand All @@ -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();
Expand Down
1 change: 1 addition & 0 deletions client/core/controllers/apiController.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public slots:

QString wireGuardClientPrivKey;
QString wireGuardClientPubKey;
QString wireGuardPskKey;
};

ApiPayloadData generateApiPayloadData(const QString &protocol);
Expand Down

0 comments on commit bb3c36c

Please sign in to comment.