diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp index 174a3c3b..e8e57dc8 100644 --- a/lang/cpp/src/context.cpp +++ b/lang/cpp/src/context.cpp @@ -612,7 +612,7 @@ Error Context::startKeyExport(const char *patterns[], Data &keyData, unsigned in Error Context::exportPublicKeys(const char *pattern, Data &keyData, unsigned int mode) { - if (mode & ExportSecret) { + if (mode & (ExportSecret | ExportSecretSubkey)) { return Error::fromCode(GPG_ERR_INV_FLAG); } return exportKeys(pattern, keyData, mode); @@ -620,7 +620,7 @@ Error Context::exportPublicKeys(const char *pattern, Data &keyData, unsigned int Error Context::exportPublicKeys(const char *patterns[], Data &keyData, unsigned int mode) { - if (mode & ExportSecret) { + if (mode & (ExportSecret | ExportSecretSubkey)) { return Error::fromCode(GPG_ERR_INV_FLAG); } return exportKeys(patterns, keyData, mode); @@ -628,7 +628,7 @@ Error Context::exportPublicKeys(const char *patterns[], Data &keyData, unsigned Error Context::startPublicKeyExport(const char *pattern, Data &keyData, unsigned int mode) { - if (mode & ExportSecret) { + if (mode & (ExportSecret | ExportSecretSubkey)) { return Error::fromCode(GPG_ERR_INV_FLAG); } return startKeyExport(pattern, keyData, mode); @@ -636,7 +636,7 @@ Error Context::startPublicKeyExport(const char *pattern, Data &keyData, unsigned Error Context::startPublicKeyExport(const char *patterns[], Data &keyData, unsigned int mode) { - if (mode & ExportSecret) { + if (mode & (ExportSecret | ExportSecretSubkey)) { return Error::fromCode(GPG_ERR_INV_FLAG); } return startKeyExport(patterns, keyData, mode); @@ -695,6 +695,26 @@ Error Context::startSecretKeyExport(const char *patterns[], Data &keyData, unsig return startKeyExport(patterns, keyData, mode|ExportSecret); } +Error Context::exportSecretSubkeys(const char *pattern, Data &keyData, unsigned int mode) +{ + return exportKeys(pattern, keyData, mode|ExportSecretSubkey); +} + +Error Context::exportSecretSubkeys(const char *patterns[], Data &keyData, unsigned int mode) +{ + return exportKeys(patterns, keyData, mode|ExportSecretSubkey); +} + +Error Context::startSecretSubkeyExport(const char *pattern, Data &keyData, unsigned int mode) +{ + return startKeyExport(pattern, keyData, mode|ExportSecretSubkey); +} + +Error Context::startSecretSubkeyExport(const char *patterns[], Data &keyData, unsigned int mode) +{ + return startKeyExport(patterns, keyData, mode|ExportSecretSubkey); +} + ImportResult Context::importKeys(const Data &data) { d->lastop = Private::Import; diff --git a/lang/cpp/src/context.h b/lang/cpp/src/context.h index 2631678a..bfa6b8d8 100644 --- a/lang/cpp/src/context.h +++ b/lang/cpp/src/context.h @@ -191,6 +191,7 @@ public: ExportPKCS12 = 64, ExportNoUID = 128, // obsolete; has no effect ExportSSH = 256, + ExportSecretSubkey = 512, }; GpgME::Error exportPublicKeys(const char *pattern, Data &keyData); @@ -207,6 +208,11 @@ public: GpgME::Error startSecretKeyExport(const char *pattern, Data &keyData, unsigned int mode = ExportSecret); GpgME::Error startSecretKeyExport(const char *pattern[], Data &keyData, unsigned int mode = ExportSecret); + GpgME::Error exportSecretSubkeys(const char *pattern, Data &keyData, unsigned int mode = ExportSecretSubkey); + GpgME::Error exportSecretSubkeys(const char *pattern[], Data &keyData, unsigned int mode = ExportSecretSubkey); + GpgME::Error startSecretSubkeyExport(const char *pattern, Data &keyData, unsigned int mode = ExportSecretSubkey); + GpgME::Error startSecretSubkeyExport(const char *pattern[], Data &keyData, unsigned int mode = ExportSecretSubkey); + // generic export functions; prefer using the specific public/secret key export functions GpgME::Error exportKeys(const char *pattern, Data &keyData, unsigned int mode = ExportDefault); GpgME::Error exportKeys(const char *pattern[], Data &keyData, unsigned int mode = ExportDefault);