Browse Source

merged in other head

pEpMIME_windows
parent
commit
c8f6efa6f3
3 changed files with 73 additions and 50 deletions
  1. +17
    -9
      src/message_api.c
  2. +52
    -39
      sync/gen_statemachine.ysl2
  3. +4
    -2
      sync/sync.fsm

+ 17
- 9
src/message_api.c View File

@ -3855,16 +3855,22 @@ DYNAMIC_API PEP_STATUS decrypt_message(
char *sync_fpr = NULL;
PEP_STATUS tmpstatus = base_extract_message(session, msg, &size, &data, &sync_fpr);
if (!tmpstatus && size && data) {
pEp_identity *_from = identity_dup(msg->from);
if (!_from) {
free_message(*dst);
*dst = NULL;
free_stringlist(*keylist);
*keylist = NULL;
return PEP_OUT_OF_MEMORY;
if ((*keylist && strcasecmp(msg->from->fpr, (*keylist)->value))
|| (sync_fpr && strcasecmp(msg->from->fpr, sync_fpr))) {
pEp_identity *_from = identity_dup(msg->from);
if (!_from) {
free_message(*dst);
*dst = NULL;
free_stringlist(*keylist);
*keylist = NULL;
free(sync_fpr);
return PEP_OUT_OF_MEMORY;
}
if (session->sync_state.common.from)
free_identity(session->sync_state.common.from);
session->sync_state.common.from = _from;
signal_Sync_message(session, *rating, data, size, sync_fpr);
}
session->sync_state.common.from = _from;
signal_Sync_message(session, *rating, data, size, sync_fpr);
}
free(sync_fpr);
}
@ -4069,6 +4075,8 @@ DYNAMIC_API PEP_STATUS identity_rating(
if (!(session && ident && rating))
return PEP_ILLEGAL_VALUE;
*rating = PEP_rating_undefined;
if (ident->me)
status = _myself(session, ident, false, true);
else


+ 52
- 39
sync/gen_statemachine.ysl2 View File

@ -55,7 +55,7 @@ tstylesheet {
#define «yml:ucase(@name)»_TIMEOUT_EVENT new_«@name»_event(«@name»_PR_NOTHING, 0, NULL);
// free_«@name»_event() - free memory occupied by event
//
// parameters:
@ -321,13 +321,25 @@ tstylesheet {
if (!session->inject_«yml:lcase(@name)»_event)
return PEP_«yml:ucase(@name)»_NO_INJECT_CALLBACK;
PEP_STATUS status = PEP_STATUS_OK;
«@name»_event_t *ev = NULL;
if (fpr) {
if (session->«yml:lcase(@name)»_state.common.from->fpr)
free(session->«yml:lcase(@name)»_state.common.from->fpr);
session->«yml:lcase(@name)»_state.common.from->fpr = strdup(fpr);
assert(session->«yml:lcase(@name)»_state.common.from->fpr);
if (!session->«yml:lcase(@name)»_state.common.from->fpr) {
status = PEP_OUT_OF_MEMORY;
goto the_end;
}
}
«@name»_t *msg = NULL;
PEP_STATUS status = decode_«@name»_message(data, size, &msg);
status = decode_«@name»_message(data, size, &msg);
if (status)
return status;
«@name»_event_t *ev = NULL;
«@name»_PR fsm = msg->present;
int event = 0;
@ -338,17 +350,6 @@ tstylesheet {
goto the_end;
}
if (fpr) {
if (session->«yml:lcase(@name)»_state.common.from->fpr)
free(session->«yml:lcase(@name)»_state.common.from->fpr);
session->«yml:lcase(@name)»_state.common.from->fpr = strdup(fpr);
assert(session->«yml:lcase(@name)»_state.common.from->fpr);
if (!session->«yml:lcase(@name)»_state.common.from->fpr) {
status = PEP_OUT_OF_MEMORY;
goto the_end;
}
}
ev = new_«@name»_event(fsm, event, msg);
if (!ev) {
status = PEP_OUT_OF_MEMORY;
@ -449,6 +450,7 @@ tstylesheet {
goto the_end;
}
}
break;
default:
status = PEP_«yml:ucase(@name)»_ILLEGAL_MESSAGE;
@ -622,43 +624,54 @@ tstylesheet {
{
||
case «../@name»_PR_«yml:lcase(@name)»:
event = msg->choice.«yml:lcase(@name)».payload.present;
switch (event) {
switch (msg->choice.«yml:lcase(@name)».payload.present) {
||
if "message[@security='unencrypted']" {
| // these messages require a detached signature
for "message[@security='unencrypted']"
|>> case «../@name»__payload_PR_«yml:mixedCase(@name)»:
|>> // these messages require a detached signature
for "message[@security='unencrypted']" {
||
case «../@name»__payload_PR_«yml:mixedCase(@name)»:
if (!fpr) {
status = PEP_«yml:ucase(ancestor::protocol/@name)»_ILLEGAL_MESSAGE;
goto the_end;
}
event = «@name»;
break;
||
}
}
if "message[@security='untrusted']"
||
// these messages must arrive encrypted
`` for "message[@security='untrusted']" |>> case «../@name»__payload_PR_«yml:mixedCase(@name)»:
if (fpr || rating < PEP_rating_reliable) {
status = PEP_«yml:ucase(ancestor::protocol/@name)»_ILLEGAL_MESSAGE;
goto the_end;
}
break;
if "message[@security='untrusted']" {
|>> // these messages must arrive encrypted
for "message[@security='untrusted']" {
||
case «../@name»__payload_PR_«yml:mixedCase(@name)»:
if (rating < PEP_rating_reliable) {
status = PEP_«yml:ucase(ancestor::protocol/@name)»_ILLEGAL_MESSAGE;
goto the_end;
}
event = «@name»;
break;
||
if "message[@security='trusted']"
||
// these messages must come through a trusted channel
`` for "message[@security='trusted']" |>> case «ancestor::fsm/@name»__payload_PR_«yml:mixedCase(@name)»:
if (fpr || rating < PEP_rating_trusted) {
status = PEP_«yml:ucase(ancestor::protocol/@name)»_ILLEGAL_MESSAGE;
goto the_end;
}
break;
||
}
}
if "message[@security='trusted']" {
|>> // these messages must come through a trusted channel
for "message[@security='trusted']" {
||
case «../@name»__payload_PR_«yml:mixedCase(@name)»:
if (rating < PEP_rating_trusted) {
status = PEP_«yml:ucase(ancestor::protocol/@name)»_ILLEGAL_MESSAGE;
goto the_end;
}
event = «@name»;
break;
||
}
}
||
default:
status = PEP_«yml:ucase(ancestor::protocol/@name)»_ILLEGAL_MESSAGE;
goto the_end;


+ 4
- 2
sync/sync.fsm View File

@ -42,6 +42,7 @@ protocol Sync 1 {
do openTransaction;
do storeTransaction;
send HandshakeRequest;
go HandshakeRequested;
}
}
@ -56,6 +57,9 @@ protocol Sync 1 {
}
}
}
state HandshakeRequested {
on HandshakeAnswer
go HandshakingNew();
}
@ -312,13 +316,11 @@ protocol Sync 1 {
field TID challenge;
auto Version version;
field TID transaction;
field Hash fpr;
field bool is_group;
}
message HandshakeAnswer 4 {
field TID transaction;
field Hash fpr;
}
message Rollback 5, security=untrusted {


Loading…
Cancel
Save