Browse Source

try_base_prepare_message() for signing

doxygen-key-id archive/ENGINE-764
Volker Birk 2 years ago
parent
commit
d93e9646bc
3 changed files with 74 additions and 1 deletions
  1. +57
    -0
      src/baseprotocol.c
  2. +16
    -0
      src/baseprotocol.h
  3. +1
    -1
      sync/gen_statemachine.ysl2

+ 57
- 0
src/baseprotocol.c View File

@ -214,3 +214,60 @@ the_end:
free_stringlist(keylist);
return status;
}
PEP_STATUS try_base_prepare_message(
PEP_SESSION session,
const pEp_identity *me,
const pEp_identity *partner,
base_protocol_type type,
char *payload,
size_t size,
const char *fpr,
message **result
)
{
PEP_STATUS status = PEP_STATUS_OK;
assert(me);
assert(partner);
assert(payload);
assert(size);
assert(result);
assert(type == BASE_SYNC || type == BASE_KEYRESET);
if (!(me && partner && payload && size && result && type))
return PEP_ILLEGAL_VALUE;
// https://dev.pep.foundation/Engine/MessageToSendPassphrase
if (session->curr_passphrase) {
// first try with empty passphrase
char *passphrase = session->curr_passphrase;
session->curr_passphrase = NULL;
status = base_prepare_message(session, me, partner, type, payload, size, fpr, result);
session->curr_passphrase = passphrase;
if (!(status == PEP_PASSPHRASE_REQUIRED || status == PEP_WRONG_PASSPHRASE))
return status;
}
do {
// then try passphrases
status = base_prepare_message(session, me, partner, type, payload, size, fpr, result);
if (status == PEP_PASSPHRASE_REQUIRED || status == PEP_WRONG_PASSPHRASE) {
status = session->messageToSend(NULL);
if (status == PEP_PASSPHRASE_REQUIRED || status == PEP_WRONG_PASSPHRASE) {
pEp_identity *_me = identity_dup(me);
if (!_me)
return PEP_OUT_OF_MEMORY;
session->notifyHandshake(_me, NULL, SYNC_PASSPHRASE_REQUIRED);
break;
}
}
else {
break;
}
} while (!status);
return status;
}

+ 16
- 0
src/baseprotocol.h View File

@ -106,6 +106,22 @@ PEP_STATUS base_extract_message(
);
// this is the internal function to be used by asynchronous network protocol
// implementations
//
// this function is calling messageToSend(NULL) in case there is a missing or wrong passphrase
PEP_STATUS try_base_prepare_message(
PEP_SESSION session,
const pEp_identity *me,
const pEp_identity *partner,
base_protocol_type type,
char *payload,
size_t size,
const char *fpr,
message **result
);
#ifdef __cplusplus
}
#endif


+ 1
- 1
sync/gen_statemachine.ysl2 View File

@ -568,7 +568,7 @@ tstylesheet {
switch (message_type) {
`` for "fsm/message[@security='unencrypted' and ../@name!='KeySync']" | #error unencrypted only allowed with KeySync
`` for "fsm/message[@security='unencrypted' and ../@name='KeySync']" |>>> case «../@name»_PR_«yml:mixedCase(@name)»:
status = base_prepare_message(
status = try_base_prepare_message(
session,
li->ident,
li->ident,


Loading…
Cancel
Save