cpp: Allow export of secret subkeys
* lang/cpp/src/context.h (enum Context::ExportMode): Add value ExportSecretSubkey. (class Context): Add member functions exportSecretSubkeys and startSecretSubkeyExport. * lang/cpp/src/context.cpp (Context::exportPublicKeys, Context::startPublicKeyExport): Return error if ExportSecretSubkey mode flag is set. (Context::exportSecretSubkeys, Context::startSecretSubkeyExport): Implement. -- GnuPG-bug-id: 5757
This commit is contained in:
parent
88ad37ea96
commit
e5c7fc3e02
@ -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)
|
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 Error::fromCode(GPG_ERR_INV_FLAG);
|
||||||
}
|
}
|
||||||
return exportKeys(pattern, keyData, mode);
|
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)
|
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 Error::fromCode(GPG_ERR_INV_FLAG);
|
||||||
}
|
}
|
||||||
return exportKeys(patterns, keyData, mode);
|
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)
|
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 Error::fromCode(GPG_ERR_INV_FLAG);
|
||||||
}
|
}
|
||||||
return startKeyExport(pattern, keyData, mode);
|
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)
|
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 Error::fromCode(GPG_ERR_INV_FLAG);
|
||||||
}
|
}
|
||||||
return startKeyExport(patterns, keyData, mode);
|
return startKeyExport(patterns, keyData, mode);
|
||||||
@ -695,6 +695,26 @@ Error Context::startSecretKeyExport(const char *patterns[], Data &keyData, unsig
|
|||||||
return startKeyExport(patterns, keyData, mode|ExportSecret);
|
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)
|
ImportResult Context::importKeys(const Data &data)
|
||||||
{
|
{
|
||||||
d->lastop = Private::Import;
|
d->lastop = Private::Import;
|
||||||
|
@ -191,6 +191,7 @@ public:
|
|||||||
ExportPKCS12 = 64,
|
ExportPKCS12 = 64,
|
||||||
ExportNoUID = 128, // obsolete; has no effect
|
ExportNoUID = 128, // obsolete; has no effect
|
||||||
ExportSSH = 256,
|
ExportSSH = 256,
|
||||||
|
ExportSecretSubkey = 512,
|
||||||
};
|
};
|
||||||
|
|
||||||
GpgME::Error exportPublicKeys(const char *pattern, Data &keyData);
|
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 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
|
// 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);
|
||||||
GpgME::Error exportKeys(const char *pattern[], Data &keyData, unsigned int mode = ExportDefault);
|
GpgME::Error exportKeys(const char *pattern[], Data &keyData, unsigned int mode = ExportDefault);
|
||||||
|
Loading…
Reference in New Issue
Block a user