|
|
@ -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); |
|
|
|
|
|
|
|