Browse Source

import_key()

PYADPT-55
Volker Birk 6 years ago
parent
commit
d6f4631f55
  1. 22
      src/basic_api.cc
  2. 2
      src/basic_api.hh
  3. 6
      src/pEpmodule.cc

22
src/basic_api.cc

@ -83,7 +83,8 @@ namespace pEp {
_throw_status(status);
}
void key_reset_trust(Identity ident) {
void key_reset_trust(Identity ident)
{
if (ident.fpr() == "")
throw invalid_argument("address needed");
if (ident.address() == "")
@ -94,6 +95,25 @@ namespace pEp {
PEP_STATUS status = key_reset_trust(adapter.session(), ident);
_throw_status(status);
}
boost::python::list import_key(string key_data)
{
::identity_list *private_keys = NULL;
PEP_STATUS status = ::import_key(adapter.session(), key_data.c_str(), key_data.size(), &private_keys);
if (status && status != PEP_KEY_IMPORTED)
_throw_status(status);
auto result = boost::python::list();
for (::identity_list *il = private_keys; il && il->ident; il=il->next) {
::pEp_identity *ident = ::identity_dup(il->ident);
if (!ident)
throw bad_alloc();
result.append(Identity(ident));
il = il->next;
}
return result;
}
}
}

2
src/basic_api.hh

@ -20,6 +20,8 @@ namespace pEp {
void unset_identity_flags(Identity ident, identity_flags_t flags);
void key_reset_trust(Identity ident);
boost::python::list import_key(string key_data);
}
}

6
src/pEpmodule.cc

@ -393,6 +393,12 @@ BOOST_PYTHON_MODULE(pEp)
"its accompanying key/user_id pair\n"
);
def("import_key", &pEp::PythonAdapter::import_key,
"private_key_list = import_key(key_data)\n"
"\n"
"import key(s) from key_data\n"
);
// message API
enum_<PEP_rating>("PEP_rating")

Loading…
Cancel
Save