src/keymanagement.h
author Edouard Tisserant <edouard@pep-project.org>
Thu, 10 Nov 2016 21:10:24 +0100
changeset 1370 274b7141afb6
parent 1365 9e45d9a7583b
child 1381 f84211f27e5b
permissions -rw-r--r--
ENGINE-140: merged
vb@39
     1
#pragma once
vb@39
     2
vb@217
     3
#include "pEpEngine.h"
vb@217
     4
vb@0
     5
#ifdef __cplusplus
vb@0
     6
extern "C" {
vb@0
     7
#endif
vb@0
     8
vb@1360
     9
PEP_STATUS _update_identity(
vb@1360
    10
        PEP_SESSION session, pEp_identity * identity, bool with_myself
vb@1360
    11
    );
vb@1360
    12
vb@0
    13
// update_identity() - update identity information
vb@0
    14
//
vb@0
    15
//  parameters:
vb@0
    16
//      session (in)        session to use
vb@0
    17
//      identity (inout)    identity information of communication partner
krista@1220
    18
//                          (identity->fpr is OUT ONLY)
vb@0
    19
//  caveat:
vb@10
    20
//      if this function returns PEP_ct_unknown or PEP_ct_key_expired in
vb@10
    21
//      identity->comm_type, the caller must insert the identity into the
vb@10
    22
//      asynchronous management implementation, so retrieve_next_identity()
vb@10
    23
//      will return this identity later
vb@21
    24
//      at least identity->address must be a non-empty UTF-8 string as input
vb@932
    25
//      update_identity() never writes flags; use set_identity_flags() for
vb@932
    26
//      writing
krista@1220
    27
//      this function NEVER reads the incoming fpr, only writes to it.
vb@0
    28
vb@0
    29
DYNAMIC_API PEP_STATUS update_identity(
vb@0
    30
        PEP_SESSION session, pEp_identity * identity
vb@0
    31
    );
vb@0
    32
vb@0
    33
vb@0
    34
// myself() - ensures that the own identity is being complete
vb@0
    35
//
vb@0
    36
//  parameters:
vb@0
    37
//      session (in)        session to use
vb@0
    38
//      identity (inout)    identity of local user
vb@0
    39
//                          at least .address, .username, .user_id must be set
vb@0
    40
//
vb@0
    41
//  return value:
vb@0
    42
//      PEP_STATUS_OK if identity could be completed or was already complete,
vb@0
    43
//      any other value on error
vb@0
    44
//
vb@0
    45
//  caveat:
vb@0
    46
//      this function generates a keypair on demand; because it's synchronous
vb@0
    47
//      it can need a decent amount of time to return
vb@0
    48
//      if you need to do this asynchronous, you need to return an identity
vb@0
    49
//      with retrieve_next_identity() where pEp_identity.me is true
vb@932
    50
//      myself() never writes flags; use set_identity_flags() for writing
vb@0
    51
vb@0
    52
DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity);
vb@0
    53
vb@0
    54
vb@0
    55
// retrieve_next_identity() - callback being called by do_keymanagement()
vb@0
    56
//
vb@0
    57
//  parameters:
vb@0
    58
//      management (in)     data structure to deliver (implementation defined)
vb@0
    59
//
vb@0
    60
//  return value:
vb@0
    61
//      identity to check or NULL to terminate do_keymanagement()
vb@0
    62
//      if given identity must be created with new_identity()
vb@0
    63
//      the identity struct is going to the ownership of this library
vb@0
    64
//      it must not be freed by the callee
vb@0
    65
//
vb@0
    66
//  caveat:
vb@0
    67
//      this callback has to block until an identity or NULL can be returned
vb@0
    68
//      an implementation is not provided by this library; instead it has to be
vb@0
    69
//      implemented by the user of this library
vb@0
    70
vb@0
    71
typedef pEp_identity *(*retrieve_next_identity_t)(void *management);
vb@0
    72
vb@0
    73
vb@292
    74
// examine_identity() - callback for appending to queue
vb@292
    75
//
vb@292
    76
//  parameters:
vb@292
    77
//      ident (in)          identity to examine
vb@292
    78
//      management (in)     data structure to deliver (implementation defined)
vb@292
    79
//
vb@292
    80
//  return value:
vb@292
    81
//      0 if identity was added successfully to queue or nonzero otherwise
vb@292
    82
vb@296
    83
typedef int (*examine_identity_t)(pEp_identity *ident, void *management);
vb@292
    84
vb@292
    85
vb@292
    86
// register_examine_function() - register examine_identity() callback
vb@292
    87
//
vb@292
    88
//  parameters:
vb@292
    89
//      session (in)            session to use
vb@292
    90
//      examine_identity (in)   examine_identity() function to register
vb@292
    91
//      management (in)     data structure to deliver (implementation defined)
vb@292
    92
vb@296
    93
DYNAMIC_API PEP_STATUS register_examine_function(
vb@292
    94
        PEP_SESSION session, 
vb@292
    95
        examine_identity_t examine_identity,
vb@292
    96
        void *management
vb@292
    97
    );
vb@292
    98
vb@292
    99
vb@0
   100
// do_keymanagement() - function to be run on an extra thread
vb@0
   101
//
vb@0
   102
