src/pgp_gpg.h
author Volker Birk <vb@pep.foundation>
Sat, 15 Sep 2018 14:36:03 +0200
branchsync
changeset 2945 8c2cc198fc8d
parent 2458 2dfe65bd3613
child 2946 bacb52cb79d0
permissions -rw-r--r--
beginning with documentation of PGP backend
vb@1513
     1
// This file is under GNU General Public License 3.0
vb@1513
     2
// see LICENSE.txt
vb@1513
     3
vb@24
     4
#pragma once
vb@24
     5
vb@24
     6
#include "pEpEngine.h"
vb@24
     7
vb@2945
     8
vb@2945
     9
// pgp_init(): initialize PGP backend
vb@2945
    10
//
vb@2945
    11
//  parameters:
vb@2945
    12
//      session (in)        session handle
vb@2945
    13
//      in_first (in)       true if this is the first session
vb@2945
    14
//
vb@2945
    15
//  return value:
vb@2945
    16
//      PEP_STATUS_OK if PGP backend was successfully initialized
vb@2945
    17
//      or any other value on error
vb@2945
    18
vb@62
    19
PEP_STATUS pgp_init(PEP_SESSION session, bool in_first);
vb@2945
    20
vb@2945
    21
vb@2945
    22
// pgp_release(): release PGP backend
vb@2945
    23
//
vb@2945
    24
//  paramters:
vb@2945
    25
//      session (in)        session handle
vb@2945
    26
//      out_last (in)       true if this is the last session to release
vb@2945
    27
vb@62
    28
void pgp_release(PEP_SESSION session, bool out_last);
vb@24
    29
vb@2945
    30
vb@2945
    31
// pgp_decrypt_and_verify(): decrypt and verify cyphertext
vb@2945
    32
//
vb@2945
    33
//  parameters:
vb@2945
    34
//      session (in)        session handle
vb@2945
    35
//      ctext (in)          bytes with ciphertext
vb@2945
    36
//      csize (in)          size of ciphertext in bytes
vb@2945
    37
//      dsigtext (in)       pointer to bytes with detached signature
vb@2945
    38
//                          or NULL if no detached signature
vb@2945
    39
//      dsigsize (in)       size of detached signature in bytes
vb@2945
    40
//      ptext (out)         pointer to receive plaintext
vb@2945
    41
//      psize (out)         size of plaintext delivered
vb@2945
    42
//      keylist (out)       list of keys being used
vb@2945
    43
vb@24
    44
PEP_STATUS pgp_decrypt_and_verify(
vb@2945
    45
        PEP_SESSION session,
vb@2945
    46
        const char *ctext,
vb@2945
    47
        size_t csize,
vb@2945
    48
        const char *dsigtext,
vb@2945
    49
        size_t dsigsize,
vb@2945
    50
        char **ptext,
vb@2945
    51
        size_t *psize,
vb@2945
    52
        stringlist_t **keylist
vb@24
    53
    );
vb@24
    54
vb@2945
    55
vb@24
    56
PEP_STATUS pgp_encrypt_and_sign(
vb@2945
    57
        PEP_SESSION session,
vb@2945
    58
        const stringlist_t *keylist,
vb@2945
    59
        const char *ptext,
vb@2945
    60
        size_t psize,
vb@2945
    61
        char **ctext,
vb@2945
    62
        size_t *csize
vb@24
    63
    );
vb@24
    64
krista@1639
    65
PEP_STATUS pgp_encrypt_only(
vb@2945
    66
        PEP_SESSION session,
vb@2945
    67
        const stringlist_t *keylist,
vb@2945
    68
        const char *ptext,
vb@2945
    69
        size_t psize,
vb@2945
    70
        char **ctext,
vb@2945
    71
        size_t *csize
krista@1639
    72
    );
krista@1639
    73
krista@1639
    74
vb@24
    75
PEP_STATUS pgp_verify_text(
vb@2945
    76
        PEP_SESSION session,
vb@2945
    77
        const char *text,
vb@2945
    78
        size_t size,
vb@2945
    79
        const char *signature,
vb@2945
    80
        size_t sig_size,
vb@2945
    81
        stringlist_t **keylist
vb@24
    82
    );
vb@24
    83
vb@24
    84
PEP_STATUS pgp_delete_keypair(PEP_SESSION session, const char *fpr);
vb@24
    85
Edouard@170
    86
PEP_STATUS pgp_export_keydata(
vb@2945
    87
        PEP_SESSION session,
vb@2945
    88
        const char *fpr,
vb@2945
    89
        char **key_data,
vb@2945
    90
        size_t *size,
vb@1103
    91
        bool secret
vb@24
    92
    );
