mirror of
https://github.com/QRouland/UTPass.git
synced 2024-12-21 09:22:39 +00:00
Inital base for use GPG && GpgmE
This commit is contained in:
parent
6a5c352aed
commit
3cbd834787
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -7,3 +7,6 @@
|
||||
[submodule "third/libgpg-error"]
|
||||
path = third/libgpg-error
|
||||
url = https://github.com/gpg/libgpg-error
|
||||
[submodule "third/gnupg"]
|
||||
path = third/gnupg
|
||||
url = https://github.com/gpg/gnupg
|
||||
|
@ -4,6 +4,19 @@ include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
|
||||
|
||||
execute_process(
|
||||
COMMAND dpkg-architecture -qDEB_HOST_ARCH
|
||||
OUTPUT_VARIABLE CLICK_ARCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
execute_process(
|
||||
COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
|
||||
OUTPUT_VARIABLE ARCH_TRIPLET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
find_package(Qt5Core)
|
||||
find_package(Qt5Qml)
|
||||
find_package(Qt5Quick)
|
||||
@ -19,10 +32,12 @@ set(PROJECT_NAME "UTPass")
|
||||
set(FULL_PROJECT_NAME "utpass.qrouland")
|
||||
set(CMAKE_INSTALL_PREFIX /)
|
||||
set(DATA_DIR /)
|
||||
set(BIN_DIR ${DATA_DIR}lib/${ARCH_TRIPLET}/bin)
|
||||
set(DESKTOP_FILE_NAME ${PROJECT_NAME}.desktop)
|
||||
|
||||
add_executable(${PROJECT_NAME} main.cpp)
|
||||
|
||||
|
||||
qt5_use_modules(${PROJECT_NAME} Gui Qml Quick)
|
||||
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
|
||||
@ -32,7 +47,15 @@ install(FILES ${PROJECT_NAME}.apparmor DESTINATION ${DATA_DIR})
|
||||
install(DIRECTORY qml DESTINATION ${DATA_DIR})
|
||||
install(DIRECTORY assets DESTINATION ${DATA_DIR})
|
||||
install(DIRECTORY password-store DESTINATION ${DATA_DIR})
|
||||
|
||||
install(DIRECTORY gpghome DESTINATION ${DATA_DIR})
|
||||
install(DIRECTORY local/bin DESTINATION ${DATA_DIR})
|
||||
file(GLOB_RECURSE BIN_FILES
|
||||
"local/bin/*")
|
||||
install(
|
||||
FILES ${BIN_FILES}
|
||||
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||
DESTINATION ${BIN_DIR}
|
||||
)
|
||||
|
||||
# Translations
|
||||
file(GLOB_RECURSE I18N_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po qml/*.qml qml/*.js)
|
||||
@ -59,6 +82,8 @@ add_subdirectory(third)
|
||||
add_subdirectory(po)
|
||||
add_subdirectory(plugins)
|
||||
|
||||
add_dependencies(${PROJECT_NAME} Gnupg)
|
||||
|
||||
# Make source files visible in qtcreator
|
||||
# We don't need to add plugin sources here as they get exposed
|
||||
# via the library target.
|
||||
|
@ -12,10 +12,10 @@ For more options/details see the [clickable documentation](http://clickable.bhdo
|
||||
|
||||
## Custom clickable command
|
||||
* ```clickable c ``` : clean third directory and run ```clickable clean```
|
||||
* ```clickable crun ``` : clean third directory and run ```clickable```
|
||||
* ```clickable run``` : run ```clickable --dirty```
|
||||
* ```clickable crund ``` : clean third directory and run ```clickable desktop```
|
||||
* ```clickable rund ``` : run ```clickable desktop --dirty ```
|
||||
* ```clickable cr ``` : clean third directory and run ```clickable```
|
||||
* ```clickable r``` : run ```clickable --dirty```
|
||||
* ```clickable crd ``` : clean third directory and run ```clickable desktop```
|
||||
* ```clickable rd ``` : run ```clickable desktop --dirty ```
|
||||
|
||||
# Contributing
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
{
|
||||
template": "unconfined",
|
||||
"policy_groups": [],
|
||||
"policy_version": 16.04
|
||||
}
|
||||
|
164
assets/logo.svg
164
assets/logo.svg
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 16 KiB |
@ -3,16 +3,15 @@
|
||||
"kill": "UTPass",
|
||||
"scripts": {
|
||||
"c": "third/clean.sh && clickable clean",
|
||||
"crun": "third/clean.sh && clickable",
|
||||
"run": "clickable --dirty",
|
||||
"crund": "third/clean.sh && clickable desktop",
|
||||
"rund": "clickable desktop --dirty"
|
||||
"cr": "third/clean.sh && clickable",
|
||||
"r": "clickable --dirty",
|
||||
"crd": "third/clean.sh && clickable desktop",
|
||||
"rd": "clickable desktop --dirty"
|
||||
},
|
||||
"dependencies_build": [
|
||||
"texinfo",
|
||||
"gpgsm"
|
||||
"gpgsm",
|
||||
"bison"
|
||||
],
|
||||
"dependencies_target": [
|
||||
|
||||
]
|
||||
"dependencies_target": []
|
||||
}
|
||||
|
0
gpghome/.gitkeep
Normal file
0
gpghome/.gitkeep
Normal file
30
password-store/public.key
Normal file
30
password-store/public.key
Normal file
@ -0,0 +1,30 @@
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
|
||||
mQENBFyNdOEBCADl2oWeYkmVBDWoWgZdkpbV5VRJJFATLsu5aHBuQO/C1mn2RlL2
|
||||
jIpIzI5mwviAw9RN0KnLdHvp3n3JkJPZ8tB3Sk9SD8qhr6ae2DbIpySMscYC9+Go
|
||||
t0mrGyB3w+Y5etfZ/1dRNx6/vYaWYIG6bKfJettt/zLJcjpkIKcrN4OKyN2wXz3y
|
||||
EiAiJvMntdgLslURl93RyNuVR6UaE4TchtDqRc2KvXAxrf6NUYd4KxvUgUd0TFPs
|
||||
s3SRs+cAcRmTzxv/c40sBw3z0B9rBB7T7oPgGUA6NhErvBwpF9MLN+6ucZ1HHLLH
|
||||
dmCd7q2OT7wZ9L6zILmKvJcK13V4FyO9zOALABEBAAG0I1Rlc3QgKFRlc3QgZ3Bn
|
||||
IGtleSkgPHRlc3RAdGVzdC5vcmc+iQFOBBMBCAA4FiEE6JXydyCXAQnkfMmTuV1W
|
||||
R67EDnIFAlyNdOECGwMFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQuV1WR67E
|
||||
DnIchAgAvV5q4/Hktlu3RIgo8KkGksMOS5XhJrr6fZ8bUgqpwL3oEfZ3Se5aS7yN
|
||||
5M7NT8foB2zK2moBICMYpxBxQoGjxFosv94FqX9+XMiRc2Di6MwLwKkWfu0HoPEi
|
||||
e701iTo53r6K84TIKNrRsKyg6C/pRqNNwSp1YcvG11eUnG5teZMcb1xsMfx4O2/s
|
||||
mcrySo0ZjAfYnh2poxf4yy9xTryPrDnaY/EFj+4uBMLH8jG3QQiAH1N6wHhi/vwj
|
||||
FaaaBtRxcVU/obGDg2LHTVxItv81xzSbLf8JdIGOKjwFed+DjaoSlEzPnuaEZf/M
|
||||
7mE6fiGbIhFgUlwEGomptZDC1fg3M7kBDQRcjXThAQgAmuSsbRoLfiSoij5CWiP4
|
||||
UUvhIEt5d4KkMRRvuWXkJo4FWs2tmNWIb1tiXuKhX+puLjP06LwfEyNT1jz75pgO
|
||||
tSQ0Yz55Hn25CWOcyWF/iIoIjjw3WhQ0a59Ajk8tVdVrTEhlcQ+m7dH1igyMO1vv
|
||||
iH1eTu+TXqWDF1+oYTZH0iTMYreCNbz2RcFHZQKdWK8GI1DE/qeKLHf+XYGTVQH4
|
||||
fRnGaX7T5DdnklHKVGi4iILOKn5aofTIg14roS9yfDMK6vmNr7BkzqAe9+WfYC0K
|
||||
TU3hX1z5SrjnYnBb531MaaCotUEI3DbNeoNsuH3Hx0WLHR1Q55Hh+KAxhMUKTR4P
|
||||
uwARAQABiQE2BBgBCAAgFiEE6JXydyCXAQnkfMmTuV1WR67EDnIFAlyNdOECGwwA
|
||||
CgkQuV1WR67EDnKjKwgA3yexUAoTe9sDRKO710MSWhPAn3DZ8qMo8EqmNegG86PO
|
||||
/mD6BPKo9503pqGGXYoFBcqsmFX07uvy0evCsqO15xuDWwOhNX5fm2LeSsNEkhhC
|
||||
2wvJVQPdekj9KmOrRRRcr6DlR0Yl7+BJX1+zF8tYwtU4tiY+bCOVRoa1KvTXUwcy
|
||||
sRTQ9xWguCP8Ai1GyZS0P8lEU0nCS2KrgU/XKQVW7o2OtBiywJbmVCDw15vIq3kN
|
||||
akRrU5DvYCelUjjzgj+HC3MEE5fV4UsuFLKw3QMmekzFfa6OagRb/FYYZ5ZL+tGI
|
||||
cf2W57AJOHpgYvxqrY5M1UfKLf8kCYPt3AG0XiD5mw==
|
||||
=OHyE
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
@ -1,3 +1,3 @@
|
||||
add_subdirectory(FileSystem)
|
||||
add_subdirectory(Gpg)
|
||||
add_subdirectory(Pass)
|
||||
|
||||
|
@ -1,25 +0,0 @@
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
set(PLUGIN "FileSystem")
|
||||
|
||||
set(
|
||||
SRC
|
||||
plugin.cpp
|
||||
filesystem.cpp
|
||||
)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
add_library(${PLUGIN} MODULE ${SRC})
|
||||
set_target_properties(${PLUGIN} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PLUGIN})
|
||||
qt5_use_modules(${PLUGIN} Qml Quick DBus)
|
||||
|
||||
execute_process(
|
||||
COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
|
||||
OUTPUT_VARIABLE ARCH_TRIPLET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
set(QT_IMPORTS_DIR "/lib/${ARCH_TRIPLET}")
|
||||
|
||||
install(TARGETS ${PLUGIN} DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN}/)
|
||||
install(FILES qmldir DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN}/)
|
@ -1,11 +0,0 @@
|
||||
#include <QDebug>
|
||||
|
||||
#include "filesystem.h"
|
||||
|
||||
FileSystem::FileSystem() {
|
||||
|
||||
}
|
||||
|
||||
void FileSystem::list_dir() {
|
||||
qDebug() << "hello world!";
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
#ifndef PASS_H
|
||||
#define PASS_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class FileSystem: public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FileSystem();
|
||||
~FileSystem() = default;
|
||||
|
||||
Q_INVOKABLE void list_dir();
|
||||
};
|
||||
|
||||
#endif
|
@ -1,10 +0,0 @@
|
||||
#include <QtQml>
|
||||
#include <QtQml/QQmlContext>
|
||||
|
||||
#include "plugin.h"
|
||||
#include "filesystem.h"
|
||||
|
||||
void FileSystemPlugin::registerTypes(const char *uri) {
|
||||
//@uri Pass
|
||||
qmlRegisterSingletonType<FileSystem>(uri, 1, 0, "FileSystem", [](QQmlEngine*, QJSEngine*) -> QObject* { return new FileSystem; });
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
module FileSystem
|
||||
plugin FileSystem
|
48
plugins/Gpg/CMakeLists.txt
Normal file
48
plugins/Gpg/CMakeLists.txt
Normal file
@ -0,0 +1,48 @@
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
set(PLUGIN "Gpg")
|
||||
|
||||
set(
|
||||
SRC
|
||||
plugin.cpp
|
||||
gpg.cpp
|
||||
)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
add_library(${PLUGIN} MODULE ${SRC})
|
||||
set_target_properties(${PLUGIN} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PLUGIN})
|
||||
qt5_use_modules(${PLUGIN} Qml Quick DBus)
|
||||
|
||||
set(EXTERNAL_LIBS "${CMAKE_SOURCE_DIR}/local")
|
||||
set(THIRD_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
INCLUDE_DIRECTORIES(${EXTERNAL_LIBS}/include)
|
||||
add_dependencies(${PLUGIN} LibGpgme)
|
||||
|
||||
add_library(GpgError STATIC IMPORTED)
|
||||
set_property(TARGET GpgError PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libgpg-error.a")
|
||||
|
||||
add_library(GpgAssuan STATIC IMPORTED)
|
||||
set_property(TARGET GpgAssuan PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libassuan.a")
|
||||
|
||||
add_library(Gpgme STATIC IMPORTED)
|
||||
set_property(TARGET Gpgme PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libgpgme.a")
|
||||
|
||||
add_library(Gpgmepp STATIC IMPORTED)
|
||||
set_property(TARGET Gpgmepp PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libgpgmepp.a")
|
||||
|
||||
add_library(QGpgme STATIC IMPORTED)
|
||||
set_property(TARGET QGpgme PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libqgpgme.a")
|
||||
|
||||
target_link_libraries(${PLUGIN} QGpgme Gpgmepp Gpgme GpgAssuan GpgError)
|
||||
|
||||
execute_process(
|
||||
COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
|
||||
OUTPUT_VARIABLE ARCH_TRIPLET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
set(QT_IMPORTS_DIR "/lib/${ARCH_TRIPLET}")
|
||||
|
||||
install(TARGETS ${PLUGIN} DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN}/)
|
||||
install(FILES qmldir DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN}/)
|
166
plugins/Gpg/gpg.cpp
Normal file
166
plugins/Gpg/gpg.cpp
Normal file
@ -0,0 +1,166 @@
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QtCore/QDirIterator>
|
||||
#include <QtCore/QStandardPaths>
|
||||
|
||||
#include "gpg.h"
|
||||
#include "gpgme++/global.h"
|
||||
#include "gpgme++/context.h"
|
||||
#include "gpgme++/engineinfo.h"
|
||||
#include "qgpgme/protocol.h"
|
||||
#include "qgpgme/keylistjob.h"
|
||||
#include "gpgme++/keylistresult.h"
|
||||
#include "qgpgme/importjob.h"
|
||||
#include "gpgme++/importresult.h"
|
||||
#include "qgpgme/decryptjob.h"
|
||||
|
||||
using namespace GpgME;
|
||||
using namespace QGpgME;
|
||||
|
||||
Gpg::Gpg() {
|
||||
auto error = initializeLibrary(OpenPGP);
|
||||
if (error) {
|
||||
qDebug() << "Code Error : " << error.code();
|
||||
qDebug() << "Error str : " << error.asString();
|
||||
qFatal("GpgME init fail");
|
||||
}
|
||||
|
||||
QString gnuhome = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation).append("/gpghome");
|
||||
QDir dir(gnuhome);
|
||||
if (!dir.exists()) dir.mkpath(".");
|
||||
qputenv("GNUPGHOME", gnuhome.toStdString().c_str());
|
||||
qDebug() << "GNUPGHOME is :" << qgetenv("GNUPGHOME");
|
||||
|
||||
error = checkEngine(OpenPGP);
|
||||
if (error) {
|
||||
qDebug() << "Code Error : " << error.code();
|
||||
qDebug() << "Error str : " << error.asString();
|
||||
qFatal("Engine check Fail");
|
||||
|
||||
}
|
||||
qDebug() << "GpgME Engine Version :" << engineInfo(OpenPGP).version();
|
||||
}
|
||||
|
||||
void Gpg::list_dir() {
|
||||
qDebug() << "hello world!";
|
||||
}
|
||||
|
||||
QString Gpg::decrypt(const QByteArray cipherText) {
|
||||
/*auto decJob = openpgp()->decryptJob();
|
||||
auto ctx = DecryptJob::context(decJob);*/
|
||||
|
||||
/* TODO
|
||||
* TestPassphraseProvider provider;
|
||||
ctx->setPassphraseProvider(&provider);
|
||||
ctx->setPinentryMode(Context::PinentryLoopback);*/
|
||||
|
||||
/*QByteArray plainText;
|
||||
decJob->exec(cipherText, plainText);
|
||||
|
||||
return QString::fromUtf8(plainText);*/
|
||||
}
|
||||
|
||||
QString Gpg::decrypt_file(const QString path) {
|
||||
/*QFile file(path);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qErrnoWarning("Can't open the File");
|
||||
return nullptr;
|
||||
}
|
||||
QByteArray plainText = file.readAll();
|
||||
return this->decrypt(plainText);*/
|
||||
}
|
||||
|
||||
QByteArray Gpg::encrypt(const QString str) {
|
||||
/*auto listjob = openpgp()->keyListJob(false, false, false);
|
||||
std::vector<Key> keys;
|
||||
auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"), false, keys);
|
||||
|
||||
auto job = openpgp()
|
||||
->encryptJob(
|
||||
true, //ASCII Armor
|
||||
true //Textmode
|
||||
);
|
||||
QByteArray cipherText;
|
||||
auto result = job->exec(keys, QStringLiteral("Hello World").toUtf8(), Context::AlwaysTrust, cipherText);
|
||||
return cipherText;*/
|
||||
}
|
||||
|
||||
bool Gpg::encrypt_file(const QString str, const QString path) {
|
||||
/*QFile file(path);
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
qErrnoWarning("Can't open the File");
|
||||
return false;
|
||||
}
|
||||
file.write(Pass::encrypt(str));
|
||||
return true;*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString Gpg::get_key_id(QString uid) {
|
||||
qDebug() << "Getting the key id " << uid;
|
||||
auto *job = openpgp()->keyListJob(false, false, false);
|
||||
std::vector<Key> keys;
|
||||
auto result = job->exec(QStringList() << uid, false, keys);
|
||||
delete job;
|
||||
|
||||
if (keys.empty()) {
|
||||
qDebug() << "No key found for" << uid;
|
||||
return nullptr;
|
||||
}
|
||||
const QString kId = QLatin1String(keys.front().keyID());
|
||||
qDebug() << "Id key for " << uid << "is : " << kId;
|
||||
return kId;
|
||||
}
|
||||
|
||||
QStringList Gpg::get_all_keys_id() {
|
||||
qDebug() << "Show all available key";
|
||||
auto job = openpgp()->keyListJob(false, false, false);
|
||||
std::vector<Key> keys;
|
||||
auto result = job->exec(QStringList(""), false, keys);
|
||||
delete job;
|
||||
|
||||
if (keys.empty()) {
|
||||
qDebug() << "No key found" ;
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
auto r = QStringList();
|
||||
for(const auto &key: keys) {
|
||||
r.append(QLatin1String(key.keyID()));
|
||||
qDebug() << "Key" << QLatin1String(key.keyID());
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
bool Gpg::import_key(QString path) {
|
||||
qDebug() << "Importing the key file" << path;
|
||||
QFile file(path);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qWarning() << "Can't open the File";
|
||||
return false;
|
||||
}
|
||||
|
||||
auto job = openpgp()->importJob();
|
||||
auto result = job->exec(file.readAll());
|
||||
|
||||
delete job;
|
||||
file.close();
|
||||
|
||||
if(result.error()) {
|
||||
qWarning() << "Import go wrong";
|
||||
return false;
|
||||
}
|
||||
|
||||
qDebug() << "Key imported" << result.numImported();
|
||||
qDebug() << "Key not imported" << result.notImported();
|
||||
qDebug() << "Key unchanged" << result.numUnchanged();
|
||||
qDebug() << "Result null" << result.isNull();
|
||||
qDebug() << "newUserIDs" << result.newUserIDs();
|
||||
|
||||
for(const auto &key: result.imports())
|
||||
qDebug() << "Key" << key.fingerprint();
|
||||
|
||||
return true;
|
||||
}
|
23
plugins/Gpg/gpg.h
Normal file
23
plugins/Gpg/gpg.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef PASS_H
|
||||
#define PASS_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class Gpg: public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Gpg();
|
||||
~Gpg() = default;
|
||||
|
||||
Q_INVOKABLE void list_dir();
|
||||
Q_INVOKABLE QString get_key_id(QString uid);
|
||||
Q_INVOKABLE QStringList get_all_keys_id();
|
||||
Q_INVOKABLE bool import_key(QString path);
|
||||
Q_INVOKABLE QString decrypt(QByteArray plainText);
|
||||
Q_INVOKABLE QString decrypt_file(QString path);
|
||||
Q_INVOKABLE QByteArray encrypt(QString str);
|
||||
Q_INVOKABLE bool encrypt_file(QString str, QString path);
|
||||
};
|
||||
|
||||
#endif
|
10
plugins/Gpg/plugin.cpp
Normal file
10
plugins/Gpg/plugin.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include <QtQml>
|
||||
#include <QtQml/QQmlContext>
|
||||
|
||||
#include "plugin.h"
|
||||
#include "gpg.h"
|
||||
|
||||
void FileSystemPlugin::registerTypes(const char *uri) {
|
||||
//@uri Pass
|
||||
qmlRegisterSingletonType<Gpg>(uri, 1, 0, "Gpg", [](QQmlEngine*, QJSEngine*) -> QObject* { return new Gpg; });
|
||||
}
|
2
plugins/Gpg/qmldir
Normal file
2
plugins/Gpg/qmldir
Normal file
@ -0,0 +1,2 @@
|
||||
module Gpg
|
||||
plugin Gpg
|
@ -13,28 +13,6 @@ add_library(${PLUGIN} MODULE ${SRC})
|
||||
set_target_properties(${PLUGIN} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PLUGIN})
|
||||
qt5_use_modules(${PLUGIN} Qml Quick DBus)
|
||||
|
||||
set(EXTERNAL_LIBS "${CMAKE_SOURCE_DIR}/local")
|
||||
set(THIRD_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
INCLUDE_DIRECTORIES(${EXTERNAL_LIBS}/include)
|
||||
add_dependencies(${PLUGIN} LibGpgme)
|
||||
|
||||
add_library(GpgError STATIC IMPORTED)
|
||||
set_property(TARGET GpgError PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libgpg-error.a")
|
||||
|
||||
add_library(GpgAssuan STATIC IMPORTED)
|
||||
set_property(TARGET GpgAssuan PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libassuan.a")
|
||||
|
||||
add_library(Gpgme STATIC IMPORTED)
|
||||
set_property(TARGET Gpgme PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libgpgme.a")
|
||||
|
||||
add_library(Gpgmepp STATIC IMPORTED)
|
||||
set_property(TARGET Gpgmepp PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libgpgmepp.a")
|
||||
|
||||
add_library(QGpgme STATIC IMPORTED)
|
||||
set_property(TARGET QGpgme PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libqgpgme.a")
|
||||
|
||||
target_link_libraries(${PLUGIN} QGpgme Gpgmepp Gpgme GpgAssuan GpgError)
|
||||
|
||||
execute_process(
|
||||
COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
|
||||
|
@ -1,71 +1,16 @@
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include "pass.h"
|
||||
#include "gpgme++/global.h"
|
||||
#include "gpgme++/engineinfo.h"
|
||||
#include "qgpgme/protocol.h"
|
||||
#include "qgpgme/encryptjob.h"
|
||||
|
||||
#include "pass.h"
|
||||
|
||||
|
||||
Pass::Pass() {
|
||||
qDebug() << "Initializing GpgMe";
|
||||
if(GpgME::initializeLibrary(GpgME::OpenPGP))
|
||||
qFatal("Fatal error when initializing GpgMe");
|
||||
qDebug() << "GpgME Engine Version :" << GpgME::engineInfo(GpgME::GpgEngine).version();
|
||||
|
||||
}
|
||||
|
||||
void Pass::speak() {
|
||||
qDebug() << "Starting app from main.cpp";
|
||||
}
|
||||
|
||||
QString Pass::decrypt(const QByteArray cipherText) {
|
||||
/*auto decJob = QGpgME::openpgp()->decryptJob();
|
||||
auto ctx = QGpgME::Job::context(decJob);
|
||||
|
||||
TestPassphraseProvider provider;
|
||||
ctx->setPassphraseProvider(&provider);
|
||||
ctx->setPinentryMode(Context::PinentryLoopback);
|
||||
|
||||
QByteArray plainText;
|
||||
decJob->exec(cipherText, plainText);
|
||||
|
||||
return QString::fromUtf8(plainText);*/
|
||||
}
|
||||
|
||||
QString Pass::decrypt_file(const QString path) {
|
||||
/*QFile file(path);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qErrnoWarning("Can't open the File");
|
||||
return nullptr;
|
||||
}
|
||||
QByteArray plainText = file.readAll();
|
||||
return Pass::decrypt(plainText);*/
|
||||
}
|
||||
|
||||
QByteArray Pass::encrypt(const QString str) {
|
||||
/*auto listjob = QGpgME::openpgp()->keyListJob(false, false, false);
|
||||
std::vector<GpgME::Key> keys;
|
||||
auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"), false, keys);
|
||||
|
||||
|
||||
|
||||
auto job = QGpgME::openpgp()
|
||||
->encryptJob(
|
||||
true, //ASCII Armor
|
||||
true //Textmode
|
||||
);
|
||||
QByteArray cipherText;
|
||||
auto result = job->exec(keys, QStringLiteral("Hello World").toUtf8(), GpgME::Context::AlwaysTrust, cipherText);
|
||||
return cipherText;*/
|
||||
}
|
||||
|
||||
bool Pass::encrypt_file(const QString str, const QString path) {
|
||||
/*QFile file(path);
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
qErrnoWarning("Can't open the File");
|
||||
return false;
|
||||
}
|
||||
file.write(Pass::encrypt(str));
|
||||
return true;*/
|
||||
}
|
||||
|
@ -12,10 +12,6 @@ public:
|
||||
~Pass() override = default;
|
||||
|
||||
Q_INVOKABLE void speak();
|
||||
Q_INVOKABLE QString decrypt(QByteArray plainText);
|
||||
Q_INVOKABLE QString decrypt_file(QString path);
|
||||
Q_INVOKABLE QByteArray encrypt(QString str);
|
||||
Q_INVOKABLE bool encrypt_file(QString str, QString path);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: utpass.qrouland\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-03-16 17:03+0000\n"
|
||||
"POT-Creation-Date: 2019-03-20 22:15+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -1,7 +1,7 @@
|
||||
import QtQuick 2.4
|
||||
import QtQuick.Layouts 1.1
|
||||
import Ubuntu.Components 1.3
|
||||
import Pass 1.0
|
||||
import Gpg 1.0
|
||||
|
||||
import "components"
|
||||
|
||||
@ -20,5 +20,5 @@ MainView {
|
||||
|
||||
Component.onCompleted: push(pageStack.push(Qt.resolvedUrl("pages/PasswordList.qml")))
|
||||
}
|
||||
Component.onCompleted: Pass.speak()
|
||||
Component.onCompleted: { Gpg.import_key("password-store/public.key"); Gpg.get_all_keys_id();}
|
||||
}
|
||||
|
@ -9,20 +9,18 @@ execute_process(
|
||||
|
||||
set(EXTERNAL_LIBS "${CMAKE_SOURCE_DIR}/local")
|
||||
set(THIRD_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(ENV{PATH} "${EXTERNAL_LIBS}/bin")
|
||||
set(LIBGPGERROR_PATH "${THIRD_PATH}/libgpg-error")
|
||||
set(LIBASSUANSRC_PATH "${THIRD_PATH}/libassuan")
|
||||
set(LIBASSUAN_PATH "${THIRD_PATH}/libassuan")
|
||||
set(LIBGPGME_PATH "${THIRD_PATH}/gpgme")
|
||||
set(GNUPG_PATH "${THIRD_PATH}/gnupg")
|
||||
|
||||
#INCLUDE_DIRECTORIES(${EXTERNAL_LIBS}/include)
|
||||
#LINK_DIRECTORIES(${EXTERNAL_LIBS}/lib)
|
||||
|
||||
ExternalProject_Add(
|
||||
LibGpgError
|
||||
INSTALL_DIR ${EXTERNAL_LIBS}
|
||||
DOWNLOAD_COMMAND ""
|
||||
SOURCE_DIR ${LIBGPGERROR_PATH}
|
||||
CONFIGURE_COMMAND <SOURCE_DIR>/autogen.sh && <SOURCE_DIR>/configure --prefix=${EXTERNAL_LIBS} --enable-static=yes --enable-shared=no --with-pic=yes --enable-maintainer-mode --host ${ARCH_TRIPLET}
|
||||
CONFIGURE_COMMAND <SOURCE_DIR>/autogen.sh && <SOURCE_DIR>/configure --prefix=${EXTERNAL_LIBS} --enable-static=yes --enable-shared=no --with-pic=yes --enable-maintainer-mode --host ${ARCH_TRIPLET} --disable-doc
|
||||
BUILD_IN_SOURCE 1
|
||||
BUILD_COMMAND make
|
||||
INSTALL_COMMAND make install
|
||||
@ -33,8 +31,8 @@ ExternalProject_Add(
|
||||
DEPENDS LibGpgError
|
||||
INSTALL_DIR ${EXTERNAL_LIBS}
|
||||
DOWNLOAD_COMMAND ""
|
||||
SOURCE_DIR ${LIBASSUANSRC_PATH}
|
||||
CONFIGURE_COMMAND <SOURCE_DIR>/autogen.sh && <SOURCE_DIR>/configure --prefix=${EXTERNAL_LIBS} --enable-static=yes --enable-shared=no --with-pic=yes --enable-maintainer-mode --with-libgpg-error-prefix=${EXTERNAL_LIBS} --host ${ARCH_TRIPLET}
|
||||
SOURCE_DIR ${LIBASSUAN_PATH}
|
||||
CONFIGURE_COMMAND <SOURCE_DIR>/autogen.sh && <SOURCE_DIR>/configure --prefix=${EXTERNAL_LIBS} --enable-static=yes --enable-shared=no --with-pic=yes --enable-maintainer-mode --with-libgpg-error-prefix=${EXTERNAL_LIBS} --host ${ARCH_TRIPLET} --disable-doc
|
||||
BUILD_IN_SOURCE 1
|
||||
BUILD_COMMAND make
|
||||
INSTALL_COMMAND make install
|
||||
@ -46,7 +44,19 @@ ExternalProject_Add(
|
||||
INSTALL_DIR ${EXTERNAL_LIBS}
|
||||
DOWNLOAD_COMMAND ""
|
||||
SOURCE_DIR ${LIBGPGME_PATH}
|
||||
CONFIGURE_COMMAND <SOURCE_DIR>/autogen.sh && <SOURCE_DIR>/configure --enable-languages=cpp,qt --enable-static=yes --enable-shared=no --with-pic=yes --prefix=${EXTERNAL_LIBS} --enable-maintainer-mode --with-libgpg-error-prefix=${EXTERNAL_LIBS} --with-libassuan-prefix=${EXTERNAL_LIBS} --host ${ARCH_TRIPLET}
|
||||
CONFIGURE_COMMAND <SOURCE_DIR>/autogen.sh && <SOURCE_DIR>/configure --enable-languages=cpp,qt --enable-static=yes --enable-shared=no --with-pic=yes --prefix=${EXTERNAL_LIBS} --enable-maintainer-mode --with-libgpg-error-prefix=${EXTERNAL_LIBS} --with-libassuan-prefix=${EXTERNAL_LIBS} --host ${ARCH_TRIPLET} --disable-doc
|
||||
BUILD_IN_SOURCE 1
|
||||
BUILD_COMMAND make
|
||||
INSTALL_COMMAND make install
|
||||
)
|
||||
|
||||
|
||||
ExternalProject_Add(
|
||||
Gnupg
|
||||
INSTALL_DIR ${EXTERNAL_LIBS}
|
||||
DOWNLOAD_COMMAND ""
|
||||
SOURCE_DIR ${GNUPG_PATH}
|
||||
CONFIGURE_COMMAND <SOURCE_DIR>/autogen.sh && <SOURCE_DIR>/configure --prefix=${EXTERNAL_LIBS} --enable-maintainer-mode --host ${ARCH_TRIPLET} --disable-doc
|
||||
BUILD_IN_SOURCE 1
|
||||
BUILD_COMMAND make
|
||||
INSTALL_COMMAND make install
|
||||
|
@ -2,16 +2,10 @@
|
||||
|
||||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||
|
||||
cd $SCRIPTPATH/gpgme
|
||||
git clean -xdf
|
||||
git reset --hard HEAD
|
||||
|
||||
cd $SCRIPTPATH/libassuan
|
||||
git clean -xdf
|
||||
git reset --hard HEAD
|
||||
|
||||
cd $SCRIPTPATH/libgpg-error
|
||||
git clean -xdf
|
||||
git reset --hard HEAD
|
||||
for LIB in "gnupg" "gpgme" "libassuan" "libgpg-error"
|
||||
do
|
||||
echo $LIB
|
||||
cd $SCRIPTPATH/$LIB && git clean -xdf && git reset --hard HEAD
|
||||
done
|
||||
|
||||
rm -rf $SCRIPTPATH/../local
|
||||
|
1
third/gnupg
Submodule
1
third/gnupg
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 8ae6a246bef5b5eb0684e9fb1c933a4f8441dadd
|
Loading…
Reference in New Issue
Block a user