Browse Source

First try empty passphrase. In case no passphrase works notify SYNC_PASSPHRASE_REQUIRED.

doxygen-key-id
Volker Birk 2 years ago
parent
commit
8c5a464e8c
2 changed files with 26 additions and 3 deletions
  1. +22
    -2
      src/message_api.c
  2. +4
    -1
      src/sync_api.h

+ 22
- 2
src/message_api.c View File

@ -5334,12 +5334,32 @@ PEP_STATUS try_encrypt_message(
// 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 = encrypt_message(session, src, extra, dst, enc_format, flags);
session->curr_passphrase = passphrase;
if (!(status == PEP_PASSPHRASE_REQUIRED || status == PEP_WRONG_PASSPHRASE))
return status;
}
do {
// then try passphrases
status = encrypt_message(session, src, extra, dst, enc_format, flags);
if (status == PEP_PASSPHRASE_REQUIRED || status == PEP_WRONG_PASSPHRASE)
if (status == PEP_PASSPHRASE_REQUIRED || status == PEP_WRONG_PASSPHRASE) {
status = session->messageToSend(NULL);
else
if (status == PEP_PASSPHRASE_REQUIRED || status == PEP_WRONG_PASSPHRASE) {
pEp_identity *me = identity_dup(src->from);
if (!me)
return PEP_OUT_OF_MEMORY;
session->notifyHandshake(me, NULL, SYNC_PASSPHRASE_REQUIRED);
break;
}
}
else {
break;
}
} while (!status);
return status;


+ 4
- 1
src/sync_api.h View File

@ -35,6 +35,9 @@ typedef enum _sync_handshake_signal {
// forming group
// SYNC_NOTIFY_FORMING_GROUP = 10,
// message cannot be sent, need passphrase
SYNC_PASSPHRASE_REQUIRED = 128,
// notification of actual group status
SYNC_NOTIFY_SOLE = 254,
SYNC_NOTIFY_IN_GROUP = 255
@ -53,7 +56,7 @@ typedef enum _sync_handshake_signal {
// PEP_STATUS_OK or any other value on error
//
// caveat:
// ownership of self and partner go to the callee
// ownership of me and partner go to the callee
typedef PEP_STATUS (*notifyHandshake_t)(
pEp_identity *me,


Loading…
Cancel
Save