Browse Source

key import

ENGINE-781
Volker Birk 5 years ago
parent
commit
10b0cfff15
  1. 15
      test/test_ensure_passphrase.cc

15
test/test_ensure_passphrase.cc

@ -1,4 +1,6 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <unistd.h>
#include <assert.h>
#include <stdlib.h>
@ -16,6 +18,16 @@ using namespace pEp;
using namespace pEp::Adapter;
using namespace std;
void import_key_from_file(string filename)
{
ifstream f(filename, ifstream::in);
string key{istreambuf_iterator<char>(f), istreambuf_iterator<char>()};
::identity_list *il = NULL;
PEP_STATUS status = ::import_key(session(), key.c_str(), key.length(), &il);
assert(status == PEP_KEY_IMPORTED);
::free_identity_list(il);
}
void test()
{
passphrase_cache.add("erwin");
@ -28,6 +40,9 @@ void test()
const char* erwin_filename = ENGINE_TEST "/test_keys/erwin_normal_encrypted.pgp";
const char* erwin_fpr = "CBA968BC01FCEB89F04CCF155C5E9E3F0420A570";
import_key_from_file(bob_filename);
import_key_from_file(erwin_filename);
pEp_identity* bob = ::new_identity("bob@example.org", bob_fpr, "BOB", "Bob Dog");
PEP_STATUS status = ::set_own_key(session(), bob, bob_fpr);

Loading…
Cancel
Save