src/key_reset.h
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Wed, 10 Apr 2019 19:17:42 +0200
branchENGINE-536
changeset 3495 b4d3e47eab14
parent 2950 753276eb09ec
child 3498 9c7f5f60094e
permissions -rw-r--r--
ENGINE-536: newly refactored key_reset with new functions in. Passes current tests, but need to check new functions.
krista@2947
     1
// This file is under GNU General Public License 3.0
krista@2947
     2
// see LICENSE.txt
krista@2947
     3
krista@2947
     4
#pragma once
krista@2947
     5
krista@2947
     6
#include "key_reset.h"
krista@2947
     7
krista@2947
     8
#include "pEpEngine.h"
krista@2947
     9
#include "keymanagement.h"
krista@2947
    10
#include "message.h"
krista@2947
    11
#include "message_api.h"
krista@2947
    12
#include "cryptotech.h"
krista@2947
    13
krista@2947
    14
#ifdef __cplusplus
krista@2947
    15
extern "C" {
krista@2947
    16
#endif
krista@2947
    17
krista@3495
    18
// key_reset_identity() - resets trust status for this identity and fpr, and remove
krista@3495
    19
//                        this fpr as a default for all identities and users and from 
krista@3495
    20
//                        the keyring.
krista@3495
    21
//                        
krista@3495
    22
//                        If the fpr is NULL, we will reset the identity default fpr
krista@3495
    23
//                        as above. When that does not exist, then we do it for 
krista@3495
    24
//                        the user default. 
krista@3495
    25
//
krista@3495
    26
//                        For own identities, when the fpr has a private key part,
krista@3495
    27
//                        also revoke the key and communicate the revocation and new key 
krista@3495
    28
//                        to partners we have sent mail to recently from the specific identity 
krista@3495
    29
//                        (i.e. address/user_id) that contacted them. We also in this case 
krista@3495
    30
//                        set up information so that if someone we mail uses the wrong key 
krista@3495
    31
//                        and wasn't yet contacted, we can send them the reset information 
krista@3495
    32
//                        from the right address. 
krista@3495
    33
//
krista@3495
    34
//  parameters:
krista@3495
    35
//      session (in)            session handle
krista@3495
    36
//      fpr (in)                fingerprint of key to reset. If NULL, we reset the default key
krista@3495
    37
//                              this user, if there is one.
krista@3495
    38
//      ident (in)              identity for which the key reset should occur. Must contain 
krista@3495
    39
//                              user_id and address.
krista@3495
    40
//
krista@3495
    41
//                              fpr field will be ignored. Cannot be NULL.
krista@3495
    42
//
krista@3495
    43
//      Note: ident->fpr is always ignored
krista@3495
    44
//
krista@3495
    45
//
krista@3495
    46
DYNAMIC_API PEP_STATUS key_reset_identity(
krista@3495
    47
        PEP_SESSION session,
krista@3495
    48
        const char* fpr,
krista@3495
    49
        pEp_identity* ident
krista@3495
    50
    );
krista@3495
    51
krista@3495
    52
// key_reset_user() - reset the default key database status for each identity 
krista@3495
    53
//                    corresponding to this user and fpr (if present), and remove from 
krista@3495
    54
//                    the keyring. This will also remove the key(s) from all other 
krista@3495
    55
//                    users and identities. If no fpr is present, reset all default keys 
krista@3495
    56
//                    corresponding to this user and its identities.
krista@3495
    57
//           
krista@3495
    58
//                    For own keys, also revoke the key(s) and communicate the 
krista@3495
    59
//                    revocation and new key(s) to partners we have sent mail to 
krista@3495
    60
//                    recently from the specific identities (i.e. address/user_id) 
krista@3495
    61
//                    that contacted them. We also in this case set up information 
krista@3495
    62
//                    so that if someone we mail uses the wrong key and wasn't 
krista@3495
    63
//                    yet contacted, we can send them the reset information 
krista@3495
    64
//                    from the right address.
krista@3495
    65
//
krista@3495
    66
//                    If the user_id is NULL and fpr is NULL, we reset all keys for the own user. 
krista@3495
    67
//
krista@3495
    68
//  parameters:
krista@3495
    69
//      session (in)            session handle
krista@3495
    70
//      fpr (in)                fingerprint of key to reset. If NULL and user_id is NULL,
krista@3495
    71
//                              we reset all keys for the own user. If NULL, we reset all default 
krista@3495
    72
//                              keys for this user and all of its identities.
krista@3495
    73
//      user_id (in)            user_id for which the key reset should occur.
krista@3495
    74
//                              If the user_id is NULL, we reset keys for the own user.
krista@3495
    75
//
krista@3495
    76
DYNAMIC_API PEP_STATUS key_reset_user(
krista@3495
    77
        PEP_SESSION session,
krista@3495
    78
        const char* fpr,
krista@3495
    79
        const char* user_id
krista@3495
    80
    );
krista@3495
    81
krista@2948
    82
// key_reset() - reset the database status for a key, removing all trust information
krista@2948
    83
//               and default database connections. For own keys, also revoke the key
krista@2948
    84
//               and communicate the revocation and new key to partners we have sent
krista@2948
    85
//               mail to recently from the specific identity (i.e. address/user_id)
krista@2948
    86
//               that contacted them. We also in this case set up information so that
krista@2948
    87
//               if someone we mail uses the wrong key and wasn't yet contacted,
krista@2948
    88
//               we can send them the reset information from the right address.
krista@2948
    89
//
krista@2948
    90
//               Can be called manually or through another protocol.
krista@2948
    91
//
krista@2948
    92
//  parameters:
krista@2948
    93
//      session (in)            session handle
krista@2948
    94
//      fpr (in)                fingerprint of key to reset. If NULL and ident is NULL,
krista@2948
    95
//                              we reset all keys for the own user. If NULL and ident is
krista@2948
    96
//                              an own identity, we reset the default key for that
krista@2948
    97
//                              identity. If that own identity has no default key, we
krista@2948
    98
//                              reset the user default.
krista@3495
    99
//                              if it is NULL and there is a non-own identity, we will reset 
krista@3495
   100
//                              the default key for this identity.
krista@2948
   101
//      ident (in)              identity for which the key reset should occur.
krista@2948
   102
//                              if NULL and fpr is non-NULL, we'll reset the key for all
krista@2948
   103
//                              associated identities. If both ident and fpr are NULL, see 
krista@2948
   104
//                              the fpr arg documentation.
krista@2948
   105
//
krista@2950
   106
//      Note: ident->fpr is always ignored
krista@2950
   107
//
krista@3495
   108
// Caveat: this is now used in large part for internal calls.
krista@3495
   109
//         external apps should call key_reset_identity and key_reset_userdata
krista@3495
   110
//         and this function should probably be removed from the dynamic api
krista@3495
   111
PEP_STATUS key_reset(
krista@2947
   112
        PEP_SESSION session,
krista@2947
   113
        const char* fpr,
krista@2947
   114
        pEp_identity* ident
krista@2947
   115
    );
krista@2947
   116
krista@3495
   117
krista@3495
   118
krista@2947
   119
PEP_STATUS has_key_reset_been_sent(
krista@2947
   120
        PEP_SESSION session, 
krista@2947
   121
        const char* user_id, 
krista@2947
   122
        const char* revoked_fpr,
krista@2947
   123
        bool* contacted);
krista@2947
   124
krista@2947
   125
PEP_STATUS set_reset_contact_notified(
krista@2947
   126
        PEP_SESSION session,
krista@2947
   127
        const char* revoke_fpr,
krista@2947
   128
        const char* contact_id
krista@2947
   129
    );
krista@2947
   130
krista@2947
   131
PEP_STATUS receive_key_reset(PEP_SESSION session,
krista@2947
   132
                             message* reset_msg);
krista@2947
   133
krista@2947
   134
PEP_STATUS create_standalone_key_reset_message(PEP_SESSION session,
krista@2947
   135
                                               message** dst, 
krista@2947
   136
                                               pEp_identity* recip,
krista@2947
   137
                                               const char* old_fpr,
krista@2947
   138
                                               const char* new_fpr);
krista@2947
   139
                                               
krista@2947
   140
PEP_STATUS send_key_reset_to_recents(PEP_SESSION session,
krista@2947
   141
                                     const char* old_fpr, 
krista@2947
   142
                                     const char* new_fpr);
krista@2947
   143
    
krista@2947
   144
#ifdef __cplusplus
krista@2947
   145
}
krista@2947
   146
#endif