//  parameters:
vb@0
   103
//      retrieve_next_identity  pointer to retrieve_next_identity() callback
vb@0
   104
//                              which returns at least a valid address field in
vb@0
   105
//                              the identity struct
vb@0
   106
//      management              management data to give to keymanagement
vb@0
   107
//                              (implementation defined)
vb@0
   108
//
vb@0
   109
//  return value:
vb@0
   110
//      PEP_STATUS_OK if thread has to terminate successfully or any other
vb@0
   111
//      value on failure
vb@0
   112
//
vb@0
   113
//  caveat:
vb@0
   114
//      to ensure proper working of this library, a thread has to be started
vb@0
   115
//      with this function immediately after initialization
vb@0
   116
//      do_keymanagement() calls retrieve_next_identity(management)
vb@0
   117
vb@0
   118
DYNAMIC_API PEP_STATUS do_keymanagement(
vb@0
   119
        retrieve_next_identity_t retrieve_next_identity,
vb@0
   120
        void *management
vb@0
   121
    );
vb@0
   122
vb@215
   123
krista@1213
   124
// key_mistrusted() - mark key as being compromized
vb@215
   125
//
vb@215
   126
//  parameters:
vb@215
   127
//      session (in)        session to use
vb@357
   128
//      ident (in)          person and key which was compromized
vb@215
   129
krista@1213
   130
DYNAMIC_API PEP_STATUS key_mistrusted(
vb@357
   131
        PEP_SESSION session,
vb@357
   132
        pEp_identity *ident
vb@357
   133
    );
vb@215
   134
vb@215
   135
vb@354
   136
// trust_personal_key() - mark a key as trusted with a person
vb@354
   137
//
vb@354
   138
//  parameters:
vb@354
   139
//      session (in)        session to use
vb@354
   140
//      ident (in)          person and key to trust in
vb@354
   141
//
vb@354
   142
//  caveat:
vb@354
   143
//      the fields user_id, address and fpr must be supplied
vb@354
   144
vb@354
   145
DYNAMIC_API PEP_STATUS trust_personal_key(
vb@354
   146
        PEP_SESSION session,
vb@354
   147
        pEp_identity *ident
vb@354
   148
    );
vb@354
   149
vb@354
   150
krista@1213
   151
// key_reset_trust() - undo trust_personal_key and key_mistrusted() for keys
vb@421
   152
//                     we don't own
Edouard@410
   153
//
Edouard@410
   154
//  parameters:
Edouard@410
   155
//      session (in)        session to use
Edouard@410
   156
//      ident (in)          person and key which was compromized
Edouard@410
   157
Edouard@410
   158
DYNAMIC_API PEP_STATUS key_reset_trust(
Edouard@410
   159
        PEP_SESSION session,
Edouard@410
   160
        pEp_identity *ident
Edouard@410
   161
    );
Edouard@410
   162
Edouard@584
   163
Edouard@584
   164
// own_key_is_listed() - returns true id key is listed as own key
Edouard@584
   165
//
Edouard@584
   166
//  parameters:
Edouard@584
   167
//      session (in)        session to use
Edouard@584
   168
//      fpr (in)            fingerprint of key to test
Edouard@584
   169
//      bool (out)          flags if key is own
Edouard@584
   170
Edouard@584
   171
DYNAMIC_API PEP_STATUS own_key_is_listed(
Edouard@584
   172
        PEP_SESSION session,
Edouard@584
   173
        const char *fpr,
Edouard@584
   174
        bool *listed
Edouard@584
   175
    );
Edouard@584
   176
Edouard@584
   177
vb@955
   178
// own_identities_retrieve() - retrieve all own identities
Edouard@584
   179
//
Edouard@584
   180
//  parameters:
vb@955
   181
//      session (in)            session to use
vb@955
   182
//      own_identities (out)    list of own identities
Edouard@584
   183
//
Edouard@584
   184
//  caveat:
vb@1133
   185
//      the ownership of the copy of own_identities goes to the caller
Edouard@584
   186
vb@955
   187
DYNAMIC_API PEP_STATUS own_identities_retrieve(
Edouard@584
   188
        PEP_SESSION session,
vb@955
   189
        identity_list **own_identities
Edouard@584
   190
    );
Edouard@410
   191
edouard@1370
   192
// keys_retrieve_by_flag() - retrieve all flagged keypair fingerprints 
edouard@1370
   193
//
edouard@1370
   194
//  parameters:
edouard@1370
   195
//      session (in)            session to use
edouard@1370
   196
//      flags                   flags to compare pgp keypair's flags to
edouard@1370
   197
//      keylist (out)           list of fingerprints
edouard@1370
   198
//
edouard@1370
   199
//  caveat:
edouard@1370
   200
//      the ownership of the list goes to the caller
edouard@1370
   201
DYNAMIC_API PEP_STATUS keys_retrieve_by_flag(
edouard@1370
   202
        PEP_SESSION session,
edouard@1370
   203
        keypair_flags_t flags,
edouard@1370
   204
        stringlist_t **keylist
edouard@1370
   205
      );
edouard@1370
   206
vb@0
   207
#ifdef __cplusplus
vb@0
   208
}
vb@0
   209
#endif
vb@0
   210