vb@24
    93
vb@24
    94
PEP_STATUS pgp_find_keys(
vb@2945
    95
        PEP_SESSION session,
vb@2945
    96
        const char *pattern,
vb@2945
    97
        stringlist_t **keylist
vb@24
    98
    );
vb@24
    99
krista@1030
   100
PEP_STATUS pgp_list_keyinfo(
vb@2945
   101
        PEP_SESSION session,
vb@2945
   102
        const char* pattern,
vb@2945
   103
        stringpair_list_t** keyinfo_list
krista@1030
   104
    );
krista@1030
   105
vb@24
   106
PEP_STATUS pgp_generate_keypair(
vb@2945
   107
        PEP_SESSION session,
vb@2945
   108
        pEp_identity *identity
vb@24
   109
    );
vb@24
   110
vb@24
   111
PEP_STATUS pgp_get_key_rating(
vb@74
   112
        PEP_SESSION session,
vb@74
   113
        const char *fpr,
vb@74
   114
        PEP_comm_type *comm_type
vb@24
   115
    );
vb@24
   116
vb@2945
   117
PEP_STATUS pgp_import_keydata(
vb@2945
   118
        PEP_SESSION session,
vb@2945
   119
        const char *key_data,
vb@2945
   120
        size_t size,
vb@2945
   121
        identity_list **private_idents
vb@2945
   122
    );
Edouard@728
   123
vb@2945
   124
PEP_STATUS pgp_import_private_keydata(
vb@2945
   125
        PEP_SESSION session,
vb@2945
   126
        const char *key_data,
vb@2945
   127
        size_t size,
vb@2945
   128
        identity_list **private_idents
vb@2945
   129
    );
vb@24
   130
vb@24
   131
PEP_STATUS pgp_recv_key(PEP_SESSION session, const char *pattern);
vb@2945
   132
vb@200
   133
PEP_STATUS pgp_send_key(PEP_SESSION session, const char *pattern);
vb@201
   134
vb@201
   135
PEP_STATUS pgp_renew_key(
vb@201
   136
        PEP_SESSION session,
vb@201
   137
        const char *fpr,
vb@201
   138
        const timestamp *ts
vb@201
   139
    );
vb@201
   140
vb@211
   141
PEP_STATUS pgp_revoke_key(
vb@211
   142
        PEP_SESSION session,
vb@211
   143
        const char *fpr,
vb@211
   144
        const char *reason
vb@211
   145
    );
vb@24
   146
vb@214
   147
PEP_STATUS pgp_key_expired(
vb@214
   148
        PEP_SESSION session,
vb@214
   149
        const char *fpr,
Edouard@701
   150
        const time_t when,
vb@214
   151
        bool *expired
vb@214
   152
    );
vb@214
   153
Edouard@662
   154
PEP_STATUS pgp_key_revoked(
Edouard@662
   155
        PEP_SESSION session,
Edouard@662
   156
        const char *fpr,
Edouard@662
   157
        bool *revoked
Edouard@662
   158
    );
Edouard@662
   159
vb@958
   160
PEP_STATUS pgp_key_created(
vb@958
   161
        PEP_SESSION session,
vb@958
   162
        const char *fpr,
vb@958
   163
        time_t *created
vb@958
   164
    );
vb@958
   165
krista@1357
   166
PEP_STATUS pgp_contains_priv_key(
krista@1357
   167
        PEP_SESSION session, 
krista@1357
   168
        const char *fpr,
vb@2945
   169
        bool *has_private
vb@2945
   170
    );
krista@1357
   171
krista@1357
   172
PEP_STATUS pgp_find_private_keys(
vb@2945
   173
        PEP_SESSION session,
vb@2945
   174
        const char *pattern,
vb@2945
   175
        stringlist_t **keylist
vb@2945
   176
    );
krista@1357
   177
vb@507
   178
PEP_STATUS pgp_binary(const char **path);
krista@1924
   179
krista@2458
   180
// Returns first failure status, if there were any. Keys may have been
krista@2458
   181
// imported into DB regardless of status.
vb@2945
   182
krista@2458
   183
PEP_STATUS pgp_import_ultimately_trusted_keypairs(PEP_SESSION session);
krista@2458
   184
krista@1924
   185
/* Really only internal. */
krista@1924
   186
PEP_STATUS pgp_replace_only_uid(
krista@1924
   187
        PEP_SESSION session,
krista@1924
   188
        const char* fpr,
krista@1924
   189
        const char* realname,
krista@1924
   190
        const char* email
krista@1924
   191
    );
krista@1924
   192
vb@507
   193
#define PGP_BINARY_PATH pgp_binary