try_base_prepare_message() for signing

doxygen-key-id archive/ENGINE-764
Volker Birk 3 years ago
parent 8c5a464e8c
commit d93e9646bc

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

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

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