src/baseprotocol.h
author us@chu.huenfield.org
Tue, 25 Dec 2018 14:46:45 +0100
branchsync
changeset 3209 c15b4ca2b52a
parent 3143 81c80e27cbf7
child 3393 ecdb1635904a
permissions -rw-r--r--
Replace use of Sequoia's backend with a custom key store.

- Sequoia's key store doesn't meet pep's needs (in particular, the
ability to search on a key's user id) and trying to shoehorn pep's
needs onto Sequoia's key store abstractions is just introducing
overhead with no appreciable gain in functionality.

- This patch changes the Sequoia backend to use a local sqlite
database to store the public keys.
     1 // This file is under GNU General Public License 3.0
     2 // see LICENSE.txt
     3 
     4 #pragma once
     5 
     6 #include "message.h"
     7 
     8 #ifdef __cplusplus
     9 extern "C" {
    10 #endif
    11 
    12 
    13 // base_decorate_message() - decorate a message with payload
    14 //
    15 //  parameters:
    16 //      session (in)    session handle
    17 //      msg (inout)     message to decorate
    18 //      payload (in)    payload to send
    19 //      size (in)       size of payload
    20 //      fpr (in)        optional key to sign or NULL
    21 //
    22 //  returns:
    23 //      PEP_STATUS_OK and result on success or an error on failure
    24 //
    25 //  caveat:
    26 //      on success (and only then) payload goes to the ownership of the msg
    27 //      the ownership of the msg remains with the caller
    28 
    29 PEP_STATUS base_decorate_message(
    30         PEP_SESSION session,
    31         message *msg,
    32         char *payload,
    33         size_t size,
    34         char *fpr
    35     );
    36 
    37 
    38 // base_prepare_message() - prepare a sync message with payload
    39 //
    40 //  parameters:
    41 //      session (in)    session handle
    42 //      me (in)         identity to use for the sender
    43 //      partner (in)    identity to use for the receiver
    44 //      payload (in)    payload to send
    45 //      size (in)       size of payload
    46 //      fpr (in)        optional key to sign or NULL
    47 //      result (out)    message with payload
    48 //
    49 //  returns:
    50 //      PEP_STATUS_OK and result on success or an error on failure
    51 //
    52 //  caveat:
    53 //      on success (and only then) payload goes to the ownership of the result
    54 //      the ownership of the result goes to the caller
    55 
    56 PEP_STATUS base_prepare_message(
    57         PEP_SESSION session,
    58         const pEp_identity *me,
    59         const pEp_identity *partner,
    60         char *payload,
    61         size_t size,
    62         char *fpr,
    63         message **result
    64     );
    65 
    66 
    67 // base_extract_message() - extract a sync message from a pEp message
    68 //
    69 //  parameters:
    70 //      session (in)    session handle
    71 //      msg (in)        message to analyze
    72 //      size (out)      size of extracted payload or 0 if not found
    73 //      payload (out)   extraced payload
    74 //      fpr (out)       if message was correctly signed then fpr of signature's
    75 //                      key, otherwise NULL
    76 //
    77 //  returns:
    78 //      PEP_STATUS_OK and payload == NULL if no sync message
    79 //      PEP_STATUS_OK and payload, size if sync message found
    80 //      any other value on error
    81 //
    82 //  caveat:
    83 //      payload may point to msg attachment, the ownership does not change
    84 //      if fpr != NULL the ownership goes to the caller
    85 
    86 PEP_STATUS base_extract_message(
    87         PEP_SESSION session,
    88         message *msg,
    89         size_t *size,
    90         const char **payload,
    91         char **fpr
    92     );
    93 
    94 
    95 #ifdef __cplusplus
    96 }
    97 #endif
    98