1
0
mirror of https://github.com/QRouland/UTPass.git synced 2026-01-10 19:36:57 +00:00

Rewrite import key with rnp

This commit is contained in:
2025-01-29 16:42:37 +01:00
parent c01fae0c58
commit 2c9d82e0b1
30 changed files with 654 additions and 719 deletions

View File

@@ -0,0 +1,42 @@
#include <QDebug>
#include "rnpjob.h"
extern "C" {
#include <rnp/rnp.h>
#include <rnp/rnp_err.h>
}
RnpJob::RnpJob(QDir rnp_homedir):
m_rnp_homedir(rnp_homedir)
{
auto ret = rnp_ffi_create(&this->m_ffi,
RNP_KEYSTORE_GPG,
RNP_KEYSTORE_GPG);
if(ret != RNP_SUCCESS) {
qDebug() << "Err : " << ret;
qFatal("Error on rnp ffi init!");
}
}
RnpJob::~RnpJob(){
auto ret = rnp_ffi_destroy(this->m_ffi);
if(ret != RNP_SUCCESS) {
qDebug() << "Err : " << ret;
qFatal("Something go wrong on rnp ffi detroy");
}
}
bool RnpJob::passProvider(rnp_ffi_t ffi,
void * app_ctx,
rnp_key_handle_t key,
const char * pgp_context,
char buf[],
size_t buf_len)
{
if (strcmp(pgp_context, "protect")) {
return false;
}
strncpy(buf, "password", buf_len);
return true;
}