src/cryptotech.h
author Krista Bennett <krista@pep-project.org>
Fri, 01 Jun 2018 10:30:19 +0200
branchENGINE-254
changeset 2723 7194b9c8599d
parent 1639 be84d676f3ef
child 1673 559931685411
child 2458 2dfe65bd3613
permissions -rw-r--r--
close branch
vb@1513
     1
// This file is under GNU General Public License 3.0
vb@1513
     2
// see LICENSE.txt
vb@1513
     3
vb@23
     4
#pragma once
vb@23
     5
vb@23
     6
#include "pEpEngine.h"
krista@1397
     7
#include "bloblist.h"
vb@23
     8
vb@23
     9
typedef enum _PEP_cryptotech {
vb@23
    10
    PEP_crypt_none = 0,
vb@24
    11
    PEP_crypt_OpenPGP,
vb@24
    12
    //    PEP_ctypt_PEP,
vb@24
    13
    //    PEP_crypt_SMIME,
vb@24
    14
    //    PEP_crypt_CMS,
vb@23
    15
vb@23
    16
    PEP_crypt__count
vb@25
    17
} PEP_cryptotech;
vb@23
    18
vb@23
    19
typedef PEP_STATUS (*decrypt_and_verify_t)(
vb@48
    20
        PEP_SESSION session, const char *ctext, size_t csize,
krista@1397
    21
        const char *dsigtext, size_t dsigsize,
vb@48
    22
        char **ptext, size_t *psize, stringlist_t **keylist
vb@23
    23
    );
vb@23
    24
vb@23
    25
typedef PEP_STATUS (*verify_text_t)(
vb@48
    26
        PEP_SESSION session, const char *text, size_t size,
vb@48
    27
        const char *signature, size_t sig_size, stringlist_t **keylist
vb@23
    28
    );
vb@23
    29
vb@23
    30
typedef PEP_STATUS (*encrypt_and_sign_t)(
vb@48
    31
        PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
vb@48
    32
        size_t psize, char **ctext, size_t *csize
vb@23
    33
    );
vb@23
    34
krista@1639
    35
typedef PEP_STATUS (*encrypt_only_t)(
krista@1639
    36
        PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
krista@1639
    37
        size_t psize, char **ctext, size_t *csize
krista@1639
    38
    );
krista@1639
    39
vb@24
    40
typedef PEP_STATUS (*delete_keypair_t)(PEP_SESSION session, const char *fpr);
vb@24
    41
vb@24
    42
typedef PEP_STATUS (*export_key_t)(
vb@1103
    43
        PEP_SESSION session, const char *fpr, char **key_data, size_t *size,
vb@1103
    44
        bool secret
vb@24
    45
    );
vb@24
    46
vb@24
    47
typedef PEP_STATUS (*find_keys_t)(
vb@48
    48
        PEP_SESSION session, const char *pattern, stringlist_t **keylist
vb@24
    49
    );
vb@24
    50
vb@24
    51
typedef PEP_STATUS (*generate_keypair_t)(
vb@48
    52
        PEP_SESSION session, pEp_identity *identity
vb@24
    53
    );
vb@24
    54
vb@24
    55
typedef PEP_STATUS (*get_key_rating_t)(
vb@48
    56
        PEP_SESSION session,
vb@48
    57
        const char *fpr,
vb@48
    58
        PEP_comm_type *comm_type
vb@24
    59
    );
vb@24
    60
vb@201
    61
typedef PEP_STATUS (*import_key_t)(PEP_SESSION session, const char *key_data,
Edouard@728
    62
        size_t size, identity_list **private_keys);
vb@24
    63
vb@24
    64
typedef PEP_STATUS (*recv_key_t)(PEP_SESSION session, const char *pattern);
vb@24
    65
vb@24
    66
typedef PEP_STATUS (*send_key_t)(PEP_SESSION session, const char *pattern);
vb@24
    67
vb@214
    68
typedef PEP_STATUS (*renew_key_t)(PEP_SESSION session, const char *fpr,
vb@201
    69
        const timestamp *ts);
vb@200
    70
vb@214
    71
typedef PEP_STATUS (*revoke_key_t)(PEP_SESSION session, const char *fpr,
vb@211
    72
        const char *reason);
vb@200
    73
vb@214
    74
typedef PEP_STATUS (*key_expired_t)(PEP_SESSION session, const char *fpr,
Edouard@701
    75
        const time_t when, bool *expired);
vb@214
    76
Edouard@539
    77
typedef PEP_STATUS (*key_revoked_t)(PEP_SESSION session, const char *fpr,
vb@958
    78
        bool *revoked);
vb@958
    79
vb@958
    80
typedef PEP_STATUS (*key_created_t)(PEP_SESSION session, const char *fpr,
vb@958
    81
        time_t *created);
Edouard@539
    82
vb@507
    83
typedef PEP_STATUS (*binary_path_t)(const char **path);
vb@507
    84
krista@1357
    85
typedef PEP_STATUS (*contains_priv_key_t)(PEP_SESSION session, const char *fpr,
krista@1352
    86
        bool *has_private);
krista@1352
    87
krista@1357
    88
typedef PEP_STATUS (*find_private_keys_t)(
krista@1357
    89
    PEP_SESSION session, const char *pattern, stringlist_t **keylist
krista@1357
    90
);
krista@1357
    91
vb@23
    92
typedef struct _PEP_cryptotech_t {
vb@23
    93
    uint8_t id;
vb@24
    94
    // the following are default values; comm_type may vary with key length or b0rken crypto
vb@24
    95
    uint8_t unconfirmed_comm_type;
vb@24
    96
    uint8_t confirmed_comm_type;
vb@23
    97
    decrypt_and_verify_t decrypt_and_verify;
vb@23
    98
    verify_text_t verify_text;
vb@23
    99
    encrypt_and_sign_t encrypt_and_sign;
krista@1639
   100
    encrypt_only_t encrypt_only;
vb@24
   101
    delete_keypair_t delete_keypair;
vb@24
   102
    export_key_t export_key;
vb@24
   103
    find_keys_t find_keys;
vb@24
   104
    generate_keypair_t generate_keypair;
vb@24
   105
    get_key_rating_t get_key_rating;
vb@24
   106
    import_key_t import_key;
vb@24
   107
    recv_key_t recv_key;
vb@24
   108
    send_key_t send_key;
vb@200
   109
    renew_key_t renew_key;
vb@200
   110
    revoke_key_t revoke_key;
vb@214
   111
    key_expired_t key_expired;
Edouard@539
   112
    key_revoked_t key_revoked;
vb@958
   113
    key_created_t key_created;
vb@507
   114
    binary_path_t binary_path;
krista@1357
   115
    contains_priv_key_t contains_priv_key;
krista@1357
   116
    find_private_keys_t find_private_keys;
vb@23
   117
} PEP_cryptotech_t;
vb@23
   118
vb@259
   119
extern PEP_cryptotech_t cryptotech[PEP_crypt__count];
vb@259
   120
vb@23
   121
typedef uint64_t cryptotech_mask;
vb@28
   122
vb@62
   123
PEP_STATUS init_cryptotech(PEP_SESSION session, bool in_first);
vb@62
   124
void release_cryptotech(PEP_SESSION session, bool out_last);