1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

Reorganized code, added Synccrypto module

This commit is contained in:
Prasenjit Kumar Shaw 2019-06-09 12:45:24 +05:30
parent 630a57edbc
commit 81d0fa9f20
11 changed files with 128 additions and 115 deletions

View File

@ -215,7 +215,8 @@ set(SRCS ${SRCS}
sidebar/bookmarkssidebar.cpp
sidebar/historysidebar.cpp
sidebar/sidebar.cpp
sync/hkdf.cpp
sync/fxalogin.cpp
sync/synccrypto.cpp
tabwidget/combotabbar.cpp
tabwidget/tabbar.cpp
tabwidget/tabicon.cpp

View File

@ -56,7 +56,6 @@
<file>icons/preferences/privacy.svg</file>
<file>icons/preferences/shortcuts.svg</file>
<file>icons/preferences/spellcheck.svg</file>
<file>icons/preferences/sync.svg</file>
<file>icons/preferences/tabs.svg</file>
<file>icons/menu/download.svg</file>
</qresource>

View File

@ -1,57 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="32"
height="32"
viewBox="0 0 320 320"
version="1.1"
id="svg4"
sodipodi:docname="combine-top-bottom.svg"
style="clip-rule:evenodd;fill-rule:evenodd;image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<metadata
id="metadata10">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs8" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1440"
inkscape:window-height="871"
id="namedview6"
showgrid="false"
inkscape:zoom="3.6875"
inkscape:cx="32"
inkscape:cy="32"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg4" />
<path
d="M 78.179501,3.1020669 2.711865,103.92457 l 48.576908,0.008 v 178.53258 h 53.792747 v -0.007 h 36.55743 l 1.05494,0.007 48.20595,-0.0145 -51.71229,-69.08377 -34.10603,0.007 V 103.94021 l 48.57151,-0.0145 z M 241.2677,316.22199 316.74124,215.3995 l -48.5828,-0.007 v -92.01018 l 0.005,-1.74948 V 36.858711 l -2.61969,-0.0076 H 199.523 l -59.79119,0.0076 v 10.808128 l 43.6275,58.275651 h 14.80748 l 1.36751,0.007 h 14.83052 v 109.43558 l -48.57152,0.0151 75.47353,100.82249 z"
id="path2"
inkscape:connector-curvature="0"
style="stroke-width:0.5560813;fill:#00c1b2;fill-opacity:1" />
</svg>

Before

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -138,7 +138,6 @@ Preferences::Preferences(BrowserWindow* window)
setCategoryIcon(9, QIcon(":/icons/preferences/notifications.svg"));
setCategoryIcon(10, QIcon(":/icons/preferences/extensions.svg"));
setCategoryIcon(11, QIcon(":/icons/preferences/spellcheck.svg"));
setCategoryIcon(12, QIcon(":/icons/preferences/sync.svg"));
setCategoryIcon(13, QIcon(":/icons/preferences/other.svg"));
Settings settings;

View File

@ -1,4 +1,3 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2019 Prasenjit Kumar Shaw <shawprasenjit07@gmail.com>
@ -16,28 +15,24 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#include "syncoptions.h"
#include "ui_syncoptions.h"
#include "fxalogin.h"
#include <QWebEngineView>
#include <QWebEnginePage>
#include "syncoptions.h"
SyncOptions::SyncOptions(QWidget* parent)
: QWidget(parent)
, ui(new Ui::SyncOptions)
{
ui->setupUi(this);
QWebEnginePage *FxA_loginPage = new QWebEnginePage();
FxA_loginPage->load(FxALoginUrl);
ui->fxaLoginView->setPage(FxA_loginPage);
loginPage = new FxALoginPage(this);
ui->fxaLoginView->setPage(loginPage);
ui->fxaLoginView->show();
}
SyncOptions::~SyncOptions()
{
delete ui;

View File

@ -1,4 +1,3 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2019 Prasenjit Kumar Shaw <shawprasenjit07@gmail.com>
@ -16,13 +15,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#ifndef SYNCOPTIONS_H
#define SYNCOPTIONS_H
#include <QWidget>
#include <QUrl>
#include <QWebEnginePage>
#include "qzcommon.h"
@ -34,13 +32,14 @@ namespace Ui
class FALKON_EXPORT SyncOptions : public QWidget
{
Q_OBJECT
public:
explicit SyncOptions(QWidget* parent = 0);
~SyncOptions();
private:
const QUrl FxALoginUrl = QUrl("https://accounts.firefox.com/signin?service=sync&context=fx_desktop_v3");
QWebEnginePage *loginPage;
Ui::SyncOptions *ui;
};

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>535</width>
<width>607</width>
<height>749</height>
</rect>
</property>
@ -18,7 +18,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>531</width>
<width>601</width>
<height>511</height>
</rect>
</property>
@ -45,7 +45,7 @@
<rect>
<x>0</x>
<y>530</y>
<width>531</width>
<width>601</width>
<height>211</height>
</rect>
</property>
@ -57,7 +57,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>531</width>
<width>601</width>
<height>51</height>
</rect>
</property>

View File

@ -1,4 +1,3 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2019 Prasenjit Kumar Shaw <shawprasenjit07@gmail.com>
@ -16,37 +15,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#include "fxalogin.h"
#include "hkdf.h"
#include <QWebEnginePage>
#include <openssl/evp.h>
#include <openssl/kdf.h>
#include <QByteArray>
HKDF::HKDF(const QByteArray key, const QByteArray salt)
FxALoginPage::FxALoginPage(QWidget* parent)
: QWebEnginePage(parent)
{
pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF,NULL);
init(key, salt);
}
HKDF::~HKDF() {
;
}
void HKDF::init(const QByteArray key, const QByteArray salt)
{
size_t keylen = key.size();
size_t saltlen = salt.size();
EVP_PKEY_derive_init(pctx);
EVP_PKEY_CTX_set_hkdf_md(pctx, EVP_sha256());
EVP_PKEY_CTX_set1_hkdf_salt(pctx, (uchar *)salt.data(), saltlen);
EVP_PKEY_CTX_set1_hkdf_key(pctx, (uchar *)key.data(), keylen);
}
QByteArray HKDF::getKey(size_t outlen) {
QByteArray out;
EVP_PKEY_derive(pctx, (uchar *)out.data(), &outlen);
return out;
this->load(FxALoginUrl);
}

32
src/lib/sync/fxalogin.h Normal file
View File

@ -0,0 +1,32 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2019 Prasenjit Kumar Shaw <shawprasenjit07@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#pragma once
#include <QUrl>
#include <QWebEnginePage>
class FxALoginPage : public QWebEnginePage
{
Q_OBJECT
public:
explicit FxALoginPage(QWidget *parent = 0);
private:
const QUrl FxALoginUrl = QUrl("https://accounts.firefox.com/signin?service=sync&context=fx_desktop_v3");
};

View File

@ -0,0 +1,71 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2019 Prasenjit Kumar Shaw <shawprasenjit07@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#include "synccrypto.h"
#include <openssl/evp.h>
#include <openssl/kdf.h>
#include <QByteArray>
HKDF::HKDF(const QByteArray key, const QByteArray salt, const QByteArray info)
{
pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF,NULL);
init(key, salt,info);
}
HKDF::~HKDF() {
}
void HKDF::init(const QByteArray key, const QByteArray salt, const QByteArray info)
{
size_t keylen = key.size();
size_t saltlen = salt.size();
size_t infolen = info.size();
if (EVP_PKEY_derive_init(pctx) <= 0) {
qWarning("Unable to initialize public key algorithm context for HKDF.");
return;
}
if (EVP_PKEY_CTX_set_hkdf_md(pctx, EVP_sha256()) <= 0) {
qWarning("Unable to set HKDF message digest.");
return;
}
if (EVP_PKEY_CTX_set1_hkdf_salt(pctx, (uchar *)salt.data(), saltlen) <= 0) {
qWarning("Unable to set salt.");
return;
}
if (EVP_PKEY_CTX_set1_hkdf_key(pctx, (uchar *)key.data(), keylen) <= 0) {
qWarning("Unable to set key.");
return;
}
if (EVP_PKEY_CTX_add1_hkdf_info(pctx, (uchar *)info.data(), infolen) <= 0) {
qWarning("Uable to set info for HKDF.");
return;
}
}
QByteArray HKDF::getKey(size_t outlen) {
QByteArray out;
if (EVP_PKEY_derive(pctx, (uchar *)out.data(), &outlen) <= 0) {
qWarning("Unable to derive HKDF key.");
}
return out;
}

View File

@ -1,4 +1,3 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2019 Prasenjit Kumar Shaw <shawprasenjit07@gmail.com>
@ -24,13 +23,14 @@
class HKDF
{
public:
explicit HKDF(const QByteArray key, const QByteArray salt);
explicit HKDF(const QByteArray key, const QByteArray salt, const QByteArray info);
~HKDF();
QByteArray getKey(size_t outlen);
private:
void init(const QByteArray key, const QByteArray salt);
void init(const QByteArray key, const QByteArray salt, const QByteArray info);
EVP_PKEY_CTX *pctx;
};