From 42a59cbd01de7a7719ccb3b54aecd528a4fc9477 Mon Sep 17 00:00:00 2001 From: heck Date: Sun, 26 Apr 2020 23:37:19 +0200 Subject: [PATCH] Add feature export_secret_key(Identity) --- src/basic_api.cc | 11 +++++++++++ src/basic_api.hh | 1 + src/pEpmodule.cc | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/src/basic_api.cc b/src/basic_api.cc index e6c9146..05f3e30 100644 --- a/src/basic_api.cc +++ b/src/basic_api.cc @@ -130,6 +130,17 @@ namespace pEp { return key_data; } + string export_secret_key(Identity ident) + { + PEP_STATUS status = PEP_STATUS_OK; + char* key_data = NULL; + size_t size; + status = ::export_secret_key(adapter.session(), ident.fpr().c_str(), &key_data, &size); + + _throw_status(status); + return key_data; + } + void set_own_key(Identity& ident, string fpr) { if (ident.address() == "") diff --git a/src/basic_api.hh b/src/basic_api.hh index 8daf888..e1ace2d 100644 --- a/src/basic_api.hh +++ b/src/basic_api.hh @@ -19,6 +19,7 @@ namespace pEp { boost::python::list import_key(string key_data); string export_key(Identity ident); + string export_secret_key(Identity ident); void set_own_key(Identity& ident, string fpr); } } diff --git a/src/pEpmodule.cc b/src/pEpmodule.cc index 4312f05..0628370 100644 --- a/src/pEpmodule.cc +++ b/src/pEpmodule.cc @@ -451,6 +451,12 @@ BOOST_PYTHON_MODULE(pEp) "export key(s) of identity\n" ); + def("export_secret_key", &pEp::PythonAdapter::export_secret_key, + "key_data = export_seret_key(identity)\n" + "\n" + "export secret key(s) of identity\n" + ); + def("set_own_key", &pEp::PythonAdapter::set_own_key, "set_own_key(me, fpr)\n" "\n"