src/keymanagement.h
author Volker Birk <vb@pep-project.org>
Tue, 21 Apr 2015 15:40:18 +0200
changeset 215 fac4aa582acf
parent 39 66b5cc6cb987
child 217 8c084a84b4cd
permissions -rw-r--r--
DEBUG_LOG() for keymanagement
vb@39
     1
#pragma once
vb@39
     2
vb@0
     3
#ifdef __cplusplus
vb@0
     4
extern "C" {
vb@0
     5
#endif
vb@0
     6
vb@0
     7
// update_identity() - update identity information
vb@0
     8
//
vb@0
     9
//  parameters:
vb@0
    10
//      session (in)        session to use
vb@0
    11
//      identity (inout)    identity information of communication partner
vb@0
    12
//
vb@0
    13
//  caveat:
vb@10
    14
//      if this function returns PEP_ct_unknown or PEP_ct_key_expired in
vb@10
    15
//      identity->comm_type, the caller must insert the identity into the
vb@10
    16
//      asynchronous management implementation, so retrieve_next_identity()
vb@10
    17
//      will return this identity later
vb@21
    18
//      at least identity->address must be a non-empty UTF-8 string as input
vb@0
    19
vb@0
    20
DYNAMIC_API PEP_STATUS update_identity(
vb@0
    21
        PEP_SESSION session, pEp_identity * identity
vb@0
    22
    );
vb@0
    23
vb@0
    24
vb@0
    25
// myself() - ensures that the own identity is being complete
vb@0
    26
//
vb@0
    27
//  parameters:
vb@0
    28
//      session (in)        session to use
vb@0
    29
//      identity (inout)    identity of local user
vb@0
    30
//                          at least .address, .username, .user_id must be set
vb@0
    31
//
vb@0
    32
//  return value:
vb@0
    33
//      PEP_STATUS_OK if identity could be completed or was already complete,
vb@0
    34
//      any other value on error
vb@0
    35
//
vb@0
    36
//  caveat:
vb@0
    37
//      this function generates a keypair on demand; because it's synchronous
vb@0
    38
//      it can need a decent amount of time to return
vb@0
    39
//      if you need to do this asynchronous, you need to return an identity
vb@0
    40
//      with retrieve_next_identity() where pEp_identity.me is true
vb@0
    41
vb@0
    42
DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity);
vb@0
    43
vb@0
    44
vb@0
    45
// retrieve_next_identity() - callback being called by do_keymanagement()
vb@0
    46
//
vb@0
    47
//  parameters:
vb@0
    48
//      management (in)     data structure to deliver (implementation defined)
vb@0
    49
//
vb@0
    50
//  return value:
vb@0
    51
//      identity to check or NULL to terminate do_keymanagement()
vb@0
    52
//      if given identity must be created with new_identity()
vb@0
    53
//      the identity struct is going to the ownership of this library
vb@0
    54
//      it must not be freed by the callee
vb@0
    55
//
vb@0
    56
//  caveat:
vb@0
    57
//      this callback has to block until an identity or NULL can be returned
vb@0
    58
//      an implementation is not provided by this library; instead it has to be
vb@0
    59
//      implemented by the user of this library
vb@0
    60
vb@0
    61
typedef pEp_identity *(*retrieve_next_identity_t)(void *management);
vb@0
    62
vb@0
    63
vb@0
    64
// do_keymanagement() - function to be run on an extra thread
vb@0
    65
//
vb@0
    66
//  parameters:
vb@0
    67
//      retrieve_next_identity  pointer to retrieve_next_identity() callback
vb@0
    68
//                              which returns at least a valid address field in
vb@0
    69
//                              the identity struct
vb@0
    70
//      management              management data to give to keymanagement
vb@0
    71
//                              (implementation defined)
vb@0
    72
//
vb@0
    73
//  return value:
vb@0
    74
//      PEP_STATUS_OK if thread has to terminate successfully or any other
vb@0
    75
//      value on failure
vb@0
    76
//
vb@0
    77
//  caveat:
vb@0
    78
//      to ensure proper working of this library, a thread has to be started
vb@0
    79
//      with this function immediately after initialization
vb@0
    80
//      do_keymanagement() calls retrieve_next_identity(management)
vb@0
    81
vb@0
    82
DYNAMIC_API PEP_STATUS do_keymanagement(
vb@0
    83
        retrieve_next_identity_t retrieve_next_identity,
vb@0
    84
        void *management
vb@0
    85
    );
vb@0
    86
vb@215
    87
vb@215
    88
// key_compromized() - mark key as being compromized
vb@215
    89
//
vb@215
    90
//  parameters:
vb@215
    91
//      session (in)        session to use
vb@215
    92
//      fpr (in)            key which was compromized
vb@215
    93
vb@215
    94
DYNAMIC_API PEP_STATUS key_compromized(PEP_SESSION session, const char *fpr);
vb@215
    95
vb@215
    96
vb@0
    97
#ifdef __cplusplus
vb@0
    98
}
vb@0
    99
#endif
vb@0
   100