1
0
mirror of https://github.com/QRouland/UTPass.git synced 2025-07-04 03:02:28 +00:00

Fix build rnp for arm64

This commit is contained in:
2025-02-03 17:48:30 +01:00
parent b9b038b1ae
commit 93361f9ba5
27 changed files with 365 additions and 147 deletions

View File

@ -1,7 +1,13 @@
#include "decryptjob.h"
#include "qdebug.h"
extern "C" {
#include <rnp/rnp.h>
#include <rnp/rnp_err.h>
}
DecryptJob::DecryptJob(QString path, QString keyfile):
m_path(path)
DecryptJob::DecryptJob(QDir rnp_homedir, QString path):
RnpJob(rnp_homedir),
m_encrypted_file_path(path)
{
this->setObjectName("DecryptJob");
}
@ -9,7 +15,33 @@ DecryptJob::DecryptJob(QString path, QString keyfile):
void DecryptJob::run()
{
this->load_sec_keyring();
rnp_input_from_path(&keyfile, "secring.pgp"));
qFatal("To be implemented !")
qDebug() << "[DecryptJob] Starting";
this->load_sec_keyring(NULL);
rnp_input_t input = NULL;
rnp_output_t output = NULL;
uint8_t * buf = NULL;
size_t buf_len = 0;
auto ret = rnp_input_from_path(&input, this->m_encrypted_file_path.toLocal8Bit().data());
if (ret == RNP_SUCCESS) {
ret = rnp_output_to_memory(&output, 0);
}
if (ret == RNP_SUCCESS) {
ret = rnp_decrypt(this->m_ffi, input, output);
}
if (ret == RNP_SUCCESS) {
ret = rnp_output_memory_get_buf(output, &buf, &buf_len, false);
}
if (ret == RNP_SUCCESS) {
emit resultSuccess(this->m_encrypted_file_path, QString::fromUtf8((char*)buf));
}
rnp_input_destroy(input);
rnp_output_destroy(output);
terminateOnError(ret);
emit resultSuccess(this->m_encrypted_file_path, QString::fromUtf8((char*)buf));
qDebug() << "[DecryptJob] Finished Successfully ";
}

View File

@ -34,7 +34,7 @@ signals:
* @param encrypted_file_path The path to the encrypted file that was decrypted.
* @param clear_txt The decrypted content in clear-text. If an error occurs, this may be empty.
*/
void resultReady(QString encrypted_file_path, QString clear_txt);
void resultSuccess(QString encrypted_file_path, QString clear_txt);
private:
QString m_encrypted_file_path; /**< The path to the encrypted file that is to be decrypted. */
@ -46,9 +46,10 @@ public:
* This constructor initializes the DecryptJob with the encrypted file path. The decryption
* operation will be executed in a background thread when the job is started.
*
* @param rnp_homedir The directory containing the keyrings.
* @param path The path to the encrypted file that needs to be decrypted.
*/
DecryptJob(QString path);
DecryptJob(QDir rnp_homedir, QString path);
};
#endif // DECRYPTJOB_H

View File

@ -32,13 +32,14 @@ void GetKeysJob::run()
QSet<QString> fingerprints = QSet<QString>();
this->load_full_keyring(&fingerprints);
//Get infos keys
auto key_infos = QList<QJsonDocument>();
QList<QJsonDocument>::iterator i;
for (auto i = fingerprints.begin(), end = fingerprints.end(); i != end; ++i) {
key_infos.append(this->fingerprint_map_key_info(*i));
}
//Get all infos keys
// Emit result
emit resultSuccess(key_infos);
qDebug() << "[GetKeysJob] Finished Successfully ";
}

View File

@ -52,7 +52,7 @@ bool RnpJob::passProvider(rnp_ffi_t ffi,
void RnpJob::load_key_file(QSet<QString> *result_fingerprints, const QString path, const uint32_t flags)
{
qDebug() << "[RnpJob] load keyring at" << path;
qDebug() << "[RnpJob] Load keyring at" << path;
rnp_input_t input = NULL;
if (QFileInfo::exists(this->pubringPath())) {
auto ret = rnp_input_from_path(&input, path.toLocal8Bit().constData());
@ -75,9 +75,9 @@ void RnpJob::load_key_file(QSet<QString> *result_fingerprints, const QString pat
rnp_input_destroy(input);
rnp_buffer_destroy(json);
terminateOnError(ret);
qDebug() << "[RnpJob] keyring loaded successfully";
qDebug() << "[RnpJob] Keyring loaded successfully";
} else {
qDebug() << "[RnpJob] No keyring" << path << "not found";
qDebug() << "[RnpJob] Keyring" << path << "not found";
}
}
@ -85,18 +85,15 @@ void RnpJob::load_key_file(QSet<QString> *result_fingerprints, const QString pat
void RnpJob::load_pub_keyring(QSet<QString> *result_fingerprints = NULL)
{
this->load_key_file(result_fingerprints, this->pubringPath(), RNP_LOAD_SAVE_PUBLIC_KEYS);
qDebug() << "[RnpJob] pub fingerprints" << *result_fingerprints;
}
void RnpJob::load_sec_keyring(QSet<QString> *result_fingerprints = NULL)
{
this->load_key_file(result_fingerprints, this->secringPath(), RNP_LOAD_SAVE_SECRET_KEYS);
qDebug() << "[RnpJob] sec fingerprints" << *result_fingerprints;
}
void RnpJob::load_full_keyring(QSet<QString> *result_fingerprints = NULL)
{
this->load_pub_keyring(result_fingerprints);
this->load_sec_keyring(result_fingerprints);
qDebug() << "[RnpJob] full fingerprints" << *result_fingerprints;
}

View File

@ -153,6 +153,11 @@ public:
* the RNP FFI handle.
*/
~RnpJob();
void setPassProvider(rnp_password_cb pass_provider_cb) {
rnp_ffi_set_pass_provider(this->m_ffi, pass_provider_cb, NULL);
}
};
#endif // RNPJOB_H