aboutsummaryrefslogtreecommitdiffstats
path: root/src/sdk
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-11-28 22:12:49 +0000
committersaturneric <[email protected]>2024-11-28 22:12:49 +0000
commitb04f7d469de41ad2dddfad8017fceaa6aa5c176c (patch)
treea9abd928f338956d2d995f6d55c75439cc35b5ed /src/sdk
parentfix: reduce unnecessary cache write to disk (diff)
downloadGpgFrontend-b04f7d469de41ad2dddfad8017fceaa6aa5c176c.tar.gz
GpgFrontend-b04f7d469de41ad2dddfad8017fceaa6aa5c176c.zip
fix: solve discoverd issues on email functions
Diffstat (limited to 'src/sdk')
-rw-r--r--src/sdk/GFSDKGpg.cpp52
-rw-r--r--src/sdk/GFSDKGpg.h4
2 files changed, 41 insertions, 15 deletions
diff --git a/src/sdk/GFSDKGpg.cpp b/src/sdk/GFSDKGpg.cpp
index 4dd23417..52ea0520 100644
--- a/src/sdk/GFSDKGpg.cpp
+++ b/src/sdk/GFSDKGpg.cpp
@@ -68,7 +68,14 @@ auto GPGFRONTEND_MODULE_SDK_EXPORT GFGpgSignData(int channel, char** key_ids,
GpgFrontend::GpgBasicOperator::GetInstance(channel).SignSync(
signer_keys, in_buffer, gpg_sign_mode, ascii != 0);
- if (GpgFrontend::CheckGpgError(err) != GPG_ERR_NO_ERROR) return -1;
+ *ps =
+ static_cast<GFGpgSignResult*>(GFAllocateMemory(sizeof(GFGpgSignResult)));
+ auto* s = *ps;
+
+ if (GpgFrontend::CheckGpgError(err) != GPG_ERR_NO_ERROR) {
+ s->error_string = GFStrDup(GpgFrontend::DescribeGpgErrCode(err).second);
+ return -1;
+ }
auto result =
GpgFrontend::ExtractParams<GpgFrontend::GpgSignResult>(data_object, 0);
@@ -78,12 +85,10 @@ auto GPGFRONTEND_MODULE_SDK_EXPORT GFGpgSignData(int channel, char** key_ids,
auto capsule_id =
GpgFrontend::UI::UIModuleManager::GetInstance().MakeCapsule(result);
- *ps =
- static_cast<GFGpgSignResult*>(GFAllocateMemory(sizeof(GFGpgSignResult)));
- auto* s = *ps;
s->signature = GFStrDup(out_buffer.ConvertToQByteArray());
s->hash_algo = GFStrDup(result.HashAlgo());
s->capsule_id = GFStrDup(capsule_id);
+ s->error_string = GFStrDup(GpgFrontend::DescribeGpgErrCode(err).second);
return 0;
}
@@ -142,7 +147,14 @@ GFGpgEncryptData(int channel, char** key_ids, int key_ids_size, char* data,
GpgFrontend::GpgBasicOperator::GetInstance(channel).EncryptSync(
encrypt_keys, in_buffer, ascii != 0);
- if (GpgFrontend::CheckGpgError(err) != GPG_ERR_NO_ERROR) return -1;
+ *ps = static_cast<GFGpgEncryptionResult*>(
+ GFAllocateMemory(sizeof(GFGpgEncryptionResult)));
+ auto* s = *ps;
+
+ if (GpgFrontend::CheckGpgError(err) != GPG_ERR_NO_ERROR) {
+ s->error_string = GFStrDup(GpgFrontend::DescribeGpgErrCode(err).second);
+ return -1;
+ }
auto result =
GpgFrontend::ExtractParams<GpgFrontend::GpgEncryptResult>(data_object, 0);
@@ -152,11 +164,9 @@ GFGpgEncryptData(int channel, char** key_ids, int key_ids_size, char* data,
auto capsule_id =
GpgFrontend::UI::UIModuleManager::GetInstance().MakeCapsule(result);
- *ps = static_cast<GFGpgEncryptionResult*>(
- GFAllocateMemory(sizeof(GFGpgEncryptionResult)));
- auto* s = *ps;
s->encrypted_data = GFStrDup(out_buffer.ConvertToQByteArray());
s->capsule_id = GFStrDup(capsule_id);
+ s->error_string = GFStrDup(GpgFrontend::DescribeGpgErrCode(err).second);
return 0;
}
@@ -168,7 +178,14 @@ GFGpgDecryptData(int channel, char* data, GFGpgDecryptResult** ps) -> int {
GpgFrontend::GpgBasicOperator::GetInstance(channel).DecryptSync(
in_buffer);
- if (GpgFrontend::CheckGpgError(err) != GPG_ERR_NO_ERROR) return -1;
+ *ps = static_cast<GFGpgDecryptResult*>(
+ GFAllocateMemory(sizeof(GFGpgDecryptResult)));
+ auto* s = *ps;
+
+ if (GpgFrontend::CheckGpgError(err) != GPG_ERR_NO_ERROR) {
+ s->error_string = GFStrDup(GpgFrontend::DescribeGpgErrCode(err).second);
+ return -1;
+ }
auto result =
GpgFrontend::ExtractParams<GpgFrontend::GpgDecryptResult>(data_object, 0);
@@ -178,11 +195,9 @@ GFGpgDecryptData(int channel, char* data, GFGpgDecryptResult** ps) -> int {
auto capsule_id =
GpgFrontend::UI::UIModuleManager::GetInstance().MakeCapsule(result);
- *ps = static_cast<GFGpgDecryptResult*>(
- GFAllocateMemory(sizeof(GFGpgDecryptResult)));
- auto* s = *ps;
s->decrypted_data = GFStrDup(out_buffer.ConvertToQByteArray());
s->capsule_id = GFStrDup(capsule_id);
+ s->error_string = GFStrDup(GpgFrontend::DescribeGpgErrCode(err).second);
return 0;
}
@@ -195,6 +210,15 @@ auto GPGFRONTEND_MODULE_SDK_EXPORT GFGpgVerifyData(
GpgFrontend::GpgBasicOperator::GetInstance(channel).VerifySync(
in_buffer, sig_buffer);
+ *ps = static_cast<GFGpgVerifyResult*>(
+ GFAllocateMemory(sizeof(GFGpgVerifyResult)));
+ auto* s = *ps;
+
+ if (GpgFrontend::CheckGpgError(err) != GPG_ERR_NO_ERROR) {
+ s->error_string = GFStrDup(GpgFrontend::DescribeGpgErrCode(err).second);
+ return -1;
+ }
+
if (GpgFrontend::CheckGpgError(err) != GPG_ERR_NO_ERROR) return -1;
auto result =
@@ -203,9 +227,7 @@ auto GPGFRONTEND_MODULE_SDK_EXPORT GFGpgVerifyData(
auto capsule_id =
GpgFrontend::UI::UIModuleManager::GetInstance().MakeCapsule(result);
- *ps = static_cast<GFGpgVerifyResult*>(
- GFAllocateMemory(sizeof(GFGpgVerifyResult)));
- auto* s = *ps;
s->capsule_id = GFStrDup(capsule_id);
+ s->error_string = GFStrDup(GpgFrontend::DescribeGpgErrCode(err).second);
return 0;
}
diff --git a/src/sdk/GFSDKGpg.h b/src/sdk/GFSDKGpg.h
index ac166a54..8977a975 100644
--- a/src/sdk/GFSDKGpg.h
+++ b/src/sdk/GFSDKGpg.h
@@ -36,20 +36,24 @@ struct GFGpgSignResult {
char* signature;
char* hash_algo;
char* capsule_id;
+ char* error_string;
};
struct GFGpgEncryptionResult {
char* encrypted_data;
char* capsule_id;
+ char* error_string;
};
struct GFGpgDecryptResult {
char* decrypted_data;
char* capsule_id;
+ char* error_string;
};
struct GFGpgVerifyResult {
char* capsule_id;
+ char* error_string;
};
struct GFGpgKeyUID {