merged parent

ENGINE-641
commit 439e60a1fc

File diff suppressed because it is too large Load Diff

@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "NO"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "159EF1E022B6AB0700149C0C"
BuildableName = "sequoia.framework"
BlueprintName = "sequoia"
ReferencedContainer = "container:../../Sequoia4iOS/Sequoia4iOS.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "64796A3E1B455AA5004B1C24"
BuildableName = "libpEpEngine.a"
BlueprintName = "pEpEngine"
ReferencedContainer = "container:pEpEngine.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "64796A3E1B455AA5004B1C24"
BuildableName = "libpEpEngine.a"
BlueprintName = "pEpEngine"
ReferencedContainer = "container:pEpEngine.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "64796A3E1B455AA5004B1C24"
BuildableName = "libpEpEngine.a"
BlueprintName = "pEpEngine"
ReferencedContainer = "container:pEpEngine.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "64796A3E1B455AA5004B1C24"
BuildableName = "libpEpEngine.a"
BlueprintName = "pEpEngine"
ReferencedContainer = "container:pEpEngine.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

@ -164,7 +164,7 @@ PEP_STATUS base_extract_message(
char *_fpr = NULL;
if (_sign) {
status = verify_text(session, _payload, _payload_size, _sign, _sign_size, &keylist);
if (status != PEP_VERIFIED || !keylist || !keylist->value) {
if (!(status == PEP_VERIFIED || status == PEP_VERIFIED_AND_TRUSTED) || !keylist || !keylist->value) {
// signature invalid or does not match; ignore sync message
status = PEP_STATUS_OK;
goto the_end;
@ -187,4 +187,3 @@ the_end:
free_stringlist(keylist);
return status;
}

@ -249,7 +249,7 @@ static PEP_STATUS validate_fpr(PEP_SESSION session,
case PEP_ct_key_revoked:
case PEP_ct_key_b0rken:
// delete key from being default key for all users/identities
status = remove_fpr_as_default(session, fpr);
status = remove_fpr_as_default(session, fpr); //BUFF: considers the key as "revoked" ...
status = update_trust_for_fpr(session,
fpr,
ct);
@ -257,7 +257,7 @@ static PEP_STATUS validate_fpr(PEP_SESSION session,
free(ident->fpr);
ident->fpr = NULL;
ident->comm_type = ct;
status = PEP_KEY_UNSUITABLE;
status = PEP_KEY_UNSUITABLE; //BUFF: ... and returns PEP_KEY_UNSUITABLE
default:
break;
}

@ -3144,6 +3144,20 @@ static PEP_STATUS reconcile_identity_lists(identity_list* src_ids,
return status;
}
static PEP_STATUS reconcile_sent_and_recv_info(message* src, message* inner_message) {
PEP_STATUS status = PEP_STATUS_OK;
if (!src || !inner_message)
return PEP_ILLEGAL_VALUE;
if (!inner_message->sent)
inner_message->sent = timestamp_dup(src->sent);
// This will never be set otherwise, since it's a transport header on the outside
inner_message->recv = timestamp_dup(src->recv);
return PEP_STATUS_OK;
}
static PEP_STATUS reconcile_src_and_inner_messages(message* src,
message* inner_message) {
@ -3161,6 +3175,9 @@ static PEP_STATUS reconcile_src_and_inner_messages(message* src,
if (status == PEP_STATUS_OK && inner_message->bcc)
status = reconcile_identity_lists(src->bcc, inner_message->bcc);
if (status == PEP_STATUS_OK)
status = reconcile_sent_and_recv_info(src, inner_message);
return status;
// FIXME - are there any flags or anything else we need to be sure are carried?
}

@ -4450,9 +4450,33 @@ DYNAMIC_API PEP_STATUS generate_keypair(
identity->username))
return PEP_ILLEGAL_VALUE;
const char* saved_username = NULL;
const char* at = NULL;
size_t uname_len = strlen(identity->username);
if (uname_len > 0)
at = strstr(identity->username, "@");
if (at) {
saved_username = identity->username;
identity->username = calloc(uname_len + 3, 1);
if (!identity->username) {
identity->username = saved_username;
return PEP_OUT_OF_MEMORY;
}
identity->username[0] = '"';
strlcpy((identity->username) + 1, saved_username, uname_len + 1);
identity->username[uname_len + 1] = '"';
}
PEP_STATUS status =
session->cryptotech[PEP_crypt_OpenPGP].generate_keypair(session,
identity);
if (saved_username) {
free(identity->username);
identity->username = saved_username;
}
if (status != PEP_STATUS_OK)
return status;

@ -1968,6 +1968,17 @@ PEP_STATUS pgp_import_keydata(PEP_SESSION session, const char *key_data,
break;
}
int int_result = sqlite3_exec(
session->key_db,
"PRAGMA wal_checkpoint(FULL);\n"
,
NULL,
NULL,
NULL
);
if (int_result != SQLITE_OK)
status = PEP_UNKNOWN_DB_ERROR;
out:
pgp_tpk_parser_free(parser);

@ -30,7 +30,6 @@ DYNAMIC_API void free_timestamp(timestamp *ts)
DYNAMIC_API timestamp * timestamp_dup(const timestamp *src)
{
assert(src);
if (!src)
return NULL;
@ -42,4 +41,3 @@ DYNAMIC_API timestamp * timestamp_dup(const timestamp *src)
memcpy(dst, src, sizeof(timestamp));
return dst;
}

@ -18,7 +18,7 @@ condition deviceGrouped {
|> *result = _result > 0;
}
condition weAreFirst
condition weAreOfferer
||
TID_t *t1 = &session->sync_state.keysync.challenge;
TID_t *t2 = &session->sync_state.own.challenge;
@ -416,7 +416,7 @@ action saveGroupKeys
free_identity_list(il);
||
action ownKeysAreGroupKeys
action ownKeysAreDefaultKeys
||
PEP_STATUS status = PEP_STATUS_OK;
@ -430,7 +430,7 @@ action ownKeysAreGroupKeys
}
||
action receivedKeysAreGroupKeys
action receivedKeysAreDefaultKeys
||
PEP_STATUS status = PEP_STATUS_OK;
// set flag for all keys
@ -535,4 +535,3 @@ action tellWeAreNotGrouped
||
action disable;

@ -0,0 +1,44 @@
include yslt.yml2
tstylesheet {
template "/protocol" {
| protocol «@name»
apply "fsm" sort "@name";
}
template "fsm" {
| fsm «@name»
apply "state" sort "@name";
|
for "set:distinct(*/event/@name)" {
sort ".";
|> event «.»
}
|
for "set:distinct(descendant::action/@name)" {
sort ".";
|> action «.»
}
|
for "set:distinct(descendant::condition/@name)" {
sort ".";
|> condition «.»
}
|
apply "descendant::transition"
sort "ancestor::state/@name",
sort "@target",
sort "ancestor::event/@name";
|
apply "message" sort "@name";
|
for "set:distinct(message/field/@name)" {
sort ".";
|> field «.»
}
}
template "state" | state «@name»
template "transition"
| transition from «ancestor::state/@name» to «@target» on event «ancestor::event/@name»
template "message" | message «@name»
}

@ -8,34 +8,24 @@ tstylesheet {
||
digraph finite_state_machine {
rankdir=LR;
node [shape = doublecircle];
`apply "state[@end='1']" mode=end`;
node [shape = circle];
node [shape=point];
InitState;
node [shape=doublecircle];
End;
node [shape=circle, style=filled, fillcolor=lightgrey];
`` apply "state" mode=do
`` apply "descendant::transition";
}
||
template "state", mode=end > «@name»
template "state", mode=do apply "event", 0 with "state", "@name";
template "event" {
param "state";
template "transition" {
const "event", "ancestor::event/@name";
choose {
when "count(transition) > 0"
apply "transition|condition/transition", 0
with "state", "$state", with "event", "@name";
when "ancestor::fsm/message[@name=$event]"
| «ancestor::state/@name» -> «@target» [ label="«ancestor::event/@name»", color=blue ];
otherwise
if "@name != 'Init'"
| «$state» -> «$state» [ label="«@name»" ];
| «ancestor::state/@name» -> «@target» [ label="«ancestor::event/@name»", color=red ];
}
}
template "transition" {
param "state";
param "event";
| «$state» -> «@target» [ label ="«$event»" ];
}
}

@ -41,14 +41,14 @@ protocol Sync 1 {
// this is our own Beacon; ignore
}
else {
if weAreFirst {
if weAreOfferer {
do useOwnChallenge;
send Beacon;
}
else /* we are second */ {
else /* we are requester */ {
do openNegotiation;
do tellWeAreNotGrouped;
// second is sending NegotiationRequest
// requester is sending NegotiationRequest
send NegotiationRequest;
do useOwnChallenge;
}
@ -62,25 +62,25 @@ protocol Sync 1 {
}
else {
do storeNegotiation;
// first is sending NegotiationOpen
// offerer is accepting by confirming NegotiationOpen
send NegotiationOpen;
if partnerIsGrouped
go HandshakingWithGroup;
go HandshakingToJoin;
else
go HandshakingNewFirst;
go HandshakingOfferer;
}
}
}
on NegotiationOpen if sameNegotiationAndPartner {
// second is receiving NegotiationOpen
// requester is receiving NegotiationOpen
do storeNegotiation;
go HandshakingNewSecond;
go HandshakingRequester;
}
}
// handshaking without existing Device group
state HandshakingNewFirst timeout=600 {
state HandshakingOfferer timeout=600 {
on Init
do showSoleHandshake;
@ -108,17 +108,17 @@ protocol Sync 1 {
// Accept means init Phase1Commit
on Accept {
do trustThisKey;
send CommitAcceptFirst;
go HandshakingNewPhase1First;
send CommitAcceptOfferer;
go HandshakingPhase1Offerer;
}
// got a CommitAccept from second
on CommitAcceptSecond if sameNegotiationAndPartner
go HandshakingNewPhase2First;
// got a CommitAccept from requester
on CommitAcceptRequester if sameNegotiationAndPartner
go HandshakingPhase2Offerer;
}
// handshaking without existing Device group
state HandshakingNewSecond timeout=600 {
state HandshakingRequester timeout=600 {
on Init
do showSoleHandshake;
@ -146,16 +146,16 @@ protocol Sync 1 {
// Accept means init Phase1Commit
on Accept {
do trustThisKey;
send CommitAcceptSecond;
go HandshakingNewPhase1Second;
send CommitAcceptRequester;
go HandshakingPhase1Requester;
}
// got a CommitAccept from first
on CommitAcceptFirst if sameNegotiationAndPartner
go HandshakingNewPhase2Second;
// got a CommitAccept from offerer
on CommitAcceptOfferer if sameNegotiationAndPartner
go HandshakingPhase2Requester;
}
state HandshakingNewPhase1First {
state HandshakingPhase1Offerer {
on Rollback if sameNegotiationAndPartner {
do untrustThisKey;
go Sole;
@ -167,12 +167,12 @@ protocol Sync 1 {
go End;
}
on CommitAcceptSecond if sameNegotiationAndPartner {
go NewGroupFirst;
on CommitAcceptRequester if sameNegotiationAndPartner {
go FormingGroupOfferer;
}
}
state HandshakingNewPhase1Second {
state HandshakingPhase1Requester {
on Rollback if sameNegotiationAndPartner {
do untrustThisKey;
go Sole;
@ -184,12 +184,12 @@ protocol Sync 1 {
go End;
}
on CommitAcceptFirst if sameNegotiationAndPartner {
go NewGroupSecond;
on CommitAcceptOfferer if sameNegotiationAndPartner {
go FormingGroupRequester;
}
}
state HandshakingNewPhase2First {
state HandshakingPhase2Offerer {
on Cancel {
send Rollback;
go Sole;
@ -202,13 +202,13 @@ protocol Sync 1 {
}
on Accept {
send CommitAcceptFirst;
send CommitAcceptOfferer;
do trustThisKey;
go NewGroupFirst;
go FormingGroupOfferer;
}
}
state HandshakingNewPhase2Second {
state HandshakingPhase2Requester {
on Cancel {
send Rollback;
go Sole;
@ -221,36 +221,35 @@ protocol Sync 1 {
}
on Accept {
send CommitAcceptSecond;
send CommitAcceptRequester;
do trustThisKey;
go NewGroupSecond;
go FormingGroupRequester;
}
}
state NewGroupFirst {
state FormingGroupOfferer {
on Init {
do prepareOwnKeys;
send OwnKeysFirst; // we're not grouped yet, this is our own keys
send OwnKeysOfferer; // we're not grouped yet, this is our own keys
}
on OwnKeysSecond {
on OwnKeysRequester {
do saveGroupKeys;
do receivedKeysAreGroupKeys;
do receivedKeysAreDefaultKeys;
do showGroupCreated;
go Grouped;
}
}
state NewGroupSecond {
state FormingGroupRequester {
on Init {
do prepareOwnKeys;
send OwnKeysSecond; // we're not grouped yet, this is our own keys
send OwnKeysRequester; // we're not grouped yet, this is our own keys
}
on OwnKeysFirst {
on OwnKeysOfferer {
do saveGroupKeys;
do ownKeysAreGroupKeys;
do ownKeysAreDefaultKeys;
do showGroupCreated;
go Grouped;
}
@ -282,13 +281,12 @@ protocol Sync 1 {
go HandshakingGrouped;
}
on GroupTrustThisKey {
on GroupTrustThisKey
do trustThisKey;
}
}
// sole device handshaking with group
state HandshakingWithGroup {
state HandshakingToJoin {
on Init
do showJoinGroupHandshake;
@ -308,6 +306,9 @@ protocol Sync 1 {
go End;
}
on CommitAcceptForGroup if sameNegotiationAndPartner
go HandshakingToJoinPhase2;
on CommitReject if sameNegotiationAndPartner {
do disable;
go End;
@ -317,11 +318,11 @@ protocol Sync 1 {
on Accept {
do trustThisKey;
send CommitAccept;
go HandshakingJoinPhase1;
go HandshakingToJoinPhase1;
}
}
state HandshakingJoinPhase1 {
state HandshakingToJoinPhase1 {
on Rollback if sameNegotiationAndPartner
go Sole;
@ -330,12 +331,11 @@ protocol Sync 1 {
go End;
}
on CommitAcceptForGroup if sameNegotiationAndPartner {
go JoinGroup;
}
on CommitAcceptForGroup if sameNegotiationAndPartner
go JoiningGroup;
}
state HandshakingJoinPhase2 {
state HandshakingToJoinPhase2 {
on Cancel {
send Rollback;
go Sole;
@ -349,19 +349,16 @@ protocol Sync 1 {
on Accept {
do trustThisKey;
go JoinGroup;
go JoiningGroup;
}
}
state JoinGroup {
on Init {
do prepareOwnKeys;
send OwnKeys;
}
state JoiningGroup {
on GroupKeys {
do saveGroupKeys;
do receivedKeysAreGroupKeys;
do receivedKeysAreDefaultKeys;
do prepareOwnKeys;
send GroupKeys;
do showDeviceAdded;
go Grouped;
}
@ -405,14 +402,6 @@ protocol Sync 1 {
do trustThisKey;
}
on CommitAcceptForGroup {
do showDeviceAdded;
if sameNegotiationAndPartner {
do hideHandshakeDialog;
go Grouped;
}
}
on GroupKeys
do saveGroupKeys;
}
@ -496,11 +485,11 @@ protocol Sync 1 {
field TID negotiation;
}
message CommitAcceptFirst 7, security=untrusted {
message CommitAcceptOfferer 7, security=untrusted {
field TID negotiation;
}
message CommitAcceptSecond 8, security=untrusted {
message CommitAcceptRequester 8, security=untrusted {
field TID negotiation;
}
@ -522,15 +511,11 @@ protocol Sync 1 {
field IdentityList ownIdentities;
}
message OwnKeys 13, security=attach_own_keys {
field IdentityList ownIdentities;
}
message OwnKeysFirst 14, security=attach_own_keys {
message OwnKeysOfferer 13, security=attach_own_keys {
field IdentityList ownIdentities;
}
message OwnKeysSecond 15, security=attach_own_keys {
message OwnKeysRequester 14, security=attach_own_keys {
field IdentityList ownIdentities;
}
}

@ -0,0 +1,19 @@
// This file is under GNU General Public License 3.0
// see LICENSE.txt
#ifndef I_O_S1664_H
#define I_O_S1664_H
#include <string>
#include "EngineTestIndividualSuite.h"
using namespace std;
class IOS1664Tests : public EngineTestIndividualSuite {
public:
IOS1664Tests(string test_suite, string test_home_dir);
private:
void check_i_o_s1664();
};
#endif

@ -19,12 +19,12 @@
#include "VerifyTests.h"
#include "UserIdCollisionTests.h"
#include "Engine463Tests.h"
#include "IOS1664Tests.h"
#include "BloblistTests.h"
#include "NewUpdateIdAndMyselfTests.h"
#include "NoOwnIdentWritesOnDecryptTests.h"
#include "LiteralFilenameTests.h"
#include "I18nTests.h"
#include "Message2_1Tests.h"
#include "IdentityListTests.h"
#include "PgpBinaryTests.h"
#include "SubkeyRatingEvalTests.h"
@ -85,12 +85,12 @@ const char* SuiteMaker::all_suites[] = {
"VerifyTests",
"UserIdCollisionTests",
"Engine463Tests",
"IOS1664Tests",
"BloblistTests",
"NewUpdateIdAndMyselfTests",
"NoOwnIdentWritesOnDecryptTests",
"LiteralFilenameTests",
"I18nTests",
"Message2_1Tests",
"IdentityListTests",
"PgpBinaryTests",
"SubkeyRatingEvalTests",
@ -161,6 +161,8 @@ void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_
*test_suite = new UserIdCollisionTests(test_class_name, test_home);
else if (strcmp(test_class_name, "Engine463Tests") == 0)
*test_suite = new Engine463Tests(test_class_name, test_home);
else if (strcmp(test_class_name, "IOS1664Tests") == 0)
*test_suite = new IOS1664Tests(test_class_name, test_home);
else if (strcmp(test_class_name, "BloblistTests") == 0)
*test_suite = new BloblistTests(test_class_name, test_home);
else if (strcmp(test_class_name, "NewUpdateIdAndMyselfTests") == 0)
@ -171,8 +173,6 @@ void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_
*test_suite = new LiteralFilenameTests(test_class_name, test_home);
else if (strcmp(test_class_name, "I18nTests") == 0)
*test_suite = new I18nTests(test_class_name, test_home);
else if (strcmp(test_class_name, "Message2_1Tests") == 0)
*test_suite = new Message2_1Tests(test_class_name, test_home);
else if (strcmp(test_class_name, "IdentityListTests") == 0)
*test_suite = new IdentityListTests(test_class_name, test_home);
else if (strcmp(test_class_name, "PgpBinaryTests") == 0)

@ -0,0 +1,61 @@
// This file is under GNU General Public License 3.0
// see LICENSE.txt
#include <stdlib.h>
#include <cstring>
#include <string>
#include <cpptest.h>
#include "test_util.h"
#include "pEpEngine.h"
#include "EngineTestIndividualSuite.h"
#include "IOS1664Tests.h"
#include "mime.h"
using namespace std;
IOS1664Tests::IOS1664Tests(string suitename, string test_home_dir) :
EngineTestIndividualSuite::EngineTestIndividualSuite(suitename, test_home_dir) {
add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("IOS1664Tests::check_i_o_s1664"),
static_cast<Func>(&IOS1664Tests::check_i_o_s1664)));
}
void IOS1664Tests::check_i_o_s1664() {
string email = slurp("test_mails/0.47.eml");
TEST_ASSERT(!email.empty());
message* message_mail = NULL;
PEP_STATUS status = mime_decode_message(email.c_str(), email.size(), &message_mail);
TEST_ASSERT(status == PEP_STATUS_OK && message_mail);
// create own identity here, because we want to reply, before we start.
pEp_identity* me = new_identity("android01@peptest.ch", NULL, PEP_OWN_USERID, NULL);
status = myself(session, me);
TEST_ASSERT(status == PEP_STATUS_OK && me->fpr != NULL && me->fpr[0] != '\0');
// Ok, now read the message
message* read_message = NULL;
stringlist_t* keylist;
PEP_rating rating;
PEP_decrypt_flags_t flags = 0;
status = decrypt_message(session, message_mail, &read_message, &keylist, &rating, &flags);
TEST_ASSERT(status == PEP_UNENCRYPTED);
pEp_identity* you = new_identity("superxat@gmail.com", NULL, NULL, NULL);
message* out_msg = new_message(PEP_dir_outgoing);
out_msg->from = me;
out_msg->to = new_identity_list(you);
out_msg->shortmsg = strdup("Hussidente 2020!");
out_msg->longmsg = strdup("A Huss in every office!");
status = outgoing_message_rating(session, out_msg, &rating);
TEST_ASSERT(rating == PEP_rating_unencrypted);
TEST_ASSERT(true);
}

@ -1,179 +0,0 @@
// This file is under GNU General Public License 3.0
// see LICENSE.txt
#include <stdlib.h>
#include <string>
#include "pEpEngine.h"
#include "pEp_internal.h"
#include "KeySync_fsm.h"
#include "sync_codec.h"
#include "EngineTestSessionSuite.h"
#include "SyncTests.h"
using namespace std;
void Sync_Adapter::processing()
{
cout << "waiting for processing\n";
while (!q.empty()) {
nanosleep((const struct timespec[]){{0, 100000000L}}, NULL);
}
}
PEP_STATUS Sync_Adapter::notifyHandshake(
pEp_identity *me,
pEp_identity *partner,
sync_handshake_signal signal
)
{
return PEP_STATUS_OK;
}
int Sync_Adapter::inject_sync_event(SYNC_EVENT ev, void *management)
{
Sync_event_t *_ev = ev;
switch (_ev->fsm) {
case Sync_PR_keysync:
cout << "injecting event " << KeySync_event_name(_ev->event) << "\n";
break;
default:
cout << "unknown state machine: " << _ev->fsm << "\n";
assert(0);
}
auto adapter = static_cast< Sync_Adapter *>(management);
adapter->q.push_front(ev);
return 0;
}
Sync_event_t *Sync_Adapter::retrieve_next_sync_event(void *management, time_t threshold)
{
auto adapter = static_cast< Sync_Adapter *>(management);
time_t started = time(nullptr);
bool timeout = false;
while (adapter->q.empty()) {
int i = 0;
++i;
if (i > 10) {
if (time(nullptr) > started + threshold) {
timeout = true;
break;
}
i = 0;
}
nanosleep((const struct timespec[]){{0, 100000000L}}, NULL);
}
if (timeout)
return SYNC_TIMEOUT_EVENT;
Sync_event_t *ev = adapter->q.pop_front();
if (ev) {
switch (ev->fsm) {
case Sync_PR_keysync:
cout << "sync thread: retrieving event " << KeySync_event_name(ev->event) << "\n";
break;
default:
cout << "sync thread: unknown state machine: " << ev->fsm << "\n";
assert(0);
}
}
else {
cout << "sync thread: retrieving shutdown\n";
}
return ev;
}
PEP_STATUS Sync_Adapter::messageToSend(struct _message *msg)
{
assert(msg && msg->attachments);
cout << "sending message:\n";
for (bloblist_t *b = msg->attachments; b && b->value; b = b->next) {
if (b->mime_type && strcasecmp(b->mime_type, "application/pEp.sync") == 0) {
assert(msg->from && msg->from->address && msg->from->username);
cout << "<!-- " << msg->from->username << " <" << msg->from->address << "> -->\n";
char *text = NULL;
PEP_STATUS status = PER_to_XER_Sync_msg(msg->attachments->value, msg->attachments->size, &text);
assert(status == PEP_STATUS_OK);
cout << text << "\n";
free(text);
}
}
free_message(msg);
return PEP_STATUS_OK;
}
void Sync_Adapter::sync_thread(PEP_SESSION session, Sync_Adapter *adapter)
{
cout << "sync_thread: startup\n";
do_sync_protocol(session, adapter);
cout << "sync_thread: shutdown\n";
}
SyncTests::SyncTests(string suitename, string test_home_dir) :
EngineTestSessionSuite::EngineTestSessionSuite(suitename, test_home_dir) {
add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("SyncTests::check_sync"),
static_cast<Func>(&SyncTests::check_sync)));
}
void SyncTests::setup()
{
EngineTestSessionSuite::setup();
pEp_identity *self = new_identity("alice@synctests.pEp", nullptr, "23", "Alice Miller");
assert(self);
cout << "setting own identity for " << self->address << "\n";
PEP_STATUS status = myself(session, self);
assert(self->me);
assert(self->fpr);
cout << "fpr: " << self->fpr << "\n";
free_identity(self);
status = init(&sync, Sync_Adapter::messageToSend, Sync_Adapter::inject_sync_event);
TEST_ASSERT(status == PEP_STATUS_OK);
cout << "initialize sync and start first state machine\n";
status = register_sync_callbacks(
sync,
(void *) &adapter.q,
Sync_Adapter::notifyHandshake,
Sync_Adapter::retrieve_next_sync_event
);
TEST_ASSERT(status == PEP_STATUS_OK);
TEST_ASSERT(sync->sync_state.keysync.state == Sole);
cout << "creating thread for sync\n";
sync_thread = new thread(Sync_Adapter::sync_thread, sync, &adapter);
}
void SyncTests::tear_down()
{
adapter.processing();
cout << "sending shutdown to sync thread\n";
adapter.q.push_front(nullptr);
sync_thread->join();
unregister_sync_callbacks(sync);
release(sync);
EngineTestSessionSuite::tear_down();
}
void SyncTests::check_sync()
{
cout << "check_sync(): trigger KeyGen event\n";
signal_Sync_event(sync, Sync_PR_keysync, KeyGen);
adapter.processing();
cout << "check_sync(): cry for unknown key\n";
signal_Sync_event(sync, Sync_PR_keysync, CannotDecrypt);
}

@ -0,0 +1,118 @@
Return-Path: <superxat@gmail.com>
X-Original-To: android01@peptest.ch
Delivered-To: android01@peptest.ch
Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48])
by peptest.ch (Postfix) with ESMTPS id B28651A1A37
for <android01@peptest.ch>; Wed, 19 Jun 2019 13:30:48 +0200 (CEST)
Authentication-Results: plesk.peptest.ch;
spf=pass (sender IP is 209.85.128.48) smtp.mailfrom=superxat@gmail.com smtp.helo=mail-wm1-f48.google.com
Received-SPF: pass (plesk.peptest.ch: domain of gmail.com designates 209.85.128.48 as permitted sender) client-ip=209.85.128.48; envelope-from=superxat@gmail.com; helo=mail-wm1-f48.google.com;
Received: by mail-wm1-f48.google.com with SMTP id c6so1452126wml.0
for <android01@peptest.ch>; Wed, 19 Jun 2019 04:30:48 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20161025;
h=date:subject:message-id:mime-version:from:to
:content-transfer-encoding:content-disposition;
bh=NUw9sOoAh+T9dS39iJIrhWdmODeTKEUilqsSegM8sFY=;
b=P7PQKOsF5/fo55wQh0OSf0TmwvGkefdBetMjGbNU+3YMI9ivYIcA1d/BS0acEc680t
8hXsylVmD0+W51dkKDRoD0eMOI+lRy0km3i3ndTghVWQkwC4qmlcX3m9+l7JqoBK1WfS
LLQLVmYIoqOVOKeDt1Gin93KKU7UJrnxTWmQBtwStvTtBf55W9oSfwimQw4vMQ9dC18b
ZIxdIF718uUgoeNoBDCwIZSEhrx2BrtMIwQLMCo3N3tj90teB+J2RzyR1/WK5baZSYTx
jFEP820+8ijVkbfBeGe/NXO8lhjkcBJpMRt8u6hEwaYfqCHti5nNxkBPz5DTMaSpwr/i
frvw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:date:subject:message-id:mime-version:from:to
:content-transfer-encoding:content-disposition;
bh=NUw9sOoAh+T9dS39iJIrhWdmODeTKEUilqsSegM8sFY=;
b=uh9pKjfFTmrFiQ0FGn451jB7OLbRwzdgsMUkI005vc/mFKzVl2ON/+DhBdgHn32fat
NFLXoDWJLxOdmHa4AHZFuNzlq2FkuMcHol71/TrwfpcLua7lv91xK1QyNAOiZTr+svHF
OvHJfnwQDgDEKvujrDSNtiouClF8PDn3xL14oleqWHJVof/xu1g85udfrz9oCRB75LEx
MQMdg/2dZG2VOyU5oL0GxFWkJklwbVRetmeedXW03LT6nHMxgiTvu8w763Xrc6qiQg8i
E6YrGGYcGkQ2Yz+ktTWPfNRbAYqXWIcl4hTWfgz/EfA++YADsLfylsQFbLEjrzqPl3ta
n42Q==
X-Gm-Message-State: APjAAAVz898EiKLpVhBB5cId5eBhi5M165QEihBzgqQYtn4mwKLXTvmm
Zcj9EtC70y+1hUOijZcR0t20kv+pORU=
X-Google-Smtp-Source: APXvYqzwqwDR8fIHgK/akmZKDj40939fHnZCMvbJkqGJO8FJBA1CNtsOeeD/o9+oPXxSOes9wcFivw==
X-Received: by 2002:a1c:7614:: with SMTP id r20mr8454522wmc.142.1560943846238;
Wed, 19 Jun 2019 04:30:46 -0700 (PDT)
Received: from pretty.Easy.privacy (58.red-79-153-28.dynamicip.rima-tde.net. [79.153.28.58])
by smtp.gmail.com with ESMTPSA id l1sm27960688wrf.46.2019.06.19.04.30.45
for <android01@peptest.ch>
(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
Wed, 19 Jun 2019 04:30:45 -0700 (PDT)
Date: Wed, 19 Jun 2019 13:30:45 +0200
Subject: Tralal
Message-ID: <D5AB23C6.36B2.4D51.9FED.2B89DA8E24F0@pretty.Easy.privacy>
MIME-Version: 1.0
From: "Superxat" <superxat@gmail.com>
To: "android01@peptest.ch" <android01@peptest.ch>
X-pEp-Version: 2.0
Content-Transfer-Encoding: 8bit
Content-Type: multipart/related; charset="UTF-8";
boundary="=_0c0c4f5794a2b6faebb4792f1d649487"
Content-Disposition: inline
--=_0c0c4f5794a2b6faebb4792f1d649487
Content-Type: multipart/alternative; charset="UTF-8";
boundary="=_14547b0f3d5cfa991974970b718011b9"
Content-Disposition: inline
--=_14547b0f3d5cfa991974970b718011b9
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Jzbf
sent with p≡p
--=_14547b0f3d5cfa991974970b718011b9
Content-Transfer-Encoding: 8bit
Content-Type: text/html; charset="UTF-8"
Content-Disposition: inline
<p>Jzbf</p>
<p><a href="https://pep.software" style="color:#1AAA50; text-decoration: none;">sent with p≡p</a></p>
--=_14547b0f3d5cfa991974970b718011b9--
--=_0c0c4f5794a2b6faebb4792f1d649487
Content-Transfer-Encoding: base64
Content-Type: application/pgp-keys; charset="UTF-8"; name="pEpkey.asc"
Content-Disposition: attachment; filename="pEpkey.asc"
LS0tLS1CRUdJTiBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tDQpWZXJzaW9uOiBOZXRQR1Ag
Zm9yIHBFcCAzLjk5Ljk5L1tiZXRhMF0NCg0KeHNGTkJGMEtITWtCRUFDMHM2MUI2dXlGREI0
WjNoQ3h1SDJkSGltdzltT0dxUlNTR2g5dW10czh5NGs4VUJmbFlkOE43T3lIM21wQw0KMVJm
L2J3d1FESjBkMUFuUUZrdmNHOWdkQXEyTXREZHZzbGlyV1krQm1oZEtDdVVCSWxuWXhrbGRt
cUlGSVpQc1ZJam5JNG1WK3cxMg0KakFmYk9MSEZNQnhiNXdFSUZVcVpzZ25wQklsTVlNN2Nt
L05HdVlkc2pzWGl0MC93U3FxOXkySTBTL25MRWFYaXZIUmF4WmRyaFNzOA0Kb1IrTU5TVW5O
MGZsOElETnV1QUp6U0RNbzljZGwwQk1uN2ZTdWYyWXhMUlA0WWZGTHhGWGhPTStlQjNETnQ5
R2ZTZ0dVTFBQRStLcw0KVktuWkxCLzBlUEtSNWZhWDV4Rjllb2tEZlR0T3l1ZnJPRFdJK3FU
eElubUNSQzg4VFRGMGhiMTFTMGFzd0FnZW44c3QyNTBBQnFyeg0KQWVWc1Vtc2prMmR0REhM
TzJBaGxBQ3FVRmdOLzV5ckJxWXpvM0lLZVpmNTUxSFdVVzVQVGRmZmdZM1FQNUc5SkVzRVBP
a3R0RTBpYw0KdXdJbHRQS2lQZkZzNmVkMjcyNG9pNS90NVBlbm8vNTdxK2hrTStsS3RodmYy
ZEJleTkzL0FLcGtpN0F4aTJCbjRhRGVEb3JNQnNBZw0KZG9iSHFKVUxBdmVJaDR4VzFTbnJX
dlVMdDZHSUZrbjBISUJqZWhmQkFBejZGVFkwRnpiaFJacHhtaDhBNm5JU2ZZNFdZUTdCbFpl
cA0Kb1V0dFU5MHVEeEZDcWxYdlV1NnViQzhSQ1poNFNJMWd3QktobVZ3MTR4UngrZkNWTFc2
SFRvR0x4UDY5dEYwRGxucUd2YkhaOU1LdA0KRGFTSldNZEQvRUtZR1FBUkFRQUJ6UjFUZFhC
bGNuaGhkQ0E4YzNWd1pYSjRZWFJBWjIxaGFXd3VZMjl0UHNMQmZRUVRBUUlBTVFVQw0KWFFv
Y3lRVUpBZUV6Z0FrUXBSbWp3WmdBY1kwQ0dRRUNHd1lHQ3drSEF3SUJCaFVJQWdrS0N3TVdB
Z01DSGdFQUFHSU1ELzlrSFVZSQ0KN3FTWGo2Q04zeWZBZFlxT05iOGFOWXRjczNhZUd0bjRp
M3htUGw2cTFoR05KV05kTzlmYzhmNFUzSjRleDFBYlY3NFkzckpQT2xEWA0KRzBLZFBRaEVI
Tzhpc2lidkRVcDJoaEhXM20zSGF4dzg0SWY4UDlqUlJBa2JKbk1pVEFwYk9PSElOTCtqY1hz
anU1WHNKeCt5K1NCdQ0KQ3l2TXV4S0VIbnUrZldrWE05RGlKMTJiRjJxNTEwTExjUHR5SVov
azI3S3djemgrdWNQWHhXWHZQbk84MHN3SGpVWVM4L3NydjYrMA0Kcm51dXZvaXlMWlN1bzh1
QUVOZGkrQWdvU0gwMXNZcmxRRHQvSko3OXFxZ1NtcTdYRnpzeElGWFVMTG5ITHVxZmxiTEZm
eUJTMm1wcA0KbUZZa0ZlVWZ5NG9lQmY5NWkxTkVNRWZYNGk3WUhEZVNQT0Jqd1FVRi8vVEpk
R3hHT3RBYjJnaCsrZ01FdDIxaTE3MHE0dzdsQWVHOQ0KSHpHanJjWGtGdlZSZlBTbXZ0UCth
cS9xa1kyemkzcVo1ZTVmcFpncHlJcXY4T3EwdkE2M1NtWEFrd1ZnaitNMHJpQjJkSWtmRWla
OQ0KWWllVzhwaUxSWkZrb0l4QWxpZEV5MTBmQk4xOXdmL05pL09zRUR0ajN1V1lkbXBTK1hq
ODlFREQwQnhMYWhoYUNQclBxSnU3azJGaQ0KMXhtdFJZTzhZcEJxWmVTalh5OHpWN29EUmhD
eWFCSndBcmxOS2Y2cm9oTG5xM29WWDFLeFRQUlpBd3FjQ1oxaEpTRUFraVE1ejVhQw0KclJU
eCsvSTZRc3JtRk0vdDNBM3RRd0RQRGRpaExMUzhFMWNoekxyRkIwVFd3SUpWeDRtOU9odFR6
SlhqYlhlSGorelR0Zz09DQo9VGVxQw0KLS0tLS1FTkQgUEdQIFBVQkxJQyBLRVkgQkxPQ0st
LS0tLQ0K
--=_0c0c4f5794a2b6faebb4792f1d649487--
Loading…
Cancel
